diff mbox series

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

Message ID 20200821215800.27162-4-jeebjp@gmail.com
State New
Headers show
Series avcodec/aacdec_template: improvements to 22.2 layout logic
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Jan Ekström Aug. 21, 2020, 9:58 p.m. UTC
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(+)

Comments

Michael Niedermayer Aug. 22, 2020, 11:21 a.m. UTC | #1
On Sat, Aug 22, 2020 at 12:58:00AM +0300, Jan Ekström wrote:
> 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 63604d39fd..b9b9ae5324 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -266,6 +266,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,

without the NULL contexts i agree that this should be usefull for debuging

with the NULL its only when there is less than 2 streams

thx

[...]
Jan Ekström Aug. 22, 2020, 11:40 a.m. UTC | #2
On Sat, Aug 22, 2020 at 2:21 PM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Sat, Aug 22, 2020 at 12:58:00AM +0300, Jan Ekström wrote:
> > 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 63604d39fd..b9b9ae5324 100644
> > --- a/libavcodec/aacdec_template.c
> > +++ b/libavcodec/aacdec_template.c
> > @@ -266,6 +266,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,
>
> without the NULL contexts i agree that this should be usefull for debuging
>
> with the NULL its only when there is less than 2 streams
>
> thx
>

I agree, unfortunately the function where this gets called from does
not seem to have access to the context as it only has
`(uint8_t (*layout_map)[3], int tags)` as arguments.

Anyways, glad that people in general like the idea. I will then update
this patch to have the logging context passed far enough after the
main parts of this patch set get through.

Jan
diff mbox series

Patch

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 63604d39fd..b9b9ae5324 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -266,6 +266,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)
 {
@@ -494,6 +510,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) {
         // For 22.2 reorder the result as needed
         FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[0]);   // FL & FR first (final), FC third
@@ -520,6 +541,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;