| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } ENCODE_BREAKOUT_TYPE; | 75 } ENCODE_BREAKOUT_TYPE; |
| 76 | 76 |
| 77 typedef enum { | 77 typedef enum { |
| 78 NORMAL = 0, | 78 NORMAL = 0, |
| 79 FOURFIVE = 1, | 79 FOURFIVE = 1, |
| 80 THREEFIVE = 2, | 80 THREEFIVE = 2, |
| 81 ONETWO = 3 | 81 ONETWO = 3 |
| 82 } VPX_SCALING; | 82 } VPX_SCALING; |
| 83 | 83 |
| 84 typedef enum { | 84 typedef enum { |
| 85 // Good Quality Fast Encoding. The encoder balances quality with the | 85 // Good Quality Fast Encoding. The encoder balances quality with the amount of |
| 86 // amount of time it takes to encode the output. (speed setting | 86 // time it takes to encode the output. Speed setting controls how fast. |
| 87 // controls how fast) | 87 GOOD, |
| 88 ONE_PASS_GOOD = 1, | |
| 89 | 88 |
| 90 // One Pass - Best Quality. The encoder places priority on the | 89 // The encoder places priority on the quality of the output over encoding |
| 91 // quality of the output over encoding speed. The output is compressed | 90 // speed. The output is compressed at the highest possible quality. This |
| 92 // at the highest possible quality. This option takes the longest | 91 // option takes the longest amount of time to encode. Speed setting ignored. |
| 93 // amount of time to encode. (speed setting ignored) | 92 BEST, |
| 94 ONE_PASS_BEST = 2, | |
| 95 | 93 |
| 96 // Two Pass - First Pass. The encoder generates a file of statistics | 94 // Realtime/Live Encoding. This mode is optimized for realtime encoding (for |
| 97 // for use in the second encoding pass. (speed setting controls how fast) | 95 // example, capturing a television signal or feed from a live camera). Speed |
| 98 TWO_PASS_FIRST = 3, | 96 // setting controls how fast. |
| 99 | 97 REALTIME |
| 100 // Two Pass - Second Pass. The encoder uses the statistics that were | |
| 101 // generated in the first encoding pass to create the compressed | |
| 102 // output. (speed setting controls how fast) | |
| 103 TWO_PASS_SECOND_GOOD = 4, | |
| 104 | |
| 105 // Two Pass - Second Pass Best. The encoder uses the statistics that | |
| 106 // were generated in the first encoding pass to create the compressed | |
| 107 // output using the highest possible quality, and taking a | |
| 108 // longer amount of time to encode. (speed setting ignored) | |
| 109 TWO_PASS_SECOND_BEST = 5, | |
| 110 | |
| 111 // Realtime/Live Encoding. This mode is optimized for realtime | |
| 112 // encoding (for example, capturing a television signal or feed from | |
| 113 // a live camera). (speed setting controls how fast) | |
| 114 REALTIME = 6, | |
| 115 } MODE; | 98 } MODE; |
| 116 | 99 |
| 117 typedef enum { | 100 typedef enum { |
| 118 FRAMEFLAGS_KEY = 1 << 0, | 101 FRAMEFLAGS_KEY = 1 << 0, |
| 119 FRAMEFLAGS_GOLDEN = 1 << 1, | 102 FRAMEFLAGS_GOLDEN = 1 << 1, |
| 120 FRAMEFLAGS_ALTREF = 1 << 2, | 103 FRAMEFLAGS_ALTREF = 1 << 2, |
| 121 } FRAMETYPE_FLAGS; | 104 } FRAMETYPE_FLAGS; |
| 122 | 105 |
| 123 typedef enum { | 106 typedef enum { |
| 124 NO_AQ = 0, | 107 NO_AQ = 0, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 217 |
| 235 vp8e_tuning tuning; | 218 vp8e_tuning tuning; |
| 236 vp9e_tune_content content; | 219 vp9e_tune_content content; |
| 237 } VP9EncoderConfig; | 220 } VP9EncoderConfig; |
| 238 | 221 |
| 239 static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) { | 222 static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) { |
| 240 return cfg->best_allowed_q == 0 && cfg->worst_allowed_q == 0; | 223 return cfg->best_allowed_q == 0 && cfg->worst_allowed_q == 0; |
| 241 } | 224 } |
| 242 | 225 |
| 243 static INLINE int is_best_mode(MODE mode) { | 226 static INLINE int is_best_mode(MODE mode) { |
| 244 return mode == ONE_PASS_BEST || mode == TWO_PASS_SECOND_BEST; | 227 return mode == BEST; |
| 245 } | 228 } |
| 246 | 229 |
| 247 typedef struct VP9_COMP { | 230 typedef struct VP9_COMP { |
| 248 QUANTS quants; | 231 QUANTS quants; |
| 249 MACROBLOCK mb; | 232 MACROBLOCK mb; |
| 250 VP9_COMMON common; | 233 VP9_COMMON common; |
| 251 VP9EncoderConfig oxcf; | 234 VP9EncoderConfig oxcf; |
| 252 struct lookahead_ctx *lookahead; | 235 struct lookahead_ctx *lookahead; |
| 253 struct lookahead_entry *source; | 236 struct lookahead_entry *source; |
| 254 struct lookahead_entry *alt_ref_source; | 237 struct lookahead_entry *alt_ref_source; |
| 255 struct lookahead_entry *last_source; | 238 struct lookahead_entry *last_source; |
| 256 | 239 |
| 257 YV12_BUFFER_CONFIG *Source; | 240 YV12_BUFFER_CONFIG *Source; |
| 258 YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames | 241 YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames |
| 259 YV12_BUFFER_CONFIG *un_scaled_source; | 242 YV12_BUFFER_CONFIG *un_scaled_source; |
| 260 YV12_BUFFER_CONFIG scaled_source; | 243 YV12_BUFFER_CONFIG scaled_source; |
| 261 YV12_BUFFER_CONFIG *unscaled_last_source; | 244 YV12_BUFFER_CONFIG *unscaled_last_source; |
| 262 YV12_BUFFER_CONFIG scaled_last_source; | 245 YV12_BUFFER_CONFIG scaled_last_source; |
| 263 | 246 |
| 264 int gold_is_last; // gold same as last frame ( short circuit gold searches) | |
| 265 int alt_is_last; // Alt same as last ( short circuit altref search) | |
| 266 int gold_is_alt; // don't do both alt and gold search ( just do gold). | |
| 267 | |
| 268 int skippable_frame; | 247 int skippable_frame; |
| 269 | 248 |
| 270 int scaled_ref_idx[3]; | 249 int scaled_ref_idx[3]; |
| 271 int lst_fb_idx; | 250 int lst_fb_idx; |
| 272 int gld_fb_idx; | 251 int gld_fb_idx; |
| 273 int alt_fb_idx; | 252 int alt_fb_idx; |
| 274 | 253 |
| 275 int refresh_last_frame; | 254 int refresh_last_frame; |
| 276 int refresh_golden_frame; | 255 int refresh_golden_frame; |
| 277 int refresh_alt_ref_frame; | 256 int refresh_alt_ref_frame; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 467 } |
| 489 } | 468 } |
| 490 | 469 |
| 491 static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer( | 470 static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer( |
| 492 VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) { | 471 VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) { |
| 493 VP9_COMMON * const cm = &cpi->common; | 472 VP9_COMMON * const cm = &cpi->common; |
| 494 return &cm->frame_bufs[cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]] | 473 return &cm->frame_bufs[cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]] |
| 495 .buf; | 474 .buf; |
| 496 } | 475 } |
| 497 | 476 |
| 498 // Intra only frames, golden frames (except alt ref overlays) and | |
| 499 // alt ref frames tend to be coded at a higher than ambient quality | |
| 500 static INLINE int frame_is_boosted(const VP9_COMP *cpi) { | |
| 501 return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame || | |
| 502 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref) || | |
| 503 vp9_is_upper_layer_key_frame(cpi); | |
| 504 } | |
| 505 | |
| 506 static INLINE int get_token_alloc(int mb_rows, int mb_cols) { | 477 static INLINE int get_token_alloc(int mb_rows, int mb_cols) { |
| 507 // TODO(JBB): double check we can't exceed this token count if we have a | 478 // TODO(JBB): double check we can't exceed this token count if we have a |
| 508 // 32x32 transform crossing a boundary at a multiple of 16. | 479 // 32x32 transform crossing a boundary at a multiple of 16. |
| 509 // mb_rows, cols are in units of 16 pixels. We assume 3 planes all at full | 480 // mb_rows, cols are in units of 16 pixels. We assume 3 planes all at full |
| 510 // resolution. We assume up to 1 token per pixel, and then allow | 481 // resolution. We assume up to 1 token per pixel, and then allow |
| 511 // a head room of 4. | 482 // a head room of 4. |
| 512 return mb_rows * mb_cols * (16 * 16 * 3 + 4); | 483 return mb_rows * mb_cols * (16 * 16 * 3 + 4); |
| 513 } | 484 } |
| 514 | 485 |
| 515 int vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); | 486 int vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
| 516 | 487 |
| 517 void vp9_alloc_compressor_data(VP9_COMP *cpi); | 488 void vp9_alloc_compressor_data(VP9_COMP *cpi); |
| 518 | 489 |
| 519 void vp9_scale_references(VP9_COMP *cpi); | 490 void vp9_scale_references(VP9_COMP *cpi); |
| 520 | 491 |
| 521 void vp9_update_reference_frames(VP9_COMP *cpi); | 492 void vp9_update_reference_frames(VP9_COMP *cpi); |
| 522 | 493 |
| 523 int64_t vp9_rescale(int64_t val, int64_t num, int denom); | |
| 524 | |
| 525 void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv); | 494 void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv); |
| 526 | 495 |
| 527 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, | 496 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm, |
| 528 YV12_BUFFER_CONFIG *unscaled, | 497 YV12_BUFFER_CONFIG *unscaled, |
| 529 YV12_BUFFER_CONFIG *scaled); | 498 YV12_BUFFER_CONFIG *scaled); |
| 530 | 499 |
| 531 void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags); | 500 void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags); |
| 532 | 501 |
| 533 static INLINE int is_spatial_svc(const struct VP9_COMP *const cpi) { | 502 static INLINE int is_spatial_svc(const struct VP9_COMP *const cpi) { |
| 534 return cpi->use_svc && | 503 return cpi->use_svc && |
| (...skipping 19 matching lines...) Expand all Loading... |
| 554 | 523 |
| 555 static INLINE int get_chessboard_index(const int frame_index) { | 524 static INLINE int get_chessboard_index(const int frame_index) { |
| 556 return frame_index & 0x1; | 525 return frame_index & 0x1; |
| 557 } | 526 } |
| 558 | 527 |
| 559 #ifdef __cplusplus | 528 #ifdef __cplusplus |
| 560 } // extern "C" | 529 } // extern "C" |
| 561 #endif | 530 #endif |
| 562 | 531 |
| 563 #endif // VP9_ENCODER_VP9_ENCODER_H_ | 532 #endif // VP9_ENCODER_VP9_ENCODER_H_ |
| OLD | NEW |