You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
fftools/ffmpeg: use AVPacket.time_base to simplify do_streamcopy()
Besides making the code shorter, this also reduces the use of InputStream in this function and will allow not accessing it at all in the future.
This commit is contained in:
@@ -964,7 +964,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
|||||||
if (!ost->copy_prior_start &&
|
if (!ost->copy_prior_start &&
|
||||||
(pkt->pts == AV_NOPTS_VALUE ?
|
(pkt->pts == AV_NOPTS_VALUE ?
|
||||||
ist->pts < ost->ts_copy_start :
|
ist->pts < ost->ts_copy_start :
|
||||||
pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, ist->st->time_base)))
|
pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, pkt->time_base)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
|
if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
|
||||||
@@ -995,7 +995,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
|||||||
opkt->time_base = ost->mux_timebase;
|
opkt->time_base = ost->mux_timebase;
|
||||||
|
|
||||||
if (pkt->pts != AV_NOPTS_VALUE)
|
if (pkt->pts != AV_NOPTS_VALUE)
|
||||||
opkt->pts = av_rescale_q(pkt->pts, ist->st->time_base, opkt->time_base) - ost_tb_start_time;
|
opkt->pts = av_rescale_q(pkt->pts, pkt->time_base, opkt->time_base) - ost_tb_start_time;
|
||||||
|
|
||||||
if (pkt->dts == AV_NOPTS_VALUE) {
|
if (pkt->dts == AV_NOPTS_VALUE) {
|
||||||
opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, opkt->time_base);
|
opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, opkt->time_base);
|
||||||
@@ -1003,16 +1003,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
|||||||
int duration = av_get_audio_frame_duration2(ist->par, pkt->size);
|
int duration = av_get_audio_frame_duration2(ist->par, pkt->size);
|
||||||
if(!duration)
|
if(!duration)
|
||||||
duration = ist->par->frame_size;
|
duration = ist->par->frame_size;
|
||||||
opkt->dts = av_rescale_delta(ist->st->time_base, pkt->dts,
|
opkt->dts = av_rescale_delta(pkt->time_base, pkt->dts,
|
||||||
(AVRational){1, ist->par->sample_rate}, duration,
|
(AVRational){1, ist->par->sample_rate}, duration,
|
||||||
&ist->filter_in_rescale_delta_last, opkt->time_base);
|
&ist->filter_in_rescale_delta_last, opkt->time_base);
|
||||||
/* dts will be set immediately afterwards to what pts is now */
|
/* dts will be set immediately afterwards to what pts is now */
|
||||||
opkt->pts = opkt->dts - ost_tb_start_time;
|
opkt->pts = opkt->dts - ost_tb_start_time;
|
||||||
} else
|
} else
|
||||||
opkt->dts = av_rescale_q(pkt->dts, ist->st->time_base, opkt->time_base);
|
opkt->dts = av_rescale_q(pkt->dts, pkt->time_base, opkt->time_base);
|
||||||
opkt->dts -= ost_tb_start_time;
|
opkt->dts -= ost_tb_start_time;
|
||||||
|
|
||||||
opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, opkt->time_base);
|
opkt->duration = av_rescale_q(pkt->duration, pkt->time_base, opkt->time_base);
|
||||||
|
|
||||||
{
|
{
|
||||||
int ret = trigger_fix_sub_duration_heartbeat(ost, pkt);
|
int ret = trigger_fix_sub_duration_heartbeat(ost, pkt);
|
||||||
|
Reference in New Issue
Block a user