Do not truncate timestamps before the muxer as it makes simple
things like last_pts - pts rather tricky and is not good for anything. Timestamps should be truncated just before storing when needed. Originally committed as revision 15015 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
e522bd49c8
commit
f0aaa16fdf
@ -2574,18 +2574,6 @@ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void truncate_ts(AVStream *st, AVPacket *pkt){
|
|
||||||
int64_t pts_mask = (2LL << (st->pts_wrap_bits-1)) - 1;
|
|
||||||
|
|
||||||
// if(pkt->dts < 0)
|
|
||||||
// pkt->dts= 0; //this happens for low_delay=0 and B-frames, FIXME, needs further investigation about what we should do here
|
|
||||||
|
|
||||||
if (pkt->pts != AV_NOPTS_VALUE)
|
|
||||||
pkt->pts &= pts_mask;
|
|
||||||
if (pkt->dts != AV_NOPTS_VALUE)
|
|
||||||
pkt->dts &= pts_mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
|
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
int ret = compute_pkt_fields2(s->streams[pkt->stream_index], pkt);
|
int ret = compute_pkt_fields2(s->streams[pkt->stream_index], pkt);
|
||||||
@ -2593,8 +2581,6 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
|
|||||||
if(ret<0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
|
if(ret<0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
truncate_ts(s->streams[pkt->stream_index], pkt);
|
|
||||||
|
|
||||||
ret= s->oformat->write_packet(s, pkt);
|
ret= s->oformat->write_packet(s, pkt);
|
||||||
if(!ret)
|
if(!ret)
|
||||||
ret= url_ferror(s->pb);
|
ret= url_ferror(s->pb);
|
||||||
@ -2690,7 +2676,6 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
|
|||||||
if(ret<=0) //FIXME cleanup needed for ret<0 ?
|
if(ret<=0) //FIXME cleanup needed for ret<0 ?
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
truncate_ts(s->streams[opkt.stream_index], &opkt);
|
|
||||||
ret= s->oformat->write_packet(s, &opkt);
|
ret= s->oformat->write_packet(s, &opkt);
|
||||||
|
|
||||||
av_free_packet(&opkt);
|
av_free_packet(&opkt);
|
||||||
@ -2715,7 +2700,6 @@ int av_write_trailer(AVFormatContext *s)
|
|||||||
if(!ret)
|
if(!ret)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
truncate_ts(s->streams[pkt.stream_index], &pkt);
|
|
||||||
ret= s->oformat->write_packet(s, &pkt);
|
ret= s->oformat->write_packet(s, &pkt);
|
||||||
|
|
||||||
av_free_packet(&pkt);
|
av_free_packet(&pkt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user