From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Date: Wed, 14 Feb 2024 19:24:32 +0100 Message-ID: <20240214182435.31380-7-anton@khirnov.net> (raw) In-Reply-To: <20240214182435.31380-1-anton@khirnov.net> Treat it analogously to stream parameters like format/dimensions/etc. This is functionally different from previous code in 2 ways: * for non-CFR video, the frame timebase (set by the decoder) is used rather than the demuxer timebase * for sub2video, AV_TIME_BASE_Q is used, which is hardcoded by the subtitle decoding API These changes should avoid unnecessary and potentially lossy timestamp conversions from decoder timebase into the demuxer one. Changes the timebases used in sub2video tests. --- fftools/ffmpeg_filter.c | 17 ++- tests/ref/fate/sub2video_basic | 182 +++++++++++++------------- tests/ref/fate/sub2video_time_limited | 8 +- 3 files changed, 106 insertions(+), 101 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index dc65b441a6..a13b2ccf95 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -148,6 +148,8 @@ typedef struct InputFilterPriv { // fallback parameters to use when no input is ever sent struct { + AVRational time_base; + int format; int width; @@ -697,6 +699,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) palettes for all rectangles are identical or compatible */ ifp->format = AV_PIX_FMT_RGB32; + ifp->time_base = AV_TIME_BASE_Q; + av_log(fgp, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n", ifp->width, ifp->height); } @@ -1485,7 +1489,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, AVFilterContext *last_filter; const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); const AVPixFmtDescriptor *desc; - InputStream *ist = ifp->ist; AVRational fr = ifp->opts.framerate; AVRational sar; AVBPrint args; @@ -1498,9 +1501,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE) sub2video_prepare(ifp); - ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ? - av_inv_q(ifp->opts.framerate) : ist->st->time_base; - sar = ifp->sample_aspect_ratio; if(!sar.den) sar = (AVRational){0,1}; @@ -1591,8 +1591,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, char name[255]; int ret, pad_idx = 0; - ifp->time_base = (AVRational){ 1, ifp->sample_rate }; - av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s", ifp->time_base.num, ifp->time_base.den, @@ -1821,6 +1819,8 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec) { InputFilterPriv *ifp = ifp_from_ifilter(ifilter); + ifp->fallback.time_base = dec->pkt_timebase; + if (dec->codec_type == AVMEDIA_TYPE_VIDEO) { ifp->fallback.format = dec->pix_fmt; ifp->fallback.width = dec->width; @@ -1852,6 +1852,10 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr if (ret < 0) return ret; + ifp->time_base = (ifp->type == AVMEDIA_TYPE_AUDIO) ? (AVRational){ 1, frame->sample_rate } : + (ifp->opts.flags & IFILTER_FLAG_CFR) ? av_inv_q(ifp->opts.framerate) : + frame->time_base; + ifp->format = frame->format; ifp->width = frame->width; @@ -2541,6 +2545,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, ifp->sample_aspect_ratio = ifp->fallback.sample_aspect_ratio; ifp->color_space = ifp->fallback.color_space; ifp->color_range = ifp->fallback.color_range; + ifp->time_base = ifp->fallback.time_base; ret = av_channel_layout_copy(&ifp->ch_layout, &ifp->fallback.ch_layout); diff --git a/tests/ref/fate/sub2video_basic b/tests/ref/fate/sub2video_basic index a6eb1a34ea..2e4dcb625e 100644 --- a/tests/ref/fate/sub2video_basic +++ b/tests/ref/fate/sub2video_basic @@ -1,95 +1,95 @@ -#tb 0: 1/1000 +#tb 0: 1/1000000 #media_type 0: video #codec_id 0: rawvideo #dimensions 0: 720x480 #sar 0: 0/1 -0, 132499, 132499, 0, 1382400, 0x00000000 -0, 132499, 132499, 0, 1382400, 0x8c93c2ba -0, 137459, 137459, 0, 1382400, 0x00000000 -0, 147355, 147355, 0, 1382400, 0xb02e32ca -0, 152088, 152088, 0, 1382400, 0x00000000 -0, 180797, 180797, 0, 1382400, 0x83b71116 -0, 183357, 183357, 0, 1382400, 0x00000000 -0, 183433, 183433, 0, 1382400, 0x85547fd1 -0, 185799, 185799, 0, 1382400, 0x00000000 -0, 185909, 185909, 0, 1382400, 0x00000000 -0, 185910, 185910, 0, 1382400, 0xb6a8f181 -0, 188606, 188606, 0, 1382400, 0x00000000 -0, 188663, 188663, 0, 1382400, 0xb64d1a2c -0, 189925, 189925, 0, 1382400, 0x00000000 -0, 190014, 190014, 0, 1382400, 0x7b37ecf3 -0, 191675, 191675, 0, 1382400, 0x00000000 -0, 199724, 199724, 0, 1382400, 0xdc025bd1 -0, 201089, 201089, 0, 1382400, 0x00000000 -0, 201175, 201175, 0, 1382400, 0x688b294d -0, 202733, 202733, 0, 1382400, 0x00000000 -0, 202819, 202819, 0, 1382400, 0xa2b33d1b -0, 204684, 204684, 0, 1382400, 0x00000000 -0, 204762, 204762, 0, 1382400, 0xb3e525e3 -0, 206730, 206730, 0, 1382400, 0x00000000 -0, 206806, 206806, 0, 1382400, 0xaa8fbdd7 -0, 208637, 208637, 0, 1382400, 0x00000000 -0, 208716, 208716, 0, 1382400, 0x7b7f26dd -0, 209978, 209978, 0, 1382400, 0x00000000 -0, 210051, 210051, 0, 1382400, 0x15e2f836 -0, 211575, 211575, 0, 1382400, 0x00000000 -0, 211644, 211644, 0, 1382400, 0x0fee9b0c -0, 214306, 214306, 0, 1382400, 0x00000000 -0, 214380, 214380, 0, 1382400, 0x89d62791 -0, 217144, 217144, 0, 1382400, 0x00000000 -0, 217225, 217225, 0, 1382400, 0xa6a9fd74 -0, 219591, 219591, 0, 1382400, 0x00000000 -0, 219652, 219652, 0, 1382400, 0x7896178d -0, 221483, 221483, 0, 1382400, 0x00000000 -0, 223531, 223531, 0, 1382400, 0x01751a52 -0, 225863, 225863, 0, 1382400, 0x00000000 -0, 227510, 227510, 0, 1382400, 0xa3959c6f -0, 230809, 230809, 0, 1382400, 0x00000000 -0, 230872, 230872, 0, 1382400, 0x3d3ea47b -0, 233033, 233033, 0, 1382400, 0x00000000 -0, 233124, 233124, 0, 1382400, 0x593f8b24 -0, 237220, 237220, 0, 1382400, 0x00000000 -0, 237303, 237303, 0, 1382400, 0x171f05ba -0, 240033, 240033, 0, 1382400, 0x00000000 -0, 240106, 240106, 0, 1382400, 0xb014cdf1 -0, 242165, 242165, 0, 1382400, 0x00000000 -0, 273556, 273556, 0, 1382400, 0xd918e667 -0, 275217, 275217, 0, 1382400, 0x00000000 -0, 295445, 295445, 0, 1382400, 0xc9406331 -0, 296776, 296776, 0, 1382400, 0x00000000 -0, 300049, 300049, 0, 1382400, 0xaf08b10d -0, 301949, 301949, 0, 1382400, 0x00000000 -0, 302034, 302034, 0, 1382400, 0x00000000 -0, 302035, 302035, 0, 1382400, 0x853a9d93 -0, 303559, 303559, 0, 1382400, 0x00000000 -0, 304203, 304203, 0, 1382400, 0x7491a87d -0, 305898, 305898, 0, 1382400, 0x00000000 -0, 305947, 305947, 0, 1382400, 0xf7383c58 -0, 307881, 307881, 0, 1382400, 0x00000000 -0, 307957, 307957, 0, 1382400, 0xe66be411 -0, 309720, 309720, 0, 1382400, 0x00000000 -0, 321295, 321295, 0, 1382400, 0xd6850362 -0, 323263, 323263, 0, 1382400, 0x00000000 -0, 323356, 323356, 0, 1382400, 0x3e1ed109 -0, 324584, 324584, 0, 1382400, 0x00000000 -0, 324640, 324640, 0, 1382400, 0x39c1b7bd -0, 326403, 326403, 0, 1382400, 0x00000000 -0, 327193, 327193, 0, 1382400, 0x35b85f2e -0, 328285, 328285, 0, 1382400, 0x00000000 -0, 328360, 328360, 0, 1382400, 0x00000000 -0, 328361, 328361, 0, 1382400, 0x83f103e5 -0, 329885, 329885, 0, 1382400, 0x00000000 -0, 329946, 329946, 0, 1382400, 0xbc1ca9b3 -0, 331106, 331106, 0, 1382400, 0x00000000 -0, 331230, 331230, 0, 1382400, 0x94d4a51e -0, 332857, 332857, 0, 1382400, 0x00000000 -0, 332924, 332924, 0, 1382400, 0xf88cdfde -0, 334687, 334687, 0, 1382400, 0x00000000 -0, 342600, 342600, 0, 1382400, 0xdd51423b -0, 344431, 344431, 0, 1382400, 0x00000000 -0, 346771, 346771, 0, 1382400, 0x08259fa4 -0, 348329, 348329, 0, 1382400, 0x00000000 -0, 357640, 357640, 0, 1382400, 0x1663fa34 -0, 359767, 359767, 0, 1382400, 0x00000000 -0, 359834, 359834, 0, 1382400, 0xda2ceb55 -0, 361096, 361096, 0, 1382400, 0x00000000 +0, 132499000, 132499000, 0, 1382400, 0x00000000 +0, 132499000, 132499000, 0, 1382400, 0x8c93c2ba +0, 137459000, 137459000, 0, 1382400, 0x00000000 +0, 147355000, 147355000, 0, 1382400, 0xb02e32ca +0, 152088000, 152088000, 0, 1382400, 0x00000000 +0, 180797000, 180797000, 0, 1382400, 0x83b71116 +0, 183357000, 183357000, 0, 1382400, 0x00000000 +0, 183433000, 183433000, 0, 1382400, 0x85547fd1 +0, 185799000, 185799000, 0, 1382400, 0x00000000 +0, 185909999, 185909999, 0, 1382400, 0x00000000 +0, 185910000, 185910000, 0, 1382400, 0xb6a8f181 +0, 188606000, 188606000, 0, 1382400, 0x00000000 +0, 188663000, 188663000, 0, 1382400, 0xb64d1a2c +0, 189925000, 189925000, 0, 1382400, 0x00000000 +0, 190014000, 190014000, 0, 1382400, 0x7b37ecf3 +0, 191675000, 191675000, 0, 1382400, 0x00000000 +0, 199724000, 199724000, 0, 1382400, 0xdc025bd1 +0, 201089000, 201089000, 0, 1382400, 0x00000000 +0, 201175000, 201175000, 0, 1382400, 0x688b294d +0, 202733000, 202733000, 0, 1382400, 0x00000000 +0, 202819000, 202819000, 0, 1382400, 0xa2b33d1b +0, 204684000, 204684000, 0, 1382400, 0x00000000 +0, 204762000, 204762000, 0, 1382400, 0xb3e525e3 +0, 206730000, 206730000, 0, 1382400, 0x00000000 +0, 206806000, 206806000, 0, 1382400, 0xaa8fbdd7 +0, 208637000, 208637000, 0, 1382400, 0x00000000 +0, 208716000, 208716000, 0, 1382400, 0x7b7f26dd +0, 209978000, 209978000, 0, 1382400, 0x00000000 +0, 210051000, 210051000, 0, 1382400, 0x15e2f836 +0, 211575000, 211575000, 0, 1382400, 0x00000000 +0, 211644000, 211644000, 0, 1382400, 0x0fee9b0c +0, 214306000, 214306000, 0, 1382400, 0x00000000 +0, 214380000, 214380000, 0, 1382400, 0x89d62791 +0, 217144000, 217144000, 0, 1382400, 0x00000000 +0, 217225000, 217225000, 0, 1382400, 0xa6a9fd74 +0, 219591000, 219591000, 0, 1382400, 0x00000000 +0, 219652000, 219652000, 0, 1382400, 0x7896178d +0, 221483000, 221483000, 0, 1382400, 0x00000000 +0, 223531000, 223531000, 0, 1382400, 0x01751a52 +0, 225863000, 225863000, 0, 1382400, 0x00000000 +0, 227510000, 227510000, 0, 1382400, 0xa3959c6f +0, 230809000, 230809000, 0, 1382400, 0x00000000 +0, 230872000, 230872000, 0, 1382400, 0x3d3ea47b +0, 233033000, 233033000, 0, 1382400, 0x00000000 +0, 233124000, 233124000, 0, 1382400, 0x593f8b24 +0, 237220000, 237220000, 0, 1382400, 0x00000000 +0, 237303000, 237303000, 0, 1382400, 0x171f05ba +0, 240033000, 240033000, 0, 1382400, 0x00000000 +0, 240106000, 240106000, 0, 1382400, 0xb014cdf1 +0, 242165000, 242165000, 0, 1382400, 0x00000000 +0, 273556000, 273556000, 0, 1382400, 0xd918e667 +0, 275217000, 275217000, 0, 1382400, 0x00000000 +0, 295445000, 295445000, 0, 1382400, 0xc9406331 +0, 296776000, 296776000, 0, 1382400, 0x00000000 +0, 300049000, 300049000, 0, 1382400, 0xaf08b10d +0, 301949000, 301949000, 0, 1382400, 0x00000000 +0, 302034999, 302034999, 0, 1382400, 0x00000000 +0, 302035000, 302035000, 0, 1382400, 0x853a9d93 +0, 303559000, 303559000, 0, 1382400, 0x00000000 +0, 304203000, 304203000, 0, 1382400, 0x7491a87d +0, 305898000, 305898000, 0, 1382400, 0x00000000 +0, 305947000, 305947000, 0, 1382400, 0xf7383c58 +0, 307881000, 307881000, 0, 1382400, 0x00000000 +0, 307957000, 307957000, 0, 1382400, 0xe66be411 +0, 309720000, 309720000, 0, 1382400, 0x00000000 +0, 321295000, 321295000, 0, 1382400, 0xd6850362 +0, 323263000, 323263000, 0, 1382400, 0x00000000 +0, 323356000, 323356000, 0, 1382400, 0x3e1ed109 +0, 324584000, 324584000, 0, 1382400, 0x00000000 +0, 324640000, 324640000, 0, 1382400, 0x39c1b7bd +0, 326403000, 326403000, 0, 1382400, 0x00000000 +0, 327193000, 327193000, 0, 1382400, 0x35b85f2e +0, 328285000, 328285000, 0, 1382400, 0x00000000 +0, 328360999, 328360999, 0, 1382400, 0x00000000 +0, 328361000, 328361000, 0, 1382400, 0x83f103e5 +0, 329885000, 329885000, 0, 1382400, 0x00000000 +0, 329946000, 329946000, 0, 1382400, 0xbc1ca9b3 +0, 331106000, 331106000, 0, 1382400, 0x00000000 +0, 331230000, 331230000, 0, 1382400, 0x94d4a51e +0, 332857000, 332857000, 0, 1382400, 0x00000000 +0, 332924000, 332924000, 0, 1382400, 0xf88cdfde +0, 334687000, 334687000, 0, 1382400, 0x00000000 +0, 342600000, 342600000, 0, 1382400, 0xdd51423b +0, 344431000, 344431000, 0, 1382400, 0x00000000 +0, 346771000, 346771000, 0, 1382400, 0x08259fa4 +0, 348329000, 348329000, 0, 1382400, 0x00000000 +0, 357640000, 357640000, 0, 1382400, 0x1663fa34 +0, 359767000, 359767000, 0, 1382400, 0x00000000 +0, 359834000, 359834000, 0, 1382400, 0xda2ceb55 +0, 361096000, 361096000, 0, 1382400, 0x00000000 diff --git a/tests/ref/fate/sub2video_time_limited b/tests/ref/fate/sub2video_time_limited index c7d48d639f..07d50fc697 100644 --- a/tests/ref/fate/sub2video_time_limited +++ b/tests/ref/fate/sub2video_time_limited @@ -1,8 +1,8 @@ -#tb 0: 1/90000 +#tb 0: 1/1000000 #media_type 0: video #codec_id 0: rawvideo #dimensions 0: 1920x1080 #sar 0: 0/1 -0, 6072, 6072, 0, 8294400, 0x00000000 -0, 6072, 6072, 0, 8294400, 0xa87c518f -0, 36101, 36101, 0, 8294400, 0xa87c518f +0, 67467, 67467, 0, 8294400, 0x00000000 +0, 67467, 67467, 0, 8294400, 0xa87c518f +0, 401132, 401132, 0, 8294400, 0xa87c518f -- 2.42.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".
next prev parent reply other threads:[~2024-02-14 18:25 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags " Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate " Anton Khirnov 2024-02-14 18:24 ` Anton Khirnov [this message] 2024-02-15 1:58 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Michael Niedermayer 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240214182435.31380-7-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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