Browse code

Deprecate obsolete XvMC hardware decoding support

XvMC has long ago been superseded by newer acceleration APIs, such as
VDPAU, and few downstreams still support it. Furthermore XvMC is not
implemented within the hwaccel framework, but requires its own specific
code in the MPEG-1/2 decoder, which is a maintenance burden.

Diego Biurrun authored on 2013/11/05 16:16:31
Showing 18 changed files
... ...
@@ -577,7 +577,6 @@ following image formats are supported:
577 577
 @item Mobotix MxPEG video    @tab     @tab  X
578 578
 @item Motion Pixels video    @tab     @tab  X
579 579
 @item MPEG-1 video           @tab  X  @tab  X
580
-@item MPEG-1/2 video XvMC (X-Video Motion Compensation)  @tab     @tab  X
581 580
 @item MPEG-2 video           @tab  X  @tab  X
582 581
 @item MPEG-4 part 2          @tab  X  @tab  X
583 582
     @tab libxvidcore can be used alternatively for encoding.
... ...
@@ -24,8 +24,9 @@
24 24
  * Provide registration of all codecs, parsers and bitstream filters for libavcodec.
25 25
  */
26 26
 
27
-#include "avcodec.h"
28 27
 #include "config.h"
28
+#include "avcodec.h"
29
+#include "version.h"
29 30
 
30 31
 #define REGISTER_HWACCEL(X, x)                                          \
