Commit Graph

935 Commits

Author SHA1 Message Date
Anton Khirnov
7b41785eb6 fftools/ffmpeg: replace stream timebase with decoded frame one
They are the same for now, but this may change in the future.
2023-05-22 17:10:44 +02:00
Anton Khirnov
1372e81aaa fftools/ffmpeg: drop a useless local variable
Store decoded frame timestamp directly in AVFrame.pts, there is no
advantage to using a separate local variable for it.
2023-05-22 17:10:44 +02:00
Anton Khirnov
94a9647195 fftools/ffmpeg: shorten a variable name
There is only one frame used in decode_video() -- the one output by the
decoder. So there is no point in explicitly calling it the _decoded_
frame.
2023-05-22 17:10:44 +02:00
Anton Khirnov
7be945a011 fftools/ffmpeg: rename transcode_init()
It does no initialization anymore, except for setting
transcode_init_done - the bulk of the function is printing the
input/output maps. It also cannot fail anymore, so remove the useless
return value.
2023-05-15 13:32:02 +02:00
Anton Khirnov
de6d60117e fftools/ffmpeg_demux: stop logging to demuxer context
Only the demuxer itself should do that.
2023-05-15 13:32:02 +02:00
Anton Khirnov
c5d77dcbf1 fftools/ffmpeg_demux: move InputFile.ts_offset_discont,last_ts to private data
They are no longer used outside of ffmpeg_demux.
2023-05-15 13:32:02 +02:00
Anton Khirnov
ab223a4d8c fftools/ffmpeg: stop accessing input format from decoding code
Export the corresponding flag in InputFile instead. This will allow
making the demuxer AVFormatContext private in future commits, similarly
to what was previously done for muxers.
2023-05-15 13:32:02 +02:00
Anton Khirnov
2ab9f247f7 fftools/ffmpeg: log corrupt-frame errors to the appropriate context 2023-05-15 13:32:02 +02:00
Anton Khirnov
a1002bc39c fftools/ffmpeg: replace print_error() by more meaningful messages 2023-05-15 13:32:01 +02:00
Anton Khirnov
fd980b2615 fftools/ffmpeg_demux: reindent after previous commit 2023-05-15 13:32:01 +02:00
Anton Khirnov
9429624a76 fftools/ffmpeg: move discarding unused programs to ffmpeg_demux
This is a more appropriate place for this code.
2023-05-15 13:32:01 +02:00
Anton Khirnov
f9657b7443 fftools/ffmpeg: simplify tracking -readrate start time
There is no point in having a per-stream wallclock start time, since
they are all computed at the same instant. Keep a per-file start time
instead, initialized when the demuxer thread starts.
2023-05-15 13:32:01 +02:00
Anton Khirnov
6b0c984f0d fftools/ffmpeg_demux: move InputStream.streamcopy_needed to private data
It is no longer used outside of ffmpeg_demux.
2023-05-15 13:32:01 +02:00
Anton Khirnov
7df3253c5a fftools/ffmpeg_demux: move InputStream.wrap_correction_done to private data
It is no longer used outside of ffmpeg_demux.
2023-05-15 13:32:01 +02:00
Anton Khirnov
df25e21ce7 fftools/ffmpeg_demux: move InputStream.[next_]dts to private data
They are no longer used outside of ffmpeg_demux.
2023-05-15 13:32:01 +02:00
Anton Khirnov
6d7b43ed44 fftools/ffmpeg_demux: move InputStream.[saw_]first_d?ts to private data
They are no longer used outside of ffmpeg_demux.
2023-05-15 13:32:01 +02:00
Anton Khirnov
57a2b2f886 fftools/ffmpeg_demux: move InputStream.{nb_packets,data_size} to private data
They are no longer used outside of ffmpeg_demux.
2023-05-15 13:32:01 +02:00
Anton Khirnov
6fcfe4307c fftools/ffmpeg: drop unused decode_video() parameter 2023-05-15 13:32:01 +02:00
Anton Khirnov
bfd5e7ef5d fftools/ffmpeg_demux: reindent after previous commit 2023-05-15 13:32:01 +02:00
Anton Khirnov
2b99c6bfd5 fftools/ffmpeg: move post-demux packet processing to ffmpeg_demux
That is a more appropriate place for this code and will allow hiding
more of InputStream.

