]> granicus.if.org Git - libvpx/commitdiff
Merge "renamed pick_best_mbsegmentation and remove rd_check_segment_txsize"
authorJim Bankoski <jimbankoski@google.com>
Thu, 17 Apr 2014 22:42:36 +0000 (15:42 -0700)
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>
Thu, 17 Apr 2014 22:42:36 +0000 (15:42 -0700)
12 files changed:
test/datarate_test.cc
tools_common.h
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_mbgraph.c
vp9/encoder/vp9_onyx_if.c
vp9/encoder/vp9_onyx_int.h
vp9/encoder/vp9_rdopt.c
vp9/encoder/vp9_speed_features.c
vp9/encoder/vp9_temporal_filter.c
vp9/vp9_cx_iface.c
vpxenc.c

index e8604a6d7bcdc6b84a394ede33995bc4b2dd6862..2b4aa3acbacf761875f1a2c1794e6329a4639746 100644 (file)
@@ -145,7 +145,7 @@ TEST_P(DatarateTestLarge, BasicBufferModel) {
     cfg_.rc_target_bitrate = i;
     ResetModel();
     ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
-    ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_)
+    ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
         << " The datarate for the file exceeds the target!";
 
     ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3)
index 549e895ec19dea0390e01fef080102de2ac2c9f0..21248827adabfb0ad912806075959eed94281855 100644 (file)
 /* MSVS uses _f{seek,tell}i64. */
 #define fseeko _fseeki64
 #define ftello _ftelli64
-typedef long _off_t;  // NOLINT - MSVS compatible type
-typedef __int64 off_t;  // fseeki64 compatible type
-#define _OFF_T_DEFINED
 #elif defined(_WIN32)
-/* MinGW defines off_t as long and uses f{seek,tell}o64/off64_t for large
- * files. */
+/* MinGW uses f{seek,tell}o64 for large files. */
 #define fseeko fseeko64
 #define ftello ftello64
-#define off_t off64_t
 #endif  /* _WIN32 */
 
 #if CONFIG_OS_SUPPORT
@@ -50,7 +45,6 @@ typedef __int64 off_t;  // fseeki64 compatible type
 /* Use 32-bit file operations in WebM file format when building ARM
  * executables (.axf) with RVCT. */
 #if !CONFIG_OS_SUPPORT
-typedef long off_t;  /* NOLINT */
 #define fseeko fseek
 #define ftello ftell
 #endif  /* CONFIG_OS_SUPPORT */
@@ -90,7 +84,7 @@ struct VpxRational {
 struct VpxInputContext {
   const char *filename;
   FILE *file;
-  off_t length;
+  int64_t length;
   struct FileTypeDetectionBuffer detect;
   enum VideoFileType file_type;
   uint32_t width;
index dea7848b2cd9a3ec562668c4a0807852d18fd74c..213f3a91f08765dab3f9ce15184725fbf8b655cc 100644 (file)
@@ -1273,7 +1273,6 @@ static void set_source_var_based_partition(VP9_COMP *cpi,
 
 static int is_background(VP9_COMP *cpi, const TileInfo *const tile,
                          int mi_row, int mi_col) {
-  MACROBLOCK *const x = &cpi->mb;
   uint8_t *src, *pre;
   int src_stride, pre_stride;
 
@@ -1283,9 +1282,10 @@ static int is_background(VP9_COMP *cpi, const TileInfo *const tile,
   int this_sad = 0;
   int threshold = 0;
 
-  vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col);
-  src_stride = x->plane[0].src.stride;
-  src = x->plane[0].src.buf;
+  // This assumes the input source frames are of the same dimension.
+  src_stride = cpi->Source->y_stride;
+  src = cpi->Source->y_buffer + (mi_row * MI_SIZE) * src_stride +
+            (mi_col * MI_SIZE);
   pre_stride = cpi->Last_Source->y_stride;
   pre = cpi->Last_Source->y_buffer + (mi_row * MI_SIZE) * pre_stride +
           (mi_col * MI_SIZE);
@@ -2307,16 +2307,8 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
   // Copy data over into macro block data structures.
   vp9_setup_src_planes(x, cpi->Source, 0, 0);
 
-  // TODO(jkoleszar): are these initializations required?
-  vp9_setup_pre_planes(xd, 0, get_ref_frame_buffer(cpi, LAST_FRAME), 0, 0,
-                       NULL);
-  vp9_setup_dst_planes(xd, get_frame_new_buffer(cm), 0, 0);
-
   vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y);
 
-  xd->mi[0]->mbmi.mode = DC_PRED;
-  xd->mi[0]->mbmi.uv_mode = DC_PRED;
-
   // Note: this memset assumes above_context[0], [1] and [2]
   // are allocated as part of the same buffer.
   vpx_memset(xd->above_context[0], 0,
index b155fd39e314d89886861f344c2d6d770bcf6436..16f5cb1b514e211a04b25a8ac95b69b7e6545c61 100644 (file)
@@ -911,7 +911,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi,
     const int num_mbs = cpi->common.MBs;
     const double section_err = stats->coded_error / stats->count;
     const double err_per_mb = section_err / num_mbs;
-    const double speed_term = 1.0 + 0.04 * cpi->speed;
+    const double speed_term = 1.0 + 0.04 * cpi->oxcf.speed;
     const int target_norm_bits_per_mb = ((uint64_t)section_target_bandwidth <<
                                             BPER_MB_NORMBITS) / num_mbs;
     int q;
index a9da7283abc5e1728843c06302414326d4e40b7e..2f63a13a08b0a8e3d649440b625237c0d50f6b68 100644 (file)
@@ -38,8 +38,8 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
 
   // Further step/diamond searches as necessary
   int step_param = cpi->sf.reduce_first_step_size +
-      (cpi->speed < 8 ? (cpi->speed > 5 ? 1 : 0) : 2);
-  step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2));
+                       (cpi->oxcf.speed > 5 ? 1 : 0);
+  step_param = MIN(step_param, cpi->sf.max_step_search_steps - 2);
 
   vp9_set_mv_search_range(x, ref_mv);
 
index 0d6b62509b570fae10eba236a2a44d0dad799352..5a7257338d3213f23eb501335878097566812047 100644 (file)
@@ -694,14 +694,10 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) {
 
   cpi->oxcf = *oxcf;
 
-  if (cpi->oxcf.cpu_used == -6)
-    cpi->oxcf.play_alternate = 0;
-
   switch (cpi->oxcf.mode) {
       // Real time and one pass deprecated in test code base
     case ONE_PASS_GOOD:
       cpi->pass = 0;
-      cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5);
       break;
 
     case ONE_PASS_BEST:
@@ -714,7 +710,6 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) {
 
     case TWO_PASS_SECOND_GOOD:
       cpi->pass = 2;
-      cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5);
       break;
 
     case TWO_PASS_SECOND_BEST:
@@ -723,6 +718,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) {
 
     case REALTIME:
       cpi->pass = 0;
+      cpi->oxcf.play_alternate = 0;
       break;
   }
 
@@ -822,8 +818,6 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) {
                                            (int)cpi->oxcf.target_bandwidth);
   }
 
-  cpi->speed = abs(cpi->oxcf.cpu_used);
-
 #if CONFIG_MULTIPLE_ARF
   vp9_zero(cpi->alt_ref_source);
 #else
