Browse code

lavc: drop VDA

Deprecated (aka removed) in OSX 10.11, and we have a replacement for it
(VideoToolbox).

Clément Bœsch authored on 2017/09/05 22:58:13
Showing 20 changed files
... ...
@@ -5,6 +5,7 @@ version <next>:
5 5
 - Bitstream filters for editing metadata in H.264, HEVC and MPEG-2 streams
6 6
 - Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
7 7
   requires 2.1 (or later) and pkg-config.
8
+- VDA dropped (use VideoToolbox instead)
8 9
 
9 10
 
10 11
 version 3.4:
... ...
@@ -244,7 +244,6 @@ Codecs:
244 244
   txd.c                                 Ivo van Poorten
245 245
   vc2*                                  Rostislav Pehlivanov
246 246
   vcr1.c                                Michael Niedermayer
247
-  vda_h264_dec.c                        Xidorn Quan
248 247
   videotoolboxenc.c                     Rick Kern
249 248
   vima.c                                Paul B Mahol
250 249
   vorbisdec.c                           Denes Balatoni, David Conrad
... ...
@@ -318,7 +318,6 @@ External library support:
318 318
   --enable-omx-rpi         enable OpenMAX IL code for Raspberry Pi [no]
319 319
   --enable-rkmpp           enable Rockchip Media Process Platform code [no]
320 320
   --disable-vaapi          disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
321
-  --disable-vda            disable Apple Video Decode Acceleration code [autodetect]
322 321
   --disable-vdpau          disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
323 322
   --disable-videotoolbox   disable VideoToolbox code [autodetect]
324 323
 
... ...
@@ -1650,7 +1649,6 @@ HWACCEL_AUTODETECT_LIBRARY_LIST="
1650 1650
     dxva2
1651 1651
     nvenc
1652 1652
     vaapi
1653
-    vda
1654 1653
     vdpau
1655 1654
     videotoolbox
1656 1655
     v4l2_m2m
... ...
@@ -2660,10 +2658,6 @@ cuda_deps_any="libdl LoadLibrary"
2660 2660
 cuvid_deps="cuda"
2661 2661
 d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder ID3D11VideoContext"
2662 2662
 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32"
2663
-vda_framework_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension"
2664
-vda_framework_extralibs="-framework VideoDecodeAcceleration"
2665
-vda_deps="vda_framework pthreads corefoundation"
2666
-vda_extralibs="-framework QuartzCore"
2667 2663
 videotoolbox_hwaccel_deps="videotoolbox pthreads"
2668 2664
 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
2669 2665
 xvmc_deps="X11_extensions_XvMClib_h"
... ...
@@ -2685,10 +2679,6 @@ h264_mmal_hwaccel_deps="mmal"
2685 2685
 h264_qsv_hwaccel_deps="libmfx"
2686 2686
 h264_vaapi_hwaccel_deps="vaapi"
2687 2687
 h264_vaapi_hwaccel_select="h264_decoder"
2688
-h264_vda_hwaccel_deps="vda"
2689
-h264_vda_hwaccel_select="h264_decoder"
2690
-h264_vda_old_hwaccel_deps="vda"
2691
-h264_vda_old_hwaccel_select="h264_decoder"
2692 2688
 h264_vdpau_hwaccel_deps="vdpau"
2693 2689
 h264_vdpau_hwaccel_select="h264_decoder"
2694 2690
 h264_videotoolbox_hwaccel_deps="videotoolbox"
... ...
@@ -2822,8 +2812,6 @@ h264_rkmpp_decoder_deps="rkmpp"
2822 2822
 h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
2823 2823
 h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
2824 2824
 h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
2825
-h264_vda_decoder_deps="vda"
2826
-h264_vda_decoder_select="h264_decoder"
2827 2825
 h264_vdpau_decoder_deps="vdpau"
2828 2826
 h264_vdpau_decoder_select="h264_decoder"
2829 2827
 h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
... ...
@@ -3011,7 +2999,6 @@ libzvbi_teletext_decoder_deps="libzvbi"
3011 3011
 videotoolbox_suggest="coreservices"
3012 3012
 videotoolbox_deps="corefoundation coremedia corevideo"
3013 3013
 videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames"
3014
-videotoolbox_encoder_suggest="vda_framework"
3015 3014
 
3016 3015
 # demuxers / muxers
3017 3016
 ac3_demuxer_select="ac3_parser"
... ...
@@ -5847,7 +5834,6 @@ check_header sys/un.h
5847 5847
 check_header termios.h
5848 5848
 check_header unistd.h
5849 5849
 check_header valgrind/valgrind.h
5850
-check_header VideoDecodeAcceleration/VDADecoder.h
5851 5850
 check_func_headers VideoToolbox/VTCompressionSession.h VTCompressionSessionPrepareToEncodeFrames -framework VideoToolbox
5852 5851
 check_header windows.h
5853 5852
 check_header X11/extensions/XvMClib.h
... ...
@@ -786,9 +786,6 @@ Do not use any hardware acceleration (the default).
786 786
 @item auto
787 787
 Automatically select the hardware acceleration method.
788 788
 
789
-@item vda
790
-Use Apple VDA hardware acceleration.
791
-
792 789
 @item vdpau
793 790
 Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
794 791
 
... ...
@@ -63,7 +63,6 @@ enum HWAccelID {
63 63
     HWACCEL_AUTO,
64 64
     HWACCEL_VDPAU,
65 65
     HWACCEL_DXVA2,
66
-    HWACCEL_VDA,
67 66
     HWACCEL_VIDEOTOOLBOX,
68 67
     HWACCEL_QSV,
69 68
     HWACCEL_VAAPI,
... ...
@@ -661,7 +660,6 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame);
661 661
 
662 662
 int ffmpeg_parse_options(int argc, char **argv);
663 663
 
664
-int vda_init(AVCodecContext *s);
665 664
 int videotoolbox_init(AVCodecContext *s);
666 665
 int qsv_init(AVCodecContext *s);
667 666
 int cuvid_init(AVCodecContext *s);
