[FFmpeg-devel] [PATCH 1/2] avcodec: Set AV_CODEC_CAP_CHANNEL_CONF in more decoders

Paul B Mahol onemda at gmail.com
Fri Sep 11 16:46:43 EEST 2020


On Thu, Sep 10, 2020 at 02:02:19PM +0200, Michael Niedermayer wrote:
> Suggested-by: Paul B Mahol <onemda at gmail.com>
> See: [FFmpeg-devel] [PATCH 1/3] avcodec/fastaudio: Check channels
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavcodec/ac3dec_fixed.c       |  3 ++-
>  libavcodec/ac3dec_float.c       |  6 ++++--
>  libavcodec/adxdec.c             |  3 ++-
>  libavcodec/flacdec.c            |  4 +++-
>  libavcodec/mpegaudiodec_fixed.c | 15 ++++++++++-----
>  libavcodec/mpegaudiodec_float.c | 15 ++++++++++-----
>  libavcodec/pcm-dvd.c            |  3 ++-
>  libavcodec/ralf.c               |  3 ++-
>  libavcodec/s302m.c              |  3 ++-
>  libavcodec/shorten.c            |  5 ++++-
>  10 files changed, 41 insertions(+), 19 deletions(-)

I think siren also belongs here, as it hardcodes number of channels
in init, and vivo demuxer does not set channels in codecpar.

