[FFmpeg-devel] [PATCH 2/7] avcodec/vc1dec: Postpone allocating sprite frame to avoid segfault

2020-12-25 Thread Andreas Rheinhardt
Up until now, the VC-1 decoders allocated an AVFrame for usage with
sprites during vc1_decode_init(); yet said AVFrame can be freed if
(re)initializing the context (which happens ordinarily during decoding)
fails. The AVFrame does not get allocated again lateron in this case,
leading to segfaults.

Fix this by moving the allocation of said frame immediately before it is
used (this also means that said frame won't be allocated at all any more
in case of a regular (i.e. non-image) stream).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1dec.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 7809234ff7..5cdf197da7 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -539,12 +539,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
 ff_h264chroma_init(&v->h264chroma, 8);
 ff_qpeldsp_init(&s->qdsp);
 
-// Must happen after calling ff_vc1_decode_end
-// to avoid de-allocating the sprite_output_frame
-v->sprite_output_frame = av_frame_alloc();
-if (!v->sprite_output_frame)
-return AVERROR(ENOMEM);
-
 avctx->has_b_frames = !!avctx->max_b_frames;
 
 if (v->color_prim == 1 || v->color_prim == 5 || v->color_prim == 6)
@@ -577,20 +571,15 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
 v->sprite_height > 1 << 14 ||
 v->output_width  > 1 << 14 ||
 v->output_height > 1 << 14) {
-ret = AVERROR_INVALIDDATA;
-goto error;
+return AVERROR_INVALIDDATA;
 }
 
 if ((v->sprite_width&1) || (v->sprite_height&1)) {
 avpriv_request_sample(avctx, "odd sprites support");
-ret = AVERROR_PATCHWELCOME;
-goto error;
+return AVERROR_PATCHWELCOME;
 }
 }
 return 0;
-error:
-av_frame_free(&v->sprite_output_frame);
-return ret;
 }
 
 /** Close a VC1/WMV3 decoder
@@ -1147,6 +1136,11 @@ image:
 avctx->height = avctx->coded_height = v->output_height;
 if (avctx->skip_frame >= AVDISCARD_NONREF)
 goto end;
+if (!v->sprite_output_frame &&
+!(v->sprite_output_frame = av_frame_alloc())) {
+ret = AVERROR(ENOMEM);
+goto err;
+}
 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
 if ((ret = vc1_decode_sprites(v, &s->gb)) < 0)
 goto err;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 3/7] avcodec/vc1: Don't pretend ff_vc1_init_common() can fail

2020-12-25 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mss2.c   | 3 +--
 libavcodec/vc1.c| 4 +---
 libavcodec/vc1.h| 2 +-
 libavcodec/vc1_parser.c | 3 ++-
 libavcodec/vc1dec.c | 3 +--
 5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 9434a740a7..3e3205ae92 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -751,8 +751,7 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
 
 v->s.avctx= avctx;
 
-if ((ret = ff_vc1_init_common(v)) < 0)
-return ret;
+ff_vc1_init_common(v);
 ff_vc1dsp_init(&v->vc1dsp);
 
 v->profile = PROFILE_MAIN;
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index cd9975d8cf..5d854b35d2 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -1695,7 +1695,7 @@ static av_cold void vc1_init_static(void)
  * @param v The VC1Context to initialize
  * @return Status
  */
-av_cold int ff_vc1_init_common(VC1Context *v)
+av_cold void ff_vc1_init_common(VC1Context *v)
 {
 static AVOnce init_static_once = AV_ONCE_INIT;
 
@@ -1709,6 +1709,4 @@ av_cold int ff_vc1_init_common(VC1Context *v)
 
 /* VLC tables */
 ff_thread_once(&init_static_once, vc1_init_static);
-
-return 0;
 }
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 4559a06cb6..3e5368b891 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -413,7 +413,7 @@ int ff_vc1_decode_entry_point(AVCodecContext *avctx, 
VC1Context *v, GetBitContex
 
 int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext *gb);
 int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
-int ff_vc1_init_common(VC1Context *v);
+void ff_vc1_init_common(VC1Context *v);
 
 int  ff_vc1_decode_init_alloc_tables(VC1Context *v);
 void ff_vc1_init_transposed_scantables(VC1Context *v);
diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index 493ffde611..1a9d3c0140 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -283,7 +283,8 @@ static av_cold int vc1_parse_init(AVCodecParserContext *s)
 vpc->bytes_to_skip = 0;
 vpc->unesc_index = 0;
 vpc->search_state = NO_MATCH;
-return ff_vc1_init_common(&vpc->v);
+ff_vc1_init_common(&vpc->v);
+return 0;
 }
 
 AVCodecParser ff_vc1_parser = {
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 5cdf197da7..78988b740c 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -434,8 +434,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
 return AVERROR_INVALIDDATA;
 v->s.avctx = avctx;
 
-if ((ret = ff_vc1_init_common(v)) < 0)
-return ret;
+ff_vc1_init_common(v);
 
 if (avctx->codec_id == AV_CODEC_ID_WMV3 || avctx->codec_id == 
AV_CODEC_ID_WMV3IMAGE) {
 int count = 0;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 4/7] avcodec/h261dec: Remove parse_context cruft

2020-12-25 Thread Andreas Rheinhardt
The H.261 decoder doesn't use the ParseContext of its
MpegEncContext since e7316976650b429345da619c3acff38004aaf6b8.

Signed-off-by: Andreas Rheinhardt 
---
Does actually anybody use the AV_CODEC_FLAG_TRUNCATED (MpegEncContext
contains a ParseContext because of this flag)?

 libavcodec/h261dec.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 8a49e7d894..4f1f22b279 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -613,10 +613,7 @@ retry:
 }
 
 if (s->width != avctx->coded_width || s->height != avctx->coded_height) {
-ParseContext pc = s->parse_context; // FIXME move this demuxing hack 
to libavformat
-s->parse_context.buffer = 0;
 ff_mpv_common_end(s);
-s->parse_context = pc;
 }
 
 if (!s->context_initialized) {
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 6/7] avcodec/mpegvideo: Fix memleak upon allocation error

2020-12-25 Thread Andreas Rheinhardt
When slice-threading is used, ff_mpv_common_init() duplicates
the first MpegEncContext and allocates some buffers for each
MpegEncContext (the first as well as the copies). But the count of
allocated MpegEncContexts is not updated until after everything has
been allocated and if an error happens after the first one has been
allocated, only the first one is freed; the others leak.

This commit fixes this: The count is now set before the copies are
allocated. Furthermore, the copies are now created and initialized
before the first MpegEncContext, so that the buffers exclusively owned
by each MpegEncContext are still NULL in the src MpegEncContext so
that no double-free happens upon allocation failure.

Given that this effectively touches every line of the init code,
it has also been factored out in a function of its own in order to
remove code duplication with the same code in
ff_mpv_common_frame_size_change() (which was never called when using
more than one slice (and if it were, there would be potential
double-frees)).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 89 +-
 1 file changed, 36 insertions(+), 53 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 1bf25566b8..3daccb816f 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -364,13 +364,6 @@ static int init_duplicate_context(MpegEncContext *s)
 if (s->mb_height & 1)
 yc_size += 2*s->b8_stride + 2*s->mb_stride;
 
-s->sc.edge_emu_buffer =
-s->me.scratchpad   =
-s->me.temp =
-s->sc.rd_scratchpad   =
-s->sc.b_scratchpad=
-s->sc.obmc_scratchpad = NULL;
-
 if (s->encoding) {
 if (!FF_ALLOCZ_TYPED_ARRAY(s->me.map,   ME_MAP_SIZE) ||
 !FF_ALLOCZ_TYPED_ARRAY(s->me.score_map, ME_MAP_SIZE))
@@ -411,6 +404,35 @@ static int init_duplicate_context(MpegEncContext *s)
 return 0;
 }
 
