Commit Graph

20 Commits

Author SHA1 Message Date
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 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 432e287e27 fftools/ffmpeg_sched: Explicitly return 0 on sch_enc_send() success
Do not return the return value of the last enc_send_to_dst()
call, as this would treat the last call differently from the
earlier calls; furthermore, sch_enc_send() explicitly documents
to always return 0 on success.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-28 03:06:13 +01:00
Mark Thompson 7f4b8d2f5e ffmpeg: set extra_hw_frames to account for frames held in queues
Since e0da916b8f the ffmpeg utility has
held multiple frames output by the decoder in internal queues without
telling the decoder that it is going to do so.  When the decoder has a
fixed-size pool of frames (common in some hardware APIs where the output
frames must be stored as an array texture) this could lead to the pool
being exhausted and the decoder getting stuck.  Fix this by telling the
decoder to allocate additional frames according to the queue size.
2024-03-19 22:56:56 +00:00
Andreas Rheinhardt 78e2be2377 fftools/ffmpeg_sched: Remove set-but-unused variable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 22:53:45 +01:00
Anton Khirnov efab83c156 fftools/ffmpeg_sched: allow connecting encoder output to decoders 2024-03-13 08:01:15 +01:00
Anton Khirnov da17c4d24a fftools/ffmpeg_sched: factor initializing nodes into separate function
Will be useful in following commits.
2024-03-13 08:01:15 +01:00
Anton Khirnov 6ccbff2631 fftools/ffmpeg_sched: allow encoders to send to multiple destinations
Will become useful in following commits.
2024-03-13 08:01:15 +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 c19c2078f3 fftools/ffmpeg_sched: remove a triggerable assert in send_to_enc_sq()
It can be triggered when send_to_enc_thread() returns AVERROR(ENOMEM).
Propagate the error to the caller instead.

Reported-by: Andreas Rheinhardt
2024-02-24 11:51:41 +01:00
Anton Khirnov a00765fcbe fftools/ffmpeg_sched: simplify failure path in sch_dec_send() 2024-02-24 11:51:41 +01:00
Anton Khirnov e0da916b8f fftools/ffmpeg: optimize inter-thread queue sizes
Use 8 packets/frames by default rather than 1, which seems to provide
better throughput.

Allow -thread_queue_size to set the muxer queue size manually again.
2024-01-28 13:34:56 +01:00
Anton Khirnov 00013341df fftools/ffmpeg_sched: add filter API to signal EOF on input 2024-01-27 09:24:29 +01:00
Anton Khirnov 5c5140ded2 fftools/ffmpeg_sched: track dts+duration as last_dts
This should be slightly (probably negligibly) more accurate for
scheduling, but mainly it improves the final reported time.

Reported-by: Paul B Mahol
2023-12-14 20:16:54 +01:00
Anton Khirnov 2305091a3a fftools/ffmpeg: update the reported timestamp at the end
Reported-by: microchip
2023-12-14 20:16:54 +01:00
Anton Khirnov 98d706b818 fftools/ffmpeg_sched: move trailing_dts() higher up
Will be useful in following commit.
2023-12-14 20:16:54 +01:00
Anton Khirnov 06d5dc11db fftools/ffmpeg_sched: actually initialize/destroy schedule_lock 2023-12-14 10:16:39 +01:00
James Almer 7cc4b306eb ffmpeg_sched: initialize have_unchoked
Should fix valgrind warnings about Conditional jump or move depends on uninitialised value.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-12-12 16:10:28 -03:00
Anton Khirnov 9b8cc36ce0 fftools/ffmpeg: add thread-aware transcode scheduling infrastructure
See the comment block at the top of fftools/ffmpeg_sched.h for more
details on what this scheduler is for.

This commit adds the scheduling code itself, along with minimal
integration with the rest of the program:
* allocating and freeing the scheduler
* passing it throughout the call stack in order to register the
  individual components (demuxers/decoders/filtergraphs/encoders/muxers)
  with the scheduler

The scheduler is not actually used as of this commit, so it should not
result in any change in behavior. That will change in future commits.
2023-12-12 08:24:18 +01:00