Unified · Split
| @@ -1318,6 +1318,7 @@ HWACCEL_LIST=" · 1317 unmodified lines | ||
| 1318 | 1318 | vaapi |
| 1319 | 1319 | vda |
| 1320 | 1320 | vdpau |
| 1321 | + xvmc | |
| 1321 | 1322 | " |
| 1322 | 1323 | |
| 1323 | 1324 | LIBRARY_LIST=" |
| @@ -2039,6 +2040,7 @@ vaapi_deps="va_va_h" · 715 unmodified lines | ||
| 2039 | 2040 | vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" |
| 2040 | 2041 | vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" |
| 2041 | 2042 | vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" |
| 2043 | +xvmc_deps="X11_extensions_XvMClib_h" | |
| 2042 | 2044 | |
| 2043 | 2045 | h263_vaapi_hwaccel_deps="vaapi" |
| 2044 | 2046 | h263_vaapi_hwaccel_select="h263_decoder" |
| @@ -2059,10 +2061,14 @@ h264_vdpau_hwaccel_deps="vdpau" · 14 unmodified lines | ||
| 2059 | 2061 | h264_vdpau_hwaccel_select="h264_decoder" |
| 2060 | 2062 | mpeg_vdpau_decoder_deps="vdpau" |
| 2061 | 2063 | mpeg_vdpau_decoder_select="mpeg2video_decoder" |
| 2064 | +mpeg_xvmc_hwaccel_deps="xvmc" | |
| 2065 | +mpeg_xvmc_hwaccel_select="mpeg2video_decoder" | |
| 2062 | 2066 | mpeg1_vdpau_decoder_deps="vdpau" |
| 2063 | 2067 | mpeg1_vdpau_decoder_select="mpeg1video_decoder" |
| 2064 | 2068 | mpeg1_vdpau_hwaccel_deps="vdpau" |
| 2065 | 2069 | mpeg1_vdpau_hwaccel_select="mpeg1video_decoder" |
| 2070 | +mpeg1_xvmc_hwaccel_deps="xvmc" | |
| 2071 | +mpeg1_xvmc_hwaccel_select="mpeg1video_decoder" | |
| 2066 | 2072 | mpeg2_crystalhd_decoder_select="crystalhd" |
| 2067 | 2073 | mpeg2_dxva2_hwaccel_deps="dxva2" |
| 2068 | 2074 | mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" |
| @@ -2070,6 +2076,8 @@ mpeg2_vaapi_hwaccel_deps="vaapi" · 1 unmodified line | ||
| 2070 | 2076 | mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" |
| 2071 | 2077 | mpeg2_vdpau_hwaccel_deps="vdpau" |
| 2072 | 2078 | mpeg2_vdpau_hwaccel_select="mpeg2video_decoder" |
| 2079 | +mpeg2_xvmc_hwaccel_deps="xvmc" | |
| 2080 | +mpeg2_xvmc_hwaccel_select="mpeg2video_decoder" | |
| 2073 | 2081 | mpeg4_crystalhd_decoder_select="crystalhd" |
| 2074 | 2082 | mpeg4_vaapi_hwaccel_deps="vaapi" |
| 2075 | 2083 | mpeg4_vaapi_hwaccel_select="mpeg4_decoder" |
| @@ -2454,7 +2462,7 @@ enable static · 378 unmodified lines | ||
| 2454 | 2462 | enable swscale_alpha |
| 2455 | 2463 | |
| 2456 | 2464 | # Enable hwaccels by default. |
| 2457 | −enable dxva2 vaapi vdpau | |
| 2465 | +enable dxva2 vaapi vdpau xvmc | |
| 2458 | 2466 | |
| 2459 | 2467 | # build settings |
| 2460 | 2468 | SHFLAGS='-shared -Wl,-soname,$$(@F)' |
| @@ -297,7 +297,6 @@ OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o · 296 unmodified lines | ||
| 297 | 297 | OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o |
| 298 | 298 | OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12.o mpeg12data.o \ |
| 299 | 299 | mpegvideo.o error_resilience.o |
| 300 | −OBJS-$(CONFIG_MPEG_XVMC_DECODER) += mpegvideo_xvmc.o | |
| 301 | 300 | OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o |
| 302 | 301 | OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o |
| 303 | 302 | 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 | ||
| 635 | 634 | OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o |
| 636 | 635 | OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o |
| 637 | 636 | OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o |
| 637 | +OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o | |
| 638 | 638 | OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o |
| 639 | 639 | OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o vaapi_mpeg.o |
| 640 | 640 | OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o |
| 641 | +OBJS-$(CONFIG_MPEG2_XVMC_HWACCEL) += mpegvideo_xvmc.o | |
| 641 | 642 | OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o vaapi_mpeg.o |
| 642 | 643 | OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL) += vdpau_mpeg4.o |
| 643 | 644 | OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o |
| @@ -827,7 +828,7 @@ SKIPHEADERS += %_tablegen.h \ · 183 unmodified lines | ||
| 827 | 828 | SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h |
| 828 | 829 | SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h |
| 829 | 830 | SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h |
| 830 | −SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h | |
| 831 | +SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h | |
| 831 | 832 | SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h |
| 832 | 833 | SKIPHEADERS-$(CONFIG_VDA) += vda.h |
| 833 | 834 | SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h |
| @@ -80,7 +80,9 @@ void avcodec_register_all(void) · 79 unmodified lines | ||
| 80 | 80 | REGISTER_HWACCEL(H264_VAAPI, h264_vaapi); |
| 81 | 81 | REGISTER_HWACCEL(H264_VDA, h264_vda); |
| 82 | 82 | REGISTER_HWACCEL(H264_VDPAU, h264_vdpau); |
| 83 | + REGISTER_HWACCEL(MPEG1_XVMC, mpeg1_xvmc); | |
| 83 | 84 | REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau); |
| 85 | + REGISTER_HWACCEL(MPEG2_XVMC, mpeg2_xvmc); | |
| 84 | 86 | REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2); |
| 85 | 87 | REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi); |
| 86 | 88 | REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau); |
| @@ -767,7 +767,13 @@ typedef struct RcOverride{ · 766 unmodified lines | ||
| 767 | 767 | #define CODEC_CAP_DR1 0x0002 |
| 768 | 768 | #define CODEC_CAP_TRUNCATED 0x0008 |
| 769 | 769 | #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 | + */ | |
| 771 | 777 | #define CODEC_CAP_HWACCEL 0x0010 |
| 772 | 778 | #endif /* FF_API_XVMC */ |
| 773 | 779 | /** |
| @@ -1695,7 +1701,7 @@ typedef struct AVCodecContext { · 921 unmodified lines | ||
| 1695 | 1701 | * XVideo Motion Acceleration |
| 1696 | 1702 | * - encoding: forbidden |
| 1697 | 1703 | * - decoding: set by decoder |
| 1698 | − * @deprecated XvMC support is slated for removal. | |
| 1704 | + * @deprecated XvMC doesn't need it anymore. | |
| 1699 | 1705 | */ |
| 1700 | 1706 | attribute_deprecated int xvmc_acceleration; |
| 1701 | 1707 | #endif /* FF_API_XVMC */ |
| @@ -3100,6 +3106,8 @@ typedef struct AVCodec { · 1398 unmodified lines | ||
| 3100 | 3106 | |
| 3101 | 3107 | int av_codec_get_max_lowres(const AVCodec *codec); |
| 3102 | 3108 | |
| 3109 | +struct MpegEncContext; | |
| 3110 | + | |
| 3103 | 3111 | /** |
| 3104 | 3112 | * AVHWAccel. |
| 3105 | 3113 | */ |
| @@ -3161,6 +3169,7 @@ typedef struct AVHWAccel { · 55 unmodified lines | ||
| 3161 | 3169 | * |
| 3162 | 3170 | * Meaningful slice information (codec specific) is guaranteed to |
| 3163 | 3171 | * be parsed at this point. This function is mandatory. |
| 3172 | + * The only exception is XvMC, that works on MB level. | |
| 3164 | 3173 | * |
| 3165 | 3174 | * @param avctx the codec context |
| 3166 | 3175 | * @param buf the slice data buffer base |
| @@ -3188,6 +3197,17 @@ typedef struct AVHWAccel { · 21 unmodified lines | ||
| 3188 | 3197 | * AVCodecContext.release_buffer(). |
| 3189 | 3198 | */ |
| 3190 | 3199 | 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); | |
| 3191 | 3211 | } AVHWAccel; |
| 3192 | 3212 | |
| 3193 | 3213 | /** |
| @@ -699,15 +699,11 @@ static int is_intra_more_likely(ERContext *s) · 698 unmodified lines | ||
| 699 | 699 | if (undamaged_count < 5) |
| 700 | 700 | return 0; // almost all MBs damaged -> use temporal prediction |
| 701 | 701 | |
| 702 | −#if FF_API_XVMC | |
| 703 | −FF_DISABLE_DEPRECATION_WARNINGS | |
| 704 | 702 | // 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 && | |
| 707 | 705 | s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I) |
| 708 | 706 | return 1; |
| 709 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 710 | −#endif /* FF_API_XVMC */ | |
| 711 | 707 | |
| 712 | 708 | skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs |
| 713 | 709 | is_intra_likely = 0; |
| @@ -770,7 +766,7 @@ void ff_er_frame_start(ERContext *s) · 56 unmodified lines | ||
| 770 | 766 | |
| 771 | 767 | static int er_supported(ERContext *s) |
| 772 | 768 | { |
| 773 | − if(s->avctx->hwaccel || | |
| 769 | + if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice || | |
| 774 | 770 | s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU || |
| 775 | 771 | !s->cur_pic || |
| 776 | 772 | s->cur_pic->field_picture |
| @@ -795,7 +791,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty, · 18 unmodified lines | ||
| 795 | 791 | const int end_xy = s->mb_index2xy[end_i]; |
| 796 | 792 | int mask = -1; |
| 797 | 793 | |
| 798 | − if (s->avctx->hwaccel) | |
| 794 | + if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice) | |
| 799 | 795 | return; |
| 800 | 796 | |
| 801 | 797 | if (start_i > end_i || start_xy > end_xy) { |
| @@ -1188,13 +1184,9 @@ void ff_er_frame_end(ERContext *s) · 386 unmodified lines | ||
| 1188 | 1184 | } else |
| 1189 | 1185 | guess_mv(s); |
| 1190 | 1186 | |
| 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) | |
| 1195 | 1189 | goto ec_clean; |
| 1196 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 1197 | −#endif /* FF_API_XVMC */ | |
| 1198 | 1190 | /* fill DC for inter blocks */ |
| 1199 | 1191 | for (mb_y = 0; mb_y < s->mb_height; mb_y++) { |
| 1200 | 1192 | for (mb_x = 0; mb_x < s->mb_width; mb_x++) { |
| @@ -666,14 +666,6 @@ static inline int get_qscale(MpegEncContext *s) · 665 unmodified lines | ||
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
| 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 | −} | |
| 677 | 669 | |
| 678 | 670 | /* motion type (for MPEG-2) */ |
| 679 | 671 | #define MT_FIELD 1 |
| @@ -777,17 +769,10 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 97 unmodified lines | ||
| 777 | 769 | } else |
| 778 | 770 | memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */ |
| 779 | 771 | s->mb_intra = 1; |
| 780 | −#if FF_API_XVMC | |
| 781 | −FF_DISABLE_DEPRECATION_WARNINGS | |
| 782 | 772 | // 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) { | |
| 784 | 774 | ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks |
| 785 | − if (s->swap_uv) { | |
| 786 | − exchange_uv(s); | |
| 787 | − } | |
| 788 | 775 | } |
| 789 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 790 | −#endif /* FF_API_XVMC */ | |
| 791 | 776 | |
| 792 | 777 | if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { |
| 793 | 778 | if (s->flags2 & CODEC_FLAG2_FAST) { |
| @@ -1000,17 +985,10 @@ FF_ENABLE_DEPRECATION_WARNINGS · 206 unmodified lines | ||
| 1000 | 985 | return -1; |
| 1001 | 986 | } |
| 1002 | 987 | |
| 1003 | −#if FF_API_XVMC | |
| 1004 | −FF_DISABLE_DEPRECATION_WARNINGS | |
| 1005 | 988 | //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) { | |
| 1007 | 990 | ff_xvmc_pack_pblocks(s, cbp); |
| 1008 | − if (s->swap_uv) { | |
| 1009 | − exchange_uv(s); | |
| 1010 | − } | |
| 1011 | 991 | } |
| 1012 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 1013 | −#endif /* FF_API_XVMC */ | |
| 1014 | 992 | |
| 1015 | 993 | if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { |
| 1016 | 994 | 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 | ||
| 1134 | 1112 | } |
| 1135 | 1113 | |
| 1136 | 1114 | 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, | |
| 1141 | 1117 | #endif |
| 1142 | −#endif /* FF_API_XVMC */ | |
| 1143 | 1118 | #if CONFIG_MPEG1_VDPAU_HWACCEL |
| 1144 | 1119 | AV_PIX_FMT_VDPAU_MPEG1, |
| 1145 | 1120 | AV_PIX_FMT_VDPAU, |
| @@ -1149,12 +1124,9 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { · 3 unmodified lines | ||
| 1149 | 1124 | }; |
| 1150 | 1125 | |
| 1151 | 1126 | 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, | |
| 1156 | 1129 | #endif |
| 1157 | −#endif /* FF_API_XVMC */ | |
| 1158 | 1130 | #if CONFIG_MPEG2_VDPAU_HWACCEL |
| 1159 | 1131 | AV_PIX_FMT_VDPAU_MPEG2, |
| 1160 | 1132 | AV_PIX_FMT_VDPAU, |
| @@ -1191,25 +1163,21 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) · 30 unmodified lines | ||
| 1191 | 1163 | |
| 1192 | 1164 | static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx) |
| 1193 | 1165 | { |
| 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 */ | |
| 1203 | 1166 | avctx->hwaccel = ff_find_hwaccel(avctx); |
| 1204 | 1167 | // 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)) | |
| 1211 | 1169 | if (avctx->idct_algo == FF_IDCT_AUTO) |
| 1212 | 1170 | 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 | + } | |
| 1213 | 1181 | } |
| 1214 | 1182 | |
| 1215 | 1183 | /* 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 | ||
| 1630 | 1598 | return -1; |
| 1631 | 1599 | } |
| 1632 | 1600 | |
| 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 | − | |
| 1643 | 1601 | return 0; |
| 1644 | 1602 | } |
| 1645 | 1603 | |
| @@ -1711,7 +1669,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, · 65 unmodified lines | ||
| 1711 | 1669 | return -1; |
| 1712 | 1670 | } |
| 1713 | 1671 | |
| 1714 | − if (avctx->hwaccel) { | |
| 1672 | + if (avctx->hwaccel && avctx->hwaccel->decode_slice) { | |
| 1715 | 1673 | const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ |
| 1716 | 1674 | int start_code = -1; |
| 1717 | 1675 | 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 | ||
| 1741 | 1699 | } |
| 1742 | 1700 | |
| 1743 | 1701 | for (;;) { |
| 1744 | −#if FF_API_XVMC | |
| 1745 | −FF_DISABLE_DEPRECATION_WARNINGS | |
| 1746 | 1702 | // 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) | |
| 1748 | 1704 | ff_xvmc_init_block(s); // set s->block |
| 1749 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 1750 | −#endif /* FF_API_XVMC */ | |
| 1751 | 1705 | |
| 1752 | 1706 | if (mpeg_decode_mb(s, s->block) < 0) |
| 1753 | 1707 | return -1; |
| @@ -1949,13 +1903,6 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict) · 195 unmodified lines | ||
| 1949 | 1903 | av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n"); |
| 1950 | 1904 | } |
| 1951 | 1905 | |
| 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 | − | |
| 1959 | 1906 | /* end of slice reached */ |
| 1960 | 1907 | if (/*s->mb_y << field_pic == s->mb_height &&*/ !s->first_field && !s1->first_slice) { |
| 1961 | 1908 | /* end of image */ |
| @@ -39,7 +39,6 @@ · 38 unmodified lines | ||
| 39 | 39 | #include "mpegvideo.h" |
| 40 | 40 | #include "mjpegenc.h" |
| 41 | 41 | #include "msmpeg4.h" |
| 42 | −#include "xvmc_internal.h" | |
| 43 | 42 | #include "thread.h" |
| 44 | 43 | #include <limits.h> |
| 45 | 44 | |
| @@ -1673,28 +1672,12 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) · 1627 unmodified lines | ||
| 1673 | 1672 | update_noise_reduction(s); |
| 1674 | 1673 | } |
| 1675 | 1674 | |
| 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 | − | |
| 1683 | 1675 | return 0; |
| 1684 | 1676 | } |
| 1685 | 1677 | |
| 1686 | 1678 | /* called after a frame has been decoded. */ |
| 1687 | 1679 | void ff_MPV_frame_end(MpegEncContext *s) |
| 1688 | 1680 | { |
| 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 */ | |
| 1698 | 1681 | if ((s->er.error_count || !(s->avctx->codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND)) && |
| 1699 | 1682 | !s->avctx->hwaccel && |
| 1700 | 1683 | !(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 | ||
| 2618 | 2601 | { |
| 2619 | 2602 | const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; |
| 2620 | 2603 | |
| 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 | |
| 2625 | 2607 | return; |
| 2626 | 2608 | } |
| 2627 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 2628 | −#endif /* FF_API_XVMC */ | |
| 2629 | 2609 | |
| 2630 | 2610 | if(s->avctx->debug&FF_DEBUG_DCT_COEFF) { |
| 2631 | 2611 | /* print DCT coefficients */ |
| @@ -693,6 +693,7 @@ typedef struct MpegEncContext { · 692 unmodified lines | ||
| 693 | 693 | |
| 694 | 694 | uint8_t *ptr_lastgob; |
| 695 | 695 | 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. | |
| 696 | 697 | int16_t (*pblocks[12])[64]; |
| 697 | 698 | |
| 698 | 699 | int16_t (*block)[64]; ///< points to one of the following blocks |
| @@ -32,8 +32,6 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "xvmc_internal.h" |
| 33 | 33 | #include "version.h" |
| 34 | 34 | |
| 35 | −#if FF_API_XVMC | |
| 36 | − | |
| 37 | 35 | /** |
| 38 | 36 | * Initialize the block field of the MpegEncContext pointer passed as |
| 39 | 37 | * parameter after making sure that the data is not corrupted. |
| @@ -49,6 +47,15 @@ void ff_xvmc_init_block(MpegEncContext *s) · 9 unmodified lines | ||
| 49 | 47 | s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64); |
| 50 | 48 | } |
| 51 | 49 | |
| 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 | + | |
| 52 | 59 | /** |
| 53 | 60 | * Fill individual block pointers, so there are no gaps in the data_block array |
| 54 | 61 | * 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 | ||
| 66 | 73 | s->pblocks[i] = NULL; |
| 67 | 74 | cbp += cbp; |
| 68 | 75 | } |
| 76 | + if (s->swap_uv) { | |
| 77 | + exchange_uv(s); | |
| 78 | + } | |
| 69 | 79 | } |
| 70 | 80 | |
| 71 | 81 | /** |
| @@ -73,8 +83,9 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) · 1 unmodified line | ||
| 73 | 83 | * This function should be called for every new field and/or frame. |
| 74 | 84 | * It should be safe to call the function a few times for the same field. |
| 75 | 85 | */ |
| 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) | |
| 77 | 87 | { |
| 88 | + struct MpegEncContext *s = avctx->priv_data; | |
| 78 | 89 | struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; |
| 79 | 90 | const int mb_block_count = 4 + (1 << s->chroma_format); |
| 80 | 91 | |
| @@ -141,20 +152,22 @@ return -1; · 60 unmodified lines | ||
| 141 | 152 | * some leftover blocks, for example from error_resilience(), may remain. |
| 142 | 153 | * It should be safe to call the function a few times for the same field. |
| 143 | 154 | */ |
| 144 | −void ff_xvmc_field_end(MpegEncContext *s) | |
| 155 | +static int ff_xvmc_field_end(AVCodecContext *avctx) | |
| 145 | 156 | { |
| 157 | + struct MpegEncContext *s = avctx->priv_data; | |
| 146 | 158 | struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2]; |
| 147 | 159 | assert(render); |
| 148 | 160 | |
| 149 | 161 | if (render->filled_mv_blocks_num > 0) |
| 150 | 162 | ff_mpeg_draw_horiz_band(s, 0, 0); |
| 163 | + return 0; | |
| 151 | 164 | } |
| 152 | 165 | |
| 153 | 166 | /** |
| 154 | 167 | * Synthesize the data needed by XvMC to render one macroblock of data. |
| 155 | 168 | * Fill all relevant fields, if necessary do IDCT. |
| 156 | 169 | */ |
| 157 | −void ff_xvmc_decode_mb(MpegEncContext *s) | |
| 170 | +static void ff_xvmc_decode_mb(struct MpegEncContext *s) | |
| 158 | 171 | { |
| 159 | 172 | XvMCMacroBlock *mv_block; |
| 160 | 173 | struct xvmc_pix_fmt *render; |
| @@ -313,7 +326,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s) · 152 unmodified lines | ||
| 313 | 326 | * slowdown. */ |
| 314 | 327 | } |
| 315 | 328 | // copy blocks only if the codec doesn't support pblocks reordering |
| 316 | − if (s->avctx->xvmc_acceleration == 1) { | |
| 329 | + if (!s->pack_pblocks) { | |
| 317 | 330 | memcpy(&render->data_blocks[render->next_free_data_block_num*64], |
| 318 | 331 | s->pblocks[i], sizeof(*s->pblocks[i])); |
| 319 | 332 | } |
| @@ -333,4 +346,30 @@ void ff_xvmc_decode_mb(MpegEncContext *s) · 13 unmodified lines | ||
| 333 | 346 | ff_mpeg_draw_horiz_band(s, 0, 0); |
| 334 | 347 | } |
| 335 | 348 | |
| 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 | |
| @@ -583,17 +583,11 @@ static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx, · 582 unmodified lines | ||
| 583 | 583 | const int high_bit_depth = avctx->bits_per_raw_sample > 8; |
| 584 | 584 | |
| 585 | 585 | 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)) { | |
| 589 | 587 | /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */ |
| 590 | −FF_ENABLE_DEPRECATION_WARNINGS | |
| 591 | −#endif /* FF_API_XVMC */ | |
| 592 | 588 | c->clear_block = ff_clear_block_sse; |
| 593 | 589 | c->clear_blocks = ff_clear_blocks_sse; |
| 594 | −#if FF_API_XVMC | |
| 595 | 590 | } |
| 596 | −#endif /* FF_API_XVMC */ | |
| 597 | 591 | } |
| 598 | 592 | |
| 599 | 593 | c->vector_clipf = ff_vector_clipf_sse; |
| @@ -33,8 +33,6 @@ · 32 unmodified lines | ||
| 33 | 33 | #include "version.h" |
| 34 | 34 | #include "avcodec.h" |
| 35 | 35 | |
| 36 | −#if FF_API_XVMC | |
| 37 | − | |
| 38 | 36 | /** |
| 39 | 37 | * @defgroup lavc_codec_hwaccel_xvmc XvMC |
| 40 | 38 | * @ingroup lavc_codec_hwaccel |
| @@ -169,6 +167,4 @@ attribute_deprecated struct xvmc_pix_fmt { · 128 unmodified lines | ||
| 169 | 167 | * @} |
| 170 | 168 | */ |
| 171 | 169 | |
| 172 | −#endif /* FF_API_XVMC */ | |
| 173 | − | |
| 174 | 170 | #endif /* AVCODEC_XVMC_H */ |
| @@ -25,14 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "mpegvideo.h" |
| 26 | 26 | #include "version.h" |
| 27 | 27 | |
| 28 | −#if FF_API_XVMC | |
| 29 | − | |
| 30 | 28 | void ff_xvmc_init_block(MpegEncContext *s); |
| 31 | 29 | 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 */ | |
| 37 | 30 | |
| 38 | 31 | #endif /* AVCODEC_XVMC_INTERNAL_H */ |
| @@ -324,6 +324,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { · 323 unmodified lines | ||
| 324 | 324 | .flags = AV_PIX_FMT_FLAG_HWACCEL, |
| 325 | 325 | }, |
| 326 | 326 | #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 */ | |
| 327 | 333 | [AV_PIX_FMT_UYVY422] = { |
| 328 | 334 | .name = "uyvy422", |
| 329 | 335 | .nb_components = 3, |
| @@ -83,6 +83,7 @@ enum AVPixelFormat { · 82 unmodified lines | ||
| 83 | 83 | #if FF_API_XVMC |
| 84 | 84 | AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing |
| 85 | 85 | AV_PIX_FMT_XVMC_MPEG2_IDCT, |
| 86 | +#define AV_PIX_FMT_XVMC AV_PIX_FMT_XVMC_MPEG2_IDCT | |
| 86 | 87 | #endif /* FF_API_XVMC */ |
| 87 | 88 | AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 |
| 88 | 89 | 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 | ||
| 262 | 263 | AV_PIX_FMT_BAYER_GBRG16BE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian */ |
| 263 | 264 | AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */ |
| 264 | 265 | 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 */ | |
| 265 | 269 | |
| 266 | 270 | 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 |
| 267 | 271 | |