+/**
+ * Initialize an MpegEncContext's thread contexts. Presumes that
+ * slice_context_count is already set and that all the fields
+ * that are freed/reset in free_duplicate_context() are NULL.
+ */
+static int init_duplicate_contexts(MpegEncContext *s)
+{
+int nb_slices = s->slice_context_count, ret;
+
+/* We initialize the copies before the original so that
+ * fields allocated in init_duplicate_context are NULL after
+ * copying. This prevents double-frees upon allocation error. */
+for (int i = 1; i < nb_slices; i++) {
+s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext));
+if (!s->thread_context[i])
+return AVERROR(ENOMEM);
+if ((ret = init_duplicate_context(s->thread_context[i])) < 0)
+return ret;
+s->thread_context[i]->start_mb_y =
+(s->mb_height * (i) + nb_slices / 2) / nb_slices;
+s->thread_context[i]->end_mb_y   =
+(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
+}
+s->start_mb_y = 0;
+s->end_mb_y   = nb_slices > 1 ? (s->mb_height + nb_slices / 2) / nb_slices
+  : s->mb_height;
+return init_duplicate_context(s);
+}
+
 static void free_duplicate_context(MpegEncContext *s)
 {
 if (!s)
@@ -950,29 +972,12 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 s->context_initialized = 1;
 memset(s->thread_context, 0, sizeof(s->thread_context));
 s->thread_context[0]   = s;
+s->slice_context_count = nb_slices;
 
 // if (s->width && s->height) {
-if (nb_slices > 1) {
-for (i = 0; i < nb_slices; i++) {
-if (i) {
-s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext));
-if (!s->thread_context[i])
-goto fail_nomem;
-}
-if ((ret = init_duplicate_context(s->thread_context[i])) < 0)
-goto fail;
-s->thread_context[i]->start_mb_y =
-(s->mb_height * (i) + nb_slices / 2) / nb_slices;
-s->thread_context[i]->end_mb_y   =
-(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
-}
-} else {
-if ((ret = init_duplicate_context(s)) < 0)
-goto fail;
-s->start_mb_y = 0;
-s->end_mb_y   = s->mb_height;
-}
-s->slice_context_count = nb_slices;
+ret = init_duplicate_contexts(s);
+if (ret < 0)
+goto fail;
 // }
 
 return 0;
@@ -1082,31 +1087,9 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s)
 s->thread_context[0]   = s;
 
 if (s->width && s->height) {
-int nb_slices = s->slice_context_count;
-if (nb_slices > 1) {
-for (i = 0; i < nb_slices; i++) {
-if (i) {
-s->thread_context[i] = av_memdup(s, 
sizeof(MpegEncContext));
-if (!s->thread_context[i]) {
-err = AVERROR(ENOMEM);
-goto fail;
-}
-}
-   

[FFmpeg-devel] [PATCH 7/7] avcodec/mpegvideo: Factor common freeing code out

2020-12-25 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.c | 30 --
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 3daccb816f..dd50c03306 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -455,6 +455,15 @@ static void free_duplicate_context(MpegEncContext *s)
 s->block = NULL;
 }
 
+static void free_duplicate_contexts(MpegEncContext *s)
+{
+for (int i = 1; i < s->slice_context_count; i++) {
+free_duplicate_context(s->thread_context[i]);
+av_freep(&s->thread_context[i]);
+}
+free_duplicate_context(s);
+}
+
 static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src)
 {
 #define COPY(a) bak->a = src->a
@@ -1049,16 +1058,7 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s)
 if (!s->context_initialized)
 return AVERROR(EINVAL);
 
-if (s->slice_context_count > 1) {
-for (i = 0; i < s->slice_context_count; i++) {
-free_duplicate_context(s->thread_context[i]);
-}
-for (i = 1; i < s->slice_context_count; i++) {
-av_freep(&s->thread_context[i]);
-}
-} else
-free_duplicate_context(s);
-
+free_duplicate_contexts(s);
 free_context_frame(s);
 
 if (s->picture)
@@ -1106,15 +1106,9 @@ void ff_mpv_common_end(MpegEncContext *s)
 if (!s)
 return;
 
-if (s->slice_context_count > 1) {
-for (i = 0; i < s->slice_context_count; i++) {
-free_duplicate_context(s->thread_context[i]);
-}
-for (i = 1; i < s->slice_context_count; i++) {
-av_freep(&s->thread_context[i]);
-}
+free_duplicate_contexts(s);
+if (s->slice_context_count > 1)
 s->slice_context_count = 1;
-} else free_duplicate_context(s);
 
 av_freep(&s->parse_context.buffer);
 s->parse_context.buffer_size = 0;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 5/7] Revert "avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common_init()"