index 571afaa35a043202d68a1b5a6a45940a001a2d9f..a9ae7b3a8e870f2b99e498ac027bb36cd6805192 100644 (file)
@@ -196,7 +196,7 @@ typedef struct VP9_CONFIG {
 
   int noise_sensitivity;  // pre processing blur: recommendation 0
   int sharpness;  // sharpening output: recommendation 0:
-  int cpu_used;
+  int speed;
   unsigned int rc_max_intra_bitrate_pct;
 
   MODE mode;
@@ -402,10 +402,6 @@ typedef struct VP9_COMP {
   int mbgraph_n_frames;             // number of frames filled in the above
   int static_mb_pct;                // % forced skip mbs by segmentation
 
-  // for real time encoding
-  int speed;
-
-  int cpu_used;
   int pass;
 
   int ref_frame_flags;
index 9ad7fa32b04ab24ed22a2f4ccc608e5818f0c1b9..36932cfacbc6eb99dd23d91fa37b39abce36be41 100644 (file)
@@ -451,7 +451,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize,
       x->pred_sse[ref] = sse;
 
     // Fast approximate the modelling function.
-    if (cpi->speed > 4) {
+    if (cpi->oxcf.speed > 4) {
       int64_t rate;
       int64_t dist;
       int64_t square_error = sse;
index 6e0effae3976eea1e4a0748dd96515eaa75359fb..f79ded5f98d0a11957783e1fcea5e54a42214763 100644 (file)
@@ -289,7 +289,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
   SPEED_FEATURES *const sf = &cpi->sf;
   VP9_COMMON *const cm = &cpi->common;
   const VP9_CONFIG *const oxcf = &cpi->oxcf;
-  const int speed = cpi->speed < 0 ? -cpi->speed : cpi->speed;
   int i;
 
   // best quality defaults
@@ -360,10 +359,10 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
     case TWO_PASS_FIRST:
     case ONE_PASS_GOOD:
     case TWO_PASS_SECOND_GOOD:
-      set_good_speed_feature(cpi, cm, sf, speed);
+      set_good_speed_feature(cpi, cm, sf, oxcf->speed);
       break;
     case REALTIME:
-      set_rt_speed_feature(cm, sf, speed);
+      set_rt_speed_feature(cm, sf, oxcf->speed);
       break;
   }
 
index 0410273545ead154ae308003cc3f82752a28578b..c98c9d41587cab82e6750a0bd6a88c1767b6c53f 100644 (file)
@@ -151,12 +151,8 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
   xd->plane[0].pre[0].buf = frame_ptr_buf;
   xd->plane[0].pre[0].stride = stride;
 
-  // Further step/diamond searches as necessary
-  if (cpi->speed < 8)
-    step_param = cpi->sf.reduce_first_step_size + ((cpi->speed > 5) ? 1 : 0);
-  else
-    step_param = cpi->sf.reduce_first_step_size + 2;
-  step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2));
+  step_param = cpi->sf.reduce_first_step_size + (cpi->oxcf.speed > 5 ? 1 : 0);
+  step_param = MIN(step_param, cpi->sf.max_step_search_steps - 2);
 
   /*cpi->sf.search_method == HEX*/
   // Ignore mv costing by sending NULL pointer instead of cost arrays
index 95b3500c77f790d4cfcaf6fe146aff82ebe45804..87d4bb7c1ac3d1ca16449e2f669d84af28088a79 100644 (file)
@@ -356,7 +356,7 @@ static vpx_codec_err_t set_encoder_config(
 
   oxcf->key_freq               = cfg->kf_max_dist;
 
-  oxcf->cpu_used               =  extra_cfg->cpu_used;
+  oxcf->speed                  =  clamp(abs(extra_cfg->cpu_used), 0, 7);
   oxcf->encode_breakout        =  extra_cfg->static_thresh;
   oxcf->play_alternate         =  extra_cfg->enable_auto_alt_ref;
   oxcf->noise_sensitivity      =  extra_cfg->noise_sensitivity;
index f2b73aaecbd221cdd0f2f749ff045818f6662f92..8e8ed23448f6c6067b2b03529215850668d827ed 100644 (file)
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1281,7 +1281,7 @@ static void get_cx_data(struct stream_state *stream,
   *got_data = 0;
   while ((pkt = vpx_codec_get_cx_data(&stream->encoder, &iter))) {
     static size_t fsize = 0;
-    static off_t ivf_header_pos = 0;
+    static int64_t ivf_header_pos = 0;
 
     switch (pkt->kind) {
       case VPX_CODEC_CX_FRAME_PKT:
@@ -1307,7 +1307,7 @@ static void get_cx_data(struct stream_state *stream,
             fsize += pkt->data.frame.sz;
 
             if (!(pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT)) {
-              off_t currpos = ftello(stream->file);
+              const int64_t currpos = ftello(stream->file);
               fseeko(stream->file, ivf_header_pos, SEEK_SET);
               ivf_write_frame_size(stream->file, fsize);
               fseeko(stream->file, currpos, SEEK_SET);
@@ -1534,7 +1534,7 @@ int main(int argc, const char **argv_) {
     int frames_in = 0, seen_frames = 0;
     int64_t estimated_time_left = -1;
     int64_t average_rate = -1;
-    off_t lagged_count = 0;
+    int64_t lagged_count = 0;
 
     open_input_file(&input);
 
@@ -1667,15 +1667,15 @@ int main(int argc, const char **argv_) {
           int64_t rate;
 
           if (global.limit) {
-            off_t frame_in_lagged = (seen_frames - lagged_count) * 1000;
+            const int64_t frame_in_lagged = (seen_frames - lagged_count) * 1000;
 
             rate = cx_time ? frame_in_lagged * (int64_t)1000000 / cx_time : 0;
             remaining = 1000 * (global.limit - global.skip_frames
                                 - seen_frames + lagged_count);
           } else {
-            off_t input_pos = ftello(input.file);
-            off_t input_pos_lagged = input_pos - lagged_count;
-            int64_t limit = input.length;
+            const int64_t input_pos = ftello(input.file);
+            const int64_t input_pos_lagged = input_pos - lagged_count;
+            const int64_t limit = input.length;
 
             rate = cx_time ? input_pos_lagged * (int64_t)1000000 / cx_time : 0;
             remaining = limit - input_pos + lagged_count;