Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: media/base/yuv_convert.cc

Issue 1468803002: Switch to static_assert. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@assert1
Patch Set: message cleanup Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_parameters.h ('k') | mojo/converters/ime/ime_type_converters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « media/audio/audio_parameters.h ('k') | mojo/converters/ime/ime_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698