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 01/13] avcodec/h261enc: Use LUT to write motion vector differences
@ 2024-07-01 12:01 Andreas Rheinhardt
  2024-07-01 12:15 ` [FFmpeg-devel] [PATCH 02/13] avcodec/mpeg12dec: Move resetting last_dc to decoder Andreas Rheinhardt
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:01 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261enc.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index a901c32e42..d3d724bef6 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -39,6 +39,7 @@
 #define H261_MAX_RUN   26
 #define H261_MAX_LEVEL 15
 #define H261_ESC_LEN   (6 + 6 + 8)
+#define MV_TAB_OFFSET  32
 
 static struct VLCLUT {
     uint8_t len;
@@ -47,6 +48,7 @@ static struct VLCLUT {
 
 static uint8_t uni_h261_rl_len     [64 * 128];
 static uint8_t uni_h261_rl_len_last[64 * 128];
+static uint8_t h261_mv_codes[64][2];
 
 typedef struct H261EncContext {
     MpegEncContext s;
@@ -140,20 +142,8 @@ void ff_h261_reorder_mb_index(MpegEncContext *s)
 
 static void h261_encode_motion(PutBitContext *pb, int val)
 {
-    int sign, code;
-    if (val == 0) {
-        // Corresponds to ff_h261_mv_tab[0]
-        put_bits(pb, 1, 1);
-    } else {
-        if (val > 15)
-            val -= 32;
-        if (val < -16)
-            val += 32;
-        sign = val < 0;
-        code = sign ? -val : val;
-        put_bits(pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]);
-        put_bits(pb, 1, sign);
-    }
+    put_bits(pb, h261_mv_codes[MV_TAB_OFFSET + val][1],
+                 h261_mv_codes[MV_TAB_OFFSET + val][0]);
 }
 
 static inline int get_cbp(MpegEncContext *s, int16_t block[6][64])
@@ -323,6 +313,7 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
 
 static av_cold void h261_encode_init_static(void)
 {
+    uint8_t (*const mv_codes)[2] = h261_mv_codes + MV_TAB_OFFSET;
     memset(uni_h261_rl_len,      H261_ESC_LEN, sizeof(uni_h261_rl_len));
     memset(uni_h261_rl_len_last, H261_ESC_LEN + 2 /* EOB */, sizeof(uni_h261_rl_len_last));
 
@@ -341,6 +332,20 @@ static av_cold void h261_encode_init_static(void)
         uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 + level)] = len + 2;
         uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 - level)] = len + 2;
     }
+
+    for (size_t i = 1;; i++) {
+        // sign-one MV codes; diff -16..-1, 16..31
+        mv_codes[32 - i][0] = mv_codes[-i][0] = (ff_h261_mv_tab[i][0] << 1) | 1 /* sign */;
+        mv_codes[32 - i][1] = mv_codes[-i][1] = ff_h261_mv_tab[i][1] + 1;
+        if (i == 16)
+            break;
+        // sign-zero MV codes: diff -31..-17, 1..15
+        mv_codes[i][0] = mv_codes[i - 32][0] = ff_h261_mv_tab[i][0] << 1;
+        mv_codes[i][1] = mv_codes[i - 32][1] = ff_h261_mv_tab[i][1] + 1;
+    }
+    // MV code for difference zero; has no sign
+    mv_codes[0][0] = 1;
+    mv_codes[0][1] = 1;
 }
 
 av_cold int ff_h261_encode_init(MpegEncContext *s)
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 02/13] avcodec/mpeg12dec: Move resetting last_dc to decoder
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
@ 2024-07-01 12:15 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 03/13] avcodec/mpeg12enc: Move resetting last_dc to encoder Andreas Rheinhardt
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Only the MPEG-1/2, MSMPEG4V1, MPEG-4 and RV.10 decoders use last_dc
at all. Of these, RV.10 only uses it for intra frames; it does not
need these predictors reset in ff_mpv_reconstruct_mb(). MSMPEG4V1
has h263_pred set, so that last_dc is already not reset in
ff_mpv_reconstruct_mb() (instead it is reset at the beginning
of every line). MPEG-4 also has h263_pred set (and uses last_dc only
for the intra-only studio profile and needs them reset to sligthly
different values anyway).

So only the MPEG-1/2 decoders need these values reset. So move
resetting them there. This avoids resetting them unnecessarily
for FLV1, H.261, H.263I, RV.10, RV.20 and H.263(+)
(for the latter it depends upon whether h263_aic is in use).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg12dec.c                   | 2 ++
 libavcodec/mpv_reconstruct_mb_template.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index bb0a769e49..a15318e1bc 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -712,6 +712,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
         }
 
         s->mb_intra = 0;
+        s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision;
         if (HAS_CBP(mb_type)) {
             s->bdsp.clear_blocks(s->block[0]);
 
@@ -1630,6 +1631,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
                 s->mb_intra = 0;
                 for (i = 0; i < 12; i++)
                     s->block_last_index[i] = -1;
+                s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision;
                 if (s->picture_structure == PICT_FRAME)
                     s->mv_type = MV_TYPE_16X16;
                 else
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index dca982ae0f..4db85afef6 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -66,7 +66,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
         if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic)) {
             if (s->mbintra_table[mb_xy])
                 ff_clean_intra_table_entries(s);
-        } else {
+        } else if (IS_ENCODER) {
             s->last_dc[0] =
             s->last_dc[1] =
             s->last_dc[2] = 128 << s->intra_dc_precision;
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 03/13] avcodec/mpeg12enc: Move resetting last_dc to encoder
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
  2024-07-01 12:15 ` [FFmpeg-devel] [PATCH 02/13] avcodec/mpeg12dec: Move resetting last_dc to decoder Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 04/13] avcodec/h263dec: Clean intra tables in decoder, not ff_mpv_reconstruct_mb Andreas Rheinhardt
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The MPEG-1/2 encoders are the only non-intra-only mpegvideo
encoders that want last_dc reset when encoding non-intra macroblocks.
Therefore move resetting it to mpeg12enc.c.

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

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e35c916b61..72b2caab7e 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1067,6 +1067,8 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
 void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
                         int motion_x, int motion_y)
 {
+    if (!s->mb_intra)
+        s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 128 << s->intra_dc_precision;
     if (s->chroma_format == CHROMA_420)
         mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 6, 1);
     else
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index 4db85afef6..f1cb0d7989 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -66,10 +66,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
         if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic)) {
             if (s->mbintra_table[mb_xy])
                 ff_clean_intra_table_entries(s);
-        } else if (IS_ENCODER) {
-            s->last_dc[0] =
-            s->last_dc[1] =
-            s->last_dc[2] = 128 << s->intra_dc_precision;
         }
     } else if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic))
         s->mbintra_table[mb_xy] = 1;
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 04/13] avcodec/h263dec: Clean intra tables in decoder, not ff_mpv_reconstruct_mb
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
  2024-07-01 12:15 ` [FFmpeg-devel] [PATCH 02/13] avcodec/mpeg12dec: Move resetting last_dc to decoder Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 03/13] avcodec/mpeg12enc: Move resetting last_dc to encoder Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 05/13] avcodec/mpegvideo_enc: Don't reset intra buffers in mpv_reconstruct_mb() Andreas Rheinhardt
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This is a more appropriate place than a function designed
to reconstruct a macroblock. It furthermore limits these checks
to the codecs that actually need it (and removes it from e.g.
RV10 and RV20 -- the latter actually uses these buffers, but
only for intra-frames, so they don't need to be cleaned
manually).

This furthermore means that ff_mpv_reconstruct_mb() and therefore
also the error-resilience code no longer needs block_index set.
This fixes a crash caused by 65d5ccb808ec93de46a2458ea8cc082ce4460f34
when ff_mpv_reconstruct_mb() is called by VC-1 code without
block_index being initialized properly (VC-1 uses and initializes
block_index itself normally).

Fixes: 69814/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-4868081575329792
Fixes: heap-buffer-overflow

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h263dec.c                     | 9 +++++++++
 libavcodec/mpv_reconstruct_mb_template.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 0c23012584..3e9da23d3a 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -271,6 +271,15 @@ static int decode_slice(MpegEncContext *s)
             ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y);
             ret = s->decode_mb(s, s->block);
 
+            if (s->h263_pred || s->h263_aic) {
+                int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
+                if (!s->mb_intra) {
+                    if (s->mbintra_table[mb_xy])
+                        ff_clean_intra_table_entries(s);
+                } else
+                    s->mbintra_table[mb_xy] = 1;
+            }
+
             if (s->pict_type != AV_PICTURE_TYPE_B)
                 ff_h263_update_motion_val(s);
 
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index f1cb0d7989..981c837642 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -61,6 +61,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
 
     s->cur_pic.qscale_table[mb_xy] = s->qscale;
 
+#if IS_ENCODER
     /* update DC predictors for P macroblocks */
     if (!s->mb_intra) {
         if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic)) {
@@ -70,7 +71,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
     } else if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic))
         s->mbintra_table[mb_xy] = 1;
 
-#if IS_ENCODER
     if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->frame_skip_threshold || s->frame_skip_factor ||
         !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
           s->avctx->mb_decision != FF_MB_DECISION_RD))  // FIXME precalc
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 05/13] avcodec/mpegvideo_enc: Don't reset intra buffers in mpv_reconstruct_mb()
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 04/13] avcodec/h263dec: Clean intra tables in decoder, not ff_mpv_reconstruct_mb Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 06/13] avcodec/mpv_reconstruct_mb_template: Merge template into its users Andreas Rheinhardt
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is not part of reconstructing the macroblock.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c               | 11 ++++-------
 libavcodec/mpv_reconstruct_mb_template.c |  9 ---------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 620ca08869..31c5dd4736 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3188,12 +3188,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
                     s->mv[0][0][1] = 0;
                     encode_mb_hq(s, &backup_s, &best_s, pb, pb2, tex_pb,
                                  &dmin, &next_block, 0, 0);
-                    if(s->h263_pred || s->h263_aic){
-                        if(best_s.mb_intra)
-                            s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
-                        else
-                            ff_clean_intra_table_entries(s); //old mode?
-                    }
+                    s->mbintra_table[xy] = 1;
                 }
 
                 if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) {
@@ -3340,6 +3335,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
                     s->mb_intra= 1;
                     motion_x= s->mv[0][0][0] = 0;
                     motion_y= s->mv[0][0][1] = 0;
+                    s->mbintra_table[xy] = 1;
                     break;
                 case CANDIDATE_MB_TYPE_INTER:
                     s->mv_dir = MV_DIR_FORWARD;
@@ -3454,7 +3450,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
             if(s->mb_intra /* && I,P,S_TYPE */){
                 s->p_mv_table[xy][0]=0;
                 s->p_mv_table[xy][1]=0;
-            }
+            } else if ((s->h263_pred || s->h263_aic) && s->mbintra_table[xy])
+                ff_clean_intra_table_entries(s);
 
             if (s->avctx->flags & AV_CODEC_FLAG_PSNR) {
                 int w= 16;
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index 981c837642..ae7a9e34ce 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -62,15 +62,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
     s->cur_pic.qscale_table[mb_xy] = s->qscale;
 
 #if IS_ENCODER
-    /* update DC predictors for P macroblocks */
-    if (!s->mb_intra) {
-        if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic)) {
-            if (s->mbintra_table[mb_xy])
-                ff_clean_intra_table_entries(s);
-        }
-    } else if (is_mpeg12 != DEFINITELY_MPEG12_H261 && (s->h263_pred || s->h263_aic))
-        s->mbintra_table[mb_xy] = 1;
-
     if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->frame_skip_threshold || s->frame_skip_factor ||
         !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
           s->avctx->mb_decision != FF_MB_DECISION_RD))  // FIXME precalc
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 06/13] avcodec/mpv_reconstruct_mb_template: Merge template into its users
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 05/13] avcodec/mpegvideo_enc: Don't reset intra buffers in mpv_reconstruct_mb() Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 13:04   ` Rémi Denis-Courmont
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 07/13] avcodec/mpegvideo_{dec, enc}: Reindent after the previous commit Andreas Rheinhardt
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

