Converting MODE to be just BEST, GOOD, and REALTIME.
After that change oxcf->pass and oxcf->mode become two orthogonal variables. Change-Id: I1501f83cd2805480e8118135e6d4045fb41e26d5
This commit is contained in:
Родитель
17a26eb443
Коммит
215151b78d
|
@ -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,
|
||||
// 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,
|
||||
|
||||
// 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,
|
||||
// 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,
|
||||
|
||||
// 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,
|
||||
// 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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -721,28 +720,33 @@ static vpx_codec_err_t encoder_destroy(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;
|
||||
MODE new_mode = BEST;
|
||||
|
||||
if (deadline) {
|
||||
// Convert duration parameter from stream timebase to microseconds
|
||||
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)ctx->cfg.g_timebase.num /
|
||||
(uint64_t)ctx->cfg.g_timebase.den;
|
||||
(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_qc = (deadline > duration_us) ? ONE_PASS_GOOD : REALTIME;
|
||||
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->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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче