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