31 32
     {                                                                   \
... ...
@@ -178,7 +179,9 @@ void avcodec_register_all(void)
178 178
     REGISTER_DECODER(MJPEGB,            mjpegb);
179 179
     REGISTER_DECODER(MMVIDEO,           mmvideo);
180 180
     REGISTER_DECODER(MOTIONPIXELS,      motionpixels);
181
+#if FF_API_XVMC
181 182
     REGISTER_DECODER(MPEG_XVMC,         mpeg_xvmc);
183
+#endif /* FF_API_XVMC */
182 184
     REGISTER_ENCDEC (MPEG1VIDEO,        mpeg1video);
183 185
     REGISTER_ENCDEC (MPEG2VIDEO,        mpeg2video);
184 186
     REGISTER_ENCDEC (MPEG4,             mpeg4);
... ...
@@ -103,7 +103,9 @@ enum AVCodecID {
103 103
     /* video codecs */
104 104
     AV_CODEC_ID_MPEG1VIDEO,
105 105
     AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
106
+#if FF_API_XVMC
106 107
     AV_CODEC_ID_MPEG2VIDEO_XVMC,
108
+#endif /* FF_API_XVMC */
107 109
     AV_CODEC_ID_H261,
108 110
     AV_CODEC_ID_H263,
109 111
     AV_CODEC_ID_RV10,
... ...
@@ -691,8 +693,10 @@ typedef struct RcOverride{
691 691
  */
692 692
 #define CODEC_CAP_DR1             0x0002
693 693
 #define CODEC_CAP_TRUNCATED       0x0008
694
+#if FF_API_XVMC
694 695
 /* Codec can export data for HW decoding (XvMC). */
695 696
 #define CODEC_CAP_HWACCEL         0x0010
697
+#endif /* FF_API_XVMC */
696 698
 /**
697 699
  * Encoder or decoder requires flushing with NULL input at the end in order to
698 700
  * give the complete and correct output.
... ...
@@ -1526,12 +1530,15 @@ typedef struct AVCodecContext {
1526 1526
 #define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1527 1527
 #define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1528 1528
 
1529
+#if FF_API_XVMC
1529 1530
     /**
1530 1531
      * XVideo Motion Acceleration
1531 1532
      * - encoding: forbidden
1532 1533
      * - decoding: set by decoder
1534
+     * @deprecated XvMC support is slated for removal.
1533 1535
      */
1534
-    int xvmc_acceleration;
1536
+    attribute_deprecated int xvmc_acceleration;
1537
+#endif /* FF_API_XVMC */
1535 1538
 
1536 1539
     /**
1537 1540
      * macroblock decision mode
... ...
@@ -18,10 +18,10 @@
18 18
 
19 19
 #include <string.h>
20 20
 
21
-#include "avcodec.h"
22
-
23 21
 #include "libavutil/common.h"
24 22
 #include "libavutil/internal.h"
23
+#include "avcodec.h"
24
+#include "version.h"
25 25
 
26 26
 static const AVCodecDescriptor codec_descriptors[] = {
27 27
     /* video codecs */
... ...
@@ -39,6 +39,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
39 39
         .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
40 40
         .props     = AV_CODEC_PROP_LOSSY,
41 41
     },
42
+#if FF_API_XVMC
42 43
     {
43 44
         .id        = AV_CODEC_ID_MPEG2VIDEO_XVMC,
44 45
         .type      = AVMEDIA_TYPE_VIDEO,
... ...
@@ -46,6 +47,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
46 46
         .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video XvMC (X-Video Motion Compensation)"),
47 47
         .props     = AV_CODEC_PROP_LOSSY,
48 48
     },
49
+#endif /* FF_API_XVMC */
49 50
     {
50 51
         .id        = AV_CODEC_ID_H261,
51 52
         .type      = AVMEDIA_TYPE_VIDEO,
... ...
@@ -27,11 +27,13 @@
27 27
 
28 28
 #include <limits.h>
29 29
 
30
+#include "libavutil/internal.h"
30 31
 #include "avcodec.h"
31 32
 #include "error_resilience.h"
32 33
 #include "mpegvideo.h"
33 34
 #include "rectangle.h"
34 35
 #include "thread.h"
36
+#include "version.h"
35 37
 
36 38
 /**
37 39
  * @param stride the number of MVs to get to the next row
... ...
@@ -672,11 +674,15 @@ static int is_intra_more_likely(ERContext *s)
672 672
     if (undamaged_count < 5)
673 673
         return 0; // almost all MBs damaged -> use temporal prediction
674 674
 
675
+#if FF_API_XVMC
676
+FF_DISABLE_DEPRECATION_WARNINGS
675 677
     // prevent dsp.sad() check, that requires access to the image
676 678
     if (CONFIG_MPEG_XVMC_DECODER    &&
677 679
         s->avctx->xvmc_acceleration &&
678 680
         s->cur_pic->f.pict_type == AV_PICTURE_TYPE_I)
679 681
         return 1;
682
+FF_ENABLE_DEPRECATION_WARNINGS
683
+#endif /* FF_API_XVMC */
680 684
 
681 685
     skip_amount     = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
682 686
     is_intra_likely = 0;
... ...
@@ -1105,9 +1111,13 @@ void ff_er_frame_end(ERContext *s)
1105 1105
     } else
1106 1106
         guess_mv(s);
1107 1107
 
1108
+#if FF_API_XVMC
1109
+FF_DISABLE_DEPRECATION_WARNINGS
1108 1110
     /* the filters below are not XvMC compatible, skip them */
1109 1111
     if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1110 1112
         goto ec_clean;
1113
+FF_ENABLE_DEPRECATION_WARNINGS
1114
+#endif /* FF_API_XVMC */
1111 1115
     /* fill DC for inter blocks */
1112 1116
     for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
1113 1117
         for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
... ...
@@ -34,7 +34,6 @@
34 34
 #include "mpeg12.h"
35 35
 #include "mpeg12data.h"
36 36
 #include "bytestream.h"
37
-#include "xvmc_internal.h"
38 37
 #include "thread.h"
39 38
 
40 39
 uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
... ...
@@ -37,6 +37,7 @@
37 37
 #include "bytestream.h"
38 38
 #include "xvmc_internal.h"
39 39
 #include "thread.h"
40
+#include "version.h"
40 41
 
41 42
 typedef struct Mpeg1Context {
42 43
     MpegEncContext mpeg_enc_ctx;
... ...
@@ -756,6 +757,8 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
756 756
         } else
757 757
             memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
758 758
         s->mb_intra = 1;
759
+#if FF_API_XVMC
760
+FF_DISABLE_DEPRECATION_WARNINGS
759 761
         // if 1, we memcpy blocks in xvmcvideo
760 762
         if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
761 763
             ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks
... ...
@@ -763,6 +766,8 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
763 763
                 exchange_uv(s);
764 764
             }
765 765
         }
