GstEnginePipeline: Convert S24_32LE for analyzer
This commit is contained in:
@@ -888,6 +888,7 @@ void GstEngine::UpdateScope(const int chunk_length) {
|
||||
if (buffer_format_.startsWith("S16LE") ||
|
||||
buffer_format_.startsWith("U16LE") ||
|
||||
buffer_format_.startsWith("S24LE") ||
|
||||
buffer_format_.startsWith("S24_32LE") ||
|
||||
buffer_format_.startsWith("S32LE") ||
|
||||
buffer_format_.startsWith("F32LE")
|
||||
) {
|
||||
|
||||
@@ -704,6 +704,31 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
|
||||
|
||||
instance->logged_unsupported_analyzer_format_ = false;
|
||||
}
|
||||
else if (format.startsWith("S24_32LE")) {
|
||||
|
||||
GstMapInfo map_info;
|
||||
gst_buffer_map(buf, &map_info, GST_MAP_READ);
|
||||
|
||||
int32_t *s32 = reinterpret_cast<int32_t*>(map_info.data);
|
||||
int32_t *s32e = s32 + map_info.size;
|
||||
int32_t *s32p = s32;
|
||||
int samples = static_cast<int>((map_info.size / sizeof(int32_t)) / channels);
|
||||
int buf16_size = samples * static_cast<int>(sizeof(int16_t)) * channels;
|
||||
int16_t *s16 = static_cast<int16_t*>(g_malloc(buf16_size));
|
||||
memset(s16, 0, buf16_size);
|
||||
for (int i = 0; i < (samples * channels); ++i) {
|
||||
char *s24 = reinterpret_cast<char*>(s32p);
|
||||
s16[i] = *(reinterpret_cast<int16_t*>(s24+1));
|
||||
++s32p;
|
||||
if (s32p > s32e) break;
|
||||
}
|
||||
gst_buffer_unmap(buf, &map_info);
|
||||
buf16 = gst_buffer_new_wrapped(s16, buf16_size);
|
||||
GST_BUFFER_DURATION(buf16) = GST_FRAMES_TO_CLOCK_TIME(samples * sizeof(int16_t) * channels, rate);
|
||||
buf = buf16;
|
||||
|
||||
instance->logged_unsupported_analyzer_format_ = false;
|
||||
}
|
||||
else if (!instance->logged_unsupported_analyzer_format_) {
|
||||
instance->logged_unsupported_analyzer_format_ = true;
|
||||
qLog(Error) << "Unsupported audio format for the analyzer" << format;
|
||||
|
||||
Reference in New Issue
Block a user