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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" | 26 #include "vp9/encoder/vp9_aq_cyclicrefresh.h" |
27 #include "vp9/encoder/vp9_context_tree.h" | 27 #include "vp9/encoder/vp9_context_tree.h" |
28 #include "vp9/encoder/vp9_encodemb.h" | 28 #include "vp9/encoder/vp9_encodemb.h" |
29 #include "vp9/encoder/vp9_firstpass.h" | 29 #include "vp9/encoder/vp9_firstpass.h" |
30 #include "vp9/encoder/vp9_lookahead.h" | 30 #include "vp9/encoder/vp9_lookahead.h" |
31 #include "vp9/encoder/vp9_mbgraph.h" | 31 #include "vp9/encoder/vp9_mbgraph.h" |
32 #include "vp9/encoder/vp9_mcomp.h" | 32 #include "vp9/encoder/vp9_mcomp.h" |
33 #include "vp9/encoder/vp9_quantize.h" | 33 #include "vp9/encoder/vp9_quantize.h" |
34 #include "vp9/encoder/vp9_ratectrl.h" | 34 #include "vp9/encoder/vp9_ratectrl.h" |
35 #include "vp9/encoder/vp9_rdopt.h" | 35 #include "vp9/encoder/vp9_rd.h" |
36 #include "vp9/encoder/vp9_speed_features.h" | 36 #include "vp9/encoder/vp9_speed_features.h" |
37 #include "vp9/encoder/vp9_svc_layercontext.h" | 37 #include "vp9/encoder/vp9_svc_layercontext.h" |
38 #include "vp9/encoder/vp9_tokenize.h" | 38 #include "vp9/encoder/vp9_tokenize.h" |
39 #include "vp9/encoder/vp9_variance.h" | 39 #include "vp9/encoder/vp9_variance.h" |
40 #if CONFIG_DENOISING | 40 #if CONFIG_DENOISING |
41 #include "vp9/encoder/vp9_denoiser.h" | 41 #include "vp9/encoder/vp9_denoiser.h" |
42 #endif | 42 #endif |
43 | 43 |
44 #ifdef __cplusplus | 44 #ifdef __cplusplus |
45 extern "C" { | 45 extern "C" { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 return mode == ONE_PASS_BEST || mode == TWO_PASS_SECOND_BEST; | 241 return mode == ONE_PASS_BEST || mode == TWO_PASS_SECOND_BEST; |
242 } | 242 } |
243 | 243 |
244 typedef struct VP9_COMP { | 244 typedef struct VP9_COMP { |
245 QUANTS quants; | 245 QUANTS quants; |
246 MACROBLOCK mb; | 246 MACROBLOCK mb; |
247 VP9_COMMON common; | 247 VP9_COMMON common; |
248 VP9EncoderConfig oxcf; | 248 VP9EncoderConfig oxcf; |
249 struct lookahead_ctx *lookahead; | 249 struct lookahead_ctx *lookahead; |
250 struct lookahead_entry *source; | 250 struct lookahead_entry *source; |
251 #if CONFIG_MULTIPLE_ARF | |
252 struct lookahead_entry *alt_ref_source[REF_FRAMES]; | |
253 #else | |
254 struct lookahead_entry *alt_ref_source; | 251 struct lookahead_entry *alt_ref_source; |
255 #endif | |
256 struct lookahead_entry *last_source; | 252 struct lookahead_entry *last_source; |
257 | 253 |
258 YV12_BUFFER_CONFIG *Source; | 254 YV12_BUFFER_CONFIG *Source; |
259 YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames | 255 YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames |
260 YV12_BUFFER_CONFIG *un_scaled_source; | 256 YV12_BUFFER_CONFIG *un_scaled_source; |
261 YV12_BUFFER_CONFIG scaled_source; | 257 YV12_BUFFER_CONFIG scaled_source; |
262 YV12_BUFFER_CONFIG *unscaled_last_source; | 258 YV12_BUFFER_CONFIG *unscaled_last_source; |
263 YV12_BUFFER_CONFIG scaled_last_source; | 259 YV12_BUFFER_CONFIG scaled_last_source; |
264 | 260 |
265 int gold_is_last; // gold same as last frame ( short circuit gold searches) | 261 int gold_is_last; // gold same as last frame ( short circuit gold searches) |
266 int alt_is_last; // Alt same as last ( short circuit altref search) | 262 int alt_is_last; // Alt same as last ( short circuit altref search) |
267 int gold_is_alt; // don't do both alt and gold search ( just do gold). | 263 int gold_is_alt; // don't do both alt and gold search ( just do gold). |
268 | 264 |
| 265 int skippable_frame; |
| 266 |
269 int scaled_ref_idx[3]; | 267 int scaled_ref_idx[3]; |
270 int lst_fb_idx; | 268 int lst_fb_idx; |
271 int gld_fb_idx; | 269 int gld_fb_idx; |
272 int alt_fb_idx; | 270 int alt_fb_idx; |
273 | 271 |
274 #if CONFIG_MULTIPLE_ARF | |
275 int alt_ref_fb_idx[REF_FRAMES - 3]; | |
276 #endif | |
277 int refresh_last_frame; | 272 int refresh_last_frame; |
278 int refresh_golden_frame; | 273 int refresh_golden_frame; |
279 int refresh_alt_ref_frame; | 274 int refresh_alt_ref_frame; |
280 | 275 |
281 int ext_refresh_frame_flags_pending; | 276 int ext_refresh_frame_flags_pending; |
282 int ext_refresh_last_frame; | 277 int ext_refresh_last_frame; |
283 int ext_refresh_golden_frame; | 278 int ext_refresh_golden_frame; |
284 int ext_refresh_alt_ref_frame; | 279 int ext_refresh_alt_ref_frame; |
285 | 280 |
286 int ext_refresh_frame_context_pending; | 281 int ext_refresh_frame_context_pending; |
287 int ext_refresh_frame_context; | 282 int ext_refresh_frame_context; |
288 | 283 |
289 YV12_BUFFER_CONFIG last_frame_uf; | 284 YV12_BUFFER_CONFIG last_frame_uf; |
290 | 285 |
291 TOKENEXTRA *tok; | 286 TOKENEXTRA *tok; |
292 unsigned int tok_count[4][1 << 6]; | 287 unsigned int tok_count[4][1 << 6]; |
293 | 288 |
294 #if CONFIG_MULTIPLE_ARF | |
295 // Position within a frame coding order (including any additional ARF frames). | |
296 unsigned int sequence_number; | |
297 // Next frame in naturally occurring order that has not yet been coded. | |
298 int next_frame_in_order; | |
299 #endif | |
300 | |
301 // Ambient reconstruction err target for force key frames | 289 // Ambient reconstruction err target for force key frames |
302 int ambient_err; | 290 int ambient_err; |
303 | 291 |
304 RD_OPT rd; | 292 RD_OPT rd; |
305 | 293 |
306 CODING_CONTEXT coding_context; | 294 CODING_CONTEXT coding_context; |
307 | 295 |
308 int zbin_mode_boost; | 296 int zbin_mode_boost; |
309 int zbin_mode_boost_enabled; | 297 int zbin_mode_boost_enabled; |
310 int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames | 298 int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames |
(...skipping 29 matching lines...) Expand all Loading... |
340 // clips, and 300 for < HD clips. | 328 // clips, and 300 for < HD clips. |
341 int encode_breakout; | 329 int encode_breakout; |
342 | 330 |
343 unsigned char *segmentation_map; | 331 unsigned char *segmentation_map; |
344 | 332 |
345 // segment threashold for encode breakout | 333 // segment threashold for encode breakout |
346 int segment_encode_breakout[MAX_SEGMENTS]; | 334 int segment_encode_breakout[MAX_SEGMENTS]; |
347 | 335 |
348 unsigned char *complexity_map; | 336 unsigned char *complexity_map; |
349 | 337 |
350 unsigned char *active_map; | |
351 unsigned int active_map_enabled; | |
352 | |
353 CYCLIC_REFRESH *cyclic_refresh; | 338 CYCLIC_REFRESH *cyclic_refresh; |
354 | 339 |
355 fractional_mv_step_fp *find_fractional_mv_step; | 340 fractional_mv_step_fp *find_fractional_mv_step; |
356 fractional_mv_step_comp_fp *find_fractional_mv_step_comp; | 341 fractional_mv_step_comp_fp *find_fractional_mv_step_comp; |
357 vp9_full_search_fn_t full_search_sad; | 342 vp9_full_search_fn_t full_search_sad; |
358 vp9_refining_search_fn_t refining_search_sad; | 343 vp9_refining_search_fn_t refining_search_sad; |
359 vp9_diamond_search_fn_t diamond_search_sad; | 344 vp9_diamond_search_fn_t diamond_search_sad; |
360 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES]; | 345 vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES]; |
361 uint64_t time_receive_data; | 346 uint64_t time_receive_data; |
362 uint64_t time_compress_data; | 347 uint64_t time_compress_data; |
363 uint64_t time_pick_lpf; | 348 uint64_t time_pick_lpf; |
364 uint64_t time_encode_sb_row; | 349 uint64_t time_encode_sb_row; |
365 | 350 |
| 351 #if CONFIG_FP_MB_STATS |
| 352 int use_fp_mb_stats; |
| 353 #endif |
| 354 |
366 TWO_PASS twopass; | 355 TWO_PASS twopass; |
367 | 356 |
368 YV12_BUFFER_CONFIG alt_ref_buffer; | 357 YV12_BUFFER_CONFIG alt_ref_buffer; |
369 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; | 358 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; |
370 | 359 |
371 #if CONFIG_INTERNAL_STATS | 360 #if CONFIG_INTERNAL_STATS |
372 unsigned int mode_chosen_counts[MAX_MODES]; | 361 unsigned int mode_chosen_counts[MAX_MODES]; |
373 | 362 |
374 int count; | 363 int count; |
375 double total_y; | 364 double total_y; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 398 |
410 unsigned int tx_stepdown_count[TX_SIZES]; | 399 unsigned int tx_stepdown_count[TX_SIZES]; |
411 | 400 |
412 int initial_width; | 401 int initial_width; |
413 int initial_height; | 402 int initial_height; |
414 | 403 |
415 int use_svc; | 404 int use_svc; |
416 | 405 |
417 SVC svc; | 406 SVC svc; |
418 | 407 |
419 int use_large_partition_rate; | 408 // Store frame variance info in SOURCE_VAR_BASED_PARTITION search type. |
| 409 diff *source_diff_var; |
| 410 // The threshold used in SOURCE_VAR_BASED_PARTITION search type. |
| 411 unsigned int source_var_thresh; |
| 412 int frames_till_next_var_check; |
420 | 413 |
421 int frame_flags; | 414 int frame_flags; |
422 | 415 |
423 search_site_config ss_cfg; | 416 search_site_config ss_cfg; |
424 | 417 |
425 int mbmode_cost[INTRA_MODES]; | 418 int mbmode_cost[INTRA_MODES]; |
426 unsigned inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES]; | 419 unsigned inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES]; |
427 int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES]; | 420 int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES]; |
428 int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; | 421 int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; |
429 int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; | 422 int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; |
430 | 423 |
431 PICK_MODE_CONTEXT *leaf_tree; | 424 PICK_MODE_CONTEXT *leaf_tree; |
432 PC_TREE *pc_tree; | 425 PC_TREE *pc_tree; |
433 PC_TREE *pc_root; | 426 PC_TREE *pc_root; |
434 int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES]; | 427 int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES]; |
435 | 428 |
436 #if CONFIG_MULTIPLE_ARF | 429 int multi_arf_allowed; |
437 // ARF tracking variables. | |
438 int multi_arf_enabled; | 430 int multi_arf_enabled; |
439 unsigned int frame_coding_order_period; | 431 int multi_arf_last_grp_enabled; |
440 unsigned int new_frame_coding_order_period; | |
441 int frame_coding_order[MAX_LAG_BUFFERS * 2]; | |
442 int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2]; | |
443 int arf_weight[MAX_LAG_BUFFERS]; | |
444 int arf_buffered; | |
445 int this_frame_weight; | |
446 int max_arf_level; | |
447 #endif | |
448 | 432 |
449 #if CONFIG_DENOISING | 433 #if CONFIG_DENOISING |
450 VP9_DENOISER denoiser; | 434 VP9_DENOISER denoiser; |
451 #endif | 435 #endif |
452 } VP9_COMP; | 436 } VP9_COMP; |
453 | 437 |
454 void vp9_initialize_enc(); | 438 void vp9_initialize_enc(); |
455 | 439 |
456 struct VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf); | 440 struct VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf); |
457 void vp9_remove_compressor(VP9_COMP *cpi); | 441 void vp9_remove_compressor(VP9_COMP *cpi); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 int vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); | 521 int vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
538 | 522 |
539 void vp9_alloc_compressor_data(VP9_COMP *cpi); | 523 void vp9_alloc_compressor_data(VP9_COMP *cpi); |
540 | 524 |
541 void vp9_scale_references(VP9_COMP *cpi); | 525 void vp9_scale_references(VP9_COMP *cpi); |
542 | 526 |
543 void vp9_update_reference_frames(VP9_COMP *cpi); | 527 void vp9_update_reference_frames(VP9_COMP *cpi); |
544 | 528 |
545 int64_t vp9_rescale(int64_t val, int64_t num, int denom); | 529 int64_t vp9_rescale(int64_t val, int64_t num, int denom); |
546 | 530 |
| 531 void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv); |
| 532 |
547 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, | 533 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, |
548 YV12_BUFFER_CONFIG *unscaled, | 534 YV12_BUFFER_CONFIG *unscaled, |
549 YV12_BUFFER_CONFIG *scaled); | 535 YV12_BUFFER_CONFIG *scaled); |
550 | 536 |
| 537 void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags); |
| 538 |
551 static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, | 539 static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, |
552 MV_REFERENCE_FRAME ref0, | 540 MV_REFERENCE_FRAME ref0, |
553 MV_REFERENCE_FRAME ref1) { | 541 MV_REFERENCE_FRAME ref1) { |
554 xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME | 542 xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME |
555 : 0]; | 543 : 0]; |
556 xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME | 544 xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME |
557 : 0]; | 545 : 0]; |
558 } | 546 } |
559 | 547 |
560 static INLINE int get_chessboard_index(const VP9_COMMON *cm) { | 548 static INLINE int get_chessboard_index(const VP9_COMMON *cm) { |
561 return cm->current_video_frame % 2; | 549 return cm->current_video_frame % 2; |
562 } | 550 } |
563 | 551 |
564 #ifdef __cplusplus | 552 #ifdef __cplusplus |
565 } // extern "C" | 553 } // extern "C" |
566 #endif | 554 #endif |
567 | 555 |
568 #endif // VP9_ENCODER_VP9_ENCODER_H_ | 556 #endif // VP9_ENCODER_VP9_ENCODER_H_ |
OLD | NEW |