Re: [FFmpeg-devel] [PATCH 277/281] ffmpeg: convert to new channel layout-API

2022-01-15 Thread James Almer



On 1/15/2022 10:47 AM, Michael Niedermayer wrote:

On Thu, Jan 13, 2022 at 04:44:55PM -0300, James Almer wrote:



On 1/13/2022 3:40 PM, James Almer wrote:

On 1/13/2022 3:29 PM, Michael Niedermayer wrote:

On Wed, Jan 12, 2022 at 11:09:09PM -0300, James Almer wrote:

Signed-off-by: James Almer 
---
   fftools/cmdutils.c    | 42 +++-
   fftools/cmdutils.h    |  8 -
   fftools/ffmpeg.c  | 47 --
   fftools/ffmpeg.h  |  7 ++--
   fftools/ffmpeg_filter.c   | 52 ++---
   fftools/ffmpeg_opt.c  | 62 ++-
   tests/fate/aac.mak    |  2 +-
   tests/fate/lavf-container.mak |  2 +-
   8 files changed, 155 insertions(+), 67 deletions(-)


This or a prior patch introduces crashes (it bisected to this but
this is my
2nd testcase the first did not reproduce reliably at all)

Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x566ed811 in av_vlog (avcl=0x577400c0, level=24,
fmt=0x568249e8 "%d frames left in the queue on closing\n",
vl=0x7fffda50) at libavutil/log.c:428


av_vlog() is where it crashes?


428    if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
(gdb) bt
#0  0x566ed811 in av_vlog (avcl=0x577400c0, level=24,
fmt=0x568249e8 "%d frames left in the queue on closing\n",
vl=0x7fffda50) at libavutil/log.c:428
#1  0x566ed6bd in av_log (avcl=0x577400c0, level=24,
fmt=0x568249e8 "%d frames left in the queue on closing\n") at
libavutil/log.c:411
#2  0x55c320b9 in ff_af_queue_close (afq=0x576c47c8) at
libavcodec/audio_frame_queue.c:39
#3  0x55e84c06 in mp3lame_encode_close
(avctx=0x576bf180) at libavcodec/libmp3lame.c:86
#4  0x55c373f7 in avcodec_close (avctx=0x576bf180) at
libavcodec/avcodec.c:489
#5  0x55f7feab in avcodec_free_context
(pavctx=0x576a8858) at libavcodec/options.c:163
#6  0x5569cfe3 in ffmpeg_cleanup (ret=1) at fftools/ffmpeg.c:608
#7  0x55694817 in exit_program (ret=1) at fftools/cmdutils.c:131
#8  0x5569ef1f in do_audio_out (of=0x576ae2c0,
ost=0x576a8800, frame=0x576bf580) at fftools/ffmpeg.c:1056
#9  0x556a117a in reap_filters (flush=0) at fftools/ffmpeg.c:1546
#10 0x556ad8e5 in transcode_step () at fftools/ffmpeg.c:4643
#11 0x556ad9e7 in transcode () at fftools/ffmpeg.c:4687
#12 0x556ae45c in main (argc=12, argv=0x7fffe1c8) at
fftools/ffmpeg.c:4903
(gdb) print avc->version
Cannot access memory at address 0xc1528eb7c0ea0157

make -j32 && gdb --args ./ffmpeg_g -ss 8 -i NeroRecodeSample.mp4
-bitexact -t 3 -filter_complex
'[0:2]scale=720:576[v];[v][0:5]overlay' -y file-whitesubs.avi

it appears this file is at:
https://samples.ffmpeg.org/MPEG-4/NeroRecodeSample-MP4/


I can't reproduce this on mingw64.


Does the following fix it for you?


jamrial/channel_layout4 seems not to crash anymore
but the output from
libswresample/tests/swresample

changes substantially with that branch merged
here a hunk showing that:

--- /tmp/old2022-01-15 14:38:42.370067768 +0100
+++ /tmp/new2022-01-15 14:37:58.265740924 +0100
@@ -3,14 +3,14 @@
  [e:0.037321 c:0.988153 max:0.208739] len:  968
  [e:0.037581 c:0.988035 max:0.208739] len:  968
  [e:0.040051 c:0.986398 max:0.208739] len:  968
