Commit Graph

1564 Commits

Author SHA1 Message Date
Marvin Scholz
504c1ffcd8 fftools/ffmpeg: remove useless error check
When ret is checked here, it was never assigned anything, making this
check useless, as highlighted by Coverity.

It seems to be a copy paste mistake given that opt_match_per_stream_str
does not return an error code that could be checked and the previous
value assigned to ret is already checked above. So just remove this
check.

Fixes: CID1616292
2024-09-12 05:11:14 +02:00
Lynne
1709f3830e
fftools/opt_common: add missing newline after printing codecs
This fixes
ffmpeg -help bsf=trace_headers =>

Supported codecs: av1 h264 hevc vvc mjpeg mpeg2video vp8 vp9<no newline>
2024-09-09 13:03:04 +02:00
Niklas Haas
8517ff2082 fftools/ffmpeg_filter: remove YUVJ hack
This is no longer needed, since we now correctly negotiate the required
range from the mjpeg encoder via avcodec_get_supported_config().

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-08 13:59:29 +02:00
Niklas Haas
a850f80e2c fftools/ffmpeg_filter: propagate codec yuv metadata to filters
To convert between color spaces/ranges, if needed by the codec
properties.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-08 13:59:29 +02:00
Niklas Haas
33d5a4ec4e fftools/ffmpeg_filter: switch to avcodec_get_supported_config()
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-08 13:59:29 +02:00
Anton Khirnov
f3e265c690 fftools/ffmpeg_mux_init: factor out binding filters to output streams 2024-09-08 13:59:29 +02:00
Niklas Haas
7d6cd13ccb fftools/ffmpeg_filter: simplify choose_pix_fmts
The only meaningful difference between choose_pix_fmts and the default
code was the inclusion of an extra branch for `keep_pix_fmt` being true.

However, in this case, we either:
1. Force the specific `ofp->format` that we inherited from
   ofilter_bind_ost, or if no format was set:
2. Print an empty format list

Both of these goals can be accomplished by simply moving the decision
logic to ofilter_bind_ost, to avoid setting any format list when
keep_pix_fmt is enabled. This is arguably cleaner as it moves format
selection logic to a single function. In the case of branch 1, nothing
else needs to be done as we already force the format provided in
ofp->format, if any is set. Add an assertion to verify this assumption
just in case.

(Side note: The "choose_*" family of functions are arguably misnomers,
as they should really be called "print_*" - their current behavior is to
print the relevant format lists to the `vf/af_format` filter arguments)

Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Niklas Haas <git@haasn.dev>
2024-09-08 13:59:29 +02:00
Niklas Haas
7b0eca1e51 fftools/ffmpeg_mux_init: switch to avcodec_get_supported_config() 2024-09-08 13:59:29 +02:00
Niklas Haas
377652da19 fftools: drop unused/hacky macros
Having macros initialize local variables seems strange to me, and there
are no more current users of these macros. (The one that was commented
out was incorrect anyway, since the macro has changed in the meantime)
2024-09-08 13:59:29 +02:00
Niklas Haas
69b8405482 fftools/opt_common: switch to avcodec_get_supported_config()
While rewriting this macro, I decided to make it a bit more flexible so
it can work for all of the fields (including future fields) in a more
generic way, and to also print the channel layout using an AVBPrint to
avoid hard-coding the assumption that the length is less than 128
characters.
2024-09-08 13:59:29 +02:00
Nicolas Gaullier
ee9ae4e8ba fftools/ffmpeg: Fix honor -r output option with streamcopy
Fix "ost->st->avg_frame_rate = ost->frame_rate" in streamcopy_init()
being reset to input's frame rate a few lines below.
Note that in current code, there are some discrepancies amongst the
muxers. For example, avienc relies on time_base, so it is not affected
by this patch, whereas mxfenc and matroskaenc do use avg_frame_rate,
so this patch fixes -r being honored.

