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

Unified Diff: media/base/video_frame.cc

Issue 8052002: Fix support for yuv_422 pixel format. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed existing unit tests. Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_decoder_config.cc ('k') | media/ffmpeg/ffmpeg_common.h » ('j') | 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 c40c58f000f38861bb00695c7d59cb58fba0c597..340ba190568f6f277b0fd61354001f1bad8f656c 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -75,9 +75,12 @@ scoped_refptr<VideoFrame> VideoFrame::CreateBlackFrame(int width, int height) {
// Fill the U and V planes.
uint8* u_plane = frame->data(VideoFrame::kUPlane);
uint8* v_plane = frame->data(VideoFrame::kVPlane);
- for (size_t i = 0; i < (frame->height_ / 2); ++i) {
- memset(u_plane, kBlackUV, frame->width_ / 2);
- memset(v_plane, kBlackUV, frame->width_ / 2);
+ int uv_rows = frame->rows(VideoFrame::kUPlane);
+ int u_row_bytes = frame->row_bytes(VideoFrame::kUPlane);
+ int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane);
+ for (size_t i = 0; i < (size_t)uv_rows; ++i) {
+ memset(u_plane, kBlackUV, u_row_bytes);
+ memset(v_plane, kBlackUV, v_row_bytes);
u_plane += frame->stride(VideoFrame::kUPlane);
v_plane += frame->stride(VideoFrame::kVPlane);
}
@@ -115,21 +118,20 @@ void VideoFrame::AllocateYUV() {
// 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 alloc_height = RoundUp(height_, 2);
- size_t y_bytes_per_row = RoundUp(width_, 4);
- size_t uv_stride = RoundUp(y_bytes_per_row / 2, 4);
- size_t y_bytes = alloc_height * y_bytes_per_row;
- size_t uv_bytes = alloc_height * uv_stride;
- if (format_ == VideoFrame::YV12) {
- uv_bytes /= 2;
- }
+ size_t y_height = RoundUp(rows(VideoFrame::kYPlane), 2);
+ size_t y_stride = RoundUp(row_bytes(VideoFrame::kYPlane), 4);
+ size_t uv_stride = RoundUp(row_bytes(VideoFrame::kUPlane), 4);
+ size_t uv_height = RoundUp(rows(VideoFrame::kUPlane), 2);
+ size_t y_bytes = y_height * y_stride;
+ size_t uv_bytes = uv_height * uv_stride;
+
uint8* data = new uint8[y_bytes + (uv_bytes * 2) + kFramePadBytes];
planes_ = VideoFrame::kNumYUVPlanes;
COMPILE_ASSERT(0 == VideoFrame::kYPlane, y_plane_data_must_be_index_0);
data_[VideoFrame::kYPlane] = data;
data_[VideoFrame::kUPlane] = data + y_bytes;
data_[VideoFrame::kVPlane] = data + y_bytes + uv_bytes;
- strides_[VideoFrame::kYPlane] = y_bytes_per_row;
fbarchard 2011/10/05 01:38:46 FYI I'd suggest using 'stride' terminology consist
+ strides_[VideoFrame::kYPlane] = y_stride;
strides_[VideoFrame::kUPlane] = uv_stride;
strides_[VideoFrame::kVPlane] = uv_stride;
}
« no previous file with comments | « media/base/video_decoder_config.cc ('k') | media/ffmpeg/ffmpeg_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698