Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses
@ 2023-09-30 18:02 Andreas Rheinhardt
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_dec: Don't memset twice Andreas Rheinhardt
                   ` (11 more replies)
  0 siblings, 12 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-09-30 18:02 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Fixes segfaults with -debug +nomc -flags +gray (presuming
a build with --enable-gray).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_dec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 7aa46a4e25..77d90104f6 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -249,10 +249,12 @@ static void gray_frame(AVFrame *frame)
 {
     int h_chroma_shift, v_chroma_shift;
 
-    av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift);
-
     for (int i = 0; i < frame->height; i++)
         memset(frame->data[0] + frame->linesize[0] * i, 0x80, frame->width);
+
+    if (!frame->data[1])
+        return;
+    av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift);
     for (int i = 0; i < AV_CEIL_RSHIFT(frame->height, v_chroma_shift); i++) {
         memset(frame->data[1] + frame->linesize[1] * i,
                0x80, AV_CEIL_RSHIFT(frame->width, h_chroma_shift));
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_dec: Don't memset twice
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
@ 2023-09-30 18:02 ` Andreas Rheinhardt
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_dec: Remove commented-out legacy cruft Andreas Rheinhardt
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-09-30 18:02 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This has been done for the luma plane of missing FLV1 and H263
references.
Also remove code duplication by reusing gray_frame(), which
has been renamed to color_frame() for this purpose.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_dec.c | 28 +++++-----------------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 77d90104f6..617109a1f7 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -245,12 +245,12 @@ static int alloc_picture(MpegEncContext *s, Picture *pic)
                             &s->linesize, &s->uvlinesize);
 }
 
-static void gray_frame(AVFrame *frame)
+static void color_frame(AVFrame *frame, int luma)
 {
     int h_chroma_shift, v_chroma_shift;
 
     for (int i = 0; i < frame->height; i++)
-        memset(frame->data[0] + frame->linesize[0] * i, 0x80, frame->width);
+        memset(frame->data[0] + frame->linesize[0] * i, luma, frame->width);
 
     if (!frame->data[1])
         return;
@@ -365,9 +365,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
     if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&
         (s->pict_type != AV_PICTURE_TYPE_I)) {
-        int h_chroma_shift, v_chroma_shift;
-        av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
-                                         &h_chroma_shift, &v_chroma_shift);
         if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f->buf[0])
             av_log(avctx, AV_LOG_DEBUG,
                    "allocating dummy last picture for B frame\n");
@@ -393,23 +390,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
         }
 
         if (!avctx->hwaccel) {
-            for (int i = 0; i < avctx->height; i++)
-                memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0]*i,
-                       0x80, avctx->width);
-            if (s->last_picture_ptr->f->data[2]) {
-                for (int i = 0; i < AV_CEIL_RSHIFT(avctx->height, v_chroma_shift); i++) {
-                    memset(s->last_picture_ptr->f->data[1] + s->last_picture_ptr->f->linesize[1]*i,
-                        0x80, AV_CEIL_RSHIFT(avctx->width, h_chroma_shift));
-                    memset(s->last_picture_ptr->f->data[2] + s->last_picture_ptr->f->linesize[2]*i,
-                        0x80, AV_CEIL_RSHIFT(avctx->width, h_chroma_shift));
-                }
-            }
-
-            if (s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263) {
-                for (int i = 0; i < avctx->height; i++)
-                    memset(s->last_picture_ptr->f->data[0] + s->last_picture_ptr->f->linesize[0] * i,
-                           16, avctx->width);
-            }
+            int luma_val = s->codec_id == AV_CODEC_ID_FLV1 || s->codec_id == AV_CODEC_ID_H263 ? 16 : 0x80;
+            color_frame(s->last_picture_ptr->f, luma_val);
         }
 
         ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
@@ -484,7 +466,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     if (s->avctx->debug & FF_DEBUG_NOMC)
-        gray_frame(s->current_picture_ptr->f);
+        color_frame(s->current_picture_ptr->f, 0x80);
 
     return 0;
 }
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_dec: Remove commented-out legacy cruft
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_dec: Don't memset twice Andreas Rheinhardt
@ 2023-09-30 18:02 ` Andreas Rheinhardt
  2023-10-01 20:29   ` Michael Niedermayer
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 4/4] avcodec/h264_slice: Don't keep AVCodecContext props in sync manually Andreas Rheinhardt
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-09-30 18:02 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Added in 80e9e63c946660304fc65fa8141ccfdbe4d196d1 for reasons
unknown to me.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_dec.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 617109a1f7..f9fccff518 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -419,10 +419,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);
     }
 