In the updated fate test, the input is (wrongly) probed as 50fps. With
this patch, the correct value (25fps) is successfully forced with -r.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-04 13:01:37 +02:00
Zhao Zhili
523189c744 fftools/ffplay: handle flip in display matrix
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-08-24 00:26:59 +08:00
Jan Garcia via ffmpeg-devel
598f541ba4 fftools/ffmpeg: show video stats in progress output without filters
Since ffmpeg 6.1 video stats are accidentally hidden from streamcopy progress output.
This patch re-enables video stats (like frames=) in the progress output.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-08-14 15:17:58 +02:00
Anton Khirnov
9e3b5b8a26 fftools/ffmpeg: switch -map parsing to new stream specifier API
Makes optional map handling less hacky, fixes combining optional maps
with metadata matching on tags/values containing the '?' character/

Forward errors from stream specifier parsing, previously the code would
ignore them.
2024-08-13 10:28:54 +02:00
Anton Khirnov
d1bdd89c2f fftools/ffmpeg: use new stream specifier API in opt_match_per_stream*()
Removes a lot of error checking code, as matching cannot fail.
2024-08-13 10:28:54 +02:00
Anton Khirnov
46cbe4ab5c fftools/cmdutils: split stream specifier parsing and matching
This approach has the major advantage that only parsing can fail (due to
a malformed specifier or memory allocation failure). Since parsing is
done generically, while matching is per-option, this will allow to
remove substantial amounts of error checking code in following commits.

The new code also explicitly allows stream specifiers to be followed by
additional characters, which should allow cleaner handling of optional
maps, i.e. -map <stream_specifier>?, which is currently implemented in a
hacky way that breaks when the stream specifier itself contains the '?'
character (this can happen when matching metadata). It will also allow
further extending the syntax, which will be useful in following commits.

This introduces some minor behaviour changes:
* Matching metadata tags now requires the ':' character in keys or
  values to be escaped. Previously it could not be present in keys, and
  would be used verbatim in values. The change is required in order to
  know where the value terminates.
* Multiple stream types in a single specifier are now rejected - such a
  specifier makes no sense.
* Non-existent stream group ID or index is now ignored with a warning
  rather than causing a failure. This is consistent with program
  handling and is required to make matching fail-free.
2024-08-13 10:28:54 +02:00
Anton Khirnov
e1b38680b7 fftools/cmdutils: put stream specifier handling back into cmdutils
Stream specifiers were originally designed exclusively for CLI use and
were not intended to be public API. Handling them in avformat places
major restrictions on how they are used. E.g. if ffmpeg CLI wishes to
override some stream parameters, it has to change the demuxer fields
(since avformat_match_stream_specifier() does not have access to
anything else). However, such fields are supposed to be read-only for
the caller.

Furthermore having this code in avformat restricts extending the
specifier syntax. An example of such an extension will be added in
following commits.
2024-08-13 10:28:54 +02:00
Anton Khirnov
93227a68f1 fftools/ffmpeg: replace remaining uses of MATCH_PER_STREAM_OPT() 2024-08-13 10:28:54 +02:00
Anton Khirnov
e218bde9f9 fftools/ffmpeg: replace MATCH_PER_STREAM_OPT(.., str, ..) with a function
This has multiple advantages:
* The macro has multiple parameters that often have similar or identical
  values, yet very different meanings (one is the name of the
  OptionsContext member where the parsed options are stored, the other
  the name of the variable into which the result is written); this
  change makes each of these explicit.

* The macro returns on failure, which may cause leaks - this was the
  reason for adding MATCH_PER_STREAM_OPT_CLEAN(), also ost_add()
  currently leaks encoder_opts. The new function returns failure to its
  caller, which decides how to deal with it. While that adds a lot of
  error checks/forwards for now, those will be reduced in following
  commits.

* new code is type- and const- correct

Invocations of MATCH_PER_STREAM_OPT() with other types will be converted
in following commits.
2024-08-13 10:28:54 +02:00
Niklas Haas
b5aeafc00a fftools/ffprobe: implement dv_md_compression 2024-07-28 12:20:07 +02:00
Anton Khirnov
d1fa39d08d fftools/ffmpeg: prefer real errors over EOF in err_merge()
Fixes an issue in 6.1 when reading a corrupted file with -xerror would
exit with success. This specific issue is not present in master, but
this should generally be a more robust behaviour.

