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

Side by Side Diff: source/convert_from.cc

Issue 2554213003: ConvertFromI420: use halfstride instead of halfwidth (Closed)
Patch Set: i422 and i444 as well Created 4 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 | « include/libyuv/version.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2012 The LibYuv 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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 case FOURCC_NV21: { 1087 case FOURCC_NV21: {
1088 uint8* dst_vu = dst_sample + width * height; 1088 uint8* dst_vu = dst_sample + width * height;
1089 r = I420ToNV21(y, y_stride, u, u_stride, v, v_stride, dst_sample, 1089 r = I420ToNV21(y, y_stride, u, u_stride, v, v_stride, dst_sample,
1090 dst_sample_stride ? dst_sample_stride : width, dst_vu, 1090 dst_sample_stride ? dst_sample_stride : width, dst_vu,
1091 dst_sample_stride ? dst_sample_stride : width, width, 1091 dst_sample_stride ? dst_sample_stride : width, width,
1092 height); 1092 height);
1093 break; 1093 break;
1094 } 1094 }
1095 // TODO(fbarchard): Add M420. 1095 // TODO(fbarchard): Add M420.
1096 // Triplanar formats 1096 // Triplanar formats
1097 // TODO(fbarchard): halfstride instead of halfwidth
1098 case FOURCC_I420: 1097 case FOURCC_I420:
1099 case FOURCC_YV12: { 1098 case FOURCC_YV12: {
1100 int halfwidth = (width + 1) / 2; 1099 dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
1100 int halfstride = (dst_sample_stride + 1) / 2;
1101 int halfheight = (height + 1) / 2; 1101 int halfheight = (height + 1) / 2;
1102 uint8* dst_u; 1102 uint8* dst_u;
1103 uint8* dst_v; 1103 uint8* dst_v;
1104 if (format == FOURCC_YV12) { 1104 if (format == FOURCC_YV12) {
1105 dst_v = dst_sample + width * height; 1105 dst_v = dst_sample + dst_sample_stride * height;
1106 dst_u = dst_v + halfwidth * halfheight; 1106 dst_u = dst_v + halfstride * halfheight;
1107 } else { 1107 } else {
1108 dst_u = dst_sample + width * height; 1108 dst_u = dst_sample + dst_sample_stride * height;
1109 dst_v = dst_u + halfwidth * halfheight; 1109 dst_v = dst_u + halfstride * halfheight;
1110 } 1110 }
1111 r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, 1111 r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample,
1112 dst_u, halfwidth, dst_v, halfwidth, width, height); 1112 dst_sample_stride, dst_u, halfstride, dst_v, halfstride,
1113 width, height);
1113 break; 1114 break;
1114 } 1115 }
1115 case FOURCC_I422: 1116 case FOURCC_I422:
1116 case FOURCC_YV16: { 1117 case FOURCC_YV16: {
1117 int halfwidth = (width + 1) / 2; 1118 dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
1119 int halfstride = (dst_sample_stride + 1) / 2;
1118 uint8* dst_u; 1120 uint8* dst_u;
1119 uint8* dst_v; 1121 uint8* dst_v;
1120 if (format == FOURCC_YV16) { 1122 if (format == FOURCC_YV16) {
1121 dst_v = dst_sample + width * height; 1123 dst_v = dst_sample + dst_sample_stride * height;
1122 dst_u = dst_v + halfwidth * height; 1124 dst_u = dst_v + halfstride * height;
1123 } else { 1125 } else {
1124 dst_u = dst_sample + width * height; 1126 dst_u = dst_sample + dst_sample_stride * height;
1125 dst_v = dst_u + halfwidth * height; 1127 dst_v = dst_u + halfstride * height;
1126 } 1128 }
1127 r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, 1129 r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample,
1128 dst_u, halfwidth, dst_v, halfwidth, width, height); 1130 dst_sample_stride, dst_u, halfstride, dst_v, halfstride,
1131 width, height);
1129 break; 1132 break;
1130 } 1133 }
1131 case FOURCC_I444: 1134 case FOURCC_I444:
1132 case FOURCC_YV24: { 1135 case FOURCC_YV24: {
1136 dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
1133 uint8* dst_u; 1137 uint8* dst_u;
1134 uint8* dst_v; 1138 uint8* dst_v;
1135 if (format == FOURCC_YV24) { 1139 if (format == FOURCC_YV24) {
1136 dst_v = dst_sample + width * height; 1140 dst_v = dst_sample + dst_sample_stride * height;
1137 dst_u = dst_v + width * height; 1141 dst_u = dst_v + dst_sample_stride * height;
1138 } else { 1142 } else {
1139 dst_u = dst_sample + width * height; 1143 dst_u = dst_sample + dst_sample_stride * height;
1140 dst_v = dst_u + width * height; 1144 dst_v = dst_u + dst_sample_stride * height;
1141 } 1145 }
1142 r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, 1146 r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample,
1143 dst_u, width, dst_v, width, width, height); 1147 dst_sample_stride, dst_u, dst_sample_stride, dst_v,
1148 dst_sample_stride, width, height);
1144 break; 1149 break;
1145 } 1150 }
1146 // Formats not supported - MJPG, biplanar, some rgb formats. 1151 // Formats not supported - MJPG, biplanar, some rgb formats.
1147 default: 1152 default:
1148 return -1; // unknown fourcc - return failure code. 1153 return -1; // unknown fourcc - return failure code.
1149 } 1154 }
1150 return r; 1155 return r;
1151 } 1156 }
1152 1157
1153 #ifdef __cplusplus 1158 #ifdef __cplusplus
1154 } // extern "C" 1159 } // extern "C"
1155 } // namespace libyuv 1160 } // namespace libyuv
1156 #endif 1161 #endif
OLDNEW
« no previous file with comments | « include/libyuv/version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698