Commit Graph

11622 Commits

Author SHA1 Message Date
Gyan Doshi
b5daaa1503 avfilter/formats: correct error message
The check is for color space, not range.
2024-09-01 10:10:16 +05:30
Zhao Zhili
2e370805da avfilter/unsharp: Merge header into .c
It was shared with opencl implementation.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-08-26 16:58:25 +08:00
Gnattu OC
30f090b4f8 avfilter: inherit input color range for videotoolbox filters
The color range should be set to match the input when creating
the VideoToolbox context. Otherwise, the new context will default
to limited range, creates inconsistencies with full range inputs.

Signed-off-by: Gnattu OC <gnattuoc@me.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-08-24 00:24:06 +08:00
Anton Khirnov
52471b56ba lavfi: make FFFilterContext private to generic code
Nothing in it needs to be visible to filters.
2024-08-19 21:48:11 +02:00
Anton Khirnov
f19c988911 lavfi/filters: move functions only used by generic code to avfilter_internal.h 2024-08-19 21:48:11 +02:00
Anton Khirnov
6d75d44d90 lavfi: drop internal.h
All that remains in it are things that belong in avfilter_internal.h.

Move them there and remove internal.h
2024-08-19 21:48:04 +02:00
Anton Khirnov
90e4af65e1 lavfi/f_streamselect: remove a no-op ff_filter_config_links() call
It does not do anything when the links are already configured.
2024-08-19 21:45:25 +02:00
Anton Khirnov
a2314308f2 lavfi/inernal: move ff_fmt_is_regular_yuv() declaration to video.h 2024-08-19 21:45:25 +02:00
Anton Khirnov
a83a30e899 lavfi: move ff_parse_{sample_rate,channel_layout}() to audio.[ch]
That is a more appropriate place for those functions.
2024-08-19 21:45:25 +02:00
Anton Khirnov
f4bfdf7893 lavfi: move ff_parse_pixel_format() to vf_format, its only caller
The only thing this function does beyond calling av_get_pix_fmt() is
falling back onto parsing the argument as a number. No other filters
should need to do this.
2024-08-19 21:45:25 +02:00
Anton Khirnov
1afe42852b lavfi/internal: move functions used by filters to filters.h
internal.h currently mixes interfaces intended to be used by filters
with those that should be limited to generic filter- or graph-level
code.
2024-08-19 21:45:25 +02:00
James Almer
211c88b9d5 avfilter/f_zmq: fix graph argument
Fixes regression since d566a37003.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-08-16 09:53:22 -03:00
Niklas Haas
f1071dc634 avfilter/vf_zscale: remove unused fields 2024-08-16 11:43:37 +02:00
Niklas Haas
c8bc6fabd7 avfilter/vf_scale: fix 4:1:0 interlaced chroma pos
The current logic hard-coded a check for v_sub == 1. We can extend this
logic slightly to cover the case of interlaced 4:1:0 (which has v_sub ==
2).

Here is a diagram explaining this scenario (with center-siting):

a   a   a   a   a   a   a   a

b   b   b   b   b   b   b   b
      X               X
a   a   a   a   a   a   a   a

b   b   b   b   b   b   b   b

a   a   a   a   a   a   a   a

b   b   b   b   b   b   b   b
      Y               Y
a   a   a   a   a   a   a   a

b   b   b   b   b   b   b   b

a = even luma rows
b = odd luma rows
X = even chroma sample
Y = odd chroma sample

In progressive mode, the chroma samples sit at (384, 384) respectively.

Relative to the 8x4 grid of even luma samples (a), the X sample sits at:
  h_chr_pos = 384
  v_chr_pos = 192

Relative to the 8x4 grid of odd luma samples (b), the Y sample sits at:
  h_chr_pos = 384
  v_chr_pos = 576

The new code calculates the correct values in all circumstances.
2024-08-16 11:43:37 +02:00
Niklas Haas
15a67c0947 avfilter/vf_scale: add in/out_chroma_loc
Currently, this just functions as a more principled and user-friendly
replacement for the (undocumented and hard to use) *_chr_pos fields.

