Commit Graph

881 Commits

Author SHA1 Message Date
Anton Khirnov
0aada80e73 fftools/ffmpeg_filter: keep track of filtergraph input timebase
Will be useful in following commits.
2023-05-02 10:59:24 +02:00
Anton Khirnov
04f0c40c74 fftools/ffmpeg_filter: add InputFilter private data
Move InputFilter.frame_queue to it, which is not accessed outside of
ffmpeg_filter.
2023-05-02 10:59:24 +02:00
Anton Khirnov
1dcae45ecb fftools/ffmpeg_filter: factorize allocating InputFilter 2023-05-02 10:59:24 +02:00
Anton Khirnov
87ced7aee0 fftools/ffmpeg_filter: make graph_desc private
It is not used outside of ffmpeg_filter.
2023-05-02 10:59:24 +02:00
Anton Khirnov
09dd9c5f41 fftools/ffmpeg_filter: add filtergraph private data
Start by moving OutputStream.filtered_frame to it, which really belongs
to the filtergraph rather than the output stream.
2023-05-02 10:59:24 +02:00
Anton Khirnov
aee5b774bf fftools/ffmpeg_filter: make ifilter_parameters_from_frame() static
It is no longer used outside of this file.
2023-05-02 10:59:24 +02:00
Anton Khirnov
38c937e8c4 fftools/ffmpeg: drop undocumented runtime debug-setting
This feature is of highly questionable usefulness and - as the comment
in the code says - is not actually supported by the API.
2023-05-02 10:59:24 +02:00
Anton Khirnov
7e3eb24123 fftools/ffmpeg: move OutputStream.packets_encoded to Encoder
It is no longer used outside of ffmpeg_enc.
2023-05-02 10:59:24 +02:00
Anton Khirnov
6e487a50a1 fftools/ffmpeg: drop OutputStream.error
Only the first component is used in update_video_stats(), so make it a
stack variable in that function.
2023-05-02 10:59:24 +02:00
Anton Khirnov
52b632b65b fftools/ffmpeg: drop OutputStream.pict_type
It is no longer used outside of update_video_stats(), so make it a stack
variable in that function.
2023-05-02 10:59:24 +02:00
Anton Khirnov
f4a60b8ddc fftools/ffmpeg: reduce access to OutputStream.enc_ctx
It will be made private to Encoder in the future.
2023-05-02 10:59:24 +02:00
Anton Khirnov
5a04aae821 fftools/ffmpeg: deprecate -adrift_threshold
This option has had no effect since -async was removed in
3d86a13b47
2023-05-02 10:59:24 +02:00
James Almer
1b7c13e1a4 fftools/ffmpeg_filter: fix leak of AVIOContext in read_binary()
It was only being freed on failure.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-28 13:46:13 -03:00
Anton Khirnov
11872522b1 fftools/ffmpeg_filter: reindent after previous commit 2023-04-24 16:56:06 +02:00
Anton Khirnov
cc7a8ddf56 fftools/ffmpeg: move freeing a filtergraph into a separate function 2023-04-24 16:56:06 +02:00
Anton Khirnov
eb9ce9de3b fftools/ffmpeg: move filtering functions to ffmpeg_filter 2023-04-24 16:56:06 +02:00
Anton Khirnov
0add05bd3a fftools/ffmpeg_mux_init: rename init_output_filter() to ost_add_from_filter()
The previous name is misleading, because the function does not actually
initialize any filters - it creates a new output stream and binds a
filtergraph output to it.
2023-04-24 16:56:06 +02:00
Anton Khirnov
4800b50258 fftools/ffmpeg: simplify init_output_filter() 2023-04-24 16:56:06 +02:00
Anton Khirnov
ea4c42779b fftools/ffmpeg_mux_init: drop a redundant assignment
OutputFilter.format is initialized in ofilter_alloc().
2023-04-24 16:56:06 +02:00
Anton Khirnov
8b56480652 fftools/ffmpeg_filter: add a function for creating a filtergraph
Code creating a new filtergraph is currently duplicated in 3 places.
This commit unifies it and moves towards making filtergraphs more
self-contained.
2023-04-24 16:56:06 +02:00
Anton Khirnov
2104de13e9 fftools/ffmpeg: reindent after previous commit 2023-04-24 16:56:06 +02:00
Anton Khirnov
6cace17b0d fftools/ffmpeg_mux_init: drop useless new_stream_{data,unknown}
Their only function is checking that encoding was not specified for
data/unknown-type streams, but the check is broken because enc_ctx will
not be created in ost_add() unless a valid encoder can be found.