-[e:0.042843 c:0.984417 max:0.215337] len:  968
-[e:0.038669 c:0.987065 max:0.208739] len:  968
+[e:0.238849 c:-nan max:0.990217] len:  968
+[e:0.236179 c:-nan max:0.990217] len:  968
  [e:0.000987 c:0.85 max:0.003293] len:   16 F:  1
  [e:0.000131 c:0.99 max:0.000438] len:   16 F:  1
  [e:0.000999 c:0.85 max:0.00] len:   16 F:  1
  [e:0.84 c:1.00 max:0.000280] len:   16 F:  1
-[e:0.000996 c:0.85 max:0.003322] len:   16 F:  1
-[e:0.27 c:1.00 max:0.89] len:   16 F:  1
+[e:0.181271 c:-nan max:0.297598] len:   16 F:  1
+[e:0.080519 c:-nan max:0.227637] len:   16 F:  1
  
  TEST: 3.0->7.1(wide-side), rate:16000->48000, fmt:dbl->dbl

  [e:0.039816 c:0.986742 max:0.283776] len:  968


Should be fixed in the branch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 277/281] ffmpeg: convert to new channel layout-API

2022-01-15 Thread Michael Niedermayer
On Thu, Jan 13, 2022 at 04:44:55PM -0300, James Almer wrote:
> 
> 
> On 1/13/2022 3:40 PM, James Almer wrote:
> > On 1/13/2022 3:29 PM, Michael Niedermayer wrote:
> > > On Wed, Jan 12, 2022 at 11:09:09PM -0300, James Almer wrote:
> > > > Signed-off-by: James Almer 
> > > > ---
> > > >   fftools/cmdutils.c    | 42 +++-
> > > >   fftools/cmdutils.h    |  8 -
> > > >   fftools/ffmpeg.c  | 47 --
> > > >   fftools/ffmpeg.h  |  7 ++--
> > > >   fftools/ffmpeg_filter.c   | 52 ++---
> > > >   fftools/ffmpeg_opt.c  | 62 ++-
> > > >   tests/fate/aac.mak    |  2 +-
> > > >   tests/fate/lavf-container.mak |  2 +-
> > > >   8 files changed, 155 insertions(+), 67 deletions(-)
> > > 
> > > This or a prior patch introduces crashes (it bisected to this but
> > > this is my
> > > 2nd testcase the first did not reproduce reliably at all)
> > > 
> > > Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
> > > 0x566ed811 in av_vlog (avcl=0x577400c0, level=24,
> > > fmt=0x568249e8 "%d frames left in the queue on closing\n",
> > > vl=0x7fffda50) at libavutil/log.c:428
> > 
> > av_vlog() is where it crashes?
> > 
> > > 428    if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
> > > (gdb) bt
> > > #0  0x566ed811 in av_vlog (avcl=0x577400c0, level=24,
> > > fmt=0x568249e8 "%d frames left in the queue on closing\n",
> > > vl=0x7fffda50) at libavutil/log.c:428
> > > #1  0x566ed6bd in av_log (avcl=0x577400c0, level=24,
> > > fmt=0x568249e8 "%d frames left in the queue on closing\n") at
> > > libavutil/log.c:411
> > > #2  0x55c320b9 in ff_af_queue_close (afq=0x576c47c8) at
> > > libavcodec/audio_frame_queue.c:39
> > > #3  0x55e84c06 in mp3lame_encode_close
> > > (avctx=0x576bf180) at libavcodec/libmp3lame.c:86
> > > #4  0x55c373f7 in avcodec_close (avctx=0x576bf180) at
> > > libavcodec/avcodec.c:489
> > > #5  0x55f7feab in avcodec_free_context
> > > (pavctx=0x576a8858) at libavcodec/options.c:163
> > > #6  0x5569cfe3 in ffmpeg_cleanup (ret=1) at fftools/ffmpeg.c:608
> > > #7  0x55694817 in exit_program (ret=1) at fftools/cmdutils.c:131
> > > #8  0x5569ef1f in do_audio_out (of=0x576ae2c0,
> > > ost=0x576a8800, frame=0x576bf580) at fftools/ffmpeg.c:1056
> > > #9  0x556a117a in reap_filters (flush=0) at fftools/ffmpeg.c:1546
> > > #10 0x556ad8e5 in transcode_step () at fftools/ffmpeg.c:4643
> > > #11 0x556ad9e7 in transcode () at fftools/ffmpeg.c:4687
> > > #12 0x556ae45c in main (argc=12, argv=0x7fffe1c8) at
> > > fftools/ffmpeg.c:4903
> > > (gdb) print avc->version
> > > Cannot access memory at address 0xc1528eb7c0ea0157
> > > 
> > > make -j32 && gdb --args ./ffmpeg_g -ss 8 -i NeroRecodeSample.mp4
> > > -bitexact -t 3 -filter_complex
> > > '[0:2]scale=720:576[v];[v][0:5]overlay' -y file-whitesubs.avi
> > > 
> > > it appears this file is at:
> > > https://samples.ffmpeg.org/MPEG-4/NeroRecodeSample-MP4/
> > 
> > I can't reproduce this on mingw64.
> 
> Does the following fix it for you?

