Removing VP9DecoderConfig.
We only used two members from that struct: max_threads and inv_tile_order. Moving them directly to VP9Decoder struct. Change-Id: If696a4e5b5b41868a55f3cc971e1d7c1dd9d5f69
This commit is contained in:
Родитель
55e4b76569
Коммит
0dacecaf20
|
@ -677,7 +677,7 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
|
||||||
|
|
||||||
static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
|
static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
|
||||||
vp9_reader *r) {
|
vp9_reader *r) {
|
||||||
const int num_threads = pbi->oxcf.max_threads;
|
const int num_threads = pbi->max_threads;
|
||||||
VP9_COMMON *const cm = &pbi->common;
|
VP9_COMMON *const cm = &pbi->common;
|
||||||
int mi_row, mi_col;
|
int mi_row, mi_col;
|
||||||
MACROBLOCKD *xd = &pbi->mb;
|
MACROBLOCKD *xd = &pbi->mb;
|
||||||
|
@ -828,8 +828,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
|
||||||
// Decode tiles using data from tile_buffers
|
// Decode tiles using data from tile_buffers
|
||||||
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
|
||||||
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
|
for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
|
||||||
const int col = pbi->oxcf.inv_tile_order ? tile_cols - tile_col - 1
|
const int col = pbi->inv_tile_order ? tile_cols - tile_col - 1 : tile_col;
|
||||||
: tile_col;
|
|
||||||
const int last_tile = tile_row == tile_rows - 1 &&
|
const int last_tile = tile_row == tile_rows - 1 &&
|
||||||
col == tile_cols - 1;
|
col == tile_cols - 1;
|
||||||
const TileBuffer *const buf = &tile_buffers[tile_row][col];
|
const TileBuffer *const buf = &tile_buffers[tile_row][col];
|
||||||
|
@ -887,7 +886,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
|
||||||
const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
|
const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
|
||||||
const int tile_cols = 1 << cm->log2_tile_cols;
|
const int tile_cols = 1 << cm->log2_tile_cols;
|
||||||
const int tile_rows = 1 << cm->log2_tile_rows;
|
const int tile_rows = 1 << cm->log2_tile_rows;
|
||||||
const int num_workers = MIN(pbi->oxcf.max_threads & ~1, tile_cols);
|
const int num_workers = MIN(pbi->max_threads & ~1, tile_cols);
|
||||||
TileBuffer tile_buffers[1 << 6];
|
TileBuffer tile_buffers[1 << 6];
|
||||||
int n;
|
int n;
|
||||||
int final_worker = -1;
|
int final_worker = -1;
|
||||||
|
@ -899,7 +898,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi,
|
||||||
// TODO(jzern): See if we can remove the restriction of passing in max
|
// TODO(jzern): See if we can remove the restriction of passing in max
|
||||||
// threads to the decoder.
|
// threads to the decoder.
|
||||||
if (pbi->num_tile_workers == 0) {
|
if (pbi->num_tile_workers == 0) {
|
||||||
const int num_threads = pbi->oxcf.max_threads & ~1;
|
const int num_threads = pbi->max_threads & ~1;
|
||||||
int i;
|
int i;
|
||||||
// TODO(jzern): Allocate one less worker, as in the current code we only
|
// TODO(jzern): Allocate one less worker, as in the current code we only
|
||||||
// use num_threads - 1 workers.
|
// use num_threads - 1 workers.
|
||||||
|
@ -1328,7 +1327,7 @@ int vp9_decode_frame(VP9Decoder *pbi,
|
||||||
CHECK_MEM_ERROR(cm, pbi->lf_worker.data1,
|
CHECK_MEM_ERROR(cm, pbi->lf_worker.data1,
|
||||||
vpx_memalign(32, sizeof(LFWorkerData)));
|
vpx_memalign(32, sizeof(LFWorkerData)));
|
||||||
pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker;
|
pbi->lf_worker.hook = (VP9WorkerHook)vp9_loop_filter_worker;
|
||||||
if (pbi->oxcf.max_threads > 1 && !vp9_worker_reset(&pbi->lf_worker)) {
|
if (pbi->max_threads > 1 && !vp9_worker_reset(&pbi->lf_worker)) {
|
||||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
||||||
"Loop filter thread creation failed");
|
"Loop filter thread creation failed");
|
||||||
}
|
}
|
||||||
|
@ -1353,7 +1352,7 @@ int vp9_decode_frame(VP9Decoder *pbi,
|
||||||
|
|
||||||
// TODO(jzern): remove frame_parallel_decoding_mode restriction for
|
// TODO(jzern): remove frame_parallel_decoding_mode restriction for
|
||||||
// single-frame tile decoding.
|
// single-frame tile decoding.
|
||||||
if (pbi->oxcf.max_threads > 1 && tile_rows == 1 && tile_cols > 1 &&
|
if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1 &&
|
||||||
cm->frame_parallel_decoding_mode) {
|
cm->frame_parallel_decoding_mode) {
|
||||||
*p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end);
|
*p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,7 +42,7 @@ void vp9_initialize_dec() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VP9Decoder *vp9_decoder_create(const VP9DecoderConfig *oxcf) {
|
VP9Decoder *vp9_decoder_create() {
|
||||||
VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi));
|
VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi));
|
||||||
VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
|
VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ VP9Decoder *vp9_decoder_create(const VP9DecoderConfig *oxcf) {
|
||||||
vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
|
vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
|
||||||
|
|
||||||
cm->current_video_frame = 0;
|
cm->current_video_frame = 0;
|
||||||
pbi->oxcf = *oxcf;
|
|
||||||
pbi->ready_for_new_data = 1;
|
pbi->ready_for_new_data = 1;
|
||||||
pbi->decoded_key_frame = 0;
|
pbi->decoded_key_frame = 0;
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct VP9DecoderConfig {
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int version;
|
|
||||||
int max_threads;
|
|
||||||
int inv_tile_order;
|
|
||||||
} VP9DecoderConfig;
|
|
||||||
|
|
||||||
typedef struct VP9Decoder {
|
typedef struct VP9Decoder {
|
||||||
DECLARE_ALIGNED(16, MACROBLOCKD, mb);
|
DECLARE_ALIGNED(16, MACROBLOCKD, mb);
|
||||||
|
|
||||||
DECLARE_ALIGNED(16, VP9_COMMON, common);
|
DECLARE_ALIGNED(16, VP9_COMMON, common);
|
||||||
|
|
||||||
VP9DecoderConfig oxcf;
|
|
||||||
|
|
||||||
int64_t last_time_stamp;
|
int64_t last_time_stamp;
|
||||||
int ready_for_new_data;
|
int ready_for_new_data;
|
||||||
|
|
||||||
|
@ -59,6 +49,9 @@ typedef struct VP9Decoder {
|
||||||
|
|
||||||
vpx_decrypt_cb decrypt_cb;
|
vpx_decrypt_cb decrypt_cb;
|
||||||
void *decrypt_state;
|
void *decrypt_state;
|
||||||
|
|
||||||
|
int max_threads;
|
||||||
|
int inv_tile_order;
|
||||||
} VP9Decoder;
|
} VP9Decoder;
|
||||||
|
|
||||||
void vp9_initialize_dec();
|
void vp9_initialize_dec();
|
||||||
|
@ -83,8 +76,7 @@ vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
|
||||||
int vp9_get_reference_dec(struct VP9Decoder *pbi,
|
int vp9_get_reference_dec(struct VP9Decoder *pbi,
|
||||||
int index, YV12_BUFFER_CONFIG **fb);
|
int index, YV12_BUFFER_CONFIG **fb);
|
||||||
|
|
||||||
|
struct VP9Decoder *vp9_decoder_create();
|
||||||
struct VP9Decoder *vp9_decoder_create(const VP9DecoderConfig *oxcf);
|
|
||||||
|
|
||||||
void vp9_decoder_remove(struct VP9Decoder *pbi);
|
void vp9_decoder_remove(struct VP9Decoder *pbi);
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ void vp9_loop_filter_frame_mt(VP9Decoder *pbi,
|
||||||
// Number of superblock rows and cols
|
// Number of superblock rows and cols
|
||||||
const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2;
|
const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2;
|
||||||
const int tile_cols = 1 << cm->log2_tile_cols;
|
const int tile_cols = 1 << cm->log2_tile_cols;
|
||||||
const int num_workers = MIN(pbi->oxcf.max_threads & ~1, tile_cols);
|
const int num_workers = MIN(pbi->max_threads & ~1, tile_cols);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Allocate memory used in thread synchronization.
|
// Allocate memory used in thread synchronization.
|
||||||
|
|
|
@ -245,17 +245,13 @@ static void set_ppflags(const vpx_codec_alg_priv_t *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_decoder(vpx_codec_alg_priv_t *ctx) {
|
static void init_decoder(vpx_codec_alg_priv_t *ctx) {
|
||||||
VP9DecoderConfig oxcf;
|
ctx->pbi = vp9_decoder_create();
|
||||||
oxcf.width = ctx->si.w;
|
|
||||||
oxcf.height = ctx->si.h;
|
|
||||||
oxcf.version = 9;
|
|
||||||
oxcf.max_threads = ctx->cfg.threads;
|
|
||||||
oxcf.inv_tile_order = ctx->invert_tile_order;
|
|
||||||
|
|
||||||
ctx->pbi = vp9_decoder_create(&oxcf);
|
|
||||||
if (ctx->pbi == NULL)
|
if (ctx->pbi == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ctx->pbi->max_threads = ctx->cfg.threads;
|
||||||
|
ctx->pbi->inv_tile_order = ctx->invert_tile_order;
|
||||||
|
|
||||||
vp9_initialize_dec();
|
vp9_initialize_dec();
|
||||||
|
|
||||||
// If postprocessing was enabled by the application and a
|
// If postprocessing was enabled by the application and a
|
||||||
|
|
Загрузка…
Ссылка в новой задаче