summaryrefslogtreecommitdiff
path: root/libavcodec/mpv_reconstruct_mb_template.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/mpegvideo_dec: Don't use MotionEstContext as scratch spaceAndreas Rheinhardt2022-11-061-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* avcodec/mpv_reconstruct_mb_template: Optimize dead code awayAndreas Rheinhardt2022-10-201-1/+2
| | | | | | | None of the MPEG-1/2 codecs support frame threading, so one can optimize the check for it away. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Split ff_mpv_reconstruct_mb() into de/encoder partAndreas Rheinhardt2022-10-201-0/+300
This has the advantage of not having to check for whether a given MpegEncContext is actually a decoder or an encoder context at runtime. To do so, mpv_reconstruct_mb_internal() is moved into a new template file that is included by both mpegvideo_enc.c and mpegvideo_dec.c; the decoder-only code (mainly lowres) are also moved to mpegvideo_dec.c. The is_encoder checks are changed to #if IS_ENCODER in order to avoid having to include headers for decoder-only functions in mpegvideo_enc.c. This approach also has the advantage that it is easy to adapt mpv_reconstruct_mb_internal() to using different structures for decoders and encoders (e.g. the check for whether a macroblock should be processed for the encoder or not uses MpegEncContext elements that make no sense for decoders and should not be part of their context). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>