2020-12-25 Thread Andreas Rheinhardt
This mostly reverts commit 4b2863ff01b1fe93d9a518523c9098d17a9d8c6f.
Said commit removed the freeing code from ff_mpv_common_init(),
ff_mpv_common_frame_size_change() and ff_mpeg_framesize_alloc() and
instead added the FF_CODEC_CAP_INIT_CLEANUP to several codecs that use
ff_mpv_common_init(). This introduced several bugs:

a) Several decoders using ff_mpv_common_init() in their init function were
forgotten: This affected FLV, Intel H.263, RealVideo 3.0 and V4.0 as well as
VC-1/WMV3.
b) ff_mpv_common_init() is not only called from the init function of
codecs, it is also called from AVCodec.decode functions. If an error
happens after an allocation has succeeded, it can lead to memleaks;
furthermore, it is now possible for the MpegEncContext to be marked as
initialized even when ff_mpv_common_init() returns an error and this can
lead to segfaults because decoders that call ff_mpv_common_init() when
decoding a frame can mistakenly think that the MpegEncContext has been
properly initialized. This can e.g. happen with H.261 or MPEG-4.
c) Removing code for freeing from ff_mpeg_framesize_alloc() (which can't
be called from any init function) can lead to segfaults because the
check for whether it needs to called consists of checking whether the
first of the buffers allocated there has been allocated.
d) ff_mpv_common_frame_size_change() can also not be reached from any
AVCodec.init function; yet the changes can e.g. lead to segfaults with
decoders using ff_h263_decode_frame() upon allocation failure, because
the MpegEncContext will upon return be flagged as both initialized and
not in need of reinitialization (granted, the fact that
ff_h263_decode_frame() clears context_reinit before the context has been
reinited is a bug in itself). With the earlier version, the context
would be cleaned upon failure and it would be attempted to initialize
the context again in the next call to ff_h263_decode_frame().