A large part of this template is decoder-only. This makes
the complexity of the IS_ENCODER-checks not worth it.
So simply merge the template into both its users.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_dec.c               | 218 +++++++++++++++++-
 libavcodec/mpegvideo_enc.c               |  81 ++++++-
 libavcodec/mpv_reconstruct_mb_template.c | 272 -----------------------
 3 files changed, 294 insertions(+), 277 deletions(-)
 delete mode 100644 libavcodec/mpv_reconstruct_mb_template.c

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 1cab108935..2222d50283 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -904,11 +904,225 @@ static inline void add_dct(MpegEncContext *s,
     }
 }
 
-#define IS_ENCODER 0
-#include "mpv_reconstruct_mb_template.c"
+/* put block[] to dest[] */
+static inline void put_dct(MpegEncContext *s,
+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
+{
+    s->dct_unquantize_intra(s, block, i, qscale);
+    s->idsp.idct_put(dest, line_size, block);
+}
+
+static inline void add_dequant_dct(MpegEncContext *s,
+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
+{
+    if (s->block_last_index[i] >= 0) {
+        s->dct_unquantize_inter(s, block, i, qscale);
+
+        s->idsp.idct_add(dest, line_size, block);
+    }
+}
+
+#define NOT_MPEG12_H261        0
+#define MAY_BE_MPEG12_H261     1
+#define DEFINITELY_MPEG12_H261 2
+
+/* generic function called after a macroblock has been parsed by the decoder.
+
+   Important variables used:
+   s->mb_intra : true if intra macroblock
+   s->mv_dir   : motion vector direction
+   s->mv_type  : motion vector type
+   s->mv       : motion vector
+   s->interlaced_dct : true if interlaced dct used (mpeg2)
+ */
+static av_always_inline
+void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
+                                 int lowres_flag, int is_mpeg12)
+{
+#define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12)
+    {
+        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
+        int dct_linesize, dct_offset;
+        const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics
+        const int uvlinesize = s->cur_pic.linesize[1];
+        const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
+
+        dct_linesize = linesize << s->interlaced_dct;
+        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
+
+        if (!s->mb_intra) {
+            /* motion handling */
+            if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 &&
+                s->avctx->active_thread_type & FF_THREAD_FRAME) {
+                if (s->mv_dir & MV_DIR_FORWARD) {
+                    ff_thread_progress_await(&s->last_pic.ptr->progress,
+                                             lowest_referenced_row(s, 0));
+                }
+                if (s->mv_dir & MV_DIR_BACKWARD) {
+                    ff_thread_progress_await(&s->next_pic.ptr->progress,
+                                             lowest_referenced_row(s, 1));
+                }
+            }
+
+            if (lowres_flag) {
+                const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
+
+                if (s->mv_dir & MV_DIR_FORWARD) {
+                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix);
+                    op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
+                }
+                if (s->mv_dir & MV_DIR_BACKWARD) {
+                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix);
+                }
+            } else {
+                const op_pixels_func (*op_pix)[4];
+                const qpel_mc_func (*op_qpix)[16];
+
+                if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
+                    op_pix = s->hdsp.put_pixels_tab;
+                    op_qpix = s->qdsp.put_qpel_pixels_tab;
+                } else {
+                    op_pix = s->hdsp.put_no_rnd_pixels_tab;
+                    op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
+                }
+                if (s->mv_dir & MV_DIR_FORWARD) {
+                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix);
+                    op_pix  = s->hdsp.avg_pixels_tab;
+                    op_qpix = s->qdsp.avg_qpel_pixels_tab;
+                }
+                if (s->mv_dir & MV_DIR_BACKWARD) {
+                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix);
+                }
+            }
+
+            /* skip dequant / idct if we are really late ;) */
+            if (s->avctx->skip_idct) {
+                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
+                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
+                   || s->avctx->skip_idct >= AVDISCARD_ALL)
+                    return;
+            }
+
+            /* add dct residue */
+            if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
+                  (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) {
+                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                    av_assert2(s->chroma_y_shift);
+                    add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                    add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                }
+            } else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
+                add_dct(s, block[0], 0, dest_y                          , dct_linesize);
+                add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
+                add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
+                add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
+
+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                    if (s->chroma_y_shift) {//Chroma420
+                        add_dct(s, block[4], 4, dest_cb, uvlinesize);
+                        add_dct(s, block[5], 5, dest_cr, uvlinesize);
+                    } else {
+                        //chroma422
+                        dct_linesize = uvlinesize << s->interlaced_dct;
+                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
+
+                        add_dct(s, block[4], 4, dest_cb, dct_linesize);
+                        add_dct(s, block[5], 5, dest_cr, dct_linesize);
+                        add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
+                        add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
+                        if (!s->chroma_x_shift) {//Chroma444
+                            add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
+                            add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
+                            add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
+                            add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
+                        }
+                    }
+                } //fi gray
+            } else if (CONFIG_WMV2_DECODER) {
+                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
+            }
+        } else {
+            /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
+               TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
+            if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER &&
+                /* s->codec_id == AV_CODEC_ID_MPEG4 && */
+                s->avctx->bits_per_raw_sample > 8) {
+                ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
+                                       uvlinesize, dct_linesize, dct_offset);
+            } else if (!IS_MPEG12_H261(s)) {
+                /* dct only in intra block */
+                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                    if (s->chroma_y_shift) {
+                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                    } else {
+                        dct_offset >>=1;
+                        dct_linesize >>=1;
+                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
+                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
+                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
+                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
+                    }
+                }
+            } else {
+                s->idsp.idct_put(dest_y,                           dct_linesize, block[0]);
+                s->idsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
+                s->idsp.idct_put(dest_y + dct_offset,              dct_linesize, block[2]);
+                s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
+
+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                    if (s->chroma_y_shift) {
+                        s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
+                        s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
+                    } else {
+                        dct_linesize = uvlinesize << s->interlaced_dct;
+                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
+
+                        s->idsp.idct_put(dest_cb,              dct_linesize, block[4]);
+                        s->idsp.idct_put(dest_cr,              dct_linesize, block[5]);
+                        s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
+                        s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
+                        if (!s->chroma_x_shift) { //Chroma444
+                            s->idsp.idct_put(dest_cb + block_size,              dct_linesize, block[8]);
+                            s->idsp.idct_put(dest_cr + block_size,              dct_linesize, block[9]);
+                            s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
+                            s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
+                        }
+                    }
+                } //gray
+            }
+        }
+    }
+}
 
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
+    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
+            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
+
+    s->cur_pic.qscale_table[mb_xy] = s->qscale;
+
+        /* avoid copy if macroblock skipped in last frame too */
+            if (s->mb_skipped) {
+                s->mb_skipped = 0;
+                av_assert2(s->pict_type!=AV_PICTURE_TYPE_I);
+                *mbskip_ptr = 1;
+            } else if (!s->cur_pic.reference) {
+                *mbskip_ptr = 1;
+            } else{
+                *mbskip_ptr = 0; /* not skipped */
+            }
+
     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
        /* print DCT coefficients */
        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 31c5dd4736..774d16edad 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1082,11 +1082,33 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
     return 0;
 }
 
-#define IS_ENCODER 1
-#include "mpv_reconstruct_mb_template.c"
+/* put block[] to dest[] */
+static inline void put_dct(MpegEncContext *s,
+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
+{
+    s->dct_unquantize_intra(s, block, i, qscale);
+    s->idsp.idct_put(dest, line_size, block);
+}
 
+static inline void add_dequant_dct(MpegEncContext *s,
+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
+{
+    if (s->block_last_index[i] >= 0) {
+        s->dct_unquantize_inter(s, block, i, qscale);
+
+        s->idsp.idct_add(dest, line_size, block);
+    }
+}
+
+/**
+ * Performs dequantization and IDCT (if necessary)
+ */
 static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
+    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
+
+    s->cur_pic.qscale_table[mb_xy] = s->qscale;
+
     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
        /* print DCT coefficients */
        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
@@ -1099,7 +1121,60 @@ static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
        }
     }
 