-#if 0 // BUFREF-FIXME
-    memset(s->last_picture.f->data, 0, sizeof(s->last_picture.f->data));
-    memset(s->next_picture.f->data, 0, sizeof(s->next_picture.f->data));
-#endif
     if (s->last_picture_ptr) {
         if (s->last_picture_ptr->f->buf[0] &&
             (ret = ff_mpeg_ref_picture(s->avctx, &s->last_picture,
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 4/4] avcodec/h264_slice: Don't keep AVCodecContext props in sync manually
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_dec: Don't memset twice Andreas Rheinhardt
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_dec: Remove commented-out legacy cruft Andreas Rheinhardt
@ 2023-09-30 18:02 ` Andreas Rheinhardt
  2023-10-02 10:51 ` [FFmpeg-devel] [PATCH 5/8] avcodec/mpeg12dec: Don't initialize IDCT more than once Andreas Rheinhardt
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-09-30 18:02 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is already done generically in update_context_from_thread()
before this function is called.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h264_slice.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 5657327f0c..24f4690e79 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -404,10 +404,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
         memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
     }
 
-    h->avctx->coded_height  = h1->avctx->coded_height;
-    h->avctx->coded_width   = h1->avctx->coded_width;
-    h->avctx->width         = h1->avctx->width;
-    h->avctx->height        = h1->avctx->height;
     h->width_from_caller    = h1->width_from_caller;
     h->height_from_caller   = h1->height_from_caller;
     h->coded_picture_number = h1->coded_picture_number;
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_dec: Remove commented-out legacy cruft
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_dec: Remove commented-out legacy cruft Andreas Rheinhardt
@ 2023-10-01 20:29   ` Michael Niedermayer
  0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-01 20:29 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 651 bytes --]

On Sat, Sep 30, 2023 at 08:02:55PM +0200, Andreas Rheinhardt wrote:
> Added in 80e9e63c946660304fc65fa8141ccfdbe4d196d1 for reasons
> unknown to me.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpegvideo_dec.c | 4 ----
>  1 file changed, 4 deletions(-)

ok

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

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 5/8] avcodec/mpeg12dec: Don't initialize IDCT more than once
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 4/4] avcodec/h264_slice: Don't keep AVCodecContext props in sync manually Andreas Rheinhardt
@ 2023-10-02 10:51 ` Andreas Rheinhardt
  2023-10-03 22:14   ` Andreas Rheinhardt
  2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 6/8] avcodec/mpegvideo_dec: Don't zero context on init failure Andreas Rheinhardt
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-02 10:51 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Before 998c9f15d1ca8c7489775ebcca51623b915988f1, the IDCTDSPContext
has only been initialized in ff_mpv_common_init() which is deferred
until immediately before decoding a picture; to nevertheless parse
the quant matrices in sequence headers or quant matrix extensions,
a dummy (identity) permutation has been stored in the codec's init
function; after ff_mpv_common_init() which could change the permutation
the matrices were repermutated.

Yet since said commit, the IDCTDSPContext is initialized during init
and does not change afterwards (unless the user forces different CPU
flags), so there is no need to reinitialize it; the repermutation code
can be removed as well.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg12dec.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 92ef6944fa..d2dbcd5b61 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1057,8 +1057,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
         avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input
     ff_mpv_decode_init(s2, avctx);
 
-    /* we need some permutation to store matrices,
-     * until the decoder sets the real permutation. */
     ff_mpv_idct_init(s2);
     ff_mpeg12_init_vlcs();
 
@@ -1093,18 +1091,6 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx,
 }
 #endif
 
-static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
-                                 const uint8_t *new_perm)
-{
-    uint16_t temp_matrix[64];
-    int i;
-
-    memcpy(temp_matrix, matrix, 64 * sizeof(uint16_t));
-
-    for (i = 0; i < 64; i++)
-        matrix[new_perm[i]] = temp_matrix[old_perm[i]];
-}
-
 static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
 #if CONFIG_MPEG1_NVDEC_HWACCEL
     AV_PIX_FMT_CUDA,
@@ -1177,7 +1163,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
 {
     Mpeg1Context *s1  = avctx->priv_data;
     MpegEncContext *s = &s1->mpeg_enc_ctx;
-    uint8_t old_permutation[64];
     int ret;
 
     if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
@@ -1297,19 +1282,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
         avctx->pix_fmt = mpeg_get_pixelformat(avctx);
 
-        /* Quantization matrices may need reordering
-         * if DCT permutation is changed. */
-        memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
-
-        ff_mpv_idct_init(s);
         if ((ret = ff_mpv_common_init(s)) < 0)
             return ret;
 
-        quant_matrix_rebuild(s->intra_matrix,        old_permutation, s->idsp.idct_permutation);
-        quant_matrix_rebuild(s->inter_matrix,        old_permutation, s->idsp.idct_permutation);
-        quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);
-        quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);
-
         s1->mpeg_enc_ctx_allocated = 1;
     }
     return 0;
@@ -2169,7 +2144,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
 
     avctx->pix_fmt = mpeg_get_pixelformat(avctx);
 
-    ff_mpv_idct_init(s);
     if ((ret = ff_mpv_common_init(s)) < 0)
         return ret;
     s1->mpeg_enc_ctx_allocated = 1;
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 6/8] avcodec/mpegvideo_dec: Don't zero context on init failure
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2023-10-02 10:51 ` [FFmpeg-devel] [PATCH 5/8] avcodec/mpeg12dec: Don't initialize IDCT more than once Andreas Rheinhardt
@ 2023-10-02 10:52 ` Andreas Rheinhardt
  2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 7/8] avcodec/mpegvideo_dec: Always initialize IDCTDSPContext during init Andreas Rheinhardt
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-02 10:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Up until now, ff_mpeg_update_thread_context() zeroes
the context to initialize on initialization failure.
This has been added in e1d7d4bd13cdd8856a3611d1ea387ac733a7aebf.

Just as now, ff_mpeg_update_thread_context() simply
copied the src MpegEncContext over the dst MpegEncContext
to initialize it, but clear_context() was only added in
b160fc290cf49b516c5b6ee0730fd9da7fc623b1, so that cleaning up
on init failure was a minefield if performed.

It was not always performed, namely not before the first
allocation needed to be freed. In the fuzzer sample that
led to e1d7d4bd13cdd8856a3611d1ea387ac733a7aebf, the call
to av_image_check_size() failed and before said commit,
the context contained lots of pointers from the src context,
leading to assert violations lateron.

Of course, the proper fix for this is resetting the pointers
(or even better, not copying them in the first place), so
this zeroing is unnecessary since commit
b160fc290cf49b516c5b6ee0730fd9da7fc623b1. It is also harmful,
because it makes initializing something only once during init
more complicated; See the h264chroma handling in the diff
for an example. Therefore it is removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_dec.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index f9fccff518..3f173a9feb 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -83,13 +83,8 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
 
         if (s1->context_initialized) {
             ff_mpv_idct_init(s);
-            if ((err = ff_mpv_common_init(s)) < 0) {
-                memset(s, 0, sizeof(*s));
-                s->avctx = dst;
-                s->private_ctx = private_ctx;
-                memcpy(&s->h264chroma, &s1->h264chroma, sizeof(s->h264chroma));
+            if ((err = ff_mpv_common_init(s)) < 0)
                 return err;
-            }
         }
     }
 
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 7/8] avcodec/mpegvideo_dec: Always initialize IDCTDSPContext during init
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 6/8] avcodec/mpegvideo_dec: Don't zero context on init failure Andreas Rheinhardt
@ 2023-10-02 10:52 ` Andreas Rheinhardt
  2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 8/8] avcodec/h263dec, mpeg4videodec: Parse extradata " Andreas Rheinhardt
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-02 10:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It has currently not been done for H263, H263P and MPEG4.
Doing so avoids having to initialize the IDCT permutation
lateron when decoding packets in order to be able to parse
a quant matrix; it means that every mpegvideo decoder always
has an initialized IDCTDSPContext after init.
Initializing is done generically in ff_mpv_decode_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261dec.c       | 1 -
 libavcodec/h263dec.c       | 5 -----
 libavcodec/mpeg12dec.c     | 2 --
 libavcodec/mpegvideo_dec.c | 2 +-
 libavcodec/rv10.c          | 1 -
 libavcodec/rv34.c          | 1 -
 libavcodec/vc1dec.c        | 1 -
 7 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index c41b96c3c7..6cdf11f822 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -94,7 +94,6 @@ static av_cold int h261_decode_init(AVCodecContext *avctx)
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
     h->gob_start_code_skipped = 0;
-    ff_mpv_idct_init(s);
 
     ff_thread_once(&init_static_once, h261_decode_init_static);
 
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 9f63f1a7cb..544d32b682 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -128,7 +128,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
         avctx->codec->id != AV_CODEC_ID_H263P &&
         avctx->codec->id != AV_CODEC_ID_MPEG4) {
         avctx->pix_fmt = h263_get_format(avctx);
-        ff_mpv_idct_init(s);
         if ((ret = ff_mpv_common_init(s)) < 0)
             return ret;
     }
