Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: add max_frame_size support for hevc_qsv

2020-12-01 Thread Xiang, Haihao
On Wed, 2020-12-02 at 09:52 +0800, wenbin.c...@intel.com wrote:
> From: Wenbinc-Bin 
> 
> The max_frame_size parameter is set only when codec is h264. Now I add
> hevc in that conditional statement.
> 
> Signed-off-by: Wenbin CHEN 
> ---
>  libavcodec/qsvenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 2bd2a56227..aba98dd689 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -691,7 +691,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)
> >extco;
>  
>  #if QSV_HAVE_CO2
> -if (avctx->codec_id == AV_CODEC_ID_H264) {
> +if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id ==
> AV_CODEC_ID_HEVC) {
>  if (q->int_ref_type >= 0)
>  q->extco2.IntRefType = q->int_ref_type;
>  if (q->int_ref_cycle_size >= 0)


LGTM, thanks!
___
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 3/5] avcodec/qsvdec: refact, move qsvdec_h2645.c to qsvdec.c

2020-12-01 Thread Guangxin Xu
Hi Haihao,
Thanks for the review.
This patch just moves all code from qsvdec_h2645.c to qsvdec.c.
The original code in qsvdec_h2645.c did not free the point, so the code
will not free it.
The av_freep(>qsv.load_plugins); will addressed by
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201126102026.27202-4-guangxin...@intel.com/

Your finding is a good example, tell us why we need to remove duplicate
codes. :)

thanks

On Wed, Dec 2, 2020 at 12:50 PM Xiang, Haihao 
wrote:

> On Thu, 2020-11-26 at 18:20 +0800, Xu Guangxin wrote:
> > ---
> >  libavcodec/Makefile   |   8 +-
> >  libavcodec/qsvdec.c   | 215 -
> >  libavcodec/qsvdec_h2645.c | 248 --
> >  3 files changed, 217 insertions(+), 254 deletions(-)
> >  delete mode 100644 libavcodec/qsvdec_h2645.c
> >
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index a6435c9e85..3ee8aa7f86 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -374,7 +374,7 @@ OBJS-$(CONFIG_H264_NVENC_ENCODER)  +=
> nvenc_h264.o
> >  OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
> >  OBJS-$(CONFIG_NVENC_H264_ENCODER)  += nvenc_h264.o
> >  OBJS-$(CONFIG_H264_OMX_ENCODER)+= omx.o
> > -OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h2645.o
> > +OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec.o
> >  OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o
> >  OBJS-$(CONFIG_H264_RKMPP_DECODER)  += rkmppdec.o
> >  OBJS-$(CONFIG_H264_VAAPI_ENCODER)  += vaapi_encode_h264.o
> h264_levels.o
> > @@ -394,7 +394,7 @@ OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) +=
> mediacodecdec.o
> >  OBJS-$(CONFIG_HEVC_MF_ENCODER) += mfenc.o mf_utils.o
> >  OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
> >  OBJS-$(CONFIG_NVENC_HEVC_ENCODER)  += nvenc_hevc.o
> > -OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
> > +OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec.o
> >  OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o
>  \
> >hevc_data.o
> >  OBJS-$(CONFIG_HEVC_RKMPP_DECODER)  += rkmppdec.o
> > @@ -922,14 +922,14 @@ OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  +=
> > videotoolbox.o
> >  OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)   += dxva2_h264.o
> >  OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
> >  OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o
> > -OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec_h2645.o
> > +OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec.o
> >  OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
> >  OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
> >  OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
> >  OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
> >  OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
> >  OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
> > -OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
> > +OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec.o
> >  OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
> > h265_profile_level.o
> >  OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
> > h265_profile_level.o
> >  OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index c666aaeb52..0a79d00eac 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -31,6 +31,7 @@
> >  #include "libavutil/hwcontext_qsv.h"
> >  #include "libavutil/mem.h"
> >  #include "libavutil/log.h"
> > +#include "libavutil/opt.h"
> >  #include "libavutil/pixdesc.h"
> >  #include "libavutil/pixfmt.h"
> >  #include "libavutil/time.h"
> > @@ -228,7 +229,7 @@ static int qsv_decode_preinit(AVCodecContext *avctx,
> > QSVContext *q, enum AVPixel
> >  return 0;
> >   }
> >
> > -static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q,
> > mfxVideoParam *param)
> > +static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q,
> > mfxVideoParam *param)
> >  {
> >  int ret;
> >
> > @@ -615,7 +616,7 @@ int ff_qsv_process_data(AVCodecContext *avctx,
> QSVContext
> > *q,
> >  }
> >
> >  if (!q->initialized) {
> > -ret = qsv_decode_init(avctx, q, );
> > +ret = qsv_decode_init_context(avctx, q, );
> >  if (ret < 0)
> >  goto reinit_fail;
> >  q->initialized = 1;
> > @@ -633,3 +634,213 @@ void ff_qsv_decode_flush(AVCodecContext *avctx,
> > QSVContext *q)
> >  q->orig_pix_fmt = AV_PIX_FMT_NONE;
> >  q->initialized = 0;
> >  }
> > +
> > +enum LoadPlugin {
> > +LOAD_PLUGIN_NONE,
> > +LOAD_PLUGIN_HEVC_SW,
> > +LOAD_PLUGIN_HEVC_HW,
> > +};
> > +
> > +typedef struct QSVDecContext {
> > +AVClass *class;
> > +QSVContext qsv;
> > +
> > +int load_plugin;
> > +
> > +AVFifoBuffer *packet_fifo;
> > +
> > +AVPacket buffer_pkt;
> > +} QSVDecContext;
> > +
> > +static void 

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code

2020-12-01 Thread Xiang, Haihao

> Hi Haihao,
> If you check the final code. The QSVOtherContext and QSVH2645Context will
> be unified to QSVDecContext. It's no need to pass the priv_data_size.
> 
> In the final version, we have two macros
> DEFINE_QSV_DECODER_WITH_OPTION for h265 only. Maybe av1 can use it for film
> grain too.
> DEFINE_QSV_DECODER for other codecs.
> 

Thanks for the explanation, your patch looks good to me.

Regards
Haihao
 

> thanks
> 
> On Wed, Dec 2, 2020 at 12:38 PM Xiang, Haihao 
> wrote:
> 
> > 
> > > ---
> > >  libavcodec/qsvdec_other.c | 188 --
> > >  1 file changed, 36 insertions(+), 152 deletions(-)
> > > 
> > > diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> > > index 2775e07955..266ac9f2e5 100644
> > > --- a/libavcodec/qsvdec_other.c
> > > +++ b/libavcodec/qsvdec_other.c
> > > @@ -189,170 +189,54 @@ static const AVOption options[] = {
> > >  { NULL },
> > >  };
> > > 
> > > -#if CONFIG_MPEG2_QSV_DECODER
> > > -static const AVClass mpeg2_qsv_class = {
> > > -.class_name = "mpeg2_qsv",
> > > -.item_name  = av_default_item_name,
> > > -.option = options,
> > > -.version= LIBAVUTIL_VERSION_INT,
> > > -};
> > > +#define DEFINE_QSV_DECODER(x, X, bsf_name) \
> > 
> > 
> > How about to use the same macro for all QSV decoders? Compared
> > ff_mpeg2_qsv_decoder in qsvdec_other.c and ffmpeg_h264_qsv_decoder in
> > qsvh2645.c, besides x, X, bsf_name, option and priv_data_size are
> > different too.
> > So we may define a macro below in qsvdec.h and use this macro for all QSV
> > decoders.
> > 
> > #define DEFINE_QSV_DECODER(x, X, bsf_name, option, priv_data_size) \
> > ...
> > 
> > Thanks
> > Haihao
> > 
> > > +static const AVClass x##_qsv_class = { \
> > > +.class_name = #x "_qsv", \
> > > +.item_name  = av_default_item_name, \
> > > +.option = options, \
> > > +.version= LIBAVUTIL_VERSION_INT, \
> > > +}; \
> > > +AVCodec ff_##x##_qsv_decoder = { \
> > > +.name   = #x "_qsv", \
> > > +.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync
> > 
> > Video
> > > acceleration)"), \
> > > +.priv_data_size = sizeof(QSVOtherContext), \
> > > +.type   = AVMEDIA_TYPE_VIDEO, \
> > > +.id = AV_CODEC_ID_##X, \
> > > +.init   = qsv_decode_init, \
> > > +.decode = qsv_decode_frame, \
> > > +.flush  = qsv_decode_flush, \
> > > +.close  = qsv_decode_close, \
> > > +.bsfs   = bsf_name, \
> > > +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> > > AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
> > > +.priv_class = ##_qsv_class, \
> > > +.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> > > +AV_PIX_FMT_P010, \
> > > +AV_PIX_FMT_QSV, \
> > > +AV_PIX_FMT_NONE }, \
> > > +.hw_configs = ff_qsv_hw_configs, \
> > > +.wrapper_name   = "qsv", \
> > > +}; \
> > > 
> > > -AVCodec ff_mpeg2_qsv_decoder = {
> > > -.name   = "mpeg2_qsv",
> > > -.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick
> > 
> > Sync
> > > Video acceleration)"),
> > > -.priv_data_size = sizeof(QSVOtherContext),
> > > -.type   = AVMEDIA_TYPE_VIDEO,
> > > -.id = AV_CODEC_ID_MPEG2VIDEO,
> > > -.init   = qsv_decode_init,
> > > -.decode = qsv_decode_frame,
> > > -.flush  = qsv_decode_flush,
> > > -.close  = qsv_decode_close,
> > > -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> > > AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> > > -.priv_class = _qsv_class,
> > > -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> > > -AV_PIX_FMT_QSV,
> > > -AV_PIX_FMT_NONE },
> > > -.hw_configs = ff_qsv_hw_configs,
> > > -.wrapper_name   = "qsv",
> > > -};
> > > +#if CONFIG_MPEG2_QSV_DECODER
> > > +DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
> > >  #endif
> > > 
> > >  #if CONFIG_VC1_QSV_DECODER
> > > -static const AVClass vc1_qsv_class = {
> > > -.class_name = "vc1_qsv",
> > > -.item_name  = av_default_item_name,
> > > -.option = options,
> > > -.version= LIBAVUTIL_VERSION_INT,
> > > -};
> > > -
> > > -AVCodec ff_vc1_qsv_decoder = {
> > > -.name   = "vc1_qsv",
> > > -.long_name  = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync
> > > Video acceleration)"),
> > > -.priv_data_size = sizeof(QSVOtherContext),
> > > -.type   = AVMEDIA_TYPE_VIDEO,
> > > -.id = AV_CODEC_ID_VC1,
> > > -.init   = qsv_decode_init,
> > > -.decode = qsv_decode_frame,
> > > -.flush  = 

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code

2020-12-01 Thread Guangxin Xu
Hi Haihao,
If you check the final code. The QSVOtherContext and QSVH2645Context will
be unified to QSVDecContext. It's no need to pass the priv_data_size.

In the final version, we have two macros
DEFINE_QSV_DECODER_WITH_OPTION for h265 only. Maybe av1 can use it for film
grain too.
DEFINE_QSV_DECODER for other codecs.

thanks

On Wed, Dec 2, 2020 at 12:38 PM Xiang, Haihao 
wrote:

>
> > ---
> >  libavcodec/qsvdec_other.c | 188 --
> >  1 file changed, 36 insertions(+), 152 deletions(-)
> >
> > diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> > index 2775e07955..266ac9f2e5 100644
> > --- a/libavcodec/qsvdec_other.c
> > +++ b/libavcodec/qsvdec_other.c
> > @@ -189,170 +189,54 @@ static const AVOption options[] = {
> >  { NULL },
> >  };
> >
> > -#if CONFIG_MPEG2_QSV_DECODER
> > -static const AVClass mpeg2_qsv_class = {
> > -.class_name = "mpeg2_qsv",
> > -.item_name  = av_default_item_name,
> > -.option = options,
> > -.version= LIBAVUTIL_VERSION_INT,
> > -};
> > +#define DEFINE_QSV_DECODER(x, X, bsf_name) \
>
>
> How about to use the same macro for all QSV decoders? Compared
> ff_mpeg2_qsv_decoder in qsvdec_other.c and ffmpeg_h264_qsv_decoder in
> qsvh2645.c, besides x, X, bsf_name, option and priv_data_size are
> different too.
> So we may define a macro below in qsvdec.h and use this macro for all QSV
> decoders.
>
> #define DEFINE_QSV_DECODER(x, X, bsf_name, option, priv_data_size) \
> ...
>
> Thanks
> Haihao
>
> > +static const AVClass x##_qsv_class = { \
> > +.class_name = #x "_qsv", \
> > +.item_name  = av_default_item_name, \
> > +.option = options, \
> > +.version= LIBAVUTIL_VERSION_INT, \
> > +}; \
> > +AVCodec ff_##x##_qsv_decoder = { \
> > +.name   = #x "_qsv", \
> > +.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync
> Video
> > acceleration)"), \
> > +.priv_data_size = sizeof(QSVOtherContext), \
> > +.type   = AVMEDIA_TYPE_VIDEO, \
> > +.id = AV_CODEC_ID_##X, \
> > +.init   = qsv_decode_init, \
> > +.decode = qsv_decode_frame, \
> > +.flush  = qsv_decode_flush, \
> > +.close  = qsv_decode_close, \
> > +.bsfs   = bsf_name, \
> > +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> > AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
> > +.priv_class = ##_qsv_class, \
> > +.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> > +AV_PIX_FMT_P010, \
> > +AV_PIX_FMT_QSV, \
> > +AV_PIX_FMT_NONE }, \
> > +.hw_configs = ff_qsv_hw_configs, \
> > +.wrapper_name   = "qsv", \
> > +}; \
> >
> > -AVCodec ff_mpeg2_qsv_decoder = {
> > -.name   = "mpeg2_qsv",
> > -.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick
> Sync
> > Video acceleration)"),
> > -.priv_data_size = sizeof(QSVOtherContext),
> > -.type   = AVMEDIA_TYPE_VIDEO,
> > -.id = AV_CODEC_ID_MPEG2VIDEO,
> > -.init   = qsv_decode_init,
> > -.decode = qsv_decode_frame,
> > -.flush  = qsv_decode_flush,
> > -.close  = qsv_decode_close,
> > -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> > AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> > -.priv_class = _qsv_class,
> > -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> > -AV_PIX_FMT_QSV,
> > -AV_PIX_FMT_NONE },
> > -.hw_configs = ff_qsv_hw_configs,
> > -.wrapper_name   = "qsv",
> > -};
> > +#if CONFIG_MPEG2_QSV_DECODER
> > +DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
> >  #endif
> >
> >  #if CONFIG_VC1_QSV_DECODER
> > -static const AVClass vc1_qsv_class = {
> > -.class_name = "vc1_qsv",
> > -.item_name  = av_default_item_name,
> > -.option = options,
> > -.version= LIBAVUTIL_VERSION_INT,
> > -};
> > -
> > -AVCodec ff_vc1_qsv_decoder = {
> > -.name   = "vc1_qsv",
> > -.long_name  = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync
> > Video acceleration)"),
> > -.priv_data_size = sizeof(QSVOtherContext),
> > -.type   = AVMEDIA_TYPE_VIDEO,
> > -.id = AV_CODEC_ID_VC1,
> > -.init   = qsv_decode_init,
> > -.decode = qsv_decode_frame,
> > -.flush  = qsv_decode_flush,
> > -.close  = qsv_decode_close,
> > -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> > AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> > -.priv_class = _qsv_class,
> > -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> > -

