summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-08-18 15:06:14 -0700
committerDmitry Kovalev <dkovalev@google.com>2014-08-19 10:37:12 -0700
commit215151b78d689d695410bb37ad54ccf6ecb9eb01 (patch)
tree0fd3a66f2c8aaef09a82996740d4ad2bea7662a3
parent17a26eb4437d5d02a2e44c271fe6416eb253c98d (diff)
downloadlibvpx-215151b78d689d695410bb37ad54ccf6ecb9eb01.tar
libvpx-215151b78d689d695410bb37ad54ccf6ecb9eb01.tar.gz
libvpx-215151b78d689d695410bb37ad54ccf6ecb9eb01.tar.bz2
libvpx-215151b78d689d695410bb37ad54ccf6ecb9eb01.zip
Converting MODE to be just BEST, GOOD, and REALTIME.
After that change oxcf->pass and oxcf->mode become two orthogonal variables. Change-Id: I1501f83cd2805480e8118135e6d4045fb41e26d5
-rw-r--r--vp9/encoder/vp9_encoder.h45
-rw-r--r--vp9/vp9_cx_iface.c52
2 files changed, 42 insertions, 55 deletions
diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h
index 284ae9dc9..ec4f8134e 100644
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -82,36 +82,19 @@ typedef enum {
} VPX_SCALING;
typedef enum {
- // Good Quality Fast Encoding. The encoder balances quality with the
- // amount of time it takes to encode the output. (speed setting
- // controls how fast)
- ONE_PASS_GOOD = 1,
-
- // One Pass - Best Quality. The encoder places priority on the
- // quality of the output over encoding speed. The output is compressed
- // at the highest possible quality. This option takes the longest
- // amount of time to encode. (speed setting ignored)
- ONE_PASS_BEST = 2,
-
- // Two Pass - First Pass. The encoder generates a file of statistics
- // for use in the second encoding pass. (speed setting controls how fast)
- TWO_PASS_FIRST = 3,
-
- // Two Pass - Second Pass. The encoder uses the statistics that were
- // generated in the first encoding pass to create the compressed
- // output. (speed setting controls how fast)
- TWO_PASS_SECOND_GOOD = 4,
-
- // Two Pass - Second Pass Best. The encoder uses the statistics that
- // were generated in the first encoding pass to create the compressed
- // output using the highest possible quality, and taking a
- // longer amount of time to encode. (speed setting ignored)
- TWO_PASS_SECOND_BEST = 5,
-
- // Realtime/Live Encoding. This mode is optimized for realtime
- // encoding (for example, capturing a television signal or feed from
- // a live camera). (speed setting controls how fast)
- REALTIME = 6,
+ // Good Quality Fast Encoding. The encoder balances quality with the amount of
+ // time it takes to encode the output. Speed setting controls how fast.
+ GOOD,
+
+ // The encoder places priority on the quality of the output over encoding
+ // speed. The output is compressed at the highest possible quality. This
+ // option takes the longest amount of time to encode. Speed setting ignored.
+ BEST,
+
+ // Realtime/Live Encoding. This mode is optimized for realtime encoding (for
+ // example, capturing a television signal or feed from a live camera). Speed
+ // setting controls how fast.
+ REALTIME
} MODE;
typedef enum {
@@ -241,7 +224,7 @@ static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) {
}
static INLINE int is_best_mode(MODE mode) {
- return mode == ONE_PASS_BEST || mode == TWO_PASS_SECOND_BEST;
+ return mode == BEST;
}
typedef struct VP9_COMP {
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index cdbb69b2d..3bd2bfc52 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -334,17 +334,16 @@ static vpx_codec_err_t set_encoder_config(
if (oxcf->init_framerate > 180)
oxcf->init_framerate = 30;
+ oxcf->mode = BEST;
+
switch (cfg->g_pass) {
case VPX_RC_ONE_PASS:
- oxcf->mode = ONE_PASS_GOOD;
oxcf->pass = 0;
break;
case VPX_RC_FIRST_PASS:
- oxcf->mode = TWO_PASS_FIRST;
oxcf->pass = 1;
break;
case VPX_RC_LAST_PASS:
- oxcf->mode = TWO_PASS_SECOND_BEST;
oxcf->pass = 2;
break;
}
@@ -718,31 +717,36 @@ static vpx_codec_err_t encoder_destroy(vpx_codec_alg_priv_t *ctx) {
return VPX_CODEC_OK;
}
-static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
+static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
unsigned long duration,
unsigned long deadline) {
- // Use best quality mode if no deadline is given.
- MODE new_qc = ONE_PASS_BEST;
-
- if (deadline) {
- // Convert duration parameter from stream timebase to microseconds
- const uint64_t duration_us = (uint64_t)duration * 1000000 *
- (uint64_t)ctx->cfg.g_timebase.num /
- (uint64_t)ctx->cfg.g_timebase.den;
-
- // If the deadline is more that the duration this frame is to be shown,
- // use good quality mode. Otherwise use realtime mode.
- new_qc = (deadline > duration_us) ? ONE_PASS_GOOD : REALTIME;
- }
+ MODE new_mode = BEST;
- if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS)
- new_qc = TWO_PASS_FIRST;
- else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS)
- new_qc = (new_qc == ONE_PASS_BEST) ? TWO_PASS_SECOND_BEST
- : TWO_PASS_SECOND_GOOD;
+ switch (ctx->cfg.g_pass) {
+ case VPX_RC_ONE_PASS:
+ if (deadline > 0) {
+ const vpx_codec_enc_cfg_t *const cfg = &ctx->cfg;
+
+ // Convert duration parameter from stream timebase to microseconds.
+ const uint64_t duration_us = (uint64_t)duration * 1000000 *
+ (uint64_t)cfg->g_timebase.num /(uint64_t)cfg->g_timebase.den;
+
+ // If the deadline is more that the duration this frame is to be shown,
+ // use good quality mode. Otherwise use realtime mode.
+ new_mode = (deadline > duration_us) ? GOOD : REALTIME;
+ } else {
+ new_mode = BEST;
+ }
+ break;
+ case VPX_RC_FIRST_PASS:
+ break;
+ case VPX_RC_LAST_PASS:
+ new_mode = deadline > 0 ? GOOD : BEST;
+ break;
+ }
- if (ctx->oxcf.mode != new_qc) {
- ctx->oxcf.mode = new_qc;
+ if (ctx->oxcf.mode != new_mode) {
+ ctx->oxcf.mode = new_mode;
vp9_change_config(ctx->cpi, &ctx->oxcf);
}
}