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

Side by Side Diff: source/libvpx/vp8/encoder/firstpass.c

Issue 1162573005: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « source/libvpx/vp8/encoder/ethreading.c ('k') | source/libvpx/vp8/encoder/modecosts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <math.h> 11 #include <math.h>
12 #include <limits.h> 12 #include <limits.h>
13 #include <stdio.h> 13 #include <stdio.h>
14 14
15 #include "./vpx_dsp_rtcd.h"
15 #include "./vpx_scale_rtcd.h" 16 #include "./vpx_scale_rtcd.h"
16 #include "block.h" 17 #include "block.h"
17 #include "onyx_int.h" 18 #include "onyx_int.h"
18 #include "vp8/common/variance.h" 19 #include "vp8/common/variance.h"
19 #include "encodeintra.h" 20 #include "encodeintra.h"
20 #include "vp8/common/setupintrarecon.h" 21 #include "vp8/common/setupintrarecon.h"
21 #include "vp8/common/systemdependent.h" 22 #include "vp8/common/systemdependent.h"
22 #include "mcomp.h" 23 #include "mcomp.h"
23 #include "firstpass.h" 24 #include "firstpass.h"
24 #include "vpx_scale/vpx_scale.h" 25 #include "vpx_scale/vpx_scale.h"
25 #include "encodemb.h" 26 #include "encodemb.h"
26 #include "vp8/common/extend.h" 27 #include "vp8/common/extend.h"
27 #include "vpx_mem/vpx_mem.h" 28 #include "vpx_mem/vpx_mem.h"
28 #include "vp8/common/swapyv12buffer.h" 29 #include "vp8/common/swapyv12buffer.h"
29 #include "rdopt.h" 30 #include "rdopt.h"
30 #include "vp8/common/quant_common.h" 31 #include "vp8/common/quant_common.h"
31 #include "encodemv.h" 32 #include "encodemv.h"
32 #include "encodeframe.h" 33 #include "encodeframe.h"
33 34
34 /* #define OUTPUT_FPF 1 */ 35 /* #define OUTPUT_FPF 1 */
35 36
36 extern void vp8cx_frame_init_quantizer(VP8_COMP *cpi); 37 extern void vp8cx_frame_init_quantizer(VP8_COMP *cpi);
37 extern void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv);
38 extern void vp8_alloc_compressor_data(VP8_COMP *cpi);
39 38
40 #define GFQ_ADJUSTMENT vp8_gf_boost_qadjustment[Q] 39 #define GFQ_ADJUSTMENT vp8_gf_boost_qadjustment[Q]
41 extern int vp8_kf_boost_qadjustment[QINDEX_RANGE]; 40 extern int vp8_kf_boost_qadjustment[QINDEX_RANGE];
42 41
43 extern const int vp8_gf_boost_qadjustment[QINDEX_RANGE]; 42 extern const int vp8_gf_boost_qadjustment[QINDEX_RANGE];
44 43
45 #define IIFACTOR 1.5 44 #define IIFACTOR 1.5
46 #define IIKFACTOR1 1.40 45 #define IIKFACTOR1 1.40
47 #define IIKFACTOR2 1.5 46 #define IIKFACTOR2 1.5
48 #define RMAX 14.0 47 #define RMAX 14.0
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 int src_stride = b->src_stride; 416 int src_stride = b->src_stride;
418 unsigned char *raw_ptr; 417 unsigned char *raw_ptr;
419 int raw_stride = raw_buffer->y_stride; 418 int raw_stride = raw_buffer->y_stride;
420 unsigned char *ref_ptr; 419 unsigned char *ref_ptr;
421 int ref_stride = x->e_mbd.pre.y_stride; 420 int ref_stride = x->e_mbd.pre.y_stride;
422 (void)cpi; 421 (void)cpi;
423 422
424 /* Set up pointers for this macro block raw buffer */ 423 /* Set up pointers for this macro block raw buffer */
425 raw_ptr = (unsigned char *)(raw_buffer->y_buffer + recon_yoffset 424 raw_ptr = (unsigned char *)(raw_buffer->y_buffer + recon_yoffset
426 + d->offset); 425 + d->offset);
427 vp8_mse16x16 ( src_ptr, src_stride, raw_ptr, raw_stride, 426 vpx_mse16x16(src_ptr, src_stride, raw_ptr, raw_stride,
428 (unsigned int *)(raw_motion_err)); 427 (unsigned int *)(raw_motion_err));
429 428
430 /* Set up pointers for this macro block recon buffer */ 429 /* Set up pointers for this macro block recon buffer */
431 xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset; 430 xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
432 ref_ptr = (unsigned char *)(xd->pre.y_buffer + d->offset ); 431 ref_ptr = (unsigned char *)(xd->pre.y_buffer + d->offset );
433 vp8_mse16x16 ( src_ptr, src_stride, ref_ptr, ref_stride, 432 vpx_mse16x16(src_ptr, src_stride, ref_ptr, ref_stride,
434 (unsigned int *)(best_motion_err)); 433 (unsigned int *)(best_motion_err));
435 } 434 }
436 435
437 static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x, 436 static void first_pass_motion_search(VP8_COMP *cpi, MACROBLOCK *x,
438 int_mv *ref_mv, MV *best_mv, 437 int_mv *ref_mv, MV *best_mv,
439 YV12_BUFFER_CONFIG *recon_buffer, 438 YV12_BUFFER_CONFIG *recon_buffer,
440 int *best_motion_err, int recon_yoffset ) 439 int *best_motion_err, int recon_yoffset )
441 { 440 {
442 MACROBLOCKD *const xd = & x->e_mbd; 441 MACROBLOCKD *const xd = & x->e_mbd;
443 BLOCK *b = &x->block[0]; 442 BLOCK *b = &x->block[0];
444 BLOCKD *d = &x->e_mbd.block[0]; 443 BLOCKD *d = &x->e_mbd.block[0];
445 int num00; 444 int num00;
446 445
447 int_mv tmp_mv; 446 int_mv tmp_mv;
448 int_mv ref_mv_full; 447 int_mv ref_mv_full;
449 448
450 int tmp_err; 449 int tmp_err;
451 int step_param = 3; /* Dont search over full range for first pass */ 450 int step_param = 3; /* Dont search over full range for first pass */
452 int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param; 451 int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
453 int n; 452 int n;
454 vp8_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16]; 453 vp8_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
455 int new_mv_mode_penalty = 256; 454 int new_mv_mode_penalty = 256;
456 455
457 /* override the default variance function to use MSE */ 456 /* override the default variance function to use MSE */
458 v_fn_ptr.vf = vp8_mse16x16; 457 v_fn_ptr.vf = vpx_mse16x16;
459 458
460 /* Set up pointers for this macro block recon buffer */ 459 /* Set up pointers for this macro block recon buffer */
461 xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset; 460 xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
462 461
463 /* Initial step/diamond search centred on best mv */ 462 /* Initial step/diamond search centred on best mv */
464 tmp_mv.as_int = 0; 463 tmp_mv.as_int = 0;
465 ref_mv_full.as_mv.col = ref_mv->as_mv.col>>3; 464 ref_mv_full.as_mv.col = ref_mv->as_mv.col>>3;
466 ref_mv_full.as_mv.row = ref_mv->as_mv.row>>3; 465 ref_mv_full.as_mv.row = ref_mv->as_mv.row>>3;
467 tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param , 466 tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv, step_param ,
468 x->sadperbit16, &num00, &v_fn_ptr, 467 x->sadperbit16, &num00, &v_fn_ptr,
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 fprintf(f, "%8d %8d %8d %8.2f %8.3f %8.2f %8.3f %8.3f %8.3f %8d\n", cpi- >common.current_video_frame, bits_per_mb_at_this_q, 1321 fprintf(f, "%8d %8d %8d %8.2f %8.3f %8.2f %8.3f %8.3f %8.3f %8d\n", cpi- >common.current_video_frame, bits_per_mb_at_this_q,
1323 target_norm_bits_per_mb, err_per_mb, err_correction_factor, 1322 target_norm_bits_per_mb, err_per_mb, err_correction_factor,
1324 current_spend_ratio, group_iiratio, iiratio_correction_factor, 1323 current_spend_ratio, group_iiratio, iiratio_correction_factor,
1325 (double)cpi->buffer_level / (double)cpi->oxcf.optimal_buffer_lev el, Q); 1324 (double)cpi->buffer_level / (double)cpi->oxcf.optimal_buffer_lev el, Q);
1326 fclose(f); 1325 fclose(f);
1327 } 1326 }
1328 1327
1329 return Q; 1328 return Q;
1330 } 1329 }
1331 1330
1332 extern void vp8_new_framerate(VP8_COMP *cpi, double framerate);
1333
1334 void vp8_init_second_pass(VP8_COMP *cpi) 1331 void vp8_init_second_pass(VP8_COMP *cpi)
1335 { 1332 {
1336 FIRSTPASS_STATS this_frame; 1333 FIRSTPASS_STATS this_frame;
1337 FIRSTPASS_STATS *start_pos; 1334 FIRSTPASS_STATS *start_pos;
1338 1335
1339 double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth * cpi->oxcf.t wo_pass_vbrmin_section / 100); 1336 double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth * cpi->oxcf.t wo_pass_vbrmin_section / 100);
1340 1337
1341 zero_stats(&cpi->twopass.total_stats); 1338 zero_stats(&cpi->twopass.total_stats);
1342 zero_stats(&cpi->twopass.total_left_stats); 1339 zero_stats(&cpi->twopass.total_left_stats);
1343 1340
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
3362 } 3359 }
3363 3360
3364 if ((cpi->common.Width != new_width) || (cpi->common.Height != new_heigh t)) 3361 if ((cpi->common.Width != new_width) || (cpi->common.Height != new_heigh t))
3365 { 3362 {
3366 cpi->common.Width = new_width; 3363 cpi->common.Width = new_width;
3367 cpi->common.Height = new_height; 3364 cpi->common.Height = new_height;
3368 vp8_alloc_compressor_data(cpi); 3365 vp8_alloc_compressor_data(cpi);
3369 } 3366 }
3370 } 3367 }
3371 } 3368 }
OLDNEW
« no previous file with comments | « source/libvpx/vp8/encoder/ethreading.c ('k') | source/libvpx/vp8/encoder/modecosts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698