FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vda.h
Go to the documentation of this file.
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 {
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  */
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  */
121 
122  /**
123  * unused
124  */
126 
127  /**
128  * unused
129  */
131 
132  /**
133  * unused
134  */
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  */
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  */
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  */
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  */
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  */
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  */
225 
226 /**
227  * @}
228  */
229 
230 #endif /* AVCODEC_VDA_H */
int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx)
This is a convenience function that creates and sets up the VDA context using an internal implementat...
void av_vda_default_free(AVCodecContext *avctx)
This function must be called to free the VDA context initialized with av_vda_default_init().
Definition: vda.c:76
int format
The frame format.
Definition: vda.h:112
OSType cv_pix_fmt_type
The pixel format for output image buffers.
Definition: vda.h:120
This struct holds all the information that needs to be passed between the caller and libavcodec for i...
Definition: vda.h:163
int use_ref_buffer
Use av_buffer to manage buffer.
Definition: vda.h:146
uint8_t
OSType cv_pix_fmt_type
CVPixelBuffer Format Type that VDA will use for decoded frames; set by the caller.
Definition: vda.h:179
int width
The frame width.
Definition: vda.h:96
int av_vda_default_init(AVCodecContext *avctx)
This is a convenience function that creates and sets up the VDA context using an internal implementat...
Definition: vda.c:71
CVPixelBufferRef cv_buffer
The Core Video pixel buffer that contains the current image data.
Definition: vda.h:80
Libavcodec version macros.
VDADecoder decoder
VDA decoder object.
Definition: vda.h:72
This structure is used to provide the necessary configurations and data to the VDA FFmpeg HWAccel imp...
Definition: vda.h:65
Libavcodec external API header.
VDADecoder decoder
VDA decoder object.
Definition: vda.h:167
VDADecoderOutputCallback output_callback
The output callback that must be passed to VDADecoderCreate.
Definition: vda.h:173
int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
Destroy the video decoder.
Definition: vda_h264.c:264
main external API structure.
Definition: avcodec.h:1241
int use_sync_decoding
Use the hardware decoder in synchronous mode.
Definition: vda.h:88
uint8_t * priv_bitstream
unused
Definition: vda.h:125
int ff_vda_create_decoder(struct vda_context *vda_ctx, uint8_t *extradata, int extradata_size)
Create the video decoder.
Definition: vda_h264.c:177
int priv_allocated_size
unused
Definition: vda.h:135
AVVDAContext * av_vda_alloc_context(void)
Allocate and initialize a VDA context.
Definition: vda.c:66
int height
The frame height.
Definition: vda.h:104
int priv_bitstream_size
unused
Definition: vda.h:130