Reported-by: Andrej Peterka
2024-07-24 08:20:21 +02:00
James Almer
2ff7d10c30 fftools/ffmpeg_filter: use the correct specifier for crop arguments
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-18 23:27:20 -03:00
James Almer
90672974bd fftools/ffmpeg_demux: don't insert the crop filter if frame cropping side data defines no cropping
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-18 09:50:36 -03:00
Gyan Doshi
350146a1ea ffmpeg: don't truncate getmaxrss value
Can lead to printing of nonsensical negative memory usage
2024-07-15 15:15:55 +05:30
Anton Khirnov
10185e2d4c fftools/ffmpeg_mux_init: default to input timebase for streamcopy
Stop trying to invent some "framerate-based" timebase when there is no
reason to think the stream is CFR at all.
2024-07-09 11:14:08 +02:00
Anton Khirnov
ff55d1cc20 fftools/ffmpeg_dec: improve detection of lavf-guessed durations
Will be useful in following commit.
2024-07-09 11:14:08 +02:00
James Almer
bf87688a9f fftools/ffmpeg: support applying container level cropping
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-08 13:30:24 -03:00
James Almer
d570457eb7 ffprobe: print Frame Cropping packet side data info
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-08 13:30:24 -03:00
James Almer
d241edc2b4 fftools/ffmpeg_opt: add missing codec type to some options
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-03 08:26:44 -03:00
Anton Khirnov
901f7e3f72 fftools/ffmpeg_mux_init: make encoder_opts local to ost_add()
It is no longer needed after this function returns.
2024-07-03 11:38:52 +02:00
Anton Khirnov
9a7686e545 fftools/ffmpeg_mux_init: apply encoder options manually
Do not pass an options dictionary to the avcodec_open2() in enc_open().

This is cleaner and more robust, as previously various bits of code
would try to interpret the contents of the options dictionary, with
varying degrees of correctness. Now they can just access the encoder
AVCodecContext directly.

Cf. 372c78dd42 - analogous change for
decoding.

A non-progressive field order is now written on the container level in
interlaced ProRes encoding tests.
2024-07-03 11:38:52 +02:00
Anton Khirnov
f1664aabb1 fftools/ffmpeg: rewrite checking whether codec AVOptions have been used
Share the code between encoding and decoding. Instead of checking every
stream's options dictionary (which is also used for other purposes),
track all used options in a dedicated dictionary.
2024-07-03 11:38:52 +02:00
Michael Niedermayer
4bca147415
fftools/ffplay: Check vulkan_params
Fixes: CID1550133 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:20 +02:00
Michael Niedermayer
ed364444f1
fftools/ffmpeg_sched: Remove dead assignments in sch_dec_send()
Fixes: CID1592383 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:20 +02:00
Michael Niedermayer
68f6063e04
fftools/ffmpeg_mux_init: Cleanup on error return in set_dispositions()
Fixes: CID1539099 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:19 +02:00
Michael Niedermayer
7b48360907
fftools/ffmpeg_mux: Remove unneeded initialization
Not sure this change makes sense, the code is more robust with ret set

Fixes: CID1559178 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:19 +02:00
Michael Niedermayer
935d9a5712
fftools/ffmpeg_enc: Initialize Decoder
Fixes: CID1591439 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:19 +02:00
Michael Niedermayer
462bd44b03
fftools/ffmpeg_enc: Initialize fd
Fixes: CID1520677 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:18 +02:00
Michael Niedermayer
97b2ab15de
fftools/ffmpeg_enc: simplify opaque_ref check
Found-while-revieweing: CID1520670 Dereference after null check

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:18 +02:00
Michael Niedermayer
34fd247c3b
fftools/ffmpeg: Check read() for failure
Fixes: CID1591932 Ignoring number of bytes read

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-02 21:57:17 +02:00
Timo Rothenpieler
6d4eba51f2 fftools/ffplay_renderer: use correct NULL value for Vulkan type 2024-06-25 00:19:03 +02:00
Lynne
dae12ddb2e
lavu/stereo3d: change the horizontal FOV field to a rational
This avoids hardcoding any implementation-specific limitiations as
part of the API, and allows for future expandability.

This also allows API users to more conveniently convert the
values into floats without hardcoding specific conversion constants.

