Mercurial > libavformat.hg
annotate psxstr.c @ 245:d8b6af80b1dd libavformat
deploy palette control API
author | tmmm |
---|---|
date | Fri, 12 Sep 2003 03:48:14 +0000 |
parents | 7414bbf64011 |
children | ee009afcc2a1 |
rev | line source |
---|---|
209
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
1 /* |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
2 * Sony Playstation (PSX) STR File Demuxer |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
3 * Copyright (c) 2003 The ffmpeg Project |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
4 * |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
9 * |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
14 * |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
18 */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
19 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
20 /** |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
21 * @file psxstr.c |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
22 * PSX STR file demuxer |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
23 * by Mike Melanson (melanson@pcisys.net) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
24 * This module handles streams that have been ripped from Sony Playstation |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
25 * CD games. This demuxer can handle either raw STR files (which are just |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
26 * concatenations of raw compact disc sectors) or STR files with 0x2C-byte |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
27 * RIFF headers, followed by CD sectors. |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
28 */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
29 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
30 #include "avformat.h" |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
31 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
32 //#define PRINTSTUFF |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
33 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
34 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
35 #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
36 (((uint8_t*)(x))[2] << 16) | \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
37 (((uint8_t*)(x))[1] << 8) | \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
38 ((uint8_t*)(x))[0]) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
39 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
40 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
41 ( (long)(unsigned char)(ch0) | \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
42 ( (long)(unsigned char)(ch1) << 8 ) | \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
43 ( (long)(unsigned char)(ch2) << 16 ) | \ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
44 ( (long)(unsigned char)(ch3) << 24 ) ) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
45 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
46 #define RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F') |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
47 #define CDXA_TAG FOURCC_TAG('C', 'D', 'X', 'A') |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
48 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
49 #define RAW_CD_SECTOR_SIZE 2352 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
50 #define RAW_CD_SECTOR_DATA_SIZE 2304 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
51 #define VIDEO_DATA_CHUNK_SIZE 0x7E0 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
52 #define VIDEO_DATA_HEADER_SIZE 0x38 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
53 #define RIFF_HEADER_SIZE 0x2C |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
54 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
55 #define CDXA_TYPE_MASK 0x0E |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
56 #define CDXA_TYPE_DATA 0x08 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
57 #define CDXA_TYPE_AUDIO 0x04 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
58 #define CDXA_TYPE_VIDEO 0x02 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
59 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
60 #define STR_MAGIC (0x80010160) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
61 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
62 typedef struct StrChannel { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
63 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
64 int type; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
65 #define STR_AUDIO 0 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
66 #define STR_VIDEO 1 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
67 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
68 /* video parameters */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
69 int width; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
70 int height; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
71 int video_stream_index; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
72 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
73 /* audio parameters */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
74 int sample_rate; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
75 int channels; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
76 int bits; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
77 int audio_stream_index; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
78 } StrChannel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
79 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
80 typedef struct StrDemuxContext { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
81 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
82 /* a STR file can contain up to 32 channels of data */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
83 StrChannel channels[32]; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
84 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
85 /* only decode the first audio and video channels encountered */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
86 int video_channel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
87 int audio_channel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
88 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
89 int64_t pts; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
90 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
91 unsigned char *video_chunk; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
92 } StrDemuxContext; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
93 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
94 static int str_probe(AVProbeData *p) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
95 { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
96 int start; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
97 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
98 /* need at least 0x38 bytes to validate */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
99 if (p->buf_size < 0x38) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
100 return 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
101 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
102 if ((LE_32(&p->buf[0]) == RIFF_TAG) && |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
103 (LE_32(&p->buf[8]) == CDXA_TAG)) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
104 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
105 /* RIFF header seen; skip 0x2C bytes */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
106 start = RIFF_HEADER_SIZE; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
107 } else |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
108 start = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
109 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
110 /* look for CD sync header (00, 0xFF x 10, 00) */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
111 if ((p->buf[start + 0] != 0x00) || (p->buf[start + 1] != 0xFF) || |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
112 (p->buf[start + 2] != 0xFF) || (p->buf[start + 3] != 0xFF) || |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
113 (p->buf[start + 4] != 0xFF) || (p->buf[start + 5] != 0xFF) || |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
114 (p->buf[start + 6] != 0xFF) || (p->buf[start + 7] != 0xFF) || |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
115 (p->buf[start + 8] != 0xFF) || (p->buf[start + 9] != 0xFF) || |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
116 (p->buf[start + 10] != 0xFF) || (p->buf[start + 11] != 0x00)) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
117 return 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
118 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
119 /* MPEG files (like those ripped from VCDs) can also look like this; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
120 * only return half certainty */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
121 return 50; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
122 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
123 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
124 static int str_read_header(AVFormatContext *s, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
125 AVFormatParameters *ap) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
126 { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
127 ByteIOContext *pb = &s->pb; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
128 StrDemuxContext *str = (StrDemuxContext *)s->priv_data; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
129 AVStream *st; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
130 unsigned char sector[RAW_CD_SECTOR_SIZE]; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
131 int start; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
132 int i; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
133 int channel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
134 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
135 /* initialize context members */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
136 str->pts = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
137 str->audio_channel = -1; /* assume to audio or video */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
138 str->video_channel = -1; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
139 str->video_chunk = NULL; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
140 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
141 /* set the pts reference (1 pts = 1/90000) */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
142 s->pts_num = 1; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
143 s->pts_den = 90000; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
144 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
145 /* skip over any RIFF header */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
146 if (get_buffer(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
147 return AVERROR_IO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
148 if (LE_32(§or[0]) == RIFF_TAG) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
149 start = RIFF_HEADER_SIZE; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
150 else |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
151 start = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
152 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
153 url_fseek(pb, start, SEEK_SET); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
154 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
155 /* check through the first 32 sectors for individual channels */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
156 for (i = 0; i < 32; i++) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
157 if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
158 return AVERROR_IO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
159 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
160 channel = sector[0x11]; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
161 if (channel >= 32) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
162 return AVERROR_INVALIDDATA; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
163 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
164 switch (sector[0x12] & CDXA_TYPE_MASK) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
165 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
166 case CDXA_TYPE_DATA: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
167 case CDXA_TYPE_VIDEO: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
168 /* check if this channel gets to be the dominant video channel */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
169 if (str->video_channel == -1) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
170 /* qualify the magic number */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
171 if (LE_32(§or[0x18]) != STR_MAGIC) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
172 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
173 str->video_channel = channel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
174 str->channels[channel].type = STR_VIDEO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
175 str->channels[channel].width = LE_16(§or[0x28]); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
176 str->channels[channel].height = LE_16(§or[0x2A]); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
177 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
178 /* allocate a new AVStream */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
179 st = av_new_stream(s, 0); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
180 if (!st) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
181 return AVERROR_NOMEM; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
182 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
183 str->channels[channel].video_stream_index = st->index; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
184 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
185 st->codec.codec_type = CODEC_TYPE_VIDEO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
186 st->codec.codec_id = CODEC_ID_MDEC; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
187 st->codec.codec_tag = 0; /* no fourcc */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
188 st->codec.width = str->channels[channel].width; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
189 st->codec.height = str->channels[channel].height; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
190 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
191 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
192 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
193 case CDXA_TYPE_AUDIO: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
194 /* check if this channel gets to be the dominant audio channel */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
195 if (str->audio_channel == -1) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
196 str->audio_channel = channel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
197 str->channels[channel].type = STR_AUDIO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
198 str->channels[channel].channels = |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
199 (sector[0x13] & 0x01) ? 2 : 1; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
200 str->channels[channel].sample_rate = |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
201 (sector[0x13] & 0x04) ? 18900 : 37800; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
202 str->channels[channel].bits = |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
203 (sector[0x13] & 0x10) ? 8 : 4; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
204 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
205 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
206 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
207 default: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
208 /* ignore */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
209 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
210 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
211 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
212 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
213 if (str->video_channel != -1) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
214 printf (" video channel = %d, %d x %d\n", str->video_channel, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
215 str->channels[str->video_channel].width, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
216 str->channels[str->video_channel].height); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
217 if (str->audio_channel != -1) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
218 printf (" audio channel = %d, %d Hz, %d channels, %d bits/sample\n", |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
219 str->video_channel, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
220 str->channels[str->video_channel].sample_rate, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
221 str->channels[str->video_channel].channels, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
222 str->channels[str->video_channel].bits); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
223 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
224 /* back to the start */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
225 url_fseek(pb, start, SEEK_SET); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
226 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
227 return 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
228 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
229 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
230 static int str_read_packet(AVFormatContext *s, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
231 AVPacket *pkt) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
232 { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
233 ByteIOContext *pb = &s->pb; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
234 StrDemuxContext *str = (StrDemuxContext *)s->priv_data; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
235 unsigned char sector[RAW_CD_SECTOR_SIZE]; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
236 int channel; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
237 int packet_read = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
238 int video_sector_count = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
239 int current_video_sector = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
240 int video_frame_size = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
241 int video_frame_index = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
242 int bytes_to_copy; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
243 int ret = 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
244 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
245 while (!packet_read) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
246 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
247 if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
248 return -EIO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
249 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
250 channel = sector[0x11]; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
251 if (channel >= 32) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
252 return AVERROR_INVALIDDATA; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
253 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
254 switch (sector[0x12] & CDXA_TYPE_MASK) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
255 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
256 case CDXA_TYPE_DATA: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
257 case CDXA_TYPE_VIDEO: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
258 /* check if this the video channel we care about */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
259 if (channel == str->video_channel) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
260 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
261 /* if this is the first sector of the frame, allocate a pkt */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
262 if (current_video_sector == 0) { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
263 video_frame_size = LE_32(§or[0x24]); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
264 video_sector_count = LE_16(§or[0x1E]); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
265 if (av_new_packet(pkt, video_frame_size)) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
266 return -EIO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
267 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
268 pkt->stream_index = |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
269 str->channels[channel].video_stream_index; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
270 pkt->pts = str->pts; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
271 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
272 /* if there is no audio, adjust the pts after every video |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
273 * frame; assume 15 fps */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
274 if (str->audio_channel != -1) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
275 str->pts += (90000 / 15); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
276 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
277 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
278 /* load all the constituent chunks in the video packet */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
279 if (video_frame_size - video_frame_index < VIDEO_DATA_CHUNK_SIZE) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
280 bytes_to_copy = video_frame_size - video_frame_index; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
281 else |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
282 bytes_to_copy = VIDEO_DATA_CHUNK_SIZE; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
283 if (video_frame_index < video_frame_size) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
284 memcpy(&pkt->data[video_frame_index], |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
285 §or[VIDEO_DATA_HEADER_SIZE], bytes_to_copy); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
286 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
287 #ifdef PRINTSTUFF |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
288 printf (" chunk %d/%d (bytes %d/%d), first 6 bytes = %02X %02X %02X %02X %02X %02X\n", |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
289 current_video_sector, video_sector_count, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
290 video_frame_index, video_frame_size, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
291 pkt->data[current_video_sector * VIDEO_DATA_CHUNK_SIZE + 0], |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
292 pkt->data[current_video_sector * VIDEO_DATA_CHUNK_SIZE + 1], |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
293 pkt->data[current_video_sector * VIDEO_DATA_CHUNK_SIZE + 2], |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
294 pkt->data[current_video_sector * VIDEO_DATA_CHUNK_SIZE + 3], |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
295 pkt->data[current_video_sector * VIDEO_DATA_CHUNK_SIZE + 4], |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
296 pkt->data[current_video_sector * VIDEO_DATA_CHUNK_SIZE + 5]); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
297 #endif |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
298 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
299 video_frame_index += bytes_to_copy; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
300 /* must keep reading sectors until all current video sectors |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
301 * are consumed */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
302 current_video_sector++; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
303 if (current_video_sector >= video_sector_count) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
304 packet_read = 1; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
305 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
306 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
307 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
308 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
309 case CDXA_TYPE_AUDIO: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
310 #ifdef PRINTSTUFF |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
311 printf (" dropping audio sector\n"); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
312 #endif |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
313 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
314 default: |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
315 /* drop the sector and move on */ |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
316 #ifdef PRINTSTUFF |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
317 printf (" dropping other sector\n"); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
318 #endif |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
319 break; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
320 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
321 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
322 if (url_feof(pb)) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
323 return -EIO; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
324 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
325 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
326 return ret; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
327 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
328 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
329 static int str_read_close(AVFormatContext *s) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
330 { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
331 StrDemuxContext *str = (StrDemuxContext *)s->priv_data; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
332 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
333 av_free(str->video_chunk); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
334 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
335 return 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
336 } |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
337 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
338 static AVInputFormat str_iformat = { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
339 "psxstr", |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
340 "Sony Playstation STR format", |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
341 sizeof(StrDemuxContext), |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
342 str_probe, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
343 str_read_header, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
344 str_read_packet, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
345 str_read_close, |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
346 }; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
347 |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
348 int str_init(void) |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
349 { |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
350 av_register_input_format(&str_iformat); |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
351 return 0; |
7414bbf64011
first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff
changeset
|
352 } |