diff mbox

[FFmpeg-devel,06/13] avformat/mux: Use av_packet_rescale_ts

Message ID 20190813024726.6596-6-andreas.rheinhardt@gmail.com
State Accepted
Commit 789dcfaf58dbf19d050d53ba169fd352a6460641
Headers show

Commit Message

Andreas Rheinhardt Aug. 13, 2019, 2:47 a.m. UTC
ff_write_chained essentially duplicated the functionality of
av_packet_rescale_ts. This has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/mux.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Comments

Paul B Mahol Aug. 14, 2019, 3:59 p.m. UTC | #1
LGTM

On Tue, Aug 13, 2019 at 4:55 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> ff_write_chained essentially duplicated the functionality of
> av_packet_rescale_ts. This has been changed.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/mux.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index 44ce099cbf..efe2e94f40 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1317,18 +1317,10 @@ int ff_write_chained(AVFormatContext *dst, int
> dst_stream, AVPacket *pkt,
>
>      local_pkt = *pkt;
>      local_pkt.stream_index = dst_stream;
> -    if (pkt->pts != AV_NOPTS_VALUE)
> -        local_pkt.pts = av_rescale_q(pkt->pts,
> -
>  src->streams[pkt->stream_index]->time_base,
> -                                     dst->streams[dst_stream]->time_base);
> -    if (pkt->dts != AV_NOPTS_VALUE)
> -        local_pkt.dts = av_rescale_q(pkt->dts,
> -
>  src->streams[pkt->stream_index]->time_base,
> -                                     dst->streams[dst_stream]->time_base);
> -    if (pkt->duration)
> -        local_pkt.duration = av_rescale_q(pkt->duration,
> -
> src->streams[pkt->stream_index]->time_base,
> -
> dst->streams[dst_stream]->time_base);
> +
> +    av_packet_rescale_ts(&local_pkt,
> +                         src->streams[pkt->stream_index]->time_base,
> +                         dst->streams[dst_stream]->time_base);
>
>      if (interleave) ret = av_interleaved_write_frame(dst, &local_pkt);
>      else            ret = av_write_frame(dst, &local_pkt);
> --
> 2.21.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Aug. 14, 2019, 11:13 p.m. UTC | #2
On Wed, Aug 14, 2019 at 05:59:13PM +0200, Paul B Mahol wrote:
> LGTM

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 44ce099cbf..efe2e94f40 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1317,18 +1317,10 @@  int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
 
     local_pkt = *pkt;
     local_pkt.stream_index = dst_stream;
-    if (pkt->pts != AV_NOPTS_VALUE)
-        local_pkt.pts = av_rescale_q(pkt->pts,
-                                     src->streams[pkt->stream_index]->time_base,
-                                     dst->streams[dst_stream]->time_base);
-    if (pkt->dts != AV_NOPTS_VALUE)
-        local_pkt.dts = av_rescale_q(pkt->dts,
-                                     src->streams[pkt->stream_index]->time_base,
-                                     dst->streams[dst_stream]->time_base);
-    if (pkt->duration)
-        local_pkt.duration = av_rescale_q(pkt->duration,
-                                          src->streams[pkt->stream_index]->time_base,
-                                          dst->streams[dst_stream]->time_base);
+
+    av_packet_rescale_ts(&local_pkt,
+                         src->streams[pkt->stream_index]->time_base,
+                         dst->streams[dst_stream]->time_base);
 
     if (interleave) ret = av_interleaved_write_frame(dst, &local_pkt);
     else            ret = av_write_frame(dst, &local_pkt);