1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

11021 Commits

Author SHA1 Message Date
Niklas Haas
5fdb12d6a0 lavfi/vf_libplacebo: simplify SAR normalization
The old logic was trying to be excessively clever in "deducing" that the
user wanted to stretch/scale the image when ow/oh differed from iw/ih
aspect ratio. But this is almost surely unintended except in
pathological cases, and in those cases users should simply disable
normalize_sar and do all the stretching/scaling logic themselves. This
is especially important in multi-input mode, where the canvas may be
vastly different from the input dimensions of any stream. Also, passing
through input 0 SAR in multi-input mode is arbitrary and nearly useless,
so again force output SAR to 1:1 here.
2023-06-23 15:18:25 +02:00
Niklas Haas
e998d0a4f7 lavfi/vf_libplacebo: allow pos_w to depend on pos_h
Ditto for crop_w/crop_h. Requires simply repeating the evaluation of the
first variable to be evaluated.
2023-06-20 17:09:58 +02:00
Niklas Haas
f998a618ba lavfi/vf_libplacebo: add nb_inputs option
To control the number of inputs.
2023-06-20 17:09:58 +02:00
Niklas Haas
9049ea6763 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.
2023-06-20 17:09:58 +02:00
Niklas Haas
1b2c6c9a03 lavfi/vf_libplacebo: also skip cache if in FPS == out FPS
Fixes an oversight in the previous code which should have been >=, not >.
2023-06-20 17:09:58 +02:00
Niklas Haas
618b72d4b4 lavfi/vf_libplacebo: skip cache selectively per-input
It may be the case that we want to skip the single frame cache for some
inputs but not others.
2023-06-20 17:09:58 +02:00
Niklas Haas
015c3b659e lavfi/vf_libplacebo: set format list for all inputs 2023-06-20 17:09:58 +02:00
Niklas Haas
5989719e87 lavfi/vf_libplacebo: add in_idx variable
To allow placing an input dynamically, as a function of the input index.
2023-06-20 17:09:58 +02:00
Niklas Haas
7645c8df66 lavfi/vf_libplacebo: make input-dependent vars dynamic
Because these can differ based on the input, for multiple inputs.
2023-06-20 17:09:58 +02:00
Niklas Haas
d625010acd lavfi/vf_libplacebo: generalize frame update to multiple inputs
In the event that some frame mixes are OK while others are not, the
priority goes:

1. Errors in updating any frame -> return error
2. Any input incomplete -> request frames and return
3. Any inputs OK -> ignore EOF streams and render remaining inputs
4. No inputs OK -> set output to most recent status

This logic ensures that we can continue rendering the remaining streams,
no matter which streams reach their end of life, until we have no
streams left at which point we forward the last EOF.
2023-06-20 17:09:58 +02:00
Niklas Haas
6c41c3f928 lavfi/vf_libplacebo: only drain actually used PTS
When combining multiple inputs, the output PTS may be less than the PTS
of the input. In this case, the current's code assumption of always
draining one value from the FIFO is incorrect. Replace by a smarter
function which drains only those PTS values that were actually consumed.
2023-06-20 17:09:58 +02:00
Niklas Haas
502b699a50 lavfi/vf_libplacebo: determine PTS of next frame from any input
When combining multiple inputs with different PTS and durations, in
input-timed mode, we emit one output frame for every input frame PTS,
from *any* input. So when combining a low FPS stream with a high FPS
stream, the output framerate would match the higher FPS, independent of
which order they are specified in.
2023-06-20 17:09:58 +02:00
Niklas Haas
0eb37c2419 lavfi/vf_libplacebo: handle multiple inputs
This commit still relies on a single input for PTS determination, to be
changed in the next commit.
2023-06-20 17:09:58 +02:00
Niklas Haas
56e550b264 lavfi/vf_libplacebo: support blending multiple inputs
Subsequent inputs require frame blending to be enabled, in order to not
overwrite the existing frame contents.