... ...
@@ -78,10 +78,6 @@ const HWAccel hwaccels[] = {
78 78
     { "dxva2", hwaccel_decode_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD,
79 79
       AV_HWDEVICE_TYPE_DXVA2 },
80 80
 #endif
81
-#if CONFIG_VDA
82
-    { "vda",   videotoolbox_init,   HWACCEL_VDA,   AV_PIX_FMT_VDA,
83
-      AV_HWDEVICE_TYPE_NONE },
84
-#endif
85 81
 #if CONFIG_VIDEOTOOLBOX
86 82
     { "videotoolbox",   videotoolbox_init,   HWACCEL_VIDEOTOOLBOX,   AV_PIX_FMT_VIDEOTOOLBOX,
87 83
       AV_HWDEVICE_TYPE_NONE },
... ...
@@ -3631,7 +3627,7 @@ const OptionDef options[] = {
3631 3631
     { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
3632 3632
                           OPT_SPEC | OPT_INPUT,                                  { .off = OFFSET(hwaccel_output_formats) },
3633 3633
         "select output format used with HW accelerated decoding", "format" },
3634
-#if CONFIG_VDA || CONFIG_VIDEOTOOLBOX
3634
+#if CONFIG_VIDEOTOOLBOX
3635 3635
     { "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" },
3636 3636
 #endif
3637 3637
     { "hwaccels",         OPT_EXIT,                                              { .func_arg = show_hwaccels },
... ...
@@ -23,12 +23,7 @@
23 23
 #endif
24 24
 
25 25
 #include "libavcodec/avcodec.h"
26
-#if CONFIG_VDA
27
-#  include "libavcodec/vda.h"
28
-#endif
29
-#if CONFIG_VIDEOTOOLBOX
30
-#  include "libavcodec/videotoolbox.h"
31
-#endif
26
+#include "libavcodec/videotoolbox.h"
32 27
 #include "libavutil/imgutils.h"
33 28
 #include "ffmpeg.h"
34 29
 
... ...
@@ -114,15 +109,7 @@ static void videotoolbox_uninit(AVCodecContext *s)
114 114
 
115 115
     av_frame_free(&vt->tmp_frame);
116 116
 
117
-    if (ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX) {
118
-#if CONFIG_VIDEOTOOLBOX
119
-        av_videotoolbox_default_free(s);
120
-#endif
121
-    } else {
122
-#if CONFIG_VDA
123
-        av_vda_default_free(s);
124
-#endif
125
-    }
117
+    av_videotoolbox_default_free(s);
126 118
     av_freep(&ist->hwaccel_ctx);
127 119
 }
128 120
 
... ...
@@ -147,8 +134,7 @@ int videotoolbox_init(AVCodecContext *s)
147 147
         goto fail;
148 148
     }
149 149
 
150
-    if (ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX) {
151
-#if CONFIG_VIDEOTOOLBOX
150
+    // TODO: reindent
152 151
         if (!videotoolbox_pixfmt) {
153 152
             ret = av_videotoolbox_default_init(s);
154 153
         } else {
... ...
@@ -166,31 +152,8 @@ int videotoolbox_init(AVCodecContext *s)
166 166
             ret = av_videotoolbox_default_init2(s, vtctx);
167 167
             CFRelease(pixfmt_str);
168 168
         }
169
-#endif
170
-    } else {
171
-#if CONFIG_VDA
172
-        if (!videotoolbox_pixfmt) {
173
-            ret = av_vda_default_init(s);
174
-        } else {
175
-            AVVDAContext *vdactx = av_vda_alloc_context();
176
-            CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault,
177
-                                                               videotoolbox_pixfmt,
178
-                                                               kCFStringEncodingUTF8);
179
-#if HAVE_UTGETOSTYPEFROMSTRING
180
-            vdactx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str);
181
-#else
182
-            av_log(s, loglevel, "UTGetOSTypeFromString() is not available "
183
-                   "on this platform, %s pixel format can not be honored from "
184
-                   "the command line\n", videotoolbox_pixfmt);
185
-#endif
186
-            ret = av_vda_default_init2(s, vdactx);
187
-            CFRelease(pixfmt_str);
188
-        }
189
-#endif
190
-    }
191 169
     if (ret < 0) {
192
-        av_log(NULL, loglevel,
193
-               "Error creating %s decoder.\n", ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX ? "Videotoolbox" : "VDA");
170
+        av_log(NULL, loglevel, "Error creating Videotoolbox decoder.\n");
194 171
         goto fail;
195 172
     }
196 173
 
... ...
@@ -12,7 +12,6 @@ HEADERS = avcodec.h                                                     \
12 12
           mediacodec.h                                                  \
13 13
           qsv.h                                                         \
14 14
           vaapi.h                                                       \
15
-          vda.h                                                         \
16 15
           vdpau.h                                                       \
17 16
           version.h                                                     \
18 17
           videotoolbox.h                                                \
... ...
@@ -338,7 +337,6 @@ OBJS-$(CONFIG_H264_MMAL_DECODER)       += mmaldec.o
338 338
 OBJS-$(CONFIG_H264_NVENC_ENCODER)      += nvenc_h264.o
339 339
 OBJS-$(CONFIG_NVENC_ENCODER)           += nvenc_h264.o
340 340
 OBJS-$(CONFIG_NVENC_H264_ENCODER)      += nvenc_h264.o
341
-OBJS-$(CONFIG_H264_VDA_DECODER)        += vda_h264_dec.o
342 341
 OBJS-$(CONFIG_H264_OMX_ENCODER)        += omx.o
343 342
 OBJS-$(CONFIG_H264_QSV_DECODER)        += qsvdec_h2645.o
344 343
 OBJS-$(CONFIG_H264_QSV_ENCODER)        += qsvenc_h264.o
... ...
@@ -824,7 +822,6 @@ OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER)       += adpcmenc.o adpcm_data.o
824 824
 OBJS-$(CONFIG_D3D11VA)                    += dxva2.o
825 825
 OBJS-$(CONFIG_DXVA2)                      += dxva2.o
826 826
 OBJS-$(CONFIG_VAAPI)                      += vaapi_decode.o
827
-OBJS-$(CONFIG_VDA)                        += vda.o videotoolbox.o
828 827
 OBJS-$(CONFIG_VIDEOTOOLBOX)               += videotoolbox.o
829 828
 OBJS-$(CONFIG_VDPAU)                      += vdpau.o
830 829
 
... ...
@@ -834,7 +831,6 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)       += dxva2_h264.o
834 834
 OBJS-$(CONFIG_H264_DXVA2_HWACCEL)         += dxva2_h264.o
835 835
 OBJS-$(CONFIG_H264_QSV_HWACCEL)           += qsvdec_h2645.o
836 836
 OBJS-$(CONFIG_H264_VAAPI_HWACCEL)         += vaapi_h264.o
837
-OBJS-$(CONFIG_H264_VDA_HWACCEL)           += vda_h264.o
838 837
 OBJS-$(CONFIG_H264_VDPAU_HWACCEL)         += vdpau_h264.o
839 838
 OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
840 839
 OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)       += dxva2_hevc.o
... ...
@@ -1066,9 +1062,8 @@ SKIPHEADERS-$(CONFIG_QSVDEC)           += qsvdec.h
1066 1066
 SKIPHEADERS-$(CONFIG_QSVENC)           += qsvenc.h
1067 1067
 SKIPHEADERS-$(CONFIG_XVMC)             += xvmc.h
1068 1068
 SKIPHEADERS-$(CONFIG_VAAPI)            += vaapi_decode.h vaapi_encode.h
1069
-SKIPHEADERS-$(CONFIG_VDA)              += vda.h vda_vt_internal.h
1070 1069
 SKIPHEADERS-$(CONFIG_VDPAU)            += vdpau.h vdpau_internal.h
1071
-SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX)     += videotoolbox.h vda_vt_internal.h
1070
+SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX)     += videotoolbox.h vt_internal.h
1072 1071
 SKIPHEADERS-$(CONFIG_V4L2_M2M)         += v4l2_buffers.h v4l2_context.h v4l2_m2m.h
1073 1072
 
1074 1073
 TESTPROGS = avpacket                                                    \
... ...
@@ -72,8 +72,6 @@ static void register_all(void)
72 72
     REGISTER_HWACCEL(H264_MMAL,         h264_mmal);
73 73
     REGISTER_HWACCEL(H264_QSV,          h264_qsv);
74 74
     REGISTER_HWACCEL(H264_VAAPI,        h264_vaapi);
75
-    REGISTER_HWACCEL(H264_VDA,          h264_vda);
76
-    REGISTER_HWACCEL(H264_VDA_OLD,      h264_vda_old);
77 75
     REGISTER_HWACCEL(H264_VDPAU,        h264_vdpau);
78 76
     REGISTER_HWACCEL(H264_VIDEOTOOLBOX, h264_videotoolbox);
