[FFmpeg-cvslog] lavc/mpeg*: drop the XvMC hwaccel code

Anton Khirnov git at videolan.org
Tue Feb 15 11:19:25 EET 2022


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Feb  1 10:15:51 2022 +0100| [be95df12bb06b183c8d2aea3b0831fdf05466cf3] | committer: Anton Khirnov

lavc/mpeg*: drop the XvMC hwaccel code

XvMC was last relevant over 10 years ago, if ever. There is no reason to
use it today.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be95df12bb06b183c8d2aea3b0831fdf05466cf3
---

 Changelog                      |   1 +
 MAINTAINERS                    |   1 -
 configure                      |   9 -
 libavcodec/Makefile            |   2 -
 libavcodec/avcodec.h           |  12 --
 libavcodec/error_resilience.c  |   9 -
 libavcodec/hwaccels.h          |   2 -
 libavcodec/hwconfig.h          |   2 -
 libavcodec/mpeg12dec.c         |  43 -----
 libavcodec/mpegvideo.c         |   6 -
 libavcodec/mpegvideo.h         |   2 -
 libavcodec/mpegvideo_xvmc.c    | 377 -----------------------------------------
 libavcodec/version.h           |   2 +-
 libavcodec/x86/blockdsp_init.c |   4 -
 libavcodec/xvmc_internal.h     |  31 ----
 15 files changed, 2 insertions(+), 501 deletions(-)

diff --git a/Changelog b/Changelog
index f1a045fdb3..5ad2cef800 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version 5.1:
 - dialogue enhance audio filter
+- dropped obsolete XvMC hwaccel
 
 
 version 5.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index c065e94498..f33ccbd1d9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -266,7 +266,6 @@ Codecs:
   xan.c                                 Mike Melanson
   xbm*                                  Paul B Mahol
   xface                                 Stefano Sabatini
-  xvmc.c                                Ivan Kalvachev
   xwd*                                  Paul B Mahol
 
 Hardware acceleration:
diff --git a/configure b/configure
index 9222de8cd1..bab1cd372b 100755
--- a/configure
+++ b/configure
@@ -1900,7 +1900,6 @@ HWACCEL_AUTODETECT_LIBRARY_LIST="
     videotoolbox
     vulkan
     v4l2_m2m
-    xvmc
 "
 
 # catchall list of things that require external libs to link
@@ -3006,7 +3005,6 @@ vaapi_x11_deps="xlib_x11"
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
 vulkan_deps_any="libdl LoadLibrary"
-xvmc_deps="X11_extensions_XvMClib_h"
 
 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
 av1_d3d11va_hwaccel_select="av1_decoder"
@@ -3054,16 +3052,12 @@ mjpeg_nvdec_hwaccel_deps="nvdec"
 mjpeg_nvdec_hwaccel_select="mjpeg_decoder"
 mjpeg_vaapi_hwaccel_deps="vaapi"
 mjpeg_vaapi_hwaccel_select="mjpeg_decoder"
-mpeg_xvmc_hwaccel_deps="xvmc"
-mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
 mpeg1_nvdec_hwaccel_deps="nvdec"
 mpeg1_nvdec_hwaccel_select="mpeg1video_decoder"
 mpeg1_vdpau_hwaccel_deps="vdpau"
 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
 mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder"
-mpeg1_xvmc_hwaccel_deps="xvmc"
-mpeg1_xvmc_hwaccel_select="mpeg1video_decoder"
 mpeg2_d3d11va_hwaccel_deps="d3d11va"
 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
 mpeg2_d3d11va2_hwaccel_deps="d3d11va"
@@ -3078,8 +3072,6 @@ mpeg2_vdpau_hwaccel_deps="vdpau"
 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
 mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
-mpeg2_xvmc_hwaccel_deps="xvmc"
-mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
 mpeg4_nvdec_hwaccel_deps="nvdec"
 mpeg4_nvdec_hwaccel_select="mpeg4_decoder"
 mpeg4_vaapi_hwaccel_deps="vaapi"
@@ -6308,7 +6300,6 @@ check_headers unistd.h
 check_headers valgrind/valgrind.h
 check_func_headers VideoToolbox/VTCompressionSession.h VTCompressionSessionPrepareToEncodeFrames -framework VideoToolbox
 check_headers windows.h
