
Cherry-Picked the following commits: 0defd8f Changed "WebM" to "AOMedia" & "webm" to "aomedia" 54e6676 Replace "VPx" by "AVx" 5082a36 Change "Vpx" to "Avx" 7df44f1 Replace "Vp9" w/ "Av1" 967f722 Remove kVp9CodecId 828f30c Change "Vp8" to "AOM" 030b5ff AUTHORS regenerated 2524cae Add ref-mv experimental flag 016762b Change copyright notice to AOMedia form 81e5526 Replace vp9 w/ av1 9b94565 Add missing files fa8ca9f Change "vp9" to "av1" ec838b7 Convert "vp8" to "aom" 80edfa0 Change "VP9" to "AV1" d1a11fb Change "vp8" to "aom" 7b58251 Point to WebM test data dd1a5c8 Replace "VP8" with "AOM" ff00fc0 Change "VPX" to "AOM" 01dee0b Change "vp10" to "av1" in source code cebe6f0 Convert "vpx" to "aom" 17b0567 rename vp10*.mk to av1_*.mk fe5f8a8 rename files vp10_* to av1_* Change-Id: I6fc3d18eb11fc171e46140c836ad5339cf6c9419
170 lines
5.4 KiB
C
170 lines
5.4 KiB
C
/*
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef AV1_DECODER_DECODER_H_
|
|
#define AV1_DECODER_DECODER_H_
|
|
|
|
#include "./aom_config.h"
|
|
|
|
#include "aom/aom_codec.h"
|
|
#include "av1/decoder/bitreader.h"
|
|
#include "aom_scale/yv12config.h"
|
|
#include "aom_util/aom_thread.h"
|
|
|
|
#include "av1/common/thread_common.h"
|
|
#include "av1/common/onyxc_int.h"
|
|
#include "av1/decoder/dthread.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// TODO(hkuang): combine this with TileWorkerData.
|
|
typedef struct TileData {
|
|
AV1_COMMON *cm;
|
|
aom_reader bit_reader;
|
|
DECLARE_ALIGNED(16, MACROBLOCKD, xd);
|
|
/* dqcoeff are shared by all the planes. So planes must be decoded serially */
|
|
DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]);
|
|
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
|
|
} TileData;
|
|
|
|
typedef struct TileWorkerData {
|
|
struct AV1Decoder *pbi;
|
|
aom_reader bit_reader;
|
|
FRAME_COUNTS counts;
|
|
DECLARE_ALIGNED(16, MACROBLOCKD, xd);
|
|
/* dqcoeff are shared by all the planes. So planes must be decoded serially */
|
|
DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]);
|
|
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
|
|
struct aom_internal_error_info error_info;
|
|
} TileWorkerData;
|
|
|
|
typedef struct TileBufferDec {
|
|
const uint8_t *data;
|
|
size_t size;
|
|
const uint8_t *raw_data_end; // The end of the raw tile buffer in the
|
|
// bit stream.
|
|
int col; // only used with multi-threaded decoding
|
|
} TileBufferDec;
|
|
|
|
typedef struct AV1Decoder {
|
|
DECLARE_ALIGNED(16, MACROBLOCKD, mb);
|
|
|
|
DECLARE_ALIGNED(16, AV1_COMMON, common);
|
|
|
|
int ready_for_new_data;
|
|
|
|
int refresh_frame_flags;
|
|
|
|
// TODO(hkuang): Combine this with cur_buf in macroblockd as they are
|
|
// the same.
|
|
RefCntBuffer *cur_buf; // Current decoding frame buffer.
|
|
|
|
AVxWorker *frame_worker_owner; // frame_worker that owns this pbi.
|
|
AVxWorker lf_worker;
|
|
AVxWorker *tile_workers;
|
|
TileWorkerData *tile_worker_data;
|
|
TileInfo *tile_worker_info;
|
|
int num_tile_workers;
|
|
|
|
TileData *tile_data;
|
|
int allocated_tiles;
|
|
|
|
TileBufferDec tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
|
|
|
|
AV1LfSync lf_row_sync;
|
|
|
|
aom_decrypt_cb decrypt_cb;
|
|
void *decrypt_state;
|
|
|
|
int max_threads;
|
|
int inv_tile_order;
|
|
int need_resync; // wait for key/intra-only frame.
|
|
int hold_ref_buf; // hold the reference buffer.
|
|
|
|
int tile_size_bytes;
|
|
#if CONFIG_EXT_TILE
|
|
int tile_col_size_bytes;
|
|
int dec_tile_row, dec_tile_col;
|
|
#endif // CONFIG_EXT_TILE
|
|
} AV1Decoder;
|
|
|
|
int av1_receive_compressed_data(struct AV1Decoder *pbi, size_t size,
|
|
const uint8_t **dest);
|
|
|
|
int av1_get_raw_frame(struct AV1Decoder *pbi, YV12_BUFFER_CONFIG *sd);
|
|
|
|
int av1_get_frame_to_show(struct AV1Decoder *pbi, YV12_BUFFER_CONFIG *frame);
|
|
|
|
aom_codec_err_t av1_copy_reference_dec(struct AV1Decoder *pbi,
|
|
AOM_REFFRAME ref_frame_flag,
|
|
YV12_BUFFER_CONFIG *sd);
|
|
|
|
aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm,
|
|
AOM_REFFRAME ref_frame_flag,
|
|
YV12_BUFFER_CONFIG *sd);
|
|
|
|
static INLINE uint8_t read_marker(aom_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".
|
|
aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
|
|
uint32_t sizes[8], int *count,
|
|
aom_decrypt_cb decrypt_cb,
|
|
void *decrypt_state);
|
|
|
|
struct AV1Decoder *av1_decoder_create(BufferPool *const pool);
|
|
|
|
void av1_decoder_remove(struct AV1Decoder *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);
|
|
}
|
|
}
|
|
}
|
|
|
|
#if CONFIG_EXT_REFS
|
|
static INLINE int dec_is_ref_frame_buf(AV1Decoder *const pbi,
|
|
RefCntBuffer *frame_buf) {
|
|
AV1_COMMON *const cm = &pbi->common;
|
|
int i;
|
|
for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
|
|
RefBuffer *const ref_frame = &cm->frame_refs[i];
|
|
if (ref_frame->idx == INVALID_IDX) continue;
|
|
if (frame_buf == &cm->buffer_pool->frame_bufs[ref_frame->idx]) break;
|
|
}
|
|
return (i < INTER_REFS_PER_FRAME);
|
|
}
|
|
#endif // CONFIG_EXT_REFS
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif // AV1_DECODER_DECODER_H_
|