79 77
     REGISTER_HWACCEL(HEVC_CUVID,        hevc_cuvid);
... ...
@@ -217,7 +215,6 @@ static void register_all(void)
217 217
     REGISTER_DECODER(H264_MMAL,         h264_mmal);
218 218
     REGISTER_DECODER(H264_QSV,          h264_qsv);
219 219
     REGISTER_DECODER(H264_RKMPP,        h264_rkmpp);
220
-    REGISTER_DECODER(H264_VDA,          h264_vda);
221 220
 #if FF_API_VDPAU
222 221
     REGISTER_DECODER(H264_VDPAU,        h264_vdpau);
223 222
 #endif
... ...
@@ -755,7 +755,6 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
755 755
 #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \
756 756
                      (CONFIG_H264_D3D11VA_HWACCEL * 2) + \
757 757
                      CONFIG_H264_VAAPI_HWACCEL + \
758
-                     (CONFIG_H264_VDA_HWACCEL * 2) + \
759 758
                      CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \
760 759
                      CONFIG_H264_VDPAU_HWACCEL)
761 760
     enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;
... ...
@@ -834,10 +833,6 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
834 834
 #if CONFIG_H264_VAAPI_HWACCEL
835 835
             *fmt++ = AV_PIX_FMT_VAAPI;
836 836
 #endif
837
-#if CONFIG_H264_VDA_HWACCEL
838
-            *fmt++ = AV_PIX_FMT_VDA_VLD;
839
-            *fmt++ = AV_PIX_FMT_VDA;
840
-#endif
841 837
 #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
842 838
             *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;
843 839
 #endif