jamrial/channel_layout4 seems not to crash anymore
but the output from
libswresample/tests/swresample

changes substantially with that branch merged
here a hunk showing that:

--- /tmp/old2022-01-15 14:38:42.370067768 +0100
+++ /tmp/new2022-01-15 14:37:58.265740924 +0100
@@ -3,14 +3,14 @@
 [e:0.037321 c:0.988153 max:0.208739] len:  968
 [e:0.037581 c:0.988035 max:0.208739] len:  968
 [e:0.040051 c:0.986398 max:0.208739] len:  968
-[e:0.042843 c:0.984417 max:0.215337] len:  968
-[e:0.038669 c:0.987065 max:0.208739] len:  968
+[e:0.238849 c:-nan max:0.990217] len:  968
+[e:0.236179 c:-nan max:0.990217] len:  968
 [e:0.000987 c:0.85 max:0.003293] len:   16 F:  1
 [e:0.000131 c:0.99 max:0.000438] len:   16 F:  1
 [e:0.000999 c:0.85 max:0.00] len:   16 F:  1
 [e:0.84 c:1.00 max:0.000280] len:   16 F:  1
-[e:0.000996 c:0.85 max:0.003322] len:   16 F:  1
-[e:0.27 c:1.00 max:0.89] len:   16 F:  1
+[e:0.181271 c:-nan max:0.297598] len:   16 F:  1
+[e:0.080519 c:-nan max:0.227637] len:   16 F:  1
 
 TEST: 3.0->7.1(wide-side), rate:16000->48000, fmt:dbl->dbl
 [e:0.039816 c:0.986742 max:0.283776] len:  968


 
[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 277/281] ffmpeg: convert to new channel layout-API

2022-01-13 Thread James Almer



On 1/13/2022 3:40 PM, James Almer wrote:

On 1/13/2022 3:29 PM, Michael Niedermayer wrote:

On Wed, Jan 12, 2022 at 11:09:09PM -0300, James Almer wrote:

Signed-off-by: James Almer 
---
  fftools/cmdutils.c    | 42 +++-
  fftools/cmdutils.h    |  8 -
  fftools/ffmpeg.c  | 47 --
  fftools/ffmpeg.h  |  7 ++--
  fftools/ffmpeg_filter.c   | 52 ++---
  fftools/ffmpeg_opt.c  | 62 ++-
  tests/fate/aac.mak    |  2 +-
  tests/fate/lavf-container.mak |  2 +-
  8 files changed, 155 insertions(+), 67 deletions(-)


This or a prior patch introduces crashes (it bisected to this but this 
is my

2nd testcase the first did not reproduce reliably at all)

Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x566ed811 in av_vlog (avcl=0x577400c0, level=24, 
fmt=0x568249e8 "%d frames left in the queue on closing\n", 
vl=0x7fffda50) at libavutil/log.c:428


av_vlog() is where it crashes?