766
+FF_ENABLE_DEPRECATION_WARNINGS
767
+#endif /* FF_API_XVMC */
766 768
 
767 769
         if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
768 770
             if (s->flags2 & CODEC_FLAG2_FAST) {
... ...
@@ -969,6 +974,8 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
969 969
                 return -1;
970 970
             }
971 971
 
972
+#if FF_API_XVMC
973
+FF_DISABLE_DEPRECATION_WARNINGS
972 974
             //if 1, we memcpy blocks in xvmcvideo
973 975
             if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
974 976
                 ff_xvmc_pack_pblocks(s, cbp);
... ...
@@ -976,6 +983,8 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
976 976
                     exchange_uv(s);
977 977
                 }
978 978
             }
979
+FF_ENABLE_DEPRECATION_WARNINGS
980
+#endif /* FF_API_XVMC */
979 981
 
980 982
             if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
981 983
                 if (s->flags2 & CODEC_FLAG2_FAST) {
... ...
@@ -1098,10 +1107,12 @@ static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
1098 1098
     }
1099 1099
 }
1100 1100
 
1101
+#if FF_API_XVMC
1101 1102
 static const enum AVPixelFormat pixfmt_xvmc_mpg2_420[] = {
1102 1103
     AV_PIX_FMT_XVMC_MPEG2_IDCT,
1103 1104
     AV_PIX_FMT_XVMC_MPEG2_MC,
1104 1105
     AV_PIX_FMT_NONE };
1106
+#endif /* FF_API_XVMC */
1105 1107
 
1106 1108
 static const enum AVPixelFormat mpeg12_hwaccel_pixfmt_list_420[] = {
1107 1109
 #if CONFIG_MPEG2_DXVA2_HWACCEL
... ...
@@ -1122,16 +1133,19 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
1122 1122
     Mpeg1Context *s1 = avctx->priv_data;
1123 1123
     MpegEncContext *s = &s1->mpeg_enc_ctx;
1124 1124
 
1125
+#if FF_API_XVMC
1126
+FF_DISABLE_DEPRECATION_WARNINGS
1125 1127
     if (avctx->xvmc_acceleration)
1126 1128
         return avctx->get_format(avctx, pixfmt_xvmc_mpg2_420);
1127
-    else {
1128
-        if (s->chroma_format <  2)
1129
-            return avctx->get_format(avctx, mpeg12_hwaccel_pixfmt_list_420);
1130
-        else if (s->chroma_format == 2)
1131
-            return AV_PIX_FMT_YUV422P;
1132
-        else
1133
-            return AV_PIX_FMT_YUV444P;
1134
-    }
1129
+FF_ENABLE_DEPRECATION_WARNINGS
1130
+#endif /* FF_API_XVMC */
1131
+
1132
+    if (s->chroma_format <  2)
1133
+        return avctx->get_format(avctx, mpeg12_hwaccel_pixfmt_list_420);
1134
+    else if (s->chroma_format == 2)
1135
+        return AV_PIX_FMT_YUV422P;
1136
+    else
1137
+        return AV_PIX_FMT_YUV444P;
1135 1138
 }
1136 1139
 
1137 1140
 /* Call this function when we know all parameters.
... ...
@@ -1229,10 +1243,13 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
1229 1229
         avctx->pix_fmt = mpeg_get_pixelformat(avctx);
1230 1230
         avctx->hwaccel = ff_find_hwaccel(avctx);
1231 1231
         // until then pix_fmt may be changed right after codec init
1232
-        if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
1233
-            avctx->hwaccel)
1234
-            if (avctx->idct_algo == FF_IDCT_AUTO)
1235
-                avctx->idct_algo = FF_IDCT_SIMPLE;
1232
+#if FF_API_XVMC
1233
+        if ((avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
1234
+            avctx->hwaccel) && avctx->idct_algo == FF_IDCT_AUTO)
1235
+#else
1236
+        if (avctx->hwaccel && avctx->idct_algo == FF_IDCT_AUTO)
1237
+#endif /* FF_API_XVMC */
1238
+            avctx->idct_algo = FF_IDCT_SIMPLE;
1236 1239
 
