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 */
26
27 extern "C" {
29 }
30
33
35 {
38 int format;
39 int begin_ret;
40
43 return -1;
44 }
45
46 /* Read extradata */
51
52 /* Pick format based on FOURCC */
54 case MKTAG(
'U',
'L',
'Y',
'0'):
56 format = UTVF_YV12;
57 break;
58 case MKTAG(
'U',
'L',
'Y',
'2'):
60 format = UTVF_YUY2;
61 break;
62 case MKTAG(
'U',
'L',
'R',
'G'):
65 break;
66 case MKTAG(
'U',
'L',
'R',
'A'):
69 break;
70 default:
72 "Not a Ut Video FOURCC: %X\n", avctx->
codec_tag);
73 return -1;
74 }
75
76 /* Only allocate the buffer once */
79
82 return -1;
83 }
84
85 /* Allocate the output frame */
87
88 /* Ut Video only supports 8-bit */
90
91 /* Is it interlaced? */
93
94 /* Apparently Ut Video doesn't store this info... */
96
97 /*
98 * Create a Ut Video instance. Since the function wants
99 * an "interface name" string, pass it the name of the lib.
100 */
101 utv->
codec = CCodec::CreateInstance(UNFCC(avctx->
codec_tag),
"libavcodec");
102
103 /* Initialize Decoding */
106
107 /* Check to see if the decoder initlized properly */
108 if (begin_ret != 0) {
110 "Could not initialize decoder: %d\n", begin_ret);
111 return -1;
112 }
113
114 return 0;
115 }
116
119 {
123
124 /* Set flags */
125 pic->reference = 0;
127 pic->key_frame = 1;
128
129 /* Decode the frame */
131
132 /* Set the output data depending on the colorspace */
135 pic->linesize[0] = w;
136 pic->linesize[1] = pic->linesize[2] = w / 2;
137 pic->data[0] = utv->
buffer;
138 pic->data[2] = utv->
buffer + (w * h);
139 pic->data[1] = pic->data[2] + (w * h / 4);
140 break;
142 pic->linesize[0] = w * 2;
143 pic->data[0] = utv->
buffer;
144 break;
147 /* Make the linesize negative, since Ut Video uses bottom-up BGR */
150 break;
151 }
152
153 *got_frame = 1;
155
157 }
158
160 {
162
163 /* Free output */
166
167 /* Finish decoding and clean up the instance */
168 utv->
codec->DecodeEnd();
169 CCodec::DeleteInstance(utv->
codec);
170
171 return 0;
172 }
173
175 "libutvideo",
179 0, //capabilities
180 NULL,
//supported_framerates
182 NULL,
//supported_samplerates
184 NULL,
//channel_layouts
185 0, //max_lowres
189 NULL, //next
190 NULL, //init_thread_copy
191 NULL, //update_thread_context
192 NULL, //defaults
193 NULL, //init_static_data
195 NULL, //encode
196 NULL, //encode2
199 };