This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 0d123a3c23b8da2a6869976fd35fef24584a13c2 Author: Niklas Haas <[email protected]> AuthorDate: Tue May 5 15:27:05 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Sat May 23 08:41:12 2026 +0000 fftools/ffmpeg_sched: use macros for schedule_update_locked() loops Instead of awkwardly looping over the type, just split this up into multiple loops. The loss in complexity seems worth the loss in conciseness to me, and more importantly, this allows us to easily add more waiter types. Sponsored-by: nxtedition AB Signed-off-by: Niklas Haas <[email protected]> --- fftools/ffmpeg_sched.c | 68 +++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index dc5800d094..b01cf8b6ad 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -1424,12 +1424,17 @@ static void schedule_update_locked(Scheduler *sch) atomic_store(&sch->last_dts, progressing_dts(sch, 0)); // initialize our internal state - for (unsigned type = 0; type < 2; type++) - for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) { - SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter; - w->choked_prev = atomic_load(&w->choked); - w->choked_next = 1; - } +#define RESET_WAITER(field) \ + do { \ + for (unsigned i = 0; i < sch->nb_##field; i++) { \ + SchWaiter *w = &sch->field[i].waiter; \ + w->choked_prev = atomic_load(&w->choked); \ + w->choked_next = 1; \ + } \ + } while (0) + + RESET_WAITER(demux); + RESET_WAITER(filters); // figure out the sources that are allowed to proceed for (unsigned i = 0; i < sch->nb_mux; i++) { @@ -1466,28 +1471,35 @@ static void schedule_update_locked(Scheduler *sch) } // make sure to unchoke at least one source, if still available - for (unsigned type = 0; !have_unchoked && type < 2; type++) - for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) { - int exited = type ? sch->filters[i].task_exited : sch->demux[i].task_exited; - SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter; - if (!exited) { - w->choked_next = 0; - have_unchoked = 1; - break; - } - } - - for (unsigned type = 0; type < 2; type++) { - for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) { - SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter; - if (w->choked_prev != w->choked_next) { - waiter_set(w, w->choked_next); - if (!type) - choke_demux(sch, i, w->choked_next); - } - } - } - +#define UNCHOKE_ONCE(field) \ + do { \ + for (unsigned i = 0; !have_unchoked && i < sch->nb_##field; i++) { \ + SchWaiter *w = &sch->field[i].waiter; \ + if (!sch->field[i].task_exited) { \ + w->choked_next = 0; \ + have_unchoked = 1; \ + break; \ + } \ + } \ + } while (0) + + UNCHOKE_ONCE(demux); + UNCHOKE_ONCE(filters); + +#define UPDATE_WAITER(field) \ + do { \ + for (unsigned i = 0; i < sch->nb_##field; i++) { \ + SchWaiter *w = &sch->field[i].waiter; \ + if (w->choked_prev != w->choked_next) { \ + waiter_set(w, w->choked_next); \ + if (offsetof(Scheduler, field) == offsetof(Scheduler, demux)) \ + choke_demux(sch, i, w->choked_next); \ + } \ + } \ + } while (0) + + UPDATE_WAITER(demux); + UPDATE_WAITER(filters); } enum { _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
