blob: c17053d9c2f929b8aeef6a1f4f20b920101a28a4 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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 Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AV1_DECODER_DTHREAD_H_
13#define AV1_DECODER_DTHREAD_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Yaowu Xuf883b422016-08-30 14:01:10 -070015#include "./aom_config.h"
16#include "aom_util/aom_thread.h"
17#include "aom/internal/aom_codec_internal.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070018
19#ifdef __cplusplus
20extern "C" {
21#endif
22
Yaowu Xuf883b422016-08-30 14:01:10 -070023struct AV1Common;
24struct AV1Decoder;
Yaowu Xuc27fc142016-08-22 16:08:15 -070025
26// WorkerData for the FrameWorker thread. It contains all the information of
27// the worker and decode structures for decoding a frame.
28typedef struct FrameWorkerData {
Yaowu Xuf883b422016-08-30 14:01:10 -070029 struct AV1Decoder *pbi;
Yaowu Xuc27fc142016-08-22 16:08:15 -070030 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 Xuf883b422016-08-30 14:01:10 -070052void av1_frameworker_lock_stats(AVxWorker *const worker);
53void av1_frameworker_unlock_stats(AVxWorker *const worker);
54void av1_frameworker_signal_stats(AVxWorker *const worker);
Yaowu Xuc27fc142016-08-22 16:08:15 -070055
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 Xuf883b422016-08-30 14:01:10 -070060void av1_frameworker_wait(AVxWorker *const worker, RefCntBuffer *const ref_buf,
61 int row);
Yaowu Xuc27fc142016-08-22 16:08:15 -070062
63// FrameWorker broadcasts its decoding progress so other workers that are
64// waiting on it can resume decoding.
Yaowu Xuf883b422016-08-30 14:01:10 -070065void av1_frameworker_broadcast(RefCntBuffer *const buf, int row);
Yaowu Xuc27fc142016-08-22 16:08:15 -070066
67// Copy necessary decoding context from src worker to dst worker.
Yaowu Xuf883b422016-08-30 14:01:10 -070068void av1_frameworker_copy_context(AVxWorker *const dst_worker,
69 AVxWorker *const src_worker);
Yaowu Xuc27fc142016-08-22 16:08:15 -070070
71#ifdef __cplusplus
72} // extern "C"
73#endif
74
Yaowu Xuf883b422016-08-30 14:01:10 -070075#endif // AV1_DECODER_DTHREAD_H_