You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
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.
This commit is contained in:
@@ -56,6 +56,9 @@ struct Encoder {
|
||||
int opened;
|
||||
int finished;
|
||||
|
||||
Scheduler *sch;
|
||||
unsigned sch_idx;
|
||||
|
||||
pthread_t thread;
|
||||
/**
|
||||
* Queue for sending frames from the main thread to
|
||||
@@ -113,7 +116,8 @@ void enc_free(Encoder **penc)
|
||||
av_freep(penc);
|
||||
}
|
||||
|
||||
int enc_alloc(Encoder **penc, const AVCodec *codec)
|
||||
int enc_alloc(Encoder **penc, const AVCodec *codec,
|
||||
Scheduler *sch, unsigned sch_idx)
|
||||
{
|
||||
Encoder *enc;
|
||||
|
||||
@@ -133,6 +137,9 @@ int enc_alloc(Encoder **penc, const AVCodec *codec)
|
||||
if (!enc->pkt)
|
||||
goto fail;
|
||||
|
||||
enc->sch = sch;
|
||||
enc->sch_idx = sch_idx;
|
||||
|
||||
*penc = enc;
|
||||
|
||||
return 0;
|
||||
@@ -217,8 +224,6 @@ static int set_encoder_id(OutputFile *of, OutputStream *ost)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *encoder_thread(void *arg);
|
||||
|
||||
static int enc_thread_start(OutputStream *ost)
|
||||
{
|
||||
Encoder *e = ost->enc;
|
||||
@@ -1001,7 +1006,7 @@ fail:
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static void *encoder_thread(void *arg)
|
||||
void *encoder_thread(void *arg)
|
||||
{
|
||||
OutputStream *ost = arg;
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
|
||||
Reference in New Issue
Block a user