2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2014-03-06 21:08:20 +01:00
|
|
|
#ifndef VP9_DECODER_VP9_DECODER_H_
|
|
|
|
#define VP9_DECODER_VP9_DECODER_H_
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2014-03-03 23:34:39 +01:00
|
|
|
#include "./vpx_config.h"
|
|
|
|
|
|
|
|
#include "vpx/vpx_codec.h"
|
2015-07-17 23:09:05 +02:00
|
|
|
#include "vpx_dsp/bitreader.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_scale/yv12config.h"
|
2015-07-02 19:01:09 +02:00
|
|
|
#include "vpx_util/vpx_thread.h"
|
2015-07-01 23:58:13 +02:00
|
|
|
|
2015-02-06 19:03:31 +01:00
|
|
|
#include "vp9/common/vp9_thread_common.h"
|
2014-03-03 23:34:39 +01:00
|
|
|
#include "vp9/common/vp9_onyxc_int.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_ppflags.h"
|
2015-01-27 21:26:28 +01:00
|
|
|
#include "vp9/decoder/vp9_dthread.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2014-01-18 21:16:11 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-05-15 19:51:55 +02:00
|
|
|
// TODO(hkuang): combine this with TileWorkerData.
|
|
|
|
typedef struct TileData {
|
|
|
|
VP9_COMMON *cm;
|
2015-07-20 22:49:15 +02:00
|
|
|
vpx_reader bit_reader;
|
2014-05-15 19:51:55 +02:00
|
|
|
DECLARE_ALIGNED(16, MACROBLOCKD, xd);
|
2015-07-08 06:19:21 +02:00
|
|
|
/* dqcoeff are shared by all the planes. So planes must be decoded serially */
|
|
|
|
DECLARE_ALIGNED(16, tran_low_t, dqcoeff[32 * 32]);
|
2014-05-15 19:51:55 +02:00
|
|
|
} TileData;
|
|
|
|
|
2015-01-06 23:14:26 +01:00
|
|
|
typedef struct TileWorkerData {
|
2015-01-27 21:26:28 +01:00
|
|
|
struct VP9Decoder *pbi;
|
2015-07-20 22:49:15 +02:00
|
|
|
vpx_reader bit_reader;
|
2015-01-31 02:00:54 +01:00
|
|
|
FRAME_COUNTS counts;
|
2015-01-06 23:14:26 +01:00
|
|
|
DECLARE_ALIGNED(16, MACROBLOCKD, xd);
|
2015-07-08 06:19:21 +02:00
|
|
|
/* dqcoeff are shared by all the planes. So planes must be decoded serially */
|
|
|
|
DECLARE_ALIGNED(16, tran_low_t, dqcoeff[32 * 32]);
|
2015-01-06 23:14:26 +01:00
|
|
|
struct vpx_internal_error_info error_info;
|
|
|
|
} TileWorkerData;
|
|
|
|
|
2014-04-08 20:41:12 +02:00
|
|
|
typedef struct VP9Decoder {
|
2014-03-03 23:34:39 +01:00
|
|
|
DECLARE_ALIGNED(16, MACROBLOCKD, mb);
|
|
|
|
|
|
|
|
DECLARE_ALIGNED(16, VP9_COMMON, common);
|
|
|
|
|
|
|
|
int ready_for_new_data;
|
|
|
|
|
|
|
|
int refresh_frame_flags;
|
|
|
|
|
2014-06-12 01:06:50 +02:00
|
|
|
int frame_parallel_decode; // frame-based threading.
|
|
|
|
|
2015-01-27 21:26:28 +01:00
|
|
|
// TODO(hkuang): Combine this with cur_buf in macroblockd as they are
|
|
|
|
// the same.
|
|
|
|
RefCntBuffer *cur_buf; // Current decoding frame buffer.
|
|
|
|
|
2015-07-02 01:32:48 +02:00
|
|
|
VPxWorker *frame_worker_owner; // frame_worker that owns this pbi.
|
|
|
|
VPxWorker lf_worker;
|
|
|
|
VPxWorker *tile_workers;
|
2014-08-31 05:15:37 +02:00
|
|
|
TileWorkerData *tile_worker_data;
|
|
|
|
TileInfo *tile_worker_info;
|
2014-03-03 23:34:39 +01:00
|
|
|
int num_tile_workers;
|
|
|
|
|
2014-05-15 19:51:55 +02:00
|
|
|
TileData *tile_data;
|
|
|
|
int total_tiles;
|
|
|
|
|
2014-03-03 23:34:39 +01:00
|
|
|
VP9LfSync lf_row_sync;
|
2014-04-15 23:10:58 +02:00
|
|
|
|
|
|
|
vpx_decrypt_cb decrypt_cb;
|
|
|
|
void *decrypt_state;
|
2014-05-09 01:24:36 +02:00
|
|
|
|
|
|
|
int max_threads;
|
|
|
|
int inv_tile_order;
|
2015-01-27 21:26:28 +01:00
|
|
|
int need_resync; // wait for key/intra-only frame.
|
|
|
|
int hold_ref_buf; // hold the reference buffer.
|
2014-04-08 20:41:12 +02:00
|
|
|
} VP9Decoder;
|
2014-03-03 23:34:39 +01:00
|
|
|
|
2014-04-08 20:41:12 +02:00
|
|
|
int vp9_receive_compressed_data(struct VP9Decoder *pbi,
|
2014-05-14 02:35:46 +02:00
|
|
|
size_t size, const uint8_t **dest);
|
2013-04-02 22:34:20 +02:00
|
|
|
|
2014-05-14 02:35:46 +02:00
|
|
|
int vp9_get_raw_frame(struct VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd,
|
2013-04-02 22:34:20 +02:00
|
|
|
vp9_ppflags_t *flags);
|
|
|
|
|
2014-04-08 20:41:12 +02:00
|
|
|
vpx_codec_err_t vp9_copy_reference_dec(struct VP9Decoder *pbi,
|
2013-04-02 22:34:20 +02:00
|
|
|
VP9_REFFRAME ref_frame_flag,
|
|
|
|
YV12_BUFFER_CONFIG *sd);
|
|
|
|
|
2014-03-21 22:20:13 +01:00
|
|
|
vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
|
2013-04-02 22:34:20 +02:00
|
|
|
VP9_REFFRAME ref_frame_flag,
|
|
|
|
YV12_BUFFER_CONFIG *sd);
|
|
|
|
|
2014-08-13 22:12:00 +02:00
|
|
|
static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb,
|
|
|
|
void *decrypt_state,
|
|
|
|
const uint8_t *data) {
|
|
|
|
if (decrypt_cb) {
|
|
|
|
uint8_t marker;
|
|
|
|
decrypt_cb(decrypt_state, data, &marker, 1);
|
|
|
|
return marker;
|
|
|
|
}
|
|
|
|
return *data;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function is exposed for use in tests, as well as the inlined function
|
|
|
|
// "read_marker".
|
|
|
|
vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data,
|
|
|
|
size_t data_sz,
|
|
|
|
uint32_t sizes[8], int *count,
|
|
|
|
vpx_decrypt_cb decrypt_cb,
|
|
|
|
void *decrypt_state);
|
|
|
|
|
2015-01-27 21:26:28 +01:00
|
|
|
struct VP9Decoder *vp9_decoder_create(BufferPool *const pool);
|
|
|
|
|
|
|
|
void vp9_decoder_remove(struct VP9Decoder *pbi);
|
|
|
|
|
|
|
|
static INLINE void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs,
|
|
|
|
BufferPool *const pool) {
|
|
|
|
if (idx >= 0) {
|
|
|
|
--frame_bufs[idx].ref_count;
|
|
|
|
// A worker may only get a free framebuffer index when calling get_free_fb.
|
|
|
|
// But the private buffer is not set up until finish decoding header.
|
|
|
|
// So any error happens during decoding header, the frame_bufs will not
|
|
|
|
// have valid priv buffer.
|
|
|
|
if (frame_bufs[idx].ref_count == 0 &&
|
|
|
|
frame_bufs[idx].raw_frame_buffer.priv) {
|
|
|
|
pool->release_fb_cb(pool->cb_priv, &frame_bufs[idx].raw_frame_buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#ifdef __cplusplus
|
2014-01-18 21:16:11 +01:00
|
|
|
} // extern "C"
|
2010-05-18 17:58:33 +02:00
|
|
|
#endif
|
|
|
|
|
2014-03-06 21:08:20 +01:00
|
|
|
#endif // VP9_DECODER_VP9_DECODER_H_
|