Commit Graph

380 Commits

Author SHA1 Message Date
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 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 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 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 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 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 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
James Almer 0963ef4996 fftools/ffmpeg_filter: remove prototype for non existent function
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-25 23:23:27 -03:00
Anton Khirnov a9193f7b7d fftools/ffmpeg: add loopback decoding
This allows to send an encoder's output back to decoding and feed the
result into a complex filtergraph.
2024-03-13 08:01:27 +01:00
Anton Khirnov 2ee9362419 fftools/ffmpeg: remove unncessary casts for *_thread() return values
These functions used to be passed directly to pthread_create(), which
required them to return void*. This is no longer the case, so they can
return a plain int.
2024-03-13 08:01:15 +01:00
Anton Khirnov f5d03b972c fftools/ffmpeg: simplify propagating fallback parameters from decoders to filters
Current callstack looks like this:
* ifilter_bind_ist() (filter) calls ist_filter_add() (demuxer);
* ist_filter_add() opens the decoder, and then calls
  dec_add_filter() (decoder);
* dec_add_filter() calls ifilter_parameters_from_dec() (i.e. back into
  the filtering code) in order to give post-avcodec_open2() parameters
  to the filter.

This is unnecessarily complicated. Pass the parameters as follows
instead:
* dec_init() (which opens the decoder) returns post-avcodec_open2()
  parameters to its caller (i.e. the demuxer) in a parameter-only
  AVFrame
* the demuxer passes these parameters to the filter in
  InputFilterOptions, together with other filter options
2024-03-13 08:01:15 +01:00
Anton Khirnov 7b51523f12 fftools/ffmpeg_opt: merge init_complex_filters() and check_filter_outputs()
The first of these binds inputs of complex filtergraphs to demuxer
streams (with a misleading comment claiming it *creates* complex
filtergraphs).

The second ensures that all filtergraph outputs are connected to an
encoder.

Merge them into a single function, which simplifies the ffmpeg_filter
API, is shorter, and will also be useful in following commits.

Also, rename misleadingly-named init_input_filter() to
fg_complex_bind_input().
2024-03-13 08:01:15 +01:00
Anton Khirnov c4de5778bc fftools/ffmpeg_dec: factor opening the decoder out of dec_open()
Rename dec_open to dec_init(), as it is more descriptive of its new
purpose.

Will be useful in following commits, which will add a new path for
opening decoders.
2024-03-13 08:01:15 +01:00
Anton Khirnov e48055fdce fftools/ffmpeg: remove options deprecated before 6.0 2024-03-01 16:51:11 +01:00
Anton Khirnov 6b6815b1c8 fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user 2024-02-21 10:31:27 +01:00
Anton Khirnov 826cfd9997 fftools/ffmpeg_filter: pass framerate through InputFilterOptions
Rather than read it directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
2024-02-21 10:27:20 +01:00
Anton Khirnov fef3052df3 fftools/ffmpeg_filter: pass autorotate/reinit flags through InputFilterOptions
Rather than read them directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
2024-02-21 10:27:20 +01:00
Anton Khirnov 6315f78e0c fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions
Rather than read them directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
2024-02-21 10:27:20 +01:00
Anton Khirnov bd3c1c194b fftools/ffmpeg_filter: accept a name from its upstream input
Do not construct the name manually from input file/stream indices.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
2024-02-21 10:27:20 +01:00
Anton Khirnov 8f592eb35f fftools/ffmpeg_filter: compute input trim start/end in demuxer
The computation is based on demuxer properties, so that is the more
appropriate place for it. Filter code just receives the desired
start time/duration.
2024-02-21 10:27:20 +01:00
Andreas Rheinhardt 44620ade25 fftools/ffmpeg_mux_init: Fix attachment_filename use-after-free
The filename is freed with the OptionsContext and therefore
there will be a use-after-free when reporting the filename
in print_stream_maps(). So create a copy of the string.

This is a regression since 8aed3911fc.
fate-lavf-mkv_attachment exhibits it (and reports a random nonsense
filename here), but this does not make the test fail (not even with
valgrind; only with ASAN, as it aborts on use-after-free).

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-18 18:09:33 +01:00
Anton Khirnov 093be1fb06 fftools/ffmpeg: cosmetics, vertically align Input{File,Stream} 2024-01-30 09:52:00 +01:00
Anton Khirnov f4b76a1d6a fftools/ffmpeg: make InputStream.decoder_opts private to demuxer
It is no longer used outside of ffmpeg_demux.
2024-01-30 09:52:00 +01:00
Anton Khirnov 01c71b78eb fftools/ffmpeg: make InputStream.decoding_needed private to demuxer
It is no longer used outside of ffmpeg_demux.
2024-01-30 09:52:00 +01:00
Anton Khirnov 0d00e2e2f7 fftools/ffmpeg_dec: eliminate all remaining InputStream uses
Previously, the demuxer would register decoder with the scheduler, using
InputStream as opaque, and pass the scheduling index to the decoder.

Now the registration is done by the decoder itself, using DecoderPriv as
opaque, and the scheduling index is returned to demuxer from dec_open().

decoder_thread() then no longer needs to be accessed from outside of
ffmpeg_dec and can be made static.
2024-01-30 09:52:00 +01:00
Anton Khirnov fe3be6f78f fftools/ffmpeg_dec: stop passing InputStream to dec_open() 2024-01-30 09:52:00 +01:00
Anton Khirnov 1b2c539a0f fftools/ffmpeg_dec: pass AVCodecParameters through DecoderOpts
Do not retrieve it from InputStream directly.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov b3d1916ba0 fftools/ffmpeg_dec: pass AVCodec through DecoderOpts
Do not retrieve it from InputStream directly.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov 097f9ddbe9 fftools/ffmpeg_dec: pass decoder name through DecoderOpts
Do not build it from InputStream values.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov 9ba4bc87e6 fftools/ffmpeg_dec: pass top_field_first through DecoderOpts
Do not read it from InputStream directly.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov 9702817662 fftools/ffmpeg_dec: pass input timebase through DecoderOpts
Do not read it from AVStream directly.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov 052c83e356 fftools/ffmpeg_dec: pass forced/estimated framerate though DecoderOpts
Stop reading them from InputStream.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov e0a6cb07b2 fftools/ffmpeg_dec: move flags to DecoderOpts
Will be useful in the following commit.
2024-01-30 09:52:00 +01:00
Anton Khirnov 4bdffec814 fftools/ffmpeg_dec: pass hwaccel options to the decoder in a separate struct
Stop reading them from InputStream.

This is a step towards decoupling Decoder and InputStream.
2024-01-30 09:52:00 +01:00
Anton Khirnov a3a9c4ae66 fftools/ffmpeg: move hwaccel_retrieve_data() from ffmpeg_hw to ffmpeg_dec
This function is decoding-only and has no interaction with the rest of
ffmpeg_hw. It thus belongs more properly in ffmpeg_dec.
2024-01-30 09:52:00 +01:00