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

Unified 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: <WIP> 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 side-by-side diff with in-line comments
Download patch
« cc/video_layer_impl.cc ('K') | « cc/video_layer_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 3d764103f1965397fd1fff8c26d24f63df827609..fbd3f046f2adcec6e7e73518a481e51300737bf6 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -124,6 +124,7 @@ static const int kFrameSizeAlignment = 16;
static const int kFramePadBytes = 15;
void VideoFrame::AllocateRGB(size_t bytes_per_pixel) {
+ coded_size_.set_width(RoundUp(coded_size_.width(), 4));
sheu 2012/11/16 03:03:45 This is kinda hacky. I'm doing this basically bec
// Round up to align at least at a 16-byte boundary for each row.
// This is sufficient for MMX and SSE2 reads (movq/movdqa).
size_t bytes_per_row = RoundUp(coded_size_.width(),
@@ -144,19 +145,22 @@ void VideoFrame::AllocateRGB(size_t bytes_per_pixel) {
void VideoFrame::AllocateYUV() {
DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16);
- // Align Y rows at least at 16 byte boundaries. The stride for both
- // YV12 and YV16 is 1/2 of the stride of Y. For YV12, every row of bytes for
- // U and V applies to two rows of Y (one byte of UV for 4 bytes of Y), so in
- // the case of YV12 the strides are identical for the same width surface, but
- // the number of bytes allocated for YV12 is 1/2 the amount for U & V as
- // YV16. We also round the height of the surface allocated to be an even
- // number to avoid any potential of faulting by code that attempts to access
- // the Y values of the final row, but assumes that the last row of U & V
- // applies to a full two rows of Y.
+ coded_size_.set_width(RoundUp(coded_size_.width(), 4));
+ // Align Y rows at least at 32 byte boundaries, so the stride for both YV12
+ // and YV16 at 1/2 of the stride of Y is aligned to 16. For YV12, every row of
+ // bytes for U and V applies to two rows of Y (one byte of UV for 4 bytes of
+ // Y), so in the case of YV12 the strides are identical for the same width
+ // surface, but the number of bytes allocated for YV12 is 1/2 the amount for
+ // U & V as YV16. We also round the height of the surface allocated to be an
+ // even number to avoid any potential of faulting by code that attempts to
+ // access the Y values of the final row, but assumes that the last row of U &
+ // V applies to a full two rows of Y.
size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane),
- kFrameSizeAlignment);
- size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane),
- kFrameSizeAlignment);
+ kFrameSizeAlignment * 2);
+ // We keep the UV stride (and height below) proportional to the Y stride
+ // (and height), since we will be assuming an identical scale factor for
+ // stride (and height) for the Y and UV planes.
+ size_t uv_stride = y_stride / 2;
// The *2 here is because some formats (e.g. h264) allow interlaced coding,
// and then the size needs to be a multiple of two macroblocks (vertically).
// See libavcodec/utils.c:avcodec_align_dimensions2().
« 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