[FFmpeg-devel] [PATCH 1/8] avcodec/argo: use pixel format provided by the demuxer

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Jul 18 04:25:29 EEST 2021


Zane van Iperen:
> But fall back to bits_per_raw_sample, in case we're with older
> libavformat.
> 

We are still in an open ABI phase, so you do not need to care about
older libavformat.

> Signed-off-by: Zane van Iperen <zane at zanevaniperen.com>
> ---
>  libavcodec/argo.c    | 21 ++++++++++++++-------
>  libavcodec/version.h |  2 +-
>  2 files changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/argo.c b/libavcodec/argo.c
> index 87c646f56c..9df5b8a8d3 100644
> --- a/libavcodec/argo.c
> +++ b/libavcodec/argo.c
> @@ -676,13 +676,20 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  {
>      ArgoContext *s = avctx->priv_data;
>  
> -    switch (avctx->bits_per_raw_sample) {
> -    case  8: s->bpp = 1;
> -             avctx->pix_fmt = AV_PIX_FMT_PAL8; break;
> -    case 24: s->bpp = 4;
> -             avctx->pix_fmt = AV_PIX_FMT_BGR0; break;
> -    default: avpriv_request_sample(s, "depth == %u", avctx->bits_per_raw_sample);
> -             return AVERROR_PATCHWELCOME;
> +    if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
> +        /* For compat with older libavformat. */
> +        switch (avctx->bits_per_raw_sample) {
> +        case  8: s->bpp = 1;
> +                avctx->pix_fmt = AV_PIX_FMT_PAL8; break;
> +        case 24: s->bpp = 4;
> +                avctx->pix_fmt = AV_PIX_FMT_BGR0; break;
> +        default: avpriv_request_sample(s, "depth == %u", avctx->bits_per_raw_sample);
> +                return AVERROR_PATCHWELCOME;
> +        }
> +    }
> +
> +    if (avctx->pix_fmt != AV_PIX_FMT_PAL8 && avctx->pix_fmt != AV_PIX_FMT_BGR0) {
> +        return AVERROR_INVALIDDATA;
>      }
>  
>      s->frame = av_frame_alloc();
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index c660f70669..91325ce4e7 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -29,7 +29,7 @@
>  
>  #define LIBAVCODEC_VERSION_MAJOR  59
>  #define LIBAVCODEC_VERSION_MINOR   3
> -#define LIBAVCODEC_VERSION_MICRO 101
> +#define LIBAVCODEC_VERSION_MICRO 102
>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
>                                                 LIBAVCODEC_VERSION_MINOR, \
> 



More information about the ffmpeg-devel mailing list