The API was committed a few days ago, so changing this field now
is within the realms of acceptable.
2024-06-24 23:53:25 +02:00
James Almer
5140d8334e ffprobe: always print all Stereo3D fields
ffprobe is meant to generate parseable output, and if a field is present, it
should be printed even if it has a default value.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-20 17:02:44 -03:00
Derek Buitenhuis
049dfe3f65 fftools/ffprobe: Print more Stereo 3D info from side data
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-06-18 14:47:40 +01:00
Thomas Siedel
c75940db29 avcodec: add external enc libvvenc for H266/VVC
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,qpa,period,
passlogfile,stats,vvenc-params,level,tier.
Enable encoder by adding --enable-libvvenc in configure step.

Co-authored-by: Christian Bartnik chris10317h5@gmail.com
Signed-off-by: Thomas Siedel <thomas.ff@spin-digital.com>
2024-06-15 21:00:05 +08:00
Andreas Rheinhardt
6ae1a337f2 fftools/ffmpeg_mux_init: Fix leak when using non-encoding option
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-11 14:32:25 +02:00
Andreas Rheinhardt
c84e40d9e6 fftools/ffmpeg_mux_init: Return error upon error
Currently it may return an uninitialized value.
Introduced in 840f2bc18e.
Fixes Coverity issue #1603565.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-11 08:16:42 +02:00
Michael Niedermayer
840f2bc18e
fftools/ffmpeg_mux_init: Free pts on error
Fixes: CID1538863 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:26 +02:00
Michael Niedermayer
d9b9fc4be2
fftools/cmdutils: Add protective () to FLAGS
issue found while reviewing CID1452612 Free of array-typed value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-07 21:42:26 +02:00
Marton Balint
ed927f2f0c fftools/ffplay: allow unused format options which are also codec options
Same as it is handled in ffmpeg, allows using -ch_layout codec option.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-27 21:46:47 +02:00
Marton Balint
4d97557137 fftools/ffplay: use cmdutils code for checking remaining avoptions
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-27 21:46:47 +02:00
Marton Balint
f9810be5d3 fftools: move check_avoptions and remove_avoptions to cmdutils
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-27 21:46:47 +02:00
Marton Balint
4bfecde9b9 fftools/ffmpeg_demux: honor -ch_layout options for overriding input stream channel layout
The code only set the channel layout of the AVFormatContext, so the user could
not override the channel layout if the demuxer did not have such parameter.

This used to work via the respective AVCodecContext option, but since
639c2f0049 it no longer gets passed to the
decoders. It is actually better if we set it manually, instead of using the
codec option because that way we can also override it on the stream level, so
it will also work for stream copy or bitstream filtering.

We don't allow changing the number of channels, because that can cause
unexpected results. We disable layout guessing, if a channel layout is
specified.

Fixes ticket #11016.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-27 21:46:47 +02:00
Andreas Rheinhardt
62929f40ee fftools/ffmpeg_filter: Fix leak on error
Do this by attaching the FilterGraph directly to more permanent
storage from which it will be automatically freed.
Fixes Coverity issue #1596533.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 14:15:23 +02:00
Andreas Rheinhardt
f3d206d25f fftools, avfilter, avformat: Simplify check for "is dictionary empty?"
Reviewed-by: epirat07@gmail.com
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 13:52:41 +02:00
Michael Niedermayer
f44f441555
fftools/ffplay: Check return of swr_alloc_set_opts2()
This probably makes no difference but its more correct

Fixes: CID1503080 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-09 16:17:40 +02:00
Michael Niedermayer
ba7038043a
tools/opt_common: Check for malloc failure
Fixes: CID1539100 Negative loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-09 16:17:40 +02:00
Derek Buitenhuis
f8a613d6a8 fftools/ffprobe: Avoid overflow when calculating DAR
Both the codecpar's width and height, and the SAR num and den are
ints, which can overflow. Cast to int64_t, which is what av_reduce
takes.