For output metadata, we implicitly copy the metadata of the *first*
available stream (falling back to the second stream if the first has
already reached EOF, and so on). This is done to resolve any conflicts
between inputs with differing metadata. So when e.g. input 1 is HDR and
output 2 is SDR, the output will be HDR, and vice versa. This logic
could probablly be improved by dynamically determining some "superior"
set of metadata, but I don't want to handle that complexity in this
series.
2023-06-20 17:09:58 +02:00
Niklas Haas
0c66d912ba lavfi/vf_libplacebo: keep track of latest status globally
This field will effectively hold the most recent status set by any
input. Currently functionally equivalent to input->status, but will
change soon.
2023-06-20 17:09:57 +02:00
Niklas Haas
4e4a66b8c4 lavfi/vf_libplacebo: replace s->input by dynamic array
For now, hard-coded to 1 element.
2023-06-20 17:09:57 +02:00
Niklas Haas
a7775bd32c lavfi/vf_libplacebo: use correct link in update_crops()
Instead of hard-coding input 0, pass the per-input structure and use the
link contained inside it.
2023-06-20 17:09:57 +02:00
Niklas Haas
93c7e8c0ae lavfi/vf_libplacebo: factor out ref frame logic
Instead of finding the ref frame in output_frame() and then passing its
signature to update_crops(), pull out the logic and invoke it a second
time inside update_crops().

