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

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

Issue 11413005: YUV software decode path stride fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
« cc/video_layer_impl.cc ('K') | « cc/video_layer_impl.cc ('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 // 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 #include "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_piece.h" 8 #include "base/string_piece.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/video_util.h" 10 #include "media/base/video_util.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 av_malloc(bytes_per_row * aligned_height + kFramePadBytes)); 137 av_malloc(bytes_per_row * aligned_height + kFramePadBytes));
138 #else 138 #else
139 data_[VideoFrame::kRGBPlane] = new uint8_t[bytes_per_row * aligned_height]; 139 data_[VideoFrame::kRGBPlane] = new uint8_t[bytes_per_row * aligned_height];
140 #endif 140 #endif
141 DCHECK(!(reinterpret_cast<intptr_t>(data_[VideoFrame::kRGBPlane]) & 7)); 141 DCHECK(!(reinterpret_cast<intptr_t>(data_[VideoFrame::kRGBPlane]) & 7));
142 COMPILE_ASSERT(0 == VideoFrame::kRGBPlane, RGB_data_must_be_index_0); 142 COMPILE_ASSERT(0 == VideoFrame::kRGBPlane, RGB_data_must_be_index_0);
143 } 143 }
144 144
145 void VideoFrame::AllocateYUV() { 145 void VideoFrame::AllocateYUV() {
146 DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16); 146 DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16);
147 // Align Y rows at least at 16 byte boundaries. The stride for both 147 // Align Y rows at least at 32 byte boundaries, so the stride for both YV12
148 // YV12 and YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for 148 // and YV16 at 1/2 of the stride of Y is aligned to 16. For YV12, every row of
149 // U and V applies to two rows of Y (one byte of UV for 4 bytes of Y), so in 149 // bytes for U and V applies to two rows of Y (one byte of UV for 4 bytes of
150 // the case of YV12 the strides are identical for the same width surface, but 150 // Y), so in the case of YV12 the strides are identical for the same width
151 // the number of bytes allocated for YV12 is 1/2 the amount for U & V as 151 // surface, but the number of bytes allocated for YV12 is 1/2 the amount for
152 // YV16. We also round the height of the surface allocated to be an even 152 // U & V as YV16. We also round the height of the surface allocated to be an
153 // number to avoid any potential of faulting by code that attempts to access 153 // even number to avoid any potential of faulting by code that attempts to
154 // the Y values of the final row, but assumes that the last row of U & V 154 // access the Y values of the final row, but assumes that the last row of U &
155 // applies to a full two rows of Y. 155 // V applies to a full two rows of Y.
156 size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane), 156 size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane),
157 kFrameSizeAlignment); 157 kFrameSizeAlignment * 2);
158 size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), 158 size_t uv_stride = y_stride / 2;
Ami GONE FROM CHROMIUM 2012/11/15 18:15:36 I don't understand the impetus for this change. Wh
sheu 2012/11/15 19:46:38 When we're doing GL rendering of the uploaded text
Ami GONE FROM CHROMIUM 2012/11/15 20:39:09 It seems strange that an impl detail of cc::VideoL
sheu 2012/11/15 22:20:53 I guess that would have been a better way to put t
Ami GONE FROM CHROMIUM 2012/11/15 23:11:15 That seems wrong. stride can differ per-plane, an
sheu 2012/11/16 03:00:10 Right, and I'm making sure that the planes have th
159 kFrameSizeAlignment);
160 // The *2 here is because some formats (e.g. h264) allow interlaced coding, 159 // The *2 here is because some formats (e.g. h264) allow interlaced coding,
161 // and then the size needs to be a multiple of two macroblocks (vertically). 160 // and then the size needs to be a multiple of two macroblocks (vertically).
162 // See libavcodec/utils.c:avcodec_align_dimensions2(). 161 // See libavcodec/utils.c:avcodec_align_dimensions2().
163 size_t y_height = RoundUp(coded_size_.height(), kFrameSizeAlignment * 2); 162 size_t y_height = RoundUp(coded_size_.height(), kFrameSizeAlignment * 2);
164 size_t uv_height = format_ == VideoFrame::YV12 ? y_height / 2 : y_height; 163 size_t uv_height = format_ == VideoFrame::YV12 ? y_height / 2 : y_height;
165 size_t y_bytes = y_height * y_stride; 164 size_t y_bytes = y_height * y_stride;
166 size_t uv_bytes = uv_height * uv_stride; 165 size_t uv_bytes = uv_height * uv_stride;
167 166
168 #if !defined(OS_ANDROID) 167 #if !defined(OS_ANDROID)
169 // TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery 168 // TODO(dalecurtis): use DataAligned or so, so this #ifdef hackery
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 break; 317 break;
319 for(int row = 0; row < rows(plane); row++) { 318 for(int row = 0; row < rows(plane); row++) {
320 base::MD5Update(context, base::StringPiece( 319 base::MD5Update(context, base::StringPiece(
321 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 320 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
322 row_bytes(plane))); 321 row_bytes(plane)));
323 } 322 }
324 } 323 }
325 } 324 }
326 325
327 } // namespace media 326 } // namespace media
OLDNEW
« cc/video_layer_impl.cc ('K') | « cc/video_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698