[FFmpeg-devel] [PATCH 63/67] avcodec/mpeg_er: Simplify disabling IDCT
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Fri Jun 14 21:25:54 EEST 2024
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 at outlook.com>
---
libavcodec/mpeg_er.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
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 +
--
2.40.1
More information about the ffmpeg-devel
mailing list