]> git.sesse.net Git - ffmpeg/blob - libavcodec/vda.h
vda: merge implementation into one file.
[ffmpeg] / libavcodec / vda.h
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/version.h"
33
34 #if FF_API_VDA_ASYNC
35 #include <pthread.h>
36 #endif
37 #include <stdint.h>
38
39 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
40 // http://openradar.appspot.com/8026390
41 #undef __GNUC_STDC_INLINE__
42
43 #define Picture QuickdrawPicture
44 #include <VideoDecodeAcceleration/VDADecoder.h>
45 #undef Picture
46
47 /**
48  * @defgroup lavc_codec_hwaccel_vda VDA
49  * @ingroup lavc_codec_hwaccel
50  *
51  * @{
52  */
53
54 #if FF_API_VDA_ASYNC
55 /**
56  * This structure is used to store a decoded frame information and data.
57  *
58  * @deprecated Use synchronous decoding mode.
59  *
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     * An integer value that indicates whether use the hardware decoder in synchronous mode.
113     *
114     * encoding: unused
115     * decoding: Set by user.
116     */
117     int                 use_sync_decoding;
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     */
171     OSType              cv_pix_fmt_type;
172
173     /**
174     * The current bitstream buffer.
175     *
176     * - encoding: unused
177     * - decoding: Set/Unset by libavcodec.
178     */
179     uint8_t             *bitstream;
180
181     /**
182     * The current size of the bitstream.
183     *
184     * - encoding: unused
185     * - decoding: Set/Unset by libavcodec.
186     */
187     int                 bitstream_size;
188
189     /**
190     * The reference size used for fast reallocation.
191     *
192     * - encoding: unused
193     * - decoding: Set/Unset by libavcodec.
194     */
195     int                 ref_size;
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 */