diff mbox series

[FFmpeg-devel,63/67] avcodec/mpeg_er: Simplify disabling IDCT

Message ID GV1P250MB07371346D60820E30E6121048FC22@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,01/57] avcodec/vc1: Combine identical checks | expand

Commit Message

Andreas Rheinhardt June 14, 2024, 6:25 p.m. UTC
The error resilience code does not make up block coefficients
and therefore zeroes them in order to disable the IDCT.
But this can be done in a simpler manner, namely by setting
block_last_index to a negative value. Doing so also has
the advantage that the dct_unquantize functions are never even
called for those codecs that do not use ff_mpv_reconstruct_mb()
for ordinary decoding (namely RV-30/40 and the VC-1 family).

This approach would not work for intra macroblocks (there is always
at least one coefficient for them and therefore there is no check
for block_last_index for them), but this does not happen at all.
Add an assert for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg_er.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index fe7dcd7efb..3cbdeeebec 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -16,6 +16,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/mem.h"
 #include "error_resilience.h"
 #include "mpegvideo.h"
@@ -67,6 +68,8 @@  static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
 {
     MpegEncContext *s = opaque;
 
+    av_assert1(!mb_intra);
+
     s->mv_dir     = mv_dir;
     s->mv_type    = mv_type;
     s->mb_intra   = mb_intra;
@@ -76,9 +79,9 @@  static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
     s->mcsel      = 0;
     memcpy(s->mv, mv, sizeof(*mv));
 
-    s->bdsp.clear_blocks(s->block[0]);
-    if (!s->chroma_y_shift)
-        s->bdsp.clear_blocks(s->block[6]);
+    // The following disables the IDCT.
+    for (size_t i = 0; i < FF_ARRAY_ELEMS(s->block_last_index); i++)
+        s->block_last_index[i] = -1;
 
     s->dest[0] = s->cur_pic.data[0] +
                  s->mb_y * 16 * s->linesize +