aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_dec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-18 16:56:15 +0200
committerAnton Khirnov <anton@khirnov.net>2023-12-12 08:24:18 +0100
commit9b8cc36ce0b2417469d78c68780c8796886c202e (patch)
tree08e76a3dd3682ea98c4e05fe4a36b7f20ae2cb46 /fftools/ffmpeg_dec.c
parentee2a8cbfd14dab9a07f409ba322f405a633f84e7 (diff)
downloadffmpeg-9b8cc36ce0b2417469d78c68780c8796886c202e.tar.gz
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.
Diffstat (limited to 'fftools/ffmpeg_dec.c')
-rw-r--r--fftools/ffmpeg_dec.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index b60bad1220..90ea0d6d93 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -52,6 +52,9 @@ struct Decoder {
AVFrame *sub_prev[2];
AVFrame *sub_heartbeat;
+ Scheduler *sch;
+ unsigned sch_idx;
+
pthread_t thread;
/**
* Queue for sending coded packets from the main thread to
@@ -673,7 +676,7 @@ fail:
return AVERROR(ENOMEM);
}
-static void *decoder_thread(void *arg)
+void *decoder_thread(void *arg)
{
InputStream *ist = arg;
InputFile *ifile = input_files[ist->file_index];
@@ -1045,7 +1048,7 @@ static int hw_device_setup_for_decode(InputStream *ist)
return 0;
}
-int dec_open(InputStream *ist)
+int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx)
{
Decoder *d;
const AVCodec *codec = ist->dec;
@@ -1063,6 +1066,9 @@ int dec_open(InputStream *ist)
return ret;
d = ist->decoder;
+ d->sch = sch;
+ d->sch_idx = sch_idx;
+
if (codec->type == AVMEDIA_TYPE_SUBTITLE && ist->fix_sub_duration) {
for (int i = 0; i < FF_ARRAY_ELEMS(d->sub_prev); i++) {
d->sub_prev[i] = av_frame_alloc();