]> git.sesse.net Git - ffmpeg/blob - libavcodec/vda.h
Merge remote-tracking branch 'qatar/master'
[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 <pthread.h>
33 #include <stdint.h>
34
35 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
36 // http://openradar.appspot.com/8026390
37 #undef __GNUC_STDC_INLINE__
38
39 #define Picture QuickdrawPicture
40 #include <VideoDecodeAcceleration/VDADecoder.h>
41 #undef Picture
42
43 /**
44  * @defgroup lavc_codec_hwaccel_vda VDA
45  * @ingroup lavc_codec_hwaccel
46  *
47  * @{
48  */
49
50 /**
51  *  This structure is used to store a decoded frame information and data.
52  */
53 typedef struct {
54     /**
55     * The PTS of the frame.
56     *
57     * - encoding: unused
58     * - decoding: Set/Unset by libavcodec.
59     */
60     int64_t             pts;
61
62     /**
63     * The CoreVideo buffer that contains the decoded data.
64     *
65     * - encoding: unused
66     * - decoding: Set/Unset by libavcodec.
67     */
68     CVPixelBufferRef    cv_buffer;
69
70     /**
71     * A pointer to the next frame.
72     *
73     * - encoding: unused
74     * - decoding: Set/Unset by libavcodec.
75     */
76     struct vda_frame    *next_frame;
77 } vda_frame;
78
79 /**
80  * This structure is used to provide the necessary configurations and data
81  * to the VDA FFmpeg HWAccel implementation.
82  *
83  * The application must make it available as AVCodecContext.hwaccel_context.
84  */
85 struct vda_context {
86     /**
87     * VDA decoder object.
88     *
89     * - encoding: unused
90     * - decoding: Set/Unset by libavcodec.
91     */
92     VDADecoder          decoder;
93
94     /**
95     * VDA frames queue ordered by presentation timestamp.
96     *
97     * - encoding: unused
98     * - decoding: Set/Unset by libavcodec.
99     */
100     vda_frame           *queue;
101
102     /**
103     * Mutex for locking queue operations.
104     *
105     * - encoding: unused
106     * - decoding: Set/Unset by libavcodec.
107     */
108     pthread_mutex_t     queue_mutex;
109
110     /**
111     * The frame width.
112     *
113     * - encoding: unused
114     * - decoding: Set/Unset by user.
115     */
116     int                 width;
117
118     /**
119     * The frame height.
120     *
121     * - encoding: unused
122     * - decoding: Set/Unset by user.
123     */
124     int                 height;
125
126     /**
127     * The frame format.
128     *
129     * - encoding: unused
130     * - decoding: Set/Unset by user.
131     */
132     int                 format;
133
134     /**
135     * The pixel format for output image buffers.
136     *
137     * - encoding: unused
138     * - decoding: Set/Unset by user.
139     */
140     OSType              cv_pix_fmt_type;
141
142     /**
143     * The current bitstream buffer.
144     *
145     * - encoding: unused
146     * - decoding: Set/Unset by libavcodec.
147     */
148     uint8_t             *bitstream;
149
150     /**
151     * The current size of the bitstream.
152     *
153     * - encoding: unused
154     * - decoding: Set/Unset by libavcodec.
155     */
156     int                 bitstream_size;
157
158     /**
159     * The reference size used for fast reallocation.
160     *
161     * - encoding: unused
162     * - decoding: Set/Unset by libavcodec.
163     */
164     int                 ref_size;
165 };
166
167 /** Create the video decoder. */
168 int ff_vda_create_decoder(struct vda_context *vda_ctx,
169                           uint8_t *extradata,
170                           int extradata_size);
171
172 /** Destroy the video decoder. */
173 int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
174
175 /** Return the top frame of the queue. */
176 vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
177
178 /** Release the given frame. */
179 void ff_vda_release_vda_frame(vda_frame *frame);
180
181 /**
182  * @}
183  */
184
185 #endif /* AVCODEC_VDA_H */