Commit Graph

20 Commits

Author SHA1 Message Date
Anton Khirnov
9630341073 fftools/ffmpeg: factor out attaching FrameData to a frame
Will be useful in following commits.
2023-06-05 16:15:04 +02:00
Anton Khirnov
f8abab673c fftools/ffmpeg: move sub2video handling to ffmpeg_filter
Make all relevant state per-filtergraph input, rather than per-input
stream. Refactor the code to make it work and avoid leaking memory when
a single subtitle stream is sent to multiple filters.
2023-05-31 16:20:19 +02:00
Anton Khirnov
5d530e3a72 fftools/ffmpeg_dec: move sub2video submission to ffmpeg_filter
This code is a sub2video analogue of ifilter_send_frame(), so it
properly belongs to the filtering code.

Note that using sub2video with more than one target for a given input
subtitle stream is currently broken and this commit does not change
that. It will be addressed in following commits.
2023-05-31 16:19:49 +02:00
Anton Khirnov
6abb4a28ef fftools/ffmpeg: add InputStream.index
This allows to avoid access to the underlying AVStream in many places.
2023-05-28 10:47:59 +02:00
Anton Khirnov
cad59cccaf fftools/ffmpeg_dec: move timestamp estimation state to Decoder
It is purely internal to decoding.
2023-05-28 10:47:59 +02:00
Anton Khirnov
5b05e9e32a fftools/ffmpeg_dec: move InputStream.pkt to Decoder
It is purely internal to decoding.
2023-05-28 10:47:59 +02:00
Anton Khirnov
dadeb28e25 fftools/ffmpeg_dec: add decoder private data
Move InputStream.decoded_frame to it.

Analogous to what has been previously done for all the other major
components.
2023-05-28 10:47:59 +02:00
Anton Khirnov
760a9bd306 fftools/ffmpeg_hw: move hw_device_setup_for_decode() to ffmpeg_dec
This function is entangled with decoder setup, so it is more decoding
code rather than ffmpeg_hw code. This will allow making more decoder
state private in the future.
2023-05-28 10:47:59 +02:00
James Almer
e86e2d5921 fftools/ffmpeg_dec: abort if avcodec_send_packet() returns EAGAIN
As the comment in the code mentions, EAGAIN is not an expected value here
because we call avcodec_receive_frame() until all frames have been returned.
avcodec_send_packet() returning EAGAIN means a packet is still buffered, which
hints that the underlying decoder is buggy and not fetching packets as it
should.

An example of this behavior was in the libdav1d wrapper before f209614290,
where feeding it split frames (or individual OBUs) would result in the CLI
eventually printing the confusing "Error submitting packet to decoder: Resource
temporarily unavailable" error message, and just keep going until EOF without
returning new frames.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-26 19:47:54 -03:00
Anton Khirnov
c894f85f72 fftools/ffmpeg_dec: rename decode_video() to video_frame_process()
This function does not do any decoding anymore.
2023-05-22 17:10:44 +02:00
Anton Khirnov
909f5dfae1 fftools/ffmpeg_dec: inline decode_audio() into dec_packet()
The former function is now trivial - it has 3 lines and cannot fail.
2023-05-22 17:10:44 +02:00
Anton Khirnov
959a5decf2 fftools/ffmpeg_dec: deduplicate code in decode_audio/video() 2023-05-22 17:10:44 +02:00
Anton Khirnov
ab3493006f fftools/ffmpeg_dec: merge check_decode_result() into its callers
Not only is this easier to read, this also makes the code shorter.
2023-05-22 17:10:44 +02:00
Anton Khirnov
c08717adae fftools/ffmpeg: reindent after previous commit 2023-05-22 17:10:44 +02:00
Anton Khirnov
748f2999ee fftools/ffmpeg_dec: restructure audio/video decoding loop
It currently emulates the long-removed
avcodec_decode_audio4/avcodec_decode_video2 APIs, which obfuscates the
actual decoding flow. Restructure the decoding calls so that they
naturally follow the new avcodec_send_packet()/avcodec_receive_frame()
design.

This is not only significantly easier to read, but also shorter.
2023-05-22 17:10:44 +02:00
Anton Khirnov
172f901e35 fftools/ffmpeg_dec: deobfuscate subtitle decoding
It is currently handled in the same loop as audio and video, but this
obscures the actual flow, because only one iteration is ever performed
for subtitles.

Also, avoid a pointless packet reference.
2023-05-22 17:10:44 +02:00
Anton Khirnov
dbf1c6f5f1 fftools/ffmpeg: move decoding code to ffmpeg_dec 2023-05-22 17:10:44 +02:00
Anton Khirnov
c8fa58430e fftools/ffmpeg_dec: drop useless abort_codec_experimental()
It does nothing beyond exit_program().
2023-04-17 12:01:40 +02:00
Anton Khirnov
503c705634 fftools/ffmpeg_dec: reindent after previous commit 2023-04-17 12:01:40 +02:00
Anton Khirnov
9ce1a041d8 fftools/ffmpeg: move opening decoders to a new file
All decoding code will be moved to this file in the future.
2023-04-17 12:01:40 +02:00