While a) could be fixed by adding the missing FF_CODEC_CAP_INIT_CLEANUP,
keeping the current approach would entail adding cleanup code to several
other places because of b). Therefore ff_mpv_common_init() is again made
to clean up after itself; the changes to the wmv2 decoder and the SVQ1
encoder have not been reverted: The former fixed a memleak, the latter
allowed to remove cleanup code.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h261dec.c   |  1 -
 libavcodec/h263dec.c   |  4 ++--
 libavcodec/mpeg12dec.c |  9 +
 libavcodec/mpeg4videodec.c |  3 +--
 libavcodec/mpegpicture.c   |  4 +++-
 libavcodec/mpegvideo.c | 31 ---
 libavcodec/msmpeg4dec.c|  8 
 libavcodec/rv10.c  |  2 --
 8 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 4f1f22b279..6c54ca79fe 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -683,6 +683,5 @@ AVCodec ff_h261_decoder = {
 .close  = h261_decode_end,
 .decode = h261_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 .max_lowres = 3,
 };
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 32e26a57de..39881dc713 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -770,7 +770,7 @@ AVCodec ff_h263_decoder = {
 .decode = ff_h263_decode_frame,
 .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
   AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY,
-.caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | 
FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
@@ -788,7 +788,7 @@ AVCodec ff_h263p_decoder = {
 .decode = ff_h263_decode_frame,
 .capabilities   = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
   AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY,
-.caps_internal  = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | 
FF_CODEC_CAP_INIT_CLEANUP,
+.caps_internal  = 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/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 66556c7a82..ebafac209f 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2855,7 +2855,8 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx)
 {
 Mpeg1Context *s = avctx->priv_data;
 
-ff_mpv_common_end(&s->mpeg_enc_ctx);
+if (s->mpeg_enc_ctx_allocated)
+ff_mpv_common_end(&s->mpeg_enc_ctx);
 av_buffer_unref(&s->a53_buf_ref);
 return 0;
 }
@@ -2872,7 +2873,7 @@ AVCodec ff_mpeg1video_decoder = {
 .capabilities  = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
  AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
  A

[FFmpeg-devel] [PATCH 1/7] avcodec/mpeg12dec: Remove update_thread_context

2020-12-25 Thread Andreas Rheinhardt
No decoder here supports frame threading.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 28 
 1 file changed, 28 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 6d0e9fc7ed..66556c7a82 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1074,33 +1074,6 @@ static av_cold int mpeg_decode_init(AVCodecContext 
*avctx)
 return 0;
 }
 
-#if HAVE_THREADS
-static int mpeg_decode_update_thread_context(AVCodecContext *avctx,
- const AVCodecContext *avctx_from)
-{
-Mpeg1Context *ctx = avctx->priv_data, *ctx_from = avctx_from->priv_data;
-MpegEncContext *s = &ctx->mpeg_enc_ctx, *s1 = &ctx_from->mpeg_enc_ctx;
-int err;
-
-if (avctx == avctx_from   ||
-!ctx_from->mpeg_enc_ctx_allocated ||
-!s1->context_initialized)
-return 0;
-
-err = ff_mpeg_update_thread_context(avctx, avctx_from);
-if (err)
-return err;
-
-if (!ctx->mpeg_enc_ctx_allocated)
-memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext));
-
-if (!(s->pict_type == AV_PICTURE_TYPE_B || s->low_delay))
-s->picture_number++;
-
-return 0;
-}
-#endif
-
 static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
  const uint8_t *new_perm)
 {
@@ -2902,7 +2875,6 @@ AVCodec ff_mpeg1video_decoder = {
 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | 
FF_CODEC_CAP_INIT_CLEANUP,
 .flush = flush,
 .max_lowres= 3,
-.update_thread_context = 
ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
 .hw_configs= (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_MPEG1_NVDEC_HWACCEL
HWACCEL_NVDEC(mpeg1),
-- 
2.25.1

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

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

Re: [FFmpeg-devel] [PATCH 1/7] avcodec/mpeg12dec: Remove update_thread_context

2020-12-25 Thread Michael Niedermayer
On Fri, Dec 25, 2020 at 04:47:18PM +0100, Andreas Rheinhardt wrote:
> No decoder here supports frame threading.

what is missing for them to support it ?

the whole mpeg* decoders used alot of shared code, mpeg4 supports frame
threads. And i see little threading related code in mpeg4 ...

Thanks

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

Avoid a single point of failure, be that a person or equipment.


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] avfilter/vf_framerate: fix infinite loop with 1-frame input

2020-12-25 Thread Marton Balint



On Sun, 20 Dec 2020, Marton Balint wrote:


Fixes infinite loop in:
ffmpeg -f lavfi -i testsrc=d=0.04 -vf framerate=50 -f null none


Ping, will apply soon.

Regards,
Marton



Signed-off-by: Marton Balint 
---
libavfilter/vf_framerate.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 6c8d01c94b..f5085705a4 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -170,7 +170,9 @@ static int process_work_frame(AVFilterContext *ctx)
return 0;

if (!s->f0) {
-s->work = av_frame_clone(s->f1);
+av_assert1(s->flush);
+s->work = s->f1;
+s->f1 = NULL;
} else {
if (work_pts >= s->pts1 + s->delta && s->flush)
return 0;
--
2.26.2

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

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

___
ffmpeg-devel 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/6] avcodec: add h266 codec id and profiles

2020-12-25 Thread Nuo Mi
On Tue, Dec 22, 2020 at 6:37 PM Nuo Mi  wrote:

>
> Hi James,
> thanks for the review.
>
> On Mon, Dec 21, 2020 at 11:14 PM James Almer  wrote:
>
>> On 12/21/2020 3:07 AM, Nuo Mi wrote:
>> > ---
>> >   libavcodec/avcodec.h| 2 ++
>> >   libavcodec/codec_desc.c | 8 
>> >   libavcodec/codec_id.h   | 2 ++
>> >   libavcodec/profiles.c   | 5 +
>> >   libavcodec/profiles.h   | 1 +
>> >   5 files changed, 18 insertions(+)
>> >
>> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> > index 1d3099d50a..f7ea4d5849 100644
>> > --- a/libavcodec/avcodec.h
>> > +++ b/libavcodec/avcodec.h
>> > @@ -1961,6 +1961,8 @@ typedef struct AVCodecContext {
>> >   #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
>> >   #define FF_PROFILE_HEVC_REXT4
>> >
>> > +#define FF_PROFILE_H266_MAIN_10  1
>>
>> We should decide first what we are going to use, if VVC or h266.
>>
>> My suggestion was to use VVC for decoder, parser, demuxer and public
>> defines, which is what's exposed to the user, and h266 for CBS, which
>> makes things simpler to implement and is proper consider it's written
>> using the ITU spec.
>>
> Sorry for missed this. But seems mark and you have a different
> suggestion.  Could you align with him and other maintainers?
> I can continue to address other issues. It's not too later to change this
> before I checked the patch set.
>
Hi Mark,
Most of the issue are addressed.  I will send the second reversion of this
patchset.
Are you ok with James's suggestion?

thanks.

>
>> > +
>> >   #define FF_PROFILE_AV1_MAIN 0
>> >   #define FF_PROFILE_AV1_HIGH 1
>> >   #define FF_PROFILE_AV1_PROFESSIONAL 2
>> > diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
>> > index 404c460f8f..62fe0f453d 100644
>> > --- a/libavcodec/codec_desc.c
>> > +++ b/libavcodec/codec_desc.c
>> > @@ -1426,6 +1426,14 @@ static const AVCodecDescriptor
>> codec_descriptors[] = {
>> >   .long_name = NULL_IF_CONFIG_SMALL("Microsoft Paint (MSP)
>> version 2"),
>> >   .props = AV_CODEC_PROP_INTRA_ONLY |
>> AV_CODEC_PROP_LOSSLESS,
>> >   },
>> > +{
>> > +.id= AV_CODEC_ID_H266,
>> > +.type  = AVMEDIA_TYPE_VIDEO,
>> > +.name  = "h266",
>>
>> Ditto.
>>
>> > +.long_name = NULL_IF_CONFIG_SMALL("H.266 / VVC (Versatile
>> Video Coding)"),
>> > +.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
>> > +.profiles  = NULL_IF_CONFIG_SMALL(ff_h266_profiles),
>> > +},
>> >   {
>> >   .id= AV_CODEC_ID_Y41P,
>> >   .type  = AVMEDIA_TYPE_VIDEO,
>> > diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
>> > index 6133e03bb9..7a8a896bfe 100644
>> > --- a/libavcodec/codec_id.h
>> > +++ b/libavcodec/codec_id.h
>> > @@ -244,6 +244,8 @@ enum AVCodecID {
>> >   AV_CODEC_ID_PGX,
>> >   AV_CODEC_ID_AVS3,
>> >   AV_CODEC_ID_MSP2,
>> > +AV_CODEC_ID_VVC,
>> > +#define AV_CODEC_ID_H266 AV_CODEC_ID_VVC
>>
>> This chunk is good as is.
>>
>> >
>> >   AV_CODEC_ID_Y41P = 0x8000,
>> >   AV_CODEC_ID_AVRP,
>> > diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
>> > index e59a3a5c12..710f2c01e2 100644
>> > --- a/libavcodec/profiles.c
>> > +++ b/libavcodec/profiles.c
>> > @@ -74,6 +74,11 @@ const AVProfile ff_h264_profiles[] = {
>> >   { FF_PROFILE_UNKNOWN },
>> >   };
>> >
>> > +const AVProfile ff_h266_profiles[] = {
>> > +{ FF_PROFILE_H266_MAIN_10, "Main 10" },
>> > +{ FF_PROFILE_UNKNOWN },
>> > +};
>> > +
>> >   const AVProfile ff_hevc_profiles[] = {
>> >   { FF_PROFILE_HEVC_MAIN, "Main"},
>> >   { FF_PROFILE_HEVC_MAIN_10,  "Main 10" },
>> > diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
>> > index 6baaba5701..7a353dbf3d 100644
>> > --- a/libavcodec/profiles.h
>> > +++ b/libavcodec/profiles.h
>> > @@ -60,6 +60,7 @@ extern const AVProfile ff_aac_profiles[];
>> >   extern const AVProfile ff_dca_profiles[];
>> >   extern const AVProfile ff_dnxhd_profiles[];
>> >   extern const AVProfile ff_h264_profiles[];
>> > +extern const AVProfile ff_h266_profiles[];
>> >   extern const AVProfile ff_hevc_profiles[];
>> >   extern const AVProfile ff_jpeg2000_profiles[];
>> >   extern const AVProfile ff_mpeg2_video_profiles[];
>> >
>>
>> ___
>> 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".