History

Convert XvMC to hwaccel v3

Ivan Kalvachev committed 12 years ago

Commit 1c63aed1 parent c19f19314 files · +122 −139Browse files

Unified · Split

14 files
  1. configure +9 −1
  2. libavcodec/Makefile +3 −2
  3. libavcodec/allcodecs.c +2 −0
  4. libavcodec/avcodec.h +22 −2
  5. libavcodec/error_resilience.c +6 −14
  6. libavcodec/mpeg12dec.c +19 −72
  7. libavcodec/mpegvideo.c +3 −23
  8. libavcodec/mpegvideo.h +1 −0
  9. libavcodec/mpegvideo_xvmc.c +46 −7
  10. libavcodec/x86/dsputil_init.c +1 −7
  11. libavcodec/xvmc.h +0 −4
  12. libavcodec/xvmc_internal.h +0 −7
  13. libavutil/pixdesc.c +6 −0
  14. libavutil/pixfmt.h +4 −0
configure+9−1
@@ -1318,6 +1318,7 @@ HWACCEL_LIST=" · 1317 unmodified lines
13181318 vaapi
13191319 vda
13201320 vdpau
1321+ xvmc
13211322 "
13221323
13231324 LIBRARY_LIST="
@@ -2039,6 +2040,7 @@ vaapi_deps="va_va_h" · 715 unmodified lines
20392040 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
20402041 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
20412042 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
2043+xvmc_deps="X11_extensions_XvMClib_h"
20422044
20432045 h263_vaapi_hwaccel_deps="vaapi"
20442046 h263_vaapi_hwaccel_select="h263_decoder"
@@ -2059,10 +2061,14 @@ h264_vdpau_hwaccel_deps="vdpau" · 14 unmodified lines
20592061 h264_vdpau_hwaccel_select="h264_decoder"
20602062 mpeg_vdpau_decoder_deps="vdpau"
20612063 mpeg_vdpau_decoder_select="mpeg2video_decoder"
2064+mpeg_xvmc_hwaccel_deps="xvmc"
2065+mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
20622066 mpeg1_vdpau_decoder_deps="vdpau"
20632067 mpeg1_vdpau_decoder_select="mpeg1video_decoder"
20642068 mpeg1_vdpau_hwaccel_deps="vdpau"
20652069 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
2070+mpeg1_xvmc_hwaccel_deps="xvmc"
2071+mpeg1_xvmc_hwaccel_select="mpeg1video_decoder"
20662072 mpeg2_crystalhd_decoder_select="crystalhd"
20672073 mpeg2_dxva2_hwaccel_deps="dxva2"
20682074 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
@@ -2070,6 +2076,8 @@ mpeg2_vaapi_hwaccel_deps="vaapi" · 1 unmodified line
20702076 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
20712077 mpeg2_vdpau_hwaccel_deps="vdpau"
20722078 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2079+mpeg2_xvmc_hwaccel_deps="xvmc"
2080+mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
20732081 mpeg4_crystalhd_decoder_select="crystalhd"
20742082 mpeg4_vaapi_hwaccel_deps="vaapi"
20752083 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
@@ -2454,7 +2462,7 @@ enable static · 378 unmodified lines
24542462 enable swscale_alpha
24552463
24562464 # Enable hwaccels by default.
2457−enable dxva2 vaapi vdpau
2465+enable dxva2 vaapi vdpau xvmc
24582466
24592467 # build settings
24602468 SHFLAGS='-shared -Wl,-soname,$$(@F)'
libavcodec/Makefile+3−2
@@ -297,7 +297,6 @@ OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o · 296 unmodified lines
297297 OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
298298 OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12.o mpeg12data.o \
299299 mpegvideo.o error_resilience.o
300−OBJS-$(CONFIG_MPEG_XVMC_DECODER) += mpegvideo_xvmc.o
301300 OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
302301 OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
303302 OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
@@ -635,9 +634,11 @@ OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o · 331 unmodified lines
635634 OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o
636635 OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
637636 OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o
637+OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o
638638 OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
639639 OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o vaapi_mpeg.o
640640 OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o
641+OBJS-$(CONFIG_MPEG2_XVMC_HWACCEL) += mpegvideo_xvmc.o
641642 OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o vaapi_mpeg.o
642643 OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL) += vdpau_mpeg4.o
643644 OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o
@@ -827,7 +828,7 @@ SKIPHEADERS += %_tablegen.h \ · 183 unmodified lines
827828 SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h
828829 SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
829830 SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h
830−SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h
831+SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
831832 SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
832833 SKIPHEADERS-$(CONFIG_VDA) += vda.h
833834 SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
libavcodec/allcodecs.c+2−0
@@ -80,7 +80,9 @@ void avcodec_register_all(void) · 79 unmodified lines
8080 REGISTER_HWACCEL(H264_VAAPI, h264_vaapi);
8181 REGISTER_HWACCEL(H264_VDA, h264_vda);
8282 REGISTER_HWACCEL(H264_VDPAU, h264_vdpau);
83+ REGISTER_HWACCEL(MPEG1_XVMC, mpeg1_xvmc);
8384 REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau);
85+ REGISTER_HWACCEL(MPEG2_XVMC, mpeg2_xvmc);
8486 REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2);
8587 REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi);
8688 REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau);
libavcodec/avcodec.h+22−2
@@ -767,7 +767,13 @@ typedef struct RcOverride{ · 766 unmodified lines
767767 #define CODEC_CAP_DR1 0x0002
768768 #define CODEC_CAP_TRUNCATED 0x0008
769769 #if FF_API_XVMC
770−/* Codec can export data for HW decoding (XvMC). */
770+/* Codec can export data for HW decoding. This flag indicates that
771+ * the codec would call get_format() with list that might contain HW accelerated
772+ * pixel formats (XvMC, VDPAU, VAAPI, etc). The application can pick any of them
773+ * including raw image format.
774+ * The application can use the passed context to determine bitstream version,
775+ * chroma format, resolution etc.
776+ */
771777 #define CODEC_CAP_HWACCEL 0x0010
772778 #endif /* FF_API_XVMC */
773779 /**
@@ -1695,7 +1701,7 @@ typedef struct AVCodecContext { · 921 unmodified lines
16951701 * XVideo Motion Acceleration
16961702 * - encoding: forbidden
16971703 * - decoding: set by decoder
1698− * @deprecated XvMC support is slated for removal.
1704+ * @deprecated XvMC doesn't need it anymore.
16991705 */
17001706 attribute_deprecated int xvmc_acceleration;
17011707 #endif /* FF_API_XVMC */
@@ -3100,6 +3106,8 @@ typedef struct AVCodec { · 1398 unmodified lines
31003106
31013107 int av_codec_get_max_lowres(const AVCodec *codec);
31023108
3109+struct MpegEncContext;
3110+
31033111 /**
31043112 * AVHWAccel.
31053113 */
@@ -3161,6 +3169,7 @@ typedef struct AVHWAccel { · 55 unmodified lines
31613169 *
31623170 * Meaningful slice information (codec specific) is guaranteed to
31633171 * be parsed at this point. This function is mandatory.
3172+ * The only exception is XvMC, that works on MB level.
31643173 *
31653174 * @param avctx the codec context
31663175 * @param buf the slice data buffer base
@@ -3188,6 +3197,17 @@ typedef struct AVHWAccel { · 21 unmodified lines
31883197 * AVCodecContext.release_buffer().
31893198 */
31903199 int priv_data_size;
3200+
3201+ /**
3202+ * Called for every Macroblock in a slice.
3203+ *
3204+ * XvMC uses it to replace the ff_MPV_decode_mb().
3205+ * Instead of decoding to raw picture, MB parameters are
3206+ * stored in an array provided by the video driver.
3207+ *
3208+ * @param s the mpeg context
3209+ */
3210+ void (*decode_mb)(struct MpegEncContext *s);
31913211 } AVHWAccel;
31923212
31933213 /**
libavcodec/error_resilience.c+6−14
@@ -699,15 +699,11 @@ static int is_intra_more_likely(ERContext *s) · 698 unmodified lines
699699 if (undamaged_count < 5)
700700 return 0; // almost all MBs damaged -> use temporal prediction
701701
702−#if FF_API_XVMC
703−FF_DISABLE_DEPRECATION_WARNINGS
704702 // prevent dsp.sad() check, that requires access to the image
705− if (CONFIG_MPEG_XVMC_DECODER &&
706− s->avctx->xvmc_acceleration &&
703+ if (CONFIG_XVMC &&
704+ s->avctx->hwaccel && s->avctx->hwaccel->decode_mb &&
707705 s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I)
708706 return 1;
709−FF_ENABLE_DEPRECATION_WARNINGS
710−#endif /* FF_API_XVMC */
711707
712708 skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
713709 is_intra_likely = 0;
@@ -770,7 +766,7 @@ void ff_er_frame_start(ERContext *s) · 56 unmodified lines
770766
771767 static int er_supported(ERContext *s)
772768 {
773− if(s->avctx->hwaccel ||
769+ if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice ||
774770 s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
775771 !s->cur_pic ||
776772 s->cur_pic->field_picture
@@ -795,7 +791,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty, · 18 unmodified lines
795791 const int end_xy = s->mb_index2xy[end_i];
796792 int mask = -1;
797793
798− if (s->avctx->hwaccel)
794+ if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice)
799795 return;
800796
801797 if (start_i > end_i || start_xy > end_xy) {
@@ -1188,13 +1184,9 @@ void ff_er_frame_end(ERContext *s) · 386 unmodified lines
11881184 } else
11891185 guess_mv(s);
11901186
1191−#if FF_API_XVMC
1192−FF_DISABLE_DEPRECATION_WARNINGS
1193− /* the filters below are not XvMC compatible, skip them */
1194− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1187+ /* the filters below manipulate raw image, skip them */
1188+ if (CONFIG_XVMC && s->avctx->hwaccel && s->avctx->hwaccel->decode_mb)
11951189 goto ec_clean;
1196−FF_ENABLE_DEPRECATION_WARNINGS
1197−#endif /* FF_API_XVMC */
11981190 /* fill DC for inter blocks */
11991191 for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
12001192 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
libavcodec/mpeg12dec.c+19−72
@@ -666,14 +666,6 @@ static inline int get_qscale(MpegEncContext *s) · 665 unmodified lines
666666 }
667667 }
668668
669−static void exchange_uv(MpegEncContext *s)
670−{
671− int16_t (*tmp)[64];
672−
673− tmp = s->pblocks[4];
674− s->pblocks[4] = s->pblocks[5];
675− s->pblocks[5] = tmp;
676−}
677669
678670 /* motion type (for MPEG-2) */
679671 #define MT_FIELD 1
@@ -777,17 +769,10 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 97 unmodified lines
777769 } else
778770 memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
779771 s->mb_intra = 1;
780−#if FF_API_XVMC
781−FF_DISABLE_DEPRECATION_WARNINGS
782772 // if 1, we memcpy blocks in xvmcvideo
783− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
773+ if (CONFIG_XVMC && s->pack_pblocks) {
784774 ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks
785− if (s->swap_uv) {
786− exchange_uv(s);
787− }
788775 }
789−FF_ENABLE_DEPRECATION_WARNINGS
790−#endif /* FF_API_XVMC */
791776
792777 if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
793778 if (s->flags2 & CODEC_FLAG2_FAST) {
@@ -1000,17 +985,10 @@ FF_ENABLE_DEPRECATION_WARNINGS · 206 unmodified lines
1000985 return -1;
1001986 }
1002987
1003−#if FF_API_XVMC
1004−FF_DISABLE_DEPRECATION_WARNINGS
1005988 //if 1, we memcpy blocks in xvmcvideo
1006− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
989+ if (CONFIG_XVMC && s->pack_pblocks) {
1007990 ff_xvmc_pack_pblocks(s, cbp);
1008− if (s->swap_uv) {
1009− exchange_uv(s);
1010− }
1011991 }
1012−FF_ENABLE_DEPRECATION_WARNINGS
1013−#endif /* FF_API_XVMC */
1014992
1015993 if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
1016994 if (s->flags2 & CODEC_FLAG2_FAST) {
@@ -1134,12 +1112,9 @@ static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, · 117 unmodified lines
11341112 }
11351113
11361114 static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
1137−#if FF_API_XVMC
1138−#if CONFIG_MPEG_XVMC_DECODER
1139− AV_PIX_FMT_XVMC_MPEG2_IDCT,
1140− AV_PIX_FMT_XVMC_MPEG2_MC,
1115+#if CONFIG_MPEG1_XVMC_HWACCEL
1116+ AV_PIX_FMT_XVMC,
11411117 #endif
1142−#endif /* FF_API_XVMC */
11431118 #if CONFIG_MPEG1_VDPAU_HWACCEL
11441119 AV_PIX_FMT_VDPAU_MPEG1,
11451120 AV_PIX_FMT_VDPAU,
@@ -1149,12 +1124,9 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { · 3 unmodified lines
11491124 };
11501125
11511126 static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
1152−#if FF_API_XVMC
1153−#if CONFIG_MPEG_XVMC_DECODER
1154− AV_PIX_FMT_XVMC_MPEG2_IDCT,
1155− AV_PIX_FMT_XVMC_MPEG2_MC,
1127+#if CONFIG_MPEG2_XVMC_HWACCEL
1128+ AV_PIX_FMT_XVMC,
11561129 #endif
1157−#endif /* FF_API_XVMC */
11581130 #if CONFIG_MPEG2_VDPAU_HWACCEL
11591131 AV_PIX_FMT_VDPAU_MPEG2,
11601132 AV_PIX_FMT_VDPAU,
@@ -1191,25 +1163,21 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) · 30 unmodified lines
11911163
11921164 static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
11931165 {
1194−#if FF_API_XVMC
1195−FF_DISABLE_DEPRECATION_WARNINGS
1196− if (avctx->pix_fmt != AV_PIX_FMT_XVMC_MPEG2_IDCT && avctx->pix_fmt != AV_PIX_FMT_XVMC_MPEG2_MC) {
1197− avctx->xvmc_acceleration = 0;
1198− } else if (!avctx->xvmc_acceleration) {
1199− avctx->xvmc_acceleration = 2;
1200− }
1201−FF_ENABLE_DEPRECATION_WARNINGS
1202−#endif /* FF_API_XVMC */
12031166 avctx->hwaccel = ff_find_hwaccel(avctx);
12041167 // until then pix_fmt may be changed right after codec init
1205−#if FF_API_XVMC
1206− if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
1207−#else
1208− if (
1209−#endif
1210− avctx->hwaccel || uses_vdpau(avctx))
1168+ if (avctx->hwaccel || uses_vdpau(avctx))
12111169 if (avctx->idct_algo == FF_IDCT_AUTO)
12121170 avctx->idct_algo = FF_IDCT_SIMPLE;
1171+
1172+ if (avctx->hwaccel && avctx->pix_fmt == AV_PIX_FMT_XVMC) {
1173+ Mpeg1Context *s1 = avctx->priv_data;
1174+ MpegEncContext *s = &s1->mpeg_enc_ctx;
1175+
1176+ s->pack_pblocks = 1;
1177+#if FF_API_XVMC
1178+ avctx->xvmc_acceleration = 2;
1179+#endif /* FF_API_XVMC */
1180+ }
12131181 }
12141182
12151183 /* Call this function when we know all parameters.
@@ -1630,16 +1598,6 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) · 414 unmodified lines
16301598 return -1;
16311599 }
16321600
1633−#if FF_API_XVMC
1634−FF_DISABLE_DEPRECATION_WARNINGS
1635−// MPV_frame_start will call this function too,
1636−// but we need to call it on every field
1637− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1638− if (ff_xvmc_field_start(s, avctx) < 0)
1639− return -1;
1640−FF_ENABLE_DEPRECATION_WARNINGS
1641−#endif /* FF_API_XVMC */
1642−
16431601 return 0;
16441602 }
16451603
@@ -1711,7 +1669,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, · 65 unmodified lines
17111669 return -1;
17121670 }
17131671
1714− if (avctx->hwaccel) {
1672+ if (avctx->hwaccel && avctx->hwaccel->decode_slice) {
17151673 const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
17161674 int start_code = -1;
17171675 buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
@@ -1741,13 +1699,9 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, · 23 unmodified lines
17411699 }
17421700
17431701 for (;;) {
1744−#if FF_API_XVMC
1745−FF_DISABLE_DEPRECATION_WARNINGS
17461702 // If 1, we memcpy blocks in xvmcvideo.
1747− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)
1703+ if (CONFIG_XVMC && s->pack_pblocks)
17481704 ff_xvmc_init_block(s); // set s->block
1749−FF_ENABLE_DEPRECATION_WARNINGS
1750−#endif /* FF_API_XVMC */
17511705
17521706 if (mpeg_decode_mb(s, s->block) < 0)
17531707 return -1;
@@ -1949,13 +1903,6 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) · 195 unmodified lines
19491903 av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
19501904 }
19511905
1952−#if FF_API_XVMC
1953−FF_DISABLE_DEPRECATION_WARNINGS
1954− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1955− ff_xvmc_field_end(s);
1956−FF_ENABLE_DEPRECATION_WARNINGS
1957−#endif /* FF_API_XVMC */
1958−
19591906 /* end of slice reached */
19601907 if (/*s->mb_y << field_pic == s->mb_height &&*/ !s->first_field && !s1->first_slice) {
19611908 /* end of image */
libavcodec/mpegvideo.c+3−23
@@ -39,7 +39,6 @@ · 38 unmodified lines
3939 #include "mpegvideo.h"
4040 #include "mjpegenc.h"
4141 #include "msmpeg4.h"
42−#include "xvmc_internal.h"
4342 #include "thread.h"
4443 #include <limits.h>
4544
@@ -1673,28 +1672,12 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 1627 unmodified lines
16731672 update_noise_reduction(s);
16741673 }
16751674
1676−#if FF_API_XVMC
1677−FF_DISABLE_DEPRECATION_WARNINGS
1678− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1679− return ff_xvmc_field_start(s, avctx);
1680−FF_ENABLE_DEPRECATION_WARNINGS
1681−#endif /* FF_API_XVMC */
1682−
16831675 return 0;
16841676 }
16851677
16861678 /* called after a frame has been decoded. */
16871679 void ff_MPV_frame_end(MpegEncContext *s)
16881680 {
1689−#if FF_API_XVMC
1690−FF_DISABLE_DEPRECATION_WARNINGS
1691− /* redraw edges for the frame if decoding didn't complete */
1692− // just to make sure that all data is rendered.
1693− if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) {
1694− ff_xvmc_field_end(s);
1695− } else
1696−FF_ENABLE_DEPRECATION_WARNINGS
1697−#endif /* FF_API_XVMC */
16981681 if ((s->er.error_count || !(s->avctx->codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND)) &&
16991682 !s->avctx->hwaccel &&
17001683 !(s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) &&
@@ -2618,14 +2601,11 @@ void MPV_decode_mb_internal(MpegEncContext *s, int16_t block[12][64], · 917 unmodified lines
26182601 {
26192602 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
26202603
2621−#if FF_API_XVMC
2622−FF_DISABLE_DEPRECATION_WARNINGS
2623− if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
2624− ff_xvmc_decode_mb(s);//xvmc uses pblocks
2604+ if (CONFIG_XVMC &&
2605+ s->avctx->hwaccel && s->avctx->hwaccel->decode_mb) {
2606+ s->avctx->hwaccel->decode_mb(s);//xvmc uses pblocks
26252607 return;
26262608 }
2627−FF_ENABLE_DEPRECATION_WARNINGS
2628−#endif /* FF_API_XVMC */
26292609
26302610 if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
26312611 /* print DCT coefficients */
libavcodec/mpegvideo.h+1−0
@@ -693,6 +693,7 @@ typedef struct MpegEncContext { · 692 unmodified lines
693693
694694 uint8_t *ptr_lastgob;
695695 int swap_uv; //vcr2 codec is an MPEG-2 variant with U and V swapped
696+ int pack_pblocks; //xvmc needs to keep blocks without gaps.
696697 int16_t (*pblocks[12])[64];
697698
698699 int16_t (*block)[64]; ///< points to one of the following blocks
libavcodec/mpegvideo_xvmc.c+46−7
@@ -32,8 +32,6 @@ · 31 unmodified lines
3232 #include "xvmc_internal.h"
3333 #include "version.h"
3434
35−#if FF_API_XVMC
36−
3735 /**
3836 * Initialize the block field of the MpegEncContext pointer passed as
3937 * parameter after making sure that the data is not corrupted.
@@ -49,6 +47,15 @@ void ff_xvmc_init_block(MpegEncContext *s) · 9 unmodified lines
4947 s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64);
5048 }
5149
50+static void exchange_uv(MpegEncContext *s)
51+{
52+ int16_t (*tmp)[64];
53+
54+ tmp = s->pblocks[4];
55+ s->pblocks[4] = s->pblocks[5];
56+ s->pblocks[5] = tmp;
57+}
58+
5259 /**
5360 * Fill individual block pointers, so there are no gaps in the data_block array
5461 * in case not all blocks in the macroblock are coded.
@@ -66,6 +73,9 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) · 11 unmodified lines
6673 s->pblocks[i] = NULL;
6774 cbp += cbp;
6875 }
76+ if (s->swap_uv) {
77+ exchange_uv(s);
78+ }
6979 }
7080
7181 /**
@@ -73,8 +83,9 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) · 1 unmodified line
7383 * This function should be called for every new field and/or frame.
7484 * It should be safe to call the function a few times for the same field.
7585 */
76−int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
86+static int ff_xvmc_field_start(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
7787 {
88+ struct MpegEncContext *s = avctx->priv_data;
7889 struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
7990 const int mb_block_count = 4 + (1 << s->chroma_format);
8091
@@ -141,20 +152,22 @@ return -1; · 60 unmodified lines
141152 * some leftover blocks, for example from error_resilience(), may remain.
142153 * It should be safe to call the function a few times for the same field.
143154 */
144−void ff_xvmc_field_end(MpegEncContext *s)
155+static int ff_xvmc_field_end(AVCodecContext *avctx)
145156 {
157+ struct MpegEncContext *s = avctx->priv_data;
146158 struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
147159 assert(render);
148160
149161 if (render->filled_mv_blocks_num > 0)
150162 ff_mpeg_draw_horiz_band(s, 0, 0);
163+ return 0;
151164 }
152165
153166 /**
154167 * Synthesize the data needed by XvMC to render one macroblock of data.
155168 * Fill all relevant fields, if necessary do IDCT.
156169 */
157−void ff_xvmc_decode_mb(MpegEncContext *s)
170+static void ff_xvmc_decode_mb(struct MpegEncContext *s)
158171 {
159172 XvMCMacroBlock *mv_block;
160173 struct xvmc_pix_fmt *render;
@@ -313,7 +326,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s) · 152 unmodified lines
313326 * slowdown. */
314327 }
315328 // copy blocks only if the codec doesn't support pblocks reordering
316− if (s->avctx->xvmc_acceleration == 1) {
329+ if (!s->pack_pblocks) {
317330 memcpy(&render->data_blocks[render->next_free_data_block_num*64],
318331 s->pblocks[i], sizeof(*s->pblocks[i]));
319332 }
@@ -333,4 +346,30 @@ void ff_xvmc_decode_mb(MpegEncContext *s) · 13 unmodified lines
333346 ff_mpeg_draw_horiz_band(s, 0, 0);
334347 }
335348
336−#endif /* FF_API_XVMC */
349+#if CONFIG_MPEG1_XVMC_HWACCEL
350+AVHWAccel ff_mpeg1_xvmc_hwaccel = {
351+ .name = "mpeg1_xvmc",
352+ .type = AVMEDIA_TYPE_VIDEO,
353+ .id = AV_CODEC_ID_MPEG1VIDEO,
354+ .pix_fmt = AV_PIX_FMT_XVMC,
355+ .start_frame = ff_xvmc_field_start,
356+ .end_frame = ff_xvmc_field_end,
357+ .decode_slice = NULL,
358+ .decode_mb = ff_xvmc_decode_mb,
359+ .priv_data_size = 0,
360+};
361+#endif
362+
363+#if CONFIG_MPEG2_XVMC_HWACCEL
364+AVHWAccel ff_mpeg2_xvmc_hwaccel = {
365+ .name = "mpeg2_xvmc",
366+ .type = AVMEDIA_TYPE_VIDEO,
367+ .id = AV_CODEC_ID_MPEG2VIDEO,
368+ .pix_fmt = AV_PIX_FMT_XVMC,
369+ .start_frame = ff_xvmc_field_start,
370+ .end_frame = ff_xvmc_field_end,
371+ .decode_slice = NULL,
372+ .decode_mb = ff_xvmc_decode_mb,
373+ .priv_data_size = 0,
374+};
375+#endif
libavcodec/x86/dsputil_init.c+1−7
@@ -583,17 +583,11 @@ static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx, · 582 unmodified lines
583583 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
584584
585585 if (!high_bit_depth) {
586−#if FF_API_XVMC
587−FF_DISABLE_DEPRECATION_WARNINGS
588− if (!(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)) {
586+ if (!(CONFIG_XVMC && avctx->hwaccel && avctx->hwaccel->decode_mb)) {
589587 /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
590−FF_ENABLE_DEPRECATION_WARNINGS
591−#endif /* FF_API_XVMC */
592588 c->clear_block = ff_clear_block_sse;
593589 c->clear_blocks = ff_clear_blocks_sse;
594−#if FF_API_XVMC
595590 }
596−#endif /* FF_API_XVMC */
597591 }
598592
599593 c->vector_clipf = ff_vector_clipf_sse;
libavcodec/xvmc.h+0−4
@@ -33,8 +33,6 @@ · 32 unmodified lines
3333 #include "version.h"
3434 #include "avcodec.h"
3535
36−#if FF_API_XVMC
37−
3836 /**
3937 * @defgroup lavc_codec_hwaccel_xvmc XvMC
4038 * @ingroup lavc_codec_hwaccel
@@ -169,6 +167,4 @@ attribute_deprecated struct xvmc_pix_fmt { · 128 unmodified lines
169167 * @}
170168 */
171169
172−#endif /* FF_API_XVMC */
173−
174170 #endif /* AVCODEC_XVMC_H */
libavcodec/xvmc_internal.h+0−7
@@ -25,14 +25,7 @@ · 24 unmodified lines
2525 #include "mpegvideo.h"
2626 #include "version.h"
2727
28−#if FF_API_XVMC
29−
3028 void ff_xvmc_init_block(MpegEncContext *s);
3129 void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp);
32−int ff_xvmc_field_start(MpegEncContext*s, AVCodecContext *avctx);
33−void ff_xvmc_field_end(MpegEncContext *s);
34−void ff_xvmc_decode_mb(MpegEncContext *s);
35−
36−#endif /* FF_API_XVMC */
3730
3831 #endif /* AVCODEC_XVMC_INTERNAL_H */
libavutil/pixdesc.c+6−0
@@ -324,6 +324,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { · 323 unmodified lines
324324 .flags = AV_PIX_FMT_FLAG_HWACCEL,
325325 },
326326 #endif /* FF_API_XVMC */
327+#if !FF_API_XVMC
328+ [AV_PIX_FMT_XVMC] = {
329+ .name = "xvmc",
330+ .flags = AV_PIX_FMT_FLAG_HWACCEL,
331+ },
332+#endif /* !FF_API_XVMC */
327333 [AV_PIX_FMT_UYVY422] = {
328334 .name = "uyvy422",
329335 .nb_components = 3,
libavutil/pixfmt.h+4−0
@@ -83,6 +83,7 @@ enum AVPixelFormat { · 82 unmodified lines
8383 #if FF_API_XVMC
8484 AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
8585 AV_PIX_FMT_XVMC_MPEG2_IDCT,
86+#define AV_PIX_FMT_XVMC AV_PIX_FMT_XVMC_MPEG2_IDCT
8687 #endif /* FF_API_XVMC */
8788 AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
8889 AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
@@ -262,6 +263,9 @@ enum AVPixelFormat { · 173 unmodified lines
262263 AV_PIX_FMT_BAYER_GBRG16BE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian */
263264 AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */
264265 AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian */
266+#if !FF_API_XVMC
267+ AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing
268+#endif /* !FF_API_XVMC */
265269
266270 AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
267271

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t