Re: [FFmpeg-devel] [PATCH 3/5] avcodec/qsvdec: refact, move qsvdec_h2645.c to qsvdec.c

2020-12-01 Thread Xiang, Haihao
On Thu, 2020-11-26 at 18:20 +0800, Xu Guangxin wrote:
> ---
>  libavcodec/Makefile   |   8 +-
>  libavcodec/qsvdec.c   | 215 -
>  libavcodec/qsvdec_h2645.c | 248 --
>  3 files changed, 217 insertions(+), 254 deletions(-)
>  delete mode 100644 libavcodec/qsvdec_h2645.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index a6435c9e85..3ee8aa7f86 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -374,7 +374,7 @@ OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
>  OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
>  OBJS-$(CONFIG_NVENC_H264_ENCODER)  += nvenc_h264.o
>  OBJS-$(CONFIG_H264_OMX_ENCODER)+= omx.o
> -OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h2645.o
> +OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec.o
>  OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o
>  OBJS-$(CONFIG_H264_RKMPP_DECODER)  += rkmppdec.o
>  OBJS-$(CONFIG_H264_VAAPI_ENCODER)  += vaapi_encode_h264.o h264_levels.o
> @@ -394,7 +394,7 @@ OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
>  OBJS-$(CONFIG_HEVC_MF_ENCODER) += mfenc.o mf_utils.o
>  OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
>  OBJS-$(CONFIG_NVENC_HEVC_ENCODER)  += nvenc_hevc.o
> -OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
> +OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec.o
>  OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o   \
>hevc_data.o
>  OBJS-$(CONFIG_HEVC_RKMPP_DECODER)  += rkmppdec.o
> @@ -922,14 +922,14 @@ OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  +=
> videotoolbox.o
>  OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)   += dxva2_h264.o
>  OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
>  OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o
> -OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec_h2645.o
> +OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec.o
>  OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
>  OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
>  OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
>  OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
>  OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
>  OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
> -OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
> +OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec.o
>  OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
> h265_profile_level.o
>  OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
> h265_profile_level.o
>  OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index c666aaeb52..0a79d00eac 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -31,6 +31,7 @@
>  #include "libavutil/hwcontext_qsv.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/log.h"
> +#include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/pixfmt.h"
>  #include "libavutil/time.h"
> @@ -228,7 +229,7 @@ static int qsv_decode_preinit(AVCodecContext *avctx,
> QSVContext *q, enum AVPixel
>  return 0;
>   }
>  
> -static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q,
> mfxVideoParam *param)
> +static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q,
> mfxVideoParam *param)
>  {
>  int ret;
>  
> @@ -615,7 +616,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext
> *q,
>  }
>  
>  if (!q->initialized) {
> -ret = qsv_decode_init(avctx, q, );
> +ret = qsv_decode_init_context(avctx, q, );
>  if (ret < 0)
>  goto reinit_fail;
>  q->initialized = 1;
> @@ -633,3 +634,213 @@ void ff_qsv_decode_flush(AVCodecContext *avctx,
> QSVContext *q)
>  q->orig_pix_fmt = AV_PIX_FMT_NONE;
>  q->initialized = 0;
>  }
> +
> +enum LoadPlugin {
> +LOAD_PLUGIN_NONE,
> +LOAD_PLUGIN_HEVC_SW,
> +LOAD_PLUGIN_HEVC_HW,
> +};
> +
> +typedef struct QSVDecContext {
> +AVClass *class;
> +QSVContext qsv;
> +
> +int load_plugin;
> +
> +AVFifoBuffer *packet_fifo;
> +
> +AVPacket buffer_pkt;
> +} QSVDecContext;
> +
> +static void qsv_clear_buffers(QSVDecContext *s)
> +{
> +AVPacket pkt;
> +while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
> +av_fifo_generic_read(s->packet_fifo, , sizeof(pkt), NULL);
> +av_packet_unref();
> +}
> +
> +av_packet_unref(>buffer_pkt);
> +}
> +
> +static av_cold int qsv_decode_close(AVCodecContext *avctx)
> +{
> +QSVDecContext *s = avctx->priv_data;
> +

av_strdup() is called for s->qsv.load_plugins, so need to call av_freep() to
free s->qsv.load_plugins.

av_freep(>qsv.load_plugins);

> +ff_qsv_decode_close(>qsv);
> +
> +qsv_clear_buffers(s);
> +
> +av_fifo_free(s->packet_fifo);
> +
> +return 0;
> +}
> +
> +static av_cold int 

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code

2020-12-01 Thread Xiang, Haihao

> ---
>  libavcodec/qsvdec_other.c | 188 --
>  1 file changed, 36 insertions(+), 152 deletions(-)
> 
> diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> index 2775e07955..266ac9f2e5 100644
> --- a/libavcodec/qsvdec_other.c
> +++ b/libavcodec/qsvdec_other.c
> @@ -189,170 +189,54 @@ static const AVOption options[] = {
>  { NULL },
>  };
>  
> -#if CONFIG_MPEG2_QSV_DECODER
> -static const AVClass mpeg2_qsv_class = {
> -.class_name = "mpeg2_qsv",
> -.item_name  = av_default_item_name,
> -.option = options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> +#define DEFINE_QSV_DECODER(x, X, bsf_name) \


How about to use the same macro for all QSV decoders? Compared
ff_mpeg2_qsv_decoder in qsvdec_other.c and ffmpeg_h264_qsv_decoder in
qsvh2645.c, besides x, X, bsf_name, option and priv_data_size are different too.
So we may define a macro below in qsvdec.h and use this macro for all QSV
decoders.

#define DEFINE_QSV_DECODER(x, X, bsf_name, option, priv_data_size) \
...

Thanks
Haihao

> +static const AVClass x##_qsv_class = { \
> +.class_name = #x "_qsv", \
> +.item_name  = av_default_item_name, \
> +.option = options, \
> +.version= LIBAVUTIL_VERSION_INT, \
> +}; \
> +AVCodec ff_##x##_qsv_decoder = { \
> +.name   = #x "_qsv", \
> +.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync Video
> acceleration)"), \
> +.priv_data_size = sizeof(QSVOtherContext), \
> +.type   = AVMEDIA_TYPE_VIDEO, \
> +.id = AV_CODEC_ID_##X, \
> +.init   = qsv_decode_init, \
> +.decode = qsv_decode_frame, \
> +.flush  = qsv_decode_flush, \
> +.close  = qsv_decode_close, \
> +.bsfs   = bsf_name, \
> +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
> +.priv_class = ##_qsv_class, \
> +.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> +AV_PIX_FMT_P010, \
> +AV_PIX_FMT_QSV, \
> +AV_PIX_FMT_NONE }, \
> +.hw_configs = ff_qsv_hw_configs, \
> +.wrapper_name   = "qsv", \
> +}; \
>  
> -AVCodec ff_mpeg2_qsv_decoder = {
> -.name   = "mpeg2_qsv",
> -.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync
> Video acceleration)"),
> -.priv_data_size = sizeof(QSVOtherContext),
> -.type   = AVMEDIA_TYPE_VIDEO,
> -.id = AV_CODEC_ID_MPEG2VIDEO,
> -.init   = qsv_decode_init,
> -.decode = qsv_decode_frame,
> -.flush  = qsv_decode_flush,
> -.close  = qsv_decode_close,
> -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> -.priv_class = _qsv_class,
> -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> -AV_PIX_FMT_QSV,
> -AV_PIX_FMT_NONE },
> -.hw_configs = ff_qsv_hw_configs,
> -.wrapper_name   = "qsv",
> -};
> +#if CONFIG_MPEG2_QSV_DECODER
> +DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
>  #endif
>  
>  #if CONFIG_VC1_QSV_DECODER
> -static const AVClass vc1_qsv_class = {
> -.class_name = "vc1_qsv",
> -.item_name  = av_default_item_name,
> -.option = options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> -
> -AVCodec ff_vc1_qsv_decoder = {
> -.name   = "vc1_qsv",
> -.long_name  = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync
> Video acceleration)"),
> -.priv_data_size = sizeof(QSVOtherContext),
> -.type   = AVMEDIA_TYPE_VIDEO,
> -.id = AV_CODEC_ID_VC1,
> -.init   = qsv_decode_init,
> -.decode = qsv_decode_frame,
> -.flush  = qsv_decode_flush,
> -.close  = qsv_decode_close,
> -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> -.priv_class = _qsv_class,
> -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> -AV_PIX_FMT_QSV,
> -AV_PIX_FMT_NONE },
> -.hw_configs = ff_qsv_hw_configs,
> -.wrapper_name   = "qsv",
> -};
> -#endif
> -
> -#if CONFIG_VP8_QSV_DECODER
> -static const AVClass vp8_qsv_class = {
> -.class_name = "vp8_qsv",
> -.item_name  = av_default_item_name,
> -.option = options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> -
> -AVCodec ff_vp8_qsv_decoder = {
> -.name   = "vp8_qsv",
> -.long_name  = NULL_IF_CONFIG_SMALL("VP8 video (Intel Quick Sync Video
> acceleration)"),
> -

[FFmpeg-devel] [PATCH 136/217] avcodec/cscd: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cscd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c
index d50ddd6258..6c72178f83 100644
--- a/libavcodec/cscd.c
+++ b/libavcodec/cscd.c
@@ -175,6 +175,6 @@ AVCodec ff_cscd_decoder = {
 .init   = decode_init,
 .close  = decode_end,
 .decode = decode_frame,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 135/217] avcodec/dfa: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dfa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c
index 31c6c39089..cd3a9d97a3 100644
--- a/libavcodec/dfa.c
+++ b/libavcodec/dfa.c
@@ -424,4 +424,5 @@ AVCodec ff_dfa_decoder = {
 .close  = dfa_decode_end,
 .decode = dfa_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 217/217] avcodec/snow: Hardcode table to save space

2020-12-01 Thread Andreas Rheinhardt
The size of ff_qexp is only 32 bytes, but the code to generate it at
runtime takes 47 bytes (GCC 9.3, x64, -O3 in an av_cold function); so
just hardcode it.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/snow.c | 10 --
 libavcodec/snow.h |  2 +-
 libavcodec/snowdata.h | 10 --
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index bb65a6f43f..a037e36873 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -123,15 +123,6 @@ int ff_snow_alloc_blocks(SnowContext *s){
 return 0;
 }
 
-static av_cold void init_qexp(void){
-int i;
-double v=128;
-
-for(i=0; ihttps://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 216/217] avcodec/h263data, ituh263*: Make initializing RL tables thread-safe

2020-12-01 Thread Andreas Rheinhardt
Up until now, ff_h263_rl_inter and ff_rl_intra_aic were initialized by
both ituh263dec and ituh263enc; the result was that although
ff_h263_encode_init() guards the initialization of its static data with
an AVOnce, initializing the aforementioned RLTables was still not
thread-safe because ff_h263_decode_init_vlc() might try to initialize it
at the same time.

This is fixed by only initializing these RLTables from a single place
that is guarded by a dedicated AVOnce.

This also makes the Snow encoder actually init-threadsafe; it was
already wrongly marked as init-threadsafe since commit
d49210788b0836d56dd872d517fe73f83b080101.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263data.c   | 16 +++-
 libavcodec/h263data.h   |  2 +-
 libavcodec/ituh263dec.c |  3 +--
 libavcodec/ituh263enc.c |  3 +--
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h263data.c b/libavcodec/h263data.c
index f649d58f4e..8fd97100f4 100644
--- a/libavcodec/h263data.c
+++ b/libavcodec/h263data.c
@@ -25,10 +25,12 @@
 
 #include 
 
+#include "libavutil/thread.h"
+
 #include "h263data.h"
 #include "mpegvideo.h"
 
-uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3];
+static uint8_t h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 3];
 
 /* intra MCBPC, mb_type = (intra), then (intraq) */
 const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 };
@@ -290,3 +292,15 @@ const AVRational ff_h263_pixel_aspect[16] = {
 {  0,  1 },
 {  0,  1 },
 };
+
+static av_cold void h263_init_rl(void)
+{
+ff_rl_init(_h263_rl_inter, h263_static_rl_table_store[0]);
+ff_rl_init(_rl_intra_aic,  h263_static_rl_table_store[1]);
+}
+
+av_cold void ff_h263_init_rl(void)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+ff_thread_once(_static_once, h263_init_rl);
+}
diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h
index 3da0e3771f..4a619f586e 100644
--- a/libavcodec/h263data.h
+++ b/libavcodec/h263data.h
@@ -61,7 +61,7 @@ extern const int8_t ff_inter_run[102];
 
 extern RLTable ff_h263_rl_inter;
 extern RLTable ff_rl_intra_aic;
-extern uint8_t ff_h263_static_rl_table_store[2][2][2 * MAX_RUN + MAX_LEVEL + 
3];
+void ff_h263_init_rl(void);
 
 extern const uint16_t ff_h263_format[8][2];
 
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index c1005b0994..7791093cfc 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -122,8 +122,7 @@ av_cold void ff_h263_decode_init_vlc(void)
 INIT_VLC_STATIC(_vlc, MV_VLC_BITS, 33,
  _mvtab[0][1], 2, 1,
  _mvtab[0][0], 2, 1, 538);
-ff_rl_init(_h263_rl_inter, ff_h263_static_rl_table_store[0]);
-ff_rl_init(_rl_intra_aic, ff_h263_static_rl_table_store[1]);
+ff_h263_init_rl();
 INIT_VLC_RL(ff_h263_rl_inter, 554);
 INIT_VLC_RL(ff_rl_intra_aic, 554);
 INIT_VLC_STATIC(_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 88d003ed47..10d34671e1 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -757,8 +757,7 @@ static av_cold void init_uni_h263_rl_tab(const RLTable *rl, 
uint8_t *len_tab)
 
 static av_cold void h263_encode_init_static(void)
 {
-ff_rl_init(_h263_rl_inter, ff_h263_static_rl_table_store[0]);
-ff_rl_init(_rl_intra_aic, ff_h263_static_rl_table_store[1]);
+ff_h263_init_rl();
 
 init_uni_h263_rl_tab(_rl_intra_aic,  uni_h263_intra_aic_rl_len);
 init_uni_h263_rl_tab(_h263_rl_inter, uni_h263_inter_rl_len);
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 215/217] avcodec/ituh263enc: Use ff_thread_once() for static initializations

2020-12-01 Thread Andreas Rheinhardt
This already makes initializing all the objects exclusively initialized
by ff_h263_encode_init() thread-safe; this includes the static tables of
ituh263enc.c: uni_h263_int*_rl_len, mv_penalty, fcode_tab as well as
umv_fcode_tab; it does not ff_h263_rl_inter as well as ff_rl_intra_aic,
as these are also initialized by ituh263dec.c and the code there is not
guarded by the AVOnce used here. This will be dealt with in a future
commit.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ituh263enc.c | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index e1debcf63b..88d003ed47 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -30,6 +30,7 @@
 #include 
 
 #include "libavutil/attributes.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "mpegvideo.h"
 #include "mpegvideodata.h"
@@ -671,7 +672,7 @@ void ff_h263_encode_motion(PutBitContext *pb, int val, int 
f_code)
 }
 }
 