@@ -459,10 +458,6 @@ retry:
     if (ret < 0)
         return ret;
 
-    if (!s->context_initialized)
-        // we need the idct permutation for reading a custom matrix
-        ff_mpv_idct_init(s);
-
     /* let's go :-) */
     if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
         ret = ff_wmv2_decode_picture_header(s);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index d2dbcd5b61..c0f1e8763b 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1057,7 +1057,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
         avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input
     ff_mpv_decode_init(s2, avctx);
 
-    ff_mpv_idct_init(s2);
     ff_mpeg12_init_vlcs();
 
     s2->chroma_format              = 1;
@@ -3048,7 +3047,6 @@ static av_cold int ipu_decode_init(AVCodecContext *avctx)
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
     ff_mpv_decode_init(m, avctx);
-    ff_mpv_idct_init(m);
     ff_mpeg12_init_vlcs();
 
     for (int i = 0; i < 64; i++) {
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 3f173a9feb..39d1282252 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -54,6 +54,7 @@ void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
     /* convert fourcc to upper case */
     s->codec_tag       = ff_toupper4(avctx->codec_tag);
 
+    ff_mpv_idct_init(s);
     ff_h264chroma_init(&s->h264chroma, 8); //for lowres
 }
 
@@ -82,7 +83,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
         s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0;
 
         if (s1->context_initialized) {
-            ff_mpv_idct_init(s);
             if ((err = ff_mpv_common_init(s)) < 0)
                 return err;
         }
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 6abceade4e..fbecfdae9f 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -420,7 +420,6 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
-    ff_mpv_idct_init(s);
     if ((ret = ff_mpv_common_init(s)) < 0)
         return ret;
 
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index e9660bb457..152c62fa07 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1498,7 +1498,6 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
     avctx->has_b_frames = 1;
     s->low_delay = 0;
 
-    ff_mpv_idct_init(s);
     if ((ret = ff_mpv_common_init(s)) < 0)
         return ret;
 
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 449d2fea5e..a4f2d30e22 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -431,7 +431,6 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
         return ret;
 
     ff_mpv_decode_init(s, avctx);
-    ff_mpv_idct_init(s);
 
     avctx->pix_fmt = vc1_get_format(avctx);
 
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 8/8] avcodec/h263dec, mpeg4videodec: Parse extradata during init
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (5 preceding siblings ...)
  2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 7/8] avcodec/mpegvideo_dec: Always initialize IDCTDSPContext during init Andreas Rheinhardt