Without this, occasionally, display_aspect_ratio can be negative in
ffprobe's -show_stream output.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-05-05 11:56:29 +01:00
Andreas Rheinhardt
4c8a6631ad fftools/ffmpeg_filter: Fix check
Fixes Coverity issues #1596529, #1596531.
Introduced in 8e35e33d42.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-27 17:00:12 +02:00
James Almer
8c27cdd2d4 fftools/ffmpeg_mux_init: add missing IAMF Param Definition copies
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-24 18:12:00 -03:00
James Almer
f684228407 fftools/ffmpeg_mux_init: remove leftover debug log messages
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-24 17:37:13 -03:00
James Almer
ecf87dd230 fftools/ffmpeg_mux_init: allow mapping a stream group from one of the inputs
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-23 23:54:46 -03:00
Zhao Zhili
1b41631185 fftools: Fix implicit-const-int-float-conversion warning
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-04-23 16:09:09 +08:00
Anton Khirnov
3bd7c57125 fftools/ffmpeg_filter: implement filtergraph chaining
This allows one complex filtergraph's output to be sent as input to
another one, which is useful in certain situations (one is described in
the docs).

Chaining filtergraphs was already effectively possible by using a
wrapped_avframe encoder connected to a loopback decoder, but it is ugly,
non-obvious and inefficient.
2024-04-09 10:34:18 +02:00
Anton Khirnov
255ae03601 fftools/ffmpeg_sched: allow filtergraphs to send to filtergraphs
Will be useful for filtergraph chaining that will be added in following
commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
3d01996b24 fftools/ffmpeg_filter: change processing order in fg_finalise_bindings()
First bind all inputs in all filtergraphs, only then check that all
outputs are bound.

Needed by the following commit.
2024-04-09 10:34:18 +02:00
Anton Khirnov
243a51490a fftools/ffmpeg_filter: only store complex filtergraphs in global array
Store simple filtergraphs in the stream they feed. Keeping the two
separate will be useful in following commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
d74cbcb963 fftools/ffmpeg_filter: drop OutputFilter.ost
All remaining code accessing it only needs to know whether this
filtergraph output has been bound or not.
2024-04-09 10:34:18 +02:00
Anton Khirnov
f2c919252d fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions
Stop digging through encoder options manually.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
bfeb751171 fftools/ffmpeg_mux: drop OutputFile.format
It is no longer used outside of the muxing code (where we can access the
muxer directly).
2024-04-09 10:34:18 +02:00
Anton Khirnov
5b0589c8c3 fftools/ffmpeg_mux: drop OutputFile.shortest
It is no longer needed outside of of_open() and its children.
2024-04-09 10:34:18 +02:00
Anton Khirnov
a4c940c86a fftools/ffmpeg_filter: move most of -apad logic to the muxer
The decision whether -apad actually does anything is made based on muxer
properties, and so more properly belongs there. Filtering code only
receives the result.
2024-04-09 10:34:18 +02:00
Anton Khirnov
a2892dbe06 fftools/ffmpeg_filter: pass trim parameters through OutputFilterOptions
Do not read them from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
83304f7c1f fftools/ffmpeg_filter: pass autoscale through OutputFilterOptions
Do not read it from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
b8e6802023 fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptions
Do not read them from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
23c23077fc fftools/ffmpeg_filter: drop an unnecessary use of OutputStream
OutputFilter.type contains the same information.
2024-04-09 10:34:18 +02:00
Anton Khirnov
fc6354c39c fftools/ffmpeg_filter: add an AVClass to OutputFilter
Use it for logging where appropriate, avoid logging to OutputStream as
we do not own it.

