FFmpeg
 All Data Structures 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 <stdint.h>
33 
34 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
35 // http://openradar.appspot.com/8026390
36 #undef __GNUC_STDC_INLINE__
37 
38 #define Picture QuickdrawPicture
39 #include <VideoDecodeAcceleration/VDADecoder.h>
40 #undef Picture
41 
42 #include "libavcodec/version.h"
43 
44 #if FF_API_VDA_ASYNC
45 #include <pthread.h>
46 #endif
47 
48 /**
49  * @defgroup lavc_codec_hwaccel_vda VDA
50  * @ingroup lavc_codec_hwaccel
51  *
52  * @{
53  */
54 
55 #if FF_API_VDA_ASYNC
56 /**
57  * This structure is used to store decoded frame information and data.
58  *
59  * @deprecated Use synchronous decoding mode.
60  */
61 typedef struct {
62  /**
63  * The PTS of the frame.
64  *
65  * - encoding: unused
66  * - decoding: Set/Unset by libavcodec.
67  */
68  int64_t pts;
69 
70  /**
71  * The CoreVideo buffer that contains the decoded data.
72  *
73  * - encoding: unused
74  * - decoding: Set/Unset by libavcodec.
75  */
76  CVPixelBufferRef cv_buffer;
77 
78  /**
79  * A pointer to the next frame.
80  *
81  * - encoding: unused
82  * - decoding: Set/Unset by libavcodec.
83  */
84  struct vda_frame *next_frame;
85 } vda_frame;
86 #endif
87 
88 /**
89  * This structure is used to provide the necessary configurations and data
90  * to the VDA FFmpeg HWAccel implementation.
91  *
92  * The application must make it available as AVCodecContext.hwaccel_context.
93  */
94 struct vda_context {
95  /**
96  * VDA decoder object.
97  *
98  * - encoding: unused
99  * - decoding: Set/Unset by libavcodec.
100  */
101  VDADecoder decoder;
102 
103  /**
104  * The Core Video pixel buffer that contains the current image data.
105  *
106  * encoding: unused
107  * decoding: Set by libavcodec. Unset by user.
108  */
109  CVPixelBufferRef cv_buffer;
110 
111  /**
112  * Use the hardware decoder in synchronous mode.
113  *
114  * encoding: unused
115  * decoding: Set by user.
116  */
118 
119 #if FF_API_VDA_ASYNC
120  /**
121  * VDA frames queue ordered by presentation timestamp.
122  *
123  * @deprecated Use synchronous decoding mode.
124  *
125  * - encoding: unused
126  * - decoding: Set/Unset by libavcodec.
127  */
128  vda_frame *queue;
129 
130  /**
131  * Mutex for locking queue operations.
132  *
133  * @deprecated Use synchronous decoding mode.
134  *
135  * - encoding: unused
136  * - decoding: Set/Unset by libavcodec.
137  */
138  pthread_mutex_t queue_mutex;
139 #endif
140 
141  /**
142  * The frame width.
143  *
144  * - encoding: unused
145  * - decoding: Set/Unset by user.
146  */
147  int width;
148 
149  /**
150  * The frame height.
151  *
152  * - encoding: unused
153  * - decoding: Set/Unset by user.
154  */
155  int height;
156 
157  /**
158  * The frame format.
159  *
160  * - encoding: unused
161  * - decoding: Set/Unset by user.
162  */
163  int format;
164 
165  /**
166  * The pixel format for output image buffers.
167  *
168  * - encoding: unused
169  * - decoding: Set/Unset by user.
170  */
172 
173  /**
174  * The current bitstream buffer.
175  *
176  * - encoding: unused
177  * - decoding: Set/Unset by libavcodec.
178  */
180 
181  /**
182  * The current size of the bitstream.
183  *
184  * - encoding: unused
185  * - decoding: Set/Unset by libavcodec.
186  */
188 
189  /**
190  * The reference size used for fast reallocation.
191  *
192  * - encoding: unused
193  * - decoding: Set/Unset by libavcodec.
194  */
196 };
197 
198 /** Create the video decoder. */
199 int ff_vda_create_decoder(struct vda_context *vda_ctx,
200  uint8_t *extradata,
201  int extradata_size);
202 
203 /** Destroy the video decoder. */
204 int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
205 
206 #if FF_API_VDA_ASYNC
207 /**
208  * Return the top frame of the queue.
209  *
210  * @deprecated Use synchronous decoding mode.
211  */
212 vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
213 
214 /**
215  * Release the given frame.
216  *
217  * @deprecated Use synchronous decoding mode.
218  */
219 void ff_vda_release_vda_frame(vda_frame *frame);
220 #endif
221 
222 /**
223  * @}
224  */
225 
226 #endif /* AVCODEC_VDA_H */