844 840
deleted file mode 100644
... ...
@@ -1,84 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#include "config.h"
20
-
21
-#include "libavutil/mem.h"
22
-
23
-#include "vda.h"
24
-#include "vda_vt_internal.h"
25
-
26
-#if CONFIG_H264_VDA_HWACCEL
27
-AVVDAContext *av_vda_alloc_context(void)
28
-{
29
-    AVVDAContext *ret = av_mallocz(sizeof(*ret));
30
-
31
-    if (ret) {
32
-        ret->output_callback = ff_vda_output_callback;
33
-        ret->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
34
-    }
35
-
36
-    return ret;
37
-}
38
-
39
-int av_vda_default_init(AVCodecContext *avctx)
40
-{
41
-    return av_vda_default_init2(avctx, NULL);
42
-}
43
-
44
-int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
45
-{
46
-    avctx->hwaccel_context = vdactx ?: av_vda_alloc_context();
47
-    if (!avctx->hwaccel_context)
48
-        return AVERROR(ENOMEM);
49
-    return ff_vda_default_init(avctx);
50
-}
51
-
52
-void av_vda_default_free(AVCodecContext *avctx)
53
-{
54
-    ff_vda_default_free(avctx);
55
-    av_freep(&avctx->hwaccel_context);
56
-}
57
-
58
-void ff_vda_default_free(AVCodecContext *avctx)
59
-{
60
-    AVVDAContext *vda = avctx->hwaccel_context;
61
-    if (vda && vda->decoder)
62
-        VDADecoderDestroy(vda->decoder);
63
-}
64
-
65
-#else
66
-AVVDAContext *av_vda_alloc_context(void)
67
-{
68
-    return NULL;
69
-}
70
-
71
-int av_vda_default_init(AVCodecContext *avctx)
72
-{
73
-    return AVERROR(ENOSYS);
74
-}
75
-
76
-int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
77
-{
78
-    return AVERROR(ENOSYS);
79
-}
80
-
81
-void av_vda_default_free(AVCodecContext *ctx)
82
-{
83
-}
84
-#endif
85 1
deleted file mode 100644
... ...
@@ -1,230 +0,0 @@
1
-/*
2
- * VDA HW acceleration
3
- *
4
- * copyright (c) 2011 Sebastien Zwickert
5
- *
6
- * This file is part of FFmpeg.
7
- *
8
- * FFmpeg is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU Lesser General Public
10
- * License as published by the Free Software Foundation; either
11
- * version 2.1 of the License, or (at your option) any later version.
12
- *
13
- * FFmpeg is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
- * Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public
19
- * License along with FFmpeg; if not, write to the Free Software
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
- */
22
-
23
-#ifndef AVCODEC_VDA_H
24
-#define AVCODEC_VDA_H
25
-
26
-/**
27
- * @file
28
- * @ingroup lavc_codec_hwaccel_vda
29
- * Public libavcodec VDA header.
30
- */
31
-
32
-#include "libavcodec/avcodec.h"
33
-
34
-#include <stdint.h>
35
-
36
-// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
37
-// http://openradar.appspot.com/8026390
38
-#undef __GNUC_STDC_INLINE__
39
-
40
-#define Picture QuickdrawPicture
41
-#include <VideoDecodeAcceleration/VDADecoder.h>
42
-#undef Picture
43
-
44
-#include "libavcodec/version.h"
45
-
46
-// extra flags not defined in VDADecoder.h
47
-enum {
48
-    kVDADecodeInfo_Asynchronous = 1UL << 0,
49
-    kVDADecodeInfo_FrameDropped = 1UL << 1
50
-};
51
-
52
-/**
53
- * @defgroup lavc_codec_hwaccel_vda VDA
54
- * @ingroup lavc_codec_hwaccel
55
- *
56
- * @{
57
- */
58
-
59
-/**
60
- * This structure is used to provide the necessary configurations and data
61
- * to the VDA FFmpeg HWAccel implementation.
62
- *
63
- * The application must make it available as AVCodecContext.hwaccel_context.
64
- */
65
-struct vda_context {
66
-    /**
67
-     * VDA decoder object.
68
-     *
69
-     * - encoding: unused
70
-     * - decoding: Set/Unset by libavcodec.
71
-     */
72
-    VDADecoder          decoder;
73
-
74
-    /**
75
-     * The Core Video pixel buffer that contains the current image data.
76
-     *
77
-     * encoding: unused
78
-     * decoding: Set by libavcodec. Unset by user.
79
-     */
80
-    CVPixelBufferRef    cv_buffer;
81
-
82
-    /**
83
-     * Use the hardware decoder in synchronous mode.
84
-     *
85
-     * encoding: unused
86
-     * decoding: Set by user.
87
-     */
88
-    int                 use_sync_decoding;
89
-
90
-    /**
91
-     * The frame width.
92
-     *
93
-     * - encoding: unused
94
-     * - decoding: Set/Unset by user.
95
-     */
96
-    int                 width;
97
-
98
-    /**
99
-     * The frame height.
100
-     *
101
-     * - encoding: unused
102
-     * - decoding: Set/Unset by user.
103
-     */
104
-    int                 height;
105
-
106
-    /**
107
-     * The frame format.
108
-     *
109
-     * - encoding: unused
110
-     * - decoding: Set/Unset by user.
111
-     */
112
-    int                 format;
113
-
114
-    /**
115
-     * The pixel format for output image buffers.
116
-     *
117
-     * - encoding: unused
118
-     * - decoding: Set/Unset by user.
119
-     */
120
-    OSType              cv_pix_fmt_type;
121
-
122
-    /**
123
-     * unused
124
-     */
125
-    uint8_t             *priv_bitstream;
126
-
127
-    /**
128
-     * unused
129
-     */
130
-    int                 priv_bitstream_size;
131
-
132
-    /**
133
-     * unused
134
-     */
135
-    int                 priv_allocated_size;
136
-
137
-    /**
138
-     * Use av_buffer to manage buffer.
139
-     * When the flag is set, the CVPixelBuffers returned by the decoder will
140
-     * be released automatically, so you have to retain them if necessary.
141
-     * Not setting this flag may cause memory leak.
142
-     *
143
-     * encoding: unused
144
-     * decoding: Set by user.
145
-     */
146
-    int                 use_ref_buffer;
147
-};
148
-
149
-/** Create the video decoder. */
150
-int ff_vda_create_decoder(struct vda_context *vda_ctx,
151
-                          uint8_t *extradata,
152
-                          int extradata_size);
153
-
154
-/** Destroy the video decoder. */
155
-int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
156
-
157
-/**
158
- * This struct holds all the information that needs to be passed
159
- * between the caller and libavcodec for initializing VDA decoding.
160
- * Its size is not a part of the public ABI, it must be allocated with
161
- * av_vda_alloc_context() and freed with av_free().
162
- */
163
-typedef struct AVVDAContext {
164
-    /**
165
-     * VDA decoder object. Created and freed by the caller.
166
-     */
167
-    VDADecoder decoder;
168
-
169
-    /**
170
-     * The output callback that must be passed to VDADecoderCreate.
171
-     * Set by av_vda_alloc_context().
172
-     */
173
-    VDADecoderOutputCallback output_callback;
174
-
175
-    /**
176
-     * CVPixelBuffer Format Type that VDA will use for decoded frames; set by
177
-     * the caller.
178
-     */
179
-    OSType cv_pix_fmt_type;
180
-} AVVDAContext;
181
-
182
-/**
183
- * Allocate and initialize a VDA context.
184
- *
185
- * This function should be called from the get_format() callback when the caller
186
- * selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
187
- * object (using the output callback provided by libavcodec) that will be used
188
- * for VDA-accelerated decoding.
189
- *
190
- * When decoding with VDA is finished, the caller must destroy the decoder
191
- * object and free the VDA context using av_free().
192
- *
193
- * @return the newly allocated context or NULL on failure
194
- */
195
-AVVDAContext *av_vda_alloc_context(void);
196
-
197
-/**
198
- * This is a convenience function that creates and sets up the VDA context using
199
- * an internal implementation.
200
- *
201
- * @param avctx the corresponding codec context
202
- *
203
- * @return >= 0 on success, a negative AVERROR code on failure
204
- */
205
-int av_vda_default_init(AVCodecContext *avctx);
206
-
207
-/**
208
- * This is a convenience function that creates and sets up the VDA context using
209
- * an internal implementation.
210
- *
211
- * @param avctx the corresponding codec context
212
- * @param vdactx the VDA context to use
213
- *
214
- * @return >= 0 on success, a negative AVERROR code on failure
215
- */
216
-int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx);
217
-
218
-/**
219
- * This function must be called to free the VDA context initialized with
220
- * av_vda_default_init().
221
- *
222
- * @param avctx the corresponding codec context
223
- */
224
-void av_vda_default_free(AVCodecContext *avctx);
225
-
226
-/**
227
- * @}
228
- */
229
-
230
-#endif /* AVCODEC_VDA_H */
231 1
deleted file mode 100644
... ...
@@ -1,425 +0,0 @@
1
-/*
2
- * VDA H264 HW acceleration.
3
- *
4
- * copyright (c) 2011 Sebastien Zwickert
5
- *
6
- * This file is part of FFmpeg.
7
- *
8
- * FFmpeg is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU Lesser General Public
10
- * License as published by the Free Software Foundation; either
11
- * version 2.1 of the License, or (at your option) any later version.
12
- *
13
- * FFmpeg is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
- * Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public
19
- * License along with FFmpeg; if not, write to the Free Software
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
- */
22
-
23
-#include <CoreFoundation/CFDictionary.h>
24
-#include <CoreFoundation/CFNumber.h>
25
-#include <CoreFoundation/CFData.h>
26
-
27
-#include "vda.h"
28
-#include "libavutil/avutil.h"
29
-#include "h264dec.h"
30
-
31
-struct vda_buffer {
32
-    CVPixelBufferRef cv_buffer;
33
-};
34
-#include "internal.h"
35
-#include "vda_vt_internal.h"
36
-
37
-/* Decoder callback that adds the vda frame to the queue in display order. */
38
-static void vda_decoder_callback(void *vda_hw_ctx,
39
-                                 CFDictionaryRef user_info,
40
-                                 OSStatus status,
41
-                                 uint32_t infoFlags,
42
-                                 CVImageBufferRef image_buffer)
43
-{
44
-    struct vda_context *vda_ctx = vda_hw_ctx;
45
-
46
-    if (infoFlags & kVDADecodeInfo_FrameDropped)
47
-        vda_ctx->cv_buffer = NULL;
48
-
49
-    if (!image_buffer)
50
-        return;
51
-
52
-    if (vda_ctx->cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer))
53
-        return;
54
-
55
-    vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer);
56
-}
57
-
58
-static int vda_sync_decode(VTContext *ctx, struct vda_context *vda_ctx)
59
-{
60
-    OSStatus status;
61
-    CFDataRef coded_frame;
62
-    uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
63
-
64
-    coded_frame = CFDataCreate(kCFAllocatorDefault,
65
-                               ctx->bitstream,
66
-                               ctx->bitstream_size);
67
-
68
-    status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
69
-
70
-    if (kVDADecoderNoErr == status)
71
-        status = VDADecoderFlush(vda_ctx->decoder, flush_flags);
72
-
73
-    CFRelease(coded_frame);
74
-
75
-    return status;
76
-}
77
-
78
-
79
-static int vda_old_h264_start_frame(AVCodecContext *avctx,
80
-                                av_unused const uint8_t *buffer,
81
-                                av_unused uint32_t size)
82
-{
83
-    VTContext *vda = avctx->internal->hwaccel_priv_data;
84
-    struct vda_context *vda_ctx = avctx->hwaccel_context;
85
-
86
-    if (!vda_ctx->decoder)
87
-        return -1;
88
-
89
-    vda->bitstream_size = 0;
90
-
91
-    return 0;
92
-}
93
-
94
-static int vda_old_h264_decode_slice(AVCodecContext *avctx,
95
-                                 const uint8_t *buffer,
96
-                                 uint32_t size)
97
-{
98
-    VTContext *vda              = avctx->internal->hwaccel_priv_data;
99
-    struct vda_context *vda_ctx = avctx->hwaccel_context;
100
-    void *tmp;
101
-
102
-    if (!vda_ctx->decoder)
103
-        return -1;
104
-
105
-    tmp = av_fast_realloc(vda->bitstream,
106
-                          &vda->allocated_size,
107
-                          vda->bitstream_size + size + 4);
108
-    if (!tmp)
109
-        return AVERROR(ENOMEM);
110
-
111
-    vda->bitstream = tmp;
112
-
113
-    AV_WB32(vda->bitstream + vda->bitstream_size, size);
114
-    memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
115
-
116
-    vda->bitstream_size += size + 4;
117
-
118
-    return 0;
119
-}
120
-
121
-static void vda_h264_release_buffer(void *opaque, uint8_t *data)
122
-{
123
-    struct vda_buffer *context = opaque;
124
-    CVPixelBufferRelease(context->cv_buffer);
125
-    av_free(context);
126
-}
127
-
128
-static int vda_old_h264_end_frame(AVCodecContext *avctx)
129
-{
130
-    H264Context *h                      = avctx->priv_data;
131
-    VTContext *vda                      = avctx->internal->hwaccel_priv_data;
132
-    struct vda_context *vda_ctx         = avctx->hwaccel_context;
133
-    AVFrame *frame                      = h->cur_pic_ptr->f;
134
-    struct vda_buffer *context;
135
-    AVBufferRef *buffer;
136
-    int status;
137
-
138
-    if (!vda_ctx->decoder || !vda->bitstream)
139
-        return -1;
140
-
141
-    status = vda_sync_decode(vda, vda_ctx);
142
-    frame->data[3] = (void*)vda_ctx->cv_buffer;
143
-
144
-    if (status)
145
-        av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
146
-
147
-    if (!vda_ctx->use_ref_buffer || status)
148
-        return status;
149
-
150
-    context = av_mallocz(sizeof(*context));
151
-    buffer = av_buffer_create(NULL, 0, vda_h264_release_buffer, context, 0);
152
-    if (!context || !buffer) {
153
-        CVPixelBufferRelease(vda_ctx->cv_buffer);
154
-        av_free(context);
155
-        return -1;
156
-    }
157
-
158
-    context->cv_buffer = vda_ctx->cv_buffer;
159
-    frame->buf[3] = buffer;
160
-
161
-    return status;
162
-}
163
-
164
-int ff_vda_create_decoder(struct vda_context *vda_ctx,
165
-                          uint8_t *extradata,
166
-                          int extradata_size)
167
-{
168
-    OSStatus status;
169
-    CFNumberRef height;
170
-    CFNumberRef width;
171
-    CFNumberRef format;
172
-    CFDataRef avc_data;
173
-    CFMutableDictionaryRef config_info;
174
-    CFMutableDictionaryRef buffer_attributes;
175
-    CFMutableDictionaryRef io_surface_properties;
176
-    CFNumberRef cv_pix_fmt;
177
-
178
-    vda_ctx->priv_bitstream = NULL;
179
-    vda_ctx->priv_allocated_size = 0;
180
-
181
-    /* Each VCL NAL in the bitstream sent to the decoder
182
-     * is preceded by a 4 bytes length header.
183
-     * Change the avcC atom header if needed, to signal headers of 4 bytes. */
184
-    if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) {
185
-        uint8_t *rw_extradata;
186
-
187
-        if (!(rw_extradata = av_malloc(extradata_size)))
188
-            return AVERROR(ENOMEM);
189
-
190
-        memcpy(rw_extradata, extradata, extradata_size);
191
-
192
-        rw_extradata[4] |= 0x03;
193
-
194
-        avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size);
195
-
196
-        av_freep(&rw_extradata);
197
-    } else {
198
-        avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
199
-    }
200
-
201
-    config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
202
-                                            4,
203
-                                            &kCFTypeDictionaryKeyCallBacks,
204
-                                            &kCFTypeDictionaryValueCallBacks);
205
-
206
-    height   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height);
207
-    width    = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width);
208
-    format   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format);
209
-
210
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
211
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
212
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
213
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
214
-
215
-    buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
216
-                                                  2,
217
-                                                  &kCFTypeDictionaryKeyCallBacks,
218
-                                                  &kCFTypeDictionaryValueCallBacks);
219
-    io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
220
-                                                      0,
221
-                                                      &kCFTypeDictionaryKeyCallBacks,
222
-                                                      &kCFTypeDictionaryValueCallBacks);
223
-    cv_pix_fmt  = CFNumberCreate(kCFAllocatorDefault,
224
-                                 kCFNumberSInt32Type,
225
-                                 &vda_ctx->cv_pix_fmt_type);
226
-    CFDictionarySetValue(buffer_attributes,
227
-                         kCVPixelBufferPixelFormatTypeKey,
228
-                         cv_pix_fmt);
229
-    CFDictionarySetValue(buffer_attributes,
230
-                         kCVPixelBufferIOSurfacePropertiesKey,
231
-                         io_surface_properties);
232
-
233
-    status = VDADecoderCreate(config_info,
234
-                              buffer_attributes,
235
-                              (VDADecoderOutputCallback *)vda_decoder_callback,
236
-                              vda_ctx,
237
-                              &vda_ctx->decoder);
238
-
239
-    CFRelease(height);
240
-    CFRelease(width);
241
-    CFRelease(format);
242
-    CFRelease(avc_data);
243
-    CFRelease(config_info);
244
-    CFRelease(io_surface_properties);
245
-    CFRelease(cv_pix_fmt);
246
-    CFRelease(buffer_attributes);
247
-
248
-    return status;
249
-}
250
-
251
-int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
252
-{
253
-    OSStatus status = kVDADecoderNoErr;
254
-
255
-    if (vda_ctx->decoder)
256
-        status = VDADecoderDestroy(vda_ctx->decoder);
257
-
258
-    return status;
259
-}
260
-
261
-AVHWAccel ff_h264_vda_old_hwaccel = {
262
-    .name           = "h264_vda",
263
-    .type           = AVMEDIA_TYPE_VIDEO,
264
-    .id             = AV_CODEC_ID_H264,
265
-    .pix_fmt        = AV_PIX_FMT_VDA_VLD,
266
-    .start_frame    = vda_old_h264_start_frame,
267
-    .decode_slice   = vda_old_h264_decode_slice,
268
-    .end_frame      = vda_old_h264_end_frame,
269
-    .uninit         = ff_videotoolbox_uninit,
270
-    .priv_data_size = sizeof(VTContext),
271
-};
272
-
273
-void ff_vda_output_callback(void *opaque,
274
-                            CFDictionaryRef user_info,
275
-                            OSStatus status,
276
-                            uint32_t infoFlags,
277
-                            CVImageBufferRef image_buffer)
278
-{
279
-    AVCodecContext *ctx = opaque;
280
-    VTContext *vda = ctx->internal->hwaccel_priv_data;
281
-
282
-
283
-    if (vda->frame) {
284
-        CVPixelBufferRelease(vda->frame);
285
-        vda->frame = NULL;
286
-    }
287
-
288
-    if (!image_buffer)
289
-        return;
290
-
291
-    vda->frame = CVPixelBufferRetain(image_buffer);
292
-}
293
-
294
-static int vda_h264_end_frame(AVCodecContext *avctx)
295
-{
296
-    H264Context *h        = avctx->priv_data;
297
-    VTContext *vda        = avctx->internal->hwaccel_priv_data;
298
-    AVVDAContext *vda_ctx = avctx->hwaccel_context;
299
-    AVFrame *frame        = h->cur_pic_ptr->f;
300
-    uint32_t flush_flags  = 1 << 0; ///< kVDADecoderFlush_emitFrames
301
-    CFDataRef coded_frame;
302
-    OSStatus status;
303
-
304
-    if (!vda->bitstream_size)
305
-        return AVERROR_INVALIDDATA;
306
-
307
-
308
-    coded_frame = CFDataCreate(kCFAllocatorDefault,
309
-                               vda->bitstream,
310
-                               vda->bitstream_size);
311
-
312
-    status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
313
-
314
-    if (status == kVDADecoderNoErr)
315
-        status = VDADecoderFlush(vda_ctx->decoder, flush_flags);
316
-
317
-    CFRelease(coded_frame);
318
-
319
-    if (!vda->frame)
320
-        return AVERROR_UNKNOWN;
321
-
322
-    if (status != kVDADecoderNoErr) {
323
-        av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
324
-        return AVERROR_UNKNOWN;
325
-    }
326
-
327
-    return ff_videotoolbox_buffer_create(vda, frame);
328
-}
329
-
330
-int ff_vda_default_init(AVCodecContext *avctx)
331
-{
332
-    AVVDAContext *vda_ctx = avctx->hwaccel_context;
333
-    OSStatus status = kVDADecoderNoErr;
334
-    CFNumberRef height;
335
-    CFNumberRef width;
336
-    CFNumberRef format;
337
-    CFDataRef avc_data;
338
-    CFMutableDictionaryRef config_info;
339
-    CFMutableDictionaryRef buffer_attributes;
340
-    CFMutableDictionaryRef io_surface_properties;
341
-    CFNumberRef cv_pix_fmt;
342
-    int32_t fmt = 'avc1', pix_fmt = vda_ctx->cv_pix_fmt_type;
343
-
344
-    // kCVPixelFormatType_420YpCbCr8Planar;
345
-
346
-    avc_data = ff_videotoolbox_avcc_extradata_create(avctx);
347
-
348
-    config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
349
-                                            4,
350
-                                            &kCFTypeDictionaryKeyCallBacks,
351
-                                            &kCFTypeDictionaryValueCallBacks);
352
-
353
-    height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &avctx->height);
354
-    width  = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &avctx->width);
355
-    format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &fmt);
356
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
357
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
358
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
359
-    CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
360
-
361
-    buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
362
-                                                  2,
363
-                                                  &kCFTypeDictionaryKeyCallBacks,
364
-                                                  &kCFTypeDictionaryValueCallBacks);
365
-    io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
366
-                                                      0,
367
-                                                      &kCFTypeDictionaryKeyCallBacks,
368
-                                                      &kCFTypeDictionaryValueCallBacks);
369
-    cv_pix_fmt      = CFNumberCreate(kCFAllocatorDefault,
370
-                                     kCFNumberSInt32Type,
371
-                                     &pix_fmt);
372
-
373
-    CFDictionarySetValue(buffer_attributes,
374
-                         kCVPixelBufferPixelFormatTypeKey,
375
-                         cv_pix_fmt);
376
-    CFDictionarySetValue(buffer_attributes,
377
-                         kCVPixelBufferIOSurfacePropertiesKey,
378
-                         io_surface_properties);
379
-
380
-    status = VDADecoderCreate(config_info,
381
-                              buffer_attributes,
382
-                              (VDADecoderOutputCallback *)ff_vda_output_callback,
383
-                              avctx,
384
-                              &vda_ctx->decoder);
385
-
386
-    CFRelease(format);
387
-    CFRelease(height);
388
-    CFRelease(width);
389
-    CFRelease(avc_data);
390
-    CFRelease(config_info);
391
-    CFRelease(cv_pix_fmt);
392
-    CFRelease(io_surface_properties);
393
-    CFRelease(buffer_attributes);
394
-
395
-    if (status != kVDADecoderNoErr) {
396
-        av_log(avctx, AV_LOG_ERROR, "Cannot initialize VDA %d\n", status);
397
-    }
398
-
399
-    switch (status) {
400
-    case kVDADecoderHardwareNotSupportedErr:
401
-    case kVDADecoderFormatNotSupportedErr:
402
-        return AVERROR(ENOSYS);
403
-    case kVDADecoderConfigurationError:
404
-        return AVERROR(EINVAL);
405
-    case kVDADecoderDecoderFailedErr:
406
-        return AVERROR_INVALIDDATA;
407
-    case kVDADecoderNoErr:
408
-        return 0;
409
-    default:
410
-        return AVERROR_UNKNOWN;
411
-    }
412
-}
413
-
414
-AVHWAccel ff_h264_vda_hwaccel = {
415
-    .name           = "h264_vda",
416
-    .type           = AVMEDIA_TYPE_VIDEO,
417
-    .id             = AV_CODEC_ID_H264,
418
-    .pix_fmt        = AV_PIX_FMT_VDA,
419
-    .alloc_frame    = ff_videotoolbox_alloc_frame,
420
-    .start_frame    = ff_videotoolbox_h264_start_frame,
421
-    .decode_slice   = ff_videotoolbox_h264_decode_slice,
422
-    .end_frame      = vda_h264_end_frame,
423
-    .uninit         = ff_videotoolbox_uninit,
424
-    .priv_data_size = sizeof(VTContext),
425
-};
426 1
deleted file mode 100644
... ...
@@ -1,263 +0,0 @@
1
-/*
2
- * Copyright (c) 2012, Xidorn Quan
3
- *
4
- * This file is part of FFmpeg.
5
- *
6
- * FFmpeg is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU Lesser General Public
8
- * License as published by the Free Software Foundation; either
9
- * version 2.1 of the License, or (at your option) any later version.
10
- *
11
- * FFmpeg is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
- * Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public
17
- * License along with FFmpeg; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
- */
20
-
21
-/**
22
- * @file
23
- * H.264 decoder via VDA
24
- * @author Xidorn Quan <quanxunzhen@gmail.com>
25
- */
26
-
27
-#include <string.h>
28
-#include <CoreFoundation/CoreFoundation.h>
29
-
30
-#include "vda.h"
31
-#include "h264dec.h"
32
-#include "avcodec.h"
33
-
34
-#ifndef kCFCoreFoundationVersionNumber10_7
35
-#define kCFCoreFoundationVersionNumber10_7      635.00
36
-#endif
37
-
38
-extern AVCodec ff_h264_decoder, ff_h264_vda_decoder;
39
-
40
-static const enum AVPixelFormat vda_pixfmts_prior_10_7[] = {
41
-    AV_PIX_FMT_UYVY422,
42
-    AV_PIX_FMT_YUV420P,
43
-    AV_PIX_FMT_NONE
44
-};
45
-
46
-static const enum AVPixelFormat vda_pixfmts[] = {
47
-    AV_PIX_FMT_UYVY422,
48
-    AV_PIX_FMT_YUYV422,
49
-    AV_PIX_FMT_NV12,
50
-    AV_PIX_FMT_YUV420P,
51
-    AV_PIX_FMT_NONE
52
-};
53
-
54
-typedef struct {
55
-    H264Context h264ctx;
56
-    int h264_initialized;
57
-    struct vda_context vda_ctx;
58
-    enum AVPixelFormat pix_fmt;
59
-
60
-    /* for backing-up fields set by user.
61
-     * we have to gain full control of such fields here */
62
-    void *hwaccel_context;
63
-    enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
64
-    int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
65
-} VDADecoderContext;
66
-
67
-static enum AVPixelFormat get_format(struct AVCodecContext *avctx,
68
-        const enum AVPixelFormat *fmt)
69
-{
70
-    return AV_PIX_FMT_VDA_VLD;
71
-}
72
-
73
-typedef struct {
74
-    CVPixelBufferRef cv_buffer;
75
-} VDABufferContext;
76
-
77
-static void release_buffer(void *opaque, uint8_t *data)
78
-{
79
-    VDABufferContext *context = opaque;
80
-    CVPixelBufferUnlockBaseAddress(context->cv_buffer, 0);
81
-    CVPixelBufferRelease(context->cv_buffer);
82
-    av_free(context);
83
-}
84
-
85
-static int get_buffer2(AVCodecContext *avctx, AVFrame *pic, int flag)
86
-{
87
-    VDABufferContext *context = av_mallocz(sizeof(VDABufferContext));
88
-    AVBufferRef *buffer = av_buffer_create(NULL, 0, release_buffer, context, 0);
89
-    if (!context || !buffer) {
90
-        av_free(context);
91
-        return AVERROR(ENOMEM);
92
-    }
93
-
94
-    pic->buf[0] = buffer;
95
-    pic->data[0] = (void *)1;
96
-    return 0;
97
-}
98
-
99
-static inline void set_context(AVCodecContext *avctx)
100
-{
101
-    VDADecoderContext *ctx = avctx->priv_data;
102
-    ctx->hwaccel_context = avctx->hwaccel_context;
103
-    avctx->hwaccel_context = &ctx->vda_ctx;
104
-    ctx->get_format = avctx->get_format;
105
-    avctx->get_format = get_format;
106
-    ctx->get_buffer2 = avctx->get_buffer2;
107
-    avctx->get_buffer2 = get_buffer2;
108
-}
109
-
110
-static inline void restore_context(AVCodecContext *avctx)
111
-{
112
-    VDADecoderContext *ctx = avctx->priv_data;
113
-    avctx->hwaccel_context = ctx->hwaccel_context;
114
-    avctx->get_format = ctx->get_format;
115
-    avctx->get_buffer2 = ctx->get_buffer2;
116
-}
117
-
118
-static int vdadec_decode(AVCodecContext *avctx,
119
-        void *data, int *got_frame, AVPacket *avpkt)
120
-{
121
-    VDADecoderContext *ctx = avctx->priv_data;
122
-    AVFrame *pic = data;
123
-    int ret;
124
-
125
-    set_context(avctx);
126
-    ret = ff_h264_decoder.decode(avctx, data, got_frame, avpkt);
127
-    restore_context(avctx);
128
-    if (*got_frame) {
129
-        AVBufferRef *buffer = pic->buf[0];
130
-        VDABufferContext *context = av_buffer_get_opaque(buffer);
131
-        CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3];
132
-
133
-        CVPixelBufferRetain(cv_buffer);
134
-        CVPixelBufferLockBaseAddress(cv_buffer, 0);
135
-        context->cv_buffer = cv_buffer;
136
-        pic->format = ctx->pix_fmt;
137
-        if (CVPixelBufferIsPlanar(cv_buffer)) {
138
-            int i, count = CVPixelBufferGetPlaneCount(cv_buffer);
139
-            av_assert0(count < 4);
140
-            for (i = 0; i < count; i++) {
141
-                pic->data[i] = CVPixelBufferGetBaseAddressOfPlane(cv_buffer, i);
142
-                pic->linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(cv_buffer, i);
143
-            }
144
-        } else {
145
-            pic->data[0] = CVPixelBufferGetBaseAddress(cv_buffer);
146
-            pic->linesize[0] = CVPixelBufferGetBytesPerRow(cv_buffer);
147
-        }
148
-    }
149
-    avctx->pix_fmt = ctx->pix_fmt;
150
-
151
-    return ret;
152
-}
153
-
154
-static av_cold int vdadec_close(AVCodecContext *avctx)
155
-{
156
-    VDADecoderContext *ctx = avctx->priv_data;
157
-    /* release buffers and decoder */
158
-    ff_vda_destroy_decoder(&ctx->vda_ctx);
159
-    /* close H.264 decoder */
160
-    if (ctx->h264_initialized) {
161
-        set_context(avctx);
162
-        ff_h264_decoder.close(avctx);
163
-        restore_context(avctx);
164
-    }
165
-    return 0;
166
-}
167
-
168
-static av_cold int vdadec_init(AVCodecContext *avctx)
169
-{
170
-    VDADecoderContext *ctx = avctx->priv_data;
171
-    struct vda_context *vda_ctx = &ctx->vda_ctx;
172
-    OSStatus status;
173
-    int ret, i;
174
-
175
-    ctx->h264_initialized = 0;
176
-
177
-    /* init pix_fmts of codec */
178
-    if (!ff_h264_vda_decoder.pix_fmts) {
179
-        if (kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7)
180
-            ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;
181
-        else
182
-            ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
183
-    }
184
-
185
-    /* init vda */
186
-    memset(vda_ctx, 0, sizeof(struct vda_context));
187
-    vda_ctx->width = avctx->width;
188
-    vda_ctx->height = avctx->height;
189
-    vda_ctx->format = 'avc1';
190
-    vda_ctx->use_sync_decoding = 1;
191
-    vda_ctx->use_ref_buffer = 1;
192
-    ctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
193
-    switch (ctx->pix_fmt) {
194
-    case AV_PIX_FMT_UYVY422:
195
-        vda_ctx->cv_pix_fmt_type = '2vuy';
196
-        break;
197
-    case AV_PIX_FMT_YUYV422:
198
-        vda_ctx->cv_pix_fmt_type = 'yuvs';
199
-        break;
200
-    case AV_PIX_FMT_NV12:
201
-        vda_ctx->cv_pix_fmt_type = '420v';
202
-        break;
203
-    case AV_PIX_FMT_YUV420P:
204
-        vda_ctx->cv_pix_fmt_type = 'y420';
205
-        break;
206
-    default:
207
-        av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format: %d\n", avctx->pix_fmt);
208
-        goto failed;
209
-    }
210
-    status = ff_vda_create_decoder(vda_ctx,
211
-                                   avctx->extradata, avctx->extradata_size);
212
-    if (status != kVDADecoderNoErr) {
213
-        av_log(avctx, AV_LOG_ERROR,
214
-                "Failed to init VDA decoder: %d.\n", status);
215
-        goto failed;
216
-    }
217
-
218
-    /* init H.264 decoder */
219
-    set_context(avctx);
220
-    ret = ff_h264_decoder.init(avctx);
221
-    restore_context(avctx);
222
-    if (ret < 0) {
223
-        av_log(avctx, AV_LOG_ERROR, "Failed to open H.264 decoder.\n");
224
-        goto failed;
225
-    }
226
-    ctx->h264_initialized = 1;
227
-
228
-    for (i = 0; i < MAX_SPS_COUNT; i++) {
229
-        const SPS *sps = ctx->h264ctx.ps.sps_list[i] ? (const SPS*)ctx->h264ctx.ps.sps_list[i]->data : NULL;
230
-        if (sps && (sps->bit_depth_luma != 8 ||
231
-                sps->chroma_format_idc == 2 ||
232
-                sps->chroma_format_idc == 3)) {
233
-            av_log(avctx, AV_LOG_ERROR, "Format is not supported.\n");
234
-            goto failed;
235
-        }
236
-    }
237
-
238
-    return 0;
239
-
240
-failed:
241
-    vdadec_close(avctx);
242
-    return -1;
243
-}
244
-
245
-static void vdadec_flush(AVCodecContext *avctx)
246
-{
247
-    set_context(avctx);
248
-    ff_h264_decoder.flush(avctx);
249
-    restore_context(avctx);
250
-}
251
-
252
-AVCodec ff_h264_vda_decoder = {
253
-    .name           = "h264_vda",
254
-    .type           = AVMEDIA_TYPE_VIDEO,
255
-    .id             = AV_CODEC_ID_H264,
256
-    .priv_data_size = sizeof(VDADecoderContext),
257
-    .init           = vdadec_init,
258
-    .close          = vdadec_close,
259
-    .decode         = vdadec_decode,
260
-    .capabilities   = AV_CODEC_CAP_DELAY,
261
-    .flush          = vdadec_flush,
262
-    .long_name      = NULL_IF_CONFIG_SMALL("H.264 (VDA acceleration)"),
263
-};
264 1
deleted file mode 100644
... ...
@@ -1,63 +0,0 @@
1
-/*
2
- * This file is part of FFmpeg.
3
- *
4
- * FFmpeg is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU Lesser General Public
6
- * License as published by the Free Software Foundation; either
7
- * version 2.1 of the License, or (at your option) any later version.
8
- *
9
- * FFmpeg is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * Lesser General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Lesser General Public
15
- * License along with FFmpeg; if not, write to the Free Software
16
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-#ifndef AVCODEC_VDA_VT_INTERNAL_H
20
-#define AVCODEC_VDA_VT_INTERNAL_H
21
-
22
-void ff_vda_output_callback(void *vda_hw_ctx,
23
-                            CFDictionaryRef user_info,
24
-                            OSStatus status,
25
-                            uint32_t infoFlags,
26
-                            CVImageBufferRef image_buffer);
27
-
28
-int ff_vda_default_init(AVCodecContext *avctx);
29
-void ff_vda_default_free(AVCodecContext *avctx);
30
-
31
-typedef struct VTContext {
32
-    // The current bitstream buffer.
33
-    uint8_t                     *bitstream;
34
-
35
-    // The current size of the bitstream.
36
-    int                         bitstream_size;
37
-
38
-    // The reference size used for fast reallocation.
39
-    int                         allocated_size;
40
-
41
-    // The core video buffer
42
-    CVImageBufferRef            frame;
43
-
44
-    // Current dummy frames context (depends on exact CVImageBufferRef params).
45
-    struct AVBufferRef         *cached_hw_frames_ctx;
46
-
47
-    // Non-NULL if the new hwaccel API is used. This is only a separate struct
48
-    // to ease compatibility with the old API.
49
-    struct AVVideotoolboxContext *vt_ctx;
50
-} VTContext;
51
-
52
-int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame);
53
-int ff_videotoolbox_uninit(AVCodecContext *avctx);
54
-int ff_videotoolbox_buffer_create(VTContext *vtctx, AVFrame *frame);
55
-int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx,
56
-                                     const uint8_t *buffer,
57
-                                     uint32_t size);
58
-int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx,
59
-                                      const uint8_t *buffer,
60
-                                      uint32_t size);
61
-CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx);
62
-CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx);
63
-#endif /* AVCODEC_VDA_VT_INTERNAL_H */
... ...
@@ -21,13 +21,9 @@
21 21
  */