-    mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12_H261);
+    if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->frame_skip_threshold || s->frame_skip_factor ||
+        !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
+          s->avctx->mb_decision != FF_MB_DECISION_RD)) { // FIXME precalc
+        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
+        int dct_linesize, dct_offset;
+        const int linesize   = s->cur_pic.linesize[0];
+        const int uvlinesize = s->cur_pic.linesize[1];
+        const int block_size = 8;
+
+        dct_linesize = linesize << s->interlaced_dct;
+        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
+
+        if (!s->mb_intra) {
+            /* No MC, as that was already done otherwise */
+                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                    if (s->chroma_y_shift) {
+                        add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                        add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                    } else {
+                        dct_linesize >>= 1;
+                        dct_offset   >>= 1;
+                        add_dequant_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
+                        add_dequant_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
+                        add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
+                        add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
+                    }
+                }
+        } else {
+                /* dct only in intra block */
+                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                    if (s->chroma_y_shift) {
+                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                    } else {
+                        dct_offset >>=1;
+                        dct_linesize >>=1;
+                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
+                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
+                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
+                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
+                    }
+                }
+        }
+    }
 }
 
 static int get_sae(const uint8_t *src, int ref, int stride)
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
deleted file mode 100644
index ae7a9e34ce..0000000000
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * MPEG macroblock reconstruction
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define NOT_MPEG12_H261        0
-#define MAY_BE_MPEG12_H261     1
-#define DEFINITELY_MPEG12_H261 2
-
-/* put block[] to dest[] */
-static inline void put_dct(MpegEncContext *s,
-                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
-{
-    s->dct_unquantize_intra(s, block, i, qscale);
-    s->idsp.idct_put(dest, line_size, block);
-}
-
-static inline void add_dequant_dct(MpegEncContext *s,
-                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
-{
-    if (s->block_last_index[i] >= 0) {
-        s->dct_unquantize_inter(s, block, i, qscale);
-
-        s->idsp.idct_add(dest, line_size, block);
-    }
-}
-
-/* generic function called after a macroblock has been parsed by the
-   decoder or after it has been encoded by the encoder.
-
-   Important variables used:
-   s->mb_intra : true if intra macroblock
-   s->mv_dir   : motion vector direction
-   s->mv_type  : motion vector type
-   s->mv       : motion vector
-   s->interlaced_dct : true if interlaced dct used (mpeg2)
- */
-static av_always_inline
-void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
-                                 int lowres_flag, int is_mpeg12)
-{
-#define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12)
-    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-
-    s->cur_pic.qscale_table[mb_xy] = s->qscale;
-
-#if IS_ENCODER
-    if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->frame_skip_threshold || s->frame_skip_factor ||
-        !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
-          s->avctx->mb_decision != FF_MB_DECISION_RD))  // FIXME precalc
-#endif /* IS_ENCODER */
-    {
-        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
-        int dct_linesize, dct_offset;
-        const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics
-        const int uvlinesize = s->cur_pic.linesize[1];
-        const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
-
-        /* avoid copy if macroblock skipped in last frame too */
-        /* skip only during decoding as we might trash the buffers during encoding a bit */
-        if (!IS_ENCODER) {
-            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
-
-            if (s->mb_skipped) {
-                s->mb_skipped = 0;
-                av_assert2(s->pict_type!=AV_PICTURE_TYPE_I);
-                *mbskip_ptr = 1;
-            } else if (!s->cur_pic.reference) {
-                *mbskip_ptr = 1;
-            } else{
-                *mbskip_ptr = 0; /* not skipped */
-            }
-        }
-
-        dct_linesize = linesize << s->interlaced_dct;
-        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
-
-        if (!s->mb_intra) {
-            /* motion handling */
-            /* decoding or more than one mb_type (MC was already done otherwise) */
-
-#if !IS_ENCODER
-            if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 &&
-                s->avctx->active_thread_type & FF_THREAD_FRAME) {
-                if (s->mv_dir & MV_DIR_FORWARD) {
-                    ff_thread_progress_await(&s->last_pic.ptr->progress,
-                                             lowest_referenced_row(s, 0));
-                }
-                if (s->mv_dir & MV_DIR_BACKWARD) {
-                    ff_thread_progress_await(&s->next_pic.ptr->progress,
-                                             lowest_referenced_row(s, 1));
-                }
-            }
-
-            if (lowres_flag) {
-                const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
-
-                if (s->mv_dir & MV_DIR_FORWARD) {
-                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix);
-                    op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
-                }
-                if (s->mv_dir & MV_DIR_BACKWARD) {
-                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix);
-                }
-            } else {
-                const op_pixels_func (*op_pix)[4];
-                const qpel_mc_func (*op_qpix)[16];
-
-                if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
-                    op_pix = s->hdsp.put_pixels_tab;
-                    op_qpix = s->qdsp.put_qpel_pixels_tab;
-                } else {
-                    op_pix = s->hdsp.put_no_rnd_pixels_tab;
-                    op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
-                }
-                if (s->mv_dir & MV_DIR_FORWARD) {
-                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix);
-                    op_pix  = s->hdsp.avg_pixels_tab;
-                    op_qpix = s->qdsp.avg_qpel_pixels_tab;
-                }
-                if (s->mv_dir & MV_DIR_BACKWARD) {
-                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix);
-                }
-            }
-
-            /* skip dequant / idct if we are really late ;) */
-            if (s->avctx->skip_idct) {
-                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
-                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
-                   || s->avctx->skip_idct >= AVDISCARD_ALL)
-                    return;
-            }
-
-            /* add dct residue */
-            if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
-                  (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant)))
-#endif /* !IS_ENCODER */
-            {
-                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    av_assert2(IS_ENCODER || s->chroma_y_shift);
-                    if (!IS_ENCODER || s->chroma_y_shift) {
-                        add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                    } else {
-                        dct_linesize >>= 1;
-                        dct_offset   >>= 1;
-                        add_dequant_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
-                    }
-                }
-            }
-#if !IS_ENCODER
-              else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
-                add_dct(s, block[0], 0, dest_y                          , dct_linesize);
-                add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
-                add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
-                add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {//Chroma420
-                        add_dct(s, block[4], 4, dest_cb, uvlinesize);
-                        add_dct(s, block[5], 5, dest_cr, uvlinesize);
-                    } else {
-                        //chroma422
-                        dct_linesize = uvlinesize << s->interlaced_dct;
-                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
-
-                        add_dct(s, block[4], 4, dest_cb, dct_linesize);
-                        add_dct(s, block[5], 5, dest_cr, dct_linesize);
-                        add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
-                        add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
-                        if (!s->chroma_x_shift) {//Chroma444
-                            add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
-                            add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
-                            add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
-                            add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
-                        }
-                    }
-                } //fi gray
-            } else if (CONFIG_WMV2_DECODER) {
-                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
-            }
-#endif /* !IS_ENCODER */
-        } else {
-#if !IS_ENCODER
-            /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
-               TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
-            if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER &&
-                /* s->codec_id == AV_CODEC_ID_MPEG4 && */
-                s->avctx->bits_per_raw_sample > 8) {
-                ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
-                                       uvlinesize, dct_linesize, dct_offset);
-            } else if (!IS_MPEG12_H261(s))
-#endif /* !IS_ENCODER */
-            {
-                /* dct only in intra block */
-                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {
-                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                    } else {
-                        dct_offset >>=1;
-                        dct_linesize >>=1;
-                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
-                    }
-                }
-            }
-#if !IS_ENCODER
-              else {
-                s->idsp.idct_put(dest_y,                           dct_linesize, block[0]);
-                s->idsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
-                s->idsp.idct_put(dest_y + dct_offset,              dct_linesize, block[2]);
-                s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {
-                        s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
-                        s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
-                    } else {
-                        dct_linesize = uvlinesize << s->interlaced_dct;
-                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
-
-                        s->idsp.idct_put(dest_cb,              dct_linesize, block[4]);
-                        s->idsp.idct_put(dest_cr,              dct_linesize, block[5]);
-                        s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
-                        s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
-                        if (!s->chroma_x_shift) { //Chroma444
-                            s->idsp.idct_put(dest_cb + block_size,              dct_linesize, block[8]);
-                            s->idsp.idct_put(dest_cr + block_size,              dct_linesize, block[9]);
-                            s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
-                            s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
-                        }
-                    }
-                } //gray
-            }
-#endif /* !IS_ENCODER */
-        }
-    }
-}
-
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 07/13] avcodec/mpegvideo_{dec, enc}: Reindent after the previous commit
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 06/13] avcodec/mpv_reconstruct_mb_template: Merge template into its users Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 08/13] avcodec/mpegvideo_enc: Don't set qscale_table value prematurely Andreas Rheinhardt
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Could be squashed into the preceding commit.

 libavcodec/mpegvideo_dec.c | 318 ++++++++++++++++++-------------------
 libavcodec/mpegvideo_enc.c |  70 ++++----
 2 files changed, 193 insertions(+), 195 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 2222d50283..78fa10c11d 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -940,167 +940,165 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
                                  int lowres_flag, int is_mpeg12)
 {
 #define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12)
-    {
-        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
-        int dct_linesize, dct_offset;
-        const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics
-        const int uvlinesize = s->cur_pic.linesize[1];
-        const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
-
-        dct_linesize = linesize << s->interlaced_dct;
-        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
-
-        if (!s->mb_intra) {
-            /* motion handling */
-            if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 &&
-                s->avctx->active_thread_type & FF_THREAD_FRAME) {
-                if (s->mv_dir & MV_DIR_FORWARD) {
-                    ff_thread_progress_await(&s->last_pic.ptr->progress,
-                                             lowest_referenced_row(s, 0));
-                }
-                if (s->mv_dir & MV_DIR_BACKWARD) {
-                    ff_thread_progress_await(&s->next_pic.ptr->progress,
-                                             lowest_referenced_row(s, 1));
-                }
+    uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
+    int dct_linesize, dct_offset;
+    const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics
+    const int uvlinesize = s->cur_pic.linesize[1];
+    const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
+
+    dct_linesize = linesize << s->interlaced_dct;
+    dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
+
+    if (!s->mb_intra) {
+        /* motion handling */
+        if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 &&
+            s->avctx->active_thread_type & FF_THREAD_FRAME) {
+            if (s->mv_dir & MV_DIR_FORWARD) {
+                ff_thread_progress_await(&s->last_pic.ptr->progress,
+                                         lowest_referenced_row(s, 0));
+            }
+            if (s->mv_dir & MV_DIR_BACKWARD) {
+                ff_thread_progress_await(&s->next_pic.ptr->progress,
+                                         lowest_referenced_row(s, 1));
             }
+        }
 
-            if (lowres_flag) {
-                const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
+        if (lowres_flag) {
+            const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
 
-                if (s->mv_dir & MV_DIR_FORWARD) {
-                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix);
-                    op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
-                }
-                if (s->mv_dir & MV_DIR_BACKWARD) {
-                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix);
-                }
-            } else {
-                const op_pixels_func (*op_pix)[4];
-                const qpel_mc_func (*op_qpix)[16];
-
-                if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
-                    op_pix = s->hdsp.put_pixels_tab;
-                    op_qpix = s->qdsp.put_qpel_pixels_tab;
-                } else {
-                    op_pix = s->hdsp.put_no_rnd_pixels_tab;
-                    op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
-                }
-                if (s->mv_dir & MV_DIR_FORWARD) {
-                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix);
-                    op_pix  = s->hdsp.avg_pixels_tab;
-                    op_qpix = s->qdsp.avg_qpel_pixels_tab;
-                }
-                if (s->mv_dir & MV_DIR_BACKWARD) {
-                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix);
-                }
+            if (s->mv_dir & MV_DIR_FORWARD) {
+                MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix);
+                op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
+            }
+            if (s->mv_dir & MV_DIR_BACKWARD) {
+                MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix);
             }
+        } else {
+            const op_pixels_func (*op_pix)[4];
+            const qpel_mc_func (*op_qpix)[16];
 
-            /* skip dequant / idct if we are really late ;) */
-            if (s->avctx->skip_idct) {
-                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
-                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
-                   || s->avctx->skip_idct >= AVDISCARD_ALL)
-                    return;
+            if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
+                op_pix  = s->hdsp.put_pixels_tab;
+                op_qpix = s->qdsp.put_qpel_pixels_tab;
+            } else {
+                op_pix  = s->hdsp.put_no_rnd_pixels_tab;
+                op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
+            }
+            if (s->mv_dir & MV_DIR_FORWARD) {
+                ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix);
+                op_pix  = s->hdsp.avg_pixels_tab;
+                op_qpix = s->qdsp.avg_qpel_pixels_tab;
+            }
+            if (s->mv_dir & MV_DIR_BACKWARD) {
+                ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix);
             }