@ 2023-10-02 10:52 ` Andreas Rheinhardt
  2023-10-02 23:39 ` [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-02 10:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Possible now that the IDCT is already initialized at this point.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h263dec.c       | 7 -------
 libavcodec/mpeg4videodec.c | 9 +++++++++
 libavcodec/mpegvideo.h     | 1 -
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 544d32b682..eb1d87a2fe 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -464,13 +464,6 @@ retry:
     } else if (CONFIG_MSMPEG4DEC && s->msmpeg4_version) {
         ret = ff_msmpeg4_decode_picture_header(s);
     } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
-        if (s->avctx->extradata_size && !s->extradata_parsed) {
-            GetBitContext gb;
-
-            if (init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size) >= 0 )
-                ff_mpeg4_decode_picture_header(avctx->priv_data, &gb, 1, 0);
-            s->extradata_parsed = 1;
-        }
         ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0);
         s->skipped_last_frame = (ret == FRAME_SKIPPED);
     } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index a8dd57bf6b..c8d4939259 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -42,6 +42,7 @@
 #include "h263.h"
 #include "h263data.h"
 #include "h263dec.h"
+#include "internal.h"
 #include "profiles.h"
 #include "qpeldsp.h"
 #include "threadframe.h"
@@ -3831,6 +3832,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     ff_thread_once(&init_static_once, mpeg4_init_static);
 
+    /* Must be after initializing the MPEG-4 static tables */
+    if (avctx->extradata_size && !avctx->internal->is_copy) {
+        GetBitContext gb;
+
+        if (init_get_bits8(&gb, avctx->extradata, avctx->extradata_size) >= 0)
+            ff_mpeg4_decode_picture_header(ctx, &gb, 1, 0);
+    }
+
     return 0;
 }
 
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 55828e6102..d7c2f57682 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -114,7 +114,6 @@ typedef struct MpegEncContext {
     int input_picture_number;  ///< used to set pic->display_picture_number, should not be used for/by anything else
     int coded_picture_number;  ///< used to set pic->coded_picture_number, should not be used for/by anything else
     int picture_number;       //FIXME remove, unclear definition
-    int extradata_parsed;
     int picture_in_gop_number; ///< 0-> first pic in gop, ...
     int mb_width, mb_height;   ///< number of MBs horizontally & vertically
     int mb_stride;             ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (6 preceding siblings ...)
  2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 8/8] avcodec/h263dec, mpeg4videodec: Parse extradata " Andreas Rheinhardt