The value of repeat_pict extracted from libavformat internal parser no
longer needs to be trasmitted outside of the demuxing thread.

Move readrate handling to the demuxer thread. This has to be done in the
same commit, since it reads InputStream.dts,nb_packets, which are now
set in the demuxer thread.
2023-05-15 11:03:15 +02:00
Anton Khirnov
09c686788e fftools/ffmpeg: attach InputStream.dts to demuxed packets when needed
This way computing it and using it for streamcopy does not need to
happen in sync. Will be useful in following commits, where updating
InputStream.dts will be moved to the demuxing thread.
2023-05-15 10:57:19 +02:00
Anton Khirnov
abf9532bda fftools/ffmpeg_demux: move preparing DemuxMsg to separate function
Will be useful in following commits, which will move more code into this
function.
2023-05-15 10:57:19 +02:00
Anton Khirnov
989e87b03c fftools/ffmpeg: stop using decoder properties in ist_dts_update()
This code runs post-demuxing and is not synchronized with the decoder
output (which may be delayed with respect to its input by arbitrary and
unknowable amounts), so accessing any decoder properties is incorrect.
2023-05-15 10:57:19 +02:00
Anton Khirnov
0d25b404d4 fftools/ffmpeg: reindent after previous commit 2023-05-15 10:57:19 +02:00
Anton Khirnov
702ff2d281 fftools/ffmpeg: consolidate InputStream.[next_]dts updates
Move them to a separate function called right after timestamp
discontinuity processing. This is now possible, since these values have
no interaction with decoding anymore.
2023-05-15 10:57:19 +02:00
Anton Khirnov
a238ba9c3c fftools/ffmpeg: stop using deprecated ticks_per_frame 2023-05-15 10:56:48 +02:00
Anton Khirnov
78e84c054a fftools/ffmpeg: fix computing video frame duration from repeat_pict
This field contains the number of _field_ durations by which the
standard frame duration should be extended.
2023-05-15 10:31:55 +02:00
Anton Khirnov
02823210d7 fftools/opt_common: stop printing deprecated AV_CODEC_CAP_SUBFRAMES 2023-05-15 10:24:54 +02:00
James Almer
63d7ea38c7 fftools/ffprobe: print exported stream AVOptions
Similar to the decoder AVOptions, this is useful to show values from options
exported by the demuxer.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-08 11:04:37 -03:00
Anton Khirnov
2d43c23b81 fftools/ffmpeg: discard packets for unused streams in demuxing thread
Avoids the pointless overhead of transferring them to the main thread.
2023-05-08 10:38:59 +02:00
Anton Khirnov
a0174a235b fftools/ffmpeg_filter: use InputFilterPriv.eof instead of InputFile.eof_reached
The two checks using eof_reached are testing whether more input can
possibly appear on this filtergraph input. InputFilterPriv.eof is the
more authoritative source for this information.
2023-05-08 10:38:59 +02:00
Anton Khirnov
dd1c67d539 fftools/ffmpeg: move unconfigured graph handling to ffmpeg_filter
This code more properly belongs there.
2023-05-08 10:38:59 +02:00
Anton Khirnov
c26a6c5a52 fftools/ffmpeg_filter: use av_buffer_replace() to improve code
It is shorter and more efficient.
2023-05-08 10:38:59 +02:00
Anton Khirnov
5356f5ed23 fftools/ffmpeg_filter: move InputFilter.hw_frames_ctx to private data
It is not used outside of ffmpeg_filter.
2023-05-08 10:38:59 +02:00
Anton Khirnov
71d7e9bbec fftools/ffmpeg_filter: move InputFilter.displaymatrix to private data
It is not used outside of ffmpeg_filter.
2023-05-08 10:38:59 +02:00
Anton Khirnov
e8df737cb2 fftools/ffmpeg_filter: move InputFilter.eof to private data
It is not used outside of ffmpeg_filter.
2023-05-08 10:38:59 +02:00
Anton Khirnov
c7c73a3250 fftools/ffmpeg_filter: take fallback parameters from decoder, not demuxer
When an input stream terminates and no frames were successfully decoded,
filtering code will currently configure the filtergraph using demuxer
stream parameters. Use decoder parameters instead, which should be more
reliable. Also, initialize them immediately when an input stream is
bound to a filtergraph input, so that these parameters are always
available (if at all) and filtering code does not need to reach into the
decoder at some arbitrary later point.
2023-05-08 10:38:59 +02:00
Anton Khirnov
48d8d3549a fftools/ffmpeg_enc: stop configuring filter inputs from encoder flush
When no frames are ever seen by an encoder, encoder flush will do a
last-ditch attempt to configure its source filtergraph in order to at
least get the stream parameters. This involves extracting demuxer
parameters from filtergraph source inputs, which is
* a bad layering violation
* probably unreachable, because decoders are flushed before encoders,
  which should call ifilter_send_eof(), which will also set these
  parameters; however due to complex control flow it is hard to be
  entirely sure this code can never be triggered

