1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Simplify RoQ demuxer pts calculation by using a appropriate time bases.

Originally committed as revision 17946 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Reimar Döffinger 2009-03-13 13:37:35 +00:00
parent 15969b55d1
commit abb785f19e

View File

@ -46,8 +46,6 @@ typedef struct RoqDemuxContext {
int width; int width;
int height; int height;
int audio_channels; int audio_channels;
int framerate;
int frame_pts_inc;
int video_stream_index; int video_stream_index;
int audio_stream_index; int audio_stream_index;
@ -71,6 +69,7 @@ static int roq_read_header(AVFormatContext *s,
{ {
RoqDemuxContext *roq = s->priv_data; RoqDemuxContext *roq = s->priv_data;
ByteIOContext *pb = s->pb; ByteIOContext *pb = s->pb;
int framerate;
AVStream *st; AVStream *st;
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE]; unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
@ -78,8 +77,7 @@ static int roq_read_header(AVFormatContext *s,
if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE) RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO); return AVERROR(EIO);
roq->framerate = AV_RL16(&preamble[6]); framerate = AV_RL16(&preamble[6]);
roq->frame_pts_inc = 90000 / roq->framerate;
/* init private context parameters */ /* init private context parameters */
roq->width = roq->height = roq->audio_channels = roq->video_pts = roq->width = roq->height = roq->audio_channels = roq->video_pts =
@ -89,8 +87,7 @@ static int roq_read_header(AVFormatContext *s,
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
/* set the pts reference (1 pts = 1/90000) */ av_set_pts_info(st, 63, 1, framerate);
av_set_pts_info(st, 33, 1, 90000);
roq->video_stream_index = st->index; roq->video_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ROQ; st->codec->codec_id = CODEC_ID_ROQ;
@ -161,9 +158,8 @@ static int roq_read_packet(AVFormatContext *s,
if (ret != chunk_size) if (ret != chunk_size)
return AVERROR(EIO); return AVERROR(EIO);
pkt->stream_index = roq->video_stream_index; pkt->stream_index = roq->video_stream_index;
pkt->pts = roq->video_pts; pkt->pts = roq->video_pts++;
roq->video_pts += roq->frame_pts_inc;
packet_read = 1; packet_read = 1;
break; break;
@ -173,7 +169,7 @@ static int roq_read_packet(AVFormatContext *s,
AVStream *st = av_new_stream(s, 1); AVStream *st = av_new_stream(s, 1);
if (!st) if (!st)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);
roq->audio_stream_index = st->index; roq->audio_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ROQ_DPCM; st->codec->codec_id = CODEC_ID_ROQ_DPCM;
@ -194,13 +190,10 @@ static int roq_read_packet(AVFormatContext *s,
if (chunk_type == RoQ_QUAD_VQ) { if (chunk_type == RoQ_QUAD_VQ) {
pkt->stream_index = roq->video_stream_index; pkt->stream_index = roq->video_stream_index;
pkt->pts = roq->video_pts; pkt->pts = roq->video_pts++;
roq->video_pts += roq->frame_pts_inc;
} else { } else {
pkt->stream_index = roq->audio_stream_index; pkt->stream_index = roq->audio_stream_index;
pkt->pts = roq->audio_frame_count; pkt->pts = roq->audio_frame_count;
pkt->pts *= 90000;
pkt->pts /= RoQ_AUDIO_SAMPLE_RATE;
roq->audio_frame_count += (chunk_size / roq->audio_channels); roq->audio_frame_count += (chunk_size / roq->audio_channels);
} }