shithub: libvpx

Download patch

ref: 0dacecaf20bfc76f32f2daab4b524587349e863c
parent: 55e4b765696908f370197900ccf67985ec50532e
author: Dmitry Kovalev <dkovalev@google.com>
date: Thu May 8 12:24:36 EDT 2014

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

--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -677,7 +677,7 @@
 
 static void decode_tile(VP9Decoder *pbi, const TileInfo *const tile,
                         vp9_reader *r) {
-  const int num_threads = pbi->oxcf.max_threads;
+  const int num_threads = pbi->max_threads;
   VP9_COMMON *const cm = &pbi->common;
   int mi_row, mi_col;
   MACROBLOCKD *xd = &pbi->mb;
@@ -828,8 +828,7 @@
   // Decode tiles using data from tile_buffers
   for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
     for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
-      const int col = pbi->oxcf.inv_tile_order ? tile_cols - tile_col - 1
-                                               : tile_col;
+      const int col = pbi->inv_tile_order ? tile_cols - tile_col - 1 : tile_col;
       const int last_tile = tile_row == tile_rows - 1 &&
                                  col == tile_cols - 1;
       const TileBuffer *const buf = &tile_buffers[tile_row][col];
@@ -887,7 +886,7 @@
   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_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];
   int n;
   int final_worker = -1;
@@ -899,7 +898,7 @@
   // TODO(jzern): See if we can remove the restriction of passing in max
   // threads to the decoder.
   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;
     // TODO(jzern): Allocate one less worker, as in the current code we only
     // use num_threads - 1 workers.
@@ -1328,7 +1327,7 @@
     CHECK_MEM_ERROR(cm, pbi->lf_worker.data1,
                     vpx_memalign(32, sizeof(LFWorkerData)));
     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,
                          "Loop filter thread creation failed");
     }
@@ -1353,7 +1352,7 @@
 
   // TODO(jzern): remove frame_parallel_decoding_mode restriction for
   // 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) {
     *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end);
   } else {
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -42,7 +42,7 @@
   }
 }
 
-VP9Decoder *vp9_decoder_create(const VP9DecoderConfig *oxcf) {
+VP9Decoder *vp9_decoder_create() {
   VP9Decoder *const pbi = vpx_memalign(32, sizeof(*pbi));
   VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
 
@@ -66,7 +66,6 @@
   vpx_memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
 
   cm->current_video_frame = 0;
-  pbi->oxcf = *oxcf;
   pbi->ready_for_new_data = 1;
   pbi->decoded_key_frame = 0;
 
--- a/vp9/decoder/vp9_decoder.h
+++ b/vp9/decoder/vp9_decoder.h
@@ -27,21 +27,11 @@
 extern "C" {
 #endif
 
-typedef struct VP9DecoderConfig {
-  int width;
-  int height;
-  int version;
-  int max_threads;
-  int inv_tile_order;
-} VP9DecoderConfig;
-
 typedef struct VP9Decoder {
   DECLARE_ALIGNED(16, MACROBLOCKD, mb);
 
   DECLARE_ALIGNED(16, VP9_COMMON, common);
 
-  VP9DecoderConfig oxcf;
-
   int64_t last_time_stamp;
   int ready_for_new_data;
 
@@ -59,6 +49,9 @@
 
   vpx_decrypt_cb decrypt_cb;
   void *decrypt_state;
+
+  int max_threads;
+  int inv_tile_order;
 } VP9Decoder;
 
 void vp9_initialize_dec();
@@ -83,8 +76,7 @@
 int vp9_get_reference_dec(struct VP9Decoder *pbi,
                           int index, YV12_BUFFER_CONFIG **fb);
 
-
-struct VP9Decoder *vp9_decoder_create(const VP9DecoderConfig *oxcf);
+struct VP9Decoder *vp9_decoder_create();
 
 void vp9_decoder_remove(struct VP9Decoder *pbi);
 
--- a/vp9/decoder/vp9_dthread.c
+++ b/vp9/decoder/vp9_dthread.c
@@ -140,7 +140,7 @@
   // Number of superblock rows and cols
   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 num_workers = MIN(pbi->oxcf.max_threads & ~1, tile_cols);
+  const int num_workers = MIN(pbi->max_threads & ~1, tile_cols);
   int i;
 
   // Allocate memory used in thread synchronization.
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -245,16 +245,12 @@
 }
 
 static void init_decoder(vpx_codec_alg_priv_t *ctx) {
-  VP9DecoderConfig oxcf;
-  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);
+  ctx->pbi = vp9_decoder_create();
   if (ctx->pbi == NULL)
     return;
+
+  ctx->pbi->max_threads = ctx->cfg.threads;
+  ctx->pbi->inv_tile_order = ctx->invert_tile_order;
 
   vp9_initialize_dec();