1 /*
2 * DXA demuxer
3 * Copyright (c) 2007 Konstantin Shishkov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <inttypes.h>
23
28
29 #define DXA_EXTRA_SIZE 9
30
39
41 {
42 int w, h;
44 return 0;
47 /* check file header */
48 if (p->
buf[0] ==
'D' && p->
buf[1] ==
'E' &&
49 p->
buf[2] ==
'X' && p->
buf[3] ==
'A' &&
50 w && w <= 2048 && h && h <= 2048)
52 else
53 return 0;
54 }
55
57 {
63 int w, h;
64 int num, den;
67
69 if (tag !=
MKTAG(
'D',
'E',
'X',
'A'))
76 }
77
79 if(fps > 0){
80 den = 1000;
81 num = fps;
82 }else if (fps < 0){
83 den = 100000;
84 num = -fps;
85 }else{
86 den = 10;
87 num = 1;
88 }
92
94 if (!st)
96
97 // Parse WAV data header
105
107 if (!ast)
110 if (ret < 0)
114 // find 'data' chunk
118 if(tag ==
MKTAG(
'd',
'a',
't',
'a'))
break;
120 }
127 }
128
129 /* now we are ready: build format streams */
134 av_reduce(&den, &num, den, num, (1UL<<31)-1);
136 /* flags & 0x80 means that image is interlaced,
137 * flags & 0x40 means that image has double height
138 * either way set true height
139 */
140 if(flags & 0xC0){
142 }
148
149 return 0;
150 }
151
153 {
158 int pal_size = 0;
159
166 if(ret != size)
170 return 0;
171 }
177 }
179 case MKTAG(
'N',
'U',
'L',
'L'):
183 if(pal_size) memcpy(pkt->
data, pal, pal_size);
184 memcpy(pkt->
data + pal_size, buf, 4);
188 return 0;
189 case MKTAG(
'C',
'M',
'A',
'P'):
190 pal_size = 768+4;
191 memcpy(pal, buf, 4);
193 break;
194 case MKTAG(
'F',
'R',
'A',
'M'):
198 }
200 if(size > 0xFFFFFF){
202 size);
204 }
209 if(ret != size){
212 }
213 if(pal_size) memcpy(pkt->
data, pal, pal_size);
218 return 0;
219 default:
222 }
223 }
225 }
226
234 };