Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1613)

Unified Diff: source/libvpx/vp9/encoder/vp9_firstpass.c

Issue 394353005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_firstpass.h ('k') | source/libvpx/vp9/encoder/vp9_pickmode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/encoder/vp9_firstpass.c
===================================================================
--- source/libvpx/vp9/encoder/vp9_firstpass.c (revision 284462)
+++ source/libvpx/vp9/encoder/vp9_firstpass.c (working copy)
@@ -98,34 +98,6 @@
return &p->stats_in[offset];
}
-#if CONFIG_FP_MB_STATS
-static int input_mb_stats(FIRSTPASS_FRAME_MB_STATS *fp_frame_stats,
- const VP9_COMMON *const cm) {
- FILE *fpfile;
- int ret;
-
- fpfile = fopen("firstpass_mb.stt", "r");
- fseek(fpfile, cm->current_video_frame * cm->MBs * sizeof(FIRSTPASS_MB_STATS),
- SEEK_SET);
- ret = fread(fp_frame_stats->mb_stats, sizeof(FIRSTPASS_MB_STATS), cm->MBs,
- fpfile);
- fclose(fpfile);
- if (ret < cm->MBs) {
- return EOF;
- }
- return 1;
-}
-
-static void output_mb_stats(FIRSTPASS_FRAME_MB_STATS *fp_frame_stats,
- const VP9_COMMON *const cm) {
- FILE *fpfile;
-
- fpfile = fopen("firstpass_mb.stt", "a");
- fwrite(fp_frame_stats->mb_stats, sizeof(FIRSTPASS_MB_STATS), cm->MBs, fpfile);
- fclose(fpfile);
-}
-#endif
-
static int input_stats(TWO_PASS *p, FIRSTPASS_STATS *fps) {
if (p->stats_in >= p->stats_in_end)
return EOF;
@@ -175,6 +147,17 @@
#endif
}
+#if CONFIG_FP_MB_STATS
+static void output_fpmb_stats(uint8_t *this_frame_mb_stats, VP9_COMMON *cm,
+ struct vpx_codec_pkt_list *pktlist) {
+ struct vpx_codec_cx_pkt pkt;
+ pkt.kind = VPX_CODEC_FPMB_STATS_PKT;
+ pkt.data.firstpass_mb_stats.buf = this_frame_mb_stats;
+ pkt.data.firstpass_mb_stats.sz = cm->MBs * sizeof(uint8_t);
+ vpx_codec_pkt_list_add(pktlist, &pkt);
+}
+#endif
+
static void zero_stats(FIRSTPASS_STATS *section) {
section->frame = 0.0;
section->intra_error = 0.0;
@@ -473,7 +456,9 @@
const YV12_BUFFER_CONFIG *first_ref_buf = lst_yv12;
#if CONFIG_FP_MB_STATS
- FIRSTPASS_FRAME_MB_STATS *this_frame_mb_stats = &twopass->this_frame_mb_stats;
+ if (cpi->use_fp_mb_stats) {
+ vp9_zero_array(cpi->twopass.frame_mb_stats_buf, cm->MBs);
+ }
#endif
vp9_clear_system_state();
@@ -486,25 +471,34 @@
const YV12_BUFFER_CONFIG *scaled_ref_buf = NULL;
twopass = &cpi->svc.layer_context[cpi->svc.spatial_layer_id].twopass;
+ if (cpi->common.current_video_frame == 0) {
+ cpi->ref_frame_flags = 0;
+ } else {
+ LAYER_CONTEXT *lc = &cpi->svc.layer_context[cpi->svc.spatial_layer_id];
+ if (lc->current_video_frame_in_layer == 0)
+ cpi->ref_frame_flags = VP9_GOLD_FLAG;
+ else
+ cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG;
+ }
+
vp9_scale_references(cpi);
// Use either last frame or alt frame for motion search.
if (cpi->ref_frame_flags & VP9_LAST_FLAG) {
scaled_ref_buf = vp9_get_scaled_ref_frame(cpi, LAST_FRAME);
ref_frame = LAST_FRAME;
- } else if (cpi->ref_frame_flags & VP9_ALT_FLAG) {
- scaled_ref_buf = vp9_get_scaled_ref_frame(cpi, ALTREF_FRAME);
- ref_frame = ALTREF_FRAME;
+ } else if (cpi->ref_frame_flags & VP9_GOLD_FLAG) {
+ scaled_ref_buf = vp9_get_scaled_ref_frame(cpi, GOLDEN_FRAME);
+ ref_frame = GOLDEN_FRAME;
}
- if (scaled_ref_buf != NULL) {
- // Update the stride since we are using scaled reference buffer
+ if (scaled_ref_buf != NULL)
first_ref_buf = scaled_ref_buf;
- recon_y_stride = first_ref_buf->y_stride;
- recon_uv_stride = first_ref_buf->uv_stride;
- uv_mb_height = 16 >> (first_ref_buf->y_height > first_ref_buf->uv_height);
- }
+ recon_y_stride = new_yv12->y_stride;
+ recon_uv_stride = new_yv12->uv_stride;
+ uv_mb_height = 16 >> (new_yv12->y_height > new_yv12->uv_height);
+
// Disable golden frame for svc first pass for now.
gld_yv12 = NULL;
set_ref_ptrs(cm, xd, ref_frame, NONE);
@@ -605,12 +599,7 @@
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
- this_frame_mb_stats->mb_stats[mb_row * cm->mb_cols + mb_col].mode =
- DC_PRED;
- this_frame_mb_stats->mb_stats[mb_row * cm->mb_cols + mb_col].err =
- this_error;
- this_frame_mb_stats->mb_stats[mb_row * cm->mb_cols + mb_col].mv.as_int
- = 0;
+ // TODO(pengchong): store some related block statistics here
}
#endif
@@ -741,12 +730,7 @@
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
- this_frame_mb_stats->mb_stats[mb_row * cm->mb_cols + mb_col].mode =
- NEWMV;
- this_frame_mb_stats->mb_stats[mb_row * cm->mb_cols + mb_col].err =
- motion_error;
- this_frame_mb_stats->mb_stats[mb_row * cm->mb_cols + mb_col].mv.
- as_int = mv.as_int;
+ // TODO(pengchong): save some related block statistics here
}
#endif
@@ -857,7 +841,7 @@
#if CONFIG_FP_MB_STATS
if (cpi->use_fp_mb_stats) {
- output_mb_stats(this_frame_mb_stats, cm);
+ output_fpmb_stats(twopass->frame_mb_stats_buf, cm, cpi->output_pkt_list);
}
#endif
}
@@ -909,6 +893,8 @@
}
++cm->current_video_frame;
+ if (cpi->use_svc)
+ vp9_inc_frame_in_layer(&cpi->svc);
}
static double calc_correction_factor(double err_per_mb,
@@ -1506,7 +1492,7 @@
double mv_in_out_accumulator = 0.0;
double abs_mv_in_out_accumulator = 0.0;
double mv_ratio_accumulator_thresh;
- unsigned int allow_alt_ref = is_altref_enabled(oxcf);
+ unsigned int allow_alt_ref = is_altref_enabled(cpi);
int f_boost = 0;
int b_boost = 0;
@@ -2080,6 +2066,11 @@
default:
assert(0);
}
+ if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) {
+ cpi->refresh_golden_frame = 0;
+ if (cpi->alt_ref_source == NULL)
+ cpi->refresh_alt_ref_frame = 0;
+ }
}
@@ -2122,6 +2113,18 @@
#endif
vp9_rc_set_frame_target(cpi, target_rate);
cm->frame_type = INTER_FRAME;
+
+ if (is_spatial_svc) {
+ if (cpi->svc.spatial_layer_id == 0) {
+ lc->is_key_frame = 0;
+ } else {
+ lc->is_key_frame = cpi->svc.layer_context[0].is_key_frame;
+
+ if (lc->is_key_frame)
+ cpi->ref_frame_flags &= (~VP9_LAST_FLAG);
+ }
+ }
+
return;
}
@@ -2189,17 +2192,10 @@
}
rc->frames_till_gf_update_due = rc->baseline_gf_interval;
- cpi->refresh_golden_frame = 1;
+ if (!is_spatial_svc)
+ cpi->refresh_golden_frame = 1;
}
- {
- FIRSTPASS_STATS next_frame;
- if (lookup_next_frame_stats(twopass, &next_frame) != EOF) {
- twopass->next_iiratio = (int)(next_frame.intra_error /
- DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
- }
- }
-
configure_buffer_updates(cpi);
target_rate = twopass->gf_group.bit_allocation[twopass->gf_group.index];
@@ -2218,12 +2214,6 @@
// Update the total stats remaining structure.
subtract_stats(&twopass->total_left_stats, &this_frame);
-
-#if CONFIG_FP_MB_STATS
- if (cpi->use_fp_mb_stats) {
- input_mb_stats(&twopass->this_frame_mb_stats, cm);
- }
-#endif
}
void vp9_twopass_postencode_update(VP9_COMP *cpi) {
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_firstpass.h ('k') | source/libvpx/vp9/encoder/vp9_pickmode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698