This may seem wasteful at present, but will actually become required in
the future, since update_crops() runs on *every* input, and needs values
specific to that input (which the signature isn't), while output_frame()
is only interested in a single input. It's much easier to just split the
logic cleanly.
2023-06-20 17:09:57 +02:00
Niklas Haas
666c8aa4d7 lavif/vf_libplacebo: remove pl_frame_mix from output_frame_mix
Instead, rename this function to `output_frame` and make it pull the
`pl_frame_mix` from the input structure. Step towards handling multiple
inputs.
2023-06-20 17:09:57 +02:00
Niklas Haas
ad445a7030 lavfi/vf_libplacebo: move temporary vars into per-input struct
Including the queue status, because these will need to be re-queried
inside output_frame_mix when that function is refactored to handle
multiple inputs.
2023-06-20 17:09:57 +02:00
Niklas Haas
a4197196a0 lavfi/vf_libplacebo: cosmetic
Assign local variable 'in' for 's->input' and replace 'inlink' by
'in->link' to avoid hard-coding ID 0 in more than one place.
2023-06-20 17:09:57 +02:00
Niklas Haas
b5d48111ad lavfi/vf_libplacebo: move input handling to separate function
To be re-used once we support more than one input.
2023-06-20 17:09:57 +02:00
Niklas Haas
c3b17ccc62 lavfi/vf_libplacebo: move input-specific state to struct
In anticipation of a refactor which will enable multiple input support.

Note: the renderer is also input-specific because it maintains a frame
cache, HDR peak detection state and mixing cache, all of which are tied
to a specific input stream.
2023-06-20 17:09:57 +02:00
Niklas Haas
7be4434c88 lavfi/vf_libplacebo: drop redundant case
If the input queue is EOF, then the s->status check should already have
covered it, and prevented the code from getting this far.

If we still hit this case for some reason, it's probably a bug. Better
to hit the AVERROR_BUG branch.
2023-06-20 17:09:57 +02:00
Haihao Xiang
88b3841149 lavfi/qsvvpp: use the right picture struct for vpp initilaization
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-06-20 09:52:43 +08:00
Haihao Xiang
bcdea21675 lavfi/qsvvpp: postpone vpp session initialization
So there is a chance to update vpp parameters per frame

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-06-20 09:52:43 +08:00
Haihao Xiang
cf21ca9efb lavfi/qsvvpp: store a copy of the sequence parameters
We will postpone the vpp session initialization to when input and output
frames are ready, this copy of the sequence parameters will be used to
initialize vpp session.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-06-20 09:52:43 +08:00
Haihao Xiang
579711c2cc lavfi/qsvvpp: check the parameters before initializing vpp session
According to the description about MFXVideoVPP_Query [1], we may call
MFXVideoVPP_Query to check the validity of the parameters for vpp
session, use the corrected values to initialize the session.

[1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/API_ref/VPL_func_vid_vpp.html#mfxvideovpp-query

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-06-20 09:52:43 +08:00
Haihao Xiang
5189b51939 lavfi/qsvvpp: copy metadata fields from src to dst
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-06-20 09:52:43 +08:00
Haihao Xiang
07139b6deb lavfi/qsvvpp: track the runtime version in vpp context
We may check whether a feature is supported via the runtime version in
future.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2023-06-20 09:52:43 +08:00
Paul B Mahol
ea190b8a23 avfilter/vf_drawtext: use flags type of option for text_align 2023-06-19 22:35:53 +02:00
yethie
01420316d2 avfilter/vf_drawtext: add support for commands 2023-06-19 22:35:53 +02:00
yethie
692d37d2e9 avfilter/vf_drawtext: add y_align option
The new y_align option specifies if the user provided y value
is referred to the top of the text, to the font baseline or to the
top of the font
2023-06-19 22:35:53 +02:00
yethie
5f2d907de2 avfilter/vf_drawtext: implement text alignment
Text can now be aligned vertically (top, middle, bottom) and horizontally (left, center, right)
relative to the background box.
2023-06-19 22:35:53 +02:00
yethie
01d843f6d0 avfilter/vf_drawtext: add expression variables to control font ascent/descent
The following new variables can be used in the x and y expressions: font_a, font_d, top_a, bottom_d.
2023-06-19 22:35:53 +02:00
yethie
fac7bb06d8 avfilter/vf_drawtext: add options for size of the background box 2023-06-19 22:35:53 +02:00
yethie
79e39978d8 avfilter/vf_drawtext: extend boxborderw option
Adds support for different border size in each direction.
2023-06-19 22:35:53 +02:00
yethie
1eeb59a209 avfilter/vf_drawtext: improve glyph shaping and positioning
- text is now shaped using libharfbuz
- glyphs position is now accurate to 1/4 pixel in both directions
- the default line height is now the one defined in the font

Adds libharfbuzz dependency.
2023-06-19 22:35:52 +02:00
yethie
ba00ed33e5 avfilter/vf_drawtext: cosmetics 2023-06-19 22:35:52 +02:00
Paul B Mahol
8e21f32fe7 avfilter/vf_displace: add support for commands 2023-06-18 11:11:46 +02:00
Paul B Mahol
54dc06e09e avfilter/vf_displace: add slice threading support 2023-06-18 11:11:46 +02:00
Paul B Mahol
494ebfdbfa avfilter/af_drmeter: misc cleanups 2023-06-18 02:21:29 +02:00
Paul B Mahol
238ec0c31b avfilter/af_drmeter: fix error in picking 2nd peak 2023-06-18 02:21:29 +02:00
Paul B Mahol
c44fe10160 avfilter/af_afade: stop using ff_outlink_get_status on inputs 2023-06-17 22:36:31 +02:00
Paul B Mahol
a756ae41ed avfilter/af_apad: switch to activate
Fixes EOF PTS reporting.
Also allowing previous/next filters in graph to release no longer needed resources.
2023-06-17 21:33:01 +02:00
Paul B Mahol
4583a24c65 avfilter/vf_xfade: add reveal transitions 2023-06-17 19:48:10 +02:00
Paul B Mahol
8fe25b1203 avfilter/vf_xfade: add cover transitions 2023-06-17 19:48:09 +02:00
Philip Langdale
73a2252f1d avfilter/vf_bwdif_cuda: CUDA accelerated bwdif deinterlacer
I've been sitting on this for 3 1/2 years now(!), and I finally got
around to fixing the loose ends and convincing myself that it was
correct. It follows the same basic structure as yadif_cuda, including
leaving out the edge handling, to avoid expensive branching.
2023-06-16 12:52:32 -07:00
Philip Langdale
3c07c2489d avfilter/scale_cuda: add support for rgb32/bgr32 conversions
As we are introducing two new formats and supporting conversions
between them, and also with the existing 0rgb32/0bgr32 formats, we get
a combinatorial explosion of kernels. I introduced a few new macros to
keep the things mostly managable.

The conversions are all simple, following existing patterns, with four
specific exceptions. When converting from 0rgb32/0bgr32 to rgb32/bgr32,
we need to ensure the alpha value is set to 1. In all other cases, it
can just be passed through, either to be used or ignored.
2023-06-16 10:40:21 -07:00
Paul B Mahol
12a073f72c avfilter/buffersrc: stop passing AV_NOPTS_VALUE on EOF 2023-06-16 11:46:09 +02:00