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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 328 } |
329 int source_top = dest_rect_top * y_step; | 329 int source_top = dest_rect_top * y_step; |
330 if (y_step < kFractionMax * 2) { | 330 if (y_step < kFractionMax * 2) { |
331 source_top += ((y_step - kFractionMax) / 2); | 331 source_top += ((y_step - kFractionMax) / 2); |
332 } else { | 332 } else { |
333 source_top += kFractionMax / 2; | 333 source_top += kFractionMax / 2; |
334 } | 334 } |
335 | 335 |
336 // Determine the parts of the Y, U and V buffers to interpolate. | 336 // Determine the parts of the Y, U and V buffers to interpolate. |
337 int source_y_left = source_left >> kFractionBits; | 337 int source_y_left = source_left >> kFractionBits; |
338 int source_y_right = (source_right >> kFractionBits) + 2; | 338 int source_y_right = std::min( |
339 DCHECK(source_y_right <= source_width); | 339 (source_right >> kFractionBits) + 2, |
| 340 source_width + 1); |
340 | 341 |
341 int source_uv_left = source_y_left / 2; | 342 int source_uv_left = source_y_left / 2; |
342 int source_uv_right = std::min( | 343 int source_uv_right = std::min( |
343 (source_right >> (kFractionBits + 1)) + 2, | 344 (source_right >> (kFractionBits + 1)) + 2, |
344 (source_width + 1) / 2); | 345 (source_width + 1) / 2); |
345 | 346 |
346 int source_y_width = source_y_right - source_y_left; | 347 int source_y_width = source_y_right - source_y_left; |
347 int source_uv_width = source_uv_right - source_uv_left; | 348 int source_uv_width = source_uv_right - source_uv_left; |
348 | 349 |
349 // Determine number of pixels in each output row. | 350 // Determine number of pixels in each output row. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 else | 535 else |
535 convert_proc = &ConvertYUVToRGB32_C; | 536 convert_proc = &ConvertYUVToRGB32_C; |
536 } | 537 } |
537 | 538 |
538 convert_proc(yplane, uplane, vplane, rgbframe, | 539 convert_proc(yplane, uplane, vplane, rgbframe, |
539 width, height, ystride, uvstride, rgbstride, yuv_type); | 540 width, height, ystride, uvstride, rgbstride, yuv_type); |
540 #endif | 541 #endif |
541 } | 542 } |
542 | 543 |
543 } // namespace media | 544 } // namespace media |
OLD | NEW |