22 22
 
23 23
 #include "config.h"
24
-#if CONFIG_VIDEOTOOLBOX
25
-#  include "videotoolbox.h"
26
-#  include "libavutil/hwcontext_videotoolbox.h"
27
-#else
28
-#  include "vda.h"
29
-#endif
30
-#include "vda_vt_internal.h"
24
+#include "videotoolbox.h"
25
+#include "libavutil/hwcontext_videotoolbox.h"
26
+#include "vt_internal.h"
31 27
 #include "libavutil/avutil.h"
32 28
 #include "libavutil/hwcontext.h"
33 29
 #include "bytestream.h"
34 30
new file mode 100644
... ...
@@ -0,0 +1,55 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVCODEC_VT_INTERNAL_H
19
+#define AVCODEC_VT_INTERNAL_H
20
+
21
+typedef struct VTContext {
22
+    // The current bitstream buffer.
23
+    uint8_t                     *bitstream;
24
+
25
+    // The current size of the bitstream.
26
+    int                         bitstream_size;
27
+
28
+    // The reference size used for fast reallocation.
29
+    int                         allocated_size;
30
+
31
+    // The core video buffer
32
+    CVImageBufferRef            frame;
33
+
34
+    // Current dummy frames context (depends on exact CVImageBufferRef params).
35
+    struct AVBufferRef         *cached_hw_frames_ctx;
36
+
37
+    // Non-NULL if the new hwaccel API is used. This is only a separate struct
38
+    // to ease compatibility with the old API.
39
+    struct AVVideotoolboxContext *vt_ctx;
40
+} VTContext;
41
+
42
+int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame);
43
+int ff_videotoolbox_uninit(AVCodecContext *avctx);
44
+int ff_videotoolbox_buffer_create(VTContext *vtctx, AVFrame *frame);
45
+int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx,
46
+                                     const uint8_t *buffer,
47
+                                     uint32_t size);
48
+int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx,
49
+                                      const uint8_t *buffer,
50
+                                      uint32_t size);
51
+CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx);
52
+CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx);
53
+
54
+#endif /* AVCODEC_VT_INTERNAL_H */
... ...
@@ -1670,12 +1670,6 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
1670 1670
         .log2_chroma_h = 1,
