annotate psxstr.c @ 1891:2afa964cc3ea libavformat

jpeg fourcc
author michael
date Sat, 10 Mar 2007 11:30:48 +0000
parents a782462e2497
children 2f0154760e5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1242
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1242
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1242
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
8 * 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
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1242
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1242
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 *
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1242
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 885
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
209
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
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
22 /**
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
23 * @file psxstr.c
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
24 * PSX STR file demuxer
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
25 * by Mike Melanson (melanson@pcisys.net)
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
26 * 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
27 * 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
28 * 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
29 * RIFF headers, followed by CD sectors.
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
30 */
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 #include "avformat.h"
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 PRINTSTUFF
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
35
386
c152849ee643 remove numerous definitions of BE_*/LE_* macros; convert FOURCC_TAG ->
melanson
parents: 370
diff changeset
36 #define RIFF_TAG MKTAG('R', 'I', 'F', 'F')
c152849ee643 remove numerous definitions of BE_*/LE_* macros; convert FOURCC_TAG ->
melanson
parents: 370
diff changeset
37 #define CDXA_TAG MKTAG('C', 'D', 'X', 'A')
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
38
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
39 #define RAW_CD_SECTOR_SIZE 2352
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
40 #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
41 #define VIDEO_DATA_CHUNK_SIZE 0x7E0
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
42 #define VIDEO_DATA_HEADER_SIZE 0x38
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
43 #define RIFF_HEADER_SIZE 0x2C
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
44
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
45 #define CDXA_TYPE_MASK 0x0E
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
46 #define CDXA_TYPE_DATA 0x08
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
47 #define CDXA_TYPE_AUDIO 0x04
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
48 #define CDXA_TYPE_VIDEO 0x02
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
49
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
50 #define STR_MAGIC (0x80010160)
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
51
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
52 typedef struct StrChannel {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
53
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
54 int type;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
55 #define STR_AUDIO 0
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
56 #define STR_VIDEO 1
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
57
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
58 /* video parameters */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
59 int width;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
60 int height;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
61 int video_stream_index;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
62
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
63 /* audio parameters */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
64 int sample_rate;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
65 int channels;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
66 int bits;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
67 int audio_stream_index;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
68 } StrChannel;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
69
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
70 typedef struct StrDemuxContext {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
71
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
72 /* 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
73 StrChannel channels[32];
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
74
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
75 /* 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
76 int video_channel;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
77 int audio_channel;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
78
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
79 int64_t pts;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
80
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
81 unsigned char *video_chunk;
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
82 AVPacket tmp_pkt;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
83 } StrDemuxContext;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
84
1242
996ce2a68147 Fix some "'static' is not at beginning of declaration" warnings.
diego
parents: 1169
diff changeset
85 static const char sync_header[12] = {0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00};
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
86
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
87 static int str_probe(AVProbeData *p)
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 int start;
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 /* 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
92 if (p->buf_size < 0x38)
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
93 return 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
94
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
95 if ((AV_RL32(&p->buf[0]) == RIFF_TAG) &&
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
96 (AV_RL32(&p->buf[8]) == CDXA_TAG)) {
209
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 /* RIFF header seen; skip 0x2C bytes */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
99 start = RIFF_HEADER_SIZE;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
100 } else
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
101 start = 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
102
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
103 /* look for CD sync header (00, 0xFF x 10, 00) */
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
104 if (memcmp(p->buf+start,sync_header,sizeof(sync_header)))
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
105 return 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
106
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
107 /* 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
108 * only return half certainty */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
109 return 50;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
110 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
111
683
095009fc2f35 kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 482
diff changeset
112 #if 0
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
113 static void dump(unsigned char *buf,size_t len)
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
114 {
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
115 int i;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
116 for(i=0;i<len;i++) {
370
845f9de2c883 av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 281
diff changeset
117 if ((i&15)==0) av_log(NULL, AV_LOG_DEBUG, "%04x ",i);
845f9de2c883 av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 281
diff changeset
118 av_log(NULL, AV_LOG_DEBUG, "%02x ",buf[i]);
845f9de2c883 av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 281
diff changeset
119 if ((i&15)==15) av_log(NULL, AV_LOG_DEBUG, "\n");
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
120 }
370
845f9de2c883 av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 281
diff changeset
121 av_log(NULL, AV_LOG_DEBUG, "\n");
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
122 }
683
095009fc2f35 kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 482
diff changeset
123 #endif
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
124
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
125 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
126 AVFormatParameters *ap)
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
127 {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
128 ByteIOContext *pb = &s->pb;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
129 StrDemuxContext *str = (StrDemuxContext *)s->priv_data;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
130 AVStream *st;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
131 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
132 int start;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
133 int i;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
134 int channel;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
135
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
136 /* initialize context members */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
137 str->pts = 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
138 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
139 str->video_channel = -1;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
140 str->video_chunk = NULL;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
141
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
142
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
143 /* skip over any RIFF header */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
144 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
145 return AVERROR_IO;
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
146 if (AV_RL32(&sector[0]) == RIFF_TAG)
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
147 start = RIFF_HEADER_SIZE;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
148 else
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
149 start = 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
150
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
151 url_fseek(pb, start, SEEK_SET);
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 /* 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
154 for (i = 0; i < 32; i++) {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
155 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
156 return AVERROR_IO;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
157
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
158 //printf("%02x %02x %02x %02x\n",sector[0x10],sector[0x11],sector[0x12],sector[0x13]);
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
159
209
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 */
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
171 if (AV_RL32(&sector[0x18]) != STR_MAGIC)
209
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;
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
175 str->channels[channel].width = AV_RL16(&sector[0x28]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
176 str->channels[channel].height = AV_RL16(&sector[0x2A]);
209
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;
837
4cf524326a1a set timebase correctly? this thing is always 15fps?
michael
parents: 820
diff changeset
182 av_set_pts_info(st, 64, 1, 15);
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
183
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
184 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
185
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
186 st->codec->codec_type = CODEC_TYPE_VIDEO;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
187 st->codec->codec_id = CODEC_ID_MDEC;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
188 st->codec->codec_tag = 0; /* no fourcc */
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
189 st->codec->width = str->channels[channel].width;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
190 st->codec->height = str->channels[channel].height;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
191 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
192 break;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
193
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
194 case CDXA_TYPE_AUDIO:
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
195 /* 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
196 if (str->audio_channel == -1) {
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
197 int fmt;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
198 str->audio_channel = channel;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
199 str->channels[channel].type = STR_AUDIO;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
200 str->channels[channel].channels =
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
201 (sector[0x13] & 0x01) ? 2 : 1;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
202 str->channels[channel].sample_rate =
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
203 (sector[0x13] & 0x04) ? 18900 : 37800;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
204 str->channels[channel].bits =
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
205 (sector[0x13] & 0x10) ? 8 : 4;
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
206
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
207 /* allocate a new AVStream */
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
208 st = av_new_stream(s, 0);
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
209 if (!st)
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
210 return AVERROR_NOMEM;
837
4cf524326a1a set timebase correctly? this thing is always 15fps?
michael
parents: 820
diff changeset
211 av_set_pts_info(st, 64, 128, str->channels[channel].sample_rate);
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
212
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
213 str->channels[channel].audio_stream_index = st->index;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
214
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
215 fmt = sector[0x13];
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
216 st->codec->codec_type = CODEC_TYPE_AUDIO;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
217 st->codec->codec_id = CODEC_ID_ADPCM_XA;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
218 st->codec->codec_tag = 0; /* no fourcc */
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
219 st->codec->channels = (fmt&1)?2:1;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
220 st->codec->sample_rate = (fmt&4)?18900:37800;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
221 // st->codec->bit_rate = 0; //FIXME;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
222 st->codec->block_align = 128;
209
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 break;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
225
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
226 default:
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
227 /* ignore */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
228 break;
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 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
231
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
232 if (str->video_channel != -1)
370
845f9de2c883 av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 281
diff changeset
233 av_log (s, AV_LOG_DEBUG, " video channel = %d, %d x %d %d\n", str->video_channel,
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
234 str->channels[str->video_channel].width,
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
235 str->channels[str->video_channel].height,str->channels[str->video_channel].video_stream_index);
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
236 if (str->audio_channel != -1)
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
237 av_log (s, AV_LOG_DEBUG, " audio channel = %d, %d Hz, %d channels, %d bits/sample %d\n",
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
238 str->audio_channel,
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
239 str->channels[str->audio_channel].sample_rate,
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
240 str->channels[str->audio_channel].channels,
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
241 str->channels[str->audio_channel].bits,str->channels[str->audio_channel].audio_stream_index);
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
242
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
243 /* back to the start */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
244 url_fseek(pb, start, SEEK_SET);
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
245
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
246 return 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
247 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
248
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
249 static int str_read_packet(AVFormatContext *s,
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
250 AVPacket *ret_pkt)
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
251 {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
252 ByteIOContext *pb = &s->pb;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
253 StrDemuxContext *str = (StrDemuxContext *)s->priv_data;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
254 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
255 int channel;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
256 int packet_read = 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
257 int ret = 0;
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
258 AVPacket *pkt;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
259
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
260 while (!packet_read) {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
261
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
262 if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 462
diff changeset
263 return AVERROR_IO;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
264
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
265 channel = sector[0x11];
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
266 if (channel >= 32)
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
267 return AVERROR_INVALIDDATA;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
268
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
269 switch (sector[0x12] & CDXA_TYPE_MASK) {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
270
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
271 case CDXA_TYPE_DATA:
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
272 case CDXA_TYPE_VIDEO:
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
273 /* 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
274 if (channel == str->video_channel) {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
275
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
276 int current_sector = AV_RL16(&sector[0x1C]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
277 int sector_count = AV_RL16(&sector[0x1E]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
278 int frame_size = AV_RL32(&sector[0x24]);
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
279 int bytes_to_copy;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
280 // printf("%d %d %d\n",current_sector,sector_count,frame_size);
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
281 /* if this is the first sector of the frame, allocate a pkt */
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
282 pkt = &str->tmp_pkt;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
283 if (current_sector == 0) {
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
284 if (av_new_packet(pkt, frame_size))
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 462
diff changeset
285 return AVERROR_IO;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
286
775
c5077fdab490 AVPacket.pos
michael
parents: 683
diff changeset
287 pkt->pos= url_ftell(pb) - RAW_CD_SECTOR_SIZE;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
288 pkt->stream_index =
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
289 str->channels[channel].video_stream_index;
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
290 // pkt->pts = str->pts;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
291
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
292 /* 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
293 * frame; assume 15 fps */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
294 if (str->audio_channel != -1)
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
295 str->pts += (90000 / 15);
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
296 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
297
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
298 /* load all the constituent chunks in the video packet */
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
299 bytes_to_copy = frame_size - current_sector*VIDEO_DATA_CHUNK_SIZE;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
300 if (bytes_to_copy>0) {
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
301 if (bytes_to_copy>VIDEO_DATA_CHUNK_SIZE) bytes_to_copy=VIDEO_DATA_CHUNK_SIZE;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
302 memcpy(pkt->data + current_sector*VIDEO_DATA_CHUNK_SIZE,
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
303 sector + VIDEO_DATA_HEADER_SIZE, bytes_to_copy);
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
304 }
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
305 if (current_sector == sector_count-1) {
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
306 *ret_pkt = *pkt;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
307 return 0;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
308 }
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
309
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
310 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
311 break;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
312
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
313 case CDXA_TYPE_AUDIO:
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
314 #ifdef PRINTSTUFF
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
315 printf (" dropping audio sector\n");
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
316 #endif
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
317 #if 1
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
318 /* check if this the video channel we care about */
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
319 if (channel == str->audio_channel) {
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
320 pkt = ret_pkt;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
321 if (av_new_packet(pkt, 2304))
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 462
diff changeset
322 return AVERROR_IO;
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
323 memcpy(pkt->data,sector+24,2304);
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
324
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 837
diff changeset
325 pkt->stream_index =
281
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
326 str->channels[channel].audio_stream_index;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
327 //pkt->pts = str->pts;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
328 return 0;
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
329 }
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
330 #endif
ee009afcc2a1 hook up the XA ADPCM decoder
melanson
parents: 209
diff changeset
331 break;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
332 default:
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
333 /* drop the sector and move on */
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
334 #ifdef PRINTSTUFF
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
335 printf (" dropping other sector\n");
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
336 #endif
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
337 break;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
338 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
339
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
340 if (url_feof(pb))
482
0fdc96c2f2fe sweeping change from -EIO -> AVERROR_IO
melanson
parents: 462
diff changeset
341 return AVERROR_IO;
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
342 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
343
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
344 return ret;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
345 }
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 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
348 {
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
349 StrDemuxContext *str = (StrDemuxContext *)s->priv_data;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
350
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
351 av_free(str->video_chunk);
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
352
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
353 return 0;
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
354 }
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
355
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
356 AVInputFormat str_demuxer = {
209
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
357 "psxstr",
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
358 "Sony Playstation STR format",
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
359 sizeof(StrDemuxContext),
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
360 str_probe,
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
361 str_read_header,
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
362 str_read_packet,
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
363 str_read_close,
7414bbf64011 first pass at PSX STR demuxer; does not yet interact correctly with MDEC
tmmm
parents:
diff changeset
364 };