Even if this code can actually be reached, it is probably better to
return an error as the comment above it says.
2023-05-08 10:38:59 +02:00
Anton Khirnov
f5cfb2c5df fftools/ffmpeg: eliminate need_output()
Replace it by simply calling choose_output() earlier.
2023-05-08 10:38:58 +02:00
Anton Khirnov
5673da4797 fftools/ffmpeg: merge choose_output() and got_eagain()
These two functions are a part of a single logical action - determining
which, if any, output stream needs to be processed next. Keeping them
separate is a historical artifact that obscures what is actually being
done.
2023-05-08 10:38:58 +02:00
Anton Khirnov
0e00d23510 fftools/ffmpeg: reduce -re to -readrate 1
They are exactly equivalent, so there is no point in maintaining a
separate flag for -re.
2023-05-07 15:49:27 +02:00
Anton Khirnov
007ec49db8 fftools/ffmpeg: use a non-zero default for -readrate_initial_burst
Use it to replace a hack added in 6f20685228.
2023-05-07 15:49:21 +02:00
Davy Durham
2ae16b05d6 fftools/ffmpeg: add ability to set a input burst time before readrate is enforced
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-05-07 15:48:15 +02:00
James Almer
c7a8681860 fftools: use the new AVFrame keyframe flag
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 19:19:18 -03:00
James Almer
3675dd0e0c fftools: use the new AVFrame interlace flags
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:15:00 -03:00
Anton Khirnov
129c7bf53f fftools/ffmpeg: always use the same path for setting InputStream.[next_]dts
Currently those are set in different ways depending on whether the
stream is decoded or not, using some values from the decoder if it is.
This is wrong, because there may be arbitrary amount of delay between
input packets and output frames (depending e.g. on the thread count when
frame threading is used).

Always use the path that was previously used only for streamcopy. This
should not cause any issues, because these values are now used only for
streamcopy and discontinuity handling.

This change will allow to decouple discontinuity processing from
decoding and move it to ffmpeg_demux. It also makes the code simpler.

Changes output in fate-cover-art-aiff-id3v2-remux and
fate-cover-art-mp3-id3v2-remux, where attached pictures are now written
in the correct order. This happens because InputStream.dts is no longer
reset to AV_NOPTS_VALUE after decoding, so streamcopy actually sees
valid dts values.
2023-05-02 10:59:24 +02:00
Anton Khirnov
3190bed148 fftools/ffmpeg: constify packets passed to decode*()
They are not modified by these functions.
2023-05-02 10:59:24 +02:00
Anton Khirnov
302aecd06a fftools/ffmpeg: drop InputStream.[next_]pts
They are no longer used for anything.
2023-05-02 10:59:24 +02:00
Anton Khirnov
ae95cd85dc fftools/ffmpeg_filter: stop using InputStream.pts for filter EOF ts
Use InputStream.last_frame_pts/duration instead, which is more accurate.
2023-05-02 10:59:24 +02:00
Anton Khirnov
ef69f6a9d2 fftools/ffmpeg: stop using InputStream.pts for generating video timestamps
This was added in 380db56928 as a
temporary crutch that is not needed anymore. The only case where this
code can be triggered is the very first frame, for which InputStream.pts
is always equal to 0.
2023-05-02 10:59:24 +02:00