Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] fftools: allow decoders to set AVFrame time_base
@ 2022-09-10 16:42 Leo Izen
  2022-09-15 18:06 ` Marton Balint
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Izen @ 2022-09-10 16:42 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Leo Izen

This patch allows decoders to set AVFrame->time_base, which
determines the units that AVFrame->pts will use. Currently
no decoders do this, but it will allow it in the future.
---
 fftools/ffmpeg.c | 3 ++-
 fftools/ffplay.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0e1477299d..e3ea7a6c29 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2274,7 +2274,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
     }
 
     if(best_effort_timestamp != AV_NOPTS_VALUE) {
-        int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
+        int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp,
+            decoded_frame->time_base.num ? decoded_frame->time_base : ist->st->time_base, AV_TIME_BASE_Q);
 
         if (ts != AV_NOPTS_VALUE)
             ist->next_pts = ist->pts = ts;
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 9242047f5c..986b0831ac 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -1771,7 +1771,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame)
         double dpts = NAN;
 
         if (frame->pts != AV_NOPTS_VALUE)
-            dpts = av_q2d(is->video_st->time_base) * frame->pts;
+            dpts = av_q2d(frame->time_base.num ? frame->time_base : is->video_st->time_base) * frame->pts;
 
         frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame);
 
-- 
2.37.3

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] fftools: allow decoders to set AVFrame time_base
  2022-09-10 16:42 [FFmpeg-devel] [PATCH] fftools: allow decoders to set AVFrame time_base Leo Izen
@ 2022-09-15 18:06 ` Marton Balint
  0 siblings, 0 replies; 2+ messages in thread
From: Marton Balint @ 2022-09-15 18:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



On Sat, 10 Sep 2022, Leo Izen wrote:

> This patch allows decoders to set AVFrame->time_base, which
> determines the units that AVFrame->pts will use. Currently
> no decoders do this, but it will allow it in the future.

This is patch is wrong, because it implies that decoders can output frames 
in time base different to stream time base. They can't, because that would 
be a breaking change. AVFrame->time_base was not introduced for that use 
case.

Regards,
Marton

> ---
> fftools/ffmpeg.c | 3 ++-
> fftools/ffplay.c | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 0e1477299d..e3ea7a6c29 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2274,7 +2274,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
>     }
>
>     if(best_effort_timestamp != AV_NOPTS_VALUE) {
> -        int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
> +        int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp,
> +            decoded_frame->time_base.num ? decoded_frame->time_base : ist->st->time_base, AV_TIME_BASE_Q);
>
>         if (ts != AV_NOPTS_VALUE)
>             ist->next_pts = ist->pts = ts;
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 9242047f5c..986b0831ac 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -1771,7 +1771,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame)
>         double dpts = NAN;
>
>         if (frame->pts != AV_NOPTS_VALUE)
> -            dpts = av_q2d(is->video_st->time_base) * frame->pts;
> +            dpts = av_q2d(frame->time_base.num ? frame->time_base : is->video_st->time_base) * frame->pts;
>
>         frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame);
>
> -- 
> 2.37.3
>
> _______________________________________________
> 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".
>
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-15 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-10 16:42 [FFmpeg-devel] [PATCH] fftools: allow decoders to set AVFrame time_base Leo Izen
2022-09-15 18:06 ` Marton Balint

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git