However, the goal is to automatically infer these values from the input
frames' chroma location, and deprecate the manual use of *_chr_pos
altogether. (Indeed, my plans for an swscale replacement will most
likely also end up limiting the set of legal chroma locations to those
permissible by AVFrame properties)
2024-08-16 11:43:37 +02:00
Niklas Haas
18b9687308 avfilter/swscale: always fix interlaced chroma location
The current logic only fixes it when the user does not explicitly
specify the chroma location. However, this does not make a lot of sense.
Since there is no way to specify this property per-field, it effectively
*prevents* the user from being able to correctly scale interlaced frames
with top-aligned chroma.

It makes more sense to consider the user setting in the progressive case
only, and automatically adapt it to the correct interlaced field
positions, following the details of the MPEG specification.
2024-08-16 11:43:37 +02:00
Niklas Haas
5d964df5da avfilter/vf_setparams: remove unnecessary options bounds
AV_OPT_TYPE_CONST does not use min/max, we can leave them as 0.
2024-08-16 11:43:37 +02:00
Niklas Haas
201f1cba15 avfilter/vf_setparams: allow setting chroma location
Shockingly, there isn't currently _any_ filter for overriding this.
2024-08-16 11:43:37 +02:00
Lynne
a797317ab1
vulkan_filter: don't require the storage flag for the base frames format
We check for whether subformats support storage immediately below.
Those are the ones we require storage for, rather than the base format
itself.

This permits better reuse of AVHWFrame contexts.

The patch also removes an always-false check in the subformat check.
2024-08-16 01:22:17 +02:00
Lynne
b165f144e7
vulkan_filter: allow reusing frame contexts with DRM tiling
There's no reason not to permit this, particularly if a user wants
to manipulate images which will be exported back to DRM.
2024-08-16 01:22:17 +02:00
Lynne
18d964fc2c
vulkan: enable encoding of images if video_maintenance1 is enabled
Vulkan encoding was designed in a very... consolidated way.
You had to know the exact codec and profile that the image was going to
eventually be encoded as at... image creation time. Unfortunately, as good
as our code is, glimpsing into the exact future isn't what its capable of.

video_maintenance1 removed that requirement, which only then made encoding
images practically possible.
2024-08-16 01:22:16 +02:00
Anton Khirnov
d566a37003 lavfi: move AVFilterLink.graph to FilterLink 2024-08-15 19:34:27 +02:00
Anton Khirnov
fb3efef1db lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternal 2024-08-15 19:34:27 +02:00
Anton Khirnov
42cbf66fff lavfi: move AVFilterLink.{frame,sample}_count_{in,out} to FilterLink 2024-08-15 19:34:27 +02:00
Anton Khirnov
a23d565ea7 lavfi: move AVFilterLink.frame_rate to FilterLink
Co-developed-by: James Almer <jamrial@gmail.com>
2024-08-15 19:34:27 +02:00
Anton Khirnov
d6318a244d lavfi: move AVFilterLink.current_pts(_us) to FilterLink 2024-08-15 19:34:27 +02:00
Anton Khirnov
7f17e0e6dd lavfi: move AVFilterLink.hw_frames_ctx to FilterLink 2024-08-15 19:34:24 +02:00
Anton Khirnov
ce24b5ba8f lavfi/vf_*_cuda: do not access hw contexts before checking they exist
The checks are performed in init_processing_chain().
2024-08-15 19:27:01 +02:00
Anton Khirnov
99ee7a948f lavfi: move AVFilterLink.m{ax,in}_samples to FilterLink
Also, document who sets these fields and when.
2024-08-15 19:27:01 +02:00
Anton Khirnov
54754eec1e lavfi: add a new struct for private link properties
Specifically those that should be visible to filters, but hidden from
API callers. Such properties are currently located at the end of the
public AVFilterLink struct, demarcated by a comment marking them as
private. However it is generally better to hide them explicitly, using
the same pattern already employed in avformat or avcodec.