@ 2023-10-02 23:39 ` Andreas Rheinhardt
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 09/12] avcodec/rv10: Remove dead code Andreas Rheinhardt
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-02 23:39 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Fixes segfaults with -debug +nomc -flags +gray (presuming
> a build with --enable-gray).
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpegvideo_dec.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
> index 7aa46a4e25..77d90104f6 100644
> --- a/libavcodec/mpegvideo_dec.c
> +++ b/libavcodec/mpegvideo_dec.c
> @@ -249,10 +249,12 @@ static void gray_frame(AVFrame *frame)
>  {
>      int h_chroma_shift, v_chroma_shift;
>  
> -    av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift);
> -
>      for (int i = 0; i < frame->height; i++)
>          memset(frame->data[0] + frame->linesize[0] * i, 0x80, frame->width);
> +
> +    if (!frame->data[1])
> +        return;
> +    av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift);
>      for (int i = 0; i < AV_CEIL_RSHIFT(frame->height, v_chroma_shift); i++) {
>          memset(frame->data[1] + frame->linesize[1] * i,
>                 0x80, AV_CEIL_RSHIFT(frame->width, h_chroma_shift));

Will apply patches one, two and four of this patchset 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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 09/12] avcodec/rv10: Remove dead code
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (7 preceding siblings ...)
  2023-10-02 23:39 ` [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
@ 2023-10-03 16:04 ` Andreas Rheinhardt
  2023-10-04 17:28   ` Michael Niedermayer
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT Andreas Rheinhardt
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-03 16:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Dead since 248a1aa54c08b14e8bd49147f59d954c41b5b3a3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/rv10.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index fbecfdae9f..3f9d5ff242 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -176,9 +176,6 @@ static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
     case 3:
         s->pict_type = AV_PICTURE_TYPE_B;
         break;
-    default:
-        av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
-        return AVERROR_INVALIDDATA;
     }
 
     if (s->low_delay && s->pict_type == AV_PICTURE_TYPE_B) {
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (8 preceding siblings ...)
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 09/12] avcodec/rv10: Remove dead code Andreas Rheinhardt
@ 2023-10-03 16:04 ` Andreas Rheinhardt
  2023-10-04 17:27   ` Michael Niedermayer
  2023-10-06  1:42   ` Vittorio Giovara
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 11/12] avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags Andreas Rheinhardt
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 12/12] avcodec/mpegvideo: Move allocating new_picture to the encoder Andreas Rheinhardt
  11 siblings, 2 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-03 16:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/rv10.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 3f9d5ff242..216328ffe7 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -158,25 +158,14 @@ static int rv10_decode_picture_header(MpegEncContext *s)
 
 static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
 {
+    static const enum AVPictureType pict_types[] =
+        { AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_I /* hmm ... */,
+          AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B };
     MpegEncContext *s = &rv->m;
-    int seq, mb_pos, i, ret;
+    int seq, mb_pos, ret;
     int rpr_max;
 
-    i = get_bits(&s->gb, 2);
-    switch (i) {
-    case 0:
-        s->pict_type = AV_PICTURE_TYPE_I;
-        break;
-    case 1:
-        s->pict_type = AV_PICTURE_TYPE_I;
-        break;                                  // hmm ...
-    case 2:
-        s->pict_type = AV_PICTURE_TYPE_P;
-        break;
-    case 3:
-        s->pict_type = AV_PICTURE_TYPE_B;
-        break;
-    }
+    s->pict_type = pict_types[get_bits(&s->gb, 2)];
 
     if (s->low_delay && s->pict_type == AV_PICTURE_TYPE_B) {
         av_log(s->avctx, AV_LOG_ERROR, "low delay B\n");
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 11/12] avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (9 preceding siblings ...)
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT Andreas Rheinhardt
@ 2023-10-03 16:04 ` Andreas Rheinhardt
  2023-10-04 17:26   ` Michael Niedermayer
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 12/12] avcodec/mpegvideo: Move allocating new_picture to the encoder Andreas Rheinhardt
  11 siblings, 1 reply; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-03 16:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

These flags will be overwritten later in ff_mpv_frame_start().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261dec.c   |  7 -------
 libavcodec/mpeg12dec.c | 10 ----------
 libavcodec/vc1dec.c    |  7 -------
 3 files changed, 24 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 6cdf11f822..447e168c4f 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -640,13 +640,6 @@ retry:
         goto retry;
     }
 
-    // for skipping the frame
-    s->current_picture.f->pict_type = s->pict_type;
-    if (s->pict_type == AV_PICTURE_TYPE_I)
-        s->current_picture.f->flags |= AV_FRAME_FLAG_KEY;
-    else
-        s->current_picture.f->flags &= ~AV_FRAME_FLAG_KEY;
-
     if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
         (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
          avctx->skip_frame >= AVDISCARD_ALL)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index c0f1e8763b..5dac83ebcd 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1326,11 +1326,6 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
         s->mpeg_f_code[1][0] = f_code;
         s->mpeg_f_code[1][1] = f_code;
     }
-    s->current_picture.f->pict_type = s->pict_type;
-    if (s->pict_type == AV_PICTURE_TYPE_I)
-        s->current_picture.f->flags |= AV_FRAME_FLAG_KEY;
-    else
-        s->current_picture.f->flags &= ~AV_FRAME_FLAG_KEY;
 
     if (avctx->debug & FF_DEBUG_PICT_INFO)
         av_log(avctx, AV_LOG_DEBUG,
@@ -1504,11 +1499,6 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
                 s->pict_type = AV_PICTURE_TYPE_P;
         } else
             s->pict_type = AV_PICTURE_TYPE_B;
-        s->current_picture.f->pict_type = s->pict_type;
-        if (s->pict_type == AV_PICTURE_TYPE_I)
-            s->current_picture.f->flags |= AV_FRAME_FLAG_KEY;
-        else
-            s->current_picture.f->flags &= ~AV_FRAME_FLAG_KEY;
     }
 
     s->intra_dc_precision         = get_bits(&s->gb, 2);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index a4f2d30e22..534128d6ee 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1058,13 +1058,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
         goto err;
     }
 
-    // for skipping the frame
-    s->current_picture.f->pict_type = s->pict_type;
-    if (s->pict_type == AV_PICTURE_TYPE_I)
-        s->current_picture.f->flags |= AV_FRAME_FLAG_KEY;
-    else
-        s->current_picture.f->flags &= ~AV_FRAME_FLAG_KEY;
-
     /* skip B-frames if we don't have reference frames */
     if (!s->last_picture_ptr && s->pict_type == AV_PICTURE_TYPE_B) {
         av_log(v->s.avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n");
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [FFmpeg-devel] [PATCH 12/12] avcodec/mpegvideo: Move allocating new_picture to the encoder
  2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
                   ` (10 preceding siblings ...)
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 11/12] avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags Andreas Rheinhardt
@ 2023-10-03 16:04 ` Andreas Rheinhardt
  2023-10-06  2:21   ` Andreas Rheinhardt
  11 siblings, 1 reply; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-03 16:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is only used by encoders; this unfortunately necessitated
to add separate allocations to the SVQ1 encoder which uses
motion estimation without being a full member of mpegvideo.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo.c     | 5 +----
 libavcodec/mpegvideo_enc.c | 3 ++-
 libavcodec/svq1enc.c       | 6 ++++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index fc73abab9c..9ed158ac57 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -632,7 +632,6 @@ static void clear_context(MpegEncContext *s)
     memset(&s->next_picture, 0, sizeof(s->next_picture));
     memset(&s->last_picture, 0, sizeof(s->last_picture));
     memset(&s->current_picture, 0, sizeof(s->current_picture));
-    memset(&s->new_picture, 0, sizeof(s->new_picture));
 
     memset(s->thread_context, 0, sizeof(s->thread_context));
 
@@ -720,8 +719,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
 
     if (!(s->next_picture.f    = av_frame_alloc()) ||
         !(s->last_picture.f    = av_frame_alloc()) ||
-        !(s->current_picture.f = av_frame_alloc()) ||
-        !(s->new_picture       = av_frame_alloc()))
+        !(s->current_picture.f = av_frame_alloc()))
         goto fail_nomem;
 
     if ((ret = ff_mpv_init_context_frame(s)))
@@ -801,7 +799,6 @@ void ff_mpv_common_end(MpegEncContext *s)
     ff_mpv_picture_free(s->avctx, &s->last_picture);
     ff_mpv_picture_free(s->avctx, &s->current_picture);
     ff_mpv_picture_free(s->avctx, &s->next_picture);