-static av_cold void init_mv_penalty_and_fcode(MpegEncContext *s)
+static av_cold void init_mv_penalty_and_fcode(void)
 {
 int f_code;
 int mv;
@@ -754,21 +755,21 @@ static av_cold void init_uni_h263_rl_tab(const RLTable 
*rl, uint8_t *len_tab)
 }
 }
 
-av_cold void ff_h263_encode_init(MpegEncContext *s)
+static av_cold void h263_encode_init_static(void)
 {
-static int done = 0;
+ff_rl_init(_h263_rl_inter, ff_h263_static_rl_table_store[0]);
+ff_rl_init(_rl_intra_aic, ff_h263_static_rl_table_store[1]);
 
-if (!done) {
-done = 1;
+init_uni_h263_rl_tab(_rl_intra_aic,  uni_h263_intra_aic_rl_len);
+init_uni_h263_rl_tab(_h263_rl_inter, uni_h263_inter_rl_len);
 
-ff_rl_init(_h263_rl_inter, ff_h263_static_rl_table_store[0]);
-ff_rl_init(_rl_intra_aic, ff_h263_static_rl_table_store[1]);
+init_mv_penalty_and_fcode();
+}
 
-init_uni_h263_rl_tab(_rl_intra_aic,  uni_h263_intra_aic_rl_len);
-init_uni_h263_rl_tab(_h263_rl_inter, uni_h263_inter_rl_len);
+av_cold void ff_h263_encode_init(MpegEncContext *s)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
 
-init_mv_penalty_and_fcode(s);
-}
 s->me.mv_penalty= mv_penalty; // FIXME exact table for MSMPEG4 & H.263+
 
 s->intra_ac_vlc_length =s->inter_ac_vlc_length = 
uni_h263_inter_rl_len;
@@ -816,6 +817,8 @@ av_cold void ff_h263_encode_init(MpegEncContext *s)
 s->y_dc_scale_table=
 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
 }
+
+ff_thread_once(_static_once, h263_encode_init_static);
 }
 
 void ff_h263_encode_mba(MpegEncContext *s)
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 214/217] avcodec/ituh263enc: Remove unused function parameter

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ituh263enc.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index b1b78218a5..e1debcf63b 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -713,8 +713,7 @@ static av_cold void 
init_mv_penalty_and_fcode(MpegEncContext *s)
 }
 }
 
-static av_cold void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab,
- uint8_t *len_tab)
+static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab)
 {
 int slevel, run, last;
 
@@ -738,10 +737,9 @@ static av_cold void init_uni_h263_rl_tab(RLTable *rl, 
uint32_t *bits_tab,
 len=  rl->table_vlc[code][1];
 bits=bits*2+sign; len++;
 
-if(code!=rl->n && len < len_tab[index]){
-if(bits_tab) bits_tab[index]= bits;
+if (code != rl->n && len < len_tab[index])
 len_tab [index]= len;
-}
+
 /* ESC */
 bits= rl->table_vlc[rl->n][0];
 len = rl->table_vlc[rl->n][1];
@@ -749,10 +747,8 @@ static av_cold void init_uni_h263_rl_tab(RLTable *rl, 
uint32_t *bits_tab,
 bits=bits*64+run; len+=6;
 bits=bits*256+(level&0xff); len+=8;
 
-if(len < len_tab[index]){
-if(bits_tab) bits_tab[index]= bits;
+if (len < len_tab[index])
 len_tab [index]= len;
-}
 }
 }
 }
@@ -768,8 +764,8 @@ av_cold void ff_h263_encode_init(MpegEncContext *s)
 ff_rl_init(_h263_rl_inter, ff_h263_static_rl_table_store[0]);
 ff_rl_init(_rl_intra_aic, ff_h263_static_rl_table_store[1]);
 
-init_uni_h263_rl_tab(_rl_intra_aic, NULL, 
uni_h263_intra_aic_rl_len);
-init_uni_h263_rl_tab(_h263_rl_inter, NULL, 
uni_h263_inter_rl_len);
+init_uni_h263_rl_tab(_rl_intra_aic,  uni_h263_intra_aic_rl_len);
+init_uni_h263_rl_tab(_h263_rl_inter, uni_h263_inter_rl_len);
 
 init_mv_penalty_and_fcode(s);
 }
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 213/217] avcodec/me_cmp: Remove ff_check_alignment()

2020-12-01 Thread Andreas Rheinhardt
The usage of a static variable presents a potential for data races and
means that this function can't be used in init functions of codecs with
FF_CODEC_CAP_INIT_THREADSAFE (unless of course one presumes that
everything is alright in which case the error is not triggered; but then
the whole function is pointless...). This makes the Snow decoder
init-threadsafe as it already claims.

Notice that this function has been removed in 2014 by Libav in commit
9103185bd116930f90b847090e66a64fa9971ce2, because only some codepaths
are checked this way and because it only affects legacy compilers. The
latter is of course even more true today.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/me_cmp.c| 23 ---
 libavcodec/me_cmp.h|  2 --
 libavcodec/mpegvideo_enc.c |  6 --
 3 files changed, 31 deletions(-)

diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index ae248c52f8..34ecea9bb4 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -1011,31 +1011,8 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
 WRAPPER8_16_SQ(rd8x8_c, rd16_c)
 WRAPPER8_16_SQ(bit8x8_c, bit16_c)
 