428    if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
(gdb) bt
#0  0x566ed811 in av_vlog (avcl=0x577400c0, level=24, 
fmt=0x568249e8 "%d frames left in the queue on closing\n", 
vl=0x7fffda50) at libavutil/log.c:428
#1  0x566ed6bd in av_log (avcl=0x577400c0, level=24, 
fmt=0x568249e8 "%d frames left in the queue on closing\n") at 
libavutil/log.c:411
#2  0x55c320b9 in ff_af_queue_close (afq=0x576c47c8) at 
libavcodec/audio_frame_queue.c:39
#3  0x55e84c06 in mp3lame_encode_close (avctx=0x576bf180) 
at libavcodec/libmp3lame.c:86
#4  0x55c373f7 in avcodec_close (avctx=0x576bf180) at 
libavcodec/avcodec.c:489
#5  0x55f7feab in avcodec_free_context (pavctx=0x576a8858) 
at libavcodec/options.c:163

#6  0x5569cfe3 in ffmpeg_cleanup (ret=1) at fftools/ffmpeg.c:608
#7  0x55694817 in exit_program (ret=1) at fftools/cmdutils.c:131
#8  0x5569ef1f in do_audio_out (of=0x576ae2c0, 
ost=0x576a8800, frame=0x576bf580) at fftools/ffmpeg.c:1056

#9  0x556a117a in reap_filters (flush=0) at fftools/ffmpeg.c:1546
#10 0x556ad8e5 in transcode_step () at fftools/ffmpeg.c:4643
#11 0x556ad9e7 in transcode () at fftools/ffmpeg.c:4687
#12 0x556ae45c in main (argc=12, argv=0x7fffe1c8) at 
fftools/ffmpeg.c:4903

(gdb) print avc->version
Cannot access memory at address 0xc1528eb7c0ea0157

make -j32 && gdb --args ./ffmpeg_g -ss 8 -i NeroRecodeSample.mp4 
-bitexact -t 3 -filter_complex '[0:2]scale=720:576[v];[v][0:5]overlay' 
-y file-whitesubs.avi


it appears this file is at:
https://samples.ffmpeg.org/MPEG-4/NeroRecodeSample-MP4/


I can't reproduce this on mingw64.


Does the following fix it for you?


diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index 36ae57eb83..728005b840 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -344,9 +344,15 @@ const AVCodec ff_libmp3lame_encoder = {
  
AV_SAMPLE_FMT_S16P,
  
AV_SAMPLE_FMT_NONE },
 .supported_samplerates = libmp3lame_sample_rates,
+#if FF_API_OLD_CHANNEL_LAYOUT
 .channel_layouts   = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
   AV_CH_LAYOUT_STEREO,
   0 },
+#endif
+.ch_layouts= (const AVChannelLayout[]) { 
AV_CHANNEL_LAYOUT_MONO,
+ 
AV_CHANNEL_LAYOUT_STEREO,
+ { 0 },
+},
 .priv_class= _class,
 .defaults  = libmp3lame_defaults,
 .wrapper_name  = "libmp3lame",

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 277/281] ffmpeg: convert to new channel layout-API

2022-01-13 Thread James Almer

On 1/13/2022 3:29 PM, Michael Niedermayer wrote:

On Wed, Jan 12, 2022 at 11:09:09PM -0300, James Almer wrote:

Signed-off-by: James Almer 
---
  fftools/cmdutils.c| 42 +++-
  fftools/cmdutils.h|  8 -
  fftools/ffmpeg.c  | 47 --
  fftools/ffmpeg.h  |  7 ++--
  fftools/ffmpeg_filter.c   | 52 ++---
  fftools/ffmpeg_opt.c  | 62 ++-
  tests/fate/aac.mak|  2 +-
  tests/fate/lavf-container.mak |  2 +-
  8 files changed, 155 insertions(+), 67 deletions(-)