+        }
 
-            /* add dct residue */
-            if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
-                  (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) {
-                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    av_assert2(s->chroma_y_shift);
-                    add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                    add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                }
-            } else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
-                add_dct(s, block[0], 0, dest_y                          , dct_linesize);
-                add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
-                add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
-                add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {//Chroma420
-                        add_dct(s, block[4], 4, dest_cb, uvlinesize);
-                        add_dct(s, block[5], 5, dest_cr, uvlinesize);
-                    } else {
-                        //chroma422
-                        dct_linesize = uvlinesize << s->interlaced_dct;
-                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
-
-                        add_dct(s, block[4], 4, dest_cb, dct_linesize);
-                        add_dct(s, block[5], 5, dest_cr, dct_linesize);
-                        add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
-                        add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
-                        if (!s->chroma_x_shift) {//Chroma444
-                            add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
-                            add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
-                            add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
-                            add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
-                        }
+        /* skip dequant / idct if we are really late ;) */
+        if (s->avctx->skip_idct) {
+            if (  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
+                ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
+                || s->avctx->skip_idct >= AVDISCARD_ALL)
+                return;
+        }
+
+        /* add dct residue */
+        if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
+              (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) {
+            add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+            add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+            add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+            add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+            if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                av_assert2(s->chroma_y_shift);
+                add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+            }
+        } else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
+            add_dct(s, block[0], 0, dest_y                          , dct_linesize);
+            add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
+            add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
+            add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
+
+            if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                if (s->chroma_y_shift) {//Chroma420
+                    add_dct(s, block[4], 4, dest_cb, uvlinesize);
+                    add_dct(s, block[5], 5, dest_cr, uvlinesize);
+                } else {
+                    //chroma422
+                    dct_linesize = uvlinesize << s->interlaced_dct;
+                    dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
+
+                    add_dct(s, block[4], 4, dest_cb, dct_linesize);
+                    add_dct(s, block[5], 5, dest_cr, dct_linesize);
+                    add_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize);
+                    add_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize);
+                    if (!s->chroma_x_shift) {//Chroma444
+                        add_dct(s, block[8],   8, dest_cb + block_size, dct_linesize);
+                        add_dct(s, block[9],   9, dest_cr + block_size, dct_linesize);
+                        add_dct(s, block[10], 10, dest_cb + block_size + dct_offset, dct_linesize);
+                        add_dct(s, block[11], 11, dest_cr + block_size + dct_offset, dct_linesize);
                     }
-                } //fi gray
-            } else if (CONFIG_WMV2_DECODER) {
-                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
+                }
+            } //fi gray
+        } else if (CONFIG_WMV2_DECODER) {
+            ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
+        }
+    } else {
+        /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
+            TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
+        if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER &&
+            /* s->codec_id == AV_CODEC_ID_MPEG4 && */
+            s->avctx->bits_per_raw_sample > 8) {
+            ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
+                                    uvlinesize, dct_linesize, dct_offset);
+        } else if (!IS_MPEG12_H261(s)) {
+            /* dct only in intra block */
+            put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+            put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+            put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+            put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+            if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                if (s->chroma_y_shift) {
+                    put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                    put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                } else {
+                    dct_offset   >>= 1;
+                    dct_linesize >>= 1;
+                    put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
+                    put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
+                    put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
+                    put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
+                }
             }
         } else {
-            /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
-               TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
-            if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER &&
-                /* s->codec_id == AV_CODEC_ID_MPEG4 && */
-                s->avctx->bits_per_raw_sample > 8) {
-                ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
-                                       uvlinesize, dct_linesize, dct_offset);
-            } else if (!IS_MPEG12_H261(s)) {
-                /* dct only in intra block */
-                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {
-                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                    } else {
-                        dct_offset >>=1;
-                        dct_linesize >>=1;
-                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
+            s->idsp.idct_put(dest_y,                           dct_linesize, block[0]);
+            s->idsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
+            s->idsp.idct_put(dest_y + dct_offset,              dct_linesize, block[2]);
+            s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
+
+            if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                if (s->chroma_y_shift) {
+                    s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
+                    s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
+                } else {
+                    dct_linesize = uvlinesize << s->interlaced_dct;
+                    dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
+
+                    s->idsp.idct_put(dest_cb,              dct_linesize, block[4]);
+                    s->idsp.idct_put(dest_cr,              dct_linesize, block[5]);
+                    s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
+                    s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
+                    if (!s->chroma_x_shift) { //Chroma444
+                        s->idsp.idct_put(dest_cb + block_size,              dct_linesize, block[8]);
+                        s->idsp.idct_put(dest_cr + block_size,              dct_linesize, block[9]);
+                        s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
+                        s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
                     }
                 }
-            } else {
-                s->idsp.idct_put(dest_y,                           dct_linesize, block[0]);
-                s->idsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
-                s->idsp.idct_put(dest_y + dct_offset,              dct_linesize, block[2]);
-                s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {
-                        s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
-                        s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
-                    } else {
-                        dct_linesize = uvlinesize << s->interlaced_dct;
-                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
-
-                        s->idsp.idct_put(dest_cb,              dct_linesize, block[4]);
-                        s->idsp.idct_put(dest_cr,              dct_linesize, block[5]);
-                        s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
-                        s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
-                        if (!s->chroma_x_shift) { //Chroma444
-                            s->idsp.idct_put(dest_cb + block_size,              dct_linesize, block[8]);
-                            s->idsp.idct_put(dest_cr + block_size,              dct_linesize, block[9]);
-                            s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
-                            s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
-                        }
-                    }
-                } //gray
-            }
+            } //gray
         }
     }
 }
@@ -1108,20 +1106,20 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
     const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
+    uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
 
     s->cur_pic.qscale_table[mb_xy] = s->qscale;
 
-        /* avoid copy if macroblock skipped in last frame too */
-            if (s->mb_skipped) {
-                s->mb_skipped = 0;
-                av_assert2(s->pict_type!=AV_PICTURE_TYPE_I);
-                *mbskip_ptr = 1;
-            } else if (!s->cur_pic.reference) {
-                *mbskip_ptr = 1;
-            } else{
-                *mbskip_ptr = 0; /* not skipped */
-            }
+    /* avoid copy if macroblock skipped in last frame too */
+    if (s->mb_skipped) {
+        s->mb_skipped = 0;
+        av_assert2(s->pict_type != AV_PICTURE_TYPE_I);
+        *mbskip_ptr = 1;
+    } else if (!s->cur_pic.reference) {
+        *mbskip_ptr = 1;
+    } else{
+        *mbskip_ptr = 0; /* not skipped */
+    }
 
     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
        /* print DCT coefficients */
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 774d16edad..99e31be463 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1135,44 +1135,44 @@ static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 
         if (!s->mb_intra) {
             /* No MC, as that was already done otherwise */
-                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {
-                        add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                    } else {
-                        dct_linesize >>= 1;
-                        dct_offset   >>= 1;
-                        add_dequant_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
-                        add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
-                    }
+            add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+            add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+            add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+            add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+            if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                if (s->chroma_y_shift) {
+                    add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                    add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                } else {
+                    dct_linesize >>= 1;
+                    dct_offset   >>= 1;
+                    add_dequant_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
+                    add_dequant_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
+                    add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
+                    add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
                 }
+            }
         } else {
-                /* dct only in intra block */
-                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
-                    if (s->chroma_y_shift) {
-                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                    } else {
-                        dct_offset >>=1;
-                        dct_linesize >>=1;
-                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
-                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
-                    }
+            /* dct only in intra block */
+            put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
+            put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
+            put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
+            put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
+
+            if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
+                if (s->chroma_y_shift) {
+                    put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
+                    put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
+                } else {
+                    dct_offset   >>= 1;
+                    dct_linesize >>= 1;
+                    put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
+                    put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
+                    put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
+                    put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
                 }
+            }
         }
     }
 }
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 08/13] avcodec/mpegvideo_enc: Don't set qscale_table value prematurely
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (5 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 07/13] avcodec/mpegvideo_{dec, enc}: Reindent after the previous commit Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 09/13] avcodec/mpegvideo_enc: Add AV_CODEC_CAP_DR1 Andreas Rheinhardt
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

When there are multiple candidates for macroblock type, the encoder
tries them all. In order to do so, it copies the keeps several sets
of states containing the variables that get modified when encoding
the macroblock and in the end uses the best of these.

Yet one variable was set, but not included in this state:
The current macroblock's qscale value in the current picture's
qscale_table. This may currently be set multiple times in
mpv_reconstruct_mb(), yet it is read when adaptive_quant is true.
Currently, the value read can be the value set by the last attempt
to write the current macroblock and not the initial value.

Fix this by only setting the qscale_table value in one place
outside of mpv_reconstruct_mb() (where it does not belong at all).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c              |  8 ++-----
 tests/ref/seek/vsynth_lena-mpeg4-adap   | 28 ++++++++++++-------------
 tests/ref/vsynth/vsynth1-mpeg4-adap     |  8 +++----
 tests/ref/vsynth/vsynth2-mpeg4-adap     |  8 +++----
 tests/ref/vsynth/vsynth3-mpeg4-adap     |  8 +++----
 tests/ref/vsynth/vsynth_lena-mpeg4-adap |  8 +++----
 6 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 99e31be463..48d26f37cd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1105,10 +1105,6 @@ static inline void add_dequant_dct(MpegEncContext *s,
  */
 static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
-    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-
-    s->cur_pic.qscale_table[mb_xy] = s->qscale;
-
     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
        /* print DCT coefficients */
        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
@@ -3365,8 +3361,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
                     }
                 }
 
-                s->cur_pic.qscale_table[xy] = best_s.qscale;
-
                 copy_context_after_encode(s, &best_s);
 
                 pb_bits_count= put_bits_count(&s->pb);
@@ -3521,6 +3515,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
                 mpv_reconstruct_mb(s, s->block);
             }
 