-int ff_check_alignment(void)
-{
-static int did_fail = 0;
-LOCAL_ALIGNED_16(int, aligned, [4]);
-
-if ((intptr_t)aligned & 15) {
-if (!did_fail) {
-#if HAVE_MMX || HAVE_ALTIVEC
-av_log(NULL, AV_LOG_ERROR,
-"Compiler did not align stack variables. Libavcodec has been 
miscompiled\n"
-"and may be very slow or crash. This is not a bug in 
libavcodec,\n"
-"but in the compiler. You may try recompiling using gcc >= 
4.2.\n"
-"Do not report crashes to FFmpeg developers.\n");
-#endif
-did_fail=1;
-}
-return -1;
-}
-return 0;
-}
-
 av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx)
 {
-ff_check_alignment();
-
 c->sum_abs_dctelem = sum_abs_dctelem_c;
 
 /* TODO [0] 16  [1] 8 */
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 0a589e3c3d..e9b5161c9a 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -79,8 +79,6 @@ typedef struct MECmpContext {
 me_cmp_func median_sad[6];
 } MECmpContext;
 
-int ff_check_alignment(void);
-
 void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx);
 void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 7afc789ec0..878f507b57 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2785,8 +2785,6 @@ static int pre_estimate_motion_thread(AVCodecContext *c, 
void *arg){
 static int estimate_motion_thread(AVCodecContext *c, void *arg){
 MpegEncContext *s= *(void**)arg;
 
-ff_check_alignment();
-
 s->me.dia_size= s->avctx->dia_size;
 s->first_slice_line=1;
 for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
@@ -2813,8 +2811,6 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
 MpegEncContext *s= *(void**)arg;
 int mb_x, mb_y;
 
-ff_check_alignment();
-
 for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
 for(mb_x=0; mb_x < s->mb_width; mb_x++) {
 int xx = mb_x * 16;
@@ -2943,8 +2939,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
 uint8_t bit_buf_tex[2][MAX_MB_BYTES];
 PutBitContext pb[2], pb2[2], tex_pb[2];
 
-ff_check_alignment();
-
 for(i=0; i<2; i++){
 init_put_bits([i], bit_buf[i], MAX_MB_BYTES);
 init_put_bits(   [i], bit_buf2   [i], MAX_MB_BYTES);
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 212/217] avcodec/snow: Fix race in ff_snow_common_init()

2020-12-01 Thread Andreas Rheinhardt
Commits d49210788b0836d56dd872d517fe73f83b080101 and
ee8ce211ead04c8684da0c9c143814e57e9b9eda set the
FF_CODEC_CAP_INIT_THREADSAFE flag for the Snow encoder resp. decoder;
yet these codecs init functions aren't threadsafe at all:
ff_snow_common_init() initializes static data, but there is no check
at all that it is only done once by one thread.

This commit adds such checks; this makes the decoder init-threadsafe as
long as the stack is properly aligned.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/snow.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 066efc5171..bb65a6f43f 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -21,6 +21,7 @@
 #include "libavutil/intmath.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "me_cmp.h"
 #include "snow_dwt.h"
@@ -427,10 +428,19 @@ mca( 8, 0,8)
 mca( 0, 8,8)
 mca( 8, 8,8)
 
+static av_cold void snow_static_init(void)
+{
+for (int i = 0; i < MAX_REF_FRAMES; i++)
+for (int j = 0; j < MAX_REF_FRAMES; j++)
+ff_scale_mv_ref[i][j] = 256 * (i + 1) / (j + 1);
+init_qexp();
+}
+
 av_cold int ff_snow_common_init(AVCodecContext *avctx){
+static AVOnce init_static_once = AV_ONCE_INIT;
 SnowContext *s = avctx->priv_data;
 int width, height;
-int i, j;
+int i;
 
 s->avctx= avctx;
 s->max_ref_frames=1; //just make sure it's not an invalid value in case of 
no initial keyframe
@@ -480,8 +490,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
 mcfh(0, 8)
 mcfh(8, 8)
 
-init_qexp();
-
 //dec += FFMAX(s->chroma_h_shift, s->chroma_v_shift);
 
 width= s->avctx->width;
@@ -495,8 +503,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
 return AVERROR(ENOMEM);
 
 for(i=0; ilast_picture[i] = av_frame_alloc();
 if (!s->last_picture[i])
 return AVERROR(ENOMEM);
@@ -507,6 +513,8 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
 if (!s->mconly_picture || !s->current_picture)
 return AVERROR(ENOMEM);
 
+ff_thread_once(_static_once, snow_static_init);
+
 return 0;
 }
 
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 211/217] avcodec/bink: Don't waste space for VLC table

2020-12-01 Thread Andreas Rheinhardt
The Bink video decoder uses VLCs; the longest codes of these VLCs have
different lengths, yet they are all so small that each VLC is read in
one go, so that the number of elements in the VLC table actually used by
each table is 1 << nb_bits, where nb_bits is the length of the longest
code. Yet when determining the size of the VLC table nb_bits has been
overestimated as the number of bits of the longest code in all VLCs,
making said table unnecessary big (2048 vs 976 elements).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bink.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index f1fa9c0071..04c104be48 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -1311,11 +1311,12 @@ static int decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame, AVPac
 
 static av_cold void bink_init_vlcs(void)
 {
-for (int i = 0; i < 16; i++) {
-static VLC_TYPE table[16 * 128][2];
+for (int i = 0, offset = 0; i < 16; i++) {
+static VLC_TYPE table[976][2];
 const int maxbits = bink_tree_lens[i][15];
-bink_trees[i].table = table + i*128;
+bink_trees[i].table   = table + offset;
 bink_trees[i].table_allocated = 1 << maxbits;
+offset   += bink_trees[i].table_allocated;
 init_vlc(_trees[i], maxbits, 16,
  bink_tree_lens[i], 1, 1,
  bink_tree_bits[i], 1, 1, INIT_VLC_USE_NEW_STATIC | 
INIT_VLC_LE);
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 210/217] avcodec/bink: Make decoder init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bink.c | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index ec164d0165..f1fa9c0071 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -23,6 +23,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
+#include "libavutil/thread.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -1308,6 +1309,19 @@ static int decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame, AVPac
 return pkt->size;
 }
 
+static av_cold void bink_init_vlcs(void)
+{
+for (int i = 0; i < 16; i++) {
+static VLC_TYPE table[16 * 128][2];
+const int maxbits = bink_tree_lens[i][15];
+bink_trees[i].table = table + i*128;
+bink_trees[i].table_allocated = 1 << maxbits;
+init_vlc(_trees[i], maxbits, 16,
+ bink_tree_lens[i], 1, 1,
+ bink_tree_bits[i], 1, 1, INIT_VLC_USE_NEW_STATIC | 
INIT_VLC_LE);
+}
+}
+
 /**
  * Calculate quantization tables for version b
  */
@@ -1342,11 +1356,10 @@ static av_cold void binkb_calc_quant(void)
 
 static av_cold int decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 BinkContext * const c = avctx->priv_data;
-static VLC_TYPE table[16 * 128][2];
-static int binkb_initialised = 0;
 HpelDSPContext hdsp;
-int i, ret;
+int ret;
 int flags;
 
 c->version = avctx->codec_tag >> 24;
@@ -1357,16 +1370,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
 flags = AV_RL32(avctx->extradata);
 c->has_alpha = flags & BINK_FLAG_ALPHA;
 c->swap_planes = c->version >= 'h';
-if (!bink_trees[15].table) {
-for (i = 0; i < 16; i++) {
-const int maxbits = bink_tree_lens[i][15];
-bink_trees[i].table = table + i*128;
-bink_trees[i].table_allocated = 1 << maxbits;
-init_vlc(_trees[i], maxbits, 16,
- bink_tree_lens[i], 1, 1,
- bink_tree_bits[i], 1, 1, INIT_VLC_USE_NEW_STATIC | 
INIT_VLC_LE);
-}
-}
 c->avctx = avctx;
 
 if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
@@ -1388,11 +1391,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
 return ret;
 
 if (c->version == 'b') {
-if (!binkb_initialised) {
-binkb_calc_quant();
-binkb_initialised = 1;
-}
+static AVOnce binkb_init_once = AV_ONCE_INIT;
+ff_thread_once(_init_once, binkb_calc_quant);
 }
+ff_thread_once(_static_once, bink_init_vlcs);
 
 return 0;
 }
@@ -1425,5 +1427,5 @@ AVCodec ff_bink_decoder = {
 .decode = decode_frame,
 .flush  = flush,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 209/217] avcodec/kmvc: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/kmvc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index ffe6a142e9..1d6260ae87 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -425,4 +425,5 @@ AVCodec ff_kmvc_decoder = {
 .init   = decode_init,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 208/217] avcodec: Mark ff_ass_subtitle_header based decoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
ff_ass_subtitle_header_full() just uses av_asprintf() and is therefore
thread-safe itself.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ccaption_dec.c | 2 ++
 libavcodec/jacosubdec.c   | 2 ++
 libavcodec/microdvddec.c  | 2 ++
 libavcodec/movtextdec.c   | 2 ++
 libavcodec/mpl2dec.c  | 2 ++
 libavcodec/realtextdec.c  | 2 ++
 libavcodec/samidec.c  | 2 ++
 libavcodec/srtdec.c   | 3 +++
 libavcodec/subviewerdec.c | 2 ++
 libavcodec/textdec.c  | 6 ++
 libavcodec/webvttdec.c| 2 ++
 11 files changed, 27 insertions(+)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index a208e19b95..a75a5e03db 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 #include "ass.h"
+#include "internal.h"
 #include "libavutil/opt.h"
 
 #define SCREEN_ROWS 15
@@ -952,4 +953,5 @@ AVCodec ff_ccaption_decoder = {
 .decode = decode,
 .priv_class = _dec_class,
 .capabilities   = AV_CODEC_CAP_DELAY,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/jacosubdec.c b/libavcodec/jacosubdec.c
index cdb372af58..b632e474c5 100644
--- a/libavcodec/jacosubdec.c
+++ b/libavcodec/jacosubdec.c
@@ -26,6 +26,7 @@
 
 #include 
 #include "ass.h"
+#include "internal.h"
 #include "jacosub.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
@@ -202,4 +203,5 @@ AVCodec ff_jacosub_decoder = {
 .decode = jacosub_decode_frame,
 .flush  = ff_ass_decoder_flush,
 .priv_data_size = sizeof(FFASSDecoderContext),
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/microdvddec.c b/libavcodec/microdvddec.c
index dad0ec8a22..c39d54e084 100644
--- a/libavcodec/microdvddec.c
+++ b/libavcodec/microdvddec.c
@@ -31,6 +31,7 @@
 #include "libavutil/bprint.h"
 #include "avcodec.h"
 #include "ass.h"
+#include "internal.h"
 
 static int indexof(const char *s, int c)
 {
@@ -377,4 +378,5 @@ AVCodec ff_microdvd_decoder = {
 .decode   = microdvd_decode_frame,
 .flush= ff_ass_decoder_flush,
 .priv_data_size = sizeof(FFASSDecoderContext),
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index ad790bf44c..8a219a457c 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -28,6 +28,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "bytestream.h"
+#include "internal.h"
 
 #define STYLE_FLAG_BOLD (1<<0)
 #define STYLE_FLAG_ITALIC   (1<<1)
@@ -593,4 +594,5 @@ AVCodec ff_movtext_decoder = {
 .decode   = mov_text_decode_frame,
 .close= mov_text_decode_close,
 .flush= mov_text_flush,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/mpl2dec.c b/libavcodec/mpl2dec.c
index 409e4b3708..d60528af32 100644
--- a/libavcodec/mpl2dec.c
+++ b/libavcodec/mpl2dec.c
@@ -27,6 +27,7 @@
 
 #include "avcodec.h"
 #include "ass.h"
+#include "internal.h"
 #include "libavutil/bprint.h"
 
 static int mpl2_event_to_ass(AVBPrint *buf, const char *p)
@@ -90,4 +91,5 @@ AVCodec ff_mpl2_decoder = {
 .init   = ff_ass_subtitle_header_default,
 .flush  = ff_ass_decoder_flush,
 .priv_data_size = sizeof(FFASSDecoderContext),
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/realtextdec.c b/libavcodec/realtextdec.c
index 5084781123..8581081c02 100644
--- a/libavcodec/realtextdec.c
+++ b/libavcodec/realtextdec.c
@@ -26,6 +26,7 @@
 
 #include "avcodec.h"
 #include "ass.h"
+#include "internal.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 
@@ -83,4 +84,5 @@ AVCodec ff_realtext_decoder = {
 .init   = ff_ass_subtitle_header_default,
 .flush  = ff_ass_decoder_flush,
 .priv_data_size = sizeof(FFASSDecoderContext),
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
index e32f238c62..400a7642a2 100644
--- a/libavcodec/samidec.c
+++ b/libavcodec/samidec.c
@@ -28,6 +28,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "htmlsubtitles.h"
+#include "internal.h"
 
 typedef struct {
 AVBPrint source;
@@ -190,4 +191,5 @@ AVCodec ff_sami_decoder = {
 .close  = sami_close,
 .decode = sami_decode_frame,
 .flush  = sami_flush,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index ecc0801595..8ee4e04934 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -26,6 +26,7 @@
 #include "avcodec.h"
 #include "ass.h"
 #include "htmlsubtitles.h"
+#include "internal.h"
 
 static int srt_to_ass(AVCodecContext *avctx, AVBPrint *dst,
const char *in, int x1, int y1, int x2, int y2)
@@ -96,6 +97,7 @@ AVCodec ff_srt_decoder = {
 .decode   = srt_decode_frame,
 .flush= 

[FFmpeg-devel] [PATCH 207/217] avcodec/assdec: Mark decoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/assdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c
index f0b1069cd2..78df1c30ad 100644
--- a/libavcodec/assdec.c
+++ b/libavcodec/assdec.c
@@ -23,6 +23,7 @@
 
 #include "avcodec.h"
 #include "ass.h"
+#include "internal.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 
@@ -69,6 +70,7 @@ AVCodec ff_ssa_decoder = {
 .id   = AV_CODEC_ID_ASS,
 .init = ass_decode_init,
 .decode   = ass_decode_frame,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 
@@ -80,5 +82,6 @@ AVCodec ff_ass_decoder = {
 .id   = AV_CODEC_ID_ASS,
 .init = ass_decode_init,
 .decode   = ass_decode_frame,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 206/217] avcodec/dvbsubdec: Make decoder init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Note: This decoder uses a static variable in save_display_set() (which
is only enabled if DEBUG is defined); yet said function can't be reached
from the decoder's init function at all, so it is no problem for
setting the FF_CODEC_CAP_INIT_THREADSAFE flag.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dvbsubdec.c | 55 --
 1 file changed, 32 insertions(+), 23 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index b1a0c3ff24..81b8460593 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -26,6 +26,7 @@
 #include "libavutil/colorspace.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
+#include "libavutil/thread.h"
 
 #define DVBSUB_PAGE_SEGMENT 0x10
 #define DVBSUB_REGION_SEGMENT   0x11
@@ -254,31 +255,9 @@ static void delete_regions(DVBSubContext *ctx)
 }
 }
 
-static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
+static av_cold void init_default_clut(void)
 {
 int i, r, g, b, a = 0;
-DVBSubContext *ctx = avctx->priv_data;
-
-if (ctx->substream < 0) {
-ctx->composition_id = -1;
-ctx->ancillary_id   = -1;
-} else if (!avctx->extradata || (avctx->extradata_size < 4) || 
((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
-av_log(avctx, AV_LOG_WARNING, "Invalid DVB subtitles stream 
extradata!\n");
-ctx->composition_id = -1;
-ctx->ancillary_id   = -1;
-} else {
-if (avctx->extradata_size > 5*ctx->substream + 2) {
-ctx->composition_id = AV_RB16(avctx->extradata + 5*ctx->substream);
-ctx->ancillary_id   = AV_RB16(avctx->extradata + 5*ctx->substream 
+ 2);
-} else {
-av_log(avctx, AV_LOG_WARNING, "Selected DVB subtitles sub-stream 
%d is not available\n", ctx->substream);
-ctx->composition_id = AV_RB16(avctx->extradata);
-ctx->ancillary_id   = AV_RB16(avctx->extradata + 2);
-}
-}
-
-ctx->version = -1;
-ctx->prev_start = AV_NOPTS_VALUE;
 
 default_clut.id = -1;
 default_clut.next = NULL;
@@ -339,6 +318,35 @@ static av_cold int dvbsub_init_decoder(AVCodecContext 
*avctx)
 }
 default_clut.clut256[i] = RGBA(r, g, b, a);
 }
+}
+
+static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+DVBSubContext *ctx = avctx->priv_data;
+
+if (ctx->substream < 0) {
+ctx->composition_id = -1;
+ctx->ancillary_id   = -1;
+} else if (!avctx->extradata || (avctx->extradata_size < 4) || 
((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
+av_log(avctx, AV_LOG_WARNING, "Invalid DVB subtitles stream 
extradata!\n");
+ctx->composition_id = -1;
+ctx->ancillary_id   = -1;
+} else {
+if (avctx->extradata_size > 5*ctx->substream + 2) {
+ctx->composition_id = AV_RB16(avctx->extradata + 5*ctx->substream);
+ctx->ancillary_id   = AV_RB16(avctx->extradata + 5*ctx->substream 
+ 2);
+} else {
+av_log(avctx, AV_LOG_WARNING, "Selected DVB subtitles sub-stream 
%d is not available\n", ctx->substream);
+ctx->composition_id = AV_RB16(avctx->extradata);
+ctx->ancillary_id   = AV_RB16(avctx->extradata + 2);
+}
+}
+
+ctx->version = -1;
+ctx->prev_start = AV_NOPTS_VALUE;
+
+ff_thread_once(_static_once, init_default_clut);
 
 return 0;
 }
@@ -1758,4 +1766,5 @@ AVCodec ff_dvbsub_decoder = {
 .close  = dvbsub_close_decoder,
 .decode = dvbsub_decode,
 .priv_class = _class,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 205/217] avcodec/dvbsubdec: Add const where appropriate

2020-12-01 Thread Andreas Rheinhardt
These pointers sometimes point to static storage (namely to
default_clut), so adding const to the pointed-to type is important to
ensure that one does not accidentally modify something that is not owned
by a single AVCodecContext.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dvbsubdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 9bee33e4a2..b1a0c3ff24 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -724,8 +724,8 @@ static int save_subtitle_set(AVCodecContext *avctx, 
AVSubtitle *sub, int *got_ou
 DVBSubDisplayDefinition *display_def = ctx->display_definition;
 DVBSubRegion *region;
 AVSubtitleRect *rect;
-DVBSubCLUT *clut;
-uint32_t *clut_table;
+const DVBSubCLUT *clut;
+const uint32_t *clut_table;
 int i;
 int offset_x=0, offset_y=0;
 int ret = 0;
@@ -1454,8 +1454,8 @@ static int save_display_set(DVBSubContext *ctx)
 {
 DVBSubRegion *region;
 DVBSubRegionDisplay *display;
-DVBSubCLUT *clut;
-uint32_t *clut_table;
+const DVBSubCLUT *clut;
+const uint32_t *clut_table;
 int x_pos, y_pos, width, height;
 int x, y, y_off, x_off;
 uint32_t *pbuf;
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 204/217] avcodec/ass_split: Don't presume strlen to be >= 2

2020-12-01 Thread Andreas Rheinhardt
Fixes potential heap-buffer-overflow.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ass_split.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index c2c388d9f0..189272bbd9 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -376,7 +376,7 @@ ASSSplitContext *ff_ass_split(const char *buf)
 ASSSplitContext *ctx = av_mallocz(sizeof(*ctx));
 if (!ctx)
 return NULL;
-if (buf && !memcmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
+if (buf && !strncmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
 buf += 3;
 ctx->current_section = -1;
 if (ass_split(ctx, buf) < 0) {
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 203/217] avcodec/movtextenc, srtenc, webvttenc: Mark encoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
They all rely on ff_ass_split(), which does not have any static state.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/movtextenc.c | 2 +-
 libavcodec/srtenc.c | 4 
 libavcodec/webvttenc.c  | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 1bef21e0b9..8da98d61e1 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -731,5 +731,5 @@ AVCodec ff_movtext_encoder = {
 .init   = mov_text_encode_init,
 .encode_sub = mov_text_encode_frame,
 .close  = mov_text_encode_close,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c
index 655b65679e..1ec5e693ef 100644
--- a/libavcodec/srtenc.c
+++ b/libavcodec/srtenc.c
@@ -25,6 +25,7 @@
 #include "libavutil/bprint.h"
 #include "ass_split.h"
 #include "ass.h"
+#include "internal.h"
 
 
 #define SRT_STACK_SIZE 64
@@ -314,6 +315,7 @@ AVCodec ff_srt_encoder = {
 .init   = srt_encode_init,
 .encode_sub = srt_encode_frame,
 .close  = srt_encode_close,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 
@@ -327,6 +329,7 @@ AVCodec ff_subrip_encoder = {
 .init   = srt_encode_init,
 .encode_sub = srt_encode_frame,
 .close  = srt_encode_close,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 
@@ -340,5 +343,6 @@ AVCodec ff_text_encoder = {
 .init   = srt_encode_init,
 .encode_sub = text_encode_frame,
 .close  = srt_encode_close,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index febf6ee370..ed762f77e8 100644
--- a/libavcodec/webvttenc.c
+++ b/libavcodec/webvttenc.c
@@ -26,6 +26,7 @@
 #include "libavutil/bprint.h"
 #include "ass_split.h"
 #include "ass.h"
+#include "internal.h"
 
 #define WEBVTT_STACK_SIZE 64
 typedef struct {
@@ -233,4 +234,5 @@ AVCodec ff_webvtt_encoder = {
 .init   = webvtt_encode_init,
 .encode_sub = webvtt_encode_frame,
 .close  = webvtt_encode_close,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 202/217] avcodec/assenc: Mark encoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/assenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c
index a6e1d5d8b9..f3ced556de 100644
--- a/libavcodec/assenc.c
+++ b/libavcodec/assenc.c
@@ -23,6 +23,7 @@
 
 #include "avcodec.h"
 #include "ass.h"
+#include "internal.h"
 #include "libavutil/avstring.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
@@ -111,6 +112,7 @@ AVCodec ff_ssa_encoder = {
 .init = ass_encode_init,
 .encode_sub   = ass_encode_frame,
 .priv_data_size = sizeof(ASSEncodeContext),
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 
@@ -123,5 +125,6 @@ AVCodec ff_ass_encoder = {
 .init = ass_encode_init,
 .encode_sub   = ass_encode_frame,
 .priv_data_size = sizeof(ASSEncodeContext),
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 201/217] avcodec/sonic: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/sonic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index d8254f3a2a..4f75b2d985 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -1082,7 +1082,7 @@ AVCodec ff_sonic_decoder = {
 .close  = sonic_decode_close,
 .decode = sonic_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
 #endif /* CONFIG_SONIC_DECODER */
 
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 200/217] avcodec/sonic: Mark encoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/sonic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index a285228bbc..d8254f3a2a 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -1097,7 +1097,7 @@ AVCodec ff_sonic_encoder = {
 .encode2= sonic_encode_frame,
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, 
AV_SAMPLE_FMT_NONE },
 .capabilities   = AV_CODEC_CAP_EXPERIMENTAL,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 .close  = sonic_encode_close,
 };
 #endif
@@ -1113,7 +1113,7 @@ AVCodec ff_sonic_ls_encoder = {
 .encode2= sonic_encode_frame,
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, 
AV_SAMPLE_FMT_NONE },
 .capabilities   = AV_CODEC_CAP_EXPERIMENTAL,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 .close  = sonic_encode_close,
 };
 #endif
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 199/217] avcodec/dca*: Make decoder init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dca_lbr.c | 10 +-
 libavcodec/dca_lbr.h |  1 +
 libavcodec/dcadec.c  | 14 +++---
 libavcodec/dcahuff.c |  6 --
 4 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 747fdafd3e..1016a0823d 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -123,21 +123,15 @@ static const uint16_t channel_layouts[7] = {
 static floatcos_tab[256];
 static floatlpc_tab[16];
 
-static av_cold void init_tables(void)
+av_cold void ff_dca_lbr_init_tables(void)
 {
-static int initialized;
 int i;
 
-if (initialized)
-return;
-
 for (i = 0; i < 256; i++)
 cos_tab[i] = cos(M_PI * i / 128);
 
 for (i = 0; i < 16; i++)
 lpc_tab[i] = sin((i - 8) * (M_PI / ((i < 8) ? 17 : 15)));
-
-initialized = 1;
 }
 
 static int parse_lfe_24(DCALbrDecoder *s)
@@ -1817,8 +1811,6 @@ av_cold void ff_dca_lbr_flush(DCALbrDecoder *s)
 
 av_cold int ff_dca_lbr_init(DCALbrDecoder *s)
 {
-init_tables();
-
 if (!(s->fdsp = avpriv_float_dsp_alloc(0)))
 return AVERROR(ENOMEM);
 
diff --git a/libavcodec/dca_lbr.h b/libavcodec/dca_lbr.h
index 6d4c0a8a63..17472d6dee 100644
--- a/libavcodec/dca_lbr.h
+++ b/libavcodec/dca_lbr.h
@@ -129,6 +129,7 @@ typedef struct DCALbrDecoder {
 int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset);
 int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame);
 av_cold void ff_dca_lbr_flush(DCALbrDecoder *s);
+av_cold void ff_dca_lbr_init_tables(void);
 av_cold int ff_dca_lbr_init(DCALbrDecoder *s);
 av_cold void ff_dca_lbr_close(DCALbrDecoder *s);
 
diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 4146a85ec5..be860d4cc7 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -20,6 +20,7 @@
 
 #include "libavutil/opt.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/thread.h"
 
 #include "dcadec.h"
 #include "dcahuff.h"
@@ -318,8 +319,15 @@ static av_cold int dcadec_close(AVCodecContext *avctx)
 return 0;
 }
 
+static av_cold void dcadec_init_static(void)
+{
+ff_dca_lbr_init_tables();
+ff_dca_init_vlcs();
+}
+
 static av_cold int dcadec_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 DCAContext *s = avctx->priv_data;
 
 s->avctx = avctx;
@@ -328,8 +336,6 @@ static av_cold int dcadec_init(AVCodecContext *avctx)
 s->xll.avctx = avctx;
 s->lbr.avctx = avctx;
 
-ff_dca_init_vlcs();
-
 if (ff_dca_core_init(>core) < 0)
 return AVERROR(ENOMEM);
 
@@ -362,6 +368,8 @@ static av_cold int dcadec_init(AVCodecContext *avctx)
 break;
 }
 
+ff_thread_once(_static_once, dcadec_init_static);
+
 return 0;
 }
 
@@ -396,5 +404,5 @@ AVCodec ff_dca_decoder = {
   AV_SAMPLE_FMT_FLTP, 
AV_SAMPLE_FMT_NONE },
 .priv_class = _class,
 .profiles   = NULL_IF_CONFIG_SMALL(ff_dca_profiles),
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c
index 0a3eeb4d22..6197ccfe9b 100644
--- a/libavcodec/dcahuff.c
+++ b/libavcodec/dcahuff.c
@@ -1263,12 +1263,8 @@ VLC ff_dca_vlc_rsd;
 av_cold void ff_dca_init_vlcs(void)
 {
 static VLC_TYPE dca_table[30214][2];
-static int vlcs_initialized = 0;
 int i, j, k = 0;
 
-if (vlcs_initialized)
-return;
-
 #define DCA_INIT_VLC(vlc, a, b, c, d)   \
 do {\
 vlc.table   = _table[vlc_offs[k]];  \
@@ -1331,8 +1327,6 @@ av_cold void ff_dca_init_vlcs(void)
 LBR_INIT_VLC(ff_dca_vlc_grid_2,  grid_2,  9);
 LBR_INIT_VLC(ff_dca_vlc_grid_3,  grid_3,  9);
 LBR_INIT_VLC(ff_dca_vlc_rsd, rsd, 6);
-
-vlcs_initialized = 1;
 }
 
 uint32_t ff_dca_vlc_calc_quant_bits(int *values, uint8_t n, uint8_t sel, 
uint8_t table)
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 198/217] avcodec/qtrleenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/qtrleenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 8b0edf7b3d..63d7bb33a9 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -413,5 +413,5 @@ AVCodec ff_qtrle_encoder = {
 .pix_fmts   = (const enum AVPixelFormat[]){
 AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB555BE, AV_PIX_FMT_ARGB, 
AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
 },
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 197/217] avcodec/wavpackenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wavpackenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 0c85fbe374..ee9cd92c32 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -2973,4 +2973,5 @@ AVCodec ff_wavpack_encoder = {
  AV_SAMPLE_FMT_S32P,
  AV_SAMPLE_FMT_FLTP,
  AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 192/217] avcodec/binkaudio: Mark decoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/binkaudio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 2ee6f95f78..7d8cad1ec5 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -346,7 +346,7 @@ AVCodec ff_binkaudio_rdft_decoder = {
 .close  = decode_end,
 .receive_frame  = binkaudio_receive_frame,
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
 
 AVCodec ff_binkaudio_dct_decoder = {
@@ -359,5 +359,5 @@ AVCodec ff_binkaudio_dct_decoder = {
 .close  = decode_end,
 .receive_frame  = binkaudio_receive_frame,
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 191/217] avcodec/binkaudio: Check return value of functions that can fail

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/binkaudio.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index f25aea0d64..2ee6f95f78 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -69,7 +69,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 BinkAudioContext *s = avctx->priv_data;
 int sample_rate = avctx->sample_rate;
 int sample_rate_half;
-int i;
+int i, ret;
 int frame_len_bits;
 
 /* determine frame length */
@@ -131,11 +131,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
 s->first = 1;
 
 if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == 
AV_CODEC_ID_BINKAUDIO_RDFT)
-ff_rdft_init(>trans.rdft, frame_len_bits, DFT_C2R);
+ret = ff_rdft_init(>trans.rdft, frame_len_bits, DFT_C2R);
 else if (CONFIG_BINKAUDIO_DCT_DECODER)
-ff_dct_init(>trans.dct, frame_len_bits, DCT_III);
+ret = ff_dct_init(>trans.dct, frame_len_bits, DCT_III);
 else
 av_assert0(0);
+if (ret < 0)
+return ret;
 
 s->pkt = av_packet_alloc();
 if (!s->pkt)
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 196/217] avcodec/qtrle: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/qtrle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index 6bdde75df4..2fce144c52 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -600,4 +600,5 @@ AVCodec ff_qtrle_decoder = {
 .decode = qtrle_decode_frame,
 .flush  = qtrle_decode_flush,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 195/217] avcodec/mpegaudioenc: Mark encoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegaudioenc_fixed.c | 1 +
 libavcodec/mpegaudioenc_float.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavcodec/mpegaudioenc_fixed.c b/libavcodec/mpegaudioenc_fixed.c
index 022b6fedd3..eec2ecb579 100644
--- a/libavcodec/mpegaudioenc_fixed.c
+++ b/libavcodec/mpegaudioenc_fixed.c
@@ -38,4 +38,5 @@ AVCodec ff_mp2fixed_encoder = {
  AV_CH_LAYOUT_STEREO,
  0 },
 .defaults  = mp2_defaults,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/mpegaudioenc_float.c b/libavcodec/mpegaudioenc_float.c
index 4d4ab2d7fa..310f7ef98a 100644
--- a/libavcodec/mpegaudioenc_float.c
+++ b/libavcodec/mpegaudioenc_float.c
@@ -39,4 +39,5 @@ AVCodec ff_mp2_encoder = {
  AV_CH_LAYOUT_STEREO,
  0 },
 .defaults  = mp2_defaults,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 190/217] avcodec/binkaudio: Fix memleak upon init failure

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/binkaudio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 7b5965ede1..f25aea0d64 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -344,6 +344,7 @@ AVCodec ff_binkaudio_rdft_decoder = {
 .close  = decode_end,
 .receive_frame  = binkaudio_receive_frame,
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
 
 AVCodec ff_binkaudio_dct_decoder = {
@@ -356,4 +357,5 @@ AVCodec ff_binkaudio_dct_decoder = {
 .close  = decode_end,
 .receive_frame  = binkaudio_receive_frame,
 .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 194/217] avcodec/012v: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/012v.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/012v.c b/libavcodec/012v.c
index b5a4066656..7231819875 100644
--- a/libavcodec/012v.c
+++ b/libavcodec/012v.c
@@ -152,4 +152,5 @@ AVCodec ff_zero12v_decoder = {
 .init   = zero12v_decode_init,
 .decode = zero12v_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 189/217] avcodec/sanm: Cleanup generically on init failure

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/sanm.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 9c11600b76..599ecc3737 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -470,10 +470,8 @@ static av_cold int init_buffers(SANMVideoContext *ctx)
   >stored_frame_size, ctx->buf_size);
 
 if (!ctx->frm0 || !ctx->frm1 || !ctx->frm2 ||
-(!ctx->stored_frame && !ctx->version)) {
-destroy_buffers(ctx);
+(!ctx->stored_frame && !ctx->version))
 return AVERROR(ENOMEM);
-}
 
 return 0;
 }
@@ -1525,5 +1523,5 @@ AVCodec ff_sanm_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 193/217] avcodec/alac: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/alac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 9040673528..abcf032acc 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -626,6 +626,6 @@ AVCodec ff_alac_decoder = {
 .close  = alac_decode_close,
 .decode = alac_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 .priv_class = _class
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 188/217] avcodec/sanm: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/sanm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index debd0c..9c11600b76 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -1525,4 +1525,5 @@ AVCodec ff_sanm_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 187/217] avcodec/takdec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/takdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index 9fa1cb1f7f..af491d96e7 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -952,4 +952,5 @@ AVCodec ff_tak_decoder = {
 AV_SAMPLE_FMT_S16P,
 AV_SAMPLE_FMT_S32P,
 AV_SAMPLE_FMT_NONE },
+.caps_internal= FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 186/217] avcodec/v410dec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v410dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/v410dec.c b/libavcodec/v410dec.c
index 7ad5eb8fb5..87c98f75ba 100644
--- a/libavcodec/v410dec.c
+++ b/libavcodec/v410dec.c
@@ -124,5 +124,6 @@ AVCodec ff_v410_decoder = {
 .init = v410_decode_init,
 .decode   = v410_decode_frame,
 .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS |
-AV_CODEC_CAP_FRAME_THREADS
+AV_CODEC_CAP_FRAME_THREADS,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 185/217] avcodec/tiertexseqv: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/tiertexseqv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c
index 91c8314379..9610989a6f 100644
--- a/libavcodec/tiertexseqv.c
+++ b/libavcodec/tiertexseqv.c
@@ -271,4 +271,5 @@ AVCodec ff_tiertexseqvideo_decoder = {
 .close  = seqvideo_decode_end,
 .decode = seqvideo_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 184/217] avcodec/vmnc: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vmnc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c
index 7f441bc4bd..43f8c2aedb 100644
--- a/libavcodec/vmnc.c
+++ b/libavcodec/vmnc.c
@@ -582,4 +582,5 @@ AVCodec ff_vmnc_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 183/217] avcodec/v308dec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v308dec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v308dec.c b/libavcodec/v308dec.c
index dd53fbded4..377665dbff 100644
--- a/libavcodec/v308dec.c
+++ b/libavcodec/v308dec.c
@@ -80,4 +80,5 @@ AVCodec ff_v308_decoder = {
 .init = v308_decode_init,
 .decode   = v308_decode_frame,
 .capabilities = AV_CODEC_CAP_DR1,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 182/217] avcodec/v210x: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v210x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c
index f6a453aabf..70b2da55f6 100644
--- a/libavcodec/v210x.c
+++ b/libavcodec/v210x.c
@@ -128,4 +128,5 @@ AVCodec ff_v210x_decoder = {
 .init   = decode_init,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 181/217] avcodec/v210dec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v210dec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 044d35338b..0dec8a9769 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -226,4 +226,5 @@ AVCodec ff_v210_decoder = {
   AV_CODEC_CAP_SLICE_THREADS |
   AV_CODEC_CAP_FRAME_THREADS,
 .priv_class = _class,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 180/217] avcodec/vcr1: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vcr1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
index 28a5eec7d1..e19bac1ec7 100644
--- a/libavcodec/vcr1.c
+++ b/libavcodec/vcr1.c
@@ -130,4 +130,5 @@ AVCodec ff_vcr1_decoder = {
 .init   = vcr1_decode_init,
 .decode = vcr1_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 179/217] avcodec/vqavideo: Cleanup generically on init failure

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vqavideo.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index 05f77fd1c8..004e11ed7f 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -171,17 +171,17 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
 s->codebook_size = MAX_CODEBOOK_SIZE;
 s->codebook = av_malloc(s->codebook_size);
 if (!s->codebook)
-goto fail;
+return AVERROR(ENOMEM);
 s->next_codebook_buffer = av_malloc(s->codebook_size);
 if (!s->next_codebook_buffer)
-goto fail;
+return AVERROR(ENOMEM);
 
 /* allocate decode buffer */
 s->decode_buffer_size = (s->width / s->vector_width) *
 (s->height / s->vector_height) * 2;
 s->decode_buffer = av_mallocz(s->decode_buffer_size);
 if (!s->decode_buffer)
-goto fail;
+return AVERROR(ENOMEM);
 
 /* initialize the solid-color vectors */
 if (s->vector_height == 4) {
@@ -198,11 +198,6 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
 s->next_codebook_buffer_index = 0;
 
 return 0;
-fail:
-av_freep(>codebook);
-av_freep(>next_codebook_buffer);
-av_freep(>decode_buffer);
-return AVERROR(ENOMEM);
 }
 
 #define CHECK_COUNT() \
@@ -653,5 +648,5 @@ AVCodec ff_vqa_decoder = {
 .decode = vqa_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
 .defaults   = vqa_defaults,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 178/217] avcodec/vqavideo: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vqavideo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index f45390cfe5..05f77fd1c8 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -653,4 +653,5 @@ AVCodec ff_vqa_decoder = {
 .decode = vqa_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
 .defaults   = vqa_defaults,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 177/217] avcodec/vb: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vb.c b/libavcodec/vb.c
index fe419c7663..278d772082 100644
--- a/libavcodec/vb.c
+++ b/libavcodec/vb.c
@@ -288,5 +288,5 @@ AVCodec ff_vb_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 176/217] avcodec/bmvaudio: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bmvaudio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/bmvaudio.c b/libavcodec/bmvaudio.c
index b1587ab366..0292b0be1e 100644
--- a/libavcodec/bmvaudio.c
+++ b/libavcodec/bmvaudio.c
@@ -86,4 +86,5 @@ AVCodec ff_bmv_audio_decoder = {
 .init   = bmv_aud_decode_init,
 .decode = bmv_aud_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 175/217] avcodec/ttaenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ttaenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c
index ac8a432873..239136cae6 100644
--- a/libavcodec/ttaenc.c
+++ b/libavcodec/ttaenc.c
@@ -214,4 +214,5 @@ AVCodec ff_tta_encoder = {
  AV_SAMPLE_FMT_S16,
  AV_SAMPLE_FMT_S32,
  AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 174/217] avcodec/tta: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/tta.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index e68e4fbb36..5c736779cf 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -425,4 +425,5 @@ AVCodec ff_tta_decoder = {
 .decode = tta_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
 .priv_class = _decoder_class,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 173/217] avcodec/vmdaudio: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vmdaudio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/vmdaudio.c b/libavcodec/vmdaudio.c
index dfbd49fd84..4f9a827c36 100644
--- a/libavcodec/vmdaudio.c
+++ b/libavcodec/vmdaudio.c
@@ -237,4 +237,5 @@ AVCodec ff_vmdaudio_decoder = {
 .init   = vmdaudio_decode_init,
 .decode = vmdaudio_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 172/217] avcodec/vima: Make decoder init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vima.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/libavcodec/vima.c b/libavcodec/vima.c
index b4620acf6b..b0a2448ede 100644
--- a/libavcodec/vima.c
+++ b/libavcodec/vima.c
@@ -26,13 +26,13 @@
  */
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/thread.h"
 
 #include "adpcm_data.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "internal.h"
 
-static int predict_table_init = 0;
 static uint16_t predict_table[5786 * 2];
 
 static const uint8_t size_table[] = {
@@ -84,16 +84,9 @@ static const int8_t *const step_index_tables[] = {
 index_table4, index_table5, index_table6
 };
 
-static av_cold int decode_init(AVCodecContext *avctx)
+static av_cold void predict_table_init(void)
 {
-int start_pos;
-
-avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-
-if (predict_table_init)
-return 0;
-
-for (start_pos = 0; start_pos < 64; start_pos++) {
+for (int start_pos = 0; start_pos < 64; start_pos++) {
 unsigned int dest_pos, table_pos;
 
 for (table_pos = 0, dest_pos = start_pos;
@@ -110,7 +103,15 @@ static av_cold int decode_init(AVCodecContext *avctx)
 predict_table[dest_pos] = put;
 }
 }
-predict_table_init = 1;
+}
+
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+
+avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+
+ff_thread_once(_static_once, predict_table_init);
 
 return 0;
 }
@@ -215,4 +216,5 @@ AVCodec ff_adpcm_vima_decoder = {
 .init = decode_init,
 .decode   = decode_frame,
 .capabilities = AV_CODEC_CAP_DR1,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 171/217] avcodec/adxdec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/adxdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index 35b20c5cf4..70cb077545 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -203,4 +203,5 @@ AVCodec ff_adpcm_adx_decoder = {
   AV_CODEC_CAP_DR1,
 .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
   AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 170/217] avcodec/truespeech: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/truespeech.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index 3cdae8c556..06f83d1657 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -362,4 +362,5 @@ AVCodec ff_truespeech_decoder = {
 .init   = truespeech_decode_init,
 .decode = truespeech_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 169/217] avcodec/ra288: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ra288.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index 8df17891b1..a5a3478513 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -245,4 +245,5 @@ AVCodec ff_ra_288_decoder = {
 .init   = ra288_decode_init,
 .decode = ra288_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 168/217] avcodec/bintext: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bintext.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c
index 1aeed21f51..e30715368e 100644
--- a/libavcodec/bintext.c
+++ b/libavcodec/bintext.c
@@ -224,6 +224,7 @@ AVCodec ff_bintext_decoder = {
 .init   = decode_init,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 #if CONFIG_XBIN_DECODER
@@ -236,6 +237,7 @@ AVCodec ff_xbin_decoder = {
 .init   = decode_init,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 #if CONFIG_IDF_DECODER
@@ -248,5 +250,6 @@ AVCodec ff_idf_decoder = {
 .init   = decode_init,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 167/217] avcodec/truemotion1: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/truemotion1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index 94782fef4b..03ba916403 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -920,5 +920,5 @@ AVCodec ff_truemotion1_decoder = {
 .close  = truemotion1_decode_end,
 .decode = truemotion1_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 166/217] avcodec/targa_y216dec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/targa_y216dec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/targa_y216dec.c b/libavcodec/targa_y216dec.c
index 443d48a92f..426b365e26 100644
--- a/libavcodec/targa_y216dec.c
+++ b/libavcodec/targa_y216dec.c
@@ -81,4 +81,5 @@ AVCodec ff_targa_y216_decoder = {
 .init = y216_decode_init,
 .decode   = y216_decode_frame,
 .capabilities = AV_CODEC_CAP_DR1,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 165/217] avcodec/kvg1dec: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/kgv1dec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index a6bd9400ac..1514f5d680 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -187,4 +187,5 @@ AVCodec ff_kgv1_decoder = {
 .decode = decode_frame,
 .flush  = decode_flush,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 164/217] avcodec/idcinvideo: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/idcinvideo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c
index 6b2d8087ae..941a89d36d 100644
--- a/libavcodec/idcinvideo.c
+++ b/libavcodec/idcinvideo.c
@@ -258,4 +258,5 @@ AVCodec ff_idcin_decoder = {
 .decode = idcin_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
 .defaults   = idcin_defaults,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 163/217] avcodec/4xm: Make decoder init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/4xm.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 336c651d31..00a8e0b1f3 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -30,6 +30,7 @@
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "bswapdsp.h"
@@ -245,7 +246,7 @@ static void idct(int16_t block[64])
 }
 }
 
-static av_cold void init_vlcs(FourXContext *f)
+static av_cold void init_vlcs(void)
 {
 static VLC_TYPE table[2][4][32][2];
 int i, j;
@@ -987,6 +988,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
 
 static av_cold int decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 FourXContext * const f = avctx->priv_data;
 int ret;
 
@@ -1014,13 +1016,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
 ff_blockdsp_init(>bdsp, avctx);
 ff_bswapdsp_init(>bbdsp);
 f->avctx = avctx;
-init_vlcs(f);
 
 if (f->version > 2)
 avctx->pix_fmt = AV_PIX_FMT_RGB565;
 else
 avctx->pix_fmt = AV_PIX_FMT_BGR555;
 
+ff_thread_once(_static_once, init_vlcs);
+
 return 0;
 }
 
@@ -1034,4 +1037,5 @@ AVCodec ff_fourxm_decoder = {
 .close  = decode_end,
 .decode = decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 162/217] avcodec/8svx: Mark decoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/8svx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index 092dbaae04..97a05037a1 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -196,6 +196,7 @@ AVCodec ff_eightsvx_fib_decoder = {
   .capabilities   = AV_CODEC_CAP_DR1,
   .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
 AV_SAMPLE_FMT_NONE },
+  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 #if CONFIG_EIGHTSVX_EXP_DECODER
@@ -211,5 +212,6 @@ AVCodec ff_eightsvx_exp_decoder = {
   .capabilities   = AV_CODEC_CAP_DR1,
   .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
 AV_SAMPLE_FMT_NONE },
+  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 161/217] avcodec/bitpacked: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bitpacked.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/bitpacked.c b/libavcodec/bitpacked.c
index 952ba73a32..be3cdef2ea 100644
--- a/libavcodec/bitpacked.c
+++ b/libavcodec/bitpacked.c
@@ -150,4 +150,5 @@ AVCodec ff_bitpacked_decoder = {
 MKTAG('U', 'Y', 'V', 'Y'),
 FF_CODEC_TAGS_END,
 },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 160/217] avcodec/argo: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/argo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/argo.c b/libavcodec/argo.c
index 6b4d449935..57becbd416 100644
--- a/libavcodec/argo.c
+++ b/libavcodec/argo.c
@@ -736,5 +736,5 @@ AVCodec ff_argo_decoder = {
 .flush  = decode_flush,
 .close  = decode_close,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 159/217] avcodec/arbc: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/arbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
index 06970f140b..20de41ab11 100644
--- a/libavcodec/arbc.c
+++ b/libavcodec/arbc.c
@@ -223,5 +223,5 @@ AVCodec ff_arbc_decoder = {
 .flush  = decode_flush,
 .close  = decode_close,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 158/217] avcodec/adxenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/adxenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
index 93b902b0e1..ce7a76d51b 100644
--- a/libavcodec/adxenc.c
+++ b/libavcodec/adxenc.c
@@ -198,4 +198,5 @@ AVCodec ff_adpcm_adx_encoder = {
 .capabilities   = AV_CODEC_CAP_DELAY,
 .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
   AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 157/217] avcodec/alacenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/alacenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 9d135d1350..5decf8588c 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -672,4 +672,5 @@ AVCodec ff_alac_encoder = {
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P,
  AV_SAMPLE_FMT_S16P,
  AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 156/217] avcodec/s302menc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/s302menc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c
index b04a54e482..1e1d639420 100644
--- a/libavcodec/s302menc.c
+++ b/libavcodec/s302menc.c
@@ -185,4 +185,5 @@ AVCodec ff_s302m_encoder = {
   AV_CH_LAYOUT_5POINT1_BACK,
   AV_CH_LAYOUT_5POINT1_BACK | 
AV_CH_LAYOUT_STEREO_DOWNMIX,
   0 }, */
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 155/217] avcodec/v308enc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v308enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c
index 0891251dea..67b8dccbca 100644
--- a/libavcodec/v308enc.c
+++ b/libavcodec/v308enc.c
@@ -76,4 +76,5 @@ AVCodec ff_v308_encoder = {
 .init = v308_encode_init,
 .encode2  = v308_encode_frame,
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P, 
AV_PIX_FMT_NONE },
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 154/217] avcodec/v410enc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v410enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
index 5e2450279f..a4f91d77e3 100644
--- a/libavcodec/v410enc.c
+++ b/libavcodec/v410enc.c
@@ -88,4 +88,5 @@ AVCodec ff_v410_encoder = {
 .init = v410_encode_init,
 .encode2  = v410_encode_frame,
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, 
AV_PIX_FMT_NONE },
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 153/217] avcodec/targaenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/targaenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index 79030a012b..012409b48d 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -229,4 +229,5 @@ AVCodec ff_targa_encoder = {
 AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_RGB555LE, 
AV_PIX_FMT_GRAY8, AV_PIX_FMT_PAL8,
 AV_PIX_FMT_NONE
 },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 152/217] avcodec/tiffenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/tiffenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 6661e59d31..8e56f1b6ee 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -594,4 +594,5 @@ AVCodec ff_tiff_encoder = {
 AV_PIX_FMT_NONE
 },
 .priv_class = _class,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 151/217] avcodec/v210enc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v210enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 16e8810271..678affbe2a 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -166,4 +166,5 @@ AVCodec ff_v210_encoder = {
 .init   = encode_init,
 .encode2= encode_frame,
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, 
AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 145/217] avcodec/bmpenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bmpenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index e829d68475..13154c706c 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -177,4 +177,5 @@ AVCodec ff_bmp_encoder = {
 AV_PIX_FMT_MONOBLACK,
 AV_PIX_FMT_NONE
 },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 150/217] avcodec/utvideoenc: Cleanup generically on init failure

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/utvideoenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index eea685f600..5dbfed59a3 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -195,7 +195,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (!avctx->extradata) {
 av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n");
-utvideo_encode_close(avctx);
 return AVERROR(ENOMEM);
 }
 
@@ -204,7 +203,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!c->slice_buffer[i]) {
 av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 
1.\n");
-utvideo_encode_close(avctx);
 return AVERROR(ENOMEM);
 }
 }
@@ -701,5 +699,5 @@ AVCodec ff_utvideo_encoder = {
   AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, 
AV_PIX_FMT_YUV422P,
   AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, 
AV_PIX_FMT_NONE
   },
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 144/217] avcodec/cdgraphics: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cdgraphics.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c
index 965f43684a..24e1771b9e 100644
--- a/libavcodec/cdgraphics.c
+++ b/libavcodec/cdgraphics.c
@@ -394,4 +394,5 @@ AVCodec ff_cdgraphics_decoder = {
 .decode = cdg_decode_frame,
 .flush  = cdg_decode_flush,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 149/217] avcodec/utvideoenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/utvideoenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 5c87eb50ac..eea685f600 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -701,4 +701,5 @@ AVCodec ff_utvideo_encoder = {
   AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, 
AV_PIX_FMT_YUV422P,
   AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, 
AV_PIX_FMT_NONE
   },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 143/217] avcodec/cinepak: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cinepak.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index 9c5b254231..17148a3577 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -522,4 +522,5 @@ AVCodec ff_cinepak_decoder = {
 .close  = cinepak_decode_end,
 .decode = cinepak_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 148/217] avcodec/rawenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/rawenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index d181b74570..425aae75c4 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -92,4 +92,5 @@ AVCodec ff_rawvideo_encoder = {
 .id = AV_CODEC_ID_RAWVIDEO,
 .init   = raw_encode_init,
 .encode2= raw_encode,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 142/217] avcodec/cinepakenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cinepakenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index cc125ed39e..9eaa972a9c 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -1189,5 +1189,5 @@ AVCodec ff_cinepak_encoder = {
 .close  = cinepak_encode_end,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, 
AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE },
 .priv_class = _class,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 147/217] avcodec/avuienc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/avuienc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c
index 2091309e7e..45580183c2 100644
--- a/libavcodec/avuienc.c
+++ b/libavcodec/avuienc.c
@@ -100,4 +100,5 @@ AVCodec ff_avui_encoder = {
 .encode2  = avui_encode_frame,
 .capabilities = AV_CODEC_CAP_EXPERIMENTAL,
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_UYVY422, 
AV_PIX_FMT_NONE },
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 146/217] avcodec/v408enc: Mark encoders as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/v408enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c
index d2d84d9c40..7ef26c7d3d 100644
--- a/libavcodec/v408enc.c
+++ b/libavcodec/v408enc.c
@@ -82,6 +82,7 @@ AVCodec ff_ayuv_encoder = {
 .init = v408_encode_init,
 .encode2  = v408_encode_frame,
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVA444P, 
AV_PIX_FMT_NONE },
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
 #if CONFIG_V408_ENCODER
@@ -93,5 +94,6 @@ AVCodec ff_v408_encoder = {
 .init = v408_encode_init,
 .encode2  = v408_encode_frame,
 .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVA444P, 
AV_PIX_FMT_NONE },
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };
 #endif
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 141/217] avcodec/cngenc: Mark encoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cngenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
index b622d7bbda..ddc44eb515 100644
--- a/libavcodec/cngenc.c
+++ b/libavcodec/cngenc.c
@@ -111,5 +111,5 @@ AVCodec ff_comfortnoise_encoder = {
 .close  = cng_encode_close,
 .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
  AV_SAMPLE_FMT_NONE },
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 140/217] avcodec/cook: Make decoder init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cook.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index f552a57415..60b6bd6c19 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -44,6 +44,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/lfg.h"
+#include "libavutil/thread.h"
 
 #include "audiodsp.h"
 #include "avcodec.h"