Add an actually working check for all types for which encoding is not
supported in choose_encoder().
2023-04-24 16:56:06 +02:00
Anton Khirnov
ab0d2052a3 fftools/ffmpeg: remove unused function arguments 2023-04-24 16:56:06 +02:00
Anton Khirnov
ecb44ca877 fftools/ffmpeg_mux_init: drop OutputStream.filters[_script]
They are not needed outside of ost_get_filters(), so make them stack
variables there.
2023-04-24 16:56:06 +02:00
Anton Khirnov
84e1e0fa73 fftools/ffmpeg_mux_init: move check for mixing simple/complex filters
Do it in ost_get_filters() together with other similar checks. Will be
useful in following commits.

Also, improve the log message.
2023-04-24 16:56:06 +02:00
Anton Khirnov
0fe5eaf69d fftools/ffmpeg_mux_init: consolidate handling -filter for audio/video 2023-04-24 16:56:06 +02:00
Anton Khirnov
03a465be57 fftools/ffmpeg: replace stream timebase with packet one where appropriate 2023-04-24 16:56:06 +02:00
Anton Khirnov
65b1350ad4 fftools/ffmpeg: stop setting InputStream.pts for streamcopy
It is not used in that case anymore.
Forgotten in d56652fdc8.
2023-04-24 16:56:06 +02:00
Anton Khirnov
d8bc37f1f4 fftools/ffmpeg: stop using InputStream.pts in ts_discontinuity_detect()
ts_discontinuity_detect() is applied right after demuxing, while
InputStream.pts is a post-decoding timestamp, which may be delayed with
respect to demuxing by an arbitrary amount (e.g. depending on the thread
count when frame threading is used).
2023-04-24 16:56:06 +02:00
Anton Khirnov
37547e3acd fftools/ffmpeg_enc: move handling final frames to video_sync_process()
This code properly belongs there.
2023-04-24 16:56:06 +02:00
Anton Khirnov
403088cb67 fftools/ffmpeg_enc: rename next_picture to frame
The name is misleading, because it is not a picture in the sense of MPEG
terminology (which define "picture" as "frame or field"), but always a
full frame. 'next' is also redundant and/or misleading, because it is
the _current_ frame to be encoded.
2023-04-24 16:56:06 +02:00
Anton Khirnov
c94e9d03b4 fftools/ffmpeg_enc: always use video frame durations when available
Previously they would only be used with trivial filtergraphs, because
filters did not handle frame durations. That is no longer true - most
filters process frame durations properly (there may still be some that
don't - this change will help finding and fixing them).

Improves output video frame durations in a number of FATE tests.
2023-04-24 16:56:06 +02:00
Anton Khirnov
385430592a fftools/ffmpeg_filter: drop unused AUTO_INSERT_FILTER_INPUT() 2023-04-24 16:56:06 +02:00
Anton Khirnov
a664ec94e0 fftools/ffmpeg_filter: drop write-only FilterGraph.reconfiguration 2023-04-24 16:56:06 +02:00
Anton Khirnov
87b4453ec6 fftools/ffmpeg: stop printing PSNR information in status report
When an encoder exports sum-of-squared-differences information in
encoded packets, print_report() will print PSNR information in the
status line. However,
* the code computing PSNR assumes 8bit 420 video and prints incorrect
  values otherwise; there are no issues on trac about this
* only a few encoders (namely aom, vpx, mpegvideo, snow) export this
  information; other often-used encoders such as libx26[45] do not
  export this, even though they could

This suggests that this feature is not useful and it is better to remove
it rather than spend effort on fixing it.
2023-04-24 16:53:59 +02:00
Sil Vilerino
5ff1430452 fftools/ffmpeg_opt: Document VAAPI -device usage for DirectX Adapter
Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/

Signed-off-by: Sil Vilerino <sivileri@microsoft.com>
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
2023-04-24 13:24:41 +08:00
Zhao Zhili
b56aca9b42 fftools/ffmpeg_mux: fix reporting muxer EOF as error
Fix #10327.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-23 21:23:11 +08:00
James Almer
0e1745774e fftools/ffprobe: fix printing AVFrame.crop_right
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-21 09:25:53 -03:00
Anton Khirnov
c17e33c058 fftools/ffmpeg: propagate frame durations to packets when encoding
Remove now-obsolete code setting packet durations pre-muxing for CFR
encoded video.

Changes output in the following FATE tests:
* numerous adpcm tests
* ffmpeg-filter_complex_audio
* lavf-asf
* lavf-mkv
* lavf-mkv_attachment
* matroska-encoding-delay
  All of these change due to the fact that the output duration is now
  the actual input data duration and does not include padding added by
  the encoder.

* apng-osample: less wrong packet durations are now passed to the muxer.
  They are not entirely correct, because the first frame duration should
  be 3 rather than 2. This is caused by the vsync code and should be
  addressed later, but this change is a step in the right direction.
* tscc2-mov: last output frame has a duration of 11 rather than 1 - this
  corresponds to the duration actually returned by the demuxer.
* film-cvid: video frame durations are now 2 rather than 1 - this
  corresponds to durations actually returned by the demuxer and matches
  the timestamps.
* mpeg2-ticket6677: durations of some video frames are now 2 rather than
  1 - this matches the timestamps.
2023-04-19 21:12:03 +02:00
Anton Khirnov
af286f17a1 fftools/ffmpeg_enc: set audio frame duration when encoding 2023-04-19 21:12:03 +02:00
Anton Khirnov
9a44e0335c fftools/sync_queue: update audio frame duration when re-chunking 2023-04-19 21:12:03 +02:00
Anton Khirnov
0b0fa5c2a8 fftools/ffmpeg_enc: make data_size_enc private to encoding code
It is no longer used outside of ffmpeg_enc.c
2023-04-17 12:01:40 +02:00
Anton Khirnov
30699c103f fftools/ffmpeg_mux: make copy_initial_nonkeyframes private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov
7f8827f28e fftools/ffmpeg_mux: make copy_prior_start private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov
8763b9cc36 fftools/ffmpeg_mux: make streamcopy_started private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov
83646146fe fftools/ffmpeg_mux: make ts_copy_start private to muxing code
It is no longer used outside of ffmpeg_mux*
2023-04-17 12:01:40 +02:00
Anton Khirnov
3f11582ca3 fftools/ffmpeg_mux: stop using filter_in_rescale_delta_last for streamcopy
That field was added to store timestamp conversion state for audio
decoding code. Later it started being used by streamcopy as well, but
that use is wrong because, for a given input stream, both decoding and
an arbitrary number of streamcopies may be performed simultaneously.
They would then all overwrite the same state variable.

Store this state in MuxStream instead.

This is the last use of InputStream in of_streamcopy(), so the ist
parameter can now be removed.
2023-04-17 12:01:40 +02:00
Anton Khirnov
150c992490 fftools/ffmpeg_mux: use output stream parameters in of_streamcopy()
They should always be the same as the input stream parameters, but this
reduces the need to access InputStream in muxing code.
2023-04-17 12:01:40 +02:00
Anton Khirnov
2178ff2162 fftools/ffmpeg: move do_streamcopy() to ffmpeg_mux
do_streamcopy() is muxing code, so this is a more appropriate place for
this. The last uses of InputStream in it will be removed in following
commits.
2023-04-17 12:01:40 +02:00
Anton Khirnov
a34f483291 fftools/ffmpeg: add muxer-input codec parameters to OutputStream
It stores codec parameters of the stream submitted to the muxer, which
may be different from the codec parameters in AVStream due to bitstream
filtering.

This avoids the confusing back and forth synchronisation between the
encoder, bitstream filters, and the muxer, now information flows only in
one direction. It also reduces the need for non-muxing code to access
AVStream.
2023-04-17 12:01:40 +02:00