avcodec/mpeg_er: Simplify disabling IDCT

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>
This commit is contained in:
Andreas Rheinhardt 2024-06-13 20:18:16 +02:00
parent fee9520716
commit 7b539ca3e6

View File

@ -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 +