]> granicus.if.org Git - libvpx/commitdiff
Make vp8_set_maps more flexible.
authorAlex Converse <aconverse@google.com>
Mon, 10 Mar 2014 23:08:58 +0000 (16:08 -0700)
committerAlex Converse <aconverse@google.com>
Tue, 11 Mar 2014 17:44:22 +0000 (10:44 -0700)
Change-Id: I754a5c5e342cfa7c52c1a75424f18aea8b7657d2

examples/vp8_set_maps.c

index f3cc9a7687ef992b56a9c8b6a011fe1c8861b0d4..8f054eb1ae5eebb7d3e2821d172f405d8454ff3b 100644 (file)
@@ -65,8 +65,8 @@ static void set_roi_map(const vpx_codec_enc_cfg_t *cfg,
   unsigned int i;
   vpx_roi_map_t roi = {0};
 
-  roi.rows = cfg->g_h / 16;
-  roi.cols = cfg->g_w / 16;
+  roi.rows = (cfg->g_h + 15) / 16;
+  roi.cols = (cfg->g_w + 15) / 16;
 
   roi.delta_q[0] = 0;
   roi.delta_q[1] = -2;
@@ -98,8 +98,8 @@ static void set_active_map(const vpx_codec_enc_cfg_t *cfg,
   unsigned int i;
   vpx_active_map_t map = {0};
 
-  map.rows = cfg->g_h / 16;
-  map.cols = cfg->g_w / 16;
+  map.rows = (cfg->g_h + 15) / 16;
+  map.cols = (cfg->g_w + 15) / 16;
 
   map.active_map = (uint8_t *)malloc(map.rows * map.cols);
   for (i = 0; i < map.rows * map.cols; ++i)
@@ -115,8 +115,8 @@ static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,
                              vpx_codec_ctx_t *codec) {
   vpx_active_map_t map = {0};
 
-  map.rows = cfg->g_h / 16;
-  map.cols = cfg->g_w / 16;
+  map.rows = (cfg->g_h + 15) / 16;
+  map.cols = (cfg->g_w + 15) / 16;
   map.active_map = NULL;
 
   if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))
@@ -161,7 +161,7 @@ int main(int argc, char **argv) {
   VpxVideoWriter *writer = NULL;
   const VpxInterface *encoder = NULL;
   const int fps = 2;        // TODO(dkovalev) add command line argument
-  const int bitrate = 200;   // kbit/s TODO(dkovalev) add command line argument
+  const double bits_per_pixel_per_frame = 0.067;
 
   exec_name = argv[0];
 
@@ -200,7 +200,8 @@ int main(int argc, char **argv) {
   cfg.g_h = info.frame_height;
   cfg.g_timebase.num = info.time_base.numerator;
   cfg.g_timebase.den = info.time_base.denominator;
-  cfg.rc_target_bitrate = bitrate;
+  cfg.rc_target_bitrate = (unsigned int)(bits_per_pixel_per_frame * cfg.g_w *
+                                         cfg.g_h * fps / 1000);
 
   writer = vpx_video_writer_open(argv[4], kContainerIVF, &info);
   if (!writer)