Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 20/24] avcodec/mpegvideo_dec: Don't use MotionEstContext as scratch space
Date: Thu,  3 Nov 2022 03:57:36 +0100
Message-ID: <AS8P250MB0744498B2861D513D96E1E1F8F389@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737EF25F056808CC9F6896C8F349@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

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>
---
 libavcodec/h263dec.c                     | 8 --------
 libavcodec/mpv_reconstruct_mb_template.c | 6 ++++--
 libavcodec/mss2.c                        | 4 ----
 libavcodec/vc1dec.c                      | 3 ---
 4 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 90dd32bd3a..5f5ecfdddc 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -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;
 
diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c
index 5023fe58ae..6f7a5fb1b4 100644
--- a/libavcodec/mpv_reconstruct_mb_template.c
+++ b/libavcodec/mpv_reconstruct_mb_template.c
@@ -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);
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 2469718c8f..1d1ed11f54 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -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;
 }
 
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index bcfd2bae0b..e7ad540d84 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -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) {
-- 
2.34.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".

  parent reply	other threads:[~2022-11-03  2:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 23:41 [FFmpeg-devel] [PATCH 01/19] avcodec/vc1: Don't check for AVCodecContext.codec Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 02/19] avcodec/vc1: Remove always-false check Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 03/19] avcodec/vc1: Don't check for errors for complete VLC Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 04/19] avcodec/vc1: Don't use VLC to read bfraction Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 05/19] avcodec/vc1_parser: Set parse_only only once Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 06/19] avcodec/vc1_parser: Don't call ff_vc1_init_common() Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 07/19] avcodec/vc1: Move setting res_fasttx-IDCT functions to vc1dec.c Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 08/19] avcodec/vc1data: Remove duplicate defines Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 09/19] avcodec/vc1data: Remove declarations of inexistent arrays Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 10/19] avcodec/vc1data: Move VLC codes/lengths tables to a header Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 11/19] avcodec/vc1: Move ff_vc1_init_common() to vc1dec.c Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 12/19] avcodec/vc1_block: Don't duplicate #defines Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 13/19] avcodec/msmpeg4dec: Factor initializing VLCs shared with VC-1 out Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 14/19] avcodec/vc1dec: Don't open and close decoder during init Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 15/19] avcodec/vc1dec: Factor (re)initializing code out Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 16/19] avcodec/vc1dec: Return early upon error Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 17/19] avcodec/msmpeg4data: Move data shared between msmpeg4 and VC-1 out Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 18/19] avcodec/vc1dec: Split VC-1 decoders from msmpeg4 Andreas Rheinhardt
2022-10-30 23:56 ` [FFmpeg-devel] [PATCH 19/19] avcodec/vc1_block: Remove redundant write Andreas Rheinhardt
2022-11-03  2:57 ` Andreas Rheinhardt [this message]
2022-11-03  2:57 ` [FFmpeg-devel] [PATCH 21/24] avcodec/vc1dec: Remove VC-1 decoders->H.263 decoder dependency Andreas Rheinhardt
2022-11-03  2:57 ` [FFmpeg-devel] [PATCH 22/24] avcodec/h263dec: Move initializing qpel DSP context to mpeg4videodec.c Andreas Rheinhardt
2022-11-03  2:57 ` [FFmpeg-devel] [PATCH 23/24] avcodec/mpegvideo_enc: Move initializing QpelDSPCtx to mpeg4videoenc.c Andreas Rheinhardt
2022-11-03  2:57 ` [FFmpeg-devel] [PATCH 24/24] avcodec/motion_est: Remove unused field Andreas Rheinhardt
2022-11-05 17:18 ` [FFmpeg-devel] [PATCH 01/19] avcodec/vc1: Don't check for AVCodecContext.codec Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB0744498B2861D513D96E1E1F8F389@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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