-    av_frame_free(&s->new_picture);
 
     s->context_initialized      = 0;
     s->context_reinit           = 0;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 5bf4b06a11..f669658127 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -821,7 +821,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) ||
         !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16,        32) ||
         !FF_ALLOCZ_TYPED_ARRAY(s->input_picture,           MAX_PICTURE_COUNT) ||
-        !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT))
+        !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT) ||
+        !(s->new_picture = av_frame_alloc()))
         return AVERROR(ENOMEM);
 
     /* Allocate MV tables; the MV and MB tables will be copied
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 46a484e15f..894ae552bb 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -570,6 +570,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
 
     av_frame_free(&s->current_picture);
     av_frame_free(&s->last_picture);
+    av_frame_free(&s->m.new_picture);
 
     return 0;
 }
@@ -632,10 +633,11 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
     s->dummy               = av_mallocz((s->y_block_width + 1) *
                                         s->y_block_height * sizeof(int32_t));
     s->m.me.map            = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->m.me.map));
+    s->m.new_picture       = av_frame_alloc();
     s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
 
-    if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map ||
-        !s->mb_type || !s->dummy)
+    if (!s->m.me.scratchpad || !s->m.me.map ||
+        !s->mb_type || !s->dummy || !s->m.new_picture)
         return AVERROR(ENOMEM);
     s->m.me.score_map = s->m.me.map + ME_MAP_SIZE;
 
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 5/8] avcodec/mpeg12dec: Don't initialize IDCT more than once
  2023-10-02 10:51 ` [FFmpeg-devel] [PATCH 5/8] avcodec/mpeg12dec: Don't initialize IDCT more than once Andreas Rheinhardt
@ 2023-10-03 22:14   ` Andreas Rheinhardt
  0 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-03 22:14 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Before 998c9f15d1ca8c7489775ebcca51623b915988f1, the IDCTDSPContext
> has only been initialized in ff_mpv_common_init() which is deferred
> until immediately before decoding a picture; to nevertheless parse
> the quant matrices in sequence headers or quant matrix extensions,
> a dummy (identity) permutation has been stored in the codec's init
> function; after ff_mpv_common_init() which could change the permutation
> the matrices were repermutated.
> 
> Yet since said commit, the IDCTDSPContext is initialized during init
> and does not change afterwards (unless the user forces different CPU
> flags), so there is no need to reinitialize it; the repermutation code
> can be removed as well.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpeg12dec.c | 26 --------------------------
>  1 file changed, 26 deletions(-)
> 
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index 92ef6944fa..d2dbcd5b61 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -1057,8 +1057,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
>          avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input
>      ff_mpv_decode_init(s2, avctx);
>  
> -    /* we need some permutation to store matrices,
> -     * until the decoder sets the real permutation. */
>      ff_mpv_idct_init(s2);
>      ff_mpeg12_init_vlcs();
>  
> @@ -1093,18 +1091,6 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx,
>  }
>  #endif
>  
> -static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
> -                                 const uint8_t *new_perm)
> -{
> -    uint16_t temp_matrix[64];
> -    int i;
> -
> -    memcpy(temp_matrix, matrix, 64 * sizeof(uint16_t));
> -
> -    for (i = 0; i < 64; i++)
> -        matrix[new_perm[i]] = temp_matrix[old_perm[i]];
> -}
> -
>  static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
>  #if CONFIG_MPEG1_NVDEC_HWACCEL
>      AV_PIX_FMT_CUDA,
> @@ -1177,7 +1163,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
>  {
>      Mpeg1Context *s1  = avctx->priv_data;
>      MpegEncContext *s = &s1->mpeg_enc_ctx;
> -    uint8_t old_permutation[64];
>      int ret;
>  
>      if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
> @@ -1297,19 +1282,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  
>          avctx->pix_fmt = mpeg_get_pixelformat(avctx);
>  
> -        /* Quantization matrices may need reordering
> -         * if DCT permutation is changed. */
> -        memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
> -
> -        ff_mpv_idct_init(s);
>          if ((ret = ff_mpv_common_init(s)) < 0)
>              return ret;
>  
> -        quant_matrix_rebuild(s->intra_matrix,        old_permutation, s->idsp.idct_permutation);
> -        quant_matrix_rebuild(s->inter_matrix,        old_permutation, s->idsp.idct_permutation);
> -        quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);
> -        quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);
> -
>          s1->mpeg_enc_ctx_allocated = 1;
>      }
>      return 0;
> @@ -2169,7 +2144,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
>  
>      avctx->pix_fmt = mpeg_get_pixelformat(avctx);
>  
> -    ff_mpv_idct_init(s);
>      if ((ret = ff_mpv_common_init(s)) < 0)
>          return ret;
>      s1->mpeg_enc_ctx_allocated = 1;

Will apply patches 5-8 tomorrow 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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 11/12] avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 11/12] avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags Andreas Rheinhardt
@ 2023-10-04 17:26   ` Michael Niedermayer
  0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-04 17:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 555 bytes --]

On Tue, Oct 03, 2023 at 06:04:03PM +0200, Andreas Rheinhardt wrote:
> These flags will be overwritten later in ff_mpv_frame_start().
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/h261dec.c   |  7 -------
>  libavcodec/mpeg12dec.c | 10 ----------
>  libavcodec/vc1dec.c    |  7 -------
>  3 files changed, 24 deletions(-)

probably ok

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

Never trust a computer, one day, it may think you are the virus. -- Compn

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT Andreas Rheinhardt
@ 2023-10-04 17:27   ` Michael Niedermayer
  2023-10-06  1:42   ` Vittorio Giovara
  1 sibling, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-04 17:27 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 588 bytes --]

On Tue, Oct 03, 2023 at 06:04:02PM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/rv10.c | 21 +++++----------------
>  1 file changed, 5 insertions(+), 16 deletions(-)

ok

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

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 09/12] avcodec/rv10: Remove dead code
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 09/12] avcodec/rv10: Remove dead code Andreas Rheinhardt
@ 2023-10-04 17:28   ` Michael Niedermayer
  0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-04 17:28 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 487 bytes --]