+            s->cur_pic.qscale_table[xy] = s->qscale;
+
             /* clean the MV table in IPS frames for direct mode in B-frames */
             if(s->mb_intra /* && I,P,S_TYPE */){
                 s->p_mv_table[xy][0]=0;
diff --git a/tests/ref/seek/vsynth_lena-mpeg4-adap b/tests/ref/seek/vsynth_lena-mpeg4-adap
index fe841ef973..7777491651 100644
--- a/tests/ref/seek/vsynth_lena-mpeg4-adap
+++ b/tests/ref/seek/vsynth_lena-mpeg4-adap
@@ -2,45 +2,45 @@ ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   5652 size:  6855
 ret: 0         st:-1 flags:0  ts:-1.000000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   5652 size:  6855
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161318 size: 19176
+ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161352 size: 19191
 ret: 0         st: 0 flags:0  ts: 0.800000
-ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75056 size: 19178
+ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75104 size: 19178
 ret:-1         st: 0 flags:1  ts:-0.320000
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.360000 pts: NOPTS    pos: 118696 size: 20018
+ret: 0         st: 0 flags:1 dts: 1.360000 pts: NOPTS    pos: 118586 size: 20060
 ret: 0         st: 0 flags:0  ts: 0.360000
-ret: 0         st: 0 flags:1 dts: 0.400000 pts: NOPTS    pos:  35800 size: 17261
+ret: 0         st: 0 flags:1 dts: 0.400000 pts: NOPTS    pos:  35840 size: 17261
 ret:-1         st: 0 flags:1  ts:-0.760000
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75056 size: 19178
+ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75104 size: 19178
 ret: 0         st: 0 flags:0  ts:-0.040000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   5652 size:  6855
 ret: 0         st: 0 flags:1  ts: 2.840000
-ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161318 size: 19176
+ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161352 size: 19191
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161318 size: 19176
+ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161352 size: 19191
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.400000 pts: NOPTS    pos:  35800 size: 17261
+ret: 0         st: 0 flags:1 dts: 0.400000 pts: NOPTS    pos:  35840 size: 17261
 ret: 0         st: 0 flags:0  ts:-0.480000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   5652 size:  6855
 ret: 0         st: 0 flags:1  ts: 2.400000
-ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161318 size: 19176
+ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161352 size: 19191
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.360000 pts: NOPTS    pos: 118696 size: 20018
+ret: 0         st: 0 flags:1 dts: 1.360000 pts: NOPTS    pos: 118586 size: 20060
 ret: 0         st:-1 flags:1  ts: 0.200839
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   5652 size:  6855
 ret: 0         st: 0 flags:0  ts:-0.920000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   5652 size:  6855
 ret: 0         st: 0 flags:1  ts: 2.000000
-ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161318 size: 19176
+ret: 0         st: 0 flags:1 dts: 1.840000 pts: NOPTS    pos: 161352 size: 19191
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75056 size: 19178
+ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75104 size: 19178
 ret:-1         st:-1 flags:1  ts:-0.222493
 ret:-1         st: 0 flags:0  ts: 2.680000
 ret: 0         st: 0 flags:1  ts: 1.560000
-ret: 0         st: 0 flags:1 dts: 1.360000 pts: NOPTS    pos: 118696 size: 20018
+ret: 0         st: 0 flags:1 dts: 1.360000 pts: NOPTS    pos: 118586 size: 20060
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75056 size: 19178
+ret: 0         st: 0 flags:1 dts: 0.880000 pts: NOPTS    pos:  75104 size: 19178
 ret:-1         st:-1 flags:1  ts:-0.645825
diff --git a/tests/ref/vsynth/vsynth1-mpeg4-adap b/tests/ref/vsynth/vsynth1-mpeg4-adap
index 67705f0f43..d3ad12e921 100644
--- a/tests/ref/vsynth/vsynth1-mpeg4-adap
+++ b/tests/ref/vsynth/vsynth1-mpeg4-adap
@@ -1,4 +1,4 @@
-0f1cbbdc3f9b91f2d9ac3d1fc2cf7d4e *tests/data/fate/vsynth1-mpeg4-adap.avi
-325518 tests/data/fate/vsynth1-mpeg4-adap.avi
-1e6c596f9f491fbf15920ef1bace7fb8 *tests/data/fate/vsynth1-mpeg4-adap.out.rawvideo
-stddev:   14.12 PSNR: 25.13 MAXDIFF:  184 bytes:  7603200/  7603200
+3b4fe7ad106cb112364d062b20ad80a8 *tests/data/fate/vsynth1-mpeg4-adap.avi
+325594 tests/data/fate/vsynth1-mpeg4-adap.avi
+96c5a7759413ab24afaa926abb3c5fe0 *tests/data/fate/vsynth1-mpeg4-adap.out.rawvideo
+stddev:   14.11 PSNR: 25.13 MAXDIFF:  184 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-mpeg4-adap b/tests/ref/vsynth/vsynth2-mpeg4-adap
index e058cd1ce3..140b17649c 100644
--- a/tests/ref/vsynth/vsynth2-mpeg4-adap
+++ b/tests/ref/vsynth/vsynth2-mpeg4-adap
@@ -1,4 +1,4 @@
-9465ef120d560537d8fcfb5564782e01 *tests/data/fate/vsynth2-mpeg4-adap.avi
-203004 tests/data/fate/vsynth2-mpeg4-adap.avi
-d7851ab1ca9744f8e618a24193e5ef76 *tests/data/fate/vsynth2-mpeg4-adap.out.rawvideo
-stddev:    4.56 PSNR: 34.95 MAXDIFF:   84 bytes:  7603200/  7603200
+21d205e0f42ce613481b202d52593225 *tests/data/fate/vsynth2-mpeg4-adap.avi
+202870 tests/data/fate/vsynth2-mpeg4-adap.avi
+1c45877fe27fb5fbfcdaff4a1da94de4 *tests/data/fate/vsynth2-mpeg4-adap.out.rawvideo
+stddev:    4.55 PSNR: 34.95 MAXDIFF:   84 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-mpeg4-adap b/tests/ref/vsynth/vsynth3-mpeg4-adap
index 6386f13466..70a25831d9 100644
--- a/tests/ref/vsynth/vsynth3-mpeg4-adap
+++ b/tests/ref/vsynth/vsynth3-mpeg4-adap
@@ -1,4 +1,4 @@
-6b2f641f2e68b11b992fd6ba1ed66a21 *tests/data/fate/vsynth3-mpeg4-adap.avi
-41012 tests/data/fate/vsynth3-mpeg4-adap.avi
-3483a2032cb02c3a37f5e43b128e59ed *tests/data/fate/vsynth3-mpeg4-adap.out.rawvideo
-stddev:    5.79 PSNR: 32.87 MAXDIFF:   49 bytes:    86700/    86700
+10512ee1a666ed95643557e1cf699363 *tests/data/fate/vsynth3-mpeg4-adap.avi
+41100 tests/data/fate/vsynth3-mpeg4-adap.avi
+9ba2c3cab3f08d2a345b849d0b30e3e1 *tests/data/fate/vsynth3-mpeg4-adap.out.rawvideo
+stddev:    5.79 PSNR: 32.88 MAXDIFF:   49 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth_lena-mpeg4-adap b/tests/ref/vsynth/vsynth_lena-mpeg4-adap
index 91edafe9b0..912b9b2efa 100644
--- a/tests/ref/vsynth/vsynth_lena-mpeg4-adap
+++ b/tests/ref/vsynth/vsynth_lena-mpeg4-adap
@@ -1,4 +1,4 @@
-633da125f46391eef33bb031cd728f4b *tests/data/fate/vsynth_lena-mpeg4-adap.avi
-187598 tests/data/fate/vsynth_lena-mpeg4-adap.avi
-21312bfcb28c40299fb27a5b03477f8c *tests/data/fate/vsynth_lena-mpeg4-adap.out.rawvideo
-stddev:    3.63 PSNR: 36.92 MAXDIFF:   71 bytes:  7603200/  7603200
+5af033cfe87bc2abf688b602e5a1a35c *tests/data/fate/vsynth_lena-mpeg4-adap.avi
+187652 tests/data/fate/vsynth_lena-mpeg4-adap.avi
+515efcfb456cf7b460f356fe0dc7c808 *tests/data/fate/vsynth_lena-mpeg4-adap.out.rawvideo
+stddev:    3.63 PSNR: 36.93 MAXDIFF:   71 bytes:  7603200/  7603200
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 09/13] avcodec/mpegvideo_enc: Add AV_CODEC_CAP_DR1
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (6 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 08/13] avcodec/mpegvideo_enc: Don't set qscale_table value prematurely Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 10/13] avcodec/motion_est: Avoid branches for put(_no_rnd) selection Andreas Rheinhardt
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The mpegvideo-based encoders do one uncommon thing with
the packet's data given by ff_alloc_packet(): They potentially
reallocate it. But this only affects the internal buffer
and is not user-facing at all, so one can nevertheless
use the AV_CODEC_CAP_DR1 for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/flvenc.c        | 2 +-
 libavcodec/h261enc.c       | 2 +-
 libavcodec/ituh263enc.c    | 5 +++--
 libavcodec/mjpegenc.c      | 5 +++--
 libavcodec/mpeg12enc.c     | 6 ++++--
 libavcodec/mpeg4videoenc.c | 3 ++-
 libavcodec/msmpeg4enc.c    | 6 +++---
 libavcodec/rv10enc.c       | 2 +-
 libavcodec/rv20enc.c       | 2 +-
 libavcodec/speedhqenc.c    | 2 +-
 libavcodec/wmv2enc.c       | 2 +-
 11 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c
index 6a96cb0f2f..97323ac655 100644
--- a/libavcodec/flvenc.c
+++ b/libavcodec/flvenc.c
@@ -98,6 +98,7 @@ const FFCodec ff_flv_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_FLV1,
     .p.priv_class   = &ff_mpv_enc_class,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
@@ -105,5 +106,4 @@ const FFCodec ff_flv_encoder = {
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE},
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 };
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index d3d724bef6..e0ff1a03da 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -383,6 +383,7 @@ const FFCodec ff_h261_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_H261,
     .p.priv_class   = &ff_mpv_enc_class,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(H261EncContext),
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
@@ -390,5 +391,4 @@ const FFCodec ff_h261_encoder = {
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                      AV_PIX_FMT_NONE },
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 };
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 3982b1e675..ad2d1a044f 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -921,7 +921,7 @@ const FFCodec ff_h263_encoder = {
     .p.id           = AV_CODEC_ID_H263,
     .p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE},
     .p.priv_class   = &h263_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
