/* * Copyright © 2018, VideoLAN and dav1d authors * Copyright © 2018, Two Orioles, LLC * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "common/frame.h" #include "src/thread_task.h" #include "src/fg_apply.h" // This function resets the cur pointer to the first frame theoretically // executable after a task completed (ie. each time we update some progress or // insert some tasks in the queue). // When frame_idx is set, it can be either from a completed task, or from tasks // inserted in the queue, in which case we have to make sure the cur pointer // isn't past this insert. // The special case where frame_idx is UINT_MAX is to handle the reset after // completing a task and locklessly signaling progress. In this case we don't // enter a critical section, which is needed for this function, so we set an // atomic for a delayed handling, happening here. Meaning we can call this // function without any actual update other than what's in the atomic, hence // this special case. static inline int reset_task_cur(const Dav1dContext *const c, struct TaskThreadData *const ttd, unsigned frame_idx) { … } static inline void reset_task_cur_async(struct TaskThreadData *const ttd, unsigned frame_idx, unsigned n_frames) { … } static void insert_tasks_between(Dav1dFrameContext *const f, Dav1dTask *const first, Dav1dTask *const last, Dav1dTask *const a, Dav1dTask *const b, const int cond_signal) { … } static void insert_tasks(Dav1dFrameContext *const f, Dav1dTask *const first, Dav1dTask *const last, const int cond_signal) { … } static inline void insert_task(Dav1dFrameContext *const f, Dav1dTask *const t, const int cond_signal) { … } static inline void add_pending(Dav1dFrameContext *const f, Dav1dTask *const t) { … } static inline int merge_pending_frame(Dav1dFrameContext *const f) { … } static inline int merge_pending(const Dav1dContext *const c) { … } static int create_filter_sbrow(Dav1dFrameContext *const f, const int pass, Dav1dTask **res_t) { … } int dav1d_task_create_tile_sbrow(Dav1dFrameContext *const f, const int pass, const int cond_signal) { … } void dav1d_task_frame_init(Dav1dFrameContext *const f) { … } void dav1d_task_delayed_fg(Dav1dContext *const c, Dav1dPicture *const out, const Dav1dPicture *const in) { … } static inline int ensure_progress(struct TaskThreadData *const ttd, Dav1dFrameContext *const f, Dav1dTask *const t, const enum TaskType type, atomic_int *const state, int *const target) { … } static inline int check_tile(Dav1dTask *const t, Dav1dFrameContext *const f, const int frame_mt) { … } static inline int get_frame_progress(const Dav1dContext *const c, const Dav1dFrameContext *const f) { … } static inline void abort_frame(Dav1dFrameContext *const f, const int error) { … } static inline void delayed_fg_task(const Dav1dContext *const c, struct TaskThreadData *const ttd) { … } void *dav1d_worker_task(void *data) { … }