Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AV1_DECODER_DTHREAD_H_ |
| 13 | #define AV1_DECODER_DTHREAD_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | #include "./aom_config.h" |
| 16 | #include "aom_util/aom_thread.h" |
| 17 | #include "aom/internal/aom_codec_internal.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 23 | struct AV1Common; |
| 24 | struct AV1Decoder; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | |
| 26 | // WorkerData for the FrameWorker thread. It contains all the information of |
| 27 | // the worker and decode structures for decoding a frame. |
| 28 | typedef struct FrameWorkerData { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | struct AV1Decoder *pbi; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 30 | const uint8_t *data; |
| 31 | const uint8_t *data_end; |
| 32 | size_t data_size; |
| 33 | void *user_priv; |
| 34 | int result; |
| 35 | int worker_id; |
| 36 | int received_frame; |
| 37 | |
| 38 | // scratch_buffer is used in frame parallel mode only. |
| 39 | // It is used to make a copy of the compressed data. |
| 40 | uint8_t *scratch_buffer; |
| 41 | size_t scratch_buffer_size; |
| 42 | |
| 43 | #if CONFIG_MULTITHREAD |
| 44 | pthread_mutex_t stats_mutex; |
| 45 | pthread_cond_t stats_cond; |
| 46 | #endif |
| 47 | |
| 48 | int frame_context_ready; // Current frame's context is ready to read. |
| 49 | int frame_decoded; // Finished decoding current frame. |
| 50 | } FrameWorkerData; |
| 51 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 52 | void av1_frameworker_lock_stats(AVxWorker *const worker); |
| 53 | void av1_frameworker_unlock_stats(AVxWorker *const worker); |
| 54 | void av1_frameworker_signal_stats(AVxWorker *const worker); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 55 | |
| 56 | // Wait until ref_buf has been decoded to row in real pixel unit. |
| 57 | // Note: worker may already finish decoding ref_buf and release it in order to |
| 58 | // start decoding next frame. So need to check whether worker is still decoding |
| 59 | // ref_buf. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 60 | void av1_frameworker_wait(AVxWorker *const worker, RefCntBuffer *const ref_buf, |
| 61 | int row); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 62 | |
| 63 | // FrameWorker broadcasts its decoding progress so other workers that are |
| 64 | // waiting on it can resume decoding. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 65 | void av1_frameworker_broadcast(RefCntBuffer *const buf, int row); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 66 | |
| 67 | // Copy necessary decoding context from src worker to dst worker. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 68 | void av1_frameworker_copy_context(AVxWorker *const dst_worker, |
| 69 | AVxWorker *const src_worker); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 70 | |
| 71 | #ifdef __cplusplus |
| 72 | } // extern "C" |
| 73 | #endif |
| 74 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 75 | #endif // AV1_DECODER_DTHREAD_H_ |