@@ -952,7 +952,8 @@ const FFCodec ff_h263p_encoder = {
     .p.id           = AV_CODEC_ID_H263P,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
     .p.priv_class   = &h263p_class,
-    .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS |
+                      AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 9d4c3a4f41..c4f72743ca 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -649,7 +649,8 @@ const FFCodec ff_mjpeg_encoder = {
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
     .close          = mjpeg_encode_close,
-    .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS |
+    .p.capabilities = AV_CODEC_CAP_DR1 |
+                      AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS |
                       AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES,
     .p.pix_fmts     = (const enum AVPixelFormat[]) {
@@ -675,6 +676,7 @@ const FFCodec ff_amv_encoder = {
     CODEC_LONG_NAME("AMV Video"),
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_AMV,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(MJPEGEncContext),
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(amv_encode_picture),
@@ -684,6 +686,5 @@ const FFCodec ff_amv_encoder = {
         AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_NONE
     },
     .p.priv_class   = &amv_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
 };
 #endif
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 72b2caab7e..6b156772df 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1243,7 +1243,8 @@ const FFCodec ff_mpeg1video_encoder = {
     .p.supported_framerates = ff_mpeg12_frame_rate_tab + 1,
     .p.pix_fmts           = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                            AV_PIX_FMT_NONE },
-    .p.capabilities       = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
+    .p.capabilities       = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+                            AV_CODEC_CAP_SLICE_THREADS |
                             AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal        = FF_CODEC_CAP_INIT_CLEANUP,
     .p.priv_class         = &mpeg1_class,
@@ -1262,7 +1263,8 @@ const FFCodec ff_mpeg2video_encoder = {
     .p.pix_fmts           = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
                                                            AV_PIX_FMT_YUV422P,
                                                            AV_PIX_FMT_NONE },
-    .p.capabilities       = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
+    .p.capabilities       = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+                            AV_CODEC_CAP_SLICE_THREADS |
                             AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal        = FF_CODEC_CAP_INIT_CLEANUP,
     .p.priv_class         = &mpeg2_class,
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 0b18776497..abbf4180e9 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1393,7 +1393,8 @@ const FFCodec ff_mpeg4_encoder = {
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
     .close          = ff_mpv_encode_end,
     .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
-    .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+                      AV_CODEC_CAP_SLICE_THREADS |
                       AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .p.priv_class   = &mpeg4enc_class,
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 3103a73663..a78ab7b2d8 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -682,7 +682,7 @@ const FFCodec ff_msmpeg4v2_encoder = {
     .p.id           = AV_CODEC_ID_MSMPEG4V2,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_data_size = sizeof(MSMPEG4EncContext),
     .init           = ff_mpv_encode_init,
@@ -697,7 +697,7 @@ const FFCodec ff_msmpeg4v3_encoder = {
     .p.id           = AV_CODEC_ID_MSMPEG4V3,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_data_size = sizeof(MSMPEG4EncContext),
     .init           = ff_mpv_encode_init,
@@ -712,7 +712,7 @@ const FFCodec ff_wmv1_encoder = {
     .p.id           = AV_CODEC_ID_WMV1,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .priv_data_size = sizeof(MSMPEG4EncContext),
     .init           = ff_mpv_encode_init,
diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c
index 8a405b8686..b12248636d 100644
--- a/libavcodec/rv10enc.c
+++ b/libavcodec/rv10enc.c
@@ -71,7 +71,7 @@ const FFCodec ff_rv10_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_RV10,
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c
index dc26877d5e..4f90182b76 100644
--- a/libavcodec/rv20enc.c
+++ b/libavcodec/rv20enc.c
@@ -68,7 +68,7 @@ const FFCodec ff_rv20_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_RV20,
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(MpegEncContext),
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 4995b19f3b..93b249497b 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -294,7 +294,7 @@ const FFCodec ff_speedhq_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_SPEEDHQ,
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(SpeedHQEncContext),
     .init           = ff_mpv_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c
index 13ec2bf6ff..57bf931cc6 100644
--- a/libavcodec/wmv2enc.c
+++ b/libavcodec/wmv2enc.c
@@ -243,7 +243,7 @@ const FFCodec ff_wmv2_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_WMV2,
     .p.priv_class   = &ff_mpv_enc_class,
-    .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .priv_data_size = sizeof(WMV2EncContext),
     .init           = wmv2_encode_init,
     FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 10/13] avcodec/motion_est: Avoid branches for put(_no_rnd) selection
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (7 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 09/13] avcodec/mpegvideo_enc: Add AV_CODEC_CAP_DR1 Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 11/13] avcodec/mpegvideo_dec: Use picture-dimensions in ff_print_debug_info() Andreas Rheinhardt
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 554fc9780e..b9576e61bf 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -661,18 +661,12 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
                 const uint8_t *ref = c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
                 dxy = ((my4 & 3) << 2) | (mx4 & 3);
 
-                if(s->no_rounding)
-                    s->qdsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
-                else
-                    s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
+                c->qpel_put[1][dxy](dest_y, ref, stride);
             }else{
                 const uint8_t *ref = c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
                 dxy = ((my4 & 1) << 1) | (mx4 & 1);
 
-                if(s->no_rounding)
-                    s->hdsp.put_no_rnd_pixels_tab[1][dxy](dest_y    , ref    , stride, h);
-                else
-                    s->hdsp.put_pixels_tab       [1][dxy](dest_y    , ref    , stride, h);
+                c->hpel_put[1][dxy](dest_y, ref, stride, h);
             }
             dmin_sum+= (mv_penalty[mx4-pred_x4] + mv_penalty[my4-pred_y4])*c->mb_penalty_factor;
         }else
@@ -713,13 +707,8 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
 
         offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
 
-        if(s->no_rounding){
-            s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad    , s->last_pic.data[1] + offset, s->uvlinesize, 8);
-            s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8);
-        }else{
-            s->hdsp.put_pixels_tab       [1][dxy](c->scratchpad    , s->last_pic.data[1] + offset, s->uvlinesize, 8);
-            s->hdsp.put_pixels_tab       [1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8);
-        }
+        c->hpel_put[1][dxy](c->scratchpad    , s->last_pic.data[1] + offset, s->uvlinesize, 8);
+        c->hpel_put[1][dxy](c->scratchpad + 8, s->last_pic.data[2] + offset, s->uvlinesize, 8);
 
         dmin_sum += c->mb_cmp[1](s, s->new_pic->data[1] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad,     s->uvlinesize, 8);
         dmin_sum += c->mb_cmp[1](s, s->new_pic->data[2] + s->mb_x * 8 + s->mb_y * 8 * s->uvlinesize, c->scratchpad + 8, s->uvlinesize, 8);
@@ -825,11 +814,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index,
                 const uint8_t *ref = c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
                 dxy = ((my_i & 1) << 1) | (mx_i & 1);
 
-                if(s->no_rounding){
-                    s->hdsp.put_no_rnd_pixels_tab[size][dxy](c->scratchpad, ref    , stride, h);
-                }else{
-                    s->hdsp.put_pixels_tab       [size][dxy](c->scratchpad, ref    , stride, h);
-                }
+                c->hpel_put[size][dxy](c->scratchpad, ref    , stride, h);
                 dmin = c->mb_cmp[size](s, c->src[block][0], c->scratchpad, stride, h);
                 dmin+= (mv_penalty[mx_i-c->pred_x] + mv_penalty[my_i-c->pred_y] + 1)*c->mb_penalty_factor;
             }else
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 11/13] avcodec/mpegvideo_dec: Use picture-dimensions in ff_print_debug_info()
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (8 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 10/13] avcodec/motion_est: Avoid branches for put(_no_rnd) selection Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 12/13] avcodec/vc1dec: Reenable debug-info output for field pictures Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 13/13] avcodec/h261dec: Remove dead check Andreas Rheinhardt
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It will allow to avoid the special case for VC-1 field pictures.

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

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 78fa10c11d..5d8e9a36ec 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -404,7 +404,7 @@ void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *
 {
     ff_print_debug_info2(s->avctx, pict, p->mb_type,
                          p->qscale_table, p->motion_val,
-                         s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample);
+                         p->mb_width, p->mb_height, p->mb_stride, s->quarter_sample);
 }
 
 int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f,
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 12/13] avcodec/vc1dec: Reenable debug-info output for field pictures
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (9 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 11/13] avcodec/mpegvideo_dec: Use picture-dimensions in ff_print_debug_info() Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 13/13] avcodec/h261dec: Remove dead check Andreas Rheinhardt
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Effectively reverts c59b5e3d1e0121ea23b5b326529f5bdca44cf982.
This is possible now that ff_print_debug_info2() uses
the MPVPicture dimensions.

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

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 4b31860c3f..2cd87e5de4 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1365,14 +1365,12 @@ image:
         if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
             if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0)
                 goto err;
-            if (!v->field_mode)
-                ff_print_debug_info(s, s->cur_pic.ptr, pict);
+            ff_print_debug_info(s, s->cur_pic.ptr, pict);
             *got_frame = 1;
         } else if (s->last_pic.ptr) {
             if ((ret = av_frame_ref(pict, s->last_pic.ptr->f)) < 0)
                 goto err;
-            if (!v->field_mode)
-                ff_print_debug_info(s, s->last_pic.ptr, pict);
+            ff_print_debug_info(s, s->last_pic.ptr, pict);
             *got_frame = 1;
         }
     }
-- 
2.40.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] 14+ messages in thread

* [FFmpeg-devel] [PATCH 13/13] avcodec/h261dec: Remove dead check
  2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
                   ` (10 preceding siblings ...)
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 12/13] avcodec/vc1dec: Reenable debug-info output for field pictures Andreas Rheinhardt
@ 2024-07-01 12:16 ` Andreas Rheinhardt
  11 siblings, 0 replies; 14+ messages in thread
From: Andreas Rheinhardt @ 2024-07-01 12:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

H.261 does not have non-reference frames.

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index cabca33c8d..50ac53167d 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -587,8 +587,7 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
             return ret;
     }
 
-    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) ||
+    if ((avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
          avctx->skip_frame >= AVDISCARD_ALL)
         return buf_size;
 
-- 
2.40.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] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 06/13] avcodec/mpv_reconstruct_mb_template: Merge template into its users
  2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 06/13] avcodec/mpv_reconstruct_mb_template: Merge template into its users Andreas Rheinhardt
