avcodec/mpegvideo_dec: Don't use MotionEstContext as scratch space

Decoders that might use quarter pixel motion estimation
(namely MPEG-4 as well as the VC-1 family) currently
use MpegEncContext.me.qpel_(put|avg) as scratch space
for pointers to arrays of function pointers.
(MotionEstContext contains such pointers as it supports
quarter pixel motion estimation.) The MotionEstContext
is unused apart from this for the decoding part of
mpegvideo.

Using the context at all is for decoding is actually
unnecessary and easily avoided: All codecs with
quarter pixels set me.qpel_avg to qdsp.avg_qpel_pixels_tab,
so one can just unconditionally use this in ff_mpv_reconstruct_mb().
MPEG-4 sets qpel_put to qdsp.put_qpel_pixels_tab
or to qdsp.put_no_rnd_qpel_pixels_tab based upon
whether the current frame is a b-frame with no_rounding
or not, while the VC-1-based decoders set it to
qdsp.put_qpel_pixels_tab unconditionally. Given
that no_rounding is always zero for VC-1, using
the same check for VC-1 as well as for MPEG-4 would work.
Since ff_mpv_reconstruct_mb() already has exactly
the right check (for hpeldsp), it can simply be reused.

(This change will result in ff_mpv_motion() receiving
a pointer to an array of NULL function pointers instead
of a NULL pointer for codecs without qpeldsp (like MPEG-1/2).
It doesn't matter.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-10-30 23:47:18 +01:00
parent 5739fa8be2
commit 1d9aac9c4b
4 changed files with 4 additions and 17 deletions

View File

@ -597,14 +597,6 @@ retry:
avctx->skip_frame >= AVDISCARD_ALL)
return get_consumed_bytes(s, buf_size);
if ((!s->no_rounding) || s->pict_type == AV_PICTURE_TYPE_B) {
s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
} else {
s->me.qpel_put = s->qdsp.put_no_rnd_qpel_pixels_tab;
s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
}
if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
return ret;

View File

@ -145,17 +145,19 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
}
} else {
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16] = s->me.qpel_put;
qpel_mc_func (*op_qpix)[16];
if ((is_mpeg12 == DEFINITELY_MPEG12 || !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_picture.f->data, op_pix, op_qpix);
op_pix = s->hdsp.avg_pixels_tab;
op_qpix = s->me.qpel_avg;
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_picture.f->data, op_pix, op_qpix);

View File

@ -855,10 +855,6 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
/* error concealment */
v->s.me.qpel_put = v->s.qdsp.put_qpel_pixels_tab;
v->s.me.qpel_avg = v->s.qdsp.avg_qpel_pixels_tab;
return 0;
}

View File

@ -1060,9 +1060,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
s->current_picture_ptr->f->repeat_pict = v->rptfrm * 2;
}
s->me.qpel_put = s->qdsp.put_qpel_pixels_tab;
s->me.qpel_avg = s->qdsp.avg_qpel_pixels_tab;
if (avctx->hwaccel) {
s->mb_y = 0;
if (v->field_mode && buf_start_second_field) {