comparison segafilm.c @ 1548:5bb34e659b1c libavformat

Simplify the Sega FILM/CPK demuxer to not modify the bastardized Cinepak stream. I changes the lavc Cinepak decoder some time ago to be able to handle the deviant data, but never updated this demuxer.
author melanson
date Sat, 02 Dec 2006 21:28:05 +0000
parents 0899bfe4105c
children a782462e2497
comparison
equal deleted inserted replaced
1547:e48e3a714f24 1548:5bb34e659b1c
56 film_sample_t *sample_table; 56 film_sample_t *sample_table;
57 unsigned int current_sample; 57 unsigned int current_sample;
58 58
59 unsigned int base_clock; 59 unsigned int base_clock;
60 unsigned int version; 60 unsigned int version;
61 int cvid_extra_bytes; /* the number of bytes thrown into the Cinepak
62 * chunk header to throw off decoders */
63 61
64 /* buffer used for interleaving stereo PCM data */ 62 /* buffer used for interleaving stereo PCM data */
65 unsigned char *stereo_buffer; 63 unsigned char *stereo_buffer;
66 int stereo_buffer_size; 64 int stereo_buffer_size;
67 } FilmDemuxContext; 65 } FilmDemuxContext;
124 } 122 }
125 123
126 if (BE_32(&scratch[0]) != FDSC_TAG) 124 if (BE_32(&scratch[0]) != FDSC_TAG)
127 return AVERROR_INVALIDDATA; 125 return AVERROR_INVALIDDATA;
128 126
129 film->cvid_extra_bytes = 0;
130 if (BE_32(&scratch[8]) == CVID_TAG) { 127 if (BE_32(&scratch[8]) == CVID_TAG) {
131 film->video_type = CODEC_ID_CINEPAK; 128 film->video_type = CODEC_ID_CINEPAK;
132 if (film->version)
133 film->cvid_extra_bytes = 2;
134 else
135 film->cvid_extra_bytes = 6; /* Lemmings 3DO case */
136 } else 129 } else
137 film->video_type = 0; 130 film->video_type = 0;
138 131
139 /* initialize the decoder streams */ 132 /* initialize the decoder streams */
140 if (film->video_type) { 133 if (film->video_type) {
229 url_fseek(pb, sample->sample_offset, SEEK_SET); 222 url_fseek(pb, sample->sample_offset, SEEK_SET);
230 223
231 /* do a special song and dance when loading FILM Cinepak chunks */ 224 /* do a special song and dance when loading FILM Cinepak chunks */
232 if ((sample->stream == film->video_stream_index) && 225 if ((sample->stream == film->video_stream_index) &&
233 (film->video_type == CODEC_ID_CINEPAK)) { 226 (film->video_type == CODEC_ID_CINEPAK)) {
234 if (av_new_packet(pkt, sample->sample_size - film->cvid_extra_bytes))
235 return AVERROR_NOMEM;
236 if(pkt->size < 10)
237 return -1;
238 pkt->pos= url_ftell(pb); 227 pkt->pos= url_ftell(pb);
239 ret = get_buffer(pb, pkt->data, 10); 228 if (av_new_packet(pkt, sample->sample_size))
240 /* skip the non-spec CVID bytes */ 229 return AVERROR_NOMEM;
241 url_fseek(pb, film->cvid_extra_bytes, SEEK_CUR); 230 get_buffer(pb, pkt->data, sample->sample_size);
242 ret += get_buffer(pb, pkt->data + 10,
243 sample->sample_size - 10 - film->cvid_extra_bytes);
244 if (ret != sample->sample_size - film->cvid_extra_bytes)
245 ret = AVERROR_IO;
246 } else if ((sample->stream == film->audio_stream_index) && 231 } else if ((sample->stream == film->audio_stream_index) &&
247 (film->audio_channels == 2)) { 232 (film->audio_channels == 2)) {
248 /* stereo PCM needs to be interleaved */ 233 /* stereo PCM needs to be interleaved */
249 234
250 if (av_new_packet(pkt, sample->sample_size)) 235 if (av_new_packet(pkt, sample->sample_size))