@@ -1051,6 +1052,7 @@ static void dump_cook_context(COOKContext *q)
  */
 static av_cold int cook_decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 COOKContext *q = avctx->priv_data;
 GetByteContext gb;
 int s = 0;
@@ -1229,7 +1231,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
 }
 
 /* Generate tables */
-init_pow2table();
+ff_thread_once(_static_once, init_pow2table);
 init_gain_table(q);
 init_cplscales_table(q);
 
@@ -1281,7 +1283,7 @@ AVCodec ff_cook_decoder = {
 .close  = cook_decode_close,
 .decode = cook_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
   AV_SAMPLE_FMT_NONE },
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 139/217] avcodec/cook: Remove redundant free

2020-12-01 Thread Andreas Rheinhardt
This decoder has the FF_CODEC_CAP_INIT_CLEANUP flag set.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cook.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 93c51f5829..f552a57415 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -236,10 +236,9 @@ static av_cold int init_cook_mlt(COOKContext *q)
 q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel);
 
 /* Initialize the MDCT. */
-if ((ret = ff_mdct_init(>mdct_ctx, av_log2(mlt_size) + 1, 1, 1.0 / 
32768.0))) {
-av_freep(>mlt_window);
+ret = ff_mdct_init(>mdct_ctx, av_log2(mlt_size) + 1, 1, 1.0 / 32768.0);
+if (ret < 0)
 return ret;
-}
 av_log(q->avctx, AV_LOG_DEBUG, "MDCT initialized, order = %d.\n",
av_log2(mlt_size) + 1);
 
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 138/217] avcodec/cook: Don't use 0 for NULL

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cook.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 9582495442..93c51f5829 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -227,7 +227,7 @@ static av_cold int init_cook_mlt(COOKContext *q)
 int j, ret;
 int mlt_size = q->samples_per_channel;
 