On Tue, Oct 03, 2023 at 06:04:01PM +0200, Andreas Rheinhardt wrote:
> Dead since 248a1aa54c08b14e8bd49147f59d954c41b5b3a3.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/rv10.c | 3 ---
>  1 file changed, 3 deletions(-)

ok

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT Andreas Rheinhardt
  2023-10-04 17:27   ` Michael Niedermayer
@ 2023-10-06  1:42   ` Vittorio Giovara
  2023-10-06  2:03     ` Andreas Rheinhardt
  1 sibling, 1 reply; 22+ messages in thread
From: Vittorio Giovara @ 2023-10-06  1:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt

On Tue, Oct 3, 2023 at 12:03 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/rv10.c | 21 +++++----------------
>  1 file changed, 5 insertions(+), 16 deletions(-)
>
> diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
> index 3f9d5ff242..216328ffe7 100644
> --- a/libavcodec/rv10.c
> +++ b/libavcodec/rv10.c
> @@ -158,25 +158,14 @@ static int rv10_decode_picture_header(MpegEncContext
> *s)
>
>  static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
>  {
> +    static const enum AVPictureType pict_types[] =
> +        { AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_I /* hmm ... */,
>

Any chance we could replace this comment with something more detailed (or
remove it if not needed)?
-- 
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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT
  2023-10-06  1:42   ` Vittorio Giovara
@ 2023-10-06  2:03     ` Andreas Rheinhardt
  2023-10-07 16:44       ` Michael Niedermayer
  0 siblings, 1 reply; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-06  2:03 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Vittorio Giovara:
> On Tue, Oct 3, 2023 at 12:03 PM Andreas Rheinhardt <
> andreas.rheinhardt@outlook.com> wrote:
> 
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavcodec/rv10.c | 21 +++++----------------
>>  1 file changed, 5 insertions(+), 16 deletions(-)
>>
>> diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
>> index 3f9d5ff242..216328ffe7 100644
>> --- a/libavcodec/rv10.c
>> +++ b/libavcodec/rv10.c
>> @@ -158,25 +158,14 @@ static int rv10_decode_picture_header(MpegEncContext
>> *s)
>>
>>  static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
>>  {
>> +    static const enum AVPictureType pict_types[] =
>> +        { AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_I /* hmm ... */,
>>
> 
> Any chance we could replace this comment with something more detailed (or
> remove it if not needed)?

The comment has been added when the mapping for 1 was added in
248a1aa54c0 (which made the default case dead code). I simply preserved
it, Michael probably added it to show that he was not completely sure. I
don't know whether there are different semantics for the two values.
I do not object to the removal of this comment.

- 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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 12/12] avcodec/mpegvideo: Move allocating new_picture to the encoder
  2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 12/12] avcodec/mpegvideo: Move allocating new_picture to the encoder Andreas Rheinhardt
@ 2023-10-06  2:21   ` Andreas Rheinhardt
  0 siblings, 0 replies; 22+ messages in thread
From: Andreas Rheinhardt @ 2023-10-06  2:21 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> It is only used by encoders; this unfortunately necessitated
> to add separate allocations to the SVQ1 encoder which uses
> motion estimation without being a full member of mpegvideo.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpegvideo.c     | 5 +----
>  libavcodec/mpegvideo_enc.c | 3 ++-
>  libavcodec/svq1enc.c       | 6 ++++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
> index fc73abab9c..9ed158ac57 100644
> --- a/libavcodec/mpegvideo.c
> +++ b/libavcodec/mpegvideo.c
> @@ -632,7 +632,6 @@ static void clear_context(MpegEncContext *s)
>      memset(&s->next_picture, 0, sizeof(s->next_picture));
>      memset(&s->last_picture, 0, sizeof(s->last_picture));
>      memset(&s->current_picture, 0, sizeof(s->current_picture));
> -    memset(&s->new_picture, 0, sizeof(s->new_picture));
>  
>      memset(s->thread_context, 0, sizeof(s->thread_context));
>  
> @@ -720,8 +719,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
>  
>      if (!(s->next_picture.f    = av_frame_alloc()) ||
>          !(s->last_picture.f    = av_frame_alloc()) ||
> -        !(s->current_picture.f = av_frame_alloc()) ||
> -        !(s->new_picture       = av_frame_alloc()))
> +        !(s->current_picture.f = av_frame_alloc()))
>          goto fail_nomem;
>  
>      if ((ret = ff_mpv_init_context_frame(s)))
> @@ -801,7 +799,6 @@ void ff_mpv_common_end(MpegEncContext *s)
>      ff_mpv_picture_free(s->avctx, &s->last_picture);
>      ff_mpv_picture_free(s->avctx, &s->current_picture);
>      ff_mpv_picture_free(s->avctx, &s->next_picture);
> -    av_frame_free(&s->new_picture);
>  
>      s->context_initialized      = 0;
>      s->context_reinit           = 0;
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index 5bf4b06a11..f669658127 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -821,7 +821,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
>          !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) ||
>          !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16,        32) ||
>          !FF_ALLOCZ_TYPED_ARRAY(s->input_picture,           MAX_PICTURE_COUNT) ||
> -        !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT))
> +        !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT) ||
> +        !(s->new_picture = av_frame_alloc()))
>          return AVERROR(ENOMEM);
>  
>      /* Allocate MV tables; the MV and MB tables will be copied
> diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
> index 46a484e15f..894ae552bb 100644
> --- a/libavcodec/svq1enc.c
> +++ b/libavcodec/svq1enc.c
> @@ -570,6 +570,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
>  
>      av_frame_free(&s->current_picture);
>      av_frame_free(&s->last_picture);
> +    av_frame_free(&s->m.new_picture);
>  
>      return 0;
>  }
> @@ -632,10 +633,11 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
>      s->dummy               = av_mallocz((s->y_block_width + 1) *
>                                          s->y_block_height * sizeof(int32_t));
>      s->m.me.map            = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->m.me.map));
> +    s->m.new_picture       = av_frame_alloc();
>      s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
>  
> -    if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map ||
> -        !s->mb_type || !s->dummy)
> +    if (!s->m.me.scratchpad || !s->m.me.map ||
> +        !s->mb_type || !s->dummy || !s->m.new_picture)
>          return AVERROR(ENOMEM);
>      s->m.me.score_map = s->m.me.map + ME_MAP_SIZE;
>  

Will apply this patch 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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT
  2023-10-06  2:03     ` Andreas Rheinhardt