This or a prior patch introduces crashes (it bisected to this but this is my
2nd testcase the first did not reproduce reliably at all)

Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x566ed811 in av_vlog (avcl=0x577400c0, level=24, fmt=0x568249e8 "%d 
frames left in the queue on closing\n", vl=0x7fffda50) at libavutil/log.c:428


av_vlog() is where it crashes?


428 if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
(gdb) bt
#0  0x566ed811 in av_vlog (avcl=0x577400c0, level=24, fmt=0x568249e8 
"%d frames left in the queue on closing\n", vl=0x7fffda50) at 
libavutil/log.c:428
#1  0x566ed6bd in av_log (avcl=0x577400c0, level=24, fmt=0x568249e8 
"%d frames left in the queue on closing\n") at libavutil/log.c:411
#2  0x55c320b9 in ff_af_queue_close (afq=0x576c47c8) at 
libavcodec/audio_frame_queue.c:39
#3  0x55e84c06 in mp3lame_encode_close (avctx=0x576bf180) at 
libavcodec/libmp3lame.c:86
#4  0x55c373f7 in avcodec_close (avctx=0x576bf180) at 
libavcodec/avcodec.c:489
#5  0x55f7feab in avcodec_free_context (pavctx=0x576a8858) at 
libavcodec/options.c:163
#6  0x5569cfe3 in ffmpeg_cleanup (ret=1) at fftools/ffmpeg.c:608
#7  0x55694817 in exit_program (ret=1) at fftools/cmdutils.c:131
#8  0x5569ef1f in do_audio_out (of=0x576ae2c0, ost=0x576a8800, 
frame=0x576bf580) at fftools/ffmpeg.c:1056
#9  0x556a117a in reap_filters (flush=0) at fftools/ffmpeg.c:1546
#10 0x556ad8e5 in transcode_step () at fftools/ffmpeg.c:4643
#11 0x556ad9e7 in transcode () at fftools/ffmpeg.c:4687
#12 0x556ae45c in main (argc=12, argv=0x7fffe1c8) at 
fftools/ffmpeg.c:4903
(gdb) print avc->version
Cannot access memory at address 0xc1528eb7c0ea0157

make -j32 && gdb --args ./ffmpeg_g -ss 8 -i NeroRecodeSample.mp4 -bitexact -t 3 
-filter_complex '[0:2]scale=720:576[v];[v][0:5]overlay' -y file-whitesubs.avi

it appears this file is at:
https://samples.ffmpeg.org/MPEG-4/NeroRecodeSample-MP4/


I can't reproduce this on mingw64.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 277/281] ffmpeg: convert to new channel layout-API

2022-01-13 Thread Michael Niedermayer
On Wed, Jan 12, 2022 at 11:09:09PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  fftools/cmdutils.c| 42 +++-
>  fftools/cmdutils.h|  8 -
>  fftools/ffmpeg.c  | 47 --
>  fftools/ffmpeg.h  |  7 ++--
>  fftools/ffmpeg_filter.c   | 52 ++---
>  fftools/ffmpeg_opt.c  | 62 ++-
>  tests/fate/aac.mak|  2 +-
>  tests/fate/lavf-container.mak |  2 +-
>  8 files changed, 155 insertions(+), 67 deletions(-)

This or a prior patch introduces crashes (it bisected to this but this is my
2nd testcase the first did not reproduce reliably at all)

Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x566ed811 in av_vlog (avcl=0x577400c0, level=24, 
fmt=0x568249e8 "%d frames left in the queue on closing\n", 
vl=0x7fffda50) at libavutil/log.c:428
428 if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
(gdb) bt
#0  0x566ed811 in av_vlog (avcl=0x577400c0, level=24, 
fmt=0x568249e8 "%d frames left in the queue on closing\n", 
vl=0x7fffda50) at libavutil/log.c:428
#1  0x566ed6bd in av_log (avcl=0x577400c0, level=24, 
fmt=0x568249e8 "%d frames left in the queue on closing\n") at 
libavutil/log.c:411
#2  0x55c320b9 in ff_af_queue_close (afq=0x576c47c8) at 
libavcodec/audio_frame_queue.c:39
#3  0x55e84c06 in mp3lame_encode_close (avctx=0x576bf180) at 
libavcodec/libmp3lame.c:86
#4  0x55c373f7 in avcodec_close (avctx=0x576bf180) at 
libavcodec/avcodec.c:489
#5  0x55f7feab in avcodec_free_context (pavctx=0x576a8858) at 
libavcodec/options.c:163
#6  0x5569cfe3 in ffmpeg_cleanup (ret=1) at fftools/ffmpeg.c:608
#7  0x55694817 in exit_program (ret=1) at fftools/cmdutils.c:131
#8  0x5569ef1f in do_audio_out (of=0x576ae2c0, ost=0x576a8800, 
frame=0x576bf580) at fftools/ffmpeg.c:1056
#9  0x556a117a in reap_filters (flush=0) at fftools/ffmpeg.c:1546
#10 0x556ad8e5 in transcode_step () at fftools/ffmpeg.c:4643
#11 0x556ad9e7 in transcode () at fftools/ffmpeg.c:4687
#12 0x556ae45c in main (argc=12, argv=0x7fffe1c8) at 
fftools/ffmpeg.c:4903
(gdb) print avc->version
Cannot access memory at address 0xc1528eb7c0ea0157

