| 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 <math.h> | 11 #include <math.h> |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 #include <limits.h> | 13 #include <limits.h> |
| 14 | 14 |
| 15 #include "./vpx_config.h" | 15 #include "./vpx_config.h" |
| 16 #include "./vpx_scale_rtcd.h" | 16 #include "./vpx_scale_rtcd.h" |
| 17 #include "vpx/internal/vpx_psnr.h" |
| 18 #include "vpx_ports/vpx_timer.h" |
| 17 | 19 |
| 18 #include "vp9/common/vp9_alloccommon.h" | 20 #include "vp9/common/vp9_alloccommon.h" |
| 19 #include "vp9/common/vp9_filter.h" | 21 #include "vp9/common/vp9_filter.h" |
| 20 #include "vp9/common/vp9_idct.h" | 22 #include "vp9/common/vp9_idct.h" |
| 21 #if CONFIG_VP9_POSTPROC | 23 #if CONFIG_VP9_POSTPROC |
| 22 #include "vp9/common/vp9_postproc.h" | 24 #include "vp9/common/vp9_postproc.h" |
| 23 #endif | 25 #endif |
| 24 #include "vp9/common/vp9_reconinter.h" | 26 #include "vp9/common/vp9_reconinter.h" |
| 25 #include "vp9/common/vp9_systemdependent.h" | 27 #include "vp9/common/vp9_systemdependent.h" |
| 26 #include "vp9/common/vp9_tile_common.h" | 28 #include "vp9/common/vp9_tile_common.h" |
| 27 | 29 |
| 30 #include "vp9/encoder/vp9_bitstream.h" |
| 28 #include "vp9/encoder/vp9_encodemv.h" | 31 #include "vp9/encoder/vp9_encodemv.h" |
| 29 #include "vp9/encoder/vp9_firstpass.h" | 32 #include "vp9/encoder/vp9_firstpass.h" |
| 30 #include "vp9/encoder/vp9_mbgraph.h" | 33 #include "vp9/encoder/vp9_mbgraph.h" |
| 31 #include "vp9/encoder/vp9_onyx_int.h" | 34 #include "vp9/encoder/vp9_onyx_int.h" |
| 32 #include "vp9/encoder/vp9_picklpf.h" | 35 #include "vp9/encoder/vp9_picklpf.h" |
| 33 #include "vp9/encoder/vp9_psnr.h" | |
| 34 #include "vp9/encoder/vp9_ratectrl.h" | 36 #include "vp9/encoder/vp9_ratectrl.h" |
| 35 #include "vp9/encoder/vp9_rdopt.h" | 37 #include "vp9/encoder/vp9_rdopt.h" |
| 36 #include "vp9/encoder/vp9_segmentation.h" | 38 #include "vp9/encoder/vp9_segmentation.h" |
| 37 #include "vp9/encoder/vp9_temporal_filter.h" | 39 #include "vp9/encoder/vp9_temporal_filter.h" |
| 38 #include "vp9/encoder/vp9_vaq.h" | 40 #include "vp9/encoder/vp9_vaq.h" |
| 39 #include "vp9/encoder/vp9_resize.h" | 41 #include "vp9/encoder/vp9_resize.h" |
| 40 | 42 |
| 41 #include "vpx_ports/vpx_timer.h" | |
| 42 | |
| 43 void vp9_entropy_mode_init(); | |
| 44 void vp9_coef_tree_initialize(); | 43 void vp9_coef_tree_initialize(); |
| 45 | 44 |
| 46 #define DEFAULT_INTERP_FILTER SWITCHABLE | 45 #define DEFAULT_INTERP_FILTER SWITCHABLE |
| 47 | 46 |
| 48 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ | 47 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ |
| 49 | 48 |
| 50 #define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv | 49 #define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv |
| 51 // for altref computation. | 50 // for altref computation. |
| 52 #define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision | 51 #define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision |
| 53 // mv. Choose a very high value for | 52 // mv. Choose a very high value for |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 vp9_init_me_luts(); | 146 vp9_init_me_luts(); |
| 148 vp9_rc_init_minq_luts(); | 147 vp9_rc_init_minq_luts(); |
| 149 // init_base_skip_probs(); | 148 // init_base_skip_probs(); |
| 150 vp9_entropy_mv_init(); | 149 vp9_entropy_mv_init(); |
| 151 vp9_entropy_mode_init(); | 150 vp9_entropy_mode_init(); |
| 152 init_done = 1; | 151 init_done = 1; |
| 153 } | 152 } |
| 154 } | 153 } |
| 155 | 154 |
| 156 static void dealloc_compressor_data(VP9_COMP *cpi) { | 155 static void dealloc_compressor_data(VP9_COMP *cpi) { |
| 156 VP9_COMMON *const cm = &cpi->common; |
| 157 |
| 157 // Delete sementation map | 158 // Delete sementation map |
| 158 vpx_free(cpi->segmentation_map); | 159 vpx_free(cpi->segmentation_map); |
| 159 cpi->segmentation_map = 0; | 160 cpi->segmentation_map = NULL; |
| 160 vpx_free(cpi->common.last_frame_seg_map); | 161 vpx_free(cm->last_frame_seg_map); |
| 161 cpi->common.last_frame_seg_map = 0; | 162 cm->last_frame_seg_map = NULL; |
| 162 vpx_free(cpi->coding_context.last_frame_seg_map_copy); | 163 vpx_free(cpi->coding_context.last_frame_seg_map_copy); |
| 163 cpi->coding_context.last_frame_seg_map_copy = 0; | 164 cpi->coding_context.last_frame_seg_map_copy = NULL; |
| 164 | 165 |
| 165 vpx_free(cpi->complexity_map); | 166 vpx_free(cpi->complexity_map); |
| 166 cpi->complexity_map = 0; | 167 cpi->complexity_map = 0; |
| 167 vpx_free(cpi->active_map); | 168 vpx_free(cpi->active_map); |
| 168 cpi->active_map = 0; | 169 cpi->active_map = 0; |
| 169 | 170 |
| 170 vp9_free_frame_buffers(&cpi->common); | 171 vp9_free_frame_buffers(cm); |
| 171 | 172 |
| 172 vp9_free_frame_buffer(&cpi->last_frame_uf); | 173 vp9_free_frame_buffer(&cpi->last_frame_uf); |
| 173 vp9_free_frame_buffer(&cpi->scaled_source); | 174 vp9_free_frame_buffer(&cpi->scaled_source); |
| 174 vp9_free_frame_buffer(&cpi->alt_ref_buffer); | 175 vp9_free_frame_buffer(&cpi->alt_ref_buffer); |
| 175 vp9_lookahead_destroy(cpi->lookahead); | 176 vp9_lookahead_destroy(cpi->lookahead); |
| 176 | 177 |
| 177 vpx_free(cpi->tok); | 178 vpx_free(cpi->tok); |
| 178 cpi->tok = 0; | 179 cpi->tok = 0; |
| 179 | 180 |
| 180 // Activity mask based per mb zbin adjustments | 181 // Activity mask based per mb zbin adjustments |
| 181 vpx_free(cpi->mb_activity_map); | 182 vpx_free(cpi->mb_activity_map); |
| 182 cpi->mb_activity_map = 0; | 183 cpi->mb_activity_map = 0; |
| 183 vpx_free(cpi->mb_norm_activity_map); | 184 vpx_free(cpi->mb_norm_activity_map); |
| 184 cpi->mb_norm_activity_map = 0; | 185 cpi->mb_norm_activity_map = 0; |
| 185 | 186 |
| 186 vpx_free(cpi->above_context[0]); | 187 vpx_free(cpi->above_context[0]); |
| 187 cpi->above_context[0] = NULL; | 188 cpi->above_context[0] = NULL; |
| 188 | 189 |
| 189 vpx_free(cpi->above_seg_context); | 190 vpx_free(cpi->above_seg_context); |
| 190 cpi->above_seg_context = NULL; | 191 cpi->above_seg_context = NULL; |
| 191 } | 192 } |
| 192 | 193 |
| 193 // Computes a q delta (in "q index" terms) to get from a starting q value | 194 // Computes a q delta (in "q index" terms) to get from a starting q value |
| 194 // to a target value | 195 // to a target value |
| 195 // target q value | 196 // target q value |
| 196 int vp9_compute_qdelta(const VP9_COMP *cpi, double qstart, double qtarget) { | 197 int vp9_compute_qdelta(const VP9_COMP *cpi, double qstart, double qtarget) { |
| 198 const RATE_CONTROL *const rc = &cpi->rc; |
| 199 int start_index = rc->worst_quality; |
| 200 int target_index = rc->worst_quality; |
| 197 int i; | 201 int i; |
| 198 int start_index = cpi->rc.worst_quality; | |
| 199 int target_index = cpi->rc.worst_quality; | |
| 200 | 202 |
| 201 // Convert the average q value to an index. | 203 // Convert the average q value to an index. |
| 202 for (i = cpi->rc.best_quality; i < cpi->rc.worst_quality; i++) { | 204 for (i = rc->best_quality; i < rc->worst_quality; ++i) { |
| 203 start_index = i; | 205 start_index = i; |
| 204 if (vp9_convert_qindex_to_q(i) >= qstart) | 206 if (vp9_convert_qindex_to_q(i) >= qstart) |
| 205 break; | 207 break; |
| 206 } | 208 } |
| 207 | 209 |
| 208 // Convert the q target to an index | 210 // Convert the q target to an index |
| 209 for (i = cpi->rc.best_quality; i < cpi->rc.worst_quality; i++) { | 211 for (i = rc->best_quality; i < rc->worst_quality; ++i) { |
| 210 target_index = i; | 212 target_index = i; |
| 211 if (vp9_convert_qindex_to_q(i) >= qtarget) | 213 if (vp9_convert_qindex_to_q(i) >= qtarget) |
| 212 break; | 214 break; |
| 213 } | 215 } |
| 214 | 216 |
| 215 return target_index - start_index; | 217 return target_index - start_index; |
| 216 } | 218 } |
| 217 | 219 |
| 218 // Computes a q delta (in "q index" terms) to get from a starting q value | 220 // Computes a q delta (in "q index" terms) to get from a starting q value |
| 219 // to a value that should equate to thegiven rate ratio. | 221 // to a value that should equate to thegiven rate ratio. |
| 220 | 222 |
| 221 int vp9_compute_qdelta_by_rate(VP9_COMP *cpi, | 223 static int compute_qdelta_by_rate(VP9_COMP *cpi, int base_q_index, |
| 222 double base_q_index, double rate_target_ratio) { | 224 double rate_target_ratio) { |
| 223 int i; | 225 int i; |
| 224 int base_bits_per_mb; | |
| 225 int target_bits_per_mb; | |
| 226 int target_index = cpi->rc.worst_quality; | 226 int target_index = cpi->rc.worst_quality; |
| 227 | 227 |
| 228 // Make SURE use of floating point in this function is safe. | |
| 229 vp9_clear_system_state(); | |
| 230 | |
| 231 // Look up the current projected bits per block for the base index | 228 // Look up the current projected bits per block for the base index |
| 232 base_bits_per_mb = vp9_rc_bits_per_mb(cpi->common.frame_type, | 229 const int base_bits_per_mb = vp9_rc_bits_per_mb(cpi->common.frame_type, |
| 233 base_q_index, 1.0); | 230 base_q_index, 1.0); |
| 234 | 231 |
| 235 // Find the target bits per mb based on the base value and given ratio. | 232 // Find the target bits per mb based on the base value and given ratio. |
| 236 target_bits_per_mb = rate_target_ratio * base_bits_per_mb; | 233 const int target_bits_per_mb = (int)(rate_target_ratio * base_bits_per_mb); |
| 237 | 234 |
| 238 // Convert the q target to an index | 235 // Convert the q target to an index |
| 239 for (i = cpi->rc.best_quality; i < cpi->rc.worst_quality; i++) { | 236 for (i = cpi->rc.best_quality; i < cpi->rc.worst_quality; ++i) { |
| 240 target_index = i; | 237 target_index = i; |
| 241 if (vp9_rc_bits_per_mb(cpi->common.frame_type, | 238 if (vp9_rc_bits_per_mb(cpi->common.frame_type, i, 1.0) <= |
| 242 i, 1.0) <= target_bits_per_mb ) | 239 target_bits_per_mb ) |
| 243 break; | 240 break; |
| 244 } | 241 } |
| 245 | 242 |
| 246 return target_index - base_q_index; | 243 return target_index - base_q_index; |
| 247 } | 244 } |
| 248 | 245 |
| 249 // This function sets up a set of segments with delta Q values around | 246 // This function sets up a set of segments with delta Q values around |
| 250 // the baseline frame quantizer. | 247 // the baseline frame quantizer. |
| 251 static void setup_in_frame_q_adj(VP9_COMP *cpi) { | 248 static void setup_in_frame_q_adj(VP9_COMP *cpi) { |
| 252 VP9_COMMON *cm = &cpi->common; | 249 VP9_COMMON *const cm = &cpi->common; |
| 253 struct segmentation *seg = &cm->seg; | 250 struct segmentation *const seg = &cm->seg; |
| 254 // double q_ratio; | |
| 255 int segment; | |
| 256 int qindex_delta; | |
| 257 | 251 |
| 258 // Make SURE use of floating point in this function is safe. | 252 // Make SURE use of floating point in this function is safe. |
| 259 vp9_clear_system_state(); | 253 vp9_clear_system_state(); |
| 260 | 254 |
| 261 if (cm->frame_type == KEY_FRAME || | 255 if (cm->frame_type == KEY_FRAME || |
| 262 cpi->refresh_alt_ref_frame || | 256 cpi->refresh_alt_ref_frame || |
| 263 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { | 257 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { |
| 258 int segment; |
| 259 |
| 264 // Clear down the segment map | 260 // Clear down the segment map |
| 265 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); | 261 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); |
| 266 | 262 |
| 267 // Clear down the complexity map used for rd | 263 // Clear down the complexity map used for rd |
| 268 vpx_memset(cpi->complexity_map, 0, cm->mi_rows * cm->mi_cols); | 264 vpx_memset(cpi->complexity_map, 0, cm->mi_rows * cm->mi_cols); |
| 269 | 265 |
| 270 vp9_enable_segmentation((VP9_PTR)cpi); | 266 vp9_enable_segmentation(seg); |
| 271 vp9_clearall_segfeatures(seg); | 267 vp9_clearall_segfeatures(seg); |
| 272 | 268 |
| 273 // Select delta coding method | 269 // Select delta coding method |
| 274 seg->abs_delta = SEGMENT_DELTADATA; | 270 seg->abs_delta = SEGMENT_DELTADATA; |
| 275 | 271 |
| 276 // Segment 0 "Q" feature is disabled so it defaults to the baseline Q | 272 // Segment 0 "Q" feature is disabled so it defaults to the baseline Q |
| 277 vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); | 273 vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); |
| 278 | 274 |
| 279 // Use some of the segments for in frame Q adjustment | 275 // Use some of the segments for in frame Q adjustment |
| 280 for (segment = 1; segment < 2; segment++) { | 276 for (segment = 1; segment < 2; segment++) { |
| 281 qindex_delta = | 277 const int qindex_delta = compute_qdelta_by_rate(cpi, cm->base_qindex, |
| 282 vp9_compute_qdelta_by_rate(cpi, cm->base_qindex, | |
| 283 in_frame_q_adj_ratio[segment]); | 278 in_frame_q_adj_ratio[segment]); |
| 284 vp9_enable_segfeature(seg, segment, SEG_LVL_ALT_Q); | 279 vp9_enable_segfeature(seg, segment, SEG_LVL_ALT_Q); |
| 285 vp9_set_segdata(seg, segment, SEG_LVL_ALT_Q, qindex_delta); | 280 vp9_set_segdata(seg, segment, SEG_LVL_ALT_Q, qindex_delta); |
| 286 } | 281 } |
| 287 } | 282 } |
| 288 } | 283 } |
| 289 static void configure_static_seg_features(VP9_COMP *cpi) { | 284 static void configure_static_seg_features(VP9_COMP *cpi) { |
| 290 VP9_COMMON *cm = &cpi->common; | 285 VP9_COMMON *const cm = &cpi->common; |
| 291 struct segmentation *seg = &cm->seg; | 286 struct segmentation *const seg = &cm->seg; |
| 292 | 287 |
| 293 int high_q = (int)(cpi->rc.avg_q > 48.0); | 288 int high_q = (int)(cpi->rc.avg_q > 48.0); |
| 294 int qi_delta; | 289 int qi_delta; |
| 295 | 290 |
| 296 // Disable and clear down for KF | 291 // Disable and clear down for KF |
| 297 if (cm->frame_type == KEY_FRAME) { | 292 if (cm->frame_type == KEY_FRAME) { |
| 298 // Clear down the global segmentation map | 293 // Clear down the global segmentation map |
| 299 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); | 294 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); |
| 300 seg->update_map = 0; | 295 seg->update_map = 0; |
| 301 seg->update_data = 0; | 296 seg->update_data = 0; |
| 302 cpi->static_mb_pct = 0; | 297 cpi->static_mb_pct = 0; |
| 303 | 298 |
| 304 // Disable segmentation | 299 // Disable segmentation |
| 305 vp9_disable_segmentation((VP9_PTR)cpi); | 300 vp9_disable_segmentation(seg); |
| 306 | 301 |
| 307 // Clear down the segment features. | 302 // Clear down the segment features. |
| 308 vp9_clearall_segfeatures(seg); | 303 vp9_clearall_segfeatures(seg); |
| 309 } else if (cpi->refresh_alt_ref_frame) { | 304 } else if (cpi->refresh_alt_ref_frame) { |
| 310 // If this is an alt ref frame | 305 // If this is an alt ref frame |
| 311 // Clear down the global segmentation map | 306 // Clear down the global segmentation map |
| 312 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); | 307 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); |
| 313 seg->update_map = 0; | 308 seg->update_map = 0; |
| 314 seg->update_data = 0; | 309 seg->update_data = 0; |
| 315 cpi->static_mb_pct = 0; | 310 cpi->static_mb_pct = 0; |
| 316 | 311 |
| 317 // Disable segmentation and individual segment features by default | 312 // Disable segmentation and individual segment features by default |
| 318 vp9_disable_segmentation((VP9_PTR)cpi); | 313 vp9_disable_segmentation(seg); |
| 319 vp9_clearall_segfeatures(seg); | 314 vp9_clearall_segfeatures(seg); |
| 320 | 315 |
| 321 // Scan frames from current to arf frame. | 316 // Scan frames from current to arf frame. |
| 322 // This function re-enables segmentation if appropriate. | 317 // This function re-enables segmentation if appropriate. |
| 323 vp9_update_mbgraph_stats(cpi); | 318 vp9_update_mbgraph_stats(cpi); |
| 324 | 319 |
| 325 // If segmentation was enabled set those features needed for the | 320 // If segmentation was enabled set those features needed for the |
| 326 // arf itself. | 321 // arf itself. |
| 327 if (seg->enabled) { | 322 if (seg->enabled) { |
| 328 seg->update_map = 1; | 323 seg->update_map = 1; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // Segment coding disabled for compred testing | 356 // Segment coding disabled for compred testing |
| 362 if (high_q || (cpi->static_mb_pct == 100)) { | 357 if (high_q || (cpi->static_mb_pct == 100)) { |
| 363 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME); | 358 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME); |
| 364 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME); | 359 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME); |
| 365 vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP); | 360 vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP); |
| 366 } | 361 } |
| 367 } else { | 362 } else { |
| 368 // Disable segmentation and clear down features if alt ref | 363 // Disable segmentation and clear down features if alt ref |
| 369 // is not active for this group | 364 // is not active for this group |
| 370 | 365 |
| 371 vp9_disable_segmentation((VP9_PTR)cpi); | 366 vp9_disable_segmentation(seg); |
| 372 | 367 |
| 373 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); | 368 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); |
| 374 | 369 |
| 375 seg->update_map = 0; | 370 seg->update_map = 0; |
| 376 seg->update_data = 0; | 371 seg->update_data = 0; |
| 377 | 372 |
| 378 vp9_clearall_segfeatures(seg); | 373 vp9_clearall_segfeatures(seg); |
| 379 } | 374 } |
| 380 } else if (cpi->rc.is_src_frame_alt_ref) { | 375 } else if (cpi->rc.is_src_frame_alt_ref) { |
| 381 // Special case where we are coding over the top of a previous | 376 // Special case where we are coding over the top of a previous |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 420 } |
| 426 fprintf(statsfile, "\n"); | 421 fprintf(statsfile, "\n"); |
| 427 } | 422 } |
| 428 fprintf(statsfile, "\n"); | 423 fprintf(statsfile, "\n"); |
| 429 | 424 |
| 430 fclose(statsfile); | 425 fclose(statsfile); |
| 431 } | 426 } |
| 432 | 427 |
| 433 static void update_reference_segmentation_map(VP9_COMP *cpi) { | 428 static void update_reference_segmentation_map(VP9_COMP *cpi) { |
| 434 VP9_COMMON *const cm = &cpi->common; | 429 VP9_COMMON *const cm = &cpi->common; |
| 430 MODE_INFO **mi_8x8_ptr = cm->mi_grid_visible; |
| 431 uint8_t *cache_ptr = cm->last_frame_seg_map; |
| 435 int row, col; | 432 int row, col; |
| 436 MODE_INFO **mi_8x8, **mi_8x8_ptr = cm->mi_grid_visible; | |
| 437 uint8_t *cache_ptr = cm->last_frame_seg_map, *cache; | |
| 438 | 433 |
| 439 for (row = 0; row < cm->mi_rows; row++) { | 434 for (row = 0; row < cm->mi_rows; row++) { |
| 440 mi_8x8 = mi_8x8_ptr; | 435 MODE_INFO **mi_8x8 = mi_8x8_ptr; |
| 441 cache = cache_ptr; | 436 uint8_t *cache = cache_ptr; |
| 442 for (col = 0; col < cm->mi_cols; col++, mi_8x8++, cache++) | 437 for (col = 0; col < cm->mi_cols; col++, mi_8x8++, cache++) |
| 443 cache[0] = mi_8x8[0]->mbmi.segment_id; | 438 cache[0] = mi_8x8[0]->mbmi.segment_id; |
| 444 mi_8x8_ptr += cm->mode_info_stride; | 439 mi_8x8_ptr += cm->mode_info_stride; |
| 445 cache_ptr += cm->mi_cols; | 440 cache_ptr += cm->mi_cols; |
| 446 } | 441 } |
| 447 } | 442 } |
| 448 static int is_slowest_mode(int mode) { | 443 static int is_slowest_mode(int mode) { |
| 449 return (mode == MODE_SECONDPASS_BEST || mode == MODE_BESTQUALITY); | 444 return (mode == MODE_SECONDPASS_BEST || mode == MODE_BESTQUALITY); |
| 450 } | 445 } |
| 451 | 446 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 FLAG_SKIP_INTRA_BESTINTER | | 641 FLAG_SKIP_INTRA_BESTINTER | |
| 647 FLAG_SKIP_COMP_BESTINTRA | | 642 FLAG_SKIP_COMP_BESTINTRA | |
| 648 FLAG_SKIP_INTRA_LOWVAR; | 643 FLAG_SKIP_INTRA_LOWVAR; |
| 649 | 644 |
| 650 sf->use_rd_breakout = 1; | 645 sf->use_rd_breakout = 1; |
| 651 sf->adaptive_motion_search = 1; | 646 sf->adaptive_motion_search = 1; |
| 652 sf->adaptive_pred_interp_filter = 2; | 647 sf->adaptive_pred_interp_filter = 2; |
| 653 sf->reference_masking = 1; | 648 sf->reference_masking = 1; |
| 654 sf->auto_mv_step_size = 1; | 649 sf->auto_mv_step_size = 1; |
| 655 | 650 |
| 651 sf->disable_split_var_thresh = 32; |
| 656 sf->disable_filter_search_var_thresh = 100; | 652 sf->disable_filter_search_var_thresh = 100; |
| 657 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; | 653 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; |
| 658 | 654 |
| 659 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; | 655 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; |
| 660 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL; | 656 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL; |
| 661 sf->adjust_partitioning_from_last_frame = 1; | 657 sf->adjust_partitioning_from_last_frame = 1; |
| 662 sf->last_partitioning_redo_frequency = 3; | 658 sf->last_partitioning_redo_frequency = 3; |
| 663 | 659 |
| 664 sf->use_uv_intra_rd_estimate = 1; | 660 sf->use_uv_intra_rd_estimate = 1; |
| 665 sf->skip_encode_sb = 1; | 661 sf->skip_encode_sb = 1; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 681 FLAG_SKIP_COMP_REFMISMATCH | | 677 FLAG_SKIP_COMP_REFMISMATCH | |
| 682 FLAG_SKIP_INTRA_LOWVAR | | 678 FLAG_SKIP_INTRA_LOWVAR | |
| 683 FLAG_EARLY_TERMINATE; | 679 FLAG_EARLY_TERMINATE; |
| 684 | 680 |
| 685 sf->use_rd_breakout = 1; | 681 sf->use_rd_breakout = 1; |
| 686 sf->adaptive_motion_search = 1; | 682 sf->adaptive_motion_search = 1; |
| 687 sf->adaptive_pred_interp_filter = 2; | 683 sf->adaptive_pred_interp_filter = 2; |
| 688 sf->reference_masking = 1; | 684 sf->reference_masking = 1; |
| 689 sf->auto_mv_step_size = 1; | 685 sf->auto_mv_step_size = 1; |
| 690 | 686 |
| 687 sf->disable_split_var_thresh = 64; |
| 691 sf->disable_filter_search_var_thresh = 200; | 688 sf->disable_filter_search_var_thresh = 200; |
| 692 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; | 689 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; |
| 693 | 690 |
| 694 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; | 691 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX; |
| 695 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL; | 692 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL; |
| 696 sf->adjust_partitioning_from_last_frame = 1; | 693 sf->adjust_partitioning_from_last_frame = 1; |
| 697 sf->last_partitioning_redo_frequency = 3; | 694 sf->last_partitioning_redo_frequency = 3; |
| 698 | 695 |
| 699 sf->use_uv_intra_rd_estimate = 1; | 696 sf->use_uv_intra_rd_estimate = 1; |
| 700 sf->skip_encode_sb = 1; | 697 sf->skip_encode_sb = 1; |
| 701 sf->use_lp32x32fdct = 1; | 698 sf->use_lp32x32fdct = 1; |
| 702 sf->subpel_iters_per_step = 1; | 699 sf->subpel_iters_per_step = 1; |
| 703 sf->use_fast_coef_updates = 2; | 700 sf->use_fast_coef_updates = 2; |
| 704 | 701 |
| 705 sf->adaptive_rd_thresh = 4; | 702 sf->adaptive_rd_thresh = 4; |
| 706 sf->mode_skip_start = 6; | 703 sf->mode_skip_start = 6; |
| 707 } | 704 } |
| 708 if (speed == 5) { | 705 if (speed >= 5) { |
| 709 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; | 706 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; |
| 710 sf->use_one_partition_size_always = 1; | 707 sf->partition_search_type = FIXED_PARTITION; |
| 711 sf->always_this_block_size = BLOCK_16X16; | 708 sf->always_this_block_size = BLOCK_16X16; |
| 712 sf->tx_size_search_method = frame_is_intra_only(cm) ? | 709 sf->tx_size_search_method = frame_is_intra_only(cm) ? |
| 713 USE_FULL_RD : USE_LARGESTALL; | 710 USE_FULL_RD : USE_LARGESTALL; |
| 714 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | | 711 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | |
| 715 FLAG_SKIP_INTRA_BESTINTER | | 712 FLAG_SKIP_INTRA_BESTINTER | |
| 716 FLAG_SKIP_COMP_BESTINTRA | | 713 FLAG_SKIP_COMP_BESTINTRA | |
| 717 FLAG_SKIP_COMP_REFMISMATCH | | 714 FLAG_SKIP_COMP_REFMISMATCH | |
| 718 FLAG_SKIP_INTRA_LOWVAR | | 715 FLAG_SKIP_INTRA_LOWVAR | |
| 719 FLAG_EARLY_TERMINATE; | 716 FLAG_EARLY_TERMINATE; |
| 720 sf->use_rd_breakout = 1; | 717 sf->use_rd_breakout = 1; |
| 721 sf->use_lp32x32fdct = 1; | 718 sf->use_lp32x32fdct = 1; |
| 722 sf->optimize_coefficients = 0; | 719 sf->optimize_coefficients = 0; |
| 723 sf->auto_mv_step_size = 1; | 720 sf->auto_mv_step_size = 1; |
| 724 sf->reference_masking = 1; | 721 sf->reference_masking = 1; |
| 725 | 722 |
| 726 sf->disable_split_mask = DISABLE_ALL_SPLIT; | 723 sf->disable_split_mask = DISABLE_ALL_SPLIT; |
| 727 sf->search_method = HEX; | 724 sf->search_method = HEX; |
| 728 sf->subpel_iters_per_step = 1; | 725 sf->subpel_iters_per_step = 1; |
| 729 sf->disable_split_var_thresh = 64; | 726 sf->disable_split_var_thresh = 64; |
| 730 sf->disable_filter_search_var_thresh = 500; | 727 sf->disable_filter_search_var_thresh = 500; |
| 731 for (i = 0; i < TX_SIZES; i++) { | 728 for (i = 0; i < TX_SIZES; i++) { |
| 732 sf->intra_y_mode_mask[i] = INTRA_DC_ONLY; | 729 sf->intra_y_mode_mask[i] = INTRA_DC_ONLY; |
| 733 sf->intra_uv_mode_mask[i] = INTRA_DC_ONLY; | 730 sf->intra_uv_mode_mask[i] = INTRA_DC_ONLY; |
| 734 } | 731 } |
| 735 sf->use_fast_coef_updates = 2; | 732 sf->use_fast_coef_updates = 2; |
| 736 sf->adaptive_rd_thresh = 4; | 733 sf->adaptive_rd_thresh = 4; |
| 737 sf->mode_skip_start = 6; | 734 sf->mode_skip_start = 6; |
| 738 } | 735 } |
| 739 } | 736 } |
| 737 |
| 740 static void set_rt_speed_feature(VP9_COMMON *cm, | 738 static void set_rt_speed_feature(VP9_COMMON *cm, |
| 741 SPEED_FEATURES *sf, | 739 SPEED_FEATURES *sf, |
| 742 int speed) { | 740 int speed) { |
| 743 sf->static_segmentation = 0; | 741 sf->static_segmentation = 0; |
| 744 sf->adaptive_rd_thresh = 1; | 742 sf->adaptive_rd_thresh = 1; |
| 745 sf->recode_loop = ((speed < 1) ? ALLOW_RECODE : ALLOW_RECODE_KFMAXBW); | 743 sf->recode_loop = ((speed < 1) ? ALLOW_RECODE : ALLOW_RECODE_KFMAXBW); |
| 746 sf->encode_breakout_thresh = 1; | 744 sf->encode_breakout_thresh = 1; |
| 747 | 745 |
| 748 if (speed == 1) { | 746 if (speed == 1) { |
| 749 sf->use_square_partition_only = !frame_is_intra_only(cm); | 747 sf->use_square_partition_only = !frame_is_intra_only(cm); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 sf->optimize_coefficients = 0; | 833 sf->optimize_coefficients = 0; |
| 836 sf->disable_split_mask = DISABLE_ALL_SPLIT; | 834 sf->disable_split_mask = DISABLE_ALL_SPLIT; |
| 837 sf->use_fast_lpf_pick = 2; | 835 sf->use_fast_lpf_pick = 2; |
| 838 sf->encode_breakout_thresh = 700; | 836 sf->encode_breakout_thresh = 700; |
| 839 } | 837 } |
| 840 if (speed >= 5) { | 838 if (speed >= 5) { |
| 841 int i; | 839 int i; |
| 842 sf->adaptive_rd_thresh = 5; | 840 sf->adaptive_rd_thresh = 5; |
| 843 sf->auto_min_max_partition_size = frame_is_intra_only(cm) ? | 841 sf->auto_min_max_partition_size = frame_is_intra_only(cm) ? |
| 844 RELAXED_NEIGHBORING_MIN_MAX : STRICT_NEIGHBORING_MIN_MAX; | 842 RELAXED_NEIGHBORING_MIN_MAX : STRICT_NEIGHBORING_MIN_MAX; |
| 843 sf->adjust_partitioning_from_last_frame = |
| 844 cm->last_frame_type == KEY_FRAME || (0 == |
| 845 (cm->current_video_frame + 1) % sf->last_partitioning_redo_frequency); |
| 845 sf->subpel_force_stop = 1; | 846 sf->subpel_force_stop = 1; |
| 846 for (i = 0; i < TX_SIZES; i++) { | 847 for (i = 0; i < TX_SIZES; i++) { |
| 847 sf->intra_y_mode_mask[i] = INTRA_DC_H_V; | 848 sf->intra_y_mode_mask[i] = INTRA_DC_H_V; |
| 848 sf->intra_uv_mode_mask[i] = INTRA_DC_ONLY; | 849 sf->intra_uv_mode_mask[i] = INTRA_DC_ONLY; |
| 849 } | 850 } |
| 850 sf->frame_parameter_update = 0; | 851 sf->frame_parameter_update = 0; |
| 851 sf->encode_breakout_thresh = 1000; | 852 sf->encode_breakout_thresh = 1000; |
| 853 sf->search_method = FAST_HEX; |
| 852 } | 854 } |
| 853 if (speed >= 6) { | 855 if (speed >= 6) { |
| 854 sf->always_this_block_size = BLOCK_16X16; | 856 sf->partition_search_type = VAR_BASED_FIXED_PARTITION; |
| 855 sf->use_pick_mode = 1; | 857 sf->search_method = HEX; |
| 856 sf->encode_breakout_thresh = 1000; | 858 } |
| 859 if (speed >= 7) { |
| 860 sf->partition_search_type = VAR_BASED_FIXED_PARTITION; |
| 861 sf->use_nonrd_pick_mode = 1; |
| 862 sf->search_method = FAST_HEX; |
| 863 } |
| 864 if (speed >= 8) { |
| 865 int i; |
| 866 for (i = 0; i < BLOCK_SIZES; ++i) |
| 867 sf->disable_inter_mode_mask[i] = 14; // only search NEARESTMV (0) |
| 857 } | 868 } |
| 858 } | 869 } |
| 859 | 870 |
| 860 void vp9_set_speed_features(VP9_COMP *cpi) { | 871 void vp9_set_speed_features(VP9_COMP *cpi) { |
| 861 SPEED_FEATURES *sf = &cpi->sf; | 872 SPEED_FEATURES *sf = &cpi->sf; |
| 862 VP9_COMMON *cm = &cpi->common; | 873 VP9_COMMON *cm = &cpi->common; |
| 863 int speed = cpi->speed; | 874 int speed = cpi->speed; |
| 864 int i; | 875 int i; |
| 865 | 876 |
| 866 // Convert negative speed to positive | 877 // Convert negative speed to positive |
| 867 if (speed < 0) | 878 if (speed < 0) |
| 868 speed = -speed; | 879 speed = -speed; |
| 869 | 880 |
| 881 #if CONFIG_INTERNAL_STATS |
| 870 for (i = 0; i < MAX_MODES; ++i) | 882 for (i = 0; i < MAX_MODES; ++i) |
| 871 cpi->mode_chosen_counts[i] = 0; | 883 cpi->mode_chosen_counts[i] = 0; |
| 884 #endif |
| 872 | 885 |
| 873 // best quality defaults | 886 // best quality defaults |
| 874 sf->frame_parameter_update = 1; | 887 sf->frame_parameter_update = 1; |
| 875 sf->search_method = NSTEP; | 888 sf->search_method = NSTEP; |
| 876 sf->recode_loop = ALLOW_RECODE; | 889 sf->recode_loop = ALLOW_RECODE; |
| 877 sf->subpel_search_method = SUBPEL_TREE; | 890 sf->subpel_search_method = SUBPEL_TREE; |
| 878 sf->subpel_iters_per_step = 2; | 891 sf->subpel_iters_per_step = 2; |
| 879 sf->subpel_force_stop = 0; | 892 sf->subpel_force_stop = 0; |
| 880 sf->optimize_coefficients = !cpi->oxcf.lossless; | 893 sf->optimize_coefficients = !cpi->oxcf.lossless; |
| 881 sf->reduce_first_step_size = 0; | 894 sf->reduce_first_step_size = 0; |
| 882 sf->auto_mv_step_size = 0; | 895 sf->auto_mv_step_size = 0; |
| 883 sf->max_step_search_steps = MAX_MVSEARCH_STEPS; | 896 sf->max_step_search_steps = MAX_MVSEARCH_STEPS; |
| 884 sf->comp_inter_joint_search_thresh = BLOCK_4X4; | 897 sf->comp_inter_joint_search_thresh = BLOCK_4X4; |
| 885 sf->adaptive_rd_thresh = 0; | 898 sf->adaptive_rd_thresh = 0; |
| 886 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_OFF; | 899 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_OFF; |
| 887 sf->tx_size_search_method = USE_FULL_RD; | 900 sf->tx_size_search_method = USE_FULL_RD; |
| 888 sf->use_lp32x32fdct = 0; | 901 sf->use_lp32x32fdct = 0; |
| 889 sf->adaptive_motion_search = 0; | 902 sf->adaptive_motion_search = 0; |
| 890 sf->adaptive_pred_interp_filter = 0; | 903 sf->adaptive_pred_interp_filter = 0; |
| 891 sf->reference_masking = 0; | 904 sf->reference_masking = 0; |
| 892 sf->use_one_partition_size_always = 0; | 905 sf->partition_search_type = SEARCH_PARTITION; |
| 893 sf->less_rectangular_check = 0; | 906 sf->less_rectangular_check = 0; |
| 894 sf->use_square_partition_only = 0; | 907 sf->use_square_partition_only = 0; |
| 895 sf->auto_min_max_partition_size = NOT_IN_USE; | 908 sf->auto_min_max_partition_size = NOT_IN_USE; |
| 896 sf->max_partition_size = BLOCK_64X64; | 909 sf->max_partition_size = BLOCK_64X64; |
| 897 sf->min_partition_size = BLOCK_4X4; | 910 sf->min_partition_size = BLOCK_4X4; |
| 898 sf->adjust_partitioning_from_last_frame = 0; | 911 sf->adjust_partitioning_from_last_frame = 0; |
| 899 sf->last_partitioning_redo_frequency = 4; | 912 sf->last_partitioning_redo_frequency = 4; |
| 900 sf->disable_split_mask = 0; | 913 sf->disable_split_mask = 0; |
| 901 sf->mode_search_skip_flags = 0; | 914 sf->mode_search_skip_flags = 0; |
| 902 sf->disable_split_var_thresh = 0; | 915 sf->disable_split_var_thresh = 0; |
| 903 sf->disable_filter_search_var_thresh = 0; | 916 sf->disable_filter_search_var_thresh = 0; |
| 904 for (i = 0; i < TX_SIZES; i++) { | 917 for (i = 0; i < TX_SIZES; i++) { |
| 905 sf->intra_y_mode_mask[i] = ALL_INTRA_MODES; | 918 sf->intra_y_mode_mask[i] = ALL_INTRA_MODES; |
| 906 sf->intra_uv_mode_mask[i] = ALL_INTRA_MODES; | 919 sf->intra_uv_mode_mask[i] = ALL_INTRA_MODES; |
| 907 } | 920 } |
| 908 sf->use_rd_breakout = 0; | 921 sf->use_rd_breakout = 0; |
| 909 sf->skip_encode_sb = 0; | 922 sf->skip_encode_sb = 0; |
| 910 sf->use_uv_intra_rd_estimate = 0; | 923 sf->use_uv_intra_rd_estimate = 0; |
| 911 sf->use_fast_lpf_pick = 0; | 924 sf->use_fast_lpf_pick = 0; |
| 912 sf->use_fast_coef_updates = 0; | 925 sf->use_fast_coef_updates = 0; |
| 913 sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set | 926 sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set |
| 914 sf->use_pick_mode = 0; | 927 sf->use_nonrd_pick_mode = 0; |
| 915 sf->encode_breakout_thresh = 0; | 928 sf->encode_breakout_thresh = 0; |
| 929 for (i = 0; i < BLOCK_SIZES; ++i) |
| 930 sf->disable_inter_mode_mask[i] = 0; |
| 916 | 931 |
| 917 switch (cpi->oxcf.mode) { | 932 switch (cpi->oxcf.mode) { |
| 918 case MODE_BESTQUALITY: | 933 case MODE_BESTQUALITY: |
| 919 case MODE_SECONDPASS_BEST: // This is the best quality mode. | 934 case MODE_SECONDPASS_BEST: // This is the best quality mode. |
| 920 cpi->diamond_search_sad = vp9_full_range_search; | 935 cpi->diamond_search_sad = vp9_full_range_search; |
| 921 break; | 936 break; |
| 922 case MODE_FIRSTPASS: | 937 case MODE_FIRSTPASS: |
| 923 case MODE_GOODQUALITY: | 938 case MODE_GOODQUALITY: |
| 924 case MODE_SECONDPASS: | 939 case MODE_SECONDPASS: |
| 925 set_good_speed_feature(cm, sf, speed); | 940 set_good_speed_feature(cm, sf, speed); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 953 if (cpi->sf.subpel_search_method == SUBPEL_TREE) { | 968 if (cpi->sf.subpel_search_method == SUBPEL_TREE) { |
| 954 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree; | 969 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree; |
| 955 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree; | 970 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree; |
| 956 } | 971 } |
| 957 | 972 |
| 958 cpi->mb.optimize = cpi->sf.optimize_coefficients == 1 && cpi->pass != 1; | 973 cpi->mb.optimize = cpi->sf.optimize_coefficients == 1 && cpi->pass != 1; |
| 959 | 974 |
| 960 if (cpi->encode_breakout && cpi->oxcf.mode == MODE_REALTIME && | 975 if (cpi->encode_breakout && cpi->oxcf.mode == MODE_REALTIME && |
| 961 sf->encode_breakout_thresh > cpi->encode_breakout) | 976 sf->encode_breakout_thresh > cpi->encode_breakout) |
| 962 cpi->encode_breakout = sf->encode_breakout_thresh; | 977 cpi->encode_breakout = sf->encode_breakout_thresh; |
| 978 |
| 979 if (sf->disable_split_mask == DISABLE_ALL_SPLIT) |
| 980 sf->adaptive_pred_interp_filter = 0; |
| 963 } | 981 } |
| 964 | 982 |
| 965 static void alloc_raw_frame_buffers(VP9_COMP *cpi) { | 983 static void alloc_raw_frame_buffers(VP9_COMP *cpi) { |
| 966 VP9_COMMON *cm = &cpi->common; | 984 VP9_COMMON *cm = &cpi->common; |
| 985 const VP9_CONFIG *oxcf = &cpi->oxcf; |
| 967 | 986 |
| 968 cpi->lookahead = vp9_lookahead_init(cpi->oxcf.width, cpi->oxcf.height, | 987 cpi->lookahead = vp9_lookahead_init(oxcf->width, oxcf->height, |
| 969 cm->subsampling_x, cm->subsampling_y, | 988 cm->subsampling_x, cm->subsampling_y, |
| 970 cpi->oxcf.lag_in_frames); | 989 oxcf->lag_in_frames); |
| 971 if (!cpi->lookahead) | 990 if (!cpi->lookahead) |
| 972 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 991 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
| 973 "Failed to allocate lag buffers"); | 992 "Failed to allocate lag buffers"); |
| 974 | 993 |
| 975 if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer, | 994 if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer, |
| 976 cpi->oxcf.width, cpi->oxcf.height, | 995 oxcf->width, oxcf->height, |
| 977 cm->subsampling_x, cm->subsampling_y, | 996 cm->subsampling_x, cm->subsampling_y, |
| 978 VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL)) | 997 VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL)) |
| 979 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 998 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
| 980 "Failed to allocate altref buffer"); | 999 "Failed to allocate altref buffer"); |
| 981 } | 1000 } |
| 982 | 1001 |
| 983 void vp9_alloc_compressor_data(VP9_COMP *cpi) { | 1002 void vp9_alloc_compressor_data(VP9_COMP *cpi) { |
| 984 VP9_COMMON *cm = &cpi->common; | 1003 VP9_COMMON *cm = &cpi->common; |
| 985 | 1004 |
| 986 if (vp9_alloc_frame_buffers(cm, cm->width, cm->height)) | 1005 if (vp9_alloc_frame_buffers(cm, cm->width, cm->height)) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 | 1112 |
| 1094 for (i = 0; i < 64; i++) | 1113 for (i = 0; i < 64; i++) |
| 1095 if (q_trans[i] >= x) | 1114 if (q_trans[i] >= x) |
| 1096 return i; | 1115 return i; |
| 1097 | 1116 |
| 1098 return 63; | 1117 return 63; |
| 1099 }; | 1118 }; |
| 1100 | 1119 |
| 1101 void vp9_new_framerate(VP9_COMP *cpi, double framerate) { | 1120 void vp9_new_framerate(VP9_COMP *cpi, double framerate) { |
| 1102 VP9_COMMON *const cm = &cpi->common; | 1121 VP9_COMMON *const cm = &cpi->common; |
| 1103 int64_t vbr_max_bits; | 1122 int vbr_max_bits; |
| 1104 | 1123 |
| 1105 if (framerate < 0.1) | 1124 if (framerate < 0.1) |
| 1106 framerate = 30; | 1125 framerate = 30; |
| 1107 | 1126 |
| 1108 cpi->oxcf.framerate = framerate; | 1127 cpi->oxcf.framerate = framerate; |
| 1109 cpi->output_framerate = cpi->oxcf.framerate; | 1128 cpi->output_framerate = cpi->oxcf.framerate; |
| 1110 cpi->rc.av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth | 1129 cpi->rc.av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth |
| 1111 / cpi->output_framerate); | 1130 / cpi->output_framerate); |
| 1112 cpi->rc.min_frame_bandwidth = (int)(cpi->rc.av_per_frame_bandwidth * | 1131 cpi->rc.min_frame_bandwidth = (int)(cpi->rc.av_per_frame_bandwidth * |
| 1113 cpi->oxcf.two_pass_vbrmin_section / 100); | 1132 cpi->oxcf.two_pass_vbrmin_section / 100); |
| 1114 | 1133 |
| 1115 | 1134 |
| 1116 cpi->rc.min_frame_bandwidth = MAX(cpi->rc.min_frame_bandwidth, | 1135 cpi->rc.min_frame_bandwidth = MAX(cpi->rc.min_frame_bandwidth, |
| 1117 FRAME_OVERHEAD_BITS); | 1136 FRAME_OVERHEAD_BITS); |
| 1118 | 1137 |
| 1119 // A maximum bitrate for a frame is defined. | 1138 // A maximum bitrate for a frame is defined. |
| 1120 // The baseline for this aligns with HW implementations that | 1139 // The baseline for this aligns with HW implementations that |
| 1121 // can support decode of 1080P content up to a bitrate of MAX_MB_RATE bits | 1140 // can support decode of 1080P content up to a bitrate of MAX_MB_RATE bits |
| 1122 // per 16x16 MB (averaged over a frame). However this limit is extended if | 1141 // per 16x16 MB (averaged over a frame). However this limit is extended if |
| 1123 // a very high rate is given on the command line or the the rate cannnot | 1142 // a very high rate is given on the command line or the the rate cannnot |
| 1124 // be acheived because of a user specificed max q (e.g. when the user | 1143 // be acheived because of a user specificed max q (e.g. when the user |
| 1125 // specifies lossless encode. | 1144 // specifies lossless encode. |
| 1126 // | 1145 // |
| 1127 vbr_max_bits = ((int64_t)cpi->rc.av_per_frame_bandwidth * | 1146 vbr_max_bits = (int)(((int64_t)cpi->rc.av_per_frame_bandwidth * |
| 1128 (int64_t)cpi->oxcf.two_pass_vbrmax_section) / 100; | 1147 cpi->oxcf.two_pass_vbrmax_section) / 100); |
| 1129 cpi->rc.max_frame_bandwidth = | 1148 cpi->rc.max_frame_bandwidth = |
| 1130 MAX(MAX((cm->MBs * MAX_MB_RATE), MAXRATE_1080P), vbr_max_bits); | 1149 MAX(MAX((cm->MBs * MAX_MB_RATE), MAXRATE_1080P), vbr_max_bits); |
| 1131 | 1150 |
| 1132 // Set Maximum gf/arf interval | 1151 // Set Maximum gf/arf interval |
| 1133 cpi->rc.max_gf_interval = 16; | 1152 cpi->rc.max_gf_interval = 16; |
| 1134 | 1153 |
| 1135 // Extended interval for genuinely static scenes | 1154 // Extended interval for genuinely static scenes |
| 1136 cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; | 1155 cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; |
| 1137 | 1156 |
| 1138 // Special conditions when alt ref frame enabled in lagged compress mode | 1157 // Special conditions when alt ref frame enabled in lagged compress mode |
| 1139 if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) { | 1158 if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) { |
| 1140 if (cpi->rc.max_gf_interval > cpi->oxcf.lag_in_frames - 1) | 1159 if (cpi->rc.max_gf_interval > cpi->oxcf.lag_in_frames - 1) |
| 1141 cpi->rc.max_gf_interval = cpi->oxcf.lag_in_frames - 1; | 1160 cpi->rc.max_gf_interval = cpi->oxcf.lag_in_frames - 1; |
| 1142 | 1161 |
| 1143 if (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1) | 1162 if (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1) |
| 1144 cpi->twopass.static_scene_max_gf_interval = cpi->oxcf.lag_in_frames - 1; | 1163 cpi->twopass.static_scene_max_gf_interval = cpi->oxcf.lag_in_frames - 1; |
| 1145 } | 1164 } |
| 1146 | 1165 |
| 1147 if (cpi->rc.max_gf_interval > cpi->twopass.static_scene_max_gf_interval) | 1166 if (cpi->rc.max_gf_interval > cpi->twopass.static_scene_max_gf_interval) |
| 1148 cpi->rc.max_gf_interval = cpi->twopass.static_scene_max_gf_interval; | 1167 cpi->rc.max_gf_interval = cpi->twopass.static_scene_max_gf_interval; |
| 1149 } | 1168 } |
| 1150 | 1169 |
| 1151 static int64_t rescale(int val, int64_t num, int denom) { | 1170 static int64_t rescale(int64_t val, int64_t num, int denom) { |
| 1152 int64_t llnum = num; | 1171 int64_t llnum = num; |
| 1153 int64_t llden = denom; | 1172 int64_t llden = denom; |
| 1154 int64_t llval = val; | 1173 int64_t llval = val; |
| 1155 | 1174 |
| 1156 return (llval * llnum / llden); | 1175 return (llval * llnum / llden); |
| 1157 } | 1176 } |
| 1158 | 1177 |
| 1159 // Initialize layer context data from init_config(). | 1178 // Initialize layer context data from init_config(). |
| 1160 static void init_layer_context(VP9_COMP *const cpi) { | 1179 static void init_layer_context(VP9_COMP *const cpi) { |
| 1161 const VP9_CONFIG *const oxcf = &cpi->oxcf; | 1180 const VP9_CONFIG *const oxcf = &cpi->oxcf; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 const RATE_CONTROL *const rc = &cpi->rc; | 1213 const RATE_CONTROL *const rc = &cpi->rc; |
| 1195 int temporal_layer = 0; | 1214 int temporal_layer = 0; |
| 1196 float bitrate_alloc = 1.0; | 1215 float bitrate_alloc = 1.0; |
| 1197 for (temporal_layer = 0; temporal_layer < cpi->svc.number_temporal_layers; | 1216 for (temporal_layer = 0; temporal_layer < cpi->svc.number_temporal_layers; |
| 1198 ++temporal_layer) { | 1217 ++temporal_layer) { |
| 1199 LAYER_CONTEXT *const lc = &cpi->svc.layer_context[temporal_layer]; | 1218 LAYER_CONTEXT *const lc = &cpi->svc.layer_context[temporal_layer]; |
| 1200 RATE_CONTROL *const lrc = &lc->rc; | 1219 RATE_CONTROL *const lrc = &lc->rc; |
| 1201 lc->target_bandwidth = oxcf->ts_target_bitrate[temporal_layer] * 1000; | 1220 lc->target_bandwidth = oxcf->ts_target_bitrate[temporal_layer] * 1000; |
| 1202 bitrate_alloc = (float)lc->target_bandwidth / (float)target_bandwidth; | 1221 bitrate_alloc = (float)lc->target_bandwidth / (float)target_bandwidth; |
| 1203 // Update buffer-related quantities. | 1222 // Update buffer-related quantities. |
| 1204 lc->starting_buffer_level = oxcf->starting_buffer_level * bitrate_alloc; | 1223 lc->starting_buffer_level = |
| 1205 lc->optimal_buffer_level = oxcf->optimal_buffer_level * bitrate_alloc; | 1224 (int64_t)(oxcf->starting_buffer_level * bitrate_alloc); |
| 1206 lc->maximum_buffer_size = oxcf->maximum_buffer_size * bitrate_alloc; | 1225 lc->optimal_buffer_level = |
| 1226 (int64_t)(oxcf->optimal_buffer_level * bitrate_alloc); |
| 1227 lc->maximum_buffer_size = |
| 1228 (int64_t)(oxcf->maximum_buffer_size * bitrate_alloc); |
| 1207 lrc->bits_off_target = MIN(lrc->bits_off_target, lc->maximum_buffer_size); | 1229 lrc->bits_off_target = MIN(lrc->bits_off_target, lc->maximum_buffer_size); |
| 1208 lrc->buffer_level = MIN(lrc->buffer_level, lc->maximum_buffer_size); | 1230 lrc->buffer_level = MIN(lrc->buffer_level, lc->maximum_buffer_size); |
| 1209 // Update framerate-related quantities. | 1231 // Update framerate-related quantities. |
| 1210 lc->framerate = oxcf->framerate / oxcf->ts_rate_decimator[temporal_layer]; | 1232 lc->framerate = oxcf->framerate / oxcf->ts_rate_decimator[temporal_layer]; |
| 1211 lrc->av_per_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate); | 1233 lrc->av_per_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate); |
| 1212 lrc->max_frame_bandwidth = rc->max_frame_bandwidth; | 1234 lrc->max_frame_bandwidth = rc->max_frame_bandwidth; |
| 1213 // Update qp-related quantities. | 1235 // Update qp-related quantities. |
| 1214 lrc->worst_quality = rc->worst_quality; | 1236 lrc->worst_quality = rc->worst_quality; |
| 1215 lrc->best_quality = rc->best_quality; | 1237 lrc->best_quality = rc->best_quality; |
| 1216 } | 1238 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1228 lrc->max_frame_bandwidth = cpi->rc.max_frame_bandwidth; | 1250 lrc->max_frame_bandwidth = cpi->rc.max_frame_bandwidth; |
| 1229 // Update the average layer frame size (non-cumulative per-frame-bw). | 1251 // Update the average layer frame size (non-cumulative per-frame-bw). |
| 1230 if (temporal_layer == 0) { | 1252 if (temporal_layer == 0) { |
| 1231 lc->avg_frame_size = lrc->av_per_frame_bandwidth; | 1253 lc->avg_frame_size = lrc->av_per_frame_bandwidth; |
| 1232 } else { | 1254 } else { |
| 1233 double prev_layer_framerate = oxcf->framerate / | 1255 double prev_layer_framerate = oxcf->framerate / |
| 1234 oxcf->ts_rate_decimator[temporal_layer - 1]; | 1256 oxcf->ts_rate_decimator[temporal_layer - 1]; |
| 1235 int prev_layer_target_bandwidth = | 1257 int prev_layer_target_bandwidth = |
| 1236 oxcf->ts_target_bitrate[temporal_layer - 1] * 1000; | 1258 oxcf->ts_target_bitrate[temporal_layer - 1] * 1000; |
| 1237 lc->avg_frame_size = | 1259 lc->avg_frame_size = |
| 1238 (int)(lc->target_bandwidth - prev_layer_target_bandwidth) / | 1260 (int)((lc->target_bandwidth - prev_layer_target_bandwidth) / |
| 1239 (lc->framerate - prev_layer_framerate); | 1261 (lc->framerate - prev_layer_framerate)); |
| 1240 } | 1262 } |
| 1241 } | 1263 } |
| 1242 | 1264 |
| 1243 // Prior to encoding the frame, set the layer context, for the current layer | 1265 // Prior to encoding the frame, set the layer context, for the current layer |
| 1244 // to be encoded, to the cpi struct. | 1266 // to be encoded, to the cpi struct. |
| 1245 static void restore_layer_context(VP9_COMP *const cpi) { | 1267 static void restore_layer_context(VP9_COMP *const cpi) { |
| 1246 int temporal_layer = cpi->svc.temporal_layer_id; | 1268 int temporal_layer = cpi->svc.temporal_layer_id; |
| 1247 LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer]; | 1269 LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer]; |
| 1248 int frame_since_key = cpi->rc.frames_since_key; | 1270 int frame_since_key = cpi->rc.frames_since_key; |
| 1249 int frame_to_key = cpi->rc.frames_to_key; | 1271 int frame_to_key = cpi->rc.frames_to_key; |
| 1250 cpi->rc = lc->rc; | 1272 cpi->rc = lc->rc; |
| 1251 cpi->oxcf.target_bandwidth = lc->target_bandwidth; | 1273 cpi->oxcf.target_bandwidth = lc->target_bandwidth; |
| 1252 cpi->oxcf.starting_buffer_level = lc->starting_buffer_level; | 1274 cpi->oxcf.starting_buffer_level = lc->starting_buffer_level; |
| 1253 cpi->oxcf.optimal_buffer_level = lc->optimal_buffer_level; | 1275 cpi->oxcf.optimal_buffer_level = lc->optimal_buffer_level; |
| 1254 cpi->oxcf.maximum_buffer_size = lc->maximum_buffer_size; | 1276 cpi->oxcf.maximum_buffer_size = lc->maximum_buffer_size; |
| 1255 cpi->output_framerate = lc->framerate; | 1277 cpi->output_framerate = lc->framerate; |
| 1256 // Reset the frames_since_key and frames_to_key counters to their values | 1278 // Reset the frames_since_key and frames_to_key counters to their values |
| 1257 // before the layer restore. Keep these defined for the stream (not layer). | 1279 // before the layer restore. Keep these defined for the stream (not layer). |
| 1258 cpi->rc.frames_since_key = frame_since_key; | 1280 cpi->rc.frames_since_key = frame_since_key; |
| 1259 cpi->rc.frames_to_key = frame_to_key; | 1281 cpi->rc.frames_to_key = frame_to_key; |
| 1260 } | 1282 } |
| 1261 | 1283 |
| 1262 // Save the layer context after encoding the frame. | 1284 // Save the layer context after encoding the frame. |
| 1263 static void save_layer_context(VP9_COMP *const cpi) { | 1285 static void save_layer_context(VP9_COMP *const cpi) { |
| 1264 int temporal_layer = cpi->svc.temporal_layer_id; | 1286 int temporal_layer = cpi->svc.temporal_layer_id; |
| 1265 LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer]; | 1287 LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer]; |
| 1266 lc->rc = cpi->rc; | 1288 lc->rc = cpi->rc; |
| 1267 lc->target_bandwidth = cpi->oxcf.target_bandwidth; | 1289 lc->target_bandwidth = (int)cpi->oxcf.target_bandwidth; |
| 1268 lc->starting_buffer_level = cpi->oxcf.starting_buffer_level; | 1290 lc->starting_buffer_level = cpi->oxcf.starting_buffer_level; |
| 1269 lc->optimal_buffer_level = cpi->oxcf.optimal_buffer_level; | 1291 lc->optimal_buffer_level = cpi->oxcf.optimal_buffer_level; |
| 1270 lc->maximum_buffer_size = cpi->oxcf.maximum_buffer_size; | 1292 lc->maximum_buffer_size = cpi->oxcf.maximum_buffer_size; |
| 1271 lc->framerate = cpi->output_framerate; | 1293 lc->framerate = cpi->output_framerate; |
| 1272 } | 1294 } |
| 1273 | 1295 |
| 1274 static void set_tile_limits(VP9_COMP *cpi) { | 1296 static void set_tile_limits(VP9_COMP *cpi) { |
| 1275 VP9_COMMON *const cm = &cpi->common; | 1297 VP9_COMMON *const cm = &cpi->common; |
| 1276 | 1298 |
| 1277 int min_log2_tile_cols, max_log2_tile_cols; | 1299 int min_log2_tile_cols, max_log2_tile_cols; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 | 1380 |
| 1359 if (!cpi || !oxcf) | 1381 if (!cpi || !oxcf) |
| 1360 return; | 1382 return; |
| 1361 | 1383 |
| 1362 if (cm->version != oxcf->version) { | 1384 if (cm->version != oxcf->version) { |
| 1363 cm->version = oxcf->version; | 1385 cm->version = oxcf->version; |
| 1364 } | 1386 } |
| 1365 | 1387 |
| 1366 cpi->oxcf = *oxcf; | 1388 cpi->oxcf = *oxcf; |
| 1367 | 1389 |
| 1390 if (cpi->oxcf.cpu_used == -6) |
| 1391 cpi->oxcf.play_alternate = 0; |
| 1392 |
| 1368 switch (cpi->oxcf.mode) { | 1393 switch (cpi->oxcf.mode) { |
| 1369 // Real time and one pass deprecated in test code base | 1394 // Real time and one pass deprecated in test code base |
| 1370 case MODE_GOODQUALITY: | 1395 case MODE_GOODQUALITY: |
| 1371 cpi->pass = 0; | 1396 cpi->pass = 0; |
| 1372 cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5); | 1397 cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5); |
| 1373 break; | 1398 break; |
| 1374 | 1399 |
| 1375 case MODE_FIRSTPASS: | 1400 case MODE_FIRSTPASS: |
| 1376 cpi->pass = 1; | 1401 cpi->pass = 1; |
| 1377 break; | 1402 break; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 // Increasing the size of the frame beyond the first seen frame, or some | 1499 // Increasing the size of the frame beyond the first seen frame, or some |
| 1475 // otherwise signaled maximum size, is not supported. | 1500 // otherwise signaled maximum size, is not supported. |
| 1476 // TODO(jkoleszar): exit gracefully. | 1501 // TODO(jkoleszar): exit gracefully. |
| 1477 assert(cm->width <= cpi->initial_width); | 1502 assert(cm->width <= cpi->initial_width); |
| 1478 assert(cm->height <= cpi->initial_height); | 1503 assert(cm->height <= cpi->initial_height); |
| 1479 } | 1504 } |
| 1480 update_frame_size(cpi); | 1505 update_frame_size(cpi); |
| 1481 | 1506 |
| 1482 if (cpi->svc.number_temporal_layers > 1 && | 1507 if (cpi->svc.number_temporal_layers > 1 && |
| 1483 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { | 1508 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { |
| 1484 update_layer_context_change_config(cpi, cpi->oxcf.target_bandwidth); | 1509 update_layer_context_change_config(cpi, (int)cpi->oxcf.target_bandwidth); |
| 1485 } | 1510 } |
| 1486 | 1511 |
| 1487 cpi->speed = cpi->oxcf.cpu_used; | 1512 cpi->speed = abs(cpi->oxcf.cpu_used); |
| 1488 | 1513 |
| 1489 if (cpi->oxcf.lag_in_frames == 0) { | 1514 // Limit on lag buffers as these are not currently dynamically allocated. |
| 1490 // Force allow_lag to 0 if lag_in_frames is 0. | 1515 if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS) |
| 1491 cpi->oxcf.allow_lag = 0; | |
| 1492 } else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS) { | |
| 1493 // Limit on lag buffers as these are not currently dynamically allocated. | |
| 1494 cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS; | 1516 cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS; |
| 1495 } | |
| 1496 | 1517 |
| 1497 #if CONFIG_MULTIPLE_ARF | 1518 #if CONFIG_MULTIPLE_ARF |
| 1498 vp9_zero(cpi->alt_ref_source); | 1519 vp9_zero(cpi->alt_ref_source); |
| 1499 #else | 1520 #else |
| 1500 cpi->alt_ref_source = NULL; | 1521 cpi->alt_ref_source = NULL; |
| 1501 #endif | 1522 #endif |
| 1502 cpi->rc.is_src_frame_alt_ref = 0; | 1523 cpi->rc.is_src_frame_alt_ref = 0; |
| 1503 | 1524 |
| 1504 #if 0 | 1525 #if 0 |
| 1505 // Experimental RD Code | 1526 // Experimental RD Code |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 mvsadcost[0][-i] = (int)z; | 1572 mvsadcost[0][-i] = (int)z; |
| 1552 mvsadcost[1][-i] = (int)z; | 1573 mvsadcost[1][-i] = (int)z; |
| 1553 } while (++i <= MV_MAX); | 1574 } while (++i <= MV_MAX); |
| 1554 } | 1575 } |
| 1555 | 1576 |
| 1556 static void alloc_mode_context(VP9_COMMON *cm, int num_4x4_blk, | 1577 static void alloc_mode_context(VP9_COMMON *cm, int num_4x4_blk, |
| 1557 PICK_MODE_CONTEXT *ctx) { | 1578 PICK_MODE_CONTEXT *ctx) { |
| 1558 int num_pix = num_4x4_blk << 4; | 1579 int num_pix = num_4x4_blk << 4; |
| 1559 int i, k; | 1580 int i, k; |
| 1560 ctx->num_4x4_blk = num_4x4_blk; | 1581 ctx->num_4x4_blk = num_4x4_blk; |
| 1582 |
| 1561 CHECK_MEM_ERROR(cm, ctx->zcoeff_blk, | 1583 CHECK_MEM_ERROR(cm, ctx->zcoeff_blk, |
| 1562 vpx_calloc(num_4x4_blk, sizeof(uint8_t))); | 1584 vpx_calloc(num_4x4_blk, sizeof(uint8_t))); |
| 1563 for (i = 0; i < MAX_MB_PLANE; ++i) { | 1585 for (i = 0; i < MAX_MB_PLANE; ++i) { |
| 1564 for (k = 0; k < 3; ++k) { | 1586 for (k = 0; k < 3; ++k) { |
| 1565 CHECK_MEM_ERROR(cm, ctx->coeff[i][k], | 1587 CHECK_MEM_ERROR(cm, ctx->coeff[i][k], |
| 1566 vpx_memalign(16, num_pix * sizeof(int16_t))); | 1588 vpx_memalign(16, num_pix * sizeof(int16_t))); |
| 1567 CHECK_MEM_ERROR(cm, ctx->qcoeff[i][k], | 1589 CHECK_MEM_ERROR(cm, ctx->qcoeff[i][k], |
| 1568 vpx_memalign(16, num_pix * sizeof(int16_t))); | 1590 vpx_memalign(16, num_pix * sizeof(int16_t))); |
| 1569 CHECK_MEM_ERROR(cm, ctx->dqcoeff[i][k], | 1591 CHECK_MEM_ERROR(cm, ctx->dqcoeff[i][k], |
| 1570 vpx_memalign(16, num_pix * sizeof(int16_t))); | 1592 vpx_memalign(16, num_pix * sizeof(int16_t))); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1594 ctx->eobs[i][k] = 0; | 1616 ctx->eobs[i][k] = 0; |
| 1595 } | 1617 } |
| 1596 } | 1618 } |
| 1597 } | 1619 } |
| 1598 | 1620 |
| 1599 static void init_pick_mode_context(VP9_COMP *cpi) { | 1621 static void init_pick_mode_context(VP9_COMP *cpi) { |
| 1600 int i; | 1622 int i; |
| 1601 VP9_COMMON *const cm = &cpi->common; | 1623 VP9_COMMON *const cm = &cpi->common; |
| 1602 MACROBLOCK *const x = &cpi->mb; | 1624 MACROBLOCK *const x = &cpi->mb; |
| 1603 | 1625 |
| 1604 | |
| 1605 for (i = 0; i < BLOCK_SIZES; ++i) { | 1626 for (i = 0; i < BLOCK_SIZES; ++i) { |
| 1606 const int num_4x4_w = num_4x4_blocks_wide_lookup[i]; | 1627 const int num_4x4_w = num_4x4_blocks_wide_lookup[i]; |
| 1607 const int num_4x4_h = num_4x4_blocks_high_lookup[i]; | 1628 const int num_4x4_h = num_4x4_blocks_high_lookup[i]; |
| 1608 const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h); | 1629 const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h); |
| 1609 if (i < BLOCK_16X16) { | 1630 if (i < BLOCK_16X16) { |
| 1610 for (x->sb_index = 0; x->sb_index < 4; ++x->sb_index) { | 1631 for (x->sb_index = 0; x->sb_index < 4; ++x->sb_index) { |
| 1611 for (x->mb_index = 0; x->mb_index < 4; ++x->mb_index) { | 1632 for (x->mb_index = 0; x->mb_index < 4; ++x->mb_index) { |
| 1612 for (x->b_index = 0; x->b_index < 16 / num_4x4_blk; ++x->b_index) { | 1633 for (x->b_index = 0; x->b_index < 16 / num_4x4_blk; ++x->b_index) { |
| 1613 PICK_MODE_CONTEXT *ctx = get_block_context(x, i); | 1634 PICK_MODE_CONTEXT *ctx = get_block_context(x, i); |
| 1614 alloc_mode_context(cm, num_4x4_blk, ctx); | 1635 alloc_mode_context(cm, num_4x4_blk, ctx); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 ctx.cpi->common.error.setjmp = 0; | 1718 ctx.cpi->common.error.setjmp = 0; |
| 1698 vp9_remove_compressor(&ptr); | 1719 vp9_remove_compressor(&ptr); |
| 1699 return 0; | 1720 return 0; |
| 1700 } | 1721 } |
| 1701 | 1722 |
| 1702 cm->error.setjmp = 1; | 1723 cm->error.setjmp = 1; |
| 1703 | 1724 |
| 1704 CHECK_MEM_ERROR(cm, cpi->mb.ss, vpx_calloc(sizeof(search_site), | 1725 CHECK_MEM_ERROR(cm, cpi->mb.ss, vpx_calloc(sizeof(search_site), |
| 1705 (MAX_MVSEARCH_STEPS * 8) + 1)); | 1726 (MAX_MVSEARCH_STEPS * 8) + 1)); |
| 1706 | 1727 |
| 1707 vp9_create_common(cm); | 1728 vp9_rtcd(); |
| 1708 | 1729 |
| 1709 cpi->use_svc = 0; | 1730 cpi->use_svc = 0; |
| 1710 | 1731 |
| 1711 init_config((VP9_PTR)cpi, oxcf); | 1732 init_config((VP9_PTR)cpi, oxcf); |
| 1712 | 1733 |
| 1713 init_pick_mode_context(cpi); | 1734 init_pick_mode_context(cpi); |
| 1714 | 1735 |
| 1715 cm->current_video_frame = 0; | 1736 cm->current_video_frame = 0; |
| 1716 | 1737 |
| 1717 // Set reference frame sign bias for ALTREF frame to 1 (for now) | 1738 // Set reference frame sign bias for ALTREF frame to 1 (for now) |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 } | 2014 } |
| 1994 | 2015 |
| 1995 void vp9_remove_compressor(VP9_PTR *ptr) { | 2016 void vp9_remove_compressor(VP9_PTR *ptr) { |
| 1996 VP9_COMP *cpi = (VP9_COMP *)(*ptr); | 2017 VP9_COMP *cpi = (VP9_COMP *)(*ptr); |
| 1997 int i; | 2018 int i; |
| 1998 | 2019 |
| 1999 if (!cpi) | 2020 if (!cpi) |
| 2000 return; | 2021 return; |
| 2001 | 2022 |
| 2002 if (cpi && (cpi->common.current_video_frame > 0)) { | 2023 if (cpi && (cpi->common.current_video_frame > 0)) { |
| 2003 if (cpi->pass == 2) { | |
| 2004 vp9_end_second_pass(cpi); | |
| 2005 } | |
| 2006 | |
| 2007 #if CONFIG_INTERNAL_STATS | 2024 #if CONFIG_INTERNAL_STATS |
| 2008 | 2025 |
| 2009 vp9_clear_system_state(); | 2026 vp9_clear_system_state(); |
| 2010 | 2027 |
| 2011 // printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count); | 2028 // printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count); |
| 2012 if (cpi->pass != 1) { | 2029 if (cpi->pass != 1) { |
| 2013 FILE *f = fopen("opsnr.stt", "a"); | 2030 FILE *f = fopen("opsnr.stt", "a"); |
| 2014 double time_encoded = (cpi->last_end_time_stamp_seen | 2031 double time_encoded = (cpi->last_end_time_stamp_seen |
| 2015 - cpi->first_time_stamp_ever) / 10000000.000; | 2032 - cpi->first_time_stamp_ever) / 10000000.000; |
| 2016 double total_encode_time = (cpi->time_receive_data + | 2033 double total_encode_time = (cpi->time_receive_data + |
| 2017 cpi->time_compress_data) / 1000.000; | 2034 cpi->time_compress_data) / 1000.000; |
| 2018 double dr = (double)cpi->bytes * (double) 8 / (double)1000 | 2035 double dr = (double)cpi->bytes * (double) 8 / (double)1000 |
| 2019 / time_encoded; | 2036 / time_encoded; |
| 2020 | 2037 |
| 2021 if (cpi->b_calculate_psnr) { | 2038 if (cpi->b_calculate_psnr) { |
| 2022 const double total_psnr = vp9_mse2psnr(cpi->total_samples, 255.0, | 2039 const double total_psnr = |
| 2023 cpi->total_sq_error); | 2040 vpx_sse_to_psnr((double)cpi->total_samples, 255.0, |
| 2024 const double totalp_psnr = vp9_mse2psnr(cpi->totalp_samples, 255.0, | 2041 (double)cpi->total_sq_error); |
| 2025 cpi->totalp_sq_error); | 2042 const double totalp_psnr = |
| 2043 vpx_sse_to_psnr((double)cpi->totalp_samples, 255.0, |
| 2044 (double)cpi->totalp_sq_error); |
| 2026 const double total_ssim = 100 * pow(cpi->summed_quality / | 2045 const double total_ssim = 100 * pow(cpi->summed_quality / |
| 2027 cpi->summed_weights, 8.0); | 2046 cpi->summed_weights, 8.0); |
| 2028 const double totalp_ssim = 100 * pow(cpi->summedp_quality / | 2047 const double totalp_ssim = 100 * pow(cpi->summedp_quality / |
| 2029 cpi->summedp_weights, 8.0); | 2048 cpi->summedp_weights, 8.0); |
| 2030 | 2049 |
| 2031 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\t" | 2050 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\t" |
| 2032 "VPXSSIM\tVPSSIMP\t Time(ms)\n"); | 2051 "VPXSSIM\tVPSSIMP\t Time(ms)\n"); |
| 2033 fprintf(f, "%7.2f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n", | 2052 fprintf(f, "%7.2f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n", |
| 2034 dr, cpi->total / cpi->count, total_psnr, | 2053 dr, cpi->total / cpi->count, total_psnr, |
| 2035 cpi->totalp / cpi->count, totalp_psnr, total_ssim, totalp_ssim, | 2054 cpi->totalp / cpi->count, totalp_psnr, total_ssim, totalp_ssim, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 const uint8_t *b_planes[3] = {b->y_buffer, b->u_buffer, b->v_buffer }; | 2210 const uint8_t *b_planes[3] = {b->y_buffer, b->u_buffer, b->v_buffer }; |
| 2192 const int b_strides[3] = {b->y_stride, b->uv_stride, b->uv_stride}; | 2211 const int b_strides[3] = {b->y_stride, b->uv_stride, b->uv_stride}; |
| 2193 int i; | 2212 int i; |
| 2194 uint64_t total_sse = 0; | 2213 uint64_t total_sse = 0; |
| 2195 uint32_t total_samples = 0; | 2214 uint32_t total_samples = 0; |
| 2196 | 2215 |
| 2197 for (i = 0; i < 3; ++i) { | 2216 for (i = 0; i < 3; ++i) { |
| 2198 const int w = widths[i]; | 2217 const int w = widths[i]; |
| 2199 const int h = heights[i]; | 2218 const int h = heights[i]; |
| 2200 const uint32_t samples = w * h; | 2219 const uint32_t samples = w * h; |
| 2201 const double sse = calc_plane_error(a_planes[i], a_strides[i], | 2220 const uint64_t sse = calc_plane_error(a_planes[i], a_strides[i], |
| 2202 b_planes[i], b_strides[i], | 2221 b_planes[i], b_strides[i], |
| 2203 w, h); | 2222 w, h); |
| 2204 psnr->sse[1 + i] = sse; | 2223 psnr->sse[1 + i] = sse; |
| 2205 psnr->samples[1 + i] = samples; | 2224 psnr->samples[1 + i] = samples; |
| 2206 psnr->psnr[1 + i] = vp9_mse2psnr(samples, 255.0, sse); | 2225 psnr->psnr[1 + i] = vpx_sse_to_psnr(samples, 255.0, (double)sse); |
| 2207 | 2226 |
| 2208 total_sse += sse; | 2227 total_sse += sse; |
| 2209 total_samples += samples; | 2228 total_samples += samples; |
| 2210 } | 2229 } |
| 2211 | 2230 |
| 2212 psnr->sse[0] = total_sse; | 2231 psnr->sse[0] = total_sse; |
| 2213 psnr->samples[0] = total_samples; | 2232 psnr->samples[0] = total_samples; |
| 2214 psnr->psnr[0] = vp9_mse2psnr(total_samples, 255.0, total_sse); | 2233 psnr->psnr[0] = vpx_sse_to_psnr((double)total_samples, 255.0, |
| 2234 (double)total_sse); |
| 2215 } | 2235 } |
| 2216 | 2236 |
| 2217 static void generate_psnr_packet(VP9_COMP *cpi) { | 2237 static void generate_psnr_packet(VP9_COMP *cpi) { |
| 2218 struct vpx_codec_cx_pkt pkt; | 2238 struct vpx_codec_cx_pkt pkt; |
| 2219 int i; | 2239 int i; |
| 2220 PSNR_STATS psnr; | 2240 PSNR_STATS psnr; |
| 2221 calc_psnr(cpi->Source, cpi->common.frame_to_show, &psnr); | 2241 calc_psnr(cpi->Source, cpi->common.frame_to_show, &psnr); |
| 2222 for (i = 0; i < 4; ++i) { | 2242 for (i = 0; i < 4; ++i) { |
| 2223 pkt.data.psnr.samples[i] = psnr.samples[i]; | 2243 pkt.data.psnr.samples[i] = psnr.samples[i]; |
| 2224 pkt.data.psnr.sse[i] = psnr.sse[i]; | 2244 pkt.data.psnr.sse[i] = psnr.sse[i]; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 | 2673 |
| 2654 vpx_usec_timer_mark(&timer); | 2674 vpx_usec_timer_mark(&timer); |
| 2655 cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); | 2675 cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); |
| 2656 } | 2676 } |
| 2657 | 2677 |
| 2658 if (lf->filter_level > 0) { | 2678 if (lf->filter_level > 0) { |
| 2659 vp9_set_alt_lf_level(cpi, lf->filter_level); | 2679 vp9_set_alt_lf_level(cpi, lf->filter_level); |
| 2660 vp9_loop_filter_frame(cm, xd, lf->filter_level, 0, 0); | 2680 vp9_loop_filter_frame(cm, xd, lf->filter_level, 0, 0); |
| 2661 } | 2681 } |
| 2662 | 2682 |
| 2663 vp9_extend_frame_inner_borders(cm->frame_to_show, | 2683 vp9_extend_frame_inner_borders(cm->frame_to_show); |
| 2664 cm->subsampling_x, cm->subsampling_y); | |
| 2665 } | 2684 } |
| 2666 | 2685 |
| 2667 static void scale_references(VP9_COMP *cpi) { | 2686 static void scale_references(VP9_COMP *cpi) { |
| 2668 VP9_COMMON *cm = &cpi->common; | 2687 VP9_COMMON *cm = &cpi->common; |
| 2669 MV_REFERENCE_FRAME ref_frame; | 2688 MV_REFERENCE_FRAME ref_frame; |
| 2670 | 2689 |
| 2671 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { | 2690 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { |
| 2672 const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]; | 2691 const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]; |
| 2673 YV12_BUFFER_CONFIG *const ref = &cm->frame_bufs[idx].buf; | 2692 YV12_BUFFER_CONFIG *const ref = &cm->frame_bufs[idx].buf; |
| 2674 | 2693 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2717 for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) | 2736 for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) |
| 2718 full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]); | 2737 full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]); |
| 2719 } | 2738 } |
| 2720 | 2739 |
| 2721 #if 0 && CONFIG_INTERNAL_STATS | 2740 #if 0 && CONFIG_INTERNAL_STATS |
| 2722 static void output_frame_level_debug_stats(VP9_COMP *cpi) { | 2741 static void output_frame_level_debug_stats(VP9_COMP *cpi) { |
| 2723 VP9_COMMON *const cm = &cpi->common; | 2742 VP9_COMMON *const cm = &cpi->common; |
| 2724 FILE *const f = fopen("tmp.stt", cm->current_video_frame ? "a" : "w"); | 2743 FILE *const f = fopen("tmp.stt", cm->current_video_frame ? "a" : "w"); |
| 2725 int recon_err; | 2744 int recon_err; |
| 2726 | 2745 |
| 2727 vp9_clear_system_state(); // __asm emms; | 2746 vp9_clear_system_state(); |
| 2728 | 2747 |
| 2729 recon_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); | 2748 recon_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); |
| 2730 | 2749 |
| 2731 if (cpi->twopass.total_left_stats.coded_error != 0.0) | 2750 if (cpi->twopass.total_left_stats.coded_error != 0.0) |
| 2732 fprintf(f, "%10u %10d %10d %10d %10d %10d " | 2751 fprintf(f, "%10u %10d %10d %10d %10d %10d " |
| 2733 "%10"PRId64" %10"PRId64" %10d " | 2752 "%10"PRId64" %10"PRId64" %10d " |
| 2734 "%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf" | 2753 "%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf" |
| 2735 "%6d %6d %5d %5d %5d " | 2754 "%6d %6d %5d %5d %5d " |
| 2736 "%10"PRId64" %10.3lf" | 2755 "%10"PRId64" %10.3lf" |
| 2737 "%10lf %8u %10d %10d %10d\n", | 2756 "%10lf %8u %10d %10d %10d\n", |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2761 if (0) { | 2780 if (0) { |
| 2762 FILE *const fmodes = fopen("Modes.stt", "a"); | 2781 FILE *const fmodes = fopen("Modes.stt", "a"); |
| 2763 int i; | 2782 int i; |
| 2764 | 2783 |
| 2765 fprintf(fmodes, "%6d:%1d:%1d:%1d ", cpi->common.current_video_frame, | 2784 fprintf(fmodes, "%6d:%1d:%1d:%1d ", cpi->common.current_video_frame, |
| 2766 cm->frame_type, cpi->refresh_golden_frame, | 2785 cm->frame_type, cpi->refresh_golden_frame, |
| 2767 cpi->refresh_alt_ref_frame); | 2786 cpi->refresh_alt_ref_frame); |
| 2768 | 2787 |
| 2769 for (i = 0; i < MAX_MODES; ++i) | 2788 for (i = 0; i < MAX_MODES; ++i) |
| 2770 fprintf(fmodes, "%5d ", cpi->mode_chosen_counts[i]); | 2789 fprintf(fmodes, "%5d ", cpi->mode_chosen_counts[i]); |
| 2771 for (i = 0; i < MAX_REFS; ++i) | |
| 2772 fprintf(fmodes, "%5d ", cpi->sub8x8_mode_chosen_counts[i]); | |
| 2773 | 2790 |
| 2774 fprintf(fmodes, "\n"); | 2791 fprintf(fmodes, "\n"); |
| 2775 | 2792 |
| 2776 fclose(fmodes); | 2793 fclose(fmodes); |
| 2777 } | 2794 } |
| 2778 } | 2795 } |
| 2779 #endif | 2796 #endif |
| 2780 | 2797 |
| 2781 static void encode_without_recode_loop(VP9_COMP *cpi, | 2798 static void encode_without_recode_loop(VP9_COMP *cpi, |
| 2782 size_t *size, | 2799 size_t *size, |
| 2783 uint8_t *dest, | 2800 uint8_t *dest, |
| 2784 int q) { | 2801 int q) { |
| 2785 VP9_COMMON *const cm = &cpi->common; | 2802 VP9_COMMON *const cm = &cpi->common; |
| 2786 vp9_clear_system_state(); // __asm emms; | 2803 vp9_clear_system_state(); |
| 2787 vp9_set_quantizer(cpi, q); | 2804 vp9_set_quantizer(cpi, q); |
| 2788 | 2805 |
| 2789 // Set up entropy context depending on frame type. The decoder mandates | 2806 // Set up entropy context depending on frame type. The decoder mandates |
| 2790 // the use of the default context, index 0, for keyframes and inter | 2807 // the use of the default context, index 0, for keyframes and inter |
| 2791 // frames where the error_resilient_mode or intra_only flag is set. For | 2808 // frames where the error_resilient_mode or intra_only flag is set. For |
| 2792 // other inter-frames the encoder currently uses only two contexts; | 2809 // other inter-frames the encoder currently uses only two contexts; |
| 2793 // context 1 for ALTREF frames and context 0 for the others. | 2810 // context 1 for ALTREF frames and context 0 for the others. |
| 2794 if (cm->frame_type == KEY_FRAME) { | 2811 if (cm->frame_type == KEY_FRAME) { |
| 2795 vp9_setup_key_frame(cpi); | 2812 vp9_setup_key_frame(cpi); |
| 2796 } else { | 2813 } else { |
| 2797 if (!cm->intra_only && !cm->error_resilient_mode) { | 2814 if (!cm->intra_only && !cm->error_resilient_mode && !cpi->use_svc) { |
| 2798 cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame; | 2815 cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame; |
| 2799 } | 2816 } |
| 2800 vp9_setup_inter_frame(cpi); | 2817 vp9_setup_inter_frame(cpi); |
| 2801 } | 2818 } |
| 2802 // Variance adaptive and in frame q adjustment experiments are mutually | 2819 // Variance adaptive and in frame q adjustment experiments are mutually |
| 2803 // exclusive. | 2820 // exclusive. |
| 2804 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { | 2821 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 2805 vp9_vaq_frame_setup(cpi); | 2822 vp9_vaq_frame_setup(cpi); |
| 2806 } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { | 2823 } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { |
| 2807 setup_in_frame_q_adj(cpi); | 2824 setup_in_frame_q_adj(cpi); |
| 2808 } | 2825 } |
| 2809 // transform / motion compensation build reconstruction frame | 2826 // transform / motion compensation build reconstruction frame |
| 2810 vp9_encode_frame(cpi); | 2827 vp9_encode_frame(cpi); |
| 2811 | 2828 |
| 2812 // Update the skip mb flag probabilities based on the distribution | 2829 // Update the skip mb flag probabilities based on the distribution |
| 2813 // seen in the last encoder iteration. | 2830 // seen in the last encoder iteration. |
| 2814 // update_base_skip_probs(cpi); | 2831 // update_base_skip_probs(cpi); |
| 2815 vp9_clear_system_state(); // __asm emms; | 2832 vp9_clear_system_state(); |
| 2816 } | 2833 } |
| 2817 | 2834 |
| 2818 static void encode_with_recode_loop(VP9_COMP *cpi, | 2835 static void encode_with_recode_loop(VP9_COMP *cpi, |
| 2819 size_t *size, | 2836 size_t *size, |
| 2820 uint8_t *dest, | 2837 uint8_t *dest, |
| 2821 int q, | 2838 int q, |
| 2822 int bottom_index, | 2839 int bottom_index, |
| 2823 int top_index) { | 2840 int top_index) { |
| 2824 VP9_COMMON *const cm = &cpi->common; | 2841 VP9_COMMON *const cm = &cpi->common; |
| 2842 RATE_CONTROL *const rc = &cpi->rc; |
| 2825 int loop_count = 0; | 2843 int loop_count = 0; |
| 2826 int loop = 0; | 2844 int loop = 0; |
| 2827 int overshoot_seen = 0; | 2845 int overshoot_seen = 0; |
| 2828 int undershoot_seen = 0; | 2846 int undershoot_seen = 0; |
| 2829 int q_low = bottom_index, q_high = top_index; | 2847 int q_low = bottom_index, q_high = top_index; |
| 2830 int frame_over_shoot_limit; | 2848 int frame_over_shoot_limit; |
| 2831 int frame_under_shoot_limit; | 2849 int frame_under_shoot_limit; |
| 2832 | 2850 |
| 2833 // Decide frame size bounds | 2851 // Decide frame size bounds |
| 2834 vp9_rc_compute_frame_size_bounds(cpi, cpi->rc.this_frame_target, | 2852 vp9_rc_compute_frame_size_bounds(cpi, rc->this_frame_target, |
| 2835 &frame_under_shoot_limit, | 2853 &frame_under_shoot_limit, |
| 2836 &frame_over_shoot_limit); | 2854 &frame_over_shoot_limit); |
| 2837 | 2855 |
| 2838 do { | 2856 do { |
| 2839 vp9_clear_system_state(); // __asm emms; | 2857 vp9_clear_system_state(); |
| 2840 | 2858 |
| 2841 vp9_set_quantizer(cpi, q); | 2859 vp9_set_quantizer(cpi, q); |
| 2842 | 2860 |
| 2843 if (loop_count == 0) { | 2861 if (loop_count == 0) { |
| 2844 // Set up entropy context depending on frame type. The decoder mandates | 2862 // Set up entropy context depending on frame type. The decoder mandates |
| 2845 // the use of the default context, index 0, for keyframes and inter | 2863 // the use of the default context, index 0, for keyframes and inter |
| 2846 // frames where the error_resilient_mode or intra_only flag is set. For | 2864 // frames where the error_resilient_mode or intra_only flag is set. For |
| 2847 // other inter-frames the encoder currently uses only two contexts; | 2865 // other inter-frames the encoder currently uses only two contexts; |
| 2848 // context 1 for ALTREF frames and context 0 for the others. | 2866 // context 1 for ALTREF frames and context 0 for the others. |
| 2849 if (cm->frame_type == KEY_FRAME) { | 2867 if (cm->frame_type == KEY_FRAME) { |
| 2850 vp9_setup_key_frame(cpi); | 2868 vp9_setup_key_frame(cpi); |
| 2851 } else { | 2869 } else { |
| 2852 if (!cm->intra_only && !cm->error_resilient_mode) { | 2870 if (!cm->intra_only && !cm->error_resilient_mode && !cpi->use_svc) { |
| 2853 cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame; | 2871 cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame; |
| 2854 } | 2872 } |
| 2855 vp9_setup_inter_frame(cpi); | 2873 vp9_setup_inter_frame(cpi); |
| 2856 } | 2874 } |
| 2857 } | 2875 } |
| 2858 | 2876 |
| 2859 // Variance adaptive and in frame q adjustment experiments are mutually | 2877 // Variance adaptive and in frame q adjustment experiments are mutually |
| 2860 // exclusive. | 2878 // exclusive. |
| 2861 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { | 2879 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 2862 vp9_vaq_frame_setup(cpi); | 2880 vp9_vaq_frame_setup(cpi); |
| 2863 } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { | 2881 } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { |
| 2864 setup_in_frame_q_adj(cpi); | 2882 setup_in_frame_q_adj(cpi); |
| 2865 } | 2883 } |
| 2866 | 2884 |
| 2867 // transform / motion compensation build reconstruction frame | 2885 // transform / motion compensation build reconstruction frame |
| 2868 vp9_encode_frame(cpi); | 2886 vp9_encode_frame(cpi); |
| 2869 | 2887 |
| 2870 // Update the skip mb flag probabilities based on the distribution | 2888 // Update the skip mb flag probabilities based on the distribution |
| 2871 // seen in the last encoder iteration. | 2889 // seen in the last encoder iteration. |
| 2872 // update_base_skip_probs(cpi); | 2890 // update_base_skip_probs(cpi); |
| 2873 | 2891 |
| 2874 vp9_clear_system_state(); // __asm emms; | 2892 vp9_clear_system_state(); |
| 2875 | 2893 |
| 2876 // Dummy pack of the bitstream using up to date stats to get an | 2894 // Dummy pack of the bitstream using up to date stats to get an |
| 2877 // accurate estimate of output frame size to determine if we need | 2895 // accurate estimate of output frame size to determine if we need |
| 2878 // to recode. | 2896 // to recode. |
| 2879 if (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF) { | 2897 if (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF) { |
| 2880 vp9_save_coding_context(cpi); | 2898 vp9_save_coding_context(cpi); |
| 2881 cpi->dummy_packing = 1; | 2899 cpi->dummy_packing = 1; |
| 2882 if (!cpi->sf.use_pick_mode) | 2900 if (!cpi->sf.use_nonrd_pick_mode) |
| 2883 vp9_pack_bitstream(cpi, dest, size); | 2901 vp9_pack_bitstream(cpi, dest, size); |
| 2884 | 2902 |
| 2885 cpi->rc.projected_frame_size = (*size) << 3; | 2903 rc->projected_frame_size = (int)(*size) << 3; |
| 2886 vp9_restore_coding_context(cpi); | 2904 vp9_restore_coding_context(cpi); |
| 2887 | 2905 |
| 2888 if (frame_over_shoot_limit == 0) | 2906 if (frame_over_shoot_limit == 0) |
| 2889 frame_over_shoot_limit = 1; | 2907 frame_over_shoot_limit = 1; |
| 2890 } | 2908 } |
| 2891 | 2909 |
| 2892 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { | 2910 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { |
| 2893 loop = 0; | 2911 loop = 0; |
| 2894 } else { | 2912 } else { |
| 2895 if ((cm->frame_type == KEY_FRAME) && | 2913 if ((cm->frame_type == KEY_FRAME) && |
| 2896 cpi->rc.this_key_frame_forced && | 2914 rc->this_key_frame_forced && |
| 2897 (cpi->rc.projected_frame_size < cpi->rc.max_frame_bandwidth)) { | 2915 (rc->projected_frame_size < rc->max_frame_bandwidth)) { |
| 2898 int last_q = q; | 2916 int last_q = q; |
| 2899 int kf_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); | 2917 int kf_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); |
| 2900 | 2918 |
| 2901 int high_err_target = cpi->ambient_err; | 2919 int high_err_target = cpi->ambient_err; |
| 2902 int low_err_target = cpi->ambient_err >> 1; | 2920 int low_err_target = cpi->ambient_err >> 1; |
| 2903 | 2921 |
| 2904 // Prevent possible divide by zero error below for perfect KF | 2922 // Prevent possible divide by zero error below for perfect KF |
| 2905 kf_err += !kf_err; | 2923 kf_err += !kf_err; |
| 2906 | 2924 |
| 2907 // The key frame is not good enough or we can afford | 2925 // The key frame is not good enough or we can afford |
| 2908 // to make it better without undue risk of popping. | 2926 // to make it better without undue risk of popping. |
| 2909 if ((kf_err > high_err_target && | 2927 if ((kf_err > high_err_target && |
| 2910 cpi->rc.projected_frame_size <= frame_over_shoot_limit) || | 2928 rc->projected_frame_size <= frame_over_shoot_limit) || |
| 2911 (kf_err > low_err_target && | 2929 (kf_err > low_err_target && |
| 2912 cpi->rc.projected_frame_size <= frame_under_shoot_limit)) { | 2930 rc->projected_frame_size <= frame_under_shoot_limit)) { |
| 2913 // Lower q_high | 2931 // Lower q_high |
| 2914 q_high = q > q_low ? q - 1 : q_low; | 2932 q_high = q > q_low ? q - 1 : q_low; |
| 2915 | 2933 |
| 2916 // Adjust Q | 2934 // Adjust Q |
| 2917 q = (q * high_err_target) / kf_err; | 2935 q = (q * high_err_target) / kf_err; |
| 2918 q = MIN(q, (q_high + q_low) >> 1); | 2936 q = MIN(q, (q_high + q_low) >> 1); |
| 2919 } else if (kf_err < low_err_target && | 2937 } else if (kf_err < low_err_target && |
| 2920 cpi->rc.projected_frame_size >= frame_under_shoot_limit) { | 2938 rc->projected_frame_size >= frame_under_shoot_limit) { |
| 2921 // The key frame is much better than the previous frame | 2939 // The key frame is much better than the previous frame |
| 2922 // Raise q_low | 2940 // Raise q_low |
| 2923 q_low = q < q_high ? q + 1 : q_high; | 2941 q_low = q < q_high ? q + 1 : q_high; |
| 2924 | 2942 |
| 2925 // Adjust Q | 2943 // Adjust Q |
| 2926 q = (q * low_err_target) / kf_err; | 2944 q = (q * low_err_target) / kf_err; |
| 2927 q = MIN(q, (q_high + q_low + 1) >> 1); | 2945 q = MIN(q, (q_high + q_low + 1) >> 1); |
| 2928 } | 2946 } |
| 2929 | 2947 |
| 2930 // Clamp Q to upper and lower limits: | 2948 // Clamp Q to upper and lower limits: |
| 2931 q = clamp(q, q_low, q_high); | 2949 q = clamp(q, q_low, q_high); |
| 2932 | 2950 |
| 2933 loop = q != last_q; | 2951 loop = q != last_q; |
| 2934 } else if (recode_loop_test( | 2952 } else if (recode_loop_test( |
| 2935 cpi, frame_over_shoot_limit, frame_under_shoot_limit, | 2953 cpi, frame_over_shoot_limit, frame_under_shoot_limit, |
| 2936 q, MAX(q_high, top_index), bottom_index)) { | 2954 q, MAX(q_high, top_index), bottom_index)) { |
| 2937 // Is the projected frame size out of range and are we allowed | 2955 // Is the projected frame size out of range and are we allowed |
| 2938 // to attempt to recode. | 2956 // to attempt to recode. |
| 2939 int last_q = q; | 2957 int last_q = q; |
| 2940 int retries = 0; | 2958 int retries = 0; |
| 2941 | 2959 |
| 2942 // Frame size out of permitted range: | 2960 // Frame size out of permitted range: |
| 2943 // Update correction factor & compute new Q to try... | 2961 // Update correction factor & compute new Q to try... |
| 2944 | 2962 |
| 2945 // Frame is too large | 2963 // Frame is too large |
| 2946 if (cpi->rc.projected_frame_size > cpi->rc.this_frame_target) { | 2964 if (rc->projected_frame_size > rc->this_frame_target) { |
| 2947 // Special case if the projected size is > the max allowed. | 2965 // Special case if the projected size is > the max allowed. |
| 2948 if (cpi->rc.projected_frame_size >= cpi->rc.max_frame_bandwidth) | 2966 if (rc->projected_frame_size >= rc->max_frame_bandwidth) |
| 2949 q_high = cpi->rc.worst_quality; | 2967 q_high = rc->worst_quality; |
| 2950 | 2968 |
| 2951 // Raise Qlow as to at least the current value | 2969 // Raise Qlow as to at least the current value |
| 2952 q_low = q < q_high ? q + 1 : q_high; | 2970 q_low = q < q_high ? q + 1 : q_high; |
| 2953 | 2971 |
| 2954 if (undershoot_seen || loop_count > 1) { | 2972 if (undershoot_seen || loop_count > 1) { |
| 2955 // Update rate_correction_factor unless | 2973 // Update rate_correction_factor unless |
| 2956 vp9_rc_update_rate_correction_factors(cpi, 1); | 2974 vp9_rc_update_rate_correction_factors(cpi, 1); |
| 2957 | 2975 |
| 2958 q = (q_high + q_low + 1) / 2; | 2976 q = (q_high + q_low + 1) / 2; |
| 2959 } else { | 2977 } else { |
| 2960 // Update rate_correction_factor unless | 2978 // Update rate_correction_factor unless |
| 2961 vp9_rc_update_rate_correction_factors(cpi, 0); | 2979 vp9_rc_update_rate_correction_factors(cpi, 0); |
| 2962 | 2980 |
| 2963 q = vp9_rc_regulate_q(cpi, cpi->rc.this_frame_target, | 2981 q = vp9_rc_regulate_q(cpi, rc->this_frame_target, |
| 2964 bottom_index, MAX(q_high, top_index)); | 2982 bottom_index, MAX(q_high, top_index)); |
| 2965 | 2983 |
| 2966 while (q < q_low && retries < 10) { | 2984 while (q < q_low && retries < 10) { |
| 2967 vp9_rc_update_rate_correction_factors(cpi, 0); | 2985 vp9_rc_update_rate_correction_factors(cpi, 0); |
| 2968 q = vp9_rc_regulate_q(cpi, cpi->rc.this_frame_target, | 2986 q = vp9_rc_regulate_q(cpi, rc->this_frame_target, |
| 2969 bottom_index, MAX(q_high, top_index)); | 2987 bottom_index, MAX(q_high, top_index)); |
| 2970 retries++; | 2988 retries++; |
| 2971 } | 2989 } |
| 2972 } | 2990 } |
| 2973 | 2991 |
| 2974 overshoot_seen = 1; | 2992 overshoot_seen = 1; |
| 2975 } else { | 2993 } else { |
| 2976 // Frame is too small | 2994 // Frame is too small |
| 2977 q_high = q > q_low ? q - 1 : q_low; | 2995 q_high = q > q_low ? q - 1 : q_low; |
| 2978 | 2996 |
| 2979 if (overshoot_seen || loop_count > 1) { | 2997 if (overshoot_seen || loop_count > 1) { |
| 2980 vp9_rc_update_rate_correction_factors(cpi, 1); | 2998 vp9_rc_update_rate_correction_factors(cpi, 1); |
| 2981 q = (q_high + q_low) / 2; | 2999 q = (q_high + q_low) / 2; |
| 2982 } else { | 3000 } else { |
| 2983 vp9_rc_update_rate_correction_factors(cpi, 0); | 3001 vp9_rc_update_rate_correction_factors(cpi, 0); |
| 2984 q = vp9_rc_regulate_q(cpi, cpi->rc.this_frame_target, | 3002 q = vp9_rc_regulate_q(cpi, rc->this_frame_target, |
| 2985 bottom_index, top_index); | 3003 bottom_index, top_index); |
| 2986 // Special case reset for qlow for constrained quality. | 3004 // Special case reset for qlow for constrained quality. |
| 2987 // This should only trigger where there is very substantial | 3005 // This should only trigger where there is very substantial |
| 2988 // undershoot on a frame and the auto cq level is above | 3006 // undershoot on a frame and the auto cq level is above |
| 2989 // the user passsed in value. | 3007 // the user passsed in value. |
| 2990 if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY && | 3008 if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY && |
| 2991 q < q_low) { | 3009 q < q_low) { |
| 2992 q_low = q; | 3010 q_low = q; |
| 2993 } | 3011 } |
| 2994 | 3012 |
| 2995 while (q > q_high && retries < 10) { | 3013 while (q > q_high && retries < 10) { |
| 2996 vp9_rc_update_rate_correction_factors(cpi, 0); | 3014 vp9_rc_update_rate_correction_factors(cpi, 0); |
| 2997 q = vp9_rc_regulate_q(cpi, cpi->rc.this_frame_target, | 3015 q = vp9_rc_regulate_q(cpi, rc->this_frame_target, |
| 2998 bottom_index, top_index); | 3016 bottom_index, top_index); |
| 2999 retries++; | 3017 retries++; |
| 3000 } | 3018 } |
| 3001 } | 3019 } |
| 3002 | 3020 |
| 3003 undershoot_seen = 1; | 3021 undershoot_seen = 1; |
| 3004 } | 3022 } |
| 3005 | 3023 |
| 3006 // Clamp Q to upper and lower limits: | 3024 // Clamp Q to upper and lower limits: |
| 3007 q = clamp(q, q_low, q_high); | 3025 q = clamp(q, q_low, q_high); |
| 3008 | 3026 |
| 3009 loop = q != last_q; | 3027 loop = q != last_q; |
| 3010 } else { | 3028 } else { |
| 3011 loop = 0; | 3029 loop = 0; |
| 3012 } | 3030 } |
| 3013 } | 3031 } |
| 3014 | 3032 |
| 3015 // Special case for overlay frame. | 3033 // Special case for overlay frame. |
| 3016 if (cpi->rc.is_src_frame_alt_ref && | 3034 if (rc->is_src_frame_alt_ref && |
| 3017 (cpi->rc.projected_frame_size < cpi->rc.max_frame_bandwidth)) | 3035 rc->projected_frame_size < rc->max_frame_bandwidth) |
| 3018 loop = 0; | 3036 loop = 0; |
| 3019 | 3037 |
| 3020 if (loop) { | 3038 if (loop) { |
| 3021 loop_count++; | 3039 loop_count++; |
| 3022 | 3040 |
| 3023 #if CONFIG_INTERNAL_STATS | 3041 #if CONFIG_INTERNAL_STATS |
| 3024 cpi->tot_recode_hits++; | 3042 cpi->tot_recode_hits++; |
| 3025 #endif | 3043 #endif |
| 3026 } | 3044 } |
| 3027 } while (loop); | 3045 } while (loop); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3041 if (cpi->refresh_alt_ref_frame & cpi->refresh_golden_frame) | 3059 if (cpi->refresh_alt_ref_frame & cpi->refresh_golden_frame) |
| 3042 cpi->gold_is_alt = 1; | 3060 cpi->gold_is_alt = 1; |
| 3043 else if (cpi->refresh_alt_ref_frame ^ cpi->refresh_golden_frame) | 3061 else if (cpi->refresh_alt_ref_frame ^ cpi->refresh_golden_frame) |
| 3044 cpi->gold_is_alt = 0; | 3062 cpi->gold_is_alt = 0; |
| 3045 | 3063 |
| 3046 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; | 3064 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; |
| 3047 | 3065 |
| 3048 if (cpi->gold_is_last) | 3066 if (cpi->gold_is_last) |
| 3049 cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; | 3067 cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; |
| 3050 | 3068 |
| 3069 if (cpi->rc.frames_till_gf_update_due == INT_MAX) |
| 3070 cpi->ref_frame_flags &= ~VP9_GOLD_FLAG; |
| 3071 |
| 3051 if (cpi->alt_is_last) | 3072 if (cpi->alt_is_last) |
| 3052 cpi->ref_frame_flags &= ~VP9_ALT_FLAG; | 3073 cpi->ref_frame_flags &= ~VP9_ALT_FLAG; |
| 3053 | 3074 |
| 3054 if (cpi->gold_is_alt) | 3075 if (cpi->gold_is_alt) |
| 3055 cpi->ref_frame_flags &= ~VP9_ALT_FLAG; | 3076 cpi->ref_frame_flags &= ~VP9_ALT_FLAG; |
| 3056 } | 3077 } |
| 3057 | 3078 |
| 3058 static void set_ext_overrides(VP9_COMP *cpi) { | 3079 static void set_ext_overrides(VP9_COMP *cpi) { |
| 3059 // Overrides the defaults with the externally supplied values with | 3080 // Overrides the defaults with the externally supplied values with |
| 3060 // vp9_update_reference() and vp9_update_entropy() calls | 3081 // vp9_update_reference() and vp9_update_entropy() calls |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3075 static void encode_frame_to_data_rate(VP9_COMP *cpi, | 3096 static void encode_frame_to_data_rate(VP9_COMP *cpi, |
| 3076 size_t *size, | 3097 size_t *size, |
| 3077 uint8_t *dest, | 3098 uint8_t *dest, |
| 3078 unsigned int *frame_flags) { | 3099 unsigned int *frame_flags) { |
| 3079 VP9_COMMON *const cm = &cpi->common; | 3100 VP9_COMMON *const cm = &cpi->common; |
| 3080 TX_SIZE t; | 3101 TX_SIZE t; |
| 3081 int q; | 3102 int q; |
| 3082 int top_index; | 3103 int top_index; |
| 3083 int bottom_index; | 3104 int bottom_index; |
| 3084 | 3105 |
| 3085 SPEED_FEATURES *const sf = &cpi->sf; | 3106 const SPEED_FEATURES *const sf = &cpi->sf; |
| 3086 unsigned int max_mv_def = MIN(cm->width, cm->height); | 3107 const unsigned int max_mv_def = MIN(cm->width, cm->height); |
| 3087 struct segmentation *const seg = &cm->seg; | 3108 struct segmentation *const seg = &cm->seg; |
| 3088 | 3109 |
| 3089 set_ext_overrides(cpi); | 3110 set_ext_overrides(cpi); |
| 3090 | 3111 |
| 3091 /* Scale the source buffer, if required. */ | 3112 /* Scale the source buffer, if required. */ |
| 3092 if (cm->mi_cols * MI_SIZE != cpi->un_scaled_source->y_width || | 3113 if (cm->mi_cols * MI_SIZE != cpi->un_scaled_source->y_width || |
| 3093 cm->mi_rows * MI_SIZE != cpi->un_scaled_source->y_height) { | 3114 cm->mi_rows * MI_SIZE != cpi->un_scaled_source->y_height) { |
| 3094 scale_and_extend_frame_nonnormative(cpi->un_scaled_source, | 3115 scale_and_extend_frame_nonnormative(cpi->un_scaled_source, |
| 3095 &cpi->scaled_source); | 3116 &cpi->scaled_source); |
| 3096 cpi->Source = &cpi->scaled_source; | 3117 cpi->Source = &cpi->scaled_source; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3143 seg->update_map = 1; | 3164 seg->update_map = 1; |
| 3144 seg->update_data = 1; | 3165 seg->update_data = 1; |
| 3145 } | 3166 } |
| 3146 | 3167 |
| 3147 // The alternate reference frame cannot be active for a key frame. | 3168 // The alternate reference frame cannot be active for a key frame. |
| 3148 cpi->rc.source_alt_ref_active = 0; | 3169 cpi->rc.source_alt_ref_active = 0; |
| 3149 | 3170 |
| 3150 cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0); | 3171 cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0); |
| 3151 cm->frame_parallel_decoding_mode = | 3172 cm->frame_parallel_decoding_mode = |
| 3152 (cpi->oxcf.frame_parallel_decoding_mode != 0); | 3173 (cpi->oxcf.frame_parallel_decoding_mode != 0); |
| 3174 |
| 3175 // By default, encoder assumes decoder can use prev_mi. |
| 3176 cm->coding_use_prev_mi = 1; |
| 3153 if (cm->error_resilient_mode) { | 3177 if (cm->error_resilient_mode) { |
| 3178 cm->coding_use_prev_mi = 0; |
| 3154 cm->frame_parallel_decoding_mode = 1; | 3179 cm->frame_parallel_decoding_mode = 1; |
| 3155 cm->reset_frame_context = 0; | 3180 cm->reset_frame_context = 0; |
| 3156 cm->refresh_frame_context = 0; | 3181 cm->refresh_frame_context = 0; |
| 3157 } else if (cm->intra_only) { | 3182 } else if (cm->intra_only) { |
| 3158 // Only reset the current context. | 3183 // Only reset the current context. |
| 3159 cm->reset_frame_context = 2; | 3184 cm->reset_frame_context = 2; |
| 3160 } | 3185 } |
| 3161 } | 3186 } |
| 3162 | 3187 |
| 3163 // Configure experimental use of segmentation for enhanced coding of | 3188 // Configure experimental use of segmentation for enhanced coding of |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3211 #ifdef OUTPUT_YUV_SRC | 3236 #ifdef OUTPUT_YUV_SRC |
| 3212 vp9_write_yuv_frame(cpi->Source); | 3237 vp9_write_yuv_frame(cpi->Source); |
| 3213 #endif | 3238 #endif |
| 3214 | 3239 |
| 3215 // Decide q and q bounds. | 3240 // Decide q and q bounds. |
| 3216 q = vp9_rc_pick_q_and_bounds(cpi, &bottom_index, &top_index); | 3241 q = vp9_rc_pick_q_and_bounds(cpi, &bottom_index, &top_index); |
| 3217 | 3242 |
| 3218 if (!frame_is_intra_only(cm)) { | 3243 if (!frame_is_intra_only(cm)) { |
| 3219 cm->interp_filter = DEFAULT_INTERP_FILTER; | 3244 cm->interp_filter = DEFAULT_INTERP_FILTER; |
| 3220 /* TODO: Decide this more intelligently */ | 3245 /* TODO: Decide this more intelligently */ |
| 3221 set_high_precision_mv(cpi, (q < HIGH_PRECISION_MV_QTHRESH)); | 3246 set_high_precision_mv(cpi, q < HIGH_PRECISION_MV_QTHRESH); |
| 3222 } | 3247 } |
| 3223 | 3248 |
| 3224 if (cpi->sf.recode_loop == DISALLOW_RECODE) { | 3249 if (cpi->sf.recode_loop == DISALLOW_RECODE) { |
| 3225 encode_without_recode_loop(cpi, size, dest, q); | 3250 encode_without_recode_loop(cpi, size, dest, q); |
| 3226 } else { | 3251 } else { |
| 3227 encode_with_recode_loop(cpi, size, dest, q, bottom_index, top_index); | 3252 encode_with_recode_loop(cpi, size, dest, q, bottom_index, top_index); |
| 3228 } | 3253 } |
| 3229 | 3254 |
| 3230 // Special case code to reduce pulsing when key frames are forced at a | 3255 // Special case code to reduce pulsing when key frames are forced at a |
| 3231 // fixed interval. Note the reconstruction error if it is the frame before | 3256 // fixed interval. Note the reconstruction error if it is the frame before |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3404 | 3429 |
| 3405 vp9_rc_get_second_pass_params(cpi); | 3430 vp9_rc_get_second_pass_params(cpi); |
| 3406 encode_frame_to_data_rate(cpi, size, dest, frame_flags); | 3431 encode_frame_to_data_rate(cpi, size, dest, frame_flags); |
| 3407 | 3432 |
| 3408 vp9_twopass_postencode_update(cpi, *size); | 3433 vp9_twopass_postencode_update(cpi, *size); |
| 3409 } | 3434 } |
| 3410 | 3435 |
| 3411 static void check_initial_width(VP9_COMP *cpi, int subsampling_x, | 3436 static void check_initial_width(VP9_COMP *cpi, int subsampling_x, |
| 3412 int subsampling_y) { | 3437 int subsampling_y) { |
| 3413 VP9_COMMON *const cm = &cpi->common; | 3438 VP9_COMMON *const cm = &cpi->common; |
| 3439 |
| 3414 if (!cpi->initial_width) { | 3440 if (!cpi->initial_width) { |
| 3415 cm->subsampling_x = subsampling_x; | 3441 cm->subsampling_x = subsampling_x; |
| 3416 cm->subsampling_y = subsampling_y; | 3442 cm->subsampling_y = subsampling_y; |
| 3417 alloc_raw_frame_buffers(cpi); | 3443 alloc_raw_frame_buffers(cpi); |
| 3418 cpi->initial_width = cm->width; | 3444 cpi->initial_width = cm->width; |
| 3419 cpi->initial_height = cm->height; | 3445 cpi->initial_height = cm->height; |
| 3420 } | 3446 } |
| 3421 } | 3447 } |
| 3422 | 3448 |
| 3423 | 3449 |
| 3424 int vp9_receive_raw_frame(VP9_PTR ptr, unsigned int frame_flags, | 3450 int vp9_receive_raw_frame(VP9_PTR ptr, unsigned int frame_flags, |
| 3425 YV12_BUFFER_CONFIG *sd, int64_t time_stamp, | 3451 YV12_BUFFER_CONFIG *sd, int64_t time_stamp, |
| 3426 int64_t end_time) { | 3452 int64_t end_time) { |
| 3427 VP9_COMP *cpi = (VP9_COMP *) ptr; | 3453 VP9_COMP *cpi = (VP9_COMP *)ptr; |
| 3428 VP9_COMMON *cm = &cpi->common; | 3454 VP9_COMMON *cm = &cpi->common; |
| 3429 struct vpx_usec_timer timer; | 3455 struct vpx_usec_timer timer; |
| 3430 int res = 0; | 3456 int res = 0; |
| 3431 const int subsampling_x = sd->uv_width < sd->y_width; | 3457 const int subsampling_x = sd->uv_width < sd->y_width; |
| 3432 const int subsampling_y = sd->uv_height < sd->y_height; | 3458 const int subsampling_y = sd->uv_height < sd->y_height; |
| 3433 | 3459 |
| 3434 check_initial_width(cpi, subsampling_x, subsampling_y); | 3460 check_initial_width(cpi, subsampling_x, subsampling_y); |
| 3435 vpx_usec_timer_start(&timer); | 3461 vpx_usec_timer_start(&timer); |
| 3436 if (vp9_lookahead_push(cpi->lookahead, sd, time_stamp, end_time, frame_flags, | 3462 if (vp9_lookahead_push(cpi->lookahead, |
| 3437 cpi->active_map_enabled ? cpi->active_map : NULL)) | 3463 sd, time_stamp, end_time, frame_flags)) |
| 3438 res = -1; | 3464 res = -1; |
| 3439 vpx_usec_timer_mark(&timer); | 3465 vpx_usec_timer_mark(&timer); |
| 3440 cpi->time_receive_data += vpx_usec_timer_elapsed(&timer); | 3466 cpi->time_receive_data += vpx_usec_timer_elapsed(&timer); |
| 3441 | 3467 |
| 3442 if (cm->version == 0 && (subsampling_x != 1 || subsampling_y != 1)) { | 3468 if (cm->version == 0 && (subsampling_x != 1 || subsampling_y != 1)) { |
| 3443 vpx_internal_error(&cm->error, VPX_CODEC_INVALID_PARAM, | 3469 vpx_internal_error(&cm->error, VPX_CODEC_INVALID_PARAM, |
| 3444 "Non-4:2:0 color space requires profile >= 1"); | 3470 "Non-4:2:0 color space requires profile >= 1"); |
| 3445 res = -1; | 3471 res = -1; |
| 3446 } | 3472 } |
| 3447 | 3473 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3555 cpi->alt_ref_source[cpi->arf_buffered] = cpi->source; | 3581 cpi->alt_ref_source[cpi->arf_buffered] = cpi->source; |
| 3556 #else | 3582 #else |
| 3557 cpi->alt_ref_source = cpi->source; | 3583 cpi->alt_ref_source = cpi->source; |
| 3558 #endif | 3584 #endif |
| 3559 | 3585 |
| 3560 if (cpi->oxcf.arnr_max_frames > 0) { | 3586 if (cpi->oxcf.arnr_max_frames > 0) { |
| 3561 // Produce the filtered ARF frame. | 3587 // Produce the filtered ARF frame. |
| 3562 // TODO(agrange) merge these two functions. | 3588 // TODO(agrange) merge these two functions. |
| 3563 vp9_configure_arnr_filter(cpi, frames_to_arf, cpi->rc.gfu_boost); | 3589 vp9_configure_arnr_filter(cpi, frames_to_arf, cpi->rc.gfu_boost); |
| 3564 vp9_temporal_filter_prepare(cpi, frames_to_arf); | 3590 vp9_temporal_filter_prepare(cpi, frames_to_arf); |
| 3565 vp9_extend_frame_borders(&cpi->alt_ref_buffer, | 3591 vp9_extend_frame_borders(&cpi->alt_ref_buffer); |
| 3566 cm->subsampling_x, cm->subsampling_y); | |
| 3567 force_src_buffer = &cpi->alt_ref_buffer; | 3592 force_src_buffer = &cpi->alt_ref_buffer; |
| 3568 } | 3593 } |
| 3569 | 3594 |
| 3570 cm->show_frame = 0; | 3595 cm->show_frame = 0; |
| 3571 cpi->refresh_alt_ref_frame = 1; | 3596 cpi->refresh_alt_ref_frame = 1; |
| 3572 cpi->refresh_golden_frame = 0; | 3597 cpi->refresh_golden_frame = 0; |
| 3573 cpi->refresh_last_frame = 0; | 3598 cpi->refresh_last_frame = 0; |
| 3574 cpi->rc.is_src_frame_alt_ref = 0; | 3599 cpi->rc.is_src_frame_alt_ref = 0; |
| 3575 | 3600 |
| 3576 #if CONFIG_MULTIPLE_ARF | 3601 #if CONFIG_MULTIPLE_ARF |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 if (cpi->svc.number_temporal_layers > 1 && | 3679 if (cpi->svc.number_temporal_layers > 1 && |
| 3655 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { | 3680 cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { |
| 3656 update_layer_framerate(cpi); | 3681 update_layer_framerate(cpi); |
| 3657 restore_layer_context(cpi); | 3682 restore_layer_context(cpi); |
| 3658 } | 3683 } |
| 3659 | 3684 |
| 3660 // start with a 0 size frame | 3685 // start with a 0 size frame |
| 3661 *size = 0; | 3686 *size = 0; |
| 3662 | 3687 |
| 3663 // Clear down mmx registers | 3688 // Clear down mmx registers |
| 3664 vp9_clear_system_state(); // __asm emms; | 3689 vp9_clear_system_state(); |
| 3665 | 3690 |
| 3666 /* find a free buffer for the new frame, releasing the reference previously | 3691 /* find a free buffer for the new frame, releasing the reference previously |
| 3667 * held. | 3692 * held. |
| 3668 */ | 3693 */ |
| 3669 cm->frame_bufs[cm->new_fb_idx].ref_count--; | 3694 cm->frame_bufs[cm->new_fb_idx].ref_count--; |
| 3670 cm->new_fb_idx = get_free_fb(cm); | 3695 cm->new_fb_idx = get_free_fb(cm); |
| 3671 | 3696 |
| 3672 #if CONFIG_MULTIPLE_ARF | 3697 #if CONFIG_MULTIPLE_ARF |
| 3673 /* Set up the correct ARF frame. */ | 3698 /* Set up the correct ARF frame. */ |
| 3674 if (cpi->refresh_alt_ref_frame) { | 3699 if (cpi->refresh_alt_ref_frame) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3692 const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]; | 3717 const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]; |
| 3693 YV12_BUFFER_CONFIG *const buf = &cm->frame_bufs[idx].buf; | 3718 YV12_BUFFER_CONFIG *const buf = &cm->frame_bufs[idx].buf; |
| 3694 RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - 1]; | 3719 RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - 1]; |
| 3695 ref_buf->buf = buf; | 3720 ref_buf->buf = buf; |
| 3696 ref_buf->idx = idx; | 3721 ref_buf->idx = idx; |
| 3697 vp9_setup_scale_factors_for_frame(&ref_buf->sf, | 3722 vp9_setup_scale_factors_for_frame(&ref_buf->sf, |
| 3698 buf->y_crop_width, buf->y_crop_height, | 3723 buf->y_crop_width, buf->y_crop_height, |
| 3699 cm->width, cm->height); | 3724 cm->width, cm->height); |
| 3700 | 3725 |
| 3701 if (vp9_is_scaled(&ref_buf->sf)) | 3726 if (vp9_is_scaled(&ref_buf->sf)) |
| 3702 vp9_extend_frame_borders(buf, cm->subsampling_x, cm->subsampling_y); | 3727 vp9_extend_frame_borders(buf); |
| 3703 } | 3728 } |
| 3704 | 3729 |
| 3705 set_ref_ptrs(cm, xd, LAST_FRAME, LAST_FRAME); | 3730 set_ref_ptrs(cm, xd, LAST_FRAME, LAST_FRAME); |
| 3706 xd->interp_kernel = vp9_get_interp_kernel( | 3731 xd->interp_kernel = vp9_get_interp_kernel( |
| 3707 DEFAULT_INTERP_FILTER == SWITCHABLE ? EIGHTTAP : DEFAULT_INTERP_FILTER); | 3732 DEFAULT_INTERP_FILTER == SWITCHABLE ? EIGHTTAP : DEFAULT_INTERP_FILTER); |
| 3708 | 3733 |
| 3709 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { | 3734 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 3710 vp9_vaq_init(); | 3735 vp9_vaq_init(); |
| 3711 } | 3736 } |
| 3712 | 3737 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3741 | 3766 |
| 3742 vpx_usec_timer_mark(&cmptimer); | 3767 vpx_usec_timer_mark(&cmptimer); |
| 3743 cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer); | 3768 cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer); |
| 3744 | 3769 |
| 3745 if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame) | 3770 if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame) |
| 3746 generate_psnr_packet(cpi); | 3771 generate_psnr_packet(cpi); |
| 3747 | 3772 |
| 3748 #if CONFIG_INTERNAL_STATS | 3773 #if CONFIG_INTERNAL_STATS |
| 3749 | 3774 |
| 3750 if (cpi->pass != 1) { | 3775 if (cpi->pass != 1) { |
| 3751 cpi->bytes += *size; | 3776 cpi->bytes += (int)(*size); |
| 3752 | 3777 |
| 3753 if (cm->show_frame) { | 3778 if (cm->show_frame) { |
| 3754 cpi->count++; | 3779 cpi->count++; |
| 3755 | 3780 |
| 3756 if (cpi->b_calculate_psnr) { | 3781 if (cpi->b_calculate_psnr) { |
| 3757 YV12_BUFFER_CONFIG *orig = cpi->Source; | 3782 YV12_BUFFER_CONFIG *orig = cpi->Source; |
| 3758 YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show; | 3783 YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show; |
| 3759 YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer; | 3784 YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer; |
| 3760 PSNR_STATS psnr; | 3785 PSNR_STATS psnr; |
| 3761 calc_psnr(orig, recon, &psnr); | 3786 calc_psnr(orig, recon, &psnr); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3816 } | 3841 } |
| 3817 } | 3842 } |
| 3818 } | 3843 } |
| 3819 | 3844 |
| 3820 #endif | 3845 #endif |
| 3821 return 0; | 3846 return 0; |
| 3822 } | 3847 } |
| 3823 | 3848 |
| 3824 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest, | 3849 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest, |
| 3825 vp9_ppflags_t *flags) { | 3850 vp9_ppflags_t *flags) { |
| 3826 VP9_COMP *cpi = (VP9_COMP *) comp; | 3851 VP9_COMP *cpi = (VP9_COMP *)comp; |
| 3852 VP9_COMMON *cm = &cpi->common; |
| 3827 | 3853 |
| 3828 if (!cpi->common.show_frame) { | 3854 if (!cm->show_frame) { |
| 3829 return -1; | 3855 return -1; |
| 3830 } else { | 3856 } else { |
| 3831 int ret; | 3857 int ret; |
| 3832 #if CONFIG_VP9_POSTPROC | 3858 #if CONFIG_VP9_POSTPROC |
| 3833 ret = vp9_post_proc_frame(&cpi->common, dest, flags); | 3859 ret = vp9_post_proc_frame(cm, dest, flags); |
| 3834 #else | 3860 #else |
| 3835 | 3861 |
| 3836 if (cpi->common.frame_to_show) { | 3862 if (cm->frame_to_show) { |
| 3837 *dest = *cpi->common.frame_to_show; | 3863 *dest = *cm->frame_to_show; |
| 3838 dest->y_width = cpi->common.width; | 3864 dest->y_width = cm->width; |
| 3839 dest->y_height = cpi->common.height; | 3865 dest->y_height = cm->height; |
| 3840 dest->uv_width = cpi->common.width >> cpi->common.subsampling_x; | 3866 dest->uv_width = cm->width >> cm->subsampling_x; |
| 3841 dest->uv_height = cpi->common.height >> cpi->common.subsampling_y; | 3867 dest->uv_height = cm->height >> cm->subsampling_y; |
| 3842 ret = 0; | 3868 ret = 0; |
| 3843 } else { | 3869 } else { |
| 3844 ret = -1; | 3870 ret = -1; |
| 3845 } | 3871 } |
| 3846 | 3872 |
| 3847 #endif // !CONFIG_VP9_POSTPROC | 3873 #endif // !CONFIG_VP9_POSTPROC |
| 3848 vp9_clear_system_state(); | 3874 vp9_clear_system_state(); |
| 3849 return ret; | 3875 return ret; |
| 3850 } | 3876 } |
| 3851 } | 3877 } |
| 3852 | 3878 |
| 3853 int vp9_set_roimap(VP9_PTR comp, unsigned char *map, unsigned int rows, | 3879 int vp9_set_roimap(VP9_PTR comp, unsigned char *map, unsigned int rows, |
| 3854 unsigned int cols, int delta_q[MAX_SEGMENTS], | 3880 unsigned int cols, int delta_q[MAX_SEGMENTS], |
| 3855 int delta_lf[MAX_SEGMENTS], | 3881 int delta_lf[MAX_SEGMENTS], |
| 3856 unsigned int threshold[MAX_SEGMENTS]) { | 3882 unsigned int threshold[MAX_SEGMENTS]) { |
| 3857 VP9_COMP *cpi = (VP9_COMP *) comp; | 3883 VP9_COMP *cpi = (VP9_COMP *) comp; |
| 3858 signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS]; | 3884 signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS]; |
| 3859 struct segmentation *seg = &cpi->common.seg; | 3885 struct segmentation *seg = &cpi->common.seg; |
| 3860 int i; | 3886 int i; |
| 3861 | 3887 |
| 3862 if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols) | 3888 if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols) |
| 3863 return -1; | 3889 return -1; |
| 3864 | 3890 |
| 3865 if (!map) { | 3891 if (!map) { |
| 3866 vp9_disable_segmentation((VP9_PTR)cpi); | 3892 vp9_disable_segmentation(seg); |
| 3867 return 0; | 3893 return 0; |
| 3868 } | 3894 } |
| 3869 | 3895 |
| 3870 // Set the segmentation Map | 3896 // Set the segmentation Map |
| 3871 vp9_set_segmentation_map((VP9_PTR)cpi, map); | 3897 vp9_set_segmentation_map(cpi, map); |
| 3872 | 3898 |
| 3873 // Activate segmentation. | 3899 // Activate segmentation. |
| 3874 vp9_enable_segmentation((VP9_PTR)cpi); | 3900 vp9_enable_segmentation(seg); |
| 3875 | 3901 |
| 3876 // Set up the quant, LF and breakout threshold segment data | 3902 // Set up the quant, LF and breakout threshold segment data |
| 3877 for (i = 0; i < MAX_SEGMENTS; i++) { | 3903 for (i = 0; i < MAX_SEGMENTS; i++) { |
| 3878 feature_data[SEG_LVL_ALT_Q][i] = delta_q[i]; | 3904 feature_data[SEG_LVL_ALT_Q][i] = delta_q[i]; |
| 3879 feature_data[SEG_LVL_ALT_LF][i] = delta_lf[i]; | 3905 feature_data[SEG_LVL_ALT_LF][i] = delta_lf[i]; |
| 3880 cpi->segment_encode_breakout[i] = threshold[i]; | 3906 cpi->segment_encode_breakout[i] = threshold[i]; |
| 3881 } | 3907 } |
| 3882 | 3908 |
| 3883 // Enable the loop and quant changes in the feature mask | 3909 // Enable the loop and quant changes in the feature mask |
| 3884 for (i = 0; i < MAX_SEGMENTS; i++) { | 3910 for (i = 0; i < MAX_SEGMENTS; i++) { |
| 3885 if (delta_q[i]) | 3911 if (delta_q[i]) |
| 3886 vp9_enable_segfeature(seg, i, SEG_LVL_ALT_Q); | 3912 vp9_enable_segfeature(seg, i, SEG_LVL_ALT_Q); |
| 3887 else | 3913 else |
| 3888 vp9_disable_segfeature(seg, i, SEG_LVL_ALT_Q); | 3914 vp9_disable_segfeature(seg, i, SEG_LVL_ALT_Q); |
| 3889 | 3915 |
| 3890 if (delta_lf[i]) | 3916 if (delta_lf[i]) |
| 3891 vp9_enable_segfeature(seg, i, SEG_LVL_ALT_LF); | 3917 vp9_enable_segfeature(seg, i, SEG_LVL_ALT_LF); |
| 3892 else | 3918 else |
| 3893 vp9_disable_segfeature(seg, i, SEG_LVL_ALT_LF); | 3919 vp9_disable_segfeature(seg, i, SEG_LVL_ALT_LF); |
| 3894 } | 3920 } |
| 3895 | 3921 |
| 3896 // Initialize the feature data structure | 3922 // Initialize the feature data structure |
| 3897 // SEGMENT_DELTADATA 0, SEGMENT_ABSDATA 1 | 3923 // SEGMENT_DELTADATA 0, SEGMENT_ABSDATA 1 |
| 3898 vp9_set_segment_data((VP9_PTR)cpi, &feature_data[0][0], SEGMENT_DELTADATA); | 3924 vp9_set_segment_data(seg, &feature_data[0][0], SEGMENT_DELTADATA); |
| 3899 | 3925 |
| 3900 return 0; | 3926 return 0; |
| 3901 } | 3927 } |
| 3902 | 3928 |
| 3903 int vp9_set_active_map(VP9_PTR comp, unsigned char *map, | 3929 int vp9_set_active_map(VP9_PTR comp, unsigned char *map, |
| 3904 unsigned int rows, unsigned int cols) { | 3930 unsigned int rows, unsigned int cols) { |
| 3905 VP9_COMP *cpi = (VP9_COMP *) comp; | 3931 VP9_COMP *cpi = (VP9_COMP *) comp; |
| 3906 | 3932 |
| 3907 if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols) { | 3933 if (rows == cpi->common.mb_rows && cols == cpi->common.mb_cols) { |
| 3908 if (map) { | 3934 if (map) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 ref += 16 * reference->y_stride; | 4031 ref += 16 * reference->y_stride; |
| 4006 } | 4032 } |
| 4007 | 4033 |
| 4008 return total; | 4034 return total; |
| 4009 } | 4035 } |
| 4010 | 4036 |
| 4011 | 4037 |
| 4012 int vp9_get_quantizer(VP9_PTR c) { | 4038 int vp9_get_quantizer(VP9_PTR c) { |
| 4013 return ((VP9_COMP *)c)->common.base_qindex; | 4039 return ((VP9_COMP *)c)->common.base_qindex; |
| 4014 } | 4040 } |
| OLD | NEW |