@ 2023-10-07 16:44       ` Michael Niedermayer
  0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-07 16:44 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1919 bytes --]

On Fri, Oct 06, 2023 at 04:03:40AM +0200, Andreas Rheinhardt wrote:
> Vittorio Giovara:
> > On Tue, Oct 3, 2023 at 12:03 PM Andreas Rheinhardt <
> > andreas.rheinhardt@outlook.com> wrote:
> > 
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >>  libavcodec/rv10.c | 21 +++++----------------
> >>  1 file changed, 5 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
> >> index 3f9d5ff242..216328ffe7 100644
> >> --- a/libavcodec/rv10.c
> >> +++ b/libavcodec/rv10.c
> >> @@ -158,25 +158,14 @@ static int rv10_decode_picture_header(MpegEncContext
> >> *s)
> >>
> >>  static int rv20_decode_picture_header(RVDecContext *rv, int whole_size)
> >>  {
> >> +    static const enum AVPictureType pict_types[] =
> >> +        { AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_I /* hmm ... */,
> >>
> > 
> > Any chance we could replace this comment with something more detailed (or
> > remove it if not needed)?
> 
> The comment has been added when the mapping for 1 was added in
> 248a1aa54c0 (which made the default case dead code). I simply preserved
> it, Michael probably added it to show that he was not completely sure. I
> don't know whether there are different semantics for the two values.
> I do not object to the removal of this comment.

Its a bit odd when 2 values mean the same thing in a reverse engeneered
format. One kind of thinks, that there is likely some difference that we
just dont know about. maybe teh comment could elaborate in this direction
and or someone could recheck if this is still the current best knowledge ...

thx

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-10-07 16:44 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-30 18:02 [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 2/4] avcodec/mpegvideo_dec: Don't memset twice Andreas Rheinhardt
2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_dec: Remove commented-out legacy cruft Andreas Rheinhardt
2023-10-01 20:29   ` Michael Niedermayer
2023-09-30 18:02 ` [FFmpeg-devel] [PATCH 4/4] avcodec/h264_slice: Don't keep AVCodecContext props in sync manually Andreas Rheinhardt
2023-10-02 10:51 ` [FFmpeg-devel] [PATCH 5/8] avcodec/mpeg12dec: Don't initialize IDCT more than once Andreas Rheinhardt
2023-10-03 22:14   ` Andreas Rheinhardt
2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 6/8] avcodec/mpegvideo_dec: Don't zero context on init failure Andreas Rheinhardt
2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 7/8] avcodec/mpegvideo_dec: Always initialize IDCTDSPContext during init Andreas Rheinhardt
2023-10-02 10:52 ` [FFmpeg-devel] [PATCH 8/8] avcodec/h263dec, mpeg4videodec: Parse extradata " Andreas Rheinhardt
2023-10-02 23:39 ` [FFmpeg-devel] [PATCH 1/4] avcodec/mpegvideo_dec: Check for existence of planes before accesses Andreas Rheinhardt
2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 09/12] avcodec/rv10: Remove dead code Andreas Rheinhardt
2023-10-04 17:28   ` Michael Niedermayer
2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 10/12] avcodec/rv10: Replace switch by LUT Andreas Rheinhardt
2023-10-04 17:27   ` Michael Niedermayer
2023-10-06  1:42   ` Vittorio Giovara
2023-10-06  2:03     ` Andreas Rheinhardt
2023-10-07 16:44       ` Michael Niedermayer
2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 11/12] avcodec/h261dec, mpeg12dec, vc1dec: Remove setting write-only flags Andreas Rheinhardt
2023-10-04 17:26   ` Michael Niedermayer
2023-10-03 16:04 ` [FFmpeg-devel] [PATCH 12/12] avcodec/mpegvideo: Move allocating new_picture to the encoder Andreas Rheinhardt
2023-10-06  2:21   ` Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git