make -j32 && gdb --args ./ffmpeg_g -ss 8 -i NeroRecodeSample.mp4 -bitexact -t 3 
-filter_complex '[0:2]scale=720:576[v];[v][0:5]overlay' -y file-whitesubs.avi

it appears this file is at:
https://samples.ffmpeg.org/MPEG-4/NeroRecodeSample-MP4/


Press [q] to stop, [?] for help
[aac @ 0x16fb3540] This stream seems to incorrectly report its last channel as 
SCE[1], mapping to LFE[0]
[aac @ 0x16fb3540] env_facs_q 253 is invalid
==21617==at 0x12A09F8: VALGRIND_PRINTF_BACKTRACE (valgrind.h:6303)
==21617==by 0x12A15B6: av_log_default_callback (log.c:397)
==21617==by 0x12A185D: av_vlog (log.c:432)
==21617==by 0x12A16BC: av_log (log.c:411)
==21617==by 0xEED8B6: read_sbr_envelope (aacsbr_template.c:865)
==21617==by 0xEEE22F: read_sbr_single_channel_element 
(aacsbr_template.c:983)
==21617==by 0xEEE762: read_sbr_data (aacsbr_template.c:1055)
==21617==by 0xEEEAFD: ff_decode_sbr_extension (aacsbr_template.c:1144)
==21617==by 0xECD082: decode_extension_payload (aacdec_template.c:2582)
==21617==by 0xED029B: aac_decode_frame_int (aacdec_template.c:3372)
==21617==by 0xED0842: aac_decode_frame (aacdec_template.c:3500)
==21617==by 0x8ABF66: decode_simple_internal (decode.c:329)
==21617==by 0x8ACB62: decode_simple_receive_frame (decode.c:528)
==21617==by 0x8ACC5C: decode_receive_frame_internal (decode.c:548)
==21617==by 0x8ACF38: avcodec_send_packet (decode.c:615)
==21617==by 0x258160: decode (ffmpeg.c:2276)
==21617==by 0x258354: decode_audio (ffmpeg.c:2319)
==21617==by 0x259949: process_input_packet (ffmpeg.c:2638)
==21617==by 0x26138A: process_input (ffmpeg.c:4493)
==21617==by 0x26187E: transcode_step (ffmpeg.c:4633)
[aac @ 0x16fb3540] env_facs_q 252 is invalid
==21617==at 0x12A09F8: VALGRIND_PRINTF_BACKTRACE (valgrind.h:6303)
==21617==by 0x12A15B6: av_log_default_callback (log.c:397)
==21617==by 0x12A185D: av_vlog (log.c:432)
==21617==by 0x12A16BC: av_log (log.c:411)
==21617==by 0xEED8B6: read_sbr_envelope (aacsbr_template.c:865)
==21617==by 0xEEE5AC: read_sbr_channel_pair_element (aacsbr_template.c:1028)
==21617==by 0xEEE7A7: read_sbr_data (aacsbr_template.c:1060)
==21617==by 0xEEEAFD: ff_decode_sbr_extension (aacsbr_template.c:1144)
==21617==by 0xECD082: decode_extension_payload (aacdec_template.c:2582)
==21617==by 0xED029B: aac_decode_frame_int (aacdec_template.c:3372)
==21617==by 0xED0842: aac_decode_frame (aacdec_template.c:3500)
==21617==by 0x8ABF66: decode_simple_internal (decode.c:329)
==21617==by 0x8ACB62: 

[FFmpeg-devel] [PATCH 277/281] ffmpeg: convert to new channel layout-API

2022-01-12 Thread James Almer
Signed-off-by: James Almer 
---
 fftools/cmdutils.c| 42 +++-
 fftools/cmdutils.h|  8 -
 fftools/ffmpeg.c  | 47 --
 fftools/ffmpeg.h  |  7 ++--
 fftools/ffmpeg_filter.c   | 52 ++---
 fftools/ffmpeg_opt.c  | 62 ++-
 tests/fate/aac.mak|  2 +-
 tests/fate/lavf-container.mak |  2 +-
 8 files changed, 155 insertions(+), 67 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 4b50e15eef..55cdbfb7a7 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1470,8 +1470,19 @@ static void print_codec(const AVCodec *c)
   GET_SAMPLE_RATE_NAME);
 PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample 
