4 * copyright (c) 2011 Sebastien Zwickert
6 * This file is part of FFmpeg.
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.
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.
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
28 * @ingroup lavc_codec_hwaccel_vda
29 * Public libavcodec VDA header.
32 #include "libavcodec/avcodec.h"
36 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
37 // http://openradar.appspot.com/8026390
38 #undef __GNUC_STDC_INLINE__
40 #define Picture QuickdrawPicture
41 #include <VideoDecodeAcceleration/VDADecoder.h>
44 #include "libavcodec/version.h"
46 // extra flags not defined in VDADecoder.h
48 kVDADecodeInfo_Asynchronous
= 1UL << 0,
49 kVDADecodeInfo_FrameDropped
= 1UL << 1
53 * @defgroup lavc_codec_hwaccel_vda VDA
54 * @ingroup lavc_codec_hwaccel
60 * This structure is used to provide the necessary configurations and data
61 * to the VDA FFmpeg HWAccel implementation.
63 * The application must make it available as AVCodecContext.hwaccel_context.
70 * - decoding: Set/Unset by libavcodec.
75 * The Core Video pixel buffer that contains the current image data.
78 * decoding: Set by libavcodec. Unset by user.
80 CVPixelBufferRef cv_buffer
;
83 * Use the hardware decoder in synchronous mode.
86 * decoding: Set by user.
88 int use_sync_decoding
;
94 * - decoding: Set/Unset by user.
102 * - decoding: Set/Unset by user.
110 * - decoding: Set/Unset by user.
115 * The pixel format for output image buffers.
118 * - decoding: Set/Unset by user.
120 OSType cv_pix_fmt_type
;
125 uint8_t *priv_bitstream
;
130 int priv_bitstream_size
;
135 int priv_allocated_size
;
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.
144 * decoding: Set by user.
149 /** Create the video decoder. */
150 int ff_vda_create_decoder(struct vda_context
*vda_ctx
,
154 /** Destroy the video decoder. */
155 int ff_vda_destroy_decoder(struct vda_context
*vda_ctx
);
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().
163 typedef struct AVVDAContext
{
165 * VDA decoder object. Created and freed by the caller.
170 * The output callback that must be passed to VDADecoderCreate.
171 * Set by av_vda_alloc_context().
173 VDADecoderOutputCallback output_callback
;
177 * Allocate and initialize a VDA context.
179 * This function should be called from the get_format() callback when the caller
180 * selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
181 * object (using the output callback provided by libavcodec) that will be used
182 * for VDA-accelerated decoding.
184 * When decoding with VDA is finished, the caller must destroy the decoder
185 * object and free the VDA context using av_free().
187 * @return the newly allocated context or NULL on failure
189 AVVDAContext
*av_vda_alloc_context(void);
192 * This is a convenience function that creates and sets up the VDA context using
193 * an internal implementation.
195 * @param avctx the corresponding codec context
197 * @return >= 0 on success, a negative AVERROR code on failure
199 int av_vda_default_init(AVCodecContext
*avctx
);
202 * This function must be called to free the VDA context initialized with
203 * av_vda_default_init().
205 * @param avctx the corresponding codec context
207 void av_vda_default_free(AVCodecContext
*avctx
);
213 #endif /* AVCODEC_VDA_H */