1237 1240
         /* Quantization matrices may need reordering
1238 1241
          * if DCT permutation is changed. */
... ...
@@ -1557,11 +1574,15 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
1557 1557
             return -1;
1558 1558
     }
1559 1559
 
1560
+#if FF_API_XVMC
1561
+FF_DISABLE_DEPRECATION_WARNINGS
1560 1562
 // MPV_frame_start will call this function too,
1561 1563
 // but we need to call it on every field
1562 1564
     if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1563 1565
         if (ff_xvmc_field_start(s, avctx) < 0)
1564 1566
             return -1;
1567
+FF_ENABLE_DEPRECATION_WARNINGS
1568
+#endif /* FF_API_XVMC */
1565 1569
 
1566 1570
     return 0;
1567 1571
 }
... ...
@@ -1662,9 +1683,13 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
1662 1662
     }
1663 1663
 
1664 1664
     for (;;) {
1665
+#if FF_API_XVMC
1666
+FF_DISABLE_DEPRECATION_WARNINGS
1665 1667
         // If 1, we memcpy blocks in xvmcvideo.
1666 1668
         if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)
1667 1669
             ff_xvmc_init_block(s); // set s->block
1670
+FF_ENABLE_DEPRECATION_WARNINGS
1671
+#endif /* FF_API_XVMC */
1668 1672
 
1669 1673
         if (mpeg_decode_mb(s, s->block) < 0)
1670 1674
             return -1;
... ...
@@ -1854,8 +1879,12 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
1854 1854
             av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
1855 1855
     }
1856 1856
 
1857
+#if FF_API_XVMC
1858
+FF_DISABLE_DEPRECATION_WARNINGS
1857 1859
     if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1858 1860
         ff_xvmc_field_end(s);
1861
+FF_ENABLE_DEPRECATION_WARNINGS
1862
+#endif /* FF_API_XVMC */
1859 1863
 
1860 1864
     /* end of slice reached */
1861 1865
     if (/*s->mb_y << field_pic == s->mb_height &&*/ !s->first_field) {
... ...
@@ -1990,9 +2019,13 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
1990 1990
     avctx->pix_fmt = mpeg_get_pixelformat(avctx);
1991 1991
     avctx->hwaccel = ff_find_hwaccel(avctx);
1992 1992
 
1993
-    if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel)
1994
-        if (avctx->idct_algo == FF_IDCT_AUTO)
1995
-            avctx->idct_algo = FF_IDCT_SIMPLE;
1993
+#if FF_API_XVMC
1994
+    if ((avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel) &&
1995
+        avctx->idct_algo == FF_IDCT_AUTO)
1996
+#else
1997
+    if (avctx->hwaccel && avctx->idct_algo == FF_IDCT_AUTO)
1998
+#endif /* FF_API_XVMC */
1999
+        avctx->idct_algo = FF_IDCT_SIMPLE;
1996 2000
 
1997 2001
     if (ff_MPV_common_init(s) < 0)
1998 2002
         return -1;
... ...
@@ -2436,6 +2469,7 @@ AVCodec ff_mpeg2video_decoder = {
2436 2436
     .profiles       = NULL_IF_CONFIG_SMALL(mpeg2_video_profiles),
2437 2437
 };
2438 2438
 
2439
+#if FF_API_XVMC
2439 2440
 #if CONFIG_MPEG_XVMC_DECODER
2440 2441
 static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx)
2441 2442
 {
... ...
@@ -2469,3 +2503,4 @@ AVCodec ff_mpeg_xvmc_decoder = {
2469 2469
 };
2470 2470
 
2471 2471
 #endif
2472
+#endif /* FF_API_XVMC */
... ...
@@ -30,6 +30,7 @@
30 30
 #include "libavutil/attributes.h"
31 31
 #include "libavutil/avassert.h"
32 32
 #include "libavutil/imgutils.h"
33
+#include "libavutil/internal.h"
33 34
 #include "avcodec.h"
34 35
 #include "dsputil.h"
35 36
 #include "internal.h"
... ...
@@ -1671,8 +1672,12 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1671 1671
         update_noise_reduction(s);
1672 1672
     }
