hwaccel: OS X Video Decoder Acceleration (VDA) support.
[libav.git] / 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 #include <pthread.h>
27 #include <stdint.h>
28
29 // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
30 // http://openradar.appspot.com/8026390
31 #undef __GNUC_STDC_INLINE__
32
33 #define Picture QuickdrawPicture
34 #include <VideoDecodeAcceleration/VDADecoder.h>
35 #undef Picture
36
37 /**
38 * This structure is used to store a decoded frame information and data.
39 */
40 typedef struct vda_frame {
41 /**
42 * The PTS of the frame.
43 *
44 * - encoding: unused
45 * - decoding: Set/Unset by libavcodec.
46 */
47 int64_t pts;
48
49 /**
50 * The CoreVideo buffer that contains the decoded data.
51 *
52 * - encoding: unused
53 * - decoding: Set/Unset by libavcodec.
54 */
55 CVPixelBufferRef cv_buffer;
56
57 /**
58 * A pointer to the next frame.
59 *
60 * - encoding: unused
61 * - decoding: Set/Unset by libavcodec.
62 */
63 struct vda_frame *next_frame;
64 } vda_frame;
65
66 /**
67 * This structure is used to provide the necessary configurations and data
68 * to the VDA Libav 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 pthread_mutex_t 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 /** Create the video decoder. */
131 int ff_vda_create_decoder(struct vda_context *vda_ctx,
132 uint8_t *extradata,
133 int extradata_size);
134
135 /** Destroy the video decoder. */
136 int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
137
138 /** Return the top frame of the queue. */
139 vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
140
141 /** Release the given frame. */
142 void ff_vda_release_vda_frame(vda_frame *frame);
143
144 #endif /* AVCODEC_VDA_H */