[FFmpeg-devel] [PATCH 1/6] avcodec/vp6: Check initializing VP6A context
Signed-off-by: Andreas Rheinhardt --- libavcodec/vp6.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index d75e717082..95ed5eba0f 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -654,11 +654,12 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx) if (s->has_alpha) { s->alpha_context = av_mallocz(sizeof(VP56Context)); if (!s->alpha_context) { -ff_vp56_free(avctx); return AVERROR(ENOMEM); } -ff_vp56_init_context(avctx, s->alpha_context, - s->flip == -1, s->has_alpha); +ret = ff_vp56_init_context(avctx, s->alpha_context, + s->flip == -1, s->has_alpha); +if (ret < 0) +return ret; ff_vp6dsp_init(&s->alpha_context->vp56dsp); vp6_decode_init_context(s->alpha_context); } @@ -745,4 +746,5 @@ const AVCodec ff_vp6a_decoder = { .close = vp6_decode_free, .decode = ff_vp56_decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -- 2.32.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 2/6] avcodec/vp56: Cleanup generically in case of init failure
Signed-off-by: Andreas Rheinhardt --- libavcodec/vp5.c | 1 + libavcodec/vp56.c | 4 +--- libavcodec/vp56.h | 4 libavcodec/vp6.c | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index f68c62527b..a3c3da7ba6 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -306,4 +306,5 @@ const AVCodec ff_vp5_decoder = { .close = ff_vp56_free, .decode = ff_vp56_decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 695f37e972..d4184f59b4 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -800,10 +800,8 @@ av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++) { s->frames[i] = av_frame_alloc(); -if (!s->frames[i]) { -ff_vp56_free(avctx); +if (!s->frames[i]) return AVERROR(ENOMEM); -} } s->edge_emu_buffer_alloc = NULL; diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 46090f25c9..0a9eebc7ea 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -217,6 +217,10 @@ struct vp56_context { int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha); +/** + * Initializes an VP56Context. Expects its caller to clean up + * in case of error. + */ int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, int flip, int has_alpha); int ff_vp56_free(AVCodecContext *avctx); diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 95ed5eba0f..6bcbbce47b 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -720,6 +720,7 @@ const AVCodec ff_vp6_decoder = { .close = vp6_decode_free, .decode = ff_vp56_decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; /* flash version, not flipped upside-down */ @@ -733,6 +734,7 @@ const AVCodec ff_vp6f_decoder = { .close = vp6_decode_free, .decode = ff_vp56_decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; /* flash version, not flipped upside-down, with alpha channel */ -- 2.32.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 3/6] avcodec/vp6: Avoid allocation for alpha_context
Signed-off-by: Andreas Rheinhardt --- libavcodec/vp6.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 6bcbbce47b..3acca16f3c 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -652,10 +652,8 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx) vp6_decode_init_context(s); if (s->has_alpha) { -s->alpha_context = av_mallocz(sizeof(VP56Context)); -if (!s->alpha_context) { -return AVERROR(ENOMEM); -} +/* Can only happen for ff_vp6a_decoder */ +s->alpha_context = &s[1]; ret = ff_vp56_init_context(avctx, s->alpha_context, s->flip == -1, s->has_alpha); if (ret < 0) @@ -691,7 +689,7 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx) if (s->alpha_context) { ff_vp56_free_context(s->alpha_context); vp6_decode_free_context(s->alpha_context); -av_freep(&s->alpha_context); +s->alpha_context = NULL; } return 0; @@ -743,7 +741,7 @@ const AVCodec ff_vp6a_decoder = { .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP6A, -.priv_data_size = sizeof(VP56Context), +.priv_data_size = 2 /* Main context + alpha context */ * sizeof(VP56Context), .init = vp6_decode_init, .close = vp6_decode_free, .decode = ff_vp56_decode_frame, -- 2.32.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 4/6] avcodec/vp6: Avoid code duplication when initializing VP56 contexts
Signed-off-by: Andreas Rheinhardt --- libavcodec/vp6.c | 51 +--- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 3acca16f3c..ae8e223349 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -637,57 +637,58 @@ static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src, } } -static av_cold void vp6_decode_init_context(VP56Context *s); +static av_cold int vp6_decode_init_context(AVCodecContext *avctx, + VP56Context *s, int flip, int has_alpha) +{ +int ret = ff_vp56_init_context(avctx, s, flip, has_alpha); +if (ret < 0) +return ret; + +ff_vp6dsp_init(&s->vp56dsp); + +s->deblock_filtering = 0; +s->vp56_coord_div = vp6_coord_div; +s->parse_vector_adjustment = vp6_parse_vector_adjustment; +s->filter = vp6_filter; +s->default_models_init = vp6_default_models_init; +s->parse_vector_models = vp6_parse_vector_models; +s->parse_coeff_models = vp6_parse_coeff_models; +s->parse_header = vp6_parse_header; + +return 0; +} static av_cold int vp6_decode_init(AVCodecContext *avctx) { VP56Context *s = avctx->priv_data; int ret; -if ((ret = ff_vp56_init(avctx, avctx->codec->id == AV_CODEC_ID_VP6, -avctx->codec->id == AV_CODEC_ID_VP6A)) < 0) +ret = vp6_decode_init_context(avctx, s, avctx->codec_id == AV_CODEC_ID_VP6, + avctx->codec_id == AV_CODEC_ID_VP6A); +if (ret < 0) return ret; -ff_vp6dsp_init(&s->vp56dsp); - -vp6_decode_init_context(s); if (s->has_alpha) { /* Can only happen for ff_vp6a_decoder */ s->alpha_context = &s[1]; -ret = ff_vp56_init_context(avctx, s->alpha_context, - s->flip == -1, s->has_alpha); +ret = vp6_decode_init_context(avctx, s->alpha_context, + s->flip == -1, s->has_alpha); if (ret < 0) return ret; -ff_vp6dsp_init(&s->alpha_context->vp56dsp); -vp6_decode_init_context(s->alpha_context); } return 0; } -static av_cold void vp6_decode_init_context(VP56Context *s) -{ -s->deblock_filtering = 0; -s->vp56_coord_div = vp6_coord_div; -s->parse_vector_adjustment = vp6_parse_vector_adjustment; -s->filter = vp6_filter; -s->default_models_init = vp6_default_models_init; -s->parse_vector_models = vp6_parse_vector_models; -s->parse_coeff_models = vp6_parse_coeff_models; -s->parse_header = vp6_parse_header; -} - static av_cold void vp6_decode_free_context(VP56Context *s); static av_cold int vp6_decode_free(AVCodecContext *avctx) { VP56Context *s = avctx->priv_data; -ff_vp56_free(avctx); vp6_decode_free_context(s); if (s->alpha_context) { -ff_vp56_free_context(s->alpha_context); vp6_decode_free_context(s->alpha_context); s->alpha_context = NULL; } @@ -699,6 +700,8 @@ static av_cold void vp6_decode_free_context(VP56Context *s) { int pt, ct, cg; +ff_vp56_free_context(s); + for (pt=0; pt<2; pt++) { ff_free_vlc(&s->dccv_vlc[pt]); ff_free_vlc(&s->runv_vlc[pt]); -- 2.32.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 5/6] avcodec/vp56: Avoid functions with only one caller
Signed-off-by: Andreas Rheinhardt --- libavcodec/vp5.c | 10 -- libavcodec/vp56.c | 12 libavcodec/vp56.h | 2 -- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index a3c3da7ba6..dc24f5b096 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -282,7 +282,7 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx) VP56Context *s = avctx->priv_data; int ret; -if ((ret = ff_vp56_init(avctx, 1, 0)) < 0) +if ((ret = ff_vp56_init_context(avctx, s, 1, 0)) < 0) return ret; ff_vp5dsp_init(&s->vp56dsp); s->vp56_coord_div = vp5_coord_div; @@ -296,6 +296,12 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx) return 0; } +static av_cold int vp56_free(AVCodecContext *avctx) +{ +VP56Context *const s = avctx->priv_data; +return ff_vp56_free_context(s); +} + const AVCodec ff_vp5_decoder = { .name = "vp5", .long_name = NULL_IF_CONFIG_SMALL("On2 VP5"), @@ -303,7 +309,7 @@ const AVCodec ff_vp5_decoder = { .id = AV_CODEC_ID_VP5, .priv_data_size = sizeof(VP56Context), .init = vp5_decode_init, -.close = ff_vp56_free, +.close = vp56_free, .decode = ff_vp56_decode_frame, .capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index d4184f59b4..9819393447 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -773,12 +773,6 @@ next: return 0; } -av_cold int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha) -{ -VP56Context *s = avctx->priv_data; -return ff_vp56_init_context(avctx, s, flip, has_alpha); -} - av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, int flip, int has_alpha) { @@ -830,12 +824,6 @@ av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, return 0; } -av_cold int ff_vp56_free(AVCodecContext *avctx) -{ -VP56Context *s = avctx->priv_data; -return ff_vp56_free_context(s); -} - av_cold int ff_vp56_free_context(VP56Context *s) { int i; diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 0a9eebc7ea..e0dfaa8981 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -216,14 +216,12 @@ struct vp56_context { }; -int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha); /** * Initializes an VP56Context. Expects its caller to clean up * in case of error. */ int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, int flip, int has_alpha); -int ff_vp56_free(AVCodecContext *avctx); int ff_vp56_free_context(VP56Context *s); void ff_vp56_init_dequant(VP56Context *s, int quantizer); int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, -- 2.32.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 6/6] avcodec/vp[56]: Mark decoders as init-threadsafe
Nothing with static storage duration is initialized by these codecs. Signed-off-by: Andreas Rheinhardt --- libavcodec/vp5.c | 2 +- libavcodec/vp6.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index dc24f5b096..6146fbbc3a 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -312,5 +312,5 @@ const AVCodec ff_vp5_decoder = { .close = vp56_free, .decode = ff_vp56_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, }; diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index ae8e223349..40d266916e 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -721,7 +721,7 @@ const AVCodec ff_vp6_decoder = { .close = vp6_decode_free, .decode = ff_vp56_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, }; /* flash version, not flipped upside-down */ @@ -735,7 +735,7 @@ const AVCodec ff_vp6f_decoder = { .close = vp6_decode_free, .decode = ff_vp56_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, }; /* flash version, not flipped upside-down, with alpha channel */ @@ -749,5 +749,5 @@ const AVCodec ff_vp6a_decoder = { .close = vp6_decode_free, .decode = ff_vp56_decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; -- 2.32.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".
Re: [FFmpeg-devel] [PATCH] aarch64: h264dsp: Fix incorrectly indented code
On Mon, 7 Feb 2022, Martin Storsjö wrote: Signed-off-by: Martin Storsjö --- This should reduce the risk of anyone accidentally writing new code based on an incorrect example. --- libavcodec/aarch64/h264dsp_neon.S | 176 +++--- 1 file changed, 88 insertions(+), 88 deletions(-) I pushed this now. // Martin ___ 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] avcodec/g2meet: Cleanup generically on init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/g2meet.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c > index 4c53838af5..8628016ef4 100644 > --- a/libavcodec/g2meet.c > +++ b/libavcodec/g2meet.c > @@ -1592,7 +1592,6 @@ static av_cold int g2m_decode_init(AVCodecContext > *avctx) > > if ((ret = jpg_init(avctx, &c->jc)) != 0) { > av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n"); > -jpg_free_context(&c->jc); > return AVERROR(ENOMEM); > } > > @@ -1633,5 +1632,5 @@ const AVCodec ff_g2m_decoder = { > .close = g2m_decode_end, > .decode = g2m_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, > }; Will apply this tonight unless there are objections. - Andreas ___ 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] avutil/tx: Fix documentation of av_tx_uninit()
Andreas Rheinhardt: > Adapt it to the actual (sane) behaviour. > > Signed-off-by: Andreas Rheinhardt > --- > libavutil/tx.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavutil/tx.h b/libavutil/tx.h > index 087355f10d..3de2f7231b 100644 > --- a/libavutil/tx.h > +++ b/libavutil/tx.h > @@ -154,7 +154,7 @@ int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum > AVTXType type, > int inv, int len, const void *scale, uint64_t flags); > > /** > - * Frees a context and sets ctx to NULL, does nothing when ctx == NULL > + * Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL. > */ > void av_tx_uninit(AVTXContext **ctx); > Will apply this later tonight unless there are objections. - Andreas ___ 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] avcodec/metasound, twinvqdec: Cleanup generically upon init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/metasound.c | 2 +- > libavcodec/twinvq.c| 5 + > libavcodec/twinvq.h| 1 + > libavcodec/twinvqdec.c | 2 +- > 4 files changed, 4 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/metasound.c b/libavcodec/metasound.c > index 57851a43c5..f066182f02 100644 > --- a/libavcodec/metasound.c > +++ b/libavcodec/metasound.c > @@ -382,5 +382,5 @@ const AVCodec ff_metasound_decoder = { > .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, > .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, >AV_SAMPLE_FMT_NONE }, > -.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; > diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c > index 6dfaf06b14..38482e8c21 100644 > --- a/libavcodec/twinvq.c > +++ b/libavcodec/twinvq.c > @@ -783,13 +783,10 @@ av_cold int ff_twinvq_decode_init(AVCodecContext *avctx) > tctx->frames_per_packet = frames_per_packet; > > tctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & > AV_CODEC_FLAG_BITEXACT); > -if (!tctx->fdsp) { > -ff_twinvq_decode_close(avctx); > +if (!tctx->fdsp) > return AVERROR(ENOMEM); > -} > if ((ret = init_mdct_win(tctx))) { > av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); > -ff_twinvq_decode_close(avctx); > return ret; > } > init_bitstream_params(tctx); > diff --git a/libavcodec/twinvq.h b/libavcodec/twinvq.h > index 234604f581..5f49796f03 100644 > --- a/libavcodec/twinvq.h > +++ b/libavcodec/twinvq.h > @@ -197,6 +197,7 @@ static inline float twinvq_mulawinv(float y, float clip, > float mu) > int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, > int *got_frame_ptr, AVPacket *avpkt); > int ff_twinvq_decode_close(AVCodecContext *avctx); > +/** Requires the caller to call ff_twinvq_decode_close() upon failure. */ > int ff_twinvq_decode_init(AVCodecContext *avctx); > > #endif /* AVCODEC_TWINVQ_H */ > diff --git a/libavcodec/twinvqdec.c b/libavcodec/twinvqdec.c > index 1fbe0bc32e..090a9fb0eb 100644 > --- a/libavcodec/twinvqdec.c > +++ b/libavcodec/twinvqdec.c > @@ -426,5 +426,5 @@ const AVCodec ff_twinvq_decoder = { > .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, > .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, >AV_SAMPLE_FMT_NONE }, > -.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; Will apply this later tonight unless there are objections. - Andreas ___ 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] avcodec/ralf: Cleanup generically on init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/ralf.c | 26 +++--- > 1 file changed, 7 insertions(+), 19 deletions(-) > > diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c > index bb80119b0c..0c51f49939 100644 > --- a/libavcodec/ralf.c > +++ b/libavcodec/ralf.c > @@ -163,47 +163,35 @@ static av_cold int decode_init(AVCodecContext *avctx) > for (i = 0; i < 3; i++) { > ret = init_ralf_vlc(&ctx->sets[i].filter_params, filter_param_def[i], > FILTERPARAM_ELEMENTS); > -if (ret < 0) { > -decode_close(avctx); > +if (ret < 0) > return ret; > -} > ret = init_ralf_vlc(&ctx->sets[i].bias, bias_def[i], BIAS_ELEMENTS); > -if (ret < 0) { > -decode_close(avctx); > +if (ret < 0) > return ret; > -} > ret = init_ralf_vlc(&ctx->sets[i].coding_mode, coding_mode_def[i], > CODING_MODE_ELEMENTS); > -if (ret < 0) { > -decode_close(avctx); > +if (ret < 0) > return ret; > -} > for (j = 0; j < 10; j++) { > for (k = 0; k < 11; k++) { > ret = init_ralf_vlc(&ctx->sets[i].filter_coeffs[j][k], > filter_coeffs_def[i][j][k], > FILTER_COEFFS_ELEMENTS); > -if (ret < 0) { > -decode_close(avctx); > +if (ret < 0) > return ret; > -} > } > } > for (j = 0; j < 15; j++) { > ret = init_ralf_vlc(&ctx->sets[i].short_codes[j], > short_codes_def[i][j], SHORT_CODES_ELEMENTS); > -if (ret < 0) { > -decode_close(avctx); > +if (ret < 0) > return ret; > -} > } > for (j = 0; j < 125; j++) { > ret = init_ralf_vlc(&ctx->sets[i].long_codes[j], > long_codes_def[i][j], LONG_CODES_ELEMENTS); > -if (ret < 0) { > -decode_close(avctx); > +if (ret < 0) > return ret; > -} > } > } > > @@ -539,5 +527,5 @@ const AVCodec ff_ralf_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, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; Will apply this later tonight unless there are objections. - Andreas ___ 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/2] avcodec/vc2enc_dwt: Avoid NULL - 0
Andreas Rheinhardt: > It is sane, but UB. It could happen in case of allocation errors > in vc2_encode_init(). > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/vc2enc_dwt.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/vc2enc_dwt.c b/libavcodec/vc2enc_dwt.c > index a8d3f1c669..441af040ec 100644 > --- a/libavcodec/vc2enc_dwt.c > +++ b/libavcodec/vc2enc_dwt.c > @@ -276,6 +276,8 @@ av_cold int ff_vc2enc_init_transforms(VC2TransformContext > *s, int p_stride, > > av_cold void ff_vc2enc_free_transforms(VC2TransformContext *s) > { > -av_free(s->buffer - s->padding); > -s->buffer = NULL; > +if (s->buffer) { > +av_free(s->buffer - s->padding); > +s->buffer = NULL; > +} > } Will apply these patches later tonight unless there are objections. - Andreas ___ 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] avcodec/tta: Cleanup generically on init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/tta.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/tta.c b/libavcodec/tta.c > index 17b4ca9032..accac38893 100644 > --- a/libavcodec/tta.c > +++ b/libavcodec/tta.c > @@ -114,10 +114,8 @@ static int allocate_buffers(AVCodecContext *avctx) > } else > s->decode_buffer = NULL; > s->ch_ctx = av_malloc_array(avctx->channels, sizeof(*s->ch_ctx)); > -if (!s->ch_ctx) { > -av_freep(&s->decode_buffer); > +if (!s->ch_ctx) > return AVERROR(ENOMEM); > -} > > return 0; > } > @@ -427,5 +425,5 @@ const AVCodec ff_tta_decoder = { > .decode = tta_decode_frame, > .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | > AV_CODEC_CAP_CHANNEL_CONF, > .priv_class = &tta_decoder_class, > -.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; Will apply this later tonight unless there are objections. - Andreas ___ 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] avcodec/cavsdec: Cleanup generically on init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/cavs.c| 4 +--- > libavcodec/cavsdec.c | 1 + > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c > index e29d9c659b..5367c44248 100644 > --- a/libavcodec/cavs.c > +++ b/libavcodec/cavs.c > @@ -812,10 +812,8 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) > h->cur.f= av_frame_alloc(); > h->DPB[0].f = av_frame_alloc(); > h->DPB[1].f = av_frame_alloc(); > -if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) { > -ff_cavs_end(avctx); > +if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) > return AVERROR(ENOMEM); > -} > > h->luma_scan[0] = 0; > h->luma_scan[1] = 8; > diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c > index 894aa1b54a..54e1877bbd 100644 > --- a/libavcodec/cavsdec.c > +++ b/libavcodec/cavsdec.c > @@ -1319,4 +1319,5 @@ const AVCodec ff_cavs_decoder = { > .decode = cavs_decode_frame, > .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, > .flush = cavs_flush, > +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, > }; Will apply this patchset later tonight unless there are objections. - Andreas ___ 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] avcodec/cbs_jpeg: Fix size of huffman symbol table array
Andreas Rheinhardt: > L[i] can be in the range of 0-255, see table B.5 of ITU T.81. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/cbs_jpeg.h | 2 +- > libavcodec/cbs_jpeg_syntax_template.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/cbs_jpeg.h b/libavcodec/cbs_jpeg.h > index 6305f0ee86..9dbebd259f 100644 > --- a/libavcodec/cbs_jpeg.h > +++ b/libavcodec/cbs_jpeg.h > @@ -99,7 +99,7 @@ typedef struct JPEGRawHuffmanTable { > uint8_t Tc; > uint8_t Th; > uint8_t L[16]; > -uint8_t V[224]; > +uint8_t V[256]; > } JPEGRawHuffmanTable; > > typedef struct JPEGRawHuffmanTableSpecification { > diff --git a/libavcodec/cbs_jpeg_syntax_template.c > b/libavcodec/cbs_jpeg_syntax_template.c > index 6eda56d623..e06abdc674 100644 > --- a/libavcodec/cbs_jpeg_syntax_template.c > +++ b/libavcodec/cbs_jpeg_syntax_template.c > @@ -84,12 +84,12 @@ static int FUNC(huffman_table)(CodedBitstreamContext > *ctx, RWContext *rw, > u(4, Th, 0, 3); > > for (i = 0; i < 16; i++) > -us(8, L[i], i, 0, 224); > +us(8, L[i], i, 0, 255); > > ij = 0; > for (i = 0; i < 16; i++) { > for (j = 0; j < current->L[i]; j++) { > -if (ij >= 224) > +if (ij >= FF_ARRAY_ELEMS(current->V)) > return AVERROR_INVALIDDATA; > us(8, V[ij], ij, 0, 255); > ++ij; Will apply this later tonight unless there are objections. - Andreas ___ 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/2] avcodec/proresenc_kostya: Cleanup generically after init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/proresenc_kostya.c | 14 -- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c > index 85651fce2a..08a874dd4e 100644 > --- a/libavcodec/proresenc_kostya.c > +++ b/libavcodec/proresenc_kostya.c > @@ -1274,25 +1274,19 @@ static av_cold int encode_init(AVCodecContext *avctx) > } > > ctx->slice_q = av_malloc(ctx->slices_per_picture * > sizeof(*ctx->slice_q)); > -if (!ctx->slice_q) { > -encode_close(avctx); > +if (!ctx->slice_q) > return AVERROR(ENOMEM); > -} > > ctx->tdata = av_mallocz(avctx->thread_count * sizeof(*ctx->tdata)); > -if (!ctx->tdata) { > -encode_close(avctx); > +if (!ctx->tdata) > return AVERROR(ENOMEM); > -} > > for (j = 0; j < avctx->thread_count; j++) { > ctx->tdata[j].nodes = av_malloc((ctx->slices_width + 1) > * TRELLIS_WIDTH > * sizeof(*ctx->tdata->nodes)); > -if (!ctx->tdata[j].nodes) { > -encode_close(avctx); > +if (!ctx->tdata[j].nodes) > return AVERROR(ENOMEM); > -} > for (i = min_quant; i < max_quant + 2; i++) { > ctx->tdata[j].nodes[i].prev_node = -1; > ctx->tdata[j].nodes[i].bits = 0; > @@ -1415,5 +1409,5 @@ const AVCodec ff_prores_ks_encoder = { >}, > .priv_class = &proresenc_class, > .profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), > -.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | > FF_CODEC_CAP_INIT_CLEANUP, > }; Will apply this patchset later tonight unless there are objections. - Andreas ___ 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] avcodec/4xm: Cleanup generically on init failure
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/4xm.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c > index cb315cd7e4..cb361772d2 100644 > --- a/libavcodec/4xm.c > +++ b/libavcodec/4xm.c > @@ -1008,10 +1008,8 @@ static av_cold int decode_init(AVCodecContext *avctx) > > f->frame_buffer = av_mallocz(avctx->width * avctx->height * 2); > f->last_frame_buffer = av_mallocz(avctx->width * avctx->height * 2); > -if (!f->frame_buffer || !f->last_frame_buffer) { > -decode_end(avctx); > +if (!f->frame_buffer || !f->last_frame_buffer) > return AVERROR(ENOMEM); > -} > > f->version = AV_RL32(avctx->extradata) >> 16; > ff_blockdsp_init(&f->bdsp, avctx); > @@ -1038,5 +1036,5 @@ const AVCodec ff_fourxm_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, > }; Will apply this patchset later tonight unless there are objections. - Andreas ___ 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] avcodec/8bps: Mark decoder as init-threadsafe
The only unorthodox thing that this codec's init function does is calling ff_get_format(). Yet this is supposed to be save, as any get_format callback already has to deal with the scenario of different AVCodecContext's calling it simultaneously. Signed-off-by: Andreas Rheinhardt --- libavcodec/8bps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 6865b9b12e..46419b978b 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -182,4 +182,5 @@ const AVCodec ff_eightbps_decoder = { .init = decode_init, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; -- 2.32.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] avcodec/vc1: Fix indentation
Signed-off-by: Andreas Rheinhardt --- libavcodec/vc1.c | 213 +++ 1 file changed, 106 insertions(+), 107 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 40e2b4d692..fa028a5784 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -1584,115 +1584,114 @@ static const uint16_t vlc_offs[] = { static av_cold void vc1_init_static(void) { -int i = 0; static VLC_TYPE vlc_table[32372][2]; -INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, -ff_vc1_bfraction_bits, 1, 1, -ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS); -INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4, -ff_vc1_norm2_bits, 1, 1, -ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS); -INIT_VLC_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64, -ff_vc1_norm6_bits, 1, 1, -ff_vc1_norm6_codes, 2, 2, 556); -INIT_VLC_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7, -ff_vc1_imode_bits, 1, 1, -ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS); -for (i = 0; i < 3; i++) { -ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 0]]; -ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i * 3 + 1] - vlc_offs[i * 3 + 0]; -init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16, - ff_vc1_ttmb_bits[i], 1, 1, - ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); -ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 1]]; -ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i * 3 + 2] - vlc_offs[i * 3 + 1]; -init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8, - ff_vc1_ttblk_bits[i], 1, 1, - ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); -ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 2]]; -ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - vlc_offs[i * 3 + 2]; -init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, - ff_vc1_subblkpat_bits[i], 1, 1, - ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); -} -for (i = 0; i < 4; i++) { -ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 9]]; -ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i * 3 + 10] - vlc_offs[i * 3 + 9]; -init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16, - ff_vc1_4mv_block_pattern_bits[i], 1, 1, - ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); -ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 10]]; -ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i * 3 + 11] - vlc_offs[i * 3 + 10]; -init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64, - ff_vc1_cbpcy_p_bits[i], 1, 1, - ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); -ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 11]]; -ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i * 3 + 12] - vlc_offs[i * 3 + 11]; -init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73, - ff_vc1_mv_diff_bits[i], 1, 1, - ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); -} -for (i = 0; i < 8; i++) { -ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i * 2 + 21]]; -ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i * 2 + 22] - vlc_offs[i * 2 + 21]; -init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, ff_vc1_ac_sizes[i], - &vc1_ac_tables[i][0][1], 8, 4, - &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_NEW_STATIC); -/* initialize interlaced MVDATA tables (2-Ref) */ -ff_vc1_2ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 2 + 22]]; -ff_vc1_2ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 2 + 23] - vlc_offs[i * 2 + 22]; -init_vlc(&ff_vc1_2ref_mvdata_vlc[i], VC1_2REF_MVDATA_VLC_BITS, 126, - ff_vc1_2ref_mvdata_bits[i], 1, 1, - ff_vc1_2ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC); -} -for (i = 0; i < 4; i++) { -/* initialize 4MV MBMODE VLC tables for interlaced frame P picture */ -ff_vc1_intfr_4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 37]]; -ff_vc1_intfr_4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 38] - vlc_offs[i * 3 + 37]; -init_vlc(&ff_vc1_in
[FFmpeg-devel] [PATCH] avcodec/pthread_frame: Remove nonsense error message
If a frame-threaded decoder with inter-frame dependencies returns an error when decoding a frame and the returned frame isn't clean, an error message is emitted claiming that this is a bug. This seems to be based upon the thinking that in this case a ThreadFrame has not been properly unreferenced. Yet this is wrong, as decoders with inter-frame dependencies don't use the frame for output for synchronization and therefore don't use ThreadFrames at all for this. So unreferencing this frame generically is fine and not a bug. Signed-off-by: Andreas Rheinhardt --- I hope my guess of the rationale for this message was correct; apologies if not. libavcodec/pthread_frame.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 27ed0b2cc4..33b5a2e628 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -219,12 +219,8 @@ FF_ENABLE_DEPRECATION_WARNINGS p->got_frame = 0; p->result = codec->decode(avctx, p->frame, &p->got_frame, p->avpkt); -if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) { -if (avctx->codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) -av_log(avctx, AV_LOG_ERROR, "A frame threaded decoder did not " - "free the frame on failure. This is a bug, please report it.\n"); +if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) ff_thread_release_buffer(avctx, p->frame); -} if (atomic_load(&p->state) == STATE_SETTING_UP) ff_thread_finish_setup(avctx); -- 2.32.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".
Re: [FFmpeg-devel] [PATCH 1/2] http: Improve handling of Content-Range with Transfer-Encoding:chunked
On Wed, Feb 9, 2022 at 9:49 AM Paul B Mahol wrote: > On Wed, Feb 9, 2022 at 1:56 AM Vittorio Giovara < > vittorio.giov...@gmail.com> > wrote: > > > On Thu, Feb 3, 2022 at 3:12 PM Derek Buitenhuis < > > derek.buitenh...@gmail.com> > > wrote: > > > > > On 2/3/2022 1:26 AM, Aman Karmani wrote: > > > > The size part of the range header is optional, and can be '*' as > well. > > > > > > > > See also > > > > > > > > > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211005233244.37582-1-ffm...@tmm1.net/ > > > > > > Isn't this an orthogonal problem to what this patch is changing? > > > > > > - Derek > > > ___ > > > > > > > Are there any other comments/objections to the patchset? > > > > Nope. Just apply it. > Pushed o/ -- Vittorio ___ 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] avcodec/vp6: Check alpha_context for allocation failures
Fixes: null pointer dereference Reported-by: TOTE Robot Signed-off-by: Steven Liu --- libavcodec/vp6.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index d024370793..7ddabbff80 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -653,6 +653,8 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx) if (s->has_alpha) { s->alpha_context = av_mallocz(sizeof(VP56Context)); +if (!s->alpha_context) +return AVERROR(ENOMEM); ff_vp56_init_context(avctx, s->alpha_context, s->flip == -1, s->has_alpha); ff_vp6dsp_init(&s->alpha_context->vp56dsp); -- 2.25.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".
Re: [FFmpeg-devel] [PATCH] avcodec/vp6: Check alpha_context for allocation failures
Steven Liu: > Fixes: null pointer dereference > > Reported-by: TOTE Robot > Signed-off-by: Steven Liu > --- > libavcodec/vp6.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c > index d024370793..7ddabbff80 100644 > --- a/libavcodec/vp6.c > +++ b/libavcodec/vp6.c > @@ -653,6 +653,8 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx) > > if (s->has_alpha) { > s->alpha_context = av_mallocz(sizeof(VP56Context)); > +if (!s->alpha_context) > +return AVERROR(ENOMEM); > ff_vp56_init_context(avctx, s->alpha_context, > s->flip == -1, s->has_alpha); > ff_vp6dsp_init(&s->alpha_context->vp56dsp); Already fixed by https://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/292714.html (pushed as c4d63dbc9417ddf77f6e33f6144b23da7e97cb3b). Furthermore, your patch would leak in case of allocation failure. - Andreas ___ 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 0/2] Some cleanup for header includes
Just some small header cleanup. Andreas Schneider (2): avcodec/exif: Include bytestream.h for GetByteContext avcodec/exif: Include tiff_common.h only where needed libavcodec/exif.c | 1 + libavcodec/exif.h | 2 +- libavcodec/mjpegdec.c | 1 + libavcodec/webp.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) -- 2.34.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 1/2] avcodec/exif: Include bytestream.h for GetByteContext
bytestream.h should be directly included for GetByteContext and not rely on other headers to include it. It could be removed from there. Signed-off-by: Andreas Schneider --- libavcodec/exif.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/exif.h b/libavcodec/exif.h index 4db84a1c2f..310f6e8e64 100644 --- a/libavcodec/exif.h +++ b/libavcodec/exif.h @@ -30,6 +30,7 @@ #include #include "libavutil/dict.h" +#include "bytestream.h" #include "tiff.h" #define EXIF_MAX_IFD_RECURSION 2 -- 2.34.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 2/2] avcodec/exif: Don't include tiff.h in exif.h
The exif.h header doesn't use anything from tiff.h. We also just need to include tiff_common.h in .c files where it actually used. Signed-off-by: Andreas Schneider --- libavcodec/exif.c | 1 + libavcodec/exif.h | 1 - libavcodec/mjpegdec.c | 1 + libavcodec/webp.c | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/exif.c b/libavcodec/exif.c index 0b656fd09b..9485b24b8e 100644 --- a/libavcodec/exif.c +++ b/libavcodec/exif.c @@ -26,6 +26,7 @@ */ #include "exif.h" +#include "tiff_common.h" static const char *exif_get_tag_name(uint16_t id) diff --git a/libavcodec/exif.h b/libavcodec/exif.h index 310f6e8e64..ffacba7e66 100644 --- a/libavcodec/exif.h +++ b/libavcodec/exif.h @@ -31,7 +31,6 @@ #include #include "libavutil/dict.h" #include "bytestream.h" -#include "tiff.h" #define EXIF_MAX_IFD_RECURSION 2 #define EXIF_TAG_NAME_LENGTH 32 diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index a735d2337d..267609d96a 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -50,6 +50,7 @@ #include "tiff.h" #include "exif.h" #include "bytestream.h" +#include "tiff_common.h" static int init_default_huffman_tables(MJpegDecodeContext *s) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 9e642e050a..148dc02170 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -48,6 +48,7 @@ #include "exif.h" #include "get_bits.h" #include "internal.h" +#include "tiff_common.h" #include "thread.h" #include "vp8.h" -- 2.34.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] use cpu
ffmpeg use 50-70% cpu only How change thread or add virtual vcpu? If I run 2 instances of ffmpeg I get 100% cpu and real processing speedup, but I need to speed up single-instances calculation base command : ffmpeg -y -i $file -vcodec libx264 -acodec copy $file.mp4 ___ 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] [FFmpeg-devel, v2] avformat/img2dec: Option to play sequence backwards
This patch should allow to play a image sequence in backwards direction, without needing to apply a reverse filter. $ ffmpeg -i sequence%05.png forward.mkv $ ffmpeg -reverse 1 sequence%05.png backward.mkv Signed-off-by: Sergio Acereda --- libavformat/img2.h| 1 + libavformat/img2dec.c | 32 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libavformat/img2.h b/libavformat/img2.h index 5fd8ff77fc..3d01c00537 100644 --- a/libavformat/img2.h +++ b/libavformat/img2.h @@ -59,6 +59,7 @@ typedef struct VideoDemuxData { #endif int start_number; int start_number_range; +int reverse; int frame_size; int ts_from_file; int export_path_metadata; /**< enabled when set to 1. */ diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index 8608252d83..90465441f1 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -105,10 +105,12 @@ static int is_glob(const char *path) * @param plast_index pointer to index updated with the last number in the range * @param path path which has to be matched by the image files in the range * @param start_index minimum accepted value for the first index in the range + * @param start_index_range range for looking at the first sequence number + * @param reverse play backwards * @return -1 if no image file could be found */ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index, -const char *path, int start_index, int start_index_range) +const char *path, int start_index, int start_index_range, int reverse) { char buf[1024]; int range, last_index, range1, first_index; @@ -152,8 +154,14 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index break; last_index += range; } -*pfirst_index = first_index; -*plast_index = last_index; +if (reverse) { +*pfirst_index = last_index; +*plast_index = first_index; +} +else { +*pfirst_index = first_index; +*plast_index = last_index; +} return 0; fail: @@ -274,7 +282,7 @@ int ff_img_read_header(AVFormatContext *s1) } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(s1->pb, &first_index, &last_index, s->path, - s->start_number, s->start_number_range) < 0) { + s->start_number, s->start_number_range, s->reverse) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); @@ -307,7 +315,7 @@ int ff_img_read_header(AVFormatContext *s1) /* compute duration */ if (!s->ts_from_file) { st->start_time = 0; -st->duration = last_index - first_index + 1; +st->duration = abs(last_index - first_index) + 1; } } @@ -413,11 +421,12 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) AVCodecParameters *par = s1->streams[0]->codecpar; if (!s->is_pipe) { +int bad = s->reverse? (s->img_number < s->img_last) : (s->img_number > s->img_last); /* loop over input */ -if (s->loop && s->img_number > s->img_last) { +if (s->loop && bad) { s->img_number = s->img_first; } -if (s->img_number > s->img_last) +if (bad) return AVERROR_EOF; if (s->pattern_type == PT_NONE) { av_strlcpy(filename_bytes, s->path, sizeof(filename_bytes)); @@ -554,8 +563,9 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) } goto fail; } else { +int step = s->reverse? -1 : 1; s->img_count++; -s->img_number++; +s->img_number += step; s->pts++; return 0; } @@ -594,9 +604,10 @@ static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp return 0; } -if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first) +int bad = s1->reverse? (timestamp < s1->img_last) : (timestamp > s1->img_last); +if (timestamp < 0 || !s1->loop && bad) return -1; -s1->img_number = timestamp%(s1->img_last - s1->img_first + 1) + s1->img_first; +s1->img_number = timestamp%abs(s1->img_last - s1->img_first + 1) + s1->img_first; s1->pts = timestamp; return 0; } @@ -619,6 +630,7 @@ const AVOption ff_img_options[] = { { "none", "disable pattern matching",0, AV_OPT_TYPE_CONST, {.i64=PT_NONE }, INT_MIN, INT_MAX, DEC, "pattern_type" }, { "start_number", "set first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT,{.i64 = 0 }, INT_MIN, INT_MAX, DEC }, { "start_number_range", "set range for
Re: [FFmpeg-devel] [PATCH] avformat/img2dec: Option to play sequence backwards
Not sure what I'm doing wrong here. This is what I'm doing: $ git pull $ git co master ...apply changes... $ git add libavformat/img2.h $ git add libavformat/img2dec.c $ git commit -s -m"[PATCH] avformat/img2dec: Option to play sequence backwards" $ git format-patch -s -o "outputfolder" --add-header "X-Unsent: 1" --suffix .eml --to ffmpeg-devel@ffmpeg.org -1 6b36bb6 Then I open the .eml on Apple Mail client, select 'Message / Send Again', and add some explanation before the 'signed off' line. Just wondering what is wrong here, in order to not repeating the same mistake again. Thanks, Sergio > On 10 Feb 2022, at 21:50, Sergio Acereda wrote: > > By the way, is there any problem with the patch itself? Not sure why it says > 'Failed to apply patch'. > > Did my email client break it somehow? ___ 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] avformat/img2dec: Option to play sequence backwards
On 11 Feb 2022, at 17:45, Sergio Acereda wrote: Not sure what I'm doing wrong here. This is what I'm doing: $ git pull $ git co master ...apply changes... $ git add libavformat/img2.h $ git add libavformat/img2dec.c $ git commit -s -m"[PATCH] avformat/img2dec: Option to play sequence backwards" $ git format-patch -s -o "outputfolder" --add-header "X-Unsent: 1" --suffix .eml --to ffmpeg-devel@ffmpeg.org -1 6b36bb6 Then I open the .eml on Apple Mail client, select 'Message / Send Again', and add some explanation before the 'signed off' line. Just wondering what is wrong here, in order to not repeating the same mistake again. I think Apple Mail wraps the lines in the mail or somehow else alters it breaking the patch. I would recommend to use git send-email or try it with a different mail client like MailMate maybe. Thanks, Sergio On 10 Feb 2022, at 21:50, Sergio Acereda wrote: By the way, is there any problem with the patch itself? Not sure why it says 'Failed to apply patch'. Did my email client break it somehow? ___ 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 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/6] avcodec/vp6: Avoid allocation for alpha_context
On Fri, Feb 11, 2022 at 09:50:58AM +0100, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/vp6.c | 10 -- > 1 file changed, 4 insertions(+), 6 deletions(-) nice thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] libavformat/mov: fix udta reading in trak box
On Feb 9, 2022, 7:31 AM +0800, Jan Ekström , wrote: > On Tue, Feb 8, 2022 at 9:48 AM Wang Chuan wrote: > > > > Any news? > > > > Sorry, was not able to get to this according to the time line I > expected. Will see if I can find some time for this soon. > > The attempt I had done in October was quite similar now that I look at > it again > (https://github.com/jeeb/ffmpeg/commits/enable_writing_udta_metadata_for_tracks), > although it seems like I missed c->trak_index , will have to check it > :) > > Additionally, when I did the changes a lot of tests had to be updated > as the test would expect the metadata in the main context, as > previously the metadata only got applied globally. The changes in my > commit aren't what's needed as I just committed the changes in test > results to remind myself which tests would require additional changes > or at least review. > > Looking at the patchwork side for this patch set, it seems like it > wasn't able to run the tests for you, so you probably did not get any > messages about failing tests? > https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=5839 > > For running tests locally, what I usually do is: > > 1. configure and build normally > 2. `make fate-rsync SAMPLES=../../path/to/fate-suite` > 3. `make fate SAMPLES=../../path/to/fate-suite` > > this is also documented at https://www.ffmpeg.org/fate.html . Thanks for your reply! I have tried running tests on my PC, but I didn’t meet any test failure... But if I use your patch, the tests failed. The difference between your patch and my is that you use [s->nb_streams - 1] but I use [c->trak_index]. It seems like [c->trak_index] is a better choice. (It seems like if we use [s->nb_streams - 1], the metadata we read will all go to the last) Can you check this again? 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] avformat/img2dec: Option to play sequence backwards
> I think Apple Mail wraps the lines in the mail or somehow else alters it > breaking > the patch. > > I would recommend to use git send-email or try it with a different mail > client > like MailMate maybe. I see... I'll try with git send-email then, not sure if it will open a new thread or continue here. 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] avfilter: add dialogue enhance audio filter
will apply soon ___ 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 v3 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility
On Sat, 5 Feb 2022, lance.lmw...@gmail.com wrote: From: Limin Wang Suggested by zhilizhao, vlc project has solved the compatibility by the same way, so I borrowed the comments from vlc project. Fix #ticket9449 Signed-off-by: Limin Wang --- libavformat/udp.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 8178d0e..1871acf 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, { int protocol, cmd; +/* There is some confusion in the world whether IP_MULTICAST_TTL + * takes a byte or an int as an argument. + * BSD seems to indicate byte so we are going with that and use + * int and fall back to byte to be safe */ switch (addr->sa_family) { #ifdef IP_MULTICAST_TTL case AF_INET: @@ -182,8 +186,15 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, } if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) { -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST TTL)"); -return ff_neterrno(); +/* BSD compatibility */ +unsigned char ttl; + +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST TTL)"); +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL); I guess this limit check here is no longer needed after the range checking patches, so just remove. Otherwise LGTM. Thanks, Marton +if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) { +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 MULTICAST TTL)"); +return ff_neterrno(); +} } return 0; -- 1.8.3.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 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] avformat/img2dec: Option to play sequence backwards
This patch should allow to play an image sequence in backwards direction, without needing to apply a reverse filter. ffmpeg -i sequence%05d.png forward.mkv ffmpeg -reverse 1 -i sequence%05d.png backward.mkv Signed-off-by: Sergio Acereda --- libavformat/img2.h| 1 + libavformat/img2dec.c | 34 -- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libavformat/img2.h b/libavformat/img2.h index 5fd8ff77fc..3d01c00537 100644 --- a/libavformat/img2.h +++ b/libavformat/img2.h @@ -59,6 +59,7 @@ typedef struct VideoDemuxData { #endif int start_number; int start_number_range; +int reverse; int frame_size; int ts_from_file; int export_path_metadata; /**< enabled when set to 1. */ diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index 8608252d83..7b85e01aca 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -105,10 +105,12 @@ static int is_glob(const char *path) * @param plast_index pointer to index updated with the last number in the range * @param path path which has to be matched by the image files in the range * @param start_index minimum accepted value for the first index in the range + * @param start_index_range range for looking at the first sequence number + * @param reverse play backwards * @return -1 if no image file could be found */ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index, -const char *path, int start_index, int start_index_range) +const char *path, int start_index, int start_index_range, int reverse) { char buf[1024]; int range, last_index, range1, first_index; @@ -152,8 +154,13 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index break; last_index += range; } -*pfirst_index = first_index; -*plast_index = last_index; +if (reverse) { +*pfirst_index = last_index; +*plast_index = first_index; +} else { +*pfirst_index = first_index; +*plast_index = last_index; +} return 0; fail: @@ -274,7 +281,7 @@ int ff_img_read_header(AVFormatContext *s1) } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(s1->pb, &first_index, &last_index, s->path, - s->start_number, s->start_number_range) < 0) { + s->start_number, s->start_number_range, s->reverse) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); @@ -307,7 +314,7 @@ int ff_img_read_header(AVFormatContext *s1) /* compute duration */ if (!s->ts_from_file) { st->start_time = 0; -st->duration = last_index - first_index + 1; +st->duration = abs(last_index - first_index) + 1; } } @@ -413,11 +420,12 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) AVCodecParameters *par = s1->streams[0]->codecpar; if (!s->is_pipe) { +int bad = s->reverse? (s->img_number < s->img_last) : (s->img_number > s->img_last); /* loop over input */ -if (s->loop && s->img_number > s->img_last) { +if (s->loop && bad) { s->img_number = s->img_first; } -if (s->img_number > s->img_last) +if (bad) return AVERROR_EOF; if (s->pattern_type == PT_NONE) { av_strlcpy(filename_bytes, s->path, sizeof(filename_bytes)); @@ -554,8 +562,9 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) } goto fail; } else { +int step = s->reverse? -1 : 1; s->img_count++; -s->img_number++; +s->img_number += step; s->pts++; return 0; } @@ -594,9 +603,13 @@ static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp return 0; } -if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first) +int bad = s1->reverse? (timestamp < s1->img_last) : (timestamp > s1->img_last); +if (timestamp < 0 || !s1->loop && bad) return -1; -s1->img_number = timestamp%(s1->img_last - s1->img_first + 1) + s1->img_first; +int dir = s1->reverse? -1 : 1; +int span = 1 + dir * (s1->img_last - s1->img_first); +int rel = timestamp % span; +s1->img_number = s1->img_first + dir * rel; s1->pts = timestamp; return 0; } @@ -619,6 +632,7 @@ const AVOption ff_img_options[] = { { "none", "disable pattern matching",0, AV_OPT_TYPE_CONST, {.i64=PT_NONE }, INT_MIN, INT_MAX, DEC, "pattern_type" }, { "start_number", "se
[FFmpeg-devel] [RFC][PATCH 1/4] avutil/frame: add an internal field to store the size of AVFrame
This is unfortunately needed to remove (or reduce the awfulness) of certain modules violating the AVFrame API and using sizeof(AVFrame). With this, the sizeof(AVFrame) value of the libavutil loaded at runtime can be used instead of the compile time value of whatever library included frame.h Signed-off-by: James Almer --- This is sucks, but at least less so than the current situation. I don't see wrapped_avframe going away anytime soon, so something must be done, and last time i tried to change how the packets are generated my approach was shut down, so here's another attempt. libavutil/frame.c | 3 +++ libavutil/frame_internal.h | 33 + 2 files changed, 36 insertions(+) create mode 100644 libavutil/frame_internal.h diff --git a/libavutil/frame.c b/libavutil/frame.c index 8997c85e35..a63d2979db 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -23,6 +23,7 @@ #include "cpu.h" #include "dict.h" #include "frame.h" +#include "frame_internal.h" #include "imgutils.h" #include "mem.h" #include "samplefmt.h" @@ -33,6 +34,8 @@ (frame)->channels == \ av_get_channel_layout_nb_channels((frame)->channel_layout)) +const size_t avpriv_avframe_size = sizeof(AVFrame); + #if FF_API_COLORSPACE_NAME const char *av_get_colorspace_name(enum AVColorSpace val) { diff --git a/libavutil/frame_internal.h b/libavutil/frame_internal.h new file mode 100644 index 00..07c246f86a --- /dev/null +++ b/libavutil/frame_internal.h @@ -0,0 +1,33 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_FRAME_INTERNAL_H +#define AVUTIL_FRAME_INTERNAL_H + +#include + +#include "frame.h" + +/** + * sizeof(AVFrame). If you think you need to use it, then you need to change + * your code so you don't instead. + * Meant for exceptions like wrapped_avframe. + */ +extern const size_t avpriv_avframe_size; + +#endif /* AVUTIL_FRAME_INTERNAL_H */ -- 2.35.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 2/4] avcodec/wrapped_avframe: don't allocate an AVFrame twice
Signed-off-by: James Almer --- libavcodec/wrapped_avframe.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c index a7834b86e8..004bd5e0e7 100644 --- a/libavcodec/wrapped_avframe.c +++ b/libavcodec/wrapped_avframe.c @@ -43,33 +43,32 @@ static void wrapped_avframe_release_buffer(void *unused, uint8_t *data) static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { -AVFrame *wrapped = av_frame_clone(frame); uint8_t *data; -int size = sizeof(*wrapped) + AV_INPUT_BUFFER_PADDING_SIZE; - -if (!wrapped) -return AVERROR(ENOMEM); +int ret, size = sizeof(*frame) + AV_INPUT_BUFFER_PADDING_SIZE; data = av_mallocz(size); if (!data) { -av_frame_free(&wrapped); return AVERROR(ENOMEM); } +// Set frame defaults +av_frame_unref((AVFrame *)data); pkt->buf = av_buffer_create(data, size, wrapped_avframe_release_buffer, NULL, AV_BUFFER_FLAG_READONLY); if (!pkt->buf) { -av_frame_free(&wrapped); av_freep(&data); return AVERROR(ENOMEM); } -av_frame_move_ref((AVFrame*)data, wrapped); -av_frame_free(&wrapped); +ret = av_frame_ref((AVFrame*)data, frame); +if (ret < 0) { +av_buffer_unref(&pkt->buf); +return ret; +} pkt->data = data; -pkt->size = sizeof(*wrapped); +pkt->size = sizeof(*frame); pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; -- 2.35.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 3/4] avcodec/wrapped_avframe: stop hardcoding sizeof(AVFrame)
Use instead the new internal avpriv_avframe_size constant. This will ensure the actual size of AVFrame from the libavutil loaded at runtime is used instead. Signed-off-by: James Almer --- libavcodec/wrapped_avframe.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c index 004bd5e0e7..543d9f85eb 100644 --- a/libavcodec/wrapped_avframe.c +++ b/libavcodec/wrapped_avframe.c @@ -30,6 +30,7 @@ #include "libavutil/internal.h" #include "libavutil/frame.h" +#include "libavutil/frame_internal.h" #include "libavutil/buffer.h" #include "libavutil/pixdesc.h" @@ -44,7 +45,8 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { uint8_t *data; -int ret, size = sizeof(*frame) + AV_INPUT_BUFFER_PADDING_SIZE; +const size_t size = avpriv_avframe_size; +int ret; data = av_mallocz(size); if (!data) { @@ -53,7 +55,7 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt, // Set frame defaults av_frame_unref((AVFrame *)data); -pkt->buf = av_buffer_create(data, size, +pkt->buf = av_buffer_create(data, size + AV_INPUT_BUFFER_PADDING_SIZE, wrapped_avframe_release_buffer, NULL, AV_BUFFER_FLAG_READONLY); if (!pkt->buf) { @@ -68,7 +70,7 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, AVPacket *pkt, } pkt->data = data; -pkt->size = sizeof(*frame); +pkt->size = size; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -86,7 +88,7 @@ static int wrapped_avframe_decode(AVCodecContext *avctx, void *data, return AVERROR(EPERM); } -if (pkt->size < sizeof(AVFrame)) +if (pkt->size < avpriv_avframe_size) return AVERROR(EINVAL); in = (AVFrame*)pkt->data; -- 2.35.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 4/4] avformat/vapoursynth: stop hardcoding sizeof(AVFrame)
Use instead the new internal avpriv_avframe_size constant. This will ensure the actual size of AVFrame from the libavutil loaded at runtime is used instead. Also add the missing padding bytes required by the AVPacket API while at it. Signed-off-by: James Almer --- libavformat/vapoursynth.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/vapoursynth.c b/libavformat/vapoursynth.c index 1578a6ac77..5c57f3a71c 100644 --- a/libavformat/vapoursynth.c +++ b/libavformat/vapoursynth.c @@ -31,6 +31,7 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" +#include "libavutil/frame_internal.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -344,6 +345,7 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) const AVPixFmtDescriptor *desc; AVBufferRef *vsframe_ref = NULL; struct vsframe_ref_data *ref_data; +const size_t size = avpriv_avframe_size; int err = 0; int i; @@ -382,11 +384,13 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) props = vs->vsapi->getFramePropsRO(vsframe); -frame = av_frame_alloc(); +frame = (AVFrame *)av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!frame) { err = AVERROR(ENOMEM); goto end; } +// Set frame defaults +av_frame_unref(frame); frame->format = st->codecpar->format; frame->width= st->codecpar->width; @@ -432,8 +436,8 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) frame->buf[i]->size = frame->linesize[i] * plane_h; } -pkt->buf = av_buffer_create((uint8_t*)frame, sizeof(*frame), -free_frame, NULL, 0); +pkt->buf = av_buffer_create((uint8_t*)frame, size + AV_INPUT_BUFFER_PADDING_SIZE, +free_frame, NULL, AV_BUFFER_FLAG_READONLY); if (!pkt->buf) { err = AVERROR(ENOMEM); goto end; @@ -442,7 +446,7 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) frame = NULL; // pkt owns it now pkt->data = pkt->buf->data; -pkt->size = pkt->buf->size; +pkt->size = size; pkt->flags |= AV_PKT_FLAG_TRUSTED; if (vs->is_cfr) -- 2.35.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 v3 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility
On Fri, Feb 11, 2022 at 10:05:19PM +0100, Marton Balint wrote: > > > On Sat, 5 Feb 2022, lance.lmw...@gmail.com wrote: > > > From: Limin Wang > > > > Suggested by zhilizhao, vlc project has solved the compatibility by > > the same way, so I borrowed the comments from vlc project. > > > > Fix #ticket9449 > > > > Signed-off-by: Limin Wang > > --- > > libavformat/udp.c | 15 +-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/libavformat/udp.c b/libavformat/udp.c > > index 8178d0e..1871acf 100644 > > --- a/libavformat/udp.c > > +++ b/libavformat/udp.c > > @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int > > mcastTTL, > > { > > int protocol, cmd; > > > > +/* There is some confusion in the world whether IP_MULTICAST_TTL > > + * takes a byte or an int as an argument. > > + * BSD seems to indicate byte so we are going with that and use > > + * int and fall back to byte to be safe */ > > switch (addr->sa_family) { > > #ifdef IP_MULTICAST_TTL > > case AF_INET: > > @@ -182,8 +186,15 @@ static int udp_set_multicast_ttl(int sockfd, int > > mcastTTL, > > } > > > > if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) > > { > > -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 > > MULTICAST TTL)"); > > -return ff_neterrno(); > > +/* BSD compatibility */ > > +unsigned char ttl; > > + > > +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 > > MULTICAST TTL)"); > > +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL); > > I guess this limit check here is no longer needed after the range checking > patches, so just remove. Otherwise LGTM. Yes, I have replied to Chad Fraleigh in another email and have removed the check already. > > Thanks, > Marton > > > +if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) { > > +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV4/IPV6 > > MULTICAST TTL)"); > > +return ff_neterrno(); > > +} > > } > > > > return 0; > > -- > > 1.8.3.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 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". -- Thanks, Limin Wang ___ 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] [RFC][PATCH 1/4] avutil/frame: add an internal field to store the size of AVFrame
James Almer: > This is unfortunately needed to remove (or reduce the awfulness) of certain > modules violating the AVFrame API and using sizeof(AVFrame). > With this, the sizeof(AVFrame) value of the libavutil loaded at runtime can be > used instead of the compile time value of whatever library included frame.h > > Signed-off-by: James Almer > --- > This is sucks, but at least less so than the current situation. > > I don't see wrapped_avframe going away anytime soon, so something must be > done, > and last time i tried to change how the packets are generated my approach was > shut down, so here's another attempt. > > libavutil/frame.c | 3 +++ > libavutil/frame_internal.h | 33 + > 2 files changed, 36 insertions(+) > create mode 100644 libavutil/frame_internal.h > > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 8997c85e35..a63d2979db 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -23,6 +23,7 @@ > #include "cpu.h" > #include "dict.h" > #include "frame.h" > +#include "frame_internal.h" > #include "imgutils.h" > #include "mem.h" > #include "samplefmt.h" > @@ -33,6 +34,8 @@ > (frame)->channels == \ > av_get_channel_layout_nb_channels((frame)->channel_layout)) > > +const size_t avpriv_avframe_size = sizeof(AVFrame); > + > #if FF_API_COLORSPACE_NAME > const char *av_get_colorspace_name(enum AVColorSpace val) > { > diff --git a/libavutil/frame_internal.h b/libavutil/frame_internal.h > new file mode 100644 > index 00..07c246f86a > --- /dev/null > +++ b/libavutil/frame_internal.h > @@ -0,0 +1,33 @@ > +/* > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#ifndef AVUTIL_FRAME_INTERNAL_H > +#define AVUTIL_FRAME_INTERNAL_H > + > +#include size_t is in stddef.h and some other headers, but not in stdint.h. > + > +#include "frame.h" > + > +/** > + * sizeof(AVFrame). If you think you need to use it, then you need to change > + * your code so you don't instead. > + * Meant for exceptions like wrapped_avframe. > + */ > +extern const size_t avpriv_avframe_size; > + > +#endif /* AVUTIL_FRAME_INTERNAL_H */ Missing av_export_avutil. (And aren't there systems where exporting data is always problematic?) - Andreas ___ 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 01/17] avcodec/svq3: Mark decoder as init-threadsafe
The only interesting thing done in SVQ3's init function is using zlib, but this is fine: https://zlib.net/zlib_faq.html#faq21 Signed-off-by: Andreas Rheinhardt --- libavcodec/svq3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index be95e222aa..da61617f4e 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -1601,5 +1601,5 @@ const AVCodec ff_svq3_decoder = { AV_CODEC_CAP_DELAY, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE}, -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; -- 2.32.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 02/17] avcodec/amrnbdec: Mark decoder as init-threadsafe
It performs no initialization of static data during its init function. Signed-off-by: Andreas Rheinhardt --- libavcodec/amrnbdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index d8e0370a3b..1e11445cd3 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -1107,4 +1107,5 @@ const AVCodec ff_amrnb_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; -- 2.32.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 03/17] avcodec/amrwbdec: Mark decoder as init-threadsafe
It performs no initialization of static data in its init function. Signed-off-by: Andreas Rheinhardt --- libavcodec/amrwbdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 3ff4077f7f..7d1b820bbb 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -1303,4 +1303,5 @@ const AVCodec ff_amrwb_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .sample_fmts= (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; -- 2.32.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 04/17] avcodec/rv30: Mark decoder as init-threadsafe
Init-threadsafe since f697622f687c22392194d6939914c9a6a01ce69e. Signed-off-by: Andreas Rheinhardt --- libavcodec/rv30.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 751647bebe..bd4d43aeeb 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -306,5 +306,6 @@ const AVCodec ff_rv30_decoder = { AV_PIX_FMT_NONE }, .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context), -.caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_ALLOCATE_PROGRESS, }; -- 2.32.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 05/17] avcodec/rv40: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt --- libavcodec/rv40.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 31a7a04e51..8f7589242d 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -27,6 +27,7 @@ #include "config.h" #include "libavutil/imgutils.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "mpegutils.h" @@ -553,14 +554,13 @@ static void rv40_loop_filter(RV34DecContext *r, int row) */ static av_cold int rv40_decode_init(AVCodecContext *avctx) { +static AVOnce init_static_once = AV_ONCE_INIT; RV34DecContext *r = avctx->priv_data; int ret; r->rv30 = 0; if ((ret = ff_rv34_decode_init(avctx)) < 0) return ret; -if(!aic_top_vlc.bits) -rv40_init_tables(); r->parse_slice_header = rv40_parse_slice_header; r->decode_intra_types = rv40_decode_intra_types; r->decode_mb_info = rv40_decode_mb_info; @@ -568,6 +568,7 @@ static av_cold int rv40_decode_init(AVCodecContext *avctx) r->luma_dc_quant_i = rv40_luma_dc_quant[0]; r->luma_dc_quant_p = rv40_luma_dc_quant[1]; ff_rv40dsp_init(&r->rdsp); +ff_thread_once(&init_static_once, rv40_init_tables); return 0; } @@ -588,5 +589,6 @@ const AVCodec ff_rv40_decoder = { AV_PIX_FMT_NONE }, .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context), -.caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_ALLOCATE_PROGRESS, }; -- 2.32.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 06/17] avcodec/apedec: Mark decoder as init-threadsafe
Signed-off-by: Andreas Rheinhardt --- libavcodec/apedec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 607304fe36..923f79046b 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1666,7 +1666,7 @@ const AVCodec ff_ape_decoder = { .decode = ape_decode_frame, .capabilities = AV_CODEC_CAP_SUBFRAMES | 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, .flush = ape_flush, .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, -- 2.32.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 09/17] avcodec/alsdec, mlz: Check allocation
Signed-off-by: Andreas Rheinhardt --- libavcodec/alsdec.c | 4 +++- libavcodec/mlz.c| 7 ++- libavcodec/mlz.h| 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index c09401d257..029c37e99c 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -2111,7 +2111,9 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } -ff_mlz_init_dict(avctx, ctx->mlz); +ret = ff_mlz_init_dict(avctx, ctx->mlz); +if (ret < 0) +return ret; ff_mlz_flush_dict(ctx->mlz); for (c = 0; c < avctx->channels; ++c) { diff --git a/libavcodec/mlz.c b/libavcodec/mlz.c index dbeb7dcad9..9087ffd8f0 100644 --- a/libavcodec/mlz.c +++ b/libavcodec/mlz.c @@ -20,8 +20,11 @@ #include "mlz.h" -av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) { +av_cold int ff_mlz_init_dict(void *context, MLZ *mlz) +{ mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict)); +if (!mlz->dict) +return AVERROR(ENOMEM); mlz->flush_code= FLUSH_CODE; mlz->current_dic_index_max = DIC_INDEX_INIT; @@ -30,6 +33,8 @@ av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) { mlz->next_code = FIRST_CODE; mlz->freeze_flag = 0; mlz->context = context; + +return 0; } av_cold void ff_mlz_flush_dict(MLZ *mlz) { diff --git a/libavcodec/mlz.h b/libavcodec/mlz.h index c3df52c9b4..24993126ca 100644 --- a/libavcodec/mlz.h +++ b/libavcodec/mlz.h @@ -57,7 +57,7 @@ typedef struct MLZ { /** Initialize the dictionary */ -void ff_mlz_init_dict(void* context, MLZ *mlz); +int ff_mlz_init_dict(void *context, MLZ *mlz); /** Flush the dictionary */ -- 2.32.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 10/17] avcodec/alsdec: Mark decoder as init-threadsafe
It does not initialize any static data in its init function. Signed-off-by: Andreas Rheinhardt --- libavcodec/alsdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 029c37e99c..b9629fc3d2 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -2177,5 +2177,5 @@ const AVCodec ff_als_decoder = { .decode = decode_frame, .flush = flush, .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; -- 2.32.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 11/17] avcodec/ituh263dec: Make initializing VLCs thread-safe
This automatically makes the FLV, H.263, H.263+, Intel H.263, MPEG-4, RealVideo 1.0 and RealVideo 2.0 decoders init-threadsafe. Signed-off-by: Andreas Rheinhardt --- libavcodec/flvdec.c| 3 ++- libavcodec/h263dec.c | 6 -- libavcodec/intelh263dec.c | 3 ++- libavcodec/ituh263dec.c| 15 --- libavcodec/mpeg4videodec.c | 3 ++- libavcodec/rv10.c | 2 ++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 2bd86b5b47..587cbb3ca5 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -122,7 +122,8 @@ const AVCodec ff_flv_decoder = { .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .max_lowres = 3, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 3466027286..27f9c2932c 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -772,7 +772,8 @@ const AVCodec ff_h263_decoder = { AV_CODEC_CAP_TRUNCATED | #endif AV_CODEC_CAP_DELAY, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, @@ -793,7 +794,8 @@ const AVCodec ff_h263p_decoder = { AV_CODEC_CAP_TRUNCATED | #endif AV_CODEC_CAP_DELAY, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .flush = ff_mpeg_flush, .max_lowres = 3, .pix_fmts = ff_h263_hwaccel_pixfmt_list_420, diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 9dde247298..b0009f00d7 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -138,7 +138,8 @@ const AVCodec ff_h263i_decoder = { .close = ff_h263_decode_end, .decode = ff_h263_decode_frame, .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 445d5f3f36..6fa5249569 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -35,6 +35,7 @@ #include "libavutil/internal.h" #include "libavutil/mathematics.h" #include "libavutil/mem_internal.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "mpegvideo.h" #include "h263.h" @@ -104,12 +105,8 @@ static VLC cbpc_b_vlc; /* init vlcs */ -/* XXX: find a better solution to handle static init */ -av_cold void ff_h263_decode_init_vlc(void) +static av_cold void h263_decode_init_vlc(void) { -static volatile int done = 0; - -if (!done) { INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, ff_h263_intra_MCBPC_bits, 1, 1, ff_h263_intra_MCBPC_code, 1, 1, 72); @@ -131,8 +128,12 @@ av_cold void ff_h263_decode_init_vlc(void) INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4, &ff_cbpc_b_tab[0][1], 2, 1, &ff_cbpc_b_tab[0][0], 2, 1, 8); -done = 1; -} +} + +av_cold void ff_h263_decode_init_vlc(void) +{ +static AVOnce init_static_once = AV_ONCE_INIT; +ff_thread_once(&init_static_once, h263_decode_init_vlc); } int ff_h263_decode_mba(MpegEncContext *s) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 655be5697d..432d3c418c 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3672,7 +3672,8 @@ const AVCodec ff_mpeg4_decoder = { AV_CODEC_CAP_TRUNCATED | #endif AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS, -.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_ALLOCATE_PROGRESS, .flush = ff_mpeg_flush, .max_lowres= 3, diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 4dfaa3460d..34f9dbf80a 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -690,6 +
[FFmpeg-devel] [PATCH 12/17] avcodec/ituh263dec: Reindent after the last commit
Signed-off-by: Andreas Rheinhardt --- libavcodec/ituh263dec.c | 42 - 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 6fa5249569..c141888003 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -107,27 +107,27 @@ static VLC cbpc_b_vlc; static av_cold void h263_decode_init_vlc(void) { -INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, - ff_h263_intra_MCBPC_bits, 1, 1, - ff_h263_intra_MCBPC_code, 1, 1, 72); -INIT_VLC_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28, - ff_h263_inter_MCBPC_bits, 1, 1, - ff_h263_inter_MCBPC_code, 1, 1, 198); -INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16, - &ff_h263_cbpy_tab[0][1], 2, 1, - &ff_h263_cbpy_tab[0][0], 2, 1, 64); -INIT_VLC_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33, - &ff_mvtab[0][1], 2, 1, - &ff_mvtab[0][0], 2, 1, 538); -ff_h263_init_rl_inter(); -INIT_VLC_RL(ff_h263_rl_inter, 554); -INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554); -INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15, - &ff_h263_mbtype_b_tab[0][1], 2, 1, - &ff_h263_mbtype_b_tab[0][0], 2, 1, 80); -INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4, - &ff_cbpc_b_tab[0][1], 2, 1, - &ff_cbpc_b_tab[0][0], 2, 1, 8); +INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, +ff_h263_intra_MCBPC_bits, 1, 1, +ff_h263_intra_MCBPC_code, 1, 1, 72); +INIT_VLC_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28, +ff_h263_inter_MCBPC_bits, 1, 1, +ff_h263_inter_MCBPC_code, 1, 1, 198); +INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16, +&ff_h263_cbpy_tab[0][1], 2, 1, +&ff_h263_cbpy_tab[0][0], 2, 1, 64); +INIT_VLC_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33, +&ff_mvtab[0][1], 2, 1, +&ff_mvtab[0][0], 2, 1, 538); +ff_h263_init_rl_inter(); +INIT_VLC_RL(ff_h263_rl_inter, 554); +INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554); +INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15, +&ff_h263_mbtype_b_tab[0][1], 2, 1, +&ff_h263_mbtype_b_tab[0][0], 2, 1, 80); +INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4, +&ff_cbpc_b_tab[0][1], 2, 1, +&ff_cbpc_b_tab[0][0], 2, 1, 8); } av_cold void ff_h263_decode_init_vlc(void) -- 2.32.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 13/17] avcodec/exr: Mark decoder as init-threadsafe
This decoder does not initialize any static data in its init function. Signed-off-by: Andreas Rheinhardt --- libavcodec/exr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 8b04fab951..fc32ef1dde 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -2351,5 +2351,6 @@ const AVCodec ff_exr_decoder = { .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, +.caps_internal= FF_CODEC_CAP_INIT_THREADSAFE, .priv_class = &exr_class, }; -- 2.32.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 14/17] avcodec/vorbisdec: Mark decoder as init-threadsafe
It does not modify any static data in its init function. Signed-off-by: Andreas Rheinhardt --- libavcodec/vorbisdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 6e07bc5a8a..be4ac055e0 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1891,7 +1891,7 @@ const AVCodec ff_vorbis_decoder = { .decode = vorbis_decode_frame, .flush = vorbis_decode_flush, .capabilities= AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .channel_layouts = ff_vorbis_channel_layouts, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, -- 2.32.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 15/17] avcodec/avcodec: Decrease the amount of time while holding the lock
Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 4df834c708..92639dda6b 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -169,8 +169,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) return AVERROR(EINVAL); -lock_avcodec(codec); - avci = av_mallocz(sizeof(*avci)); if (!avci) { ret = AVERROR(ENOMEM); @@ -301,16 +299,17 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n"); if (CONFIG_FRAME_THREAD_ENCODER && av_codec_is_encoder(avctx->codec)) { -unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem ret = ff_frame_thread_encoder_init(avctx); -lock_avcodec(codec); if (ret < 0) goto free_and_end; } if (HAVE_THREADS && !(avci->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) { +/* Frame-threaded decoders call AVCodec.init for their child contexts. */ +lock_avcodec(codec); ret = ff_thread_init(avctx); +unlock_avcodec(codec); if (ret < 0) { goto free_and_end; } @@ -321,7 +320,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (!(avctx->active_thread_type & FF_THREAD_FRAME) || avci->frame_thread_encoder) { if (avctx->codec->init) { +lock_avcodec(codec); ret = avctx->codec->init(avctx); +unlock_avcodec(codec); if (ret < 0) { avci->needs_close = avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP; goto free_and_end; @@ -369,7 +370,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class); end: -unlock_avcodec(codec); return ret; free_and_end: -- 2.32.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 16/17] avcodec/msmpeg4dec: Make initializing VLCs thread-safe
This automatically makes the remaining mpegvideo-decoders (namely msmpeg4v[1-3], mss2, VC-1, VC-1 Image, WMV-[1-3] and WMV-3 Image) init-threadsafe. These were the last native codecs that were not init-threadsafe; only wrappers for external libraries and for hardware accelerations are now not init-threadsafe. Signed-off-by: Andreas Rheinhardt --- The above is based around the assumption that my other patches marking the VP56 and 8bps decoders as init-threadsafe are already applied. Here is an incomplete list of non-native codecs that are not init-threadsafe yet even after all these patches have been applied (this list is incomplete because it only contains codecs that I include in a fairly, but not completely extensive build of mine; the threading flags stand for frame-slice-other; if all frame-threaded decoders were init-threadsafe, one could avoid locking around ff_thread_init() in avcodec_open2(). This only affects libopenjpeg and I guess that it is init-threadsafe (as are probably most of the following entries): Encoder libaom-av1 is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Encoder libcodec2 is not init-threadsafe yet. Encoder libfdk_aac is not init-threadsafe yet. Encoder libgsm is not init-threadsafe yet. Encoder libgsm_ms is not init-threadsafe yet. Encoder libilbc is not init-threadsafe yet. Encoder libmp3lame is not init-threadsafe yet. Encoder libopencore_amrnb is not init-threadsafe yet. Encoder libopenjpeg is not init-threadsafe yet. Codec supports threading: 1, 0, 0 Encoder libopus is not init-threadsafe yet. Encoder libshine is not init-threadsafe yet. Encoder libspeex is not init-threadsafe yet. Encoder libtheora is not init-threadsafe yet. Encoder libtwolame is not init-threadsafe yet. Encoder libvorbis is not init-threadsafe yet. Encoder libvpx is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Encoder libvpx-vp9 is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Encoder libwebp_anim is not init-threadsafe yet. Encoder libwebp is not init-threadsafe yet. Encoder libx265 is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Encoder libxavs is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Encoder libxavs2 is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Encoder h263_v4l2m2m is not init-threadsafe yet. Encoder h264_nvenc is not init-threadsafe yet. Encoder h264_qsv is not init-threadsafe yet. Encoder h264_v4l2m2m is not init-threadsafe yet. Encoder h264_vaapi is not init-threadsafe yet. Encoder hevc_nvenc is not init-threadsafe yet. Encoder hevc_qsv is not init-threadsafe yet. Encoder hevc_v4l2m2m is not init-threadsafe yet. Encoder hevc_vaapi is not init-threadsafe yet. Encoder mjpeg_qsv is not init-threadsafe yet. Encoder mjpeg_vaapi is not init-threadsafe yet. Encoder mpeg2_qsv is not init-threadsafe yet. Encoder mpeg2_vaapi is not init-threadsafe yet. Encoder mpeg4_v4l2m2m is not init-threadsafe yet. Encoder vp8_v4l2m2m is not init-threadsafe yet. Encoder vp8_vaapi is not init-threadsafe yet. Encoder vp9_vaapi is not init-threadsafe yet. Encoder vp9_qsv is not init-threadsafe yet. Decoder h263_v4l2m2m is not init-threadsafe yet. Decoder h264_crystalhd is not init-threadsafe yet. Decoder h264_v4l2m2m is not init-threadsafe yet. Decoder h264_qsv is not init-threadsafe yet. Decoder h264_rkmpp is not init-threadsafe yet. Decoder hevc_qsv is not init-threadsafe yet. Decoder hevc_rkmpp is not init-threadsafe yet. Decoder hevc_v4l2m2m is not init-threadsafe yet. Decoder mpeg4_crystalhd is not init-threadsafe yet. Decoder mpeg4_v4l2m2m is not init-threadsafe yet. Decoder mpeg1_v4l2m2m is not init-threadsafe yet. Decoder mpeg2_crystalhd is not init-threadsafe yet. Decoder mpeg2_v4l2m2m is not init-threadsafe yet. Decoder mpeg2_qsv is not init-threadsafe yet. Decoder msmpeg4_crystalhd is not init-threadsafe yet. Decoder vc1_crystalhd is not init-threadsafe yet. Decoder vc1_qsv is not init-threadsafe yet. Decoder vc1_v4l2m2m is not init-threadsafe yet. Decoder vp8_rkmpp is not init-threadsafe yet. Decoder vp8_v4l2m2m is not init-threadsafe yet. Decoder vp9_rkmpp is not init-threadsafe yet. Decoder vp9_v4l2m2m is not init-threadsafe yet. Decoder wmv3_crystalhd is not init-threadsafe yet. Decoder libaribb24 is not init-threadsafe yet. Decoder libcelt is not init-threadsafe yet. Decoder libcodec2 is not init-threadsafe yet. Decoder libdavs2 is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Decoder libgsm is not init-threadsafe yet. Decoder libgsm_ms is not init-threadsafe yet. Decoder libilbc is not init-threadsafe yet. Decoder libopencore_amrnb is not init-threadsafe yet. Decoder libopencore_amrwb is not init-threadsafe yet. Decoder libopenjpeg is not init-threadsafe yet. Codec supports threading: 1, 0, 0 Decoder libopus is not init-threadsafe yet. Decoder libspeex is not init-threadsafe yet. Decoder libuavs3d is not init-threadsafe yet. Codec supports threading: 0, 0, 1 Decoder libvorbis is not init-threadsafe ye
[FFmpeg-devel] [PATCH 17/17] avcodec/msmpeg4dec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt --- libavcodec/msmpeg4dec.c | 114 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index ba72c7ee50..ac7c7d75e2 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -298,70 +298,70 @@ static av_cold void msmpeg4_decode_init_static(void) { MVTable *mv; -INIT_FIRST_VLC_RL(ff_rl_table[0], 642); -INIT_FIRST_VLC_RL(ff_rl_table[1], 1104); -INIT_FIRST_VLC_RL(ff_rl_table[2], 554); -INIT_VLC_RL(ff_rl_table[3], 940); -INIT_VLC_RL(ff_rl_table[4], 962); -/* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been - * initialized in ff_h263_decode_init() above. So just copy the VLCs. */ -av_assert1(ff_h263_rl_inter.rl_vlc[0]); -memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc)); - -mv = &ff_mv_tables[0]; -INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1, +INIT_FIRST_VLC_RL(ff_rl_table[0], 642); +INIT_FIRST_VLC_RL(ff_rl_table[1], 1104); +INIT_FIRST_VLC_RL(ff_rl_table[2], 554); +INIT_VLC_RL(ff_rl_table[3], 940); +INIT_VLC_RL(ff_rl_table[4], 962); +/* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been +* initialized in ff_h263_decode_init() above. So just copy the VLCs. */ +av_assert1(ff_h263_rl_inter.rl_vlc[0]); +memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc)); + +mv = &ff_mv_tables[0]; +INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1, mv->table_mv_bits, 1, 1, mv->table_mv_code, 2, 2, 3714); -mv = &ff_mv_tables[1]; -INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1, +mv = &ff_mv_tables[1]; +INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, MSMPEG4_MV_TABLES_NB_ELEMS + 1, mv->table_mv_bits, 1, 1, mv->table_mv_code, 2, 2, 2694); -INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120, - &ff_table0_dc_lum[0][1], 8, 4, - &ff_table0_dc_lum[0][0], 8, 4, 1158); -INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120, - &ff_table0_dc_chroma[0][1], 8, 4, - &ff_table0_dc_chroma[0][0], 8, 4, 1118); -INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120, - &ff_table1_dc_lum[0][1], 8, 4, - &ff_table1_dc_lum[0][0], 8, 4, 1476); -INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120, - &ff_table1_dc_chroma[0][1], 8, 4, - &ff_table1_dc_chroma[0][0], 8, 4, 1216); - -INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512, - &ff_v2_dc_lum_table[0][1], 8, 4, - &ff_v2_dc_lum_table[0][0], 8, 4, 1472); -INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512, - &ff_v2_dc_chroma_table[0][1], 8, 4, - &ff_v2_dc_chroma_table[0][0], 8, 4, 1506); - -INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4, - &ff_v2_intra_cbpc[0][1], 2, 1, - &ff_v2_intra_cbpc[0][0], 2, 1, 8); -INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8, - &ff_v2_mb_type[0][1], 2, 1, - &ff_v2_mb_type[0][0], 2, 1, 128); - -for (unsigned i = 0, offset = 0; i < 4; i++) { -static VLC_TYPE vlc_buf[1636 + 2648 + 1532 + 2488][2]; -ff_mb_non_intra_vlc[i].table = &vlc_buf[offset]; -ff_mb_non_intra_vlc[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset; -init_vlc(&ff_mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128, - &ff_wmv2_inter_table[i][0][1], 8, 4, - &ff_wmv2_inter_table[i][0][0], 8, 4, - INIT_VLC_STATIC_OVERLONG); -offset += ff_mb_non_intra_vlc[i].table_size; -} +INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120, +&ff_table0_dc_lum[0][1], 8, 4, +&ff_table0_dc_lum[0][0], 8, 4, 1158); +INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120, +&ff_table0_dc_chroma[0][1], 8, 4, +&ff_table0_dc_chroma[0][0], 8, 4, 1118); +INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120, +&ff_table1_dc_lum[0][1], 8, 4, +&ff_table1_dc_lum[0][0], 8, 4, 1476); +INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120, +&ff_table1_dc_chroma[0][1], 8, 4, +&ff_table1_dc_chroma[0][0], 8, 4, 1216); + +INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512, +&ff_v2_dc_lum_table[0][1], 8, 4, +&ff_v2_dc_lum_table[0][0], 8, 4, 1472); +
[FFmpeg-devel] [PATCH 07/17] avcodec/alsdec: Return directly upon error
Signed-off-by: Andreas Rheinhardt --- libavcodec/alsdec.c | 30 ++ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 9e1aaf065a..f8609e61fd 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -1990,17 +1990,17 @@ static av_cold int decode_init(AVCodecContext *avctx) if ((ret = read_specific_config(ctx)) < 0) { av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n"); -goto fail; +return ret; } if ((ret = check_specific_config(ctx)) < 0) { -goto fail; +return ret; } if (sconf->bgmc) { ret = ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status); if (ret < 0) -goto fail; +return ret; } if (sconf->floating) { avctx->sample_fmt = AV_SAMPLE_FMT_FLT; @@ -2012,8 +2012,7 @@ static av_cold int decode_init(AVCodecContext *avctx) if (avctx->bits_per_raw_sample > 32) { av_log(avctx, AV_LOG_ERROR, "Bits per raw sample %d larger than 32.\n", avctx->bits_per_raw_sample); -ret = AVERROR_INVALIDDATA; -goto fail; +return AVERROR_INVALIDDATA; } } @@ -2044,8 +2043,7 @@ static av_cold int decode_init(AVCodecContext *avctx) !ctx->quant_cof_buffer || !ctx->lpc_cof_buffer || !ctx->lpc_cof_reversed_buffer) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); -ret = AVERROR(ENOMEM); -goto fail; +return AVERROR(ENOMEM); } // assign quantized parcor coefficient buffers @@ -2069,8 +2067,7 @@ static av_cold int decode_init(AVCodecContext *avctx) !ctx->use_ltp || !ctx->ltp_lag || !ctx->ltp_gain || !ctx->ltp_gain_buffer) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); -ret = AVERROR(ENOMEM); -goto fail; +return AVERROR(ENOMEM); } for (c = 0; c < num_buffers; c++) @@ -2086,8 +2083,7 @@ static av_cold int decode_init(AVCodecContext *avctx) if (!ctx->chan_data_buffer || !ctx->chan_data || !ctx->reverted_channels) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); -ret = AVERROR(ENOMEM); -goto fail; +return AVERROR(ENOMEM); } for (c = 0; c < num_buffers; c++) @@ -2118,8 +2114,7 @@ static av_cold int decode_init(AVCodecContext *avctx) if (!ctx->mlz || !ctx->acf || !ctx->shift_value || !ctx->last_shift_value || !ctx->last_acf_mantissa || !ctx->raw_mantissa) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); -ret = AVERROR(ENOMEM); -goto fail; +return AVERROR(ENOMEM); } ff_mlz_init_dict(avctx, ctx->mlz); @@ -2133,8 +2128,7 @@ static av_cold int decode_init(AVCodecContext *avctx) // allocate previous raw sample buffer if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); -ret = AVERROR(ENOMEM); -goto fail; +return AVERROR(ENOMEM); } // assign raw samples buffers @@ -2151,17 +2145,13 @@ static av_cold int decode_init(AVCodecContext *avctx) sizeof(*ctx->crc_buffer)); if (!ctx->crc_buffer) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); -ret = AVERROR(ENOMEM); -goto fail; +return AVERROR(ENOMEM); } } ff_bswapdsp_init(&ctx->bdsp); return 0; - -fail: -return ret; } -- 2.32.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 08/17] avcodec/alsdec: Improve code locality
Signed-off-by: Andreas Rheinhardt --- libavcodec/alsdec.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index f8609e61fd..c09401d257 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -2094,12 +2094,6 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->reverted_channels = NULL; } -channel_size = sconf->frame_length + sconf->max_order; - -ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples)); -ctx->raw_buffer = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer)); -ctx->raw_samples = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples)); - if (sconf->floating) { ctx->acf = av_malloc_array(avctx->channels, sizeof(*ctx->acf)); ctx->shift_value = av_malloc_array(avctx->channels, sizeof(*ctx->shift_value)); @@ -2125,7 +2119,12 @@ static av_cold int decode_init(AVCodecContext *avctx) } } +channel_size = sconf->frame_length + sconf->max_order; + // allocate previous raw sample buffer +ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples)); +ctx->raw_buffer = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer)); +ctx->raw_samples = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples)); if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); return AVERROR(ENOMEM); -- 2.32.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".
Re: [FFmpeg-devel] [RFC][PATCH 1/4] avutil/frame: add an internal field to store the size of AVFrame
James Almer: > This is unfortunately needed to remove (or reduce the awfulness) of certain > modules violating the AVFrame API and using sizeof(AVFrame). > With this, the sizeof(AVFrame) value of the libavutil loaded at runtime can be > used instead of the compile time value of whatever library included frame.h > > Signed-off-by: James Almer > --- > This is sucks, but at least less so than the current situation. > > I don't see wrapped_avframe going away anytime soon, so something must be > done, > and last time i tried to change how the packets are generated my approach was > shut down, so here's another attempt. > Where can I find this earlier approach? (Also why don't we just switch to something like what is done for uncoded frames in libavformat/mux.c?) > libavutil/frame.c | 3 +++ > libavutil/frame_internal.h | 33 + > 2 files changed, 36 insertions(+) > create mode 100644 libavutil/frame_internal.h > > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 8997c85e35..a63d2979db 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -23,6 +23,7 @@ > #include "cpu.h" > #include "dict.h" > #include "frame.h" > +#include "frame_internal.h" > #include "imgutils.h" > #include "mem.h" > #include "samplefmt.h" > @@ -33,6 +34,8 @@ > (frame)->channels == \ > av_get_channel_layout_nb_channels((frame)->channel_layout)) > > +const size_t avpriv_avframe_size = sizeof(AVFrame); > + > #if FF_API_COLORSPACE_NAME > const char *av_get_colorspace_name(enum AVColorSpace val) > { > diff --git a/libavutil/frame_internal.h b/libavutil/frame_internal.h > new file mode 100644 > index 00..07c246f86a > --- /dev/null > +++ b/libavutil/frame_internal.h > @@ -0,0 +1,33 @@ > +/* > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#ifndef AVUTIL_FRAME_INTERNAL_H > +#define AVUTIL_FRAME_INTERNAL_H > + > +#include > + > +#include "frame.h" This header is completely unnecessary. > + > +/** > + * sizeof(AVFrame). If you think you need to use it, then you need to change > + * your code so you don't instead. > + * Meant for exceptions like wrapped_avframe. > + */ > +extern const size_t avpriv_avframe_size; > + > +#endif /* AVUTIL_FRAME_INTERNAL_H */ ___ 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 13/17] avcodec/exr: Mark decoder as init-threadsafe
LGTM ___ 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 03/17] avcodec/amrwbdec: Mark decoder as init-threadsafe
LGTM ___ 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 02/17] avcodec/amrnbdec: Mark decoder as init-threadsafe
LGTM ___ 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".