[FFmpeg-devel] [PATCH 3/3] avcodec/aacdec_template: log the element order before/after reordering

Jan Ekström jeebjp at gmail.com
Tue Aug 18 22:25:38 EEST 2020


This was quite useful to verify that 22.2 got properly handled,
among other things.
---
 libavcodec/aacdec_template.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 1e112ccf76..4662bbe41a 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -263,6 +263,22 @@ static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos,
     return num_pos_channels;
 }
 
+static void log_e2c(int num, struct elem_to_channel e2c) {
+    char buf[128] = { 0 };
+
+    av_get_channel_layout_string(buf, sizeof(buf), -1, e2c.av_position);
+
+    av_log(NULL, AV_LOG_DEBUG,
+           "tag %d = { position(s): %s (0x%"PRIx64"), syn_elem: %s, elem_id: %"PRIu8" }\n",
+           num,
+           e2c.av_position == UINT64_MAX ? "Unset/Ignored" : buf,
+           e2c.av_position,
+           e2c.syn_ele == TYPE_SCE ? "SCE" :
+           e2c.syn_ele == TYPE_CPE ? "CPE" :
+           e2c.syn_ele == TYPE_LFE ? "LFE" : "<unknown>",
+           e2c.elem_id);
+}
+
 #define PREFIX_FOR_22POINT2 (AV_CH_LAYOUT_7POINT1_WIDE_BACK|AV_CH_BACK_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_LOW_FREQUENCY_2)
 static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
 {
@@ -483,6 +499,11 @@ end_of_layout_definition:
 
     total_non_cc_elements = n = i;
 
+    av_log(NULL, AV_LOG_DEBUG, "Element order before reorder:\n");
+    for (i = 0; i < n; i++) {
+        log_e2c(i, e2c_vec[i]);
+    }
+
     if (layout == AV_CH_LAYOUT_22POINT2 &&
         tags == 16 && total_non_cc_elements == 16) {
         // For 22.2 reorder the result as needed
@@ -510,6 +531,11 @@ end_of_layout_definition:
 
     }
 
+    av_log(NULL, AV_LOG_DEBUG, "Element order after reorder:\n");
+    for (i = 0; i < total_non_cc_elements; i++) {
+        log_e2c(i, e2c_vec[i]);
+    }
+
     for (i = 0; i < total_non_cc_elements; i++) {
         layout_map[i][0] = e2c_vec[i].syn_ele;
         layout_map[i][1] = e2c_vec[i].elem_id;
-- 
2.26.2



More information about the ffmpeg-devel mailing list