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

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

Issue 7519024: Fix possible typos in RGB->YUV conversion (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/yuv_convert_unittest.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "media/base/yuv_convert.h" 5 #include "media/base/yuv_convert.h"
6 #include "media/base/yuv_convert_internal.h" 6 #include "media/base/yuv_convert_internal.h"
7 7
8 namespace media { 8 namespace media {
9 9
10 static int clip_byte(int x) { 10 static int clip_byte(int x) {
(...skipping 17 matching lines...) Expand all
28 for (int i = 0; i < height; ++i) { 28 for (int i = 0; i < height; ++i) {
29 for (int j = 0; j < width; ++j) { 29 for (int j = 0; j < width; ++j) {
30 // Since the input pixel format is RGB32, there are 4 bytes per pixel. 30 // Since the input pixel format is RGB32, there are 4 bytes per pixel.
31 const uint8* pixel = rgbframe + 4 * j; 31 const uint8* pixel = rgbframe + 4 * j;
32 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + 32 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 +
33 pixel[0] * 25 + 128) >> 8) + 16); 33 pixel[0] * 25 + 128) >> 8) + 16);
34 if (i % 2 == 0 && j % 2 == 0) { 34 if (i % 2 == 0 && j % 2 == 0) {
35 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + 35 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 +
36 pixel[0] * 112 + 128) >> 8) + 128); 36 pixel[0] * 112 + 128) >> 8) + 128);
37 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + 37 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 +
38 pixel[1] * -18 + 128) >> 8) + 128); 38 pixel[0] * -18 + 128) >> 8) + 128);
39 } 39 }
40 } 40 }
41 41
42 rgbframe += rgbstride; 42 rgbframe += rgbstride;
43 yplane += ystride; 43 yplane += ystride;
44 if (i % 2 == 0) { 44 if (i % 2 == 0) {
45 uplane += uvstride; 45 uplane += uvstride;
46 vplane += uvstride; 46 vplane += uvstride;
47 } 47 }
48 } 48 }
(...skipping 11 matching lines...) Expand all
60 for (int i = 0; i < height; ++i) { 60 for (int i = 0; i < height; ++i) {
61 for (int j = 0; j < width; ++j) { 61 for (int j = 0; j < width; ++j) {
62 // Since the input pixel format is RGB24, there are 3 bytes per pixel. 62 // Since the input pixel format is RGB24, there are 3 bytes per pixel.
63 const uint8* pixel = rgbframe + 3 * j; 63 const uint8* pixel = rgbframe + 3 * j;
64 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + 64 yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 +
65 pixel[0] * 25 + 128) >> 8) + 16); 65 pixel[0] * 25 + 128) >> 8) + 16);
66 if (i % 2 == 0 && j % 2 == 0) { 66 if (i % 2 == 0 && j % 2 == 0) {
67 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + 67 uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 +
68 pixel[0] * 112 + 128) >> 8) + 128); 68 pixel[0] * 112 + 128) >> 8) + 128);
69 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + 69 vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 +
70 pixel[1] * -18 + 128) >> 8) + 128); 70 pixel[0] * -18 + 128) >> 8) + 128);
71 } 71 }
72 } 72 }
73 73
74 rgbframe += rgbstride; 74 rgbframe += rgbstride;
75 yplane += ystride; 75 yplane += ystride;
76 if (i % 2 == 0) { 76 if (i % 2 == 0) {
77 uplane += uvstride; 77 uplane += uvstride;
78 vplane += uvstride; 78 vplane += uvstride;
79 } 79 }
80 } 80 }
(...skipping 19 matching lines...) Expand all
100 for (int j = 0; j < (width / 2); ++j) { 100 for (int j = 0; j < (width / 2); ++j) {
101 yplane[0] = src[0]; 101 yplane[0] = src[0];
102 yplane[1] = src[2]; 102 yplane[1] = src[2];
103 src += 4; 103 src += 4;
104 yplane += 2; 104 yplane += 2;
105 } 105 }
106 } 106 }
107 } 107 }
108 108
109 } // namespace media 109 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/yuv_convert_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698