1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

fftools/ffmpeg_sched: add a function to remove a filtergraph from the scheduler

For the purpose of merging streams in a stream group, a filtergraph can't be
created once we know it will be used. Therefore, allow filtergraphs to be
removed from the scheduler after being added.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-10-18 20:08:49 -03:00
parent c751ad2c36
commit cce85642c9
2 changed files with 25 additions and 0 deletions

View File

@@ -405,6 +405,9 @@ static int task_start(SchTask *task)
{
int ret;
if (!task->parent)
return 0;
av_log(task->func_arg, AV_LOG_VERBOSE, "Starting thread...\n");
av_assert0(!task->thread_running);
@@ -454,6 +457,23 @@ static int64_t trailing_dts(const Scheduler *sch, int count_finished)
return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
}
void sch_remove_filtergraph(Scheduler *sch, int idx)
{
SchFilterGraph *fg = &sch->filters[idx];
av_assert0(!fg->task.thread_running);
memset(&fg->task, 0, sizeof(fg->task));
tq_free(&fg->queue);
av_freep(&fg->inputs);
fg->nb_inputs = 0;
av_freep(&fg->outputs);
fg->nb_outputs = 0;
fg->task_exited = 1;
}
void sch_free(Scheduler **psch)
{
Scheduler *sch = *psch;
@@ -2630,6 +2650,9 @@ static int task_stop(Scheduler *sch, SchTask *task)
int ret;
void *thread_ret;
if (!task->parent)
return 0;
if (!task->thread_running)
return task_cleanup(sch, task->node);

View File

@@ -205,6 +205,8 @@ int sch_add_dec_output(Scheduler *sch, unsigned dec_idx);
int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs,
SchThreadFunc func, void *ctx);
void sch_remove_filtergraph(Scheduler *sch, int idx);
/**
* Add a muxer to the scheduler.
*