-if ((q->mlt_window = av_malloc_array(mlt_size, sizeof(*q->mlt_window))) == 
0)
+if (!(q->mlt_window = av_malloc_array(mlt_size, sizeof(*q->mlt_window
 return AVERROR(ENOMEM);
 
 /* Initialize the MLT window: simple sine window. */
-- 
2.25.1

___
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".

[FFmpeg-devel] [PATCH 137/217] avcodec/cpia: Mark decoder as init-threadsafe

2020-12-01 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cpia.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
index bf09e1a5db..5f12a99a83 100644
--- a/libavcodec/cpia.c
+++ b/libavcodec/cpia.c
@@ -230,4 +230,5 @@ AVCodec ff_cpia_decoder = {
 .close  = cpia_decode_end,
 .decode = cpia_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
-- 
2.25.1

___
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 1/5] avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code

2020-12-01 Thread Guangxin Xu
Hi Mark & Zong,
Any suggestion on this?
thanks

On Thu, Nov 26, 2020 at 6:21 PM Xu Guangxin  wrote:

> ---
>  libavcodec/qsvdec_other.c | 188 --
>  1 file changed, 36 insertions(+), 152 deletions(-)
>
> diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> index 2775e07955..266ac9f2e5 100644
> --- a/libavcodec/qsvdec_other.c
> +++ b/libavcodec/qsvdec_other.c
> @@ -189,170 +189,54 @@ static const AVOption options[] = {
>  { NULL },
>  };
>
> -#if CONFIG_MPEG2_QSV_DECODER
> -static const AVClass mpeg2_qsv_class = {
> -.class_name = "mpeg2_qsv",
> -.item_name  = av_default_item_name,
> -.option = options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> +#define DEFINE_QSV_DECODER(x, X, bsf_name) \
> +static const AVClass x##_qsv_class = { \
> +.class_name = #x "_qsv", \
> +.item_name  = av_default_item_name, \
> +.option = options, \
> +.version= LIBAVUTIL_VERSION_INT, \
> +}; \
> +AVCodec ff_##x##_qsv_decoder = { \
> +.name   = #x "_qsv", \
> +.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync
> Video acceleration)"), \
> +.priv_data_size = sizeof(QSVOtherContext), \
> +.type   = AVMEDIA_TYPE_VIDEO, \
> +.id = AV_CODEC_ID_##X, \
> +.init   = qsv_decode_init, \
> +.decode = qsv_decode_frame, \
> +.flush  = qsv_decode_flush, \
> +.close  = qsv_decode_close, \
> +.bsfs   = bsf_name, \
> +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
> +.priv_class = ##_qsv_class, \
> +.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> +AV_PIX_FMT_P010, \
> +AV_PIX_FMT_QSV, \
> +AV_PIX_FMT_NONE }, \
> +.hw_configs = ff_qsv_hw_configs, \
> +.wrapper_name   = "qsv", \
> +}; \
>
> -AVCodec ff_mpeg2_qsv_decoder = {
> -.name   = "mpeg2_qsv",
> -.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick
> Sync Video acceleration)"),
> -.priv_data_size = sizeof(QSVOtherContext),
> -.type   = AVMEDIA_TYPE_VIDEO,
> -.id = AV_CODEC_ID_MPEG2VIDEO,
> -.init   = qsv_decode_init,
> -.decode = qsv_decode_frame,
> -.flush  = qsv_decode_flush,
> -.close  = qsv_decode_close,
> -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> -.priv_class = _qsv_class,
> -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> -AV_PIX_FMT_QSV,
> -AV_PIX_FMT_NONE },
> -.hw_configs = ff_qsv_hw_configs,
> -.wrapper_name   = "qsv",
> -};
> +#if CONFIG_MPEG2_QSV_DECODER
> +DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
>  #endif
>
>  #if CONFIG_VC1_QSV_DECODER
> -static const AVClass vc1_qsv_class = {
> -.class_name = "vc1_qsv",
> -.item_name  = av_default_item_name,
> -.option = options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> -
> -AVCodec ff_vc1_qsv_decoder = {
> -.name   = "vc1_qsv",
> -.long_name  = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync
> Video acceleration)"),
> -.priv_data_size = sizeof(QSVOtherContext),
> -.type   = AVMEDIA_TYPE_VIDEO,
> -.id = AV_CODEC_ID_VC1,
> -.init   = qsv_decode_init,
> -.decode = qsv_decode_frame,
> -.flush  = qsv_decode_flush,
> -.close  = qsv_decode_close,
> -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> -.priv_class = _qsv_class,
> -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> -AV_PIX_FMT_QSV,
> -AV_PIX_FMT_NONE },
> -.hw_configs = ff_qsv_hw_configs,
> -.wrapper_name   = "qsv",
> -};
> -#endif
> -
> -#if CONFIG_VP8_QSV_DECODER
> -static const AVClass vp8_qsv_class = {
> -.class_name = "vp8_qsv",
> -.item_name  = av_default_item_name,
> -.option = options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> -
> -AVCodec ff_vp8_qsv_decoder = {
> -.name   = "vp8_qsv",
> -.long_name  = NULL_IF_CONFIG_SMALL("VP8 video (Intel Quick Sync
> Video acceleration)"),
> -.priv_data_size = sizeof(QSVOtherContext),
> -.type   = AVMEDIA_TYPE_VIDEO,
> -.id = AV_CODEC_ID_VP8,
> -.init   = qsv_decode_init,
> -.decode = qsv_decode_frame,
> -.flush  = qsv_decode_flush,
> -.close  = qsv_decode_close,
> -  

[FFmpeg-devel] [PATCH] libavcodec/qsvenc: add max_frame_size support for hevc_qsv

2020-12-01 Thread wenbin . chen
From: Wenbinc-Bin 

The max_frame_size parameter is set only when codec is h264. Now I add
hevc in that conditional statement.

Signed-off-by: Wenbin CHEN 
---
 libavcodec/qsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2bd2a56227..aba98dd689 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -691,7 +691,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco;
 
 #if QSV_HAVE_CO2
-if (avctx->codec_id == AV_CODEC_ID_H264) {
+if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_HEVC) {
 if (q->int_ref_type >= 0)
 q->extco2.IntRefType = q->int_ref_type;
 if (q->int_ref_cycle_size >= 0)
-- 
2.25.1

___
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] lavf/qsv_scale: add interpolation methods support

2020-12-01 Thread Xiang, Haihao
On Tue, 2020-12-01 at 22:42 +, Artem Galin wrote:
> Since 1.33 API version
> 
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/api/include/mfxstructures.h#L2088
> 
> Signed-off-by: Artem Galin 
> ---
>  libavfilter/vf_scale_qsv.c | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> index 5064dcbb60..1a6121c295 100644
> --- a/libavfilter/vf_scale_qsv.c
> +++ b/libavfilter/vf_scale_qsv.c
> @@ -70,6 +70,7 @@ enum var_name {
>  };
>  
>  #define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
> +#define QSV_HAVE_INTERPOLATION_METHOD QSV_VERSION_ATLEAST(1, 33)
>  
>  typedef struct QSVScaleContext {
>  const AVClass *class;
> @@ -95,6 +96,7 @@ typedef struct QSVScaleContext {
>  mfxExtVPPScaling scale_conf;
>  #endif
>  int  mode;
> +int  interpmethod;
>  
>  mfxExtBuffer *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
>  int  num_ext_buf;
> @@ -409,6 +411,10 @@ static int init_out_session(AVFilterContext *ctx)
>  s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
>  s->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
>  s->scale_conf.ScalingMode = s->mode;
> +#if QSV_HAVE_INTERPOLATION_METHOD
> +s->scale_conf.InterpolationMethod = s->interpmethod;
> +av_log(ctx, AV_LOG_VERBOSE, "Interpolation method: %d\n", s-
> >interpmethod);
> +#endif
>  s->ext_buffers[s->num_ext_buf++]  = (mfxExtBuffer*)>scale_conf;
>  av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %d\n", s->mode);
>  #endif
> @@ -624,6 +630,17 @@ static const AVOption options[] = {
>  { "low_power",
> "",  0, AV_OPT_TYPE_CONST,  { .i64 = 1},
> 0,   0, FLAGS, "mode"},
>  {
> "hq","",  0, AV_OPT_TYPE_CONST,  {
> .i64 = 2}, 0,   0, FLAGS, "mode"},
>  #endif
> +#if QSV_HAVE_INTERPOLATION_METHOD
> +{ "interpmethod",  "set interpolation method", OFFSET(interpmethod),
> AV_OPT_TYPE_INT,   { .i64 = MFX_INTERPOLATION_DEFAULT},
> MFX_INTERPOLATION_DEFAULT, MFX_INTERPOLATION_ADVANCED, FLAGS, "interpmethod"},
> +{ "nearest",   "nearest neighbor
> method",  0,AV_OPT_TYPE_CONST, { .i64 =
> MFX_INTERPOLATION_NEAREST_NEIGHBOR}, INT_MIN, INT_MAX, FLAGS, "interpmethod"},
> +{ "bilinear",  "bilinear
> method",  0,AV_OPT_TYPE_CONST, { .i64 =
> MFX_INTERPOLATION_BILINEAR}, INT_MIN, INT_MAX, FLAGS, "interpmethod"},
> +{ "advanced",  "advanced
> method",  0,AV_OPT_TYPE_CONST, { .i64 =
> MFX_INTERPOLATION_ADVANCED}, INT_MIN, INT_MAX, FLAGS, "interpmethod"},
> +#else
> +{ "interpmethod",  "(not supported)",  OFFSET(interpmethod),
> AV_OPT_TYPE_INT,   { .i64 = 0}, 0, INT_MAX, FLAGS, "interpmethod"},
> +{
> "nearest",   "", 0,AV_OPT_TYPE
> _CONST, { .i64 = 1}, 0, 0, FLAGS, "interpmethod"},
> +{
> "bilinear",  "", 0,AV_OPT_TYPE
> _CONST, { .i64 = 2}, 0, 0, FLAGS, "interpmethod"},
> +{
> "advanced",  "", 0,AV_OPT_TYPE
> _CONST, { .i64 = 3}, 0, 0, FLAGS, "interpmethod"},
> +#endif
>  

Why is this option added for !QSV_HAVE_INTERPOLATION_METHOD? 

>  { NULL },
>  };
___
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] lavf/qsv_scale: fix green stripe at the bottom