1671 1671
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
1672 1672
     },
1673
-    [AV_PIX_FMT_VDA_VLD] = {
1674
-        .name = "vda_vld",
1675
-        .log2_chroma_w = 1,
1676
-        .log2_chroma_h = 1,
1677
-        .flags = AV_PIX_FMT_FLAG_HWACCEL,
1678
-    },
1679 1673
     [AV_PIX_FMT_YA8] = {
1680 1674
         .name = "ya8",
1681 1675
         .nb_components = 2,
... ...
@@ -2029,10 +2023,6 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
2029 2029
         },
2030 2030
         .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE,
2031 2031
     },
2032
-    [AV_PIX_FMT_VDA] = {
2033
-        .name = "vda",
2034
-        .flags = AV_PIX_FMT_FLAG_HWACCEL,
2035
-    },
2036 2032
     [AV_PIX_FMT_QSV] = {
2037 2033
         .name = "qsv",
2038 2034
         .flags = AV_PIX_FMT_FLAG_HWACCEL,
... ...
@@ -176,7 +176,6 @@ enum AVPixelFormat {
176 176
     AV_PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
177 177
     AV_PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
178 178
     AV_PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
179
-    AV_PIX_FMT_VDA_VLD,    ///< hardware decoding through VDA
180 179
     AV_PIX_FMT_GBRP,      ///< planar GBR 4:4:4 24bpp
181 180
     AV_PIX_FMT_GBR24P = AV_PIX_FMT_GBRP, // alias for #AV_PIX_FMT_GBRP
182 181
     AV_PIX_FMT_GBRP9BE,   ///< planar GBR 4:4:4 27bpp, big-endian
... ...
@@ -221,8 +220,6 @@ enum AVPixelFormat {
221 221
 
222 222
     AV_PIX_FMT_YVYU422,   ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
223 223
 
224
-    AV_PIX_FMT_VDA,          ///< HW acceleration through VDA, data[3] contains a CVPixelBufferRef
225
-
226 224
     AV_PIX_FMT_YA16BE,       ///< 16 bits gray, 16 bits alpha (big-endian)
227 225
     AV_PIX_FMT_YA16LE,       ///< 16 bits gray, 16 bits alpha (little-endian)
228 226
 
... ...
@@ -41,9 +41,6 @@ unsigned avutil_version(void)
41 41
     if (checks_done)
42 42
         return LIBAVUTIL_VERSION_INT;
43 43
 
44
-#if FF_API_VDPAU
45
-    av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
46
-#endif
47 44
     av_assert0(AV_SAMPLE_FMT_DBLP == 9);
48 45
     av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
49 46
     av_assert0(AV_PICTURE_TYPE_BI == 7);