| 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 | 11 |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 #include <limits.h> | 15 #include <limits.h> |
| 16 #include <assert.h> | 16 #include <assert.h> |
| 17 | 17 |
| 18 #include "math.h" | 18 #include "math.h" |
| 19 #include "vp8/common/common.h" | 19 #include "vp8/common/common.h" |
| 20 #include "ratectrl.h" | 20 #include "ratectrl.h" |
| 21 #include "vp8/common/entropymode.h" | 21 #include "vp8/common/entropymode.h" |
| 22 #include "vpx_mem/vpx_mem.h" | 22 #include "vpx_mem/vpx_mem.h" |
| 23 #include "vp8/common/systemdependent.h" | 23 #include "vp8/common/systemdependent.h" |
| 24 #include "encodemv.h" | 24 #include "encodemv.h" |
| 25 #include "vpx_dsp/vpx_dsp_common.h" |
| 25 | 26 |
| 26 | 27 |
| 27 #define MIN_BPB_FACTOR 0.01 | 28 #define MIN_BPB_FACTOR 0.01 |
| 28 #define MAX_BPB_FACTOR 50 | 29 #define MAX_BPB_FACTOR 50 |
| 29 | 30 |
| 30 extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES]; | 31 extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES]; |
| 31 | 32 |
| 32 | 33 |
| 33 | 34 |
| 34 #ifdef MODE_STATS | 35 #ifdef MODE_STATS |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 374 } |
| 374 else | 375 else |
| 375 { | 376 { |
| 376 /* if this keyframe was forced, use a more recent Q estimate */ | 377 /* if this keyframe was forced, use a more recent Q estimate */ |
| 377 int Q = (cpi->common.frame_flags & FRAMEFLAGS_KEY) | 378 int Q = (cpi->common.frame_flags & FRAMEFLAGS_KEY) |
| 378 ? cpi->avg_frame_qindex : cpi->ni_av_qi; | 379 ? cpi->avg_frame_qindex : cpi->ni_av_qi; |
| 379 | 380 |
| 380 int initial_boost = 32; /* |3.0 * per_frame_bandwidth| */ | 381 int initial_boost = 32; /* |3.0 * per_frame_bandwidth| */ |
| 381 /* Boost depends somewhat on frame rate: only used for 1 layer case. */ | 382 /* Boost depends somewhat on frame rate: only used for 1 layer case. */ |
| 382 if (cpi->oxcf.number_of_layers == 1) { | 383 if (cpi->oxcf.number_of_layers == 1) { |
| 383 kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16)); | 384 kf_boost = VPXMAX(initial_boost, |
| 385 (int)(2 * cpi->output_framerate - 16)); |
| 384 } | 386 } |
| 385 else { | 387 else { |
| 386 /* Initial factor: set target size to: |3.0 * per_frame_bandwidth|. */ | 388 /* Initial factor: set target size to: |3.0 * per_frame_bandwidth|. */ |
| 387 kf_boost = initial_boost; | 389 kf_boost = initial_boost; |
| 388 } | 390 } |
| 389 | 391 |
| 390 /* adjustment up based on q: this factor ranges from ~1.2 to 2.2. */ | 392 /* adjustment up based on q: this factor ranges from ~1.2 to 2.2. */ |
| 391 kf_boost = kf_boost * kf_boost_qadjustment[Q] / 100; | 393 kf_boost = kf_boost * kf_boost_qadjustment[Q] / 100; |
| 392 | 394 |
| 393 /* frame separation adjustment ( down) */ | 395 /* frame separation adjustment ( down) */ |
| (...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 } else { | 1602 } else { |
| 1601 cpi->force_maxqp = 0; | 1603 cpi->force_maxqp = 0; |
| 1602 return 0; | 1604 return 0; |
| 1603 } | 1605 } |
| 1604 cpi->force_maxqp = 0; | 1606 cpi->force_maxqp = 0; |
| 1605 return 0; | 1607 return 0; |
| 1606 } | 1608 } |
| 1607 cpi->force_maxqp = 0; | 1609 cpi->force_maxqp = 0; |
| 1608 return 0; | 1610 return 0; |
| 1609 } | 1611 } |
| OLD | NEW |