OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This webpage shows layout of YV12 and other YUV formats | 5 // This webpage shows layout of YV12 and other YUV formats |
6 // http://www.fourcc.org/yuv.php | 6 // http://www.fourcc.org/yuv.php |
7 // The actual conversion is best described here | 7 // The actual conversion is best described here |
8 // http://en.wikipedia.org/wiki/YUV | 8 // http://en.wikipedia.org/wiki/YUV |
9 // An article on optimizing YUV conversion using tables instead of multiplies | 9 // An article on optimizing YUV conversion using tables instead of multiplies |
10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf | 10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const int kNumTables = 4; | 178 const int kNumTables = 4; |
179 // Each table has 256 rows (for all possible 8-bit values). | 179 // Each table has 256 rows (for all possible 8-bit values). |
180 const int kNumRows = 256; | 180 const int kNumRows = 256; |
181 // Each row has 4 columns, for contributions to each of R, G, B and A. | 181 // Each row has 4 columns, for contributions to each of R, G, B and A. |
182 const int kNumColumns = 4; | 182 const int kNumColumns = 4; |
183 // Each element is a fixed-point (10.6) 16-bit signed value. | 183 // Each element is a fixed-point (10.6) 16-bit signed value. |
184 const int kElementSize = sizeof(int16); | 184 const int kElementSize = sizeof(int16); |
185 | 185 |
186 // Sanity check that our constants here match the size of the statically | 186 // Sanity check that our constants here match the size of the statically |
187 // allocated tables. | 187 // allocated tables. |
188 COMPILE_ASSERT( | 188 static_assert( |
189 kNumTables * kNumRows * kNumColumns * kElementSize == kYUVToRGBTableSize, | 189 kNumTables * kNumRows * kNumColumns * kElementSize == kYUVToRGBTableSize, |
190 "YUV lookup table size doesn't match expectation."); | 190 "YUV lookup table size doesn't match expectation."); |
191 | 191 |
192 // Y needs an offset of -16 for color ranges that ignore the lower 16 values, | 192 // Y needs an offset of -16 for color ranges that ignore the lower 16 values, |
193 // U and V get -128 to put them in [-128, 127] from [0, 255]. | 193 // U and V get -128 to put them in [-128, 127] from [0, 255]. |
194 int offsets[3] = {(full_range ? 0 : -16), -128, -128}; | 194 int offsets[3] = {(full_range ? 0 : -16), -128, -128}; |
195 | 195 |
196 for (int i = 0; i < kNumRows; ++i) { | 196 for (int i = 0; i < kNumRows; ++i) { |
197 // Y, U, and V contributions to each of R, G, B and A. | 197 // Y, U, and V contributions to each of R, G, B and A. |
198 for (int j = 0; j < 3; ++j) { | 198 for (int j = 0; j < 3; ++j) { |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 width, | 737 width, |
738 height, | 738 height, |
739 ystride, | 739 ystride, |
740 uvstride, | 740 uvstride, |
741 astride, | 741 astride, |
742 rgbstride, | 742 rgbstride, |
743 yuv_type); | 743 yuv_type); |
744 } | 744 } |
745 | 745 |
746 } // namespace media | 746 } // namespace media |
OLD | NEW |