OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 29 matching lines...) Expand all Loading... |
40 vp9_clearall_segfeatures(seg); | 40 vp9_clearall_segfeatures(seg); |
41 | 41 |
42 // Select delta coding method. | 42 // Select delta coding method. |
43 seg->abs_delta = SEGMENT_DELTADATA; | 43 seg->abs_delta = SEGMENT_DELTADATA; |
44 | 44 |
45 // Segment 0 "Q" feature is disabled so it defaults to the baseline Q. | 45 // Segment 0 "Q" feature is disabled so it defaults to the baseline Q. |
46 vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); | 46 vp9_disable_segfeature(seg, 0, SEG_LVL_ALT_Q); |
47 | 47 |
48 // Use some of the segments for in frame Q adjustment. | 48 // Use some of the segments for in frame Q adjustment. |
49 for (segment = 1; segment < 2; segment++) { | 49 for (segment = 1; segment < 2; segment++) { |
50 const int qindex_delta = | 50 int qindex_delta = |
51 vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex, | 51 vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex, |
52 in_frame_q_adj_ratio[segment]); | 52 in_frame_q_adj_ratio[segment]); |
53 vp9_enable_segfeature(seg, segment, SEG_LVL_ALT_Q); | 53 |
54 vp9_set_segdata(seg, segment, SEG_LVL_ALT_Q, qindex_delta); | 54 // For AQ mode 2, we dont allow Q0 in a segment if the base Q is not 0. |
| 55 // Q0 (lossless) implies 4x4 only and in AQ mode 2 a segment Q delta |
| 56 // is sometimes applied without going back around the rd loop. |
| 57 // This could lead to an illegal combination of partition size and q. |
| 58 if ((cm->base_qindex != 0) && ((cm->base_qindex + qindex_delta) == 0)) { |
| 59 qindex_delta = -cm->base_qindex + 1; |
| 60 } |
| 61 if ((cm->base_qindex + qindex_delta) > 0) { |
| 62 vp9_enable_segfeature(seg, segment, SEG_LVL_ALT_Q); |
| 63 vp9_set_segdata(seg, segment, SEG_LVL_ALT_Q, qindex_delta); |
| 64 } |
55 } | 65 } |
56 } | 66 } |
57 } | 67 } |
58 | 68 |
59 // Select a segment for the current SB64 | 69 // Select a segment for the current SB64 |
60 void vp9_select_in_frame_q_segment(VP9_COMP *cpi, | 70 void vp9_select_in_frame_q_segment(VP9_COMP *cpi, |
61 int mi_row, int mi_col, | 71 int mi_row, int mi_col, |
62 int output_enabled, int projected_rate) { | 72 int output_enabled, int projected_rate) { |
63 VP9_COMMON *const cm = &cpi->common; | 73 VP9_COMMON *const cm = &cpi->common; |
64 | 74 |
(...skipping 29 matching lines...) Expand all Loading... |
94 | 104 |
95 // Fill in the entires in the segment map corresponding to this SB64. | 105 // Fill in the entires in the segment map corresponding to this SB64. |
96 for (y = 0; y < ymis; y++) { | 106 for (y = 0; y < ymis; y++) { |
97 for (x = 0; x < xmis; x++) { | 107 for (x = 0; x < xmis; x++) { |
98 cpi->segmentation_map[mi_offset + y * cm->mi_cols + x] = segment; | 108 cpi->segmentation_map[mi_offset + y * cm->mi_cols + x] = segment; |
99 cpi->complexity_map[mi_offset + y * cm->mi_cols + x] = | 109 cpi->complexity_map[mi_offset + y * cm->mi_cols + x] = |
100 (unsigned char)complexity_metric; | 110 (unsigned char)complexity_metric; |
101 } | 111 } |
102 } | 112 } |
103 } | 113 } |
OLD | NEW |