4 * copyright (c) 2011 Sebastien Zwickert
6 * This file is part of Libav.
8 * Libav 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 * Libav 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 Libav; 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"
33 #include "libavcodec/version.h"
37 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
38 // http://openradar.appspot.com/8026390
39 #undef __GNUC_STDC_INLINE__
41 #define Picture QuickdrawPicture
42 #include <VideoDecodeAcceleration/VDADecoder.h>
46 * @defgroup lavc_codec_hwaccel_vda VDA
47 * @ingroup lavc_codec_hwaccel
53 * This structure is used to provide the necessary configurations and data
54 * to the VDA Libav HWAccel implementation.
56 * The application must make it available as AVCodecContext.hwaccel_context.
63 * - decoding: Set/Unset by libavcodec.
68 * The Core Video pixel buffer that contains the current image data.
71 * decoding: Set by libavcodec. Unset by user.
73 CVPixelBufferRef cv_buffer;
76 * Use the hardware decoder in synchronous mode.
79 * decoding: Set by user.
81 int use_sync_decoding;
87 * - decoding: Set/Unset by user.
95 * - decoding: Set/Unset by user.
103 * - decoding: Set/Unset by user.
108 * The pixel format for output image buffers.
111 * - decoding: Set/Unset by user.
113 OSType cv_pix_fmt_type;
118 uint8_t *priv_bitstream;
123 int priv_bitstream_size;
128 int priv_allocated_size;
131 /** Create the video decoder. */
132 int ff_vda_create_decoder(struct vda_context *vda_ctx,
136 /** Destroy the video decoder. */
137 int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
140 * This struct holds all the information that needs to be passed
141 * between the caller and libavcodec for initializing VDA decoding.
142 * Its size is not a part of the public ABI, it must be allocated with
143 * av_vda_alloc_context() and freed with av_free().
145 typedef struct AVVDAContext {
147 * VDA decoder object. Created and freed by the caller.
152 * The output callback that must be passed to VDADecoderCreate.
153 * Set by av_vda_alloc_context().
155 VDADecoderOutputCallback output_callback;
158 * CVPixelBuffer Format Type that VDA will use for decoded frames; set by
161 OSType cv_pix_fmt_type;
165 * Allocate and initialize a VDA context.
167 * This function should be called from the get_format() callback when the caller
168 * selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
169 * object (using the output callback provided by libavcodec) that will be used
170 * for VDA-accelerated decoding.
172 * When decoding with VDA is finished, the caller must destroy the decoder
173 * object and free the VDA context using av_free().
175 * @return the newly allocated context or NULL on failure
177 AVVDAContext *av_vda_alloc_context(void);
180 * This is a convenience function that creates and sets up the VDA context using
181 * an internal implementation.
183 * @param avctx the corresponding codec context
185 * @return >= 0 on success, a negative AVERROR code on failure
187 int av_vda_default_init(AVCodecContext *avctx);
190 * This is a convenience function that creates and sets up the VDA context using
191 * an internal implementation.
193 * @param avctx the corresponding codec context
194 * @param vdactx the VDA context to use
196 * @return >= 0 on success, a negative AVERROR code on failure
198 int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx);
201 * This function must be called to free the VDA context initialized with
202 * av_vda_default_init().
204 * @param avctx the corresponding codec context
206 void av_vda_default_free(AVCodecContext *avctx);
212 #endif /* AVCODEC_VDA_H */