@ 2024-07-01 13:04   ` Rémi Denis-Courmont
  0 siblings, 0 replies; 14+ messages in thread
From: Rémi Denis-Courmont @ 2024-07-01 13:04 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



Le 1 juillet 2024 15:16:03 GMT+03:00, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> a écrit :
>A large part of this template is decoder-only. This makes
>the complexity of the IS_ENCODER-checks not worth it.
>So simply merge the template into both its users.
>
>Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>---
> libavcodec/mpegvideo_dec.c               | 218 +++++++++++++++++-
> libavcodec/mpegvideo_enc.c               |  81 ++++++-
> libavcodec/mpv_reconstruct_mb_template.c | 272 -----------------------
> 3 files changed, 294 insertions(+), 277 deletions(-)
> delete mode 100644 libavcodec/mpv_reconstruct_mb_template.c
>
>diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
>index 1cab108935..2222d50283 100644
>--- a/libavcodec/mpegvideo_dec.c
>+++ b/libavcodec/mpegvideo_dec.c
>@@ -904,11 +904,225 @@ static inline void add_dct(MpegEncContext *s,
>     }
> }
> 
>-#define IS_ENCODER 0
>-#include "mpv_reconstruct_mb_template.c"
>+/* put block[] to dest[] */
>+static inline void put_dct(MpegEncContext *s,
>+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
>+{
>+    s->dct_unquantize_intra(s, block, i, qscale);
>+    s->idsp.idct_put(dest, line_size, block);
>+}

BTW, shouldn't the put/add be folded into the more specific callback, as most other decoder DSP functions seems to work?

(No objections either way.)

>+
>+static inline void add_dequant_dct(MpegEncContext *s,
>+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
>+{
>+    if (s->block_last_index[i] >= 0) {
>+        s->dct_unquantize_inter(s, block, i, qscale);
>+
>+        s->idsp.idct_add(dest, line_size, block);
>+    }
>+}
>+
>+#define NOT_MPEG12_H261        0
>+#define MAY_BE_MPEG12_H261     1
>+#define DEFINITELY_MPEG12_H261 2
>+
>+/* generic function called after a macroblock has been parsed by the decoder.
>+
>+   Important variables used:
>+   s->mb_intra : true if intra macroblock
>+   s->mv_dir   : motion vector direction
>+   s->mv_type  : motion vector type
>+   s->mv       : motion vector
>+   s->interlaced_dct : true if interlaced dct used (mpeg2)
>+ */
>+static av_always_inline
>+void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
>+                                 int lowres_flag, int is_mpeg12)
>+{
>+#define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12)
>+    {
>+        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
>+        int dct_linesize, dct_offset;
>+        const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics
>+        const int uvlinesize = s->cur_pic.linesize[1];
>+        const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
>+
>+        dct_linesize = linesize << s->interlaced_dct;
>+        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
>+
>+        if (!s->mb_intra) {
>+            /* motion handling */
>+            if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 &&
>+                s->avctx->active_thread_type & FF_THREAD_FRAME) {
>+                if (s->mv_dir & MV_DIR_FORWARD) {
>+                    ff_thread_progress_await(&s->last_pic.ptr->progress,
>+                                             lowest_referenced_row(s, 0));
>+                }
>+                if (s->mv_dir & MV_DIR_BACKWARD) {
>+                    ff_thread_progress_await(&s->next_pic.ptr->progress,
>+                                             lowest_referenced_row(s, 1));
>+                }
>+            }
>+
>+            if (lowres_flag) {
>+                const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
>+
>+                if (s->mv_dir & MV_DIR_FORWARD) {
>+                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix);
>+                    op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
>+                }
>+                if (s->mv_dir & MV_DIR_BACKWARD) {
>+                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix);
>+                }
>+            } else {
>+                const op_pixels_func (*op_pix)[4];
>+                const qpel_mc_func (*op_qpix)[16];
>+
>+                if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
>+                    op_pix = s->hdsp.put_pixels_tab;
>+                    op_qpix = s->qdsp.put_qpel_pixels_tab;
>+                } else {
>+                    op_pix = s->hdsp.put_no_rnd_pixels_tab;
>+                    op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
>+                }
>+                if (s->mv_dir & MV_DIR_FORWARD) {
>+                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix);
>+                    op_pix  = s->hdsp.avg_pixels_tab;
>+                    op_qpix = s->qdsp.avg_qpel_pixels_tab;
>+                }
>+                if (s->mv_dir & MV_DIR_BACKWARD) {
>+                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix);
>+                }
>+            }
>+
>+            /* skip dequant / idct if we are really late ;) */
>+            if (s->avctx->skip_idct) {
>+                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
>+                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
>+                   || s->avctx->skip_idct >= AVDISCARD_ALL)
>+                    return;
>+            }
>+
>+            /* add dct residue */
>+            if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
>+                  (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant))) {
>+                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
>+                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
>+                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
>+                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
>+
>+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>+                    av_assert2(s->chroma_y_shift);
>+                    add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
>+                    add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
>+                }
>+            } else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
>+                add_dct(s, block[0], 0, dest_y                          , dct_linesize);
>+                add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
>+                add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
>+                add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
>+
>+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>+                    if (s->chroma_y_shift) {//Chroma420
>+                        add_dct(s, block[4], 4, dest_cb, uvlinesize);
>+                        add_dct(s, block[5], 5, dest_cr, uvlinesize);
>+                    } else {
>+                        //chroma422
>+                        dct_linesize = uvlinesize << s->interlaced_dct;
>+                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
>+
>+                        add_dct(s, block[4], 4, dest_cb, dct_linesize);
>+                        add_dct(s, block[5], 5, dest_cr, dct_linesize);
>+                        add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
>+                        add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
>+                        if (!s->chroma_x_shift) {//Chroma444
>+                            add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
>+                            add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
>+                            add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
>+                            add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
>+                        }
>+                    }
>+                } //fi gray
>+            } else if (CONFIG_WMV2_DECODER) {
>+                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
>+            }
>+        } else {
>+            /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
>+               TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
>+            if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER &&
>+                /* s->codec_id == AV_CODEC_ID_MPEG4 && */
>+                s->avctx->bits_per_raw_sample > 8) {
>+                ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
>+                                       uvlinesize, dct_linesize, dct_offset);
>+            } else if (!IS_MPEG12_H261(s)) {
>+                /* dct only in intra block */
>+                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
>+                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
>+                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
>+                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
>+
>+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>+                    if (s->chroma_y_shift) {
>+                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
>+                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
>+                    } else {
>+                        dct_offset >>=1;
>+                        dct_linesize >>=1;
>+                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
>+                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
>+                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
>+                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
>+                    }
>+                }
>+            } else {
>+                s->idsp.idct_put(dest_y,                           dct_linesize, block[0]);
>+                s->idsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
>+                s->idsp.idct_put(dest_y + dct_offset,              dct_linesize, block[2]);
>+                s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
>+
>+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>+                    if (s->chroma_y_shift) {
>+                        s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
>+                        s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
>+                    } else {
>+                        dct_linesize = uvlinesize << s->interlaced_dct;
>+                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
>+
>+                        s->idsp.idct_put(dest_cb,              dct_linesize, block[4]);
>+                        s->idsp.idct_put(dest_cr,              dct_linesize, block[5]);
>+                        s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
>+                        s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
>+                        if (!s->chroma_x_shift) { //Chroma444
>+                            s->idsp.idct_put(dest_cb + block_size,              dct_linesize, block[8]);
>+                            s->idsp.idct_put(dest_cr + block_size,              dct_linesize, block[9]);
>+                            s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
>+                            s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
>+                        }
>+                    }
>+                } //gray
>+            }
>+        }
>+    }
>+}
> 
> void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
> {
>+    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
>+            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
>+
>+    s->cur_pic.qscale_table[mb_xy] = s->qscale;
>+
>+        /* avoid copy if macroblock skipped in last frame too */
>+            if (s->mb_skipped) {
>+                s->mb_skipped = 0;
>+                av_assert2(s->pict_type!=AV_PICTURE_TYPE_I);
>+                *mbskip_ptr = 1;
>+            } else if (!s->cur_pic.reference) {
>+                *mbskip_ptr = 1;
>+            } else{
>+                *mbskip_ptr = 0; /* not skipped */
>+            }
>+
>     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
>        /* print DCT coefficients */
>        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
>diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
>index 31c5dd4736..774d16edad 100644
>--- a/libavcodec/mpegvideo_enc.c
>+++ b/libavcodec/mpegvideo_enc.c
>@@ -1082,11 +1082,33 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
>     return 0;
> }
> 
>-#define IS_ENCODER 1
>-#include "mpv_reconstruct_mb_template.c"
>+/* put block[] to dest[] */
>+static inline void put_dct(MpegEncContext *s,
>+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
>+{
>+    s->dct_unquantize_intra(s, block, i, qscale);
>+    s->idsp.idct_put(dest, line_size, block);
>+}
> 
>+static inline void add_dequant_dct(MpegEncContext *s,
>+                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
>+{
>+    if (s->block_last_index[i] >= 0) {
>+        s->dct_unquantize_inter(s, block, i, qscale);
>+
>+        s->idsp.idct_add(dest, line_size, block);
>+    }
>+}
>+
>+/**
>+ * Performs dequantization and IDCT (if necessary)
>+ */
> static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
> {
>+    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
>+
>+    s->cur_pic.qscale_table[mb_xy] = s->qscale;
>+
>     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
>        /* print DCT coefficients */
>        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
>@@ -1099,7 +1121,60 @@ static void mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
>        }
>     }
> 
>-    mpv_reconstruct_mb_internal(s, block, 0, MAY_BE_MPEG12_H261);
>+    if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->frame_skip_threshold || s->frame_skip_factor ||
>+        !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
>+          s->avctx->mb_decision != FF_MB_DECISION_RD)) { // FIXME precalc
>+        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
>+        int dct_linesize, dct_offset;
>+        const int linesize   = s->cur_pic.linesize[0];
>+        const int uvlinesize = s->cur_pic.linesize[1];
>+        const int block_size = 8;
>+
>+        dct_linesize = linesize << s->interlaced_dct;
>+        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
>+
>+        if (!s->mb_intra) {
>+            /* No MC, as that was already done otherwise */
>+                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
>+                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
>+                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
>+                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
>+
>+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>+                    if (s->chroma_y_shift) {
>+                        add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
>+                        add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
>+                    } else {
>+                        dct_linesize >>= 1;
>+                        dct_offset   >>= 1;
>+                        add_dequant_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
>+                        add_dequant_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
>+                        add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
>+                        add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
>+                    }
>+                }
>+        } else {
>+                /* dct only in intra block */
>+                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
>+                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
>+                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
>+                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
>+
>+                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>+                    if (s->chroma_y_shift) {
>+                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
>+                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
>+                    } else {
>+                        dct_offset >>=1;
>+                        dct_linesize >>=1;
>+                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
>+                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
>+                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
>+                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
>+                    }
>+                }
>+        }
>+    }
> }
> 
> static int get_sae(const uint8_t *src, int ref, int stride)
>diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
>deleted file mode 100644
>index ae7a9e34ce..0000000000
>--- a/libavcodec/mpv_reconstruct_mb_template.c
>+++ /dev/null
>@@ -1,272 +0,0 @@
>-/*
>- * MPEG macroblock reconstruction
>- * Copyright (c) 2000,2001 Fabrice Bellard
>- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
>- *
>- * This file is part of FFmpeg.
>- *
>- * FFmpeg is free software; you can redistribute it and/or
>- * modify it under the terms of the GNU Lesser General Public
>- * License as published by the Free Software Foundation; either
>- * version 2.1 of the License, or (at your option) any later version.
>- *
>- * FFmpeg is distributed in the hope that it will be useful,
>- * but WITHOUT ANY WARRANTY; without even the implied warranty of
>- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>- * Lesser General Public License for more details.
>- *
>- * You should have received a copy of the GNU Lesser General Public
>- * License along with FFmpeg; if not, write to the Free Software
>- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>- */
>-
>-#define NOT_MPEG12_H261        0
>-#define MAY_BE_MPEG12_H261     1
>-#define DEFINITELY_MPEG12_H261 2
>-
>-/* put block[] to dest[] */
>-static inline void put_dct(MpegEncContext *s,
>-                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
>-{
>-    s->dct_unquantize_intra(s, block, i, qscale);
>-    s->idsp.idct_put(dest, line_size, block);
>-}
>-
>-static inline void add_dequant_dct(MpegEncContext *s,
>-                           int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
>-{
>-    if (s->block_last_index[i] >= 0) {
>-        s->dct_unquantize_inter(s, block, i, qscale);
>-
>-        s->idsp.idct_add(dest, line_size, block);
>-    }
>-}
>-
>-/* generic function called after a macroblock has been parsed by the
>-   decoder or after it has been encoded by the encoder.
>-
>-   Important variables used:
>-   s->mb_intra : true if intra macroblock
>-   s->mv_dir   : motion vector direction
>-   s->mv_type  : motion vector type
>-   s->mv       : motion vector
>-   s->interlaced_dct : true if interlaced dct used (mpeg2)
>- */
>-static av_always_inline
>-void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
>-                                 int lowres_flag, int is_mpeg12)
>-{
>-#define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12)
>-    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
>-
>-    s->cur_pic.qscale_table[mb_xy] = s->qscale;
>-
>-#if IS_ENCODER
>-    if ((s->avctx->flags & AV_CODEC_FLAG_PSNR) || s->frame_skip_threshold || s->frame_skip_factor ||
>-        !((s->intra_only || s->pict_type == AV_PICTURE_TYPE_B) &&
>-          s->avctx->mb_decision != FF_MB_DECISION_RD))  // FIXME precalc
>-#endif /* IS_ENCODER */
>-    {
>-        uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2];
>-        int dct_linesize, dct_offset;
>-        const int linesize   = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics
>-        const int uvlinesize = s->cur_pic.linesize[1];
>-        const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8;
>-
>-        /* avoid copy if macroblock skipped in last frame too */
>-        /* skip only during decoding as we might trash the buffers during encoding a bit */
>-        if (!IS_ENCODER) {
>-            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
>-
>-            if (s->mb_skipped) {
>-                s->mb_skipped = 0;
>-                av_assert2(s->pict_type!=AV_PICTURE_TYPE_I);
>-                *mbskip_ptr = 1;
>-            } else if (!s->cur_pic.reference) {
>-                *mbskip_ptr = 1;
>-            } else{
>-                *mbskip_ptr = 0; /* not skipped */
>-            }
>-        }
>-
>-        dct_linesize = linesize << s->interlaced_dct;
>-        dct_offset   = s->interlaced_dct ? linesize : linesize * block_size;
>-
>-        if (!s->mb_intra) {
>-            /* motion handling */
>-            /* decoding or more than one mb_type (MC was already done otherwise) */
>-
>-#if !IS_ENCODER
>-            if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12_H261 &&
>-                s->avctx->active_thread_type & FF_THREAD_FRAME) {
>-                if (s->mv_dir & MV_DIR_FORWARD) {
>-                    ff_thread_progress_await(&s->last_pic.ptr->progress,
>-                                             lowest_referenced_row(s, 0));
>-                }
>-                if (s->mv_dir & MV_DIR_BACKWARD) {
>-                    ff_thread_progress_await(&s->next_pic.ptr->progress,
>-                                             lowest_referenced_row(s, 1));
>-                }
>-            }
>-
>-            if (lowres_flag) {
>-                const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
>-
>-                if (s->mv_dir & MV_DIR_FORWARD) {
>-                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix);
>-                    op_pix = s->h264chroma.avg_h264_chroma_pixels_tab;
>-                }
>-                if (s->mv_dir & MV_DIR_BACKWARD) {
>-                    MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix);
>-                }
>-            } else {
>-                const op_pixels_func (*op_pix)[4];
>-                const qpel_mc_func (*op_qpix)[16];
>-
>-                if ((is_mpeg12 == DEFINITELY_MPEG12_H261 || !s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
>-                    op_pix = s->hdsp.put_pixels_tab;
>-                    op_qpix = s->qdsp.put_qpel_pixels_tab;
>-                } else {
>-                    op_pix = s->hdsp.put_no_rnd_pixels_tab;
>-                    op_qpix = s->qdsp.put_no_rnd_qpel_pixels_tab;
>-                }
>-                if (s->mv_dir & MV_DIR_FORWARD) {
>-                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_pic.data, op_pix, op_qpix);
>-                    op_pix  = s->hdsp.avg_pixels_tab;
>-                    op_qpix = s->qdsp.avg_qpel_pixels_tab;
>-                }
>-                if (s->mv_dir & MV_DIR_BACKWARD) {
>-                    ff_mpv_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_pic.data, op_pix, op_qpix);
>-                }
>-            }
>-
>-            /* skip dequant / idct if we are really late ;) */
>-            if (s->avctx->skip_idct) {
>-                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
>-                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
>-                   || s->avctx->skip_idct >= AVDISCARD_ALL)
>-                    return;
>-            }
>-
>-            /* add dct residue */
>-            if (!(IS_MPEG12_H261(s) || s->msmpeg4_version != MSMP4_UNUSED ||
>-                  (s->codec_id == AV_CODEC_ID_MPEG4 && !s->mpeg_quant)))
>-#endif /* !IS_ENCODER */
>-            {
>-                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
>-                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
>-                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
>-                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
>-
>-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>-                    av_assert2(IS_ENCODER || s->chroma_y_shift);
>-                    if (!IS_ENCODER || s->chroma_y_shift) {
>-                        add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
>-                        add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
>-                    } else {
>-                        dct_linesize >>= 1;
>-                        dct_offset   >>= 1;
>-                        add_dequant_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
>-                        add_dequant_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
>-                        add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
>-                        add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
>-                    }
>-                }
>-            }
>-#if !IS_ENCODER
>-              else if (is_mpeg12 == DEFINITELY_MPEG12_H261 || lowres_flag || (s->codec_id != AV_CODEC_ID_WMV2)) {
>-                add_dct(s, block[0], 0, dest_y                          , dct_linesize);
>-                add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
>-                add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
>-                add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
>-
>-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>-                    if (s->chroma_y_shift) {//Chroma420
>-                        add_dct(s, block[4], 4, dest_cb, uvlinesize);
>-                        add_dct(s, block[5], 5, dest_cr, uvlinesize);
>-                    } else {
>-                        //chroma422
>-                        dct_linesize = uvlinesize << s->interlaced_dct;
>-                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
>-
>-                        add_dct(s, block[4], 4, dest_cb, dct_linesize);
>-                        add_dct(s, block[5], 5, dest_cr, dct_linesize);
>-                        add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
>-                        add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
>-                        if (!s->chroma_x_shift) {//Chroma444
>-                            add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
>-                            add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
>-                            add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
>-                            add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
>-                        }
>-                    }
>-                } //fi gray
>-            } else if (CONFIG_WMV2_DECODER) {
>-                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
>-            }
>-#endif /* !IS_ENCODER */
>-        } else {
>-#if !IS_ENCODER
>-            /* Only MPEG-4 Simple Studio Profile is supported in > 8-bit mode.
>-               TODO: Integrate 10-bit properly into mpegvideo.c so that ER works properly */
>-            if (is_mpeg12 != DEFINITELY_MPEG12_H261 && CONFIG_MPEG4_DECODER &&
>-                /* s->codec_id == AV_CODEC_ID_MPEG4 && */
>-                s->avctx->bits_per_raw_sample > 8) {
>-                ff_mpeg4_decode_studio(s, dest_y, dest_cb, dest_cr, block_size,
>-                                       uvlinesize, dct_linesize, dct_offset);
>-            } else if (!IS_MPEG12_H261(s))
>-#endif /* !IS_ENCODER */
>-            {
>-                /* dct only in intra block */
>-                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
>-                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
>-                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
>-                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
>-
>-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>-                    if (s->chroma_y_shift) {
>-                        put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
>-                        put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
>-                    } else {
>-                        dct_offset >>=1;
>-                        dct_linesize >>=1;
>-                        put_dct(s, block[4], 4, dest_cb,              dct_linesize, s->chroma_qscale);
>-                        put_dct(s, block[5], 5, dest_cr,              dct_linesize, s->chroma_qscale);
>-                        put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
>-                        put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
>-                    }
>-                }
>-            }
>-#if !IS_ENCODER
>-              else {
>-                s->idsp.idct_put(dest_y,                           dct_linesize, block[0]);
>-                s->idsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
>-                s->idsp.idct_put(dest_y + dct_offset,              dct_linesize, block[2]);
>-                s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
>-
>-                if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
>-                    if (s->chroma_y_shift) {
>-                        s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
>-                        s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
>-                    } else {
>-                        dct_linesize = uvlinesize << s->interlaced_dct;
>-                        dct_offset   = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
>-
>-                        s->idsp.idct_put(dest_cb,              dct_linesize, block[4]);
>-                        s->idsp.idct_put(dest_cr,              dct_linesize, block[5]);
>-                        s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
>-                        s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
>-                        if (!s->chroma_x_shift) { //Chroma444
>-                            s->idsp.idct_put(dest_cb + block_size,              dct_linesize, block[8]);
>-                            s->idsp.idct_put(dest_cr + block_size,              dct_linesize, block[9]);
>-                            s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
>-                            s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
>-                        }
>-                    }
>-                } //gray
>-            }
>-#endif /* !IS_ENCODER */
>-        }
>-    }
>-}
>-
_______________________________________________
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] 14+ messages in thread

end of thread, other threads:[~2024-07-01 13:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-01 12:01 [FFmpeg-devel] [PATCH 01/13] avcodec/h261enc: Use LUT to write motion vector differences Andreas Rheinhardt
2024-07-01 12:15 ` [FFmpeg-devel] [PATCH 02/13] avcodec/mpeg12dec: Move resetting last_dc to decoder Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 03/13] avcodec/mpeg12enc: Move resetting last_dc to encoder Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 04/13] avcodec/h263dec: Clean intra tables in decoder, not ff_mpv_reconstruct_mb Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 05/13] avcodec/mpegvideo_enc: Don't reset intra buffers in mpv_reconstruct_mb() Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 06/13] avcodec/mpv_reconstruct_mb_template: Merge template into its users Andreas Rheinhardt
2024-07-01 13:04   ` Rémi Denis-Courmont
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 07/13] avcodec/mpegvideo_{dec, enc}: Reindent after the previous commit Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 08/13] avcodec/mpegvideo_enc: Don't set qscale_table value prematurely Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 09/13] avcodec/mpegvideo_enc: Add AV_CODEC_CAP_DR1 Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 10/13] avcodec/motion_est: Avoid branches for put(_no_rnd) selection Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 11/13] avcodec/mpegvideo_dec: Use picture-dimensions in ff_print_debug_info() Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 12/13] avcodec/vc1dec: Reenable debug-info output for field pictures Andreas Rheinhardt
2024-07-01 12:16 ` [FFmpeg-devel] [PATCH 13/13] avcodec/h261dec: Remove dead check 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