formats",
   AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME);
-PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts",
-  0, GET_CH_LAYOUT_DESC);
+
+if (c->ch_layouts) {
+const AVChannelLayout *p = c->ch_layouts;
+
+printf("Supported channel layouts:");
+while (p->nb_channels) {
+char name[128];
+av_channel_layout_describe(p, name, sizeof(name));
+printf(" %s", name);
+p++;
+}
+printf("\n");
+}
 
 if (c->priv_class) {
 show_help_children(c->priv_class,
@@ -1784,29 +1795,30 @@ int show_pix_fmts(void *optctx, const char *opt, const 
char *arg)
 
 int show_layouts(void *optctx, const char *opt, const char *arg)
 {
+const AVChannelLayout *ch_layout;
+void *iter = NULL;
+char buf[128], buf2[128];
 int i = 0;
-uint64_t layout, j;
-const char *name, *descr;
 
 printf("Individual channels:\n"
"NAME   DESCRIPTION\n");
 for (i = 0; i < 63; i++) {
-name = av_get_channel_name((uint64_t)1 << i);
-if (!name)
+av_channel_name(buf, sizeof(buf), i);
+if (!strcmp(buf, "?"))
 continue;
-descr = av_get_channel_description((uint64_t)1 << i);
-printf("%-14s %s\n", name, descr);
+av_channel_description(buf2, sizeof(buf2), i);
+printf("%-14s %s\n", buf, buf2);
 }
 printf("\nStandard channel layouts:\n"
"NAME   DECOMPOSITION\n");
-for (i = 0; !av_get_standard_channel_layout(i, , ); i++) {
-if (name) {
-printf("%-14s ", name);
-for (j = 1; j; j <<= 1)
-if ((layout & j))
-printf("%s%s", (layout & (j - 1)) ? "+" : "", 
av_get_channel_name(j));
+while (ch_layout = av_channel_layout_standard()) {
+av_channel_layout_describe(ch_layout, buf, sizeof(buf));
+av_channel_name(buf2, sizeof(buf2), i);
+printf("%-14s ", buf);
+for (i = 0; i < 63; i++)
+if (av_channel_layout_index_from_channel(ch_layout, i) >= 0)
+printf("%s%s", i ? "+" : "", buf2);
 printf("\n");
-}
 }
 return 0;
 }
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 50eed9b13a..274d2e5b14 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -663,14 +663,6 @@ void *allocate_array_elem(void *array, size_t elem_size, 
int *nb_elems);
 char name[16];\
 snprintf(name, sizeof(name), "%d", rate);
 
-#define GET_CH_LAYOUT_NAME(ch_layout)\
-char name[16];\
-snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
-
-#define GET_CH_LAYOUT_DESC(ch_layout)\
-char name[128];\
-av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
-
 double get_rotation(int32_t *displaymatrix);
 
 #endif /* FFTOOLS_CMDUTILS_H */
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5d134b025f..22d6309f2a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -555,6 +555,7 @@ static void ffmpeg_cleanup(int ret)
 
 avfilter_inout_free(>out_tmp);
 av_freep(>name);
+av_channel_layout_uninit(>ch_layout);
 av_freep(>outputs[j]);
 }
 av_freep(>outputs);
@@ -1537,7 +1538,7 @@ static int reap_filters(int flush)
 break;
 case AVMEDIA_TYPE_AUDIO:
 if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) &&
-enc->channels != filtered_frame->channels) {
+enc->ch_layout.nb_channels != 
filtered_frame->ch_layout.nb_channels) {
 av_log(NULL, AV_LOG_ERROR,
"Audio filter graph output is not normalized and 
encoder does not support parameter changes\n");
 break;
@@ -1883,17 +1884,22 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 print_final_stats(total_size);
 }
 
-static void ifilter_parameters_from_codecpar(InputFilter *ifilter, 
AVCodecParameters *par)
+static int