1673 1673
 
1674
+#if FF_API_XVMC
1675
+FF_DISABLE_DEPRECATION_WARNINGS
1674 1676
     if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
1675 1677
         return ff_xvmc_field_start(s, avctx);
1678
+FF_ENABLE_DEPRECATION_WARNINGS
1679
+#endif /* FF_API_XVMC */
1676 1680
 
1677 1681
     return 0;
1678 1682
 }
... ...
@@ -1682,31 +1687,37 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1682 1682
 void ff_MPV_frame_end(MpegEncContext *s)
1683 1683
 {
1684 1684
     int i;
1685
+
1686
+#if FF_API_XVMC
1687
+FF_DISABLE_DEPRECATION_WARNINGS
1685 1688
     /* redraw edges for the frame if decoding didn't complete */
1686 1689
     // just to make sure that all data is rendered.
1687 1690
     if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration) {
1688 1691
         ff_xvmc_field_end(s);
1689
-   } else if ((s->er.error_count || s->encoding) &&
1690
-              !s->avctx->hwaccel &&
1691
-              s->unrestricted_mv &&
1692
-              s->current_picture.reference &&
1693
-              !s->intra_only &&
1694
-              !(s->flags & CODEC_FLAG_EMU_EDGE)) {
1695
-       const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
1696
-       int hshift = desc->log2_chroma_w;
1697
-       int vshift = desc->log2_chroma_h;
1698
-       s->dsp.draw_edges(s->current_picture.f.data[0], s->linesize,
1699
-                         s->h_edge_pos, s->v_edge_pos,
1700
-                         EDGE_WIDTH, EDGE_WIDTH,
1701
-                         EDGE_TOP | EDGE_BOTTOM);
1702
-       s->dsp.draw_edges(s->current_picture.f.data[1], s->uvlinesize,
1703
-                         s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
1704
-                         EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
1705
-                         EDGE_TOP | EDGE_BOTTOM);
1706
-       s->dsp.draw_edges(s->current_picture.f.data[2], s->uvlinesize,
1707
-                         s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
1708
-                         EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
1709
-                         EDGE_TOP | EDGE_BOTTOM);
1692
+    } else
1693
+FF_ENABLE_DEPRECATION_WARNINGS
1694
+#endif /* FF_API_XVMC */
1695
+    if ((s->er.error_count || s->encoding) &&
1696
+        !s->avctx->hwaccel &&
1697
+        s->unrestricted_mv &&
1698
+        s->current_picture.reference &&
1699
+        !s->intra_only &&
1700
+        !(s->flags & CODEC_FLAG_EMU_EDGE)) {
1701
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
1702
+        int hshift = desc->log2_chroma_w;
1703
+        int vshift = desc->log2_chroma_h;
1704
+        s->dsp.draw_edges(s->current_picture.f.data[0], s->linesize,
1705
+                          s->h_edge_pos, s->v_edge_pos,
1706
+                          EDGE_WIDTH, EDGE_WIDTH,
1707
+                          EDGE_TOP | EDGE_BOTTOM);
1708
+        s->dsp.draw_edges(s->current_picture.f.data[1], s->uvlinesize,
1709
+                          s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
1710
+                          EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
1711
+                          EDGE_TOP | EDGE_BOTTOM);
1712
+        s->dsp.draw_edges(s->current_picture.f.data[2], s->uvlinesize,
1713
+                          s->h_edge_pos >> hshift, s->v_edge_pos >> vshift,
1714
+                          EDGE_WIDTH >> hshift, EDGE_WIDTH >> vshift,
1715
+                          EDGE_TOP | EDGE_BOTTOM);
1710 1716
     }
1711 1717
 
1712 1718
     emms_c();
... ...
@@ -1959,10 +1970,15 @@ void MPV_decode_mb_internal(MpegEncContext *s, int16_t block[12][64],
1959 1959
                             int is_mpeg12)
