History

lavfi/vf_libplacebo: set time_base/frame_rate dynamically

Use the gcd of all input timebases to ensure PTS accuracy. For the framerate, just pick the highest of all the inputs, under the assumption that we will render frames with approximately this frequency. Of course, this is not 100% accurate, in particular if the input frames are badly misaligned. But this field is informational to begin with. Importantly, it covers the "common" case of combining high FPS and low FPS streams with aligned frames.

Niklas Haas committed 3 years ago

Commit 9049ea61 parent 1b2c6c91 file · +15 −0Browse files

Unified · Split

libavfilter/vf_libplacebo.c+15−0
@@ -1158,6 +1158,11 @@ static int libplacebo_config_input(AVFilterLink *inlink) · 1157 unmodified lines
1158 return 0;1158 return 0;
1159}1159}
1160 1160
1161static inline AVRational max_q(AVRational a, AVRational b)
1162{
1163 return av_cmp_q(a, b) < 0 ? b : a;
1164}
1165
1161static int libplacebo_config_output(AVFilterLink *outlink)1166static int libplacebo_config_output(AVFilterLink *outlink)
1162{1167{
1163 int err;1168 int err;
@@ -1198,6 +1203,16 @@ static int libplacebo_config_output(AVFilterLink *outlink) · 34 unmodified lines
1198 if (s->fps.num) {1203 if (s->fps.num) {
1199 outlink->frame_rate = s->fps;1204 outlink->frame_rate = s->fps;
1200 outlink->time_base = av_inv_q(s->fps);1205 outlink->time_base = av_inv_q(s->fps);
1206 } else {
1207 outlink->frame_rate = avctx->inputs[0]->frame_rate;
1208 outlink->time_base = avctx->inputs[0]->time_base;
1209 for (int i = 1; i < s->nb_inputs; i++) {
1210 outlink->frame_rate = max_q(outlink->frame_rate,
1211 avctx->inputs[i]->frame_rate);
1212 outlink->time_base = av_gcd_q(outlink->time_base,
1213 avctx->inputs[i]->time_base,
1214 AV_TIME_BASE / 2, AV_TIME_BASE_Q);
1215 }
1201 }1216 }
1202 1217
1203 /* Static variables */1218 /* Static variables */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t