| OLD | NEW |
| 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 <assert.h> |
| 12 #include <limits.h> |
| 13 #include <math.h> |
| 14 #include <stdio.h> |
| 15 #include <stdlib.h> |
| 16 #include <string.h> |
| 11 | 17 |
| 12 #include <stdlib.h> | 18 #include "vpx_mem/vpx_mem.h" |
| 13 #include <stdio.h> | |
| 14 #include <string.h> | |
| 15 #include <limits.h> | |
| 16 #include <assert.h> | |
| 17 #include <math.h> | |
| 18 | 19 |
| 19 #include "vp9/common/vp9_alloccommon.h" | 20 #include "vp9/common/vp9_alloccommon.h" |
| 20 #include "vp9/common/vp9_common.h" | 21 #include "vp9/common/vp9_common.h" |
| 21 #include "vp9/encoder/vp9_ratectrl.h" | |
| 22 #include "vp9/common/vp9_entropymode.h" | 22 #include "vp9/common/vp9_entropymode.h" |
| 23 #include "vpx_mem/vpx_mem.h" | |
| 24 #include "vp9/common/vp9_systemdependent.h" | |
| 25 #include "vp9/encoder/vp9_encodemv.h" | |
| 26 #include "vp9/common/vp9_quant_common.h" | 23 #include "vp9/common/vp9_quant_common.h" |
| 27 #include "vp9/common/vp9_seg_common.h" | 24 #include "vp9/common/vp9_seg_common.h" |
| 25 #include "vp9/common/vp9_systemdependent.h" |
| 26 |
| 27 #include "vp9/encoder/vp9_encodemv.h" |
| 28 #include "vp9/encoder/vp9_ratectrl.h" |
| 28 | 29 |
| 29 #define LIMIT_QRANGE_FOR_ALTREF_AND_KEY 1 | 30 #define LIMIT_QRANGE_FOR_ALTREF_AND_KEY 1 |
| 30 | 31 |
| 31 #define MIN_BPB_FACTOR 0.005 | 32 #define MIN_BPB_FACTOR 0.005 |
| 32 #define MAX_BPB_FACTOR 50 | 33 #define MAX_BPB_FACTOR 50 |
| 33 | 34 |
| 34 // Bits Per MB at different Q (Multiplied by 512) | 35 // Bits Per MB at different Q (Multiplied by 512) |
| 35 #define BPER_MB_NORMBITS 9 | 36 #define BPER_MB_NORMBITS 9 |
| 36 | 37 |
| 37 // Tables relating active max Q to active min Q | 38 // Tables relating active max Q to active min Q |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 348 |
| 348 void vp9_rc_update_rate_correction_factors(VP9_COMP *cpi, int damp_var) { | 349 void vp9_rc_update_rate_correction_factors(VP9_COMP *cpi, int damp_var) { |
| 349 const int q = cpi->common.base_qindex; | 350 const int q = cpi->common.base_qindex; |
| 350 int correction_factor = 100; | 351 int correction_factor = 100; |
| 351 double rate_correction_factor = get_rate_correction_factor(cpi); | 352 double rate_correction_factor = get_rate_correction_factor(cpi); |
| 352 double adjustment_limit; | 353 double adjustment_limit; |
| 353 | 354 |
| 354 int projected_size_based_on_q = 0; | 355 int projected_size_based_on_q = 0; |
| 355 | 356 |
| 356 // Clear down mmx registers to allow floating point in what follows | 357 // Clear down mmx registers to allow floating point in what follows |
| 357 vp9_clear_system_state(); // __asm emms; | 358 vp9_clear_system_state(); |
| 358 | 359 |
| 359 // Work out how big we would have expected the frame to be at this Q given | 360 // Work out how big we would have expected the frame to be at this Q given |
| 360 // the current correction factor. | 361 // the current correction factor. |
| 361 // Stay in double to avoid int overflow when values are large | 362 // Stay in double to avoid int overflow when values are large |
| 362 projected_size_based_on_q = estimate_bits_at_q(cpi->common.frame_type, q, | 363 projected_size_based_on_q = estimate_bits_at_q(cpi->common.frame_type, q, |
| 363 cpi->common.MBs, | 364 cpi->common.MBs, |
| 364 rate_correction_factor); | 365 rate_correction_factor); |
| 365 // Work out a size correction factor. | 366 // Work out a size correction factor. |
| 366 if (projected_size_based_on_q > 0) | 367 if (projected_size_based_on_q > 0) |
| 367 correction_factor = (100 * cpi->rc.projected_frame_size) / | 368 correction_factor = (100 * cpi->rc.projected_frame_size) / |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 // Adjust active_worst_quality level based on buffer level. | 494 // Adjust active_worst_quality level based on buffer level. |
| 494 static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) { | 495 static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) { |
| 495 // Adjust active_worst_quality: If buffer is above the optimal/target level, | 496 // Adjust active_worst_quality: If buffer is above the optimal/target level, |
| 496 // bring active_worst_quality down depending on fullness of buffer. | 497 // bring active_worst_quality down depending on fullness of buffer. |
| 497 // If buffer is below the optimal level, let the active_worst_quality go from | 498 // If buffer is below the optimal level, let the active_worst_quality go from |
| 498 // ambient Q (at buffer = optimal level) to worst_quality level | 499 // ambient Q (at buffer = optimal level) to worst_quality level |
| 499 // (at buffer = critical level). | 500 // (at buffer = critical level). |
| 500 const VP9_CONFIG *oxcf = &cpi->oxcf; | 501 const VP9_CONFIG *oxcf = &cpi->oxcf; |
| 501 const RATE_CONTROL *rc = &cpi->rc; | 502 const RATE_CONTROL *rc = &cpi->rc; |
| 502 // Buffer level below which we push active_worst to worst_quality. | 503 // Buffer level below which we push active_worst to worst_quality. |
| 503 int critical_level = oxcf->optimal_buffer_level >> 2; | 504 int64_t critical_level = oxcf->optimal_buffer_level >> 2; |
| 505 int64_t buff_lvl_step = 0; |
| 504 int adjustment = 0; | 506 int adjustment = 0; |
| 505 int buff_lvl_step = 0; | |
| 506 int active_worst_quality; | 507 int active_worst_quality; |
| 507 if (cpi->common.frame_type == KEY_FRAME) | 508 if (cpi->common.frame_type == KEY_FRAME) |
| 508 return rc->worst_quality; | 509 return rc->worst_quality; |
| 509 if (cpi->common.current_video_frame > 1) | 510 if (cpi->common.current_video_frame > 1) |
| 510 active_worst_quality = MIN(rc->worst_quality, | 511 active_worst_quality = MIN(rc->worst_quality, |
| 511 rc->avg_frame_qindex[INTER_FRAME] * 5 / 4); | 512 rc->avg_frame_qindex[INTER_FRAME] * 5 / 4); |
| 512 else | 513 else |
| 513 active_worst_quality = MIN(rc->worst_quality, | 514 active_worst_quality = MIN(rc->worst_quality, |
| 514 rc->avg_frame_qindex[KEY_FRAME] * 3 / 2); | 515 rc->avg_frame_qindex[KEY_FRAME] * 3 / 2); |
| 515 if (rc->buffer_level > oxcf->optimal_buffer_level) { | 516 if (rc->buffer_level > oxcf->optimal_buffer_level) { |
| 516 // Adjust down. | 517 // Adjust down. |
| 517 // Maximum limit for down adjustment, ~30%. | 518 // Maximum limit for down adjustment, ~30%. |
| 518 int max_adjustment_down = active_worst_quality / 3; | 519 int max_adjustment_down = active_worst_quality / 3; |
| 519 if (max_adjustment_down) { | 520 if (max_adjustment_down) { |
| 520 buff_lvl_step = (int)((oxcf->maximum_buffer_size - | 521 buff_lvl_step = ((oxcf->maximum_buffer_size - |
| 521 oxcf->optimal_buffer_level) / max_adjustment_down); | 522 oxcf->optimal_buffer_level) / max_adjustment_down); |
| 522 if (buff_lvl_step) | 523 if (buff_lvl_step) |
| 523 adjustment = (int)((rc->buffer_level - oxcf->optimal_buffer_level) / | 524 adjustment = (int)((rc->buffer_level - oxcf->optimal_buffer_level) / |
| 524 buff_lvl_step); | 525 buff_lvl_step); |
| 525 active_worst_quality -= adjustment; | 526 active_worst_quality -= adjustment; |
| 526 } | 527 } |
| 527 } else if (rc->buffer_level > critical_level) { | 528 } else if (rc->buffer_level > critical_level) { |
| 528 // Adjust up from ambient Q. | 529 // Adjust up from ambient Q. |
| 529 if (critical_level) { | 530 if (critical_level) { |
| 530 buff_lvl_step = (oxcf->optimal_buffer_level - critical_level); | 531 buff_lvl_step = (oxcf->optimal_buffer_level - critical_level); |
| 531 if (buff_lvl_step) { | 532 if (buff_lvl_step) { |
| 532 adjustment = (rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) * | 533 adjustment = |
| 533 (oxcf->optimal_buffer_level - rc->buffer_level) / | 534 (int)((rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) * |
| 534 buff_lvl_step; | 535 (oxcf->optimal_buffer_level - rc->buffer_level) / |
| 536 buff_lvl_step); |
| 535 } | 537 } |
| 536 active_worst_quality = rc->avg_frame_qindex[INTER_FRAME] + adjustment; | 538 active_worst_quality = rc->avg_frame_qindex[INTER_FRAME] + adjustment; |
| 537 } | 539 } |
| 538 } else { | 540 } else { |
| 539 // Set to worst_quality if buffer is below critical level. | 541 // Set to worst_quality if buffer is below critical level. |
| 540 active_worst_quality = rc->worst_quality; | 542 active_worst_quality = rc->worst_quality; |
| 541 } | 543 } |
| 542 return active_worst_quality; | 544 return active_worst_quality; |
| 543 } | 545 } |
| 544 | 546 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 // cq value. | 952 // cq value. |
| 951 if (rc->rolling_actual_bits < rc->min_frame_bandwidth) | 953 if (rc->rolling_actual_bits < rc->min_frame_bandwidth) |
| 952 active_best_quality = oxcf->cq_level; | 954 active_best_quality = oxcf->cq_level; |
| 953 else | 955 else |
| 954 active_best_quality = cpi->cq_target_quality; | 956 active_best_quality = cpi->cq_target_quality; |
| 955 } | 957 } |
| 956 } | 958 } |
| 957 } | 959 } |
| 958 | 960 |
| 959 // Clip the active best and worst quality values to limits. | 961 // Clip the active best and worst quality values to limits. |
| 960 if (active_worst_quality > rc->worst_quality) | 962 active_best_quality = clamp(active_best_quality, |
| 961 active_worst_quality = rc->worst_quality; | 963 rc->best_quality, rc->worst_quality); |
| 962 | 964 active_worst_quality = clamp(active_worst_quality, |
| 963 if (active_best_quality < rc->best_quality) | 965 active_best_quality, rc->worst_quality); |
| 964 active_best_quality = rc->best_quality; | |
| 965 | |
| 966 if (active_best_quality > rc->worst_quality) | |
| 967 active_best_quality = rc->worst_quality; | |
| 968 | |
| 969 if (active_worst_quality < active_best_quality) | |
| 970 active_worst_quality = active_best_quality; | |
| 971 | 966 |
| 972 *top_index = active_worst_quality; | 967 *top_index = active_worst_quality; |
| 973 *bottom_index = active_best_quality; | 968 *bottom_index = active_best_quality; |
| 974 | 969 |
| 975 #if LIMIT_QRANGE_FOR_ALTREF_AND_KEY | 970 #if LIMIT_QRANGE_FOR_ALTREF_AND_KEY |
| 976 // Limit Q range for the adaptive loop. | 971 // Limit Q range for the adaptive loop. |
| 977 if (cm->frame_type == KEY_FRAME && !rc->this_key_frame_forced) { | 972 if (cm->frame_type == KEY_FRAME && !rc->this_key_frame_forced) { |
| 978 *top_index = (active_worst_quality + active_best_quality * 3) / 4; | 973 *top_index = (active_worst_quality + active_best_quality * 3) / 4; |
| 979 } else if (!rc->is_src_frame_alt_ref && | 974 } else if (!rc->is_src_frame_alt_ref && |
| 980 (oxcf->end_usage != USAGE_STREAM_FROM_SERVER) && | 975 (oxcf->end_usage != USAGE_STREAM_FROM_SERVER) && |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 q = rc_pick_q_and_bounds_one_pass_cbr(cpi, bottom_index, top_index); | 1028 q = rc_pick_q_and_bounds_one_pass_cbr(cpi, bottom_index, top_index); |
| 1034 else | 1029 else |
| 1035 q = rc_pick_q_and_bounds_one_pass_vbr(cpi, bottom_index, top_index); | 1030 q = rc_pick_q_and_bounds_one_pass_vbr(cpi, bottom_index, top_index); |
| 1036 } else { | 1031 } else { |
| 1037 q = rc_pick_q_and_bounds_two_pass(cpi, bottom_index, top_index); | 1032 q = rc_pick_q_and_bounds_two_pass(cpi, bottom_index, top_index); |
| 1038 } | 1033 } |
| 1039 | 1034 |
| 1040 // JBB : This is realtime mode. In real time mode the first frame | 1035 // JBB : This is realtime mode. In real time mode the first frame |
| 1041 // should be larger. Q of 0 is disabled because we force tx size to be | 1036 // should be larger. Q of 0 is disabled because we force tx size to be |
| 1042 // 16x16... | 1037 // 16x16... |
| 1043 if (cpi->sf.use_pick_mode) { | 1038 if (cpi->sf.use_nonrd_pick_mode) { |
| 1044 if (cpi->common.current_video_frame == 0) | 1039 if (cpi->common.current_video_frame == 0) |
| 1045 q /= 3; | 1040 q /= 3; |
| 1046 if (q == 0) | 1041 if (q == 0) |
| 1047 q++; | 1042 q++; |
| 1048 if (q < *bottom_index) | 1043 if (q < *bottom_index) |
| 1049 *bottom_index = q; | 1044 *bottom_index = q; |
| 1050 else if (q > *top_index) | 1045 else if (q > *top_index) |
| 1051 *top_index = q; | 1046 *top_index = q; |
| 1052 } | 1047 } |
| 1053 return q; | 1048 return q; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 rc->frames_since_golden++; | 1138 rc->frames_since_golden++; |
| 1144 } | 1139 } |
| 1145 } | 1140 } |
| 1146 | 1141 |
| 1147 void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { | 1142 void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { |
| 1148 VP9_COMMON *const cm = &cpi->common; | 1143 VP9_COMMON *const cm = &cpi->common; |
| 1149 RATE_CONTROL *const rc = &cpi->rc; | 1144 RATE_CONTROL *const rc = &cpi->rc; |
| 1150 | 1145 |
| 1151 cm->last_frame_type = cm->frame_type; | 1146 cm->last_frame_type = cm->frame_type; |
| 1152 // Update rate control heuristics | 1147 // Update rate control heuristics |
| 1153 rc->projected_frame_size = (bytes_used << 3); | 1148 rc->projected_frame_size = (int)(bytes_used << 3); |
| 1154 | 1149 |
| 1155 // Post encode loop adjustment of Q prediction. | 1150 // Post encode loop adjustment of Q prediction. |
| 1156 vp9_rc_update_rate_correction_factors( | 1151 vp9_rc_update_rate_correction_factors( |
| 1157 cpi, (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF || | 1152 cpi, (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF || |
| 1158 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) ? 2 : 0); | 1153 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) ? 2 : 0); |
| 1159 | 1154 |
| 1160 // Keep a record of last Q and ambient average Q. | 1155 // Keep a record of last Q and ambient average Q. |
| 1161 if (cm->frame_type == KEY_FRAME) { | 1156 if (cm->frame_type == KEY_FRAME) { |
| 1162 rc->last_q[KEY_FRAME] = cm->base_qindex; | 1157 rc->last_q[KEY_FRAME] = cm->base_qindex; |
| 1163 rc->avg_frame_qindex[KEY_FRAME] = ROUND_POWER_OF_TWO( | 1158 rc->avg_frame_qindex[KEY_FRAME] = ROUND_POWER_OF_TWO( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 target = calc_iframe_target_size_one_pass_vbr(cpi); | 1297 target = calc_iframe_target_size_one_pass_vbr(cpi); |
| 1303 else | 1298 else |
| 1304 target = calc_pframe_target_size_one_pass_vbr(cpi); | 1299 target = calc_pframe_target_size_one_pass_vbr(cpi); |
| 1305 vp9_rc_set_frame_target(cpi, target); | 1300 vp9_rc_set_frame_target(cpi, target); |
| 1306 } | 1301 } |
| 1307 | 1302 |
| 1308 static int calc_pframe_target_size_one_pass_cbr(const VP9_COMP *cpi) { | 1303 static int calc_pframe_target_size_one_pass_cbr(const VP9_COMP *cpi) { |
| 1309 const VP9_CONFIG *oxcf = &cpi->oxcf; | 1304 const VP9_CONFIG *oxcf = &cpi->oxcf; |
| 1310 const RATE_CONTROL *rc = &cpi->rc; | 1305 const RATE_CONTROL *rc = &cpi->rc; |
| 1311 const int64_t diff = oxcf->optimal_buffer_level - rc->buffer_level; | 1306 const int64_t diff = oxcf->optimal_buffer_level - rc->buffer_level; |
| 1312 const int one_pct_bits = 1 + oxcf->optimal_buffer_level / 100; | 1307 const int64_t one_pct_bits = 1 + oxcf->optimal_buffer_level / 100; |
| 1313 int min_frame_target = MAX(rc->av_per_frame_bandwidth >> 4, | 1308 int min_frame_target = MAX(rc->av_per_frame_bandwidth >> 4, |
| 1314 FRAME_OVERHEAD_BITS); | 1309 FRAME_OVERHEAD_BITS); |
| 1315 int target = rc->av_per_frame_bandwidth; | 1310 int target = rc->av_per_frame_bandwidth; |
| 1316 if (cpi->svc.number_temporal_layers > 1 && | 1311 if (cpi->svc.number_temporal_layers > 1 && |
| 1317 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { | 1312 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { |
| 1318 // Note that for layers, av_per_frame_bandwidth is the cumulative | 1313 // Note that for layers, av_per_frame_bandwidth is the cumulative |
| 1319 // per-frame-bandwidth. For the target size of this frame, use the | 1314 // per-frame-bandwidth. For the target size of this frame, use the |
| 1320 // layer average frame size (i.e., non-cumulative per-frame-bw). | 1315 // layer average frame size (i.e., non-cumulative per-frame-bw). |
| 1321 int current_temporal_layer = cpi->svc.temporal_layer_id; | 1316 int current_temporal_layer = cpi->svc.temporal_layer_id; |
| 1322 const LAYER_CONTEXT *lc = &cpi->svc.layer_context[current_temporal_layer]; | 1317 const LAYER_CONTEXT *lc = &cpi->svc.layer_context[current_temporal_layer]; |
| 1323 target = lc->avg_frame_size; | 1318 target = lc->avg_frame_size; |
| 1324 min_frame_target = MAX(lc->avg_frame_size >> 4, FRAME_OVERHEAD_BITS); | 1319 min_frame_target = MAX(lc->avg_frame_size >> 4, FRAME_OVERHEAD_BITS); |
| 1325 } | 1320 } |
| 1326 if (diff > 0) { | 1321 if (diff > 0) { |
| 1327 // Lower the target bandwidth for this frame. | 1322 // Lower the target bandwidth for this frame. |
| 1328 const int pct_low = MIN(diff / one_pct_bits, oxcf->under_shoot_pct); | 1323 const int pct_low = (int)MIN(diff / one_pct_bits, oxcf->under_shoot_pct); |
| 1329 target -= (target * pct_low) / 200; | 1324 target -= (target * pct_low) / 200; |
| 1330 } else if (diff < 0) { | 1325 } else if (diff < 0) { |
| 1331 // Increase the target bandwidth for this frame. | 1326 // Increase the target bandwidth for this frame. |
| 1332 const int pct_high = MIN(-diff / one_pct_bits, oxcf->over_shoot_pct); | 1327 const int pct_high = (int)MIN(-diff / one_pct_bits, oxcf->over_shoot_pct); |
| 1333 target += (target * pct_high) / 200; | 1328 target += (target * pct_high) / 200; |
| 1334 } | 1329 } |
| 1335 return MAX(min_frame_target, target); | 1330 return MAX(min_frame_target, target); |
| 1336 } | 1331 } |
| 1337 | 1332 |
| 1338 static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) { | 1333 static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) { |
| 1339 const RATE_CONTROL *rc = &cpi->rc; | 1334 const RATE_CONTROL *rc = &cpi->rc; |
| 1335 int target; |
| 1340 | 1336 |
| 1341 if (cpi->common.current_video_frame == 0) { | 1337 if (cpi->common.current_video_frame == 0) { |
| 1342 return cpi->oxcf.starting_buffer_level / 2; | 1338 target = ((cpi->oxcf.starting_buffer_level / 2) > INT_MAX) |
| 1339 ? INT_MAX : (int)(cpi->oxcf.starting_buffer_level / 2); |
| 1343 } else { | 1340 } else { |
| 1344 const int initial_boost = 32; | 1341 const int initial_boost = 32; |
| 1345 int kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16)); | 1342 int kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16)); |
| 1346 if (rc->frames_since_key < cpi->output_framerate / 2) { | 1343 if (rc->frames_since_key < cpi->output_framerate / 2) { |
| 1347 kf_boost = (int)(kf_boost * rc->frames_since_key / | 1344 kf_boost = (int)(kf_boost * rc->frames_since_key / |
| 1348 (cpi->output_framerate / 2)); | 1345 (cpi->output_framerate / 2)); |
| 1349 } | 1346 } |
| 1350 return ((16 + kf_boost) * rc->av_per_frame_bandwidth) >> 4; | 1347 target = ((16 + kf_boost) * rc->av_per_frame_bandwidth) >> 4; |
| 1351 } | 1348 } |
| 1349 return vp9_rc_clamp_iframe_target_size(cpi, target); |
| 1352 } | 1350 } |
| 1353 | 1351 |
| 1354 void vp9_rc_get_svc_params(VP9_COMP *cpi) { | 1352 void vp9_rc_get_svc_params(VP9_COMP *cpi) { |
| 1355 VP9_COMMON *const cm = &cpi->common; | 1353 VP9_COMMON *const cm = &cpi->common; |
| 1356 int target = cpi->rc.av_per_frame_bandwidth; | 1354 int target = cpi->rc.av_per_frame_bandwidth; |
| 1357 if ((cm->current_video_frame == 0) || | 1355 if ((cm->current_video_frame == 0) || |
| 1358 (cm->frame_flags & FRAMEFLAGS_KEY) || | 1356 (cm->frame_flags & FRAMEFLAGS_KEY) || |
| 1359 (cpi->oxcf.auto_key && (cpi->rc.frames_since_key % | 1357 (cpi->oxcf.auto_key && (cpi->rc.frames_since_key % |
| 1360 cpi->key_frame_frequency == 0))) { | 1358 cpi->key_frame_frequency == 0))) { |
| 1361 cm->frame_type = KEY_FRAME; | 1359 cm->frame_type = KEY_FRAME; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1391 target = calc_iframe_target_size_one_pass_cbr(cpi); | 1389 target = calc_iframe_target_size_one_pass_cbr(cpi); |
| 1392 } else { | 1390 } else { |
| 1393 cm->frame_type = INTER_FRAME; | 1391 cm->frame_type = INTER_FRAME; |
| 1394 target = calc_pframe_target_size_one_pass_cbr(cpi); | 1392 target = calc_pframe_target_size_one_pass_cbr(cpi); |
| 1395 } | 1393 } |
| 1396 vp9_rc_set_frame_target(cpi, target); | 1394 vp9_rc_set_frame_target(cpi, target); |
| 1397 // Don't use gf_update by default in CBR mode. | 1395 // Don't use gf_update by default in CBR mode. |
| 1398 rc->frames_till_gf_update_due = INT_MAX; | 1396 rc->frames_till_gf_update_due = INT_MAX; |
| 1399 rc->baseline_gf_interval = INT_MAX; | 1397 rc->baseline_gf_interval = INT_MAX; |
| 1400 } | 1398 } |
| OLD | NEW |