2020-12-01 Thread Xiang, Haihao
On Tue, 2020-12-01 at 22:40 +, Artem Galin wrote:
> Explicitly set region of interest for input surfaces.
> 
> Signed-off-by: Artem Galin 
> ---
>  libavfilter/vf_scale_qsv.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> index 5064dcbb60..321adbbb18 100644
> --- a/libavfilter/vf_scale_qsv.c
> +++ b/libavfilter/vf_scale_qsv.c
> @@ -274,7 +274,7 @@ static const mfxHandleType handle_types[] = {
>  MFX_HANDLE_D3D11_DEVICE,
>  };
>  
> -static int init_out_session(AVFilterContext *ctx)
> +static int init_out_session(AVFilterContext *ctx, int in_width, int
> in_height)
>  {
>  
>  QSVScaleContext   *s = ctx->priv;
> @@ -385,8 +385,11 @@ static int init_out_session(AVFilterContext *ctx)
>   sizeof(*s->mem_ids_in));
>  if (!s->mem_ids_in)
>  return AVERROR(ENOMEM);
> -for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
> +for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) {
>  s->mem_ids_in[i] = in_frames_hwctx->surfaces[i].Data.MemId;
> +in_frames_hwctx->surfaces[i].Info.CropW = in_width;
> +in_frames_hwctx->surfaces[i].Info.CropH = in_height;
> +}
>  s->nb_mem_ids_in = in_frames_hwctx->nb_surfaces;
>  
>  s->mem_ids_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
> @@ -450,7 +453,7 @@ static int init_scale_session(AVFilterContext *ctx, int
> in_width, int in_height,
>  if (ret < 0)
>  return ret;
>  
> -ret = init_out_session(ctx);
> +ret = init_out_session(ctx, in_width, in_height);
>  if (ret < 0)
>  return ret;

LGTM, thanks!

>  
___
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] libavcodec/qsvenc.c: add max_frame_size support for hevc_qsv

2020-12-01 Thread Xiang, Haihao
On Mon, 2020-11-30 at 13:49 +0800, wenbin.c...@intel.com wrote:
> From: Wenbinc-Bin 
> 
> The max_frame_size parameter is set only when codec is h264. Now I add
> hevc in that conditional statement.
> 
> Signed-off-by: Wenbin CHEN 

Please remove the spaces at the beginning of each line in the commit log.

> ---
>  libavcodec/qsvenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 2bd2a56227..aba98dd689 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -691,7 +691,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)
> >extco;
>  
>  #if QSV_HAVE_CO2
> -if (avctx->codec_id == AV_CODEC_ID_H264) {
> +if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id ==
> AV_CODEC_ID_HEVC) {
>  if (q->int_ref_type >= 0)
>  q->extco2.IntRefType = q->int_ref_type;
>  if (q->int_ref_cycle_size >= 0)
___
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".

[FFmpeg-devel] [PATCH] lavf/qsv_scale: fix green stripe at the bottom

2020-12-01 Thread Artem Galin
Explicitly set region of interest for input surfaces.

Signed-off-by: Artem Galin 
---
 libavfilter/vf_scale_qsv.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 5064dcbb60..321adbbb18 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -274,7 +274,7 @@ static const mfxHandleType handle_types[] = {
 MFX_HANDLE_D3D11_DEVICE,
 };
 
-static int init_out_session(AVFilterContext *ctx)
+static int init_out_session(AVFilterContext *ctx, int in_width, int in_height)
 {
 
 QSVScaleContext   *s = ctx->priv;
@@ -385,8 +385,11 @@ static int init_out_session(AVFilterContext *ctx)
  sizeof(*s->mem_ids_in));
 if (!s->mem_ids_in)
 return AVERROR(ENOMEM);
-for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
+for (i = 0; i < in_frames_hwctx->nb_surfaces; i++) {
 s->mem_ids_in[i] = in_frames_hwctx->surfaces[i].Data.MemId;
+in_frames_hwctx->surfaces[i].Info.CropW = in_width;
+in_frames_hwctx->surfaces[i].Info.CropH = in_height;
+}
 s->nb_mem_ids_in = in_frames_hwctx->nb_surfaces;
 
 s->mem_ids_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
@@ -450,7 +453,7 @@ static int init_scale_session(AVFilterContext *ctx, int 
in_width, int in_height,
 if (ret < 0)
 return ret;
 
-ret = init_out_session(ctx);
+ret = init_out_session(ctx, in_width, in_height);
 if (ret < 0)
 return ret;
 
-- 
2.26.2

___
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".

[FFmpeg-devel] [PATCH] lavf/qsv_scale: add interpolation methods support

2020-12-01 Thread Artem Galin
Since 1.33 API version
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/api/include/mfxstructures.h#L2088

Signed-off-by: Artem Galin 
---
 libavfilter/vf_scale_qsv.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 5064dcbb60..1a6121c295 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -70,6 +70,7 @@ enum var_name {
 };
 
 #define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
+#define QSV_HAVE_INTERPOLATION_METHOD QSV_VERSION_ATLEAST(1, 33)
 
 typedef struct QSVScaleContext {
 const AVClass *class;
@@ -95,6 +96,7 @@ typedef struct QSVScaleContext {
 mfxExtVPPScaling scale_conf;
 #endif
 int  mode;
+int  interpmethod;
 
 mfxExtBuffer *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
 int  num_ext_buf;
@@ -409,6 +411,10 @@ static int init_out_session(AVFilterContext *ctx)
 s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
 s->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
 s->scale_conf.ScalingMode = s->mode;
+#if QSV_HAVE_INTERPOLATION_METHOD
+s->scale_conf.InterpolationMethod = s->interpmethod;
+av_log(ctx, AV_LOG_VERBOSE, "Interpolation method: %d\n", s->interpmethod);
+#endif
 s->ext_buffers[s->num_ext_buf++]  = (mfxExtBuffer*)>scale_conf;
 av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %d\n", s->mode);
 #endif
@@ -624,6 +630,17 @@ static const AVOption options[] = {
 { "low_power", "",  0, AV_OPT_TYPE_CONST,  
{ .i64 = 1}, 0,   0, FLAGS, "mode"},
 { "hq","",  0, AV_OPT_TYPE_CONST,  
{ .i64 = 2}, 0,   0, FLAGS, "mode"},
 #endif
+#if QSV_HAVE_INTERPOLATION_METHOD
+{ "interpmethod",  "set interpolation method", OFFSET(interpmethod), 
AV_OPT_TYPE_INT,   { .i64 = MFX_INTERPOLATION_DEFAULT}, 
MFX_INTERPOLATION_DEFAULT, MFX_INTERPOLATION_ADVANCED, FLAGS, "interpmethod"},
+{ "nearest",   "nearest neighbor method",  0,
AV_OPT_TYPE_CONST, { .i64 = MFX_INTERPOLATION_NEAREST_NEIGHBOR}, INT_MIN, 
INT_MAX, FLAGS, "interpmethod"},
+{ "bilinear",  "bilinear method",  0,
AV_OPT_TYPE_CONST, { .i64 = MFX_INTERPOLATION_BILINEAR}, INT_MIN, 
INT_MAX, FLAGS, "interpmethod"},
+{ "advanced",  "advanced method",  0,
AV_OPT_TYPE_CONST, { .i64 = MFX_INTERPOLATION_ADVANCED}, INT_MIN, 
INT_MAX, FLAGS, "interpmethod"},
+#else
+{ "interpmethod",  "(not supported)",  OFFSET(interpmethod), 
AV_OPT_TYPE_INT,   { .i64 = 0}, 0, INT_MAX, FLAGS, "interpmethod"},
+{ "nearest",   "", 0,
AV_OPT_TYPE_CONST, { .i64 = 1}, 0, 0, FLAGS, "interpmethod"},
+{ "bilinear",  "", 0,
AV_OPT_TYPE_CONST, { .i64 = 2}, 0, 0, FLAGS, "interpmethod"},
+{ "advanced",  "", 0,
AV_OPT_TYPE_CONST, { .i64 = 3}, 0, 0, FLAGS, "interpmethod"},
+#endif
 
 { NULL },
 };
-- 
2.26.2

___
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 7/9] mjpegdec: convert to receive_frame()

2020-12-01 Thread James Almer

On 12/1/2020 5:19 PM, Anton Khirnov wrote:

This will be useful in the following commit.
---
  libavcodec/jpeglsdec.c|  2 +-
  libavcodec/mjpegdec.c | 71 +--
  libavcodec/mjpegdec.h |  8 ++--
  libavcodec/sp5xdec.c  | 28 ++
  tests/ref/fate/exif-image-jpg |  4 +-
  5 files changed, 72 insertions(+), 41 deletions(-)

diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
index 0b1e139048..e72f9f2315 100644
--- a/libavcodec/jpeglsdec.c
+++ b/libavcodec/jpeglsdec.c
@@ -551,7 +551,7 @@ AVCodec ff_jpegls_decoder = {
  .priv_data_size = sizeof(MJpegDecodeContext),
  .init   = ff_mjpeg_decode_init,
  .close  = ff_mjpeg_decode_end,
-.decode = ff_mjpeg_decode_frame,
+.receive_frame  = ff_mjpeg_receive_frame,
  .capabilities   = AV_CODEC_CAP_DR1,
  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
  };
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 147dd819e5..96dfc3dc19 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -36,6 +36,7 @@
  #include "avcodec.h"
  #include "blockdsp.h"
  #include "copy_block.h"
+#include "decode.h"
  #include "hwconfig.h"
  #include "idctdsp.h"
  #include "internal.h"
@@ -163,6 +164,10 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
  s->picture_ptr = s->picture;
  }
  
+s->pkt = av_packet_alloc();

+if (!s->pkt)
+return AVERROR(ENOMEM);
+
  s->avctx = avctx;
  ff_blockdsp_init(>bdsp, avctx);
  ff_hpeldsp_init(>hdsp, avctx->flags);
@@ -2336,12 +2341,32 @@ static void reset_icc_profile(MJpegDecodeContext *s)
  s->iccnum  = 0;
  }
  
-int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,

-  AVPacket *avpkt)
+static int mjpeg_get_packet(AVCodecContext *avctx)
+{
+MJpegDecodeContext *s = avctx->priv_data;
+int ret;
+
+av_packet_unref(s->pkt);
+ret = ff_decode_get_packet(avctx, s->pkt);
+if (ret < 0)
+return ret;
+
+#if CONFIG_SP5X_DECODER || CONFIG_AMV_DECODER
+if (avctx->codec_id == AV_CODEC_ID_SP5X ||
+avctx->codec_id == AV_CODEC_ID_AMV) {
+ret = ff_sp5x_process_packet(avctx, s->pkt);
+if (ret < 0)
+return ret;
+}
+#endif
+
+s->buf_size = s->pkt->size;
+
+return 0;
+}
+
+int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame)
  {
-AVFrame *frame = data;
-const uint8_t *buf = avpkt->data;
-int buf_size   = avpkt->size;
  MJpegDecodeContext *s = avctx->priv_data;
  const uint8_t *buf_end, *buf_ptr;
  const uint8_t *unescaped_buf_ptr;
@@ -2352,8 +2377,6 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
  int ret = 0;
  int is16bit;
  
-s->buf_size = buf_size;

-
  av_dict_free(>exif_metadata);
  av_freep(>stereo3d);
  s->adobe_transform = -1;
@@ -2361,8 +2384,12 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
  if (s->iccnum != 0)
  reset_icc_profile(s);
  
-buf_ptr = buf;

-buf_end = buf + buf_size;
+ret = mjpeg_get_packet(avctx);
+if (ret < 0)
+return ret;
+
+buf_ptr = s->pkt->data;
+buf_end = s->pkt->data + s->pkt->size;
  while (buf_ptr < buf_end) {
  /* find start next marker */
  start_code = ff_mjpeg_find_marker(s, _ptr, buf_end,
@@ -2374,7 +2401,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
  } else if (unescaped_buf_size > INT_MAX / 8) {
  av_log(avctx, AV_LOG_ERROR,
 "MJPEG packet 0x%x too big (%d/%d), corrupt data?\n",
-   start_code, unescaped_buf_size, buf_size);
+   start_code, unescaped_buf_size, s->pkt->size);
  return AVERROR_INVALIDDATA;
  }
  av_log(avctx, AV_LOG_DEBUG, "marker=%x 
avail_size_in_buf=%"PTRDIFF_SPECIFIER"\n",
@@ -2511,6 +2538,7 @@ eoi_parser:
  }
  if (avctx->skip_frame == AVDISCARD_ALL) {
  s->got_picture = 0;
+ret = AVERROR(EAGAIN);
  goto the_end_no_picture;
  }
  if (s->avctx->hwaccel) {
@@ -2522,9 +2550,10 @@ eoi_parser:
  }
  if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)
  return ret;
-*got_frame = 1;
  s->got_picture = 0;
  
+frame->pkt_dts = s->pkt->dts;


You should set FF_CODEC_CAP_SETS_PKT_DTS for this (Not too important 
considering it's only checked for AVCodec->decode() decoders, but it 
could change in the future, so might as well keep the decoder ready for it).



+
  if (!s->lossless) {
  int qp = FFMAX3(s->qscale[0],
  s->qscale[1],
@@ -2533,7 +2562,7 @@ eoi_parser:
  AVBufferRef *qp_table_buf = av_buffer_alloc(qpw);
  

Re: [FFmpeg-devel] [PATCH 3/9] tests: drop api-codec-param test

2020-12-01 Thread James Almer

On 12/1/2020 5:19 PM, Anton Khirnov wrote:

It fundamentally depends on deprecated lavf internals.
---
  tests/api/Makefile   |   1 -
  tests/api/api-codec-param-test.c | 256 ---
  tests/fate/api.mak   |   8 -


Should also delete the two ref files in test/ref/fate.


  3 files changed, 265 deletions(-)
  delete mode 100644 tests/api/api-codec-param-test.c


Fine by me.
___
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".

[FFmpeg-devel] [PATCH] hwcontext: Return a sensible error when deriving an unsupported device type

2020-12-01 Thread Mark Thompson

This previously returned ENOMEM because the failure was detected during
av_hwdevice_ctx_alloc(), which is not helpful.  Check earlier in order to
return the correct ENOSYS instead.
---
Before:

$ ./ffmpeg_g -init_hw_device vaapi=d0:/dev/dri/renderD128 -init_hw_device 
dxva2=d1@d0
...
Device creation failed: -12.
Failed to set value 'dxva2=d1@d0' for option 'init_hw_device': Cannot allocate 
memory
Error parsing global options: Cannot allocate memory

After:

$ ./ffmpeg_g -init_hw_device vaapi=d0:/dev/dri/renderD128 -init_hw_device 
dxva2=d1@d0
Device creation failed: -38.
Failed to set value 'dxva2=d1@d0' for option 'init_hw_device': Function not 
implemented
Error parsing global options: Function not implemented


 libavutil/hwcontext.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index d13d0f7c9b..4a307369c4 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -139,19 +139,22 @@ static void hwdevice_ctx_free(void *opaque, uint8_t *data)
 av_freep();
 }

+static const HWContextType *hwcontext_find_type(enum AVHWDeviceType type)
+{
+for (int i = 0; hw_table[i]; i++) {
+if (hw_table[i]->type == type)
+return hw_table[i];
+}
+return NULL;
+}
+
 AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
 {
 AVHWDeviceContext *ctx;
 AVBufferRef *buf;
-const HWContextType *hw_type = NULL;
-int i;
+const HWContextType *hw_type;

-for (i = 0; hw_table[i]; i++) {
-if (hw_table[i]->type == type) {
-hw_type = hw_table[i];
-break;
-}
-}
+hw_type = hwcontext_find_type(type);
 if (!hw_type)
 return NULL;

@@ -652,6 +655,11 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef 
**dst_ref_ptr,
 AVHWDeviceContext *dst_ctx, *tmp_ctx;
 int ret = 0;

+if (!hwcontext_find_type(type)) {
+// The type we want to derive is not supported in this build.
+return AVERROR(ENOSYS);
+}
+
 tmp_ref = src_ref;
 while (tmp_ref) {
 tmp_ctx = (AVHWDeviceContext*)tmp_ref->data;
--
2.29.2
___
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".

[FFmpeg-devel] [PATCH 9/9] smvjpegdec: merge into mjpegdec

2020-12-01 Thread Anton Khirnov
SMVJPEG stores frames as slices of a big JPEG image. The decoder is
implemented as a wrapper that instantiates a full internal MJPEG
decoder, then forwards the decoded frames with offset data pointers.
This is unnecessarily complex and fragile, not supporting useful decoder
capabilities like direct rendering.

Re-implement the decoder inside the MJPEG decoder, which is accomplished
by returning each decoded frame multiple times, setting cropping
information appropriately on each instance.

One peculiar aspect of the previous design is that since
- the smvjpeg decoder returns one frame per input packet
- there are multiple frames in each packets (the aformentioned slices)
the demuxer needs to return each packet multiple times.
This is now also eliminated - the demuxer now returns each packet
exactly once, with the duration set to the number of frames it decodes
to.

This also removes one of the last remaining internal uses of the old
video decoding API.
---
 MAINTAINERS |   1 -
 configure   |   1 +
 libavcodec/Makefile |   1 -
 libavcodec/mjpegdec.c   |  88 +++-
 libavcodec/mjpegdec.h   |   4 +
 libavcodec/smvjpegdec.c | 223 
 libavformat/wavdec.c|  12 +--
 tests/ref/fate/smvjpeg  |   2 +-
 8 files changed, 96 insertions(+), 236 deletions(-)
 delete mode 100644 libavcodec/smvjpegdec.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 2464f82be3..00c9007671 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -235,7 +235,6 @@ Codecs:
   rv10.cMichael Niedermayer
   s3tc* Ivo van Poorten
   smc.c Mike Melanson
-  smvjpegdec.c  Ash Hughes
   snow* Michael Niedermayer, Loren Merritt
   sonic.c   Alex Beregszaszi
   speedhq.c Steinar H. Gunderson
diff --git a/configure b/configure
index 51e43fbf66..277c2d699a 100755
--- a/configure
+++ b/configure
@@ -2838,6 +2838,7 @@ rv40_decoder_select="golomb h264pred h264qpel mpegvideo 
rv34dsp"
 screenpresso_decoder_deps="zlib"
 shorten_decoder_select="bswapdsp"
 sipr_decoder_select="lsp"
+smvjpeg_decoder_select="mjpeg_decoder"
 snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp"
 snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder"
 sonic_decoder_select="golomb rangecoder"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a6435c9e85..1f6e929a42 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -616,7 +616,6 @@ OBJS-$(CONFIG_SIREN_DECODER)   += siren.o
 OBJS-$(CONFIG_SMACKAUD_DECODER)+= smacker.o
 OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o
 OBJS-$(CONFIG_SMC_DECODER) += smc.o
-OBJS-$(CONFIG_SMVJPEG_DECODER) += smvjpegdec.o
 OBJS-$(CONFIG_SNOW_DECODER)+= snowdec.o snow.o snow_dwt.o
 OBJS-$(CONFIG_SNOW_ENCODER)+= snowenc.o snow.o snow_dwt.o  
   \
   h263.o h263data.o ituh263enc.o
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 96dfc3dc19..7cc5f2a32e 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -203,7 +203,19 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
 s->interlace_polarity = 1;
 }
 
-if (   avctx->extradata_size > 8
+if (avctx->codec_id == AV_CODEC_ID_SMVJPEG) {
+if (avctx->extradata_size >= 4)
+s->smv_frames_per_jpeg = AV_RL32(avctx->extradata);
+
+if (s->smv_frames_per_jpeg <= 0) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of frames per 
jpeg.\n");
+return AVERROR_INVALIDDATA;
+}
+
+s->smv_frame = av_frame_alloc();
+if (!s->smv_frame)
+return AVERROR(ENOMEM);
+} else if (avctx->extradata_size > 8
 && AV_RL32(avctx->extradata) == 0x2C
 && AV_RL32(avctx->extradata+4) == 0x18) {
 parse_avid(s, avctx->extradata, avctx->extradata_size);
@@ -477,6 +489,12 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 size_change = 0;
 }
 
+if (s->avctx->codec_id == AV_CODEC_ID_SMVJPEG) {
+s->avctx->height = s->avctx->coded_height / s->smv_frames_per_jpeg;
+if (s->avctx->height <= 0)
+return AVERROR_INVALIDDATA;
+}
+
 if (s->got_picture && s->interlaced && (s->bottom_field == 
!s->interlace_polarity)) {
 if (s->progressive) {
 avpriv_request_sample(s->avctx, "progressively coded interlaced 
picture");
@@ -2341,6 +2359,42 @@ static void reset_icc_profile(MJpegDecodeContext *s)
 s->iccnum  = 0;
 }
 
+// SMV JPEG just stacks several output frames into one JPEG picture
+// we handle that by setting up the cropping parameters appropriately
+static int smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
+{
+MJpegDecodeContext *s = avctx->priv_data;
+int ret;
+
+   

  1   2   >