-check_headers X11/extensions/XvMClib.h
 check_headers asm/types.h
 
 # it seems there are versions of clang in some distros that try to use the
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cfc70a3eaf..6076b4ad80 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -963,7 +963,6 @@ OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)        += vaapi_mjpeg.o
 OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL)        += nvdec_mpeg12.o
 OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)        += vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
-OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL)         += mpegvideo_xvmc.o
 OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL)      += dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)        += dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL)        += nvdec_mpeg12.o
@@ -971,7 +970,6 @@ OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)          += qsvdec.o
 OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)        += vaapi_mpeg2.o
 OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL)        += vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
-OBJS-$(CONFIG_MPEG2_XVMC_HWACCEL)         += mpegvideo_xvmc.o
 OBJS-$(CONFIG_MPEG4_NVDEC_HWACCEL)        += nvdec_mpeg4.o
 OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL)        += vaapi_mpeg4.o
 OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL)        += vdpau_mpeg4.o
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ec1a0566a4..acb7ae0e14 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2119,7 +2119,6 @@ typedef struct AVHWAccel {
      *
      * Meaningful slice information (codec specific) is guaranteed to
      * be parsed at this point. This function is mandatory.
-     * The only exception is XvMC, that works on MB level.
      *
      * @param avctx the codec context
      * @param buf the slice data buffer base
@@ -2148,17 +2147,6 @@ typedef struct AVHWAccel {
      */
     int frame_priv_data_size;
 
-    /**
-     * Called for every Macroblock in a slice.
-     *
-     * XvMC uses it to replace the ff_mpv_reconstruct_mb().
-     * Instead of decoding to raw picture, MB parameters are
-     * stored in an array provided by the video driver.
-     *
-     * @param s the mpeg context
-     */
-    void (*decode_mb)(struct MpegEncContext *s);
-
     /**
      * Initialize the hwaccel private data.
      *
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 551ef914ce..91b7b277a3 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -736,12 +736,6 @@ static int is_intra_more_likely(ERContext *s)
     if (undamaged_count < 5)
         return 0; // almost all MBs damaged -> use temporal prediction
 
-    // prevent dsp.sad() check, that requires access to the image
-    if (CONFIG_XVMC    &&
-        s->avctx->hwaccel && s->avctx->hwaccel->decode_mb &&
-        s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I)
-        return 1;
-
     skip_amount     = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
     is_intra_likely = 0;
 
@@ -1229,9 +1223,6 @@ void ff_er_frame_end(ERContext *s)
     } else
         guess_mv(s);
 
-    /* the filters below manipulate raw image, skip them */
-    if (CONFIG_XVMC && s->avctx->hwaccel && s->avctx->hwaccel->decode_mb)
-        goto ec_clean;
     /* fill DC for inter blocks */
     for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
         for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 1e7b464950..ff4daca0e2 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -47,7 +47,6 @@ extern const AVHWAccel ff_mjpeg_vaapi_hwaccel;
 extern const AVHWAccel ff_mpeg1_nvdec_hwaccel;
 extern const AVHWAccel ff_mpeg1_vdpau_hwaccel;
 extern const AVHWAccel ff_mpeg1_videotoolbox_hwaccel;
-extern const AVHWAccel ff_mpeg1_xvmc_hwaccel;
 extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel;
 extern const AVHWAccel ff_mpeg2_d3d11va2_hwaccel;
 extern const AVHWAccel ff_mpeg2_nvdec_hwaccel;
@@ -55,7 +54,6 @@ extern const AVHWAccel ff_mpeg2_dxva2_hwaccel;
 extern const AVHWAccel ff_mpeg2_vaapi_hwaccel;
 extern const AVHWAccel ff_mpeg2_vdpau_hwaccel;
 extern const AVHWAccel ff_mpeg2_videotoolbox_hwaccel;
-extern const AVHWAccel ff_mpeg2_xvmc_hwaccel;
 extern const AVHWAccel ff_mpeg4_nvdec_hwaccel;
 extern const AVHWAccel ff_mpeg4_vaapi_hwaccel;
 extern const AVHWAccel ff_mpeg4_vdpau_hwaccel;
diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h
index f421dc909f..721424912c 100644
--- a/libavcodec/hwconfig.h
+++ b/libavcodec/hwconfig.h
@@ -78,8 +78,6 @@ typedef struct AVCodecHWConfigInternal {
     HW_CONFIG_HWACCEL(1, 1, 1, VIDEOTOOLBOX, VIDEOTOOLBOX, ff_ ## codec ## _videotoolbox_hwaccel)
 #define HWACCEL_D3D11VA(codec) \
     HW_CONFIG_HWACCEL(0, 0, 1, D3D11VA_VLD,  NONE,         ff_ ## codec ## _d3d11va_hwaccel)
-#define HWACCEL_XVMC(codec) \
-    HW_CONFIG_HWACCEL(0, 0, 1, XVMC,         NONE,         ff_ ## codec ## _xvmc_hwaccel)
 
 #define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \
     &(const AVCodecHWConfigInternal) { \
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index f4e39e5d22..9e4e26aa67 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -51,7 +51,6 @@
 #include "profiles.h"
 #include "startcode.h"
 #include "thread.h"
-#include "xvmc_internal.h"
 
 #define A53_MAX_CC_COUNT 2000
 
@@ -763,9 +762,6 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
             memset(s->last_mv, 0, sizeof(s->last_mv));
         }
         s->mb_intra = 1;
-        // if 1, we memcpy blocks in xvmcvideo
-        if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
-            ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks
 
         if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
             if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
@@ -994,10 +990,6 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
                 return AVERROR_INVALIDDATA;
             }
 
-            // if 1, we memcpy blocks in xvmcvideo
-            if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
-                ff_xvmc_pack_pblocks(s, cbp);
-
             if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
                 if (s->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
                     for (i = 0; i < 6; i++) {
@@ -1115,9 +1107,6 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
 #if CONFIG_MPEG1_NVDEC_HWACCEL
     AV_PIX_FMT_CUDA,
 #endif
-#if CONFIG_MPEG1_XVMC_HWACCEL
-    AV_PIX_FMT_XVMC,
-#endif
 #if CONFIG_MPEG1_VDPAU_HWACCEL
     AV_PIX_FMT_VDPAU,
 #endif
@@ -1129,9 +1118,6 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
 #if CONFIG_MPEG2_NVDEC_HWACCEL
     AV_PIX_FMT_CUDA,
 #endif
-#if CONFIG_MPEG2_XVMC_HWACCEL
-    AV_PIX_FMT_XVMC,
-#endif
 #if CONFIG_MPEG2_VDPAU_HWACCEL
     AV_PIX_FMT_VDPAU,
 #endif
@@ -1183,21 +1169,6 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
     return ff_thread_get_format(avctx, pix_fmts);
 }
 
-static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
-{
-    // until then pix_fmt may be changed right after codec init
-    if (avctx->hwaccel)
-        if (avctx->idct_algo == FF_IDCT_AUTO)
-            avctx->idct_algo = FF_IDCT_NONE;
-
-    if (avctx->hwaccel && avctx->pix_fmt == AV_PIX_FMT_XVMC) {
-        Mpeg1Context *s1 = avctx->priv_data;
-        MpegEncContext *s = &s1->mpeg_enc_ctx;
-
-        s->pack_pblocks = 1;
-    }
-}
-
 /* Call this function when we know all parameters.
  * It may be called in different places for MPEG-1 and MPEG-2. */
 static int mpeg_decode_postinit(AVCodecContext *avctx)
@@ -1321,7 +1292,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
         } // MPEG-2
 
         avctx->pix_fmt = mpeg_get_pixelformat(avctx);
-        setup_hwaccel_for_pixfmt(avctx);
 
         /* Quantization matrices may need reordering
          * if DCT permutation is changed. */
@@ -1809,10 +1779,6 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
     }
 
     for (;;) {
-        // If 1, we memcpy blocks in xvmcvideo.
-        if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
-            ff_xvmc_init_block(s); // set s->block
-
         if ((ret = mpeg_decode_mb(s, s->block)) < 0)
             return ret;
 
@@ -2166,7 +2132,6 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
     s->codec_id             =
     s->avctx->codec_id      = AV_CODEC_ID_MPEG1VIDEO;
     s->out_format           = FMT_MPEG1;
-    s->swap_uv              = 0; // AFAIK VCR2 does not have SEQ_HEADER
     if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
         s->low_delay = 1;
 
@@ -2195,7 +2160,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
     s->low_delay        = 1;
 
     avctx->pix_fmt = mpeg_get_pixelformat(avctx);
-    setup_hwaccel_for_pixfmt(avctx);
 
     ff_mpv_idct_init(s);
     if ((ret = ff_mpv_common_init(s)) < 0)
@@ -2222,7 +2186,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
     if (s->codec_tag == AV_RL32("BW10")) {
         s->codec_id              = s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
     } else {
-        s->swap_uv = 1; // in case of xvmc we need to swap uv for each MB
         s->codec_id              = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
     }
     s1->save_width           = s->width;
@@ -2924,9 +2887,6 @@ const AVCodec ff_mpeg1video_decoder = {
 #endif
 #if CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL
                                HWACCEL_VIDEOTOOLBOX(mpeg1),
-#endif
-#if CONFIG_MPEG1_XVMC_HWACCEL
-                               HWACCEL_XVMC(mpeg1),
 #endif
                                NULL
                            },
@@ -2972,9 +2932,6 @@ const AVCodec ff_mpeg2video_decoder = {
 #endif
 #if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL
                         HWACCEL_VIDEOTOOLBOX(mpeg2),
-#endif
-#if CONFIG_MPEG2_XVMC_HWACCEL
-                        HWACCEL_XVMC(mpeg2),
 #endif
                         NULL
                     },
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a4ed1f8b36..fc970e9614 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1644,12 +1644,6 @@ skip_idct:
 
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
-    if (CONFIG_XVMC &&
-        s->avctx->hwaccel && s->avctx->hwaccel->decode_mb) {
-        s->avctx->hwaccel->decode_mb(s); //xvmc uses pblocks
-        return;
-    }
-
     if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
        /* print DCT coefficients */
        av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 77d1593928..501ba26750 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -467,8 +467,6 @@ typedef struct MpegEncContext {
     int rtp_payload_size;
 
     uint8_t *ptr_lastgob;
-    int swap_uv;             //vcr2 codec is an MPEG-2 variant with U and V swapped
-    int pack_pblocks;        //xvmc needs to keep blocks without gaps.
     int16_t (*pblocks[12])[64];
 
     int16_t (*block)[64]; ///< points to one of the following blocks
diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c
deleted file mode 100644
index f3ae9c4c0a..0000000000
--- a/libavcodec/mpegvideo_xvmc.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * XVideo Motion Compensation
- * Copyright (c) 2003 Ivan Kalvachev
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <limits.h>
-#include <X11/extensions/XvMC.h>
-
-#include "avcodec.h"
-#include "mpegutils.h"
-#include "mpegvideo.h"
-#include "mpegvideodec.h"
-
-#undef NDEBUG
-#include <assert.h>
-
-#include "xvmc.h"
-#include "xvmc_internal.h"
-#include "version.h"
-
-/**
- * Initialize the block field of the MpegEncContext pointer passed as
- * parameter after making sure that the data is not corrupted.
- * In order to implement something like direct rendering instead of decoding
- * coefficients in s->blocks and then copying them, copy them directly
- * into the data_blocks array provided by xvmc.
- */
-void ff_xvmc_init_block(MpegEncContext *s)
-{
-    struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
-    assert(render && render->xvmc_id == AV_XVMC_ID);
-
-    s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64);
-}
-
-static void exchange_uv(MpegEncContext *s)
-{
-    int16_t (*tmp)[64];
-
-    tmp           = s->pblocks[4];
-    s->pblocks[4] = s->pblocks[5];
-    s->pblocks[5] = tmp;
-}
-
-/**
- * Fill individual block pointers, so there are no gaps in the data_block array
- * in case not all blocks in the macroblock are coded.
- */
-void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
-{
-    int i, j = 0;
-    const int mb_block_count = 4 + (1 << s->chroma_format);
-
-    cbp <<= 12-mb_block_count;
-    for (i = 0; i < mb_block_count; i++) {
-        if (cbp & (1 << 11))
-            s->pblocks[i] = &s->block[j++];
-        else
-            s->pblocks[i] = NULL;
-        cbp += cbp;
-    }
-    if (s->swap_uv) {
-        exchange_uv(s);
-    }
-}
-
-/**
- * Find and store the surfaces that are used as reference frames.
- * This function should be called for every new field and/or frame.
- * It should be safe to call the function a few times for the same field.
- */
-static int ff_xvmc_field_start(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
-{
-    struct MpegEncContext *s = avctx->priv_data;
-    struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
-    const int mb_block_count = 4 + (1 << s->chroma_format);
-
-    assert(avctx);
-    if (!render || render->xvmc_id != AV_XVMC_ID ||
-        !render->data_blocks || !render->mv_blocks ||
-        (unsigned int)render->allocated_mv_blocks   > INT_MAX/(64*6) ||
-        (unsigned int)render->allocated_data_blocks > INT_MAX/64     ||
-        !render->p_surface) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Render token doesn't look as expected.\n");
-        return -1; // make sure that this is a render packet
-    }
-
-    if (render->filled_mv_blocks_num) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Rendering surface contains %i unprocessed blocks.\n",
-               render->filled_mv_blocks_num);
-        return -1;
-    }
-    if (render->allocated_mv_blocks   < 1 ||
-        render->allocated_data_blocks <  render->allocated_mv_blocks*mb_block_count ||
-        render->start_mv_blocks_num   >= render->allocated_mv_blocks                ||
-        render->next_free_data_block_num >
-                        render->allocated_data_blocks -
-                        mb_block_count*(render->allocated_mv_blocks-render->start_mv_blocks_num)) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Rendering surface doesn't provide enough block structures to work with.\n");
-        return -1;
-    }
-
-    render->picture_structure = s->picture_structure;
-    render->flags             = s->first_field ? 0 : XVMC_SECOND_FIELD;
-    render->p_future_surface  = NULL;
-    render->p_past_surface    = NULL;
-
-    switch(s->pict_type) {
-        case  AV_PICTURE_TYPE_I:
-            return 0; // no prediction from other frames
-        case  AV_PICTURE_TYPE_B:
-            next = (struct xvmc_pix_fmt*)s->next_picture.f->data[2];
-            if (!next)
-                return -1;
-            if (next->xvmc_id != AV_XVMC_ID)
-                return -1;
-            render->p_future_surface = next->p_surface;
-            // no return here, going to set forward prediction
-        case  AV_PICTURE_TYPE_P:
-            last = (struct xvmc_pix_fmt*)s->last_picture.f->data[2];
-            if (!last)
-                last = render; // predict second field from the first
-            if (last->xvmc_id != AV_XVMC_ID)
-                return -1;
-            render->p_past_surface = last->p_surface;
-            return 0;
-    }
-
-return -1;
-}
-
-/**
- * Complete frame/field rendering by passing any remaining blocks.
- * Normally ff_draw_horiz_band() is called for each slice, however,
- * some leftover blocks, for example from error_resilience(), may remain.
- * It should be safe to call the function a few times for the same field.
- */
-static int ff_xvmc_field_end(AVCodecContext *avctx)
-{
-    struct MpegEncContext *s = avctx->priv_data;
-    struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
-    assert(render);
-
-    if (render->filled_mv_blocks_num > 0)
-        ff_mpeg_draw_horiz_band(s, 0, 0);
-    return 0;
-}
-
-/**
- * Synthesize the data needed by XvMC to render one macroblock of data.
- * Fill all relevant fields, if necessary do IDCT.
- */
-static void ff_xvmc_decode_mb(struct MpegEncContext *s)
-{
-    XvMCMacroBlock *mv_block;
-    struct xvmc_pix_fmt *render;
-    int i, cbp, blocks_per_mb;
-
-    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-
-
-    if (s->encoding) {
-        av_log(s->avctx, AV_LOG_ERROR, "XVMC doesn't support encoding!!!\n");
-        return;
-    }
-
-    // from ff_mpv_reconstruct_mb(), update DC predictors for P macroblocks
-    if (!s->mb_intra) {
-        s->last_dc[0] =
-        s->last_dc[1] =
-        s->last_dc[2] =  128 << s->intra_dc_precision;
-    }
-
-    // MC doesn't skip blocks
-    s->mb_skipped = 0;
-
-
-    // Do I need to export quant when I could not perform postprocessing?
-    // Anyway, it doesn't hurt.
-    s->current_picture.qscale_table[mb_xy] = s->qscale;
-
-    // start of XVMC-specific code
-    render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
-    assert(render);
-    assert(render->xvmc_id == AV_XVMC_ID);
-    assert(render->mv_blocks);
-
-    // take the next free macroblock
-    mv_block = &render->mv_blocks[render->start_mv_blocks_num +
-                                  render->filled_mv_blocks_num];
-
-    mv_block->x        = s->mb_x;
-    mv_block->y        = s->mb_y;
-    mv_block->dct_type = s->interlaced_dct; // XVMC_DCT_TYPE_FRAME/FIELD;
-    if (s->mb_intra) {
-        mv_block->macroblock_type = XVMC_MB_TYPE_INTRA; // no MC, all done
-    } else {
-        mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN;
-
-        if (s->mv_dir & MV_DIR_FORWARD) {
-            mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_FORWARD;
-            // PMV[n][dir][xy] = mv[dir][n][xy]
-            mv_block->PMV[0][0][0] = s->mv[0][0][0];
-            mv_block->PMV[0][0][1] = s->mv[0][0][1];
-            mv_block->PMV[1][0][0] = s->mv[0][1][0];
-            mv_block->PMV[1][0][1] = s->mv[0][1][1];
-        }
-        if (s->mv_dir & MV_DIR_BACKWARD) {
-            mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_BACKWARD;
-            mv_block->PMV[0][1][0] = s->mv[1][0][0];
-            mv_block->PMV[0][1][1] = s->mv[1][0][1];
-            mv_block->PMV[1][1][0] = s->mv[1][1][0];
-            mv_block->PMV[1][1][1] = s->mv[1][1][1];
-        }
-
-        switch(s->mv_type) {
-            case  MV_TYPE_16X16:
-                mv_block->motion_type = XVMC_PREDICTION_FRAME;
-                break;
-            case  MV_TYPE_16X8:
-                mv_block->motion_type = XVMC_PREDICTION_16x8;
-                break;
-            case  MV_TYPE_FIELD:
-                mv_block->motion_type = XVMC_PREDICTION_FIELD;
-                if (s->picture_structure == PICT_FRAME) {
-                    mv_block->PMV[0][0][1] <<= 1;
-                    mv_block->PMV[1][0][1] <<= 1;
-                    mv_block->PMV[0][1][1] <<= 1;
-                    mv_block->PMV[1][1][1] <<= 1;
-                }
-                break;
-            case  MV_TYPE_DMV:
-                mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME;
-                if (s->picture_structure == PICT_FRAME) {
-
-                    mv_block->PMV[0][0][0] = s->mv[0][0][0];      // top from top
-                    mv_block->PMV[0][0][1] = s->mv[0][0][1] << 1;
-
-                    mv_block->PMV[0][1][0] = s->mv[0][0][0];      // bottom from bottom
-                    mv_block->PMV[0][1][1] = s->mv[0][0][1] << 1;
-
-                    mv_block->PMV[1][0][0] = s->mv[0][2][0];      // dmv00, top from bottom
-                    mv_block->PMV[1][0][1] = s->mv[0][2][1] << 1; // dmv01
-
-                    mv_block->PMV[1][1][0] = s->mv[0][3][0];      // dmv10, bottom from top
-                    mv_block->PMV[1][1][1] = s->mv[0][3][1] << 1; // dmv11
-
-                } else {
-                    mv_block->PMV[0][1][0] = s->mv[0][2][0];      // dmv00
-                    mv_block->PMV[0][1][1] = s->mv[0][2][1];      // dmv01
-                }
-                break;
-            default:
-                assert(0);
-        }
-
-        mv_block->motion_vertical_field_select = 0;
-
-        // set correct field references
-        if (s->mv_type == MV_TYPE_FIELD || s->mv_type == MV_TYPE_16X8) {
-            mv_block->motion_vertical_field_select |= s->field_select[0][0];
-            mv_block->motion_vertical_field_select |= s->field_select[1][0] << 1;
-            mv_block->motion_vertical_field_select |= s->field_select[0][1] << 2;
-            mv_block->motion_vertical_field_select |= s->field_select[1][1] << 3;
-        }
-    } // !intra
-    // time to handle data blocks
-    mv_block->index = render->next_free_data_block_num;
-
-    blocks_per_mb = 6;
-    if (s->chroma_format >= 2) {
-        blocks_per_mb = 4 + (1 << s->chroma_format);
-    }
-
-    // calculate cbp
-    cbp = 0;
-    for (i = 0; i < blocks_per_mb; i++) {
-        cbp += cbp;
-        if (s->block_last_index[i] >= 0)
-            cbp++;
-    }
-
-    if (s->avctx->flags & AV_CODEC_FLAG_GRAY) {
-        if (s->mb_intra) {                                   // intra frames are always full chroma blocks
-            for (i = 4; i < blocks_per_mb; i++) {
-                memset(s->pblocks[i], 0, sizeof(*s->pblocks[i]));  // so we need to clear them
-                if (!render->unsigned_intra)
-                    *s->pblocks[i][0] = 1 << 10;
-            }
-        } else {
-            cbp &= 0xf << (blocks_per_mb - 4);
-            blocks_per_mb = 4;                               // luminance blocks only
-        }
-    }
-    mv_block->coded_block_pattern = cbp;
-    if (cbp == 0)
-        mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
-
-    for (i = 0; i < blocks_per_mb; i++) {
-        if (s->block_last_index[i] >= 0) {
-            // I do not have unsigned_intra MOCO to test, hope it is OK.
-            if (s->mb_intra && (render->idct || !render->unsigned_intra))
-                *s->pblocks[i][0] -= 1 << 10;
-            if (!render->idct) {
-                s->idsp.idct(*s->pblocks[i]);
-                /* It is unclear if MC hardware requires pixel diff values to be
-                 * in the range [-255;255]. TODO: Clipping if such hardware is
-                 * ever found. As of now it would only be an unnecessary
-                 * slowdown. */
-            }
-            // copy blocks only if the codec doesn't support pblocks reordering
-            if (!s->pack_pblocks) {
-                memcpy(&render->data_blocks[render->next_free_data_block_num*64],
-                       s->pblocks[i], sizeof(*s->pblocks[i]));
-            }
-            render->next_free_data_block_num++;
-        }
-    }
-    render->filled_mv_blocks_num++;
-
-    assert(render->filled_mv_blocks_num     <= render->allocated_mv_blocks);
-    assert(render->next_free_data_block_num <= render->allocated_data_blocks);
-    /* The above conditions should not be able to fail as long as this function
-     * is used and the following 'if ()' automatically calls a callback to free
-     * blocks. */
-
-
-    if (render->filled_mv_blocks_num == render->allocated_mv_blocks)
-        ff_mpeg_draw_horiz_band(s, 0, 0);
-}
-
-#if CONFIG_MPEG1_XVMC_HWACCEL
-const AVHWAccel ff_mpeg1_xvmc_hwaccel = {
-    .name           = "mpeg1_xvmc",
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_MPEG1VIDEO,
-    .pix_fmt        = AV_PIX_FMT_XVMC,
-    .start_frame    = ff_xvmc_field_start,
-    .end_frame      = ff_xvmc_field_end,
-    .decode_slice   = NULL,
-    .decode_mb      = ff_xvmc_decode_mb,
-    .priv_data_size = 0,
-};
-#endif
-
-#if CONFIG_MPEG2_XVMC_HWACCEL
-const AVHWAccel ff_mpeg2_xvmc_hwaccel = {
-    .name           = "mpeg2_xvmc",
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = AV_CODEC_ID_MPEG2VIDEO,
-    .pix_fmt        = AV_PIX_FMT_XVMC,
-    .start_frame    = ff_xvmc_field_start,
-    .end_frame      = ff_xvmc_field_end,
-    .decode_slice   = NULL,
-    .decode_mb      = ff_xvmc_decode_mb,
-    .priv_data_size = 0,
-};
-#endif
diff --git a/libavcodec/version.h b/libavcodec/version.h
index a46fb05f1a..b5867ad041 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  59
-#define LIBAVCODEC_VERSION_MINOR  20
+#define LIBAVCODEC_VERSION_MINOR  21
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c
index 8b01a447cd..be3eef0021 100644
--- a/libavcodec/x86/blockdsp_init.c
+++ b/libavcodec/x86/blockdsp_init.c
@@ -44,10 +44,6 @@ av_cold void ff_blockdsp_init_x86(BlockDSPContext *c,
         c->clear_blocks = ff_clear_blocks_mmx;
     }
 
-    /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
-    if (CONFIG_XVMC && avctx->hwaccel && avctx->hwaccel->decode_mb)
-        return;
-
     if (EXTERNAL_SSE(cpu_flags)) {
         c->clear_block  = ff_clear_block_sse;
         c->clear_blocks = ff_clear_blocks_sse;
diff --git a/libavcodec/xvmc_internal.h b/libavcodec/xvmc_internal.h
deleted file mode 100644
index d365ef0266..0000000000
--- a/libavcodec/xvmc_internal.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * XVideo Motion Compensation internal functions
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_XVMC_INTERNAL_H
-#define AVCODEC_XVMC_INTERNAL_H
-
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "version.h"
-
-void ff_xvmc_init_block(MpegEncContext *s);
-void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp);
-
-#endif /* AVCODEC_XVMC_INTERNAL_H */



More information about the ffmpeg-cvslog mailing list