> 
> diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c
> index 336a538cad..f36854cdc5 100644
> --- a/libavcodec/ac3dec_fixed.c
> +++ b/libavcodec/ac3dec_fixed.c
> @@ -176,7 +176,8 @@ AVCodec ff_ac3_fixed_decoder = {
>      .init           = ac3_decode_init,
>      .close          = ac3_decode_end,
>      .decode         = ac3_decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .long_name      = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_NONE },
> diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c
> index b85a4ce336..57a626a181 100644
> --- a/libavcodec/ac3dec_float.c
> +++ b/libavcodec/ac3dec_float.c
> @@ -61,7 +61,8 @@ AVCodec ff_ac3_decoder = {
>      .init           = ac3_decode_init,
>      .close          = ac3_decode_end,
>      .decode         = ac3_decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .long_name      = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_NONE },
> @@ -84,7 +85,8 @@ AVCodec ff_eac3_decoder = {
>      .init           = ac3_decode_init,
>      .close          = ac3_decode_end,
>      .decode         = ac3_decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .long_name      = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_NONE },
> diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
> index 40ed8e5ba7..69a391ee1f 100644
> --- a/libavcodec/adxdec.c
> +++ b/libavcodec/adxdec.c
> @@ -183,7 +183,8 @@ AVCodec ff_adpcm_adx_decoder = {
>      .init           = adx_decode_init,
>      .decode         = adx_decode_frame,
>      .flush          = adx_decode_flush,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_NONE },
>  };
> diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
> index d1cf82b541..cf6128f897 100644
> --- a/libavcodec/flacdec.c
> +++ b/libavcodec/flacdec.c
> @@ -669,7 +669,9 @@ AVCodec ff_flac_decoder = {
>      .init           = flac_decode_init,
>      .close          = flac_decode_close,
>      .decode         = flac_decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1 |
> +                      AV_CODEC_CAP_FRAME_THREADS,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
>                                                        AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_S32,
> diff --git a/libavcodec/mpegaudiodec_fixed.c b/libavcodec/mpegaudiodec_fixed.c
> index ad7ceb20b6..68ba841efe 100644
> --- a/libavcodec/mpegaudiodec_fixed.c
> +++ b/libavcodec/mpegaudiodec_fixed.c
> @@ -47,7 +47,8 @@ AVCodec ff_mp1_decoder = {
>      .priv_data_size = sizeof(MPADecodeContext),
>      .init           = decode_init,
>      .decode         = decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_S16,
> @@ -63,7 +64,8 @@ AVCodec ff_mp2_decoder = {
>      .priv_data_size = sizeof(MPADecodeContext),
>      .init           = decode_init,
>      .decode         = decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_S16,
> @@ -79,7 +81,8 @@ AVCodec ff_mp3_decoder = {
>      .priv_data_size = sizeof(MPADecodeContext),
>      .init           = decode_init,
>      .decode         = decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_S16,
> @@ -95,7 +98,8 @@ AVCodec ff_mp3adu_decoder = {
>      .priv_data_size = sizeof(MPADecodeContext),
>      .init           = decode_init,
>      .decode         = decode_frame_adu,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_S16,
> @@ -112,7 +116,8 @@ AVCodec ff_mp3on4_decoder = {
>      .init           = decode_init_mp3on4,
>      .close          = decode_close_mp3on4,
>      .decode         = decode_frame_mp3on4,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush_mp3on4,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_NONE },
> diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c
> index ddfa5e0daa..6ebf4c4ae9 100644
> --- a/libavcodec/mpegaudiodec_float.c
> +++ b/libavcodec/mpegaudiodec_float.c
> @@ -48,7 +48,8 @@ AVCodec ff_mp1float_decoder = {
>      .init           = decode_init,
>      .close          = decode_close,
>      .decode         = decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_FLT,
> @@ -65,7 +66,8 @@ AVCodec ff_mp2float_decoder = {
>      .init           = decode_init,
>      .decode         = decode_frame,
>      .close          = decode_close,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_FLT,
> @@ -82,7 +84,8 @@ AVCodec ff_mp3float_decoder = {
>      .init           = decode_init,
>      .close          = decode_close,
>      .decode         = decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_FLT,
> @@ -99,7 +102,8 @@ AVCodec ff_mp3adufloat_decoder = {
>      .init           = decode_init,
>      .close          = decode_close,
>      .decode         = decode_frame_adu,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_FLT,
> @@ -116,7 +120,8 @@ AVCodec ff_mp3on4float_decoder = {
>      .init           = decode_init_mp3on4,
>      .close          = decode_close_mp3on4,
>      .decode         = decode_frame_mp3on4,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .flush          = flush_mp3on4,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
>                                                        AV_SAMPLE_FMT_NONE },
> diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
> index 0a751a8191..11a2244616 100644
> --- a/libavcodec/pcm-dvd.c
> +++ b/libavcodec/pcm-dvd.c
> @@ -311,7 +311,8 @@ AVCodec ff_pcm_dvd_decoder = {
>      .init           = pcm_dvd_decode_init,
>      .decode         = pcm_dvd_decode_frame,
>      .close          = pcm_dvd_decode_uninit,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .sample_fmts    = (const enum AVSampleFormat[]) {
>          AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE
>      }
> diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
> index 0080b23941..dc012d71b1 100644
> --- a/libavcodec/ralf.c
> +++ b/libavcodec/ralf.c
> @@ -535,7 +535,8 @@ AVCodec ff_ralf_decoder = {
>      .close          = decode_close,
>      .decode         = decode_frame,
>      .flush          = decode_flush,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_NONE },
>  };
> diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
> index 584b58e28e..113590aee4 100644
> --- a/libavcodec/s302m.c
> +++ b/libavcodec/s302m.c
> @@ -225,6 +225,7 @@ AVCodec ff_s302m_decoder = {
>      .id             = AV_CODEC_ID_S302M,
>      .priv_data_size = sizeof(S302Context),
>      .decode         = s302m_decode_frame,
> -    .capabilities   = AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DR1,
>      .priv_class     = &s302m_class,
>  };
> diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
> index 4134af74cf..517942c1b0 100644
> --- a/libavcodec/shorten.c
> +++ b/libavcodec/shorten.c
> @@ -808,7 +808,10 @@ AVCodec ff_shorten_decoder = {
>      .init           = shorten_decode_init,
>      .close          = shorten_decode_close,
>      .decode         = shorten_decode_frame,
> -    .capabilities   = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
> +    .capabilities   = AV_CODEC_CAP_CHANNEL_CONF |
> +                      AV_CODEC_CAP_DELAY |
> +                      AV_CODEC_CAP_DR1 |
> +                      AV_CODEC_CAP_SUBFRAMES ,
>      .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
>                                                        AV_SAMPLE_FMT_U8P,
>                                                        AV_SAMPLE_FMT_NONE },
> -- 
> 2.17.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list