Index: source/libvpx/vp9/vp9_cx_iface.c |
=================================================================== |
--- source/libvpx/vp9/vp9_cx_iface.c (revision 232232) |
+++ source/libvpx/vp9/vp9_cx_iface.c (working copy) |
@@ -8,30 +8,30 @@ |
* be found in the AUTHORS file in the root of the source tree. |
*/ |
+#include <stdlib.h> |
+#include <string.h> |
#include "vpx/vpx_codec.h" |
#include "vpx/internal/vpx_codec_internal.h" |
-#include "vpx_version.h" |
+#include "./vpx_version.h" |
#include "vp9/encoder/vp9_onyx_int.h" |
#include "vpx/vp8cx.h" |
#include "vp9/encoder/vp9_firstpass.h" |
#include "vp9/common/vp9_onyx.h" |
#include "vp9/vp9_iface_common.h" |
-#include <stdlib.h> |
-#include <string.h> |
struct vp9_extracfg { |
struct vpx_codec_pkt_list *pkt_list; |
- int cpu_used; /** available cpu percentage in 1/16*/ |
- unsigned int enable_auto_alt_ref; /** if encoder decides to uses alternate reference frame */ |
+ int cpu_used; /* available cpu percentage in 1/16 */ |
+ unsigned int enable_auto_alt_ref; |
unsigned int noise_sensitivity; |
unsigned int Sharpness; |
unsigned int static_thresh; |
unsigned int tile_columns; |
unsigned int tile_rows; |
- unsigned int arnr_max_frames; /* alt_ref Noise Reduction Max Frame Count */ |
- unsigned int arnr_strength; /* alt_ref Noise Reduction Strength */ |
- unsigned int arnr_type; /* alt_ref filter type */ |
+ unsigned int arnr_max_frames; |
+ unsigned int arnr_strength; |
+ unsigned int arnr_type; |
unsigned int experimental; |
vp8e_tuning tuning; |
unsigned int cq_level; /* constrained quality level */ |
@@ -48,7 +48,7 @@ |
static const struct extraconfig_map extracfg_map[] = { |
{ |
0, |
- { |
+ { // NOLINT |
NULL, |
0, /* cpu_used */ |
1, /* enable_auto_alt_ref */ |
@@ -85,11 +85,11 @@ |
uint32_t pending_frame_magnitude; |
vpx_image_t preview_img; |
vp8_postproc_cfg_t preview_ppcfg; |
- vpx_codec_pkt_list_decl(64) pkt_list; // changed to accomendate the maximum number of lagged frames allowed |
+ vpx_codec_pkt_list_decl(64) pkt_list; |
unsigned int fixed_kf_cntr; |
}; |
-static const VP9_REFFRAME ref_frame_to_vp9_reframe(vpx_ref_frame_type_t frame) { |
+static VP9_REFFRAME ref_frame_to_vp9_reframe(vpx_ref_frame_type_t frame) { |
switch (frame) { |
case VP8_LAST_FRAME: |
return VP9_LAST_FLAG; |
@@ -120,26 +120,26 @@ |
#define ERROR(str) do {\ |
ctx->base.err_detail = str;\ |
return VPX_CODEC_INVALID_PARAM;\ |
- } while(0) |
+ } while (0) |
-#define RANGE_CHECK(p,memb,lo,hi) do {\ |
- if(!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \ |
+#define RANGE_CHECK(p, memb, lo, hi) do {\ |
+ if (!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \ |
ERROR(#memb " out of range ["#lo".."#hi"]");\ |
- } while(0) |
+ } while (0) |
-#define RANGE_CHECK_HI(p,memb,hi) do {\ |
- if(!((p)->memb <= (hi))) \ |
+#define RANGE_CHECK_HI(p, memb, hi) do {\ |
+ if (!((p)->memb <= (hi))) \ |
ERROR(#memb " out of range [.."#hi"]");\ |
- } while(0) |
+ } while (0) |
-#define RANGE_CHECK_LO(p,memb,lo) do {\ |
- if(!((p)->memb >= (lo))) \ |
+#define RANGE_CHECK_LO(p, memb, lo) do {\ |
+ if (!((p)->memb >= (lo))) \ |
ERROR(#memb " out of range ["#lo"..]");\ |
- } while(0) |
+ } while (0) |
-#define RANGE_CHECK_BOOL(p,memb) do {\ |
- if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\ |
- } while(0) |
+#define RANGE_CHECK_BOOL(p, memb) do {\ |
+ if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\ |
+ } while (0) |
static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, |
const vpx_codec_enc_cfg_t *cfg, |
@@ -247,7 +247,8 @@ |
oxcf->width = cfg.g_w; |
oxcf->height = cfg.g_h; |
/* guess a frame rate if out of whack, use 30 */ |
- oxcf->framerate = (double)(cfg.g_timebase.den) / (double)(cfg.g_timebase.num); |
+ oxcf->framerate = (double)(cfg.g_timebase.den) |
+ / (double)(cfg.g_timebase.num); |
if (oxcf->framerate > 180) { |
oxcf->framerate = 30; |
@@ -255,7 +256,7 @@ |
switch (cfg.g_pass) { |
case VPX_RC_ONE_PASS: |
- oxcf->Mode = MODE_BESTQUALITY; |
+ oxcf->Mode = MODE_GOODQUALITY; |
break; |
case VPX_RC_FIRST_PASS: |
oxcf->Mode = MODE_FIRSTPASS; |
@@ -266,25 +267,25 @@ |
} |
if (cfg.g_pass == VPX_RC_FIRST_PASS) { |
- oxcf->allow_lag = 0; |
- oxcf->lag_in_frames = 0; |
+ oxcf->allow_lag = 0; |
+ oxcf->lag_in_frames = 0; |
} else { |
- oxcf->allow_lag = (cfg.g_lag_in_frames) > 0; |
- oxcf->lag_in_frames = cfg.g_lag_in_frames; |
+ oxcf->allow_lag = (cfg.g_lag_in_frames) > 0; |
+ oxcf->lag_in_frames = cfg.g_lag_in_frames; |
} |
// VBR only supported for now. |
// CBR code has been deprectated for experimental phase. |
// CQ mode not yet tested |
oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK; |
- /* |
if (cfg.rc_end_usage == VPX_CQ) |
oxcf->end_usage = USAGE_CONSTRAINED_QUALITY; |
- */ |
- if (cfg.rc_end_usage == VPX_Q) |
+ else if (cfg.rc_end_usage == VPX_Q) |
oxcf->end_usage = USAGE_CONSTANT_QUALITY; |
+ else if (cfg.rc_end_usage == VPX_CBR) |
+ oxcf->end_usage = USAGE_STREAM_FROM_SERVER; |
- oxcf->target_bandwidth = cfg.rc_target_bitrate; |
+ oxcf->target_bandwidth = cfg.rc_target_bitrate; |
oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct; |
oxcf->best_allowed_q = cfg.rc_min_quantizer; |
@@ -299,7 +300,7 @@ |
oxcf->starting_buffer_level = cfg.rc_buf_initial_sz; |
oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz; |
- oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct; |
+ oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct; |
oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct; |
oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct; |
@@ -315,23 +316,23 @@ |
oxcf->encode_breakout = vp8_cfg.static_thresh; |
oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref; |
oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity; |
- oxcf->Sharpness = vp8_cfg.Sharpness; |
+ oxcf->Sharpness = vp8_cfg.Sharpness; |
- oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in; |
- oxcf->output_pkt_list = vp8_cfg.pkt_list; |
+ oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in; |
+ oxcf->output_pkt_list = vp8_cfg.pkt_list; |
oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames; |
- oxcf->arnr_strength = vp8_cfg.arnr_strength; |
- oxcf->arnr_type = vp8_cfg.arnr_type; |
+ oxcf->arnr_strength = vp8_cfg.arnr_strength; |
+ oxcf->arnr_type = vp8_cfg.arnr_type; |
oxcf->tuning = vp8_cfg.tuning; |
oxcf->tile_columns = vp8_cfg.tile_columns; |
- oxcf->tile_rows = vp8_cfg.tile_rows; |
+ oxcf->tile_rows = vp8_cfg.tile_rows; |
oxcf->lossless = vp8_cfg.lossless; |
- oxcf->error_resilient_mode = cfg.g_error_resilient; |
+ oxcf->error_resilient_mode = cfg.g_error_resilient; |
oxcf->frame_parallel_decoding_mode = vp8_cfg.frame_parallel_decoding_mode; |
oxcf->ss_number_layers = cfg.ss_number_layers; |
@@ -500,7 +501,7 @@ |
*/ |
for (i = 0; |
extracfg_map[i].usage && extracfg_map[i].usage != cfg->g_usage; |
- i++); |
+ i++) {} |
priv->vp8_cfg = extracfg_map[i].cfg; |
priv->vp8_cfg.pkt_list = &priv->pkt_list.head; |
@@ -555,7 +556,6 @@ |
static vpx_codec_err_t vp9e_destroy(vpx_codec_alg_priv_t *ctx) { |
- |
free(ctx->cx_data); |
vp9_remove_compressor(&ctx->cpi); |
free(ctx); |
@@ -714,8 +714,10 @@ |
lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0; |
/* vp8 use 10,000,000 ticks/second as time stamp */ |
- dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den; |
- dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den; |
+ dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num |
+ / ctx->cfg.g_timebase.den; |
+ dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / |
+ ctx->cfg.g_timebase.den; |
if (img != NULL) { |
res = image2yuvconfig(img, &sd); |
@@ -769,7 +771,7 @@ |
} |
/* Add the frame packet to the list of returned packets. */ |
- round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1; |
+ round = (vpx_codec_pts_t)1000000 * ctx->cfg.g_timebase.num / 2 - 1; |
delta = (dst_end_time_stamp - dst_time_stamp); |
pkt.kind = VPX_CODEC_CX_FRAME_PKT; |
pkt.data.frame.pts = |
@@ -841,8 +843,6 @@ |
cx_data += size; |
cx_data_sz -= size; |
} |
- |
- // printf("timestamp: %lld, duration: %d\n", pkt->data.frame.pts, pkt->data.frame.duration); |
} |
} |
} |
@@ -869,15 +869,14 @@ |
vp9_set_reference_enc(ctx->cpi, ref_frame_to_vp9_reframe(frame->frame_type), |
&sd); |
return VPX_CODEC_OK; |
- } else |
+ } else { |
return VPX_CODEC_INVALID_PARAM; |
- |
+ } |
} |
static vpx_codec_err_t vp9e_copy_reference(vpx_codec_alg_priv_t *ctx, |
int ctr_id, |
va_list args) { |
- |
vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); |
if (data) { |
@@ -888,8 +887,9 @@ |
vp9_copy_reference_enc(ctx->cpi, |
ref_frame_to_vp9_reframe(frame->frame_type), &sd); |
return VPX_CODEC_OK; |
- } else |
+ } else { |
return VPX_CODEC_INVALID_PARAM; |
+ } |
} |
static vpx_codec_err_t get_reference(vpx_codec_alg_priv_t *ctx, |
@@ -918,8 +918,9 @@ |
if (data) { |
ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data); |
return VPX_CODEC_OK; |
- } else |
+ } else { |
return VPX_CODEC_INVALID_PARAM; |
+ } |
#else |
(void)ctx; |
(void)ctr_id; |
@@ -930,7 +931,6 @@ |
static vpx_image_t *vp9e_get_preview(vpx_codec_alg_priv_t *ctx) { |
- |
YV12_BUFFER_CONFIG sd; |
vp9_ppflags_t flags = {0}; |
@@ -943,8 +943,9 @@ |
if (0 == vp9_get_preview_raw_frame(ctx->cpi, &sd, &flags)) { |
yuvconfig2image(&ctx->preview_img, &sd, NULL); |
return &ctx->preview_img; |
- } else |
+ } else { |
return NULL; |
+ } |
} |
static vpx_codec_err_t vp9e_update_entropy(vpx_codec_alg_priv_t *ctx, |
@@ -953,7 +954,6 @@ |
int update = va_arg(args, int); |
vp9_update_entropy(ctx->cpi, update); |
return VPX_CODEC_OK; |
- |
} |
static vpx_codec_err_t vp9e_update_reference(vpx_codec_alg_priv_t *ctx, |
@@ -975,56 +975,38 @@ |
static vpx_codec_err_t vp9e_set_roi_map(vpx_codec_alg_priv_t *ctx, |
int ctr_id, |
va_list args) { |
- vpx_roi_map_t *data = va_arg(args, vpx_roi_map_t *); |
- |
- if (data) { |
- vpx_roi_map_t *roi = (vpx_roi_map_t *)data; |
- |
- if (!vp9_set_roimap(ctx->cpi, roi->roi_map, roi->rows, roi->cols, |
- roi->delta_q, roi->delta_lf, roi->static_threshold)) |
- return VPX_CODEC_OK; |
- else |
- return VPX_CODEC_INVALID_PARAM; |
- } else |
- return VPX_CODEC_INVALID_PARAM; |
+ // TODO(yaowu): Need to re-implement and test for VP9. |
+ return VPX_CODEC_INVALID_PARAM; |
} |
static vpx_codec_err_t vp9e_set_activemap(vpx_codec_alg_priv_t *ctx, |
int ctr_id, |
va_list args) { |
- vpx_active_map_t *data = va_arg(args, vpx_active_map_t *); |
- |
- if (data) { |
- |
- vpx_active_map_t *map = (vpx_active_map_t *)data; |
- |
- if (!vp9_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols)) |
- return VPX_CODEC_OK; |
- else |
- return VPX_CODEC_INVALID_PARAM; |
- } else |
- return VPX_CODEC_INVALID_PARAM; |
+ // TODO(yaowu): Need to re-implement and test for VP9. |
+ return VPX_CODEC_INVALID_PARAM; |
} |
static vpx_codec_err_t vp9e_set_scalemode(vpx_codec_alg_priv_t *ctx, |
int ctr_id, |
va_list args) { |
- |
vpx_scaling_mode_t *data = va_arg(args, vpx_scaling_mode_t *); |
if (data) { |
int res; |
vpx_scaling_mode_t scalemode = *(vpx_scaling_mode_t *)data; |
- res = vp9_set_internal_size(ctx->cpi, scalemode.h_scaling_mode, |
- scalemode.v_scaling_mode); |
+ res = vp9_set_internal_size(ctx->cpi, |
+ (VPX_SCALING)scalemode.h_scaling_mode, |
+ (VPX_SCALING)scalemode.v_scaling_mode); |
if (!res) { |
return VPX_CODEC_OK; |
- } else |
+ } else { |
return VPX_CODEC_INVALID_PARAM; |
- } else |
+ } |
+ } else { |
return VPX_CODEC_INVALID_PARAM; |
+ } |
} |
static vpx_codec_err_t vp9e_set_width(vpx_codec_alg_priv_t *ctx, int ctr_id, |
@@ -1130,7 +1112,7 @@ |
static vpx_codec_enc_cfg_map_t vp9e_usage_cfg_map[] = { |
{ |
0, |
- { |
+ { // NOLINT |
0, /* g_usage */ |
0, /* g_threads */ |
0, /* g_profile */ |
@@ -1199,13 +1181,13 @@ |
vp9e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ |
NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ |
NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ |
- { |
+ { // NOLINT |
NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */ |
NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */ |
NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */ |
NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */ |
}, |
- { |
+ { // NOLINT |
vp9e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ |
vp9e_encode, /* vpx_codec_encode_fn_t encode; */ |
vp9e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ |
@@ -1228,13 +1210,13 @@ |
vp9e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ |
NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ |
NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ |
- { |
+ { // NOLINT |
NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */ |
NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */ |
NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */ |
NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */ |
}, |
- { |
+ { // NOLINT |
vp9e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ |
vp9e_encode, /* vpx_codec_encode_fn_t encode; */ |
vp9e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ |