1 /*
2 * Copyright (c) 2011 Derek Buitenhuis
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation;
9 * version 2 of the License.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * Known FOURCCs:
24 * 'ULY0' (YCbCr 4:2:0), 'ULY2' (YCbCr 4:2:2), 'ULRG' (RGB), 'ULRA' (RGBA),
25 * 'ULH0' (YCbCr 4:2:0 BT.709), 'ULH2' (YCbCr 4:2:2 BT.709)
26 */
27
28 extern "C" {
30 }
31
34
36 {
39 int format;
40 int begin_ret;
41
44 return -1;
45 }
46
47 /* Read extradata */
52
53 /* Pick format based on FOURCC */
55 #ifdef UTV_BT709
56 case MKTAG(
'U',
'L',
'H',
'0'):
59 format = UTVF_YV12;
60 break;
61 case MKTAG(
'U',
'L',
'H',
'2'):
64 format = UTVF_YUY2;
65 break;
66 #endif
67 case MKTAG(
'U',
'L',
'Y',
'0'):
69 format = UTVF_YV12;
70 break;
71 case MKTAG(
'U',
'L',
'Y',
'2'):
73 format = UTVF_YUY2;
74 break;
75 case MKTAG(
'U',
'L',
'R',
'G'):
78 break;
79 case MKTAG(
'U',
'L',
'R',
'A'):
82 break;
83 default:
85 "Not a Ut Video FOURCC: %X\n", avctx->
codec_tag);
86 return -1;
87 }
88
89 /* Only allocate the buffer once */
92
95 return -1;
96 }
97
98 /* Allocate the output frame */
100
101 /* Ut Video only supports 8-bit */
103
104 /* Is it interlaced? */
106
107 /* Apparently Ut Video doesn't store this info... */
109
110 /*
111 * Create a Ut Video instance. Since the function wants
112 * an "interface name" string, pass it the name of the lib.
113 */
114 utv->
codec = CCodec::CreateInstance(UNFCC(avctx->
codec_tag),
"libavcodec");
115
116 /* Initialize Decoding */
119
120 /* Check to see if the decoder initlized properly */
121 if (begin_ret != 0) {
123 "Could not initialize decoder: %d\n", begin_ret);
124 return -1;
125 }
126
127 return 0;
128 }
129
132 {
136
137 /* Set flags */
138 pic->reference = 0;
140 pic->key_frame = 1;
141
142 /* Decode the frame */
144
145 /* Set the output data depending on the colorspace */
148 pic->linesize[0] = w;
149 pic->linesize[1] = pic->linesize[2] = w / 2;
150 pic->data[0] = utv->
buffer;
151 pic->data[2] = utv->
buffer + (w * h);
152 pic->data[1] = pic->data[2] + (w * h / 4);
153 break;
155 pic->linesize[0] = w * 2;
156 pic->data[0] = utv->
buffer;
157 break;
160 /* Make the linesize negative, since Ut Video uses bottom-up BGR */
163 break;
164 }
165
166 *got_frame = 1;
168
170 }
171
173 {
175
176 /* Free output */
179
180 /* Finish decoding and clean up the instance */
181 utv->
codec->DecodeEnd();
182 CCodec::DeleteInstance(utv->
codec);
183
184 return 0;
185 }
186
188 "libutvideo",
192 0, //capabilities
193 NULL, //supported_framerates
194 NULL, //pix_fmts
195 NULL, //supported_samplerates
196 NULL, //sample_fmts
197 NULL, //channel_layouts
198 0, //max_lowres
199 NULL, //priv_class
200 NULL, //profiles
202 NULL, //next
203 NULL, //init_thread_copy
204 NULL, //update_thread_context
205 NULL, //defaults
206 NULL, //init_static_data
208 NULL, //encode
209 NULL, //encode2
212 };