1960 1960
 {
1961 1961
     const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
1962
+
1963
+#if FF_API_XVMC
1964
+FF_DISABLE_DEPRECATION_WARNINGS
1962 1965
     if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
1963 1966
         ff_xvmc_decode_mb(s);//xvmc uses pblocks
1964 1967
         return;
1965 1968
     }
1969
+FF_ENABLE_DEPRECATION_WARNINGS
1970
+#endif /* FF_API_XVMC */
1966 1971
 
1967 1972
     if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
1968 1973
        /* print DCT coefficients */
... ...
@@ -30,6 +30,9 @@
30 30
 
31 31
 #include "xvmc.h"
32 32
 #include "xvmc_internal.h"
33
+#include "version.h"
34
+
35
+#if FF_API_XVMC
33 36
 
34 37
 /**
35 38
  * Initialize the block field of the MpegEncContext pointer passed as
... ...
@@ -329,3 +332,5 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
329 329
     if (render->filled_mv_blocks_num == render->allocated_mv_blocks)
330 330
         ff_mpeg_draw_horiz_band(s, 0, 0);
331 331
 }
332
+
333
+#endif /* FF_API_XVMC */
... ...
@@ -273,7 +273,9 @@ static const AVOption avcodec_options[] = {
273 273
 {"deflate", "deflate-based coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"},
274 274
 {"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
275 275
 {"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
276
+#if FF_API_XVMC
276 277
 {"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
278
+#endif /* FF_API_XVMC */
277 279
 {"mbd", "macroblock decision algorithm (high quality mode)", OFFSET(mb_decision), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "mbd"},
278 280
 {"simple", "use mbcmp (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_SIMPLE }, INT_MIN, INT_MAX, V|E, "mbd"},
279 281
 {"bits", "use fewest bits", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_BITS }, INT_MIN, INT_MAX, V|E, "mbd"},
... ...
@@ -97,5 +97,8 @@
97 97
 #ifndef FF_API_ARCH_ALPHA
98 98
 #define FF_API_ARCH_ALPHA        (LIBAVCODEC_VERSION_MAJOR < 56)
99 99
 #endif
100
+#ifndef FF_API_XVMC
101
+#define FF_API_XVMC              (LIBAVCODEC_VERSION_MAJOR < 56)
102
+#endif
100 103
 
101 104
 #endif /* AVCODEC_VERSION_H */
... ...
@@ -611,11 +611,15 @@ static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
611 611
     const int high_bit_depth = avctx->bits_per_raw_sample > 8;
612 612
 
613 613
     if (!high_bit_depth) {
614
+#if FF_API_XVMC
614 615
         if (!(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)) {
615 616
             /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
616
-            c->clear_block  = ff_clear_block_sse;
617
-            c->clear_blocks = ff_clear_blocks_sse;
617
+#endif /* FF_API_XVMC */
618
+        c->clear_block  = ff_clear_block_sse;
619
+        c->clear_blocks = ff_clear_blocks_sse;
620
+#if FF_API_XVMC
618 621
         }
622
+#endif /* FF_API_XVMC */
619 623
     }
620 624
 
621 625
     c->vector_clipf = ff_vector_clipf_sse;
... ...
@@ -29,8 +29,12 @@
29 29
 
30 30
 #include <X11/extensions/XvMC.h>
31 31
 
32
+#include "libavutil/attributes.h"
33
+#include "version.h"
32 34
 #include "avcodec.h"
33 35
 
36
+#if FF_API_XVMC
37
+
34 38
 /**
35 39
  * @defgroup lavc_codec_hwaccel_xvmc XvMC
36 40
  * @ingroup lavc_codec_hwaccel
... ...
@@ -41,7 +45,7 @@
41 41
 #define AV_XVMC_ID                    0x1DC711C0  /**< special value to ensure that regular pixel routines haven't corrupted the struct
42 42
                                                        the number is 1337 speak for the letters IDCT MCo (motion compensation) */
43 43
 
44
-struct xvmc_pix_fmt {
44
+attribute_deprecated struct xvmc_pix_fmt {
45 45
     /** The field contains the special constant value AV_XVMC_ID.
46 46
         It is used as a test that the application correctly uses the API,
47 47
         and that there is no corruption caused by pixel routines.
... ...
@@ -165,4 +169,6 @@ struct xvmc_pix_fmt {
165 165
  * @}
166 166
  */
167 167
 
168
+#endif /* FF_API_XVMC */
169
+
168 170
 #endif /* AVCODEC_XVMC_H */
... ...
@@ -23,6 +23,9 @@
23 23
 
24 24
 #include "avcodec.h"
25 25
 #include "mpegvideo.h"
26
+#include "version.h"
27
+
28
+#if FF_API_XVMC
26 29
 
27 30
 void ff_xvmc_init_block(MpegEncContext *s);
28 31
 void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp);
... ...
@@ -30,4 +33,6 @@ int  ff_xvmc_field_start(MpegEncContext*s, AVCodecContext *avctx);
30 30
 void ff_xvmc_field_end(MpegEncContext *s);
31 31
 void ff_xvmc_decode_mb(MpegEncContext *s);
32 32
 
33
+#endif /* FF_API_XVMC */
34
+
33 35
 #endif /* AVCODEC_XVMC_INTERNAL_H */
... ...
@@ -42,8 +42,10 @@
42 42
     PIX_FMT_YUVJ420P,  ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
43 43
     PIX_FMT_YUVJ422P,  ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
44 44
     PIX_FMT_YUVJ444P,  ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
45
+#if FF_API_XVMC
45 46
     PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
46 47
     PIX_FMT_XVMC_MPEG2_IDCT,
48
+#endif /* FF_API_XVMC */
47 49
     PIX_FMT_UYVY422,   ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
48 50
     PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
49 51
     PIX_FMT_BGR8,      ///< packed RGB 3:3:2,  8bpp, (msb)2B 3G 3R(lsb)
... ...
@@ -27,6 +27,7 @@
27 27
 #include "pixdesc.h"
28 28
 #include "internal.h"
29 29
 #include "intreadwrite.h"
30
+#include "version.h"
30 31
 
31 32
 void av_read_image_line(uint16_t *dst,
32 33
                         const uint8_t *data[4], const int linesize[4],
... ...
@@ -299,6 +300,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
299 299
         },
300 300
         .flags = AV_PIX_FMT_FLAG_PLANAR,
301 301
     },
302
+#if FF_API_XVMC
302 303
     [AV_PIX_FMT_XVMC_MPEG2_MC] = {
303 304
         .name = "xvmcmc",
304 305
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
... ...
@@ -307,6 +309,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
307 307
         .name = "xvmcidct",
308 308
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
309 309
     },
310
+#endif /* FF_API_XVMC */
310 311
     [AV_PIX_FMT_UYVY422] = {
311 312
         .name = "uyvy422",
312 313
         .nb_components = 3,
... ...
@@ -77,8 +77,10 @@ enum AVPixelFormat {
77 77
     AV_PIX_FMT_YUVJ420P,  ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
78 78
     AV_PIX_FMT_YUVJ422P,  ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
79 79
     AV_PIX_FMT_YUVJ444P,  ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
80
+#if FF_API_XVMC
80 81
     AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
81 82
     AV_PIX_FMT_XVMC_MPEG2_IDCT,
83
+#endif /* FF_API_XVMC */
82 84
     AV_PIX_FMT_UYVY422,   ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
83 85
     AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
84 86
     AV_PIX_FMT_BGR8,      ///< packed RGB 3:3:2,  8bpp, (msb)2B 3G 3R(lsb)
... ...
@@ -88,6 +88,9 @@
88 88
 #ifndef FF_API_VDPAU
89 89
 #define FF_API_VDPAU                    (LIBAVUTIL_VERSION_MAJOR < 53)
90 90
 #endif
91
+#ifndef FF_API_XVMC
92
+#define FF_API_XVMC                     (LIBAVUTIL_VERSION_MAJOR < 53)
93
+#endif
91 94
 
92 95
 /**
93 96
  * @}