This is a step towards decoupling filtering from encoding.
2024-04-09 10:34:18 +02:00
Anton Khirnov
3c3e04c8a3 fftools/ffmpeg_filter: simplify retrieving filter type 2024-04-09 10:34:18 +02:00
Anton Khirnov
114cbaa316 fftools/ffmpeg_filter: drop a redundant check
fg_finalise_bindings() already checks that all filtergraph outputs are
connected.
2024-04-09 10:34:18 +02:00
Anton Khirnov
da80e0b077 fftools/ffmpeg_filter: accept a caller-provided output name
Do not construct it from OutputStream manually.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
82c7c21b18 fftools/ffmpeg: drop OutputStream.is_cfr
It is used in a single place in the filtering code, so it is better to
inline it there.
2024-04-09 10:34:18 +02:00
Anton Khirnov
509afedaaf fftools/ffmpeg_filter: pass vsync method through OutputFilterOptions
Do not read it from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
bc206ed1b3 fftools/ffmpeg_filter: stop accessing encoder AVCodecContext
Pass all the necessary value through OutputFilterOptions.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
17702c5f7b fftools/ffmpeg_filter: move the MJPEG format selection hack to muxer setup
That, if anywhere, is a more appropriate place for it.
2024-04-09 10:34:18 +02:00
Anton Khirnov
9d5bf2d69e fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions
Reduces the need to access OutputStream, which will allow decoupling
filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
606c71bb11 fftools/ffmpeg: warn about ignored -enc_time_base for subtitles earlier
Can do it as soon as that option is parsed, no need to postpone it until
opening the encoder.
2024-04-09 10:34:18 +02:00
Anton Khirnov
e903c31fd1 fftools/ffmpeg_filter: pass keep_pix_fmt through OutputFilterOptions
Reduces the need to access OutputStream, which will allow decoupling
filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
b3864e7a08 fftools/ffmpeg_filter: pass ts offset through OutputFilterOptions
Reduces the need to access OutputFile, which will allow decoupling
filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
651c79da36 fftools/ffmpeg_filter: check that filter type matches output stream type
For simple filtergraphs. For complex filtergraphs they always match.
2024-04-09 10:34:18 +02:00
Anton Khirnov
8e35e33d42 fftools/ffmpeg_filter: stop accessing AVCodecContext.codec
Instead pass the encoder through a newly-added output options struct,
analogous to previously added input options.

Will allow decoupling filtering from encoding in future commits.
2024-04-09 10:34:18 +02:00
Anton Khirnov
8c33085313 fftools/ffmpeg_filter: do not pass OutputStream to set_channel_layout()
It only needs a list of allowed layouts and the requested layout.
2024-04-09 10:34:18 +02:00
Andreas Rheinhardt
790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Anton Khirnov
24b9f29ff2 fftools/ffmpeg_sched: make sure to always run task cleanup
Even in cases where sch_start() failed. This ensures all links are
properly closed and no tasks are left hanging.

Fixes #10916.
2024-03-29 08:51:12 +01:00
Anton Khirnov
af81788f30 fftools/ffmpeg_sched: move sch_stop() to the bottom of the file
Will allow avoiding forward declarations in following commits.
2024-03-29 08:51:12 +01:00
Andreas Rheinhardt
5d71f97e0e all: Don't use ATOMIC_VAR_INIT
C11 required to use ATOMIC_VAR_INIT to statically initialize
atomic objects with static storage duration. Yet this macro
was unsuitable for initializing structures [1] and was actually
unneeded for all known implementations (this includes our
compatibility fallback implementations which simply wrap the value
in parentheses: #define ATOMIC_VAR_INIT(value) (value)).
Therefore C17 deprecated the macro and C23 actually removed it [2].

Since commit 5ff0eb34d2 we default
to C17 if the compiler supports it; Clang warns about ATOMIC_VAR_INIT
in this mode. Given that no implementation ever needed this macro,
this commit stops using it to avoid this warning.

[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_485
[2]: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-28 09:12:48 +01:00
Anton Khirnov
a69cedb6a6 fftools/ffmpeg_demux: make InputStream.autorotate private
It is no longer accessed outside of ffmpeg_demux.
2024-03-28 08:40:11 +01:00
Anton Khirnov
c9a90c052a fftools/ffmpeg_enc: stop copying demuxer side data to the muxer
All side data should be propagated through the trancoding pipeline.
2024-03-28 08:40:11 +01:00
Anton Khirnov
106131bb10 fftools/ffmpeg_filter: remove display matrix if we have applied it 2024-03-28 08:40:01 +01:00
Anton Khirnov
b1aaa1f585 fftools/ffmpeg_dec: apply cropping manually
lavfi does not require aligned buffers, so we can safely apply top/left
cropping by any amount, without passing any special flags to lavc.
Longer term, an even better solution would probably be auto-inserting
the crop filter (or its hwaccel versions) as needed.

Multiple FATE tests no longer need -flags unaligned.
2024-03-28 08:40:01 +01:00
Anton Khirnov
0edbd00ccf fftools/ffmpeg_{demux,dec}: pass -bitexact through DecoderFlags
Avoids abusing AV_DICT_MULTIKEY and relying on undocumented AVDictionary
ordering behaviour.
2024-03-28 08:40:01 +01:00