The new struct is currently trivial, but will become more useful in
following commits.
2024-08-15 19:27:01 +02:00
Anton Khirnov
426e33c758 lavfi: set AVFilterLink.graph on link creation
There is no reason to delay this.
2024-08-15 19:27:01 +02:00
James Almer
41307ff3e9 avfilter/video: don't zero allocated buffers if memory poisoning is used
Same as in avcodec/get_buffer.c
Should help in debugging use of uninitialized memory.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-08-12 11:41:38 -03:00
Michael Niedermayer
b98125e5a5
avfilter/vf_xfade: Compute w2, h2 with float
Fixes: CID1458148 Result is not floating-point
Fixes: CID1458149 Result is not floating-point
Fixes: CID1458150 Result is not floating-point
Fixes: CID1458151 Result is not floating-point
Fixes: CID1458152 Result is not floating-point
Fixes: CID1458154 Result is not floating-point
Fixes: CID1458155 Result is not floating-point
Fixes: CID1458156 Result is not floating-point

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-11 13:21:14 +02:00
Michael Niedermayer
f802d65de0
avfilter/vf_v360: Assert that vf was initialized
Maybe helps: CID1504571 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-11 13:21:13 +02:00
Michael Niedermayer
9229587c2d
avfilter/vf_unsharp_opencl: Use AV_VIDEO_MAX_PLANES
Related: CID1423281 Out-of-bounds read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-11 13:21:13 +02:00
Michael Niedermayer
e5c0f56ca0
avfilter/vf_tonemap_opencl: Dereference after NULL check
Fixes: CID1437472 Dereference before null check

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-11 13:21:13 +02:00
Michael Niedermayer
22ee55a1da
avfilter/af_surround: Check output format
Fixes: CID1516994 Out-of-bounds access
Fixes: CID1516996 Out-of-bounds access
Fixes: CID1516999 Out-of-bounds access

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-11 13:21:12 +02:00
Michael Niedermayer
43b62b7e0c
avfilter/vf_xfade_opencl: Check ff_inlink_consume_frame() for failure
Fixes: CID1458127 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-08-11 13:21:12 +02:00
Lynne
12080ff040
nlmeans_vulkan: fix uninitialized reads 2024-08-11 05:13:17 +02:00
Lynne
12f868cab5
vulkan_shaderc: add debug information to shaders 2024-08-11 05:13:13 +02:00
Lynne
2f7dfb0d15
vulkan_shaderc: fix error reporting for certain errors
The issue is that shaderc_result_get_num_errors may sometime
return 0 even when shaderc_result_get_compilation_status returns
a non-zero error code.
Since we use the result from the former, override the status
if it returned 0.
2024-08-11 05:13:12 +02:00
Rémi Denis-Courmont
f30e5bf1f5 lavfi/riscv: depend on RVB and simplify accordingly 2024-08-05 21:16:26 +03:00
Anton Khirnov
43f702a253 lavfi/framesync: avoid forcing frame writability unnecessarily
Callers of ff_framesync_get_frame() generally do not expect the result
to be writable, those that do (e.g. ff_framesync_dualinput_get_writable())
ensure writability themselves.

Significantly reduces memory consumption in complex graphs with
framesync-based filters (e.g. scale, ssim).

Reported-By: Mark Shwartzman
2024-07-31 11:12:45 +02:00
Rémi Denis-Courmont
b5c111272b lavfi/riscv: add forward-edge CFI landing pads 2024-07-25 23:10:14 +03:00
Rémi Denis-Courmont
9108f3e5e1 lavfi/riscv: require B or zba explicitly 2024-07-25 18:55:48 +03:00
Michael Niedermayer
73ca4e75eb
avfilter/vf_xfade: Check ff_inlink_consume_frame() for failure
Fixes: CID1458043 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 17:02:14 +02:00
Michael Niedermayer
2a8fb3c2cc
avfilter/vf_scale: Check ff_scale_adjust_dimensions() for failure
Helps: CID1513722 Operands don't affect result

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 16:34:31 +02:00
Michael Niedermayer
ad9df8bcfe
avfilter/scale_eval: Use 64bit, check values in ff_scale_adjust_dimensions()
Found by reviewing CID1513722 Operands don't affect result

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 16:34:30 +02:00
Michael Niedermayer
6db4e326c2
avfilter/vf_neighbor_opencl: Use AV_PIX_MAX_PLANES
Fix/Robustness/whatever: CID1439575 Out-of-bounds read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 16:34:29 +02:00
Michael Niedermayer
ace2e25720
avfilter/vf_lut3d: Check av_scanf()
Fixes: CID1604398 Unchecked return value
Fixes: CID1604542 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-21 16:34:28 +02:00