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