comparison westwood.c @ 1550:4cb185273d4b libavformat

Do not touch pkt->pts
author kostya
date Sun, 03 Dec 2006 05:47:55 +0000
parents 3b4019c023a3
children a782462e2497
comparison
equal deleted inserted replaced
1549:3b4019c023a3 1550:4cb185273d4b
222 222
223 /* initialize the video decoder stream */ 223 /* initialize the video decoder stream */
224 st = av_new_stream(s, 0); 224 st = av_new_stream(s, 0);
225 if (!st) 225 if (!st)
226 return AVERROR_NOMEM; 226 return AVERROR_NOMEM;
227 av_set_pts_info(st, 33, 1, 90000); 227 av_set_pts_info(st, 33, 1, VQA_FRAMERATE);
228 wsvqa->video_stream_index = st->index; 228 wsvqa->video_stream_index = st->index;
229 st->codec->codec_type = CODEC_TYPE_VIDEO; 229 st->codec->codec_type = CODEC_TYPE_VIDEO;
230 st->codec->codec_id = CODEC_ID_WS_VQA; 230 st->codec->codec_id = CODEC_ID_WS_VQA;
231 st->codec->codec_tag = 0; /* no fourcc */ 231 st->codec->codec_tag = 0; /* no fourcc */
232 232
243 return AVERROR_IO; 243 return AVERROR_IO;
244 } 244 }
245 st->codec->width = LE_16(&header[6]); 245 st->codec->width = LE_16(&header[6]);
246 st->codec->height = LE_16(&header[8]); 246 st->codec->height = LE_16(&header[8]);
247 247
248 st->codec->time_base.num = 1;
249 st->codec->time_base.den = VQA_FRAMERATE;
250
251 /* initialize the audio decoder stream for VQA v1 or nonzero samplerate */ 248 /* initialize the audio decoder stream for VQA v1 or nonzero samplerate */
252 if (LE_16(&header[24]) || (LE_16(&header[0]) == 1 && LE_16(&header[2]) == 1)) { 249 if (LE_16(&header[24]) || (LE_16(&header[0]) == 1 && LE_16(&header[2]) == 1)) {
253 st = av_new_stream(s, 0); 250 st = av_new_stream(s, 0);
254 if (!st) 251 if (!st)
255 return AVERROR_NOMEM; 252 return AVERROR_NOMEM;
256 av_set_pts_info(st, 33, 1, 90000); 253 av_set_pts_info(st, 33, 1, VQA_FRAMERATE);
257 st->codec->codec_type = CODEC_TYPE_AUDIO; 254 st->codec->codec_type = CODEC_TYPE_AUDIO;
258 if (LE_16(&header[0]) == 1) 255 if (LE_16(&header[0]) == 1)
259 st->codec->codec_id = CODEC_ID_WESTWOOD_SND1; 256 st->codec->codec_id = CODEC_ID_WESTWOOD_SND1;
260 else 257 else
261 st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS; 258 st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
340 return AVERROR_IO; 337 return AVERROR_IO;
341 } 338 }
342 339
343 if (chunk_type == SND2_TAG) { 340 if (chunk_type == SND2_TAG) {
344 pkt->stream_index = wsvqa->audio_stream_index; 341 pkt->stream_index = wsvqa->audio_stream_index;
345
346 pkt->pts = 90000;
347 pkt->pts *= wsvqa->audio_frame_counter;
348 pkt->pts /= wsvqa->audio_samplerate;
349
350 /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */ 342 /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */
351 wsvqa->audio_frame_counter += (chunk_size * 2) / wsvqa->audio_channels; 343 wsvqa->audio_frame_counter += (chunk_size * 2) / wsvqa->audio_channels;
352 } else if(chunk_type == SND1_TAG) { 344 } else if(chunk_type == SND1_TAG) {
353 pkt->stream_index = wsvqa->audio_stream_index; 345 pkt->stream_index = wsvqa->audio_stream_index;
354
355 pkt->pts = 90000;
356 pkt->pts *= wsvqa->audio_frame_counter;
357 pkt->pts /= wsvqa->audio_samplerate;
358
359 /* unpacked size is stored in header */ 346 /* unpacked size is stored in header */
360 wsvqa->audio_frame_counter += LE_16(pkt->data) / wsvqa->audio_channels; 347 wsvqa->audio_frame_counter += LE_16(pkt->data) / wsvqa->audio_channels;
361 } else { 348 } else {
362 pkt->stream_index = wsvqa->video_stream_index; 349 pkt->stream_index = wsvqa->video_stream_index;
363 pkt->pts = wsvqa->video_pts;
364 wsvqa->video_pts += VQA_VIDEO_PTS_INC; 350 wsvqa->video_pts += VQA_VIDEO_PTS_INC;
365 } 351 }
366 /* stay on 16-bit alignment */ 352 /* stay on 16-bit alignment */
367 if (skip_byte) 353 if (skip_byte)
368 url_fseek(pb, 1, SEEK_CUR); 354 url_fseek(pb, 1, SEEK_CUR);