]> git.sesse.net Git - ffmpeg/blob - libavcodec/vda.h
mpegvideo_enc: do not modify the input frame.
[ffmpeg] / libavcodec / vda.h
1 /*
2  * VDA HW acceleration
3  *
4  * copyright (c) 2011 Sebastien Zwickert
5  *
6  * This file is part of Libav.
7  *
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.
12  *
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.
17  *
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
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
38 #include <stdint.h>
39
40 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
41 // http://openradar.appspot.com/8026390
42 #undef __GNUC_STDC_INLINE__
43
44 #define Picture QuickdrawPicture
45 #include <VideoDecodeAcceleration/VDADecoder.h>
46 #undef Picture
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 vda_frame {
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 Libav 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      */
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     uint8_t             *priv_bitstream;
177
178     /**
179      * The current size of the bitstream.
180      */
181     int                 priv_bitstream_size;
182
183     /**
184      * The reference size used for fast reallocation.
185      */
186     int                 priv_allocated_size;
187 };
188
189 /** Create the video decoder. */
190 int ff_vda_create_decoder(struct vda_context *vda_ctx,
191                           uint8_t *extradata,
192                           int extradata_size);
193
194 /** Destroy the video decoder. */
195 int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
196
197 #if FF_API_VDA_ASYNC
198 /**
199  * Return the top frame of the queue.
200  *
201  * @deprecated Use synchronous decoding mode.
202  */
203 vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
204
205 /**
206  * Release the given frame.
207  *
208  * @deprecated Use synchronous decoding mode.
209  */
210 void ff_vda_release_vda_frame(vda_frame *frame);
211 #endif
212
213 /**
214  * @}
215  */
216
217 #endif /* AVCODEC_VDA_H */