OLD | NEW |
1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
9 // | 9 // |
10 // Token probabilities | 10 // Coding of token probabilities, intra modes and segments. |
11 // | 11 // |
12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
13 | 13 |
14 #include "./vp8enci.h" | 14 #include "./vp8enci.h" |
15 | 15 |
16 #if defined(__cplusplus) || defined(c_plusplus) | |
17 extern "C" { | |
18 #endif | |
19 | |
20 //------------------------------------------------------------------------------ | 16 //------------------------------------------------------------------------------ |
21 // Default probabilities | 17 // Default probabilities |
22 | 18 |
23 // Paragraph 13.5 | 19 // Paragraph 13.5 |
24 const uint8_t | 20 const uint8_t |
25 VP8CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = { | 21 VP8CoeffsProba0[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = { |
26 // genereated using vp8_default_coef_probs() in entropy.c:129 | |
27 { { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, | 22 { { { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, |
28 { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, | 23 { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, |
29 { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } | 24 { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 } |
30 }, | 25 }, |
31 { { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 }, | 26 { { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 }, |
32 { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 }, | 27 { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 }, |
33 { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 } | 28 { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 } |
34 }, | 29 }, |
35 { { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 }, | 30 { { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 }, |
36 { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 }, | 31 { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 }, |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 static void PutSegment(VP8BitWriter* const bw, int s, const uint8_t* p) { | 308 static void PutSegment(VP8BitWriter* const bw, int s, const uint8_t* p) { |
314 if (VP8PutBit(bw, s >= 2, p[0])) p += 1; | 309 if (VP8PutBit(bw, s >= 2, p[0])) p += 1; |
315 VP8PutBit(bw, s & 1, p[1]); | 310 VP8PutBit(bw, s & 1, p[1]); |
316 } | 311 } |
317 | 312 |
318 void VP8CodeIntraModes(VP8Encoder* const enc) { | 313 void VP8CodeIntraModes(VP8Encoder* const enc) { |
319 VP8BitWriter* const bw = &enc->bw_; | 314 VP8BitWriter* const bw = &enc->bw_; |
320 VP8EncIterator it; | 315 VP8EncIterator it; |
321 VP8IteratorInit(enc, &it); | 316 VP8IteratorInit(enc, &it); |
322 do { | 317 do { |
323 const VP8MBInfo* mb = it.mb_; | 318 const VP8MBInfo* const mb = it.mb_; |
324 const uint8_t* preds = it.preds_; | 319 const uint8_t* preds = it.preds_; |
325 if (enc->segment_hdr_.update_map_) { | 320 if (enc->segment_hdr_.update_map_) { |
326 PutSegment(bw, mb->segment_, enc->proba_.segments_); | 321 PutSegment(bw, mb->segment_, enc->proba_.segments_); |
327 } | 322 } |
328 if (enc->proba_.use_skip_proba_) { | 323 if (enc->proba_.use_skip_proba_) { |
329 VP8PutBit(bw, mb->skip_, enc->proba_.skip_proba_); | 324 VP8PutBit(bw, mb->skip_, enc->proba_.skip_proba_); |
330 } | 325 } |
331 if (VP8PutBit(bw, (mb->type_ != 0), 145)) { // i16x16 | 326 if (VP8PutBit(bw, (mb->type_ != 0), 145)) { // i16x16 |
332 PutI16Mode(bw, preds[0]); | 327 PutI16Mode(bw, preds[0]); |
333 } else { | 328 } else { |
334 const int preds_w = enc->preds_w_; | 329 const int preds_w = enc->preds_w_; |
335 const uint8_t* top_pred = preds - preds_w; | 330 const uint8_t* top_pred = preds - preds_w; |
336 int x, y; | 331 int x, y; |
337 for (y = 0; y < 4; ++y) { | 332 for (y = 0; y < 4; ++y) { |
338 int left = preds[-1]; | 333 int left = preds[-1]; |
339 for (x = 0; x < 4; ++x) { | 334 for (x = 0; x < 4; ++x) { |
340 const uint8_t* const probas = kBModesProba[top_pred[x]][left]; | 335 const uint8_t* const probas = kBModesProba[top_pred[x]][left]; |
341 left = PutI4Mode(bw, preds[x], probas); | 336 left = PutI4Mode(bw, preds[x], probas); |
342 } | 337 } |
343 top_pred = preds; | 338 top_pred = preds; |
344 preds += preds_w; | 339 preds += preds_w; |
345 } | 340 } |
346 } | 341 } |
347 PutUVMode(bw, mb->uv_mode_); | 342 PutUVMode(bw, mb->uv_mode_); |
348 } while (VP8IteratorNext(&it, 0)); | 343 } while (VP8IteratorNext(&it)); |
349 } | 344 } |
350 | 345 |
351 //------------------------------------------------------------------------------ | 346 //------------------------------------------------------------------------------ |
352 // Paragraph 13 | 347 // Paragraph 13 |
353 | 348 |
354 const uint8_t | 349 const uint8_t |
355 VP8CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = { | 350 VP8CoeffsUpdateProba[NUM_TYPES][NUM_BANDS][NUM_CTX][NUM_PROBAS] = { |
356 { { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, | 351 { { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, |
357 { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, | 352 { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, |
358 { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } | 353 { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 495 } |
501 } | 496 } |
502 } | 497 } |
503 } | 498 } |
504 } | 499 } |
505 if (VP8PutBitUniform(bw, probas->use_skip_proba_)) { | 500 if (VP8PutBitUniform(bw, probas->use_skip_proba_)) { |
506 VP8PutValue(bw, probas->skip_proba_, 8); | 501 VP8PutValue(bw, probas->skip_proba_, 8); |
507 } | 502 } |
508 } | 503 } |
509 | 504 |
510 #if defined(__cplusplus) || defined(c_plusplus) | |
511 } // extern "C" | |
512 #endif | |
OLD | NEW |