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

Side by Side Diff: media/filters/skcanvas_video_renderer.cc

Issue 242643011: Add correct support for videos with YUVJ420P color format, in the software conversion path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@yuvnopic
Patch Set: Created 6 years, 8 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
« media/base/yuv_convert.h ('K') | « media/base/yuv_convert_unittest.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/filters/skcanvas_video_renderer.h" 5 #include "media/filters/skcanvas_video_renderer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/video_frame.h" 8 #include "media/base/video_frame.h"
9 #include "media/base/yuv_convert.h" 9 #include "media/base/yuv_convert.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 media::YUVType yuv_type = media::YV16; 81 media::YUVType yuv_type = media::YV16;
82 int y_shift = 0; 82 int y_shift = 0;
83 if (video_frame->format() == media::VideoFrame::YV12 || 83 if (video_frame->format() == media::VideoFrame::YV12 ||
84 video_frame->format() == media::VideoFrame::I420 || 84 video_frame->format() == media::VideoFrame::I420 ||
85 video_frame->format() == media::VideoFrame::YV12A) { 85 video_frame->format() == media::VideoFrame::YV12A) {
86 yuv_type = media::YV12; 86 yuv_type = media::YV12;
87 y_shift = 1; 87 y_shift = 1;
88 } 88 }
89 89
90 if (video_frame->format() == media::VideoFrame::YV12J) { 90 if (video_frame->format() == media::VideoFrame::YV12J) {
91 yuv_type = media::YV12; 91 yuv_type = media::YV12J;
92 y_shift = 1; 92 y_shift = 1;
93 } 93 }
94 94
95 // Transform the destination rectangle to local coordinates. 95 // Transform the destination rectangle to local coordinates.
96 const SkMatrix& local_matrix = canvas->getTotalMatrix(); 96 const SkMatrix& local_matrix = canvas->getTotalMatrix();
97 SkRect local_dest_rect; 97 SkRect local_dest_rect;
98 local_matrix.mapRect(&local_dest_rect, dest_rect); 98 local_matrix.mapRect(&local_dest_rect, dest_rect);
99 99
100 // After projecting the destination rectangle to local coordinates, round 100 // After projecting the destination rectangle to local coordinates, round
101 // the projected rectangle to integer values, this will give us pixel values 101 // the projected rectangle to integer values, this will give us pixel values
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // For format YV12, there is one U, V value per 2x2 block. 222 // For format YV12, there is one U, V value per 2x2 block.
223 // For format YV16, there is one U, V value per 2x1 block. 223 // For format YV16, there is one U, V value per 2x1 block.
224 uv_offset = (video_frame->stride(media::VideoFrame::kUPlane) * 224 uv_offset = (video_frame->stride(media::VideoFrame::kUPlane) *
225 (video_frame->visible_rect().y() >> y_shift)) + 225 (video_frame->visible_rect().y() >> y_shift)) +
226 (video_frame->visible_rect().x() >> 1); 226 (video_frame->visible_rect().x() >> 1);
227 } 227 }
228 228
229 switch (video_frame->format()) { 229 switch (video_frame->format()) {
230 case media::VideoFrame::YV12: 230 case media::VideoFrame::YV12:
231 case media::VideoFrame::I420: 231 case media::VideoFrame::I420:
232 case media::VideoFrame::YV12J:
233 media::ConvertYUVToRGB32( 232 media::ConvertYUVToRGB32(
234 video_frame->data(media::VideoFrame::kYPlane) + y_offset, 233 video_frame->data(media::VideoFrame::kYPlane) + y_offset,
235 video_frame->data(media::VideoFrame::kUPlane) + uv_offset, 234 video_frame->data(media::VideoFrame::kUPlane) + uv_offset,
236 video_frame->data(media::VideoFrame::kVPlane) + uv_offset, 235 video_frame->data(media::VideoFrame::kVPlane) + uv_offset,
237 static_cast<uint8*>(bitmap->getPixels()), 236 static_cast<uint8*>(bitmap->getPixels()),
238 video_frame->visible_rect().width(), 237 video_frame->visible_rect().width(),
239 video_frame->visible_rect().height(), 238 video_frame->visible_rect().height(),
240 video_frame->stride(media::VideoFrame::kYPlane), 239 video_frame->stride(media::VideoFrame::kYPlane),
241 video_frame->stride(media::VideoFrame::kUPlane), 240 video_frame->stride(media::VideoFrame::kUPlane),
242 bitmap->rowBytes(), 241 bitmap->rowBytes(),
243 media::YV12); 242 media::YV12);
244 break; 243 break;
245 244
245 case media::VideoFrame::YV12J:
246 media::ConvertYUVToRGB32(
247 video_frame->data(media::VideoFrame::kYPlane) + y_offset,
248 video_frame->data(media::VideoFrame::kUPlane) + uv_offset,
249 video_frame->data(media::VideoFrame::kVPlane) + uv_offset,
250 static_cast<uint8*>(bitmap->getPixels()),
251 video_frame->visible_rect().width(),
252 video_frame->visible_rect().height(),
253 video_frame->stride(media::VideoFrame::kYPlane),
254 video_frame->stride(media::VideoFrame::kUPlane),
255 bitmap->rowBytes(),
256 media::YV12J);
257 break;
258
246 case media::VideoFrame::YV16: 259 case media::VideoFrame::YV16:
247 media::ConvertYUVToRGB32( 260 media::ConvertYUVToRGB32(
248 video_frame->data(media::VideoFrame::kYPlane) + y_offset, 261 video_frame->data(media::VideoFrame::kYPlane) + y_offset,
249 video_frame->data(media::VideoFrame::kUPlane) + uv_offset, 262 video_frame->data(media::VideoFrame::kUPlane) + uv_offset,
250 video_frame->data(media::VideoFrame::kVPlane) + uv_offset, 263 video_frame->data(media::VideoFrame::kVPlane) + uv_offset,
251 static_cast<uint8*>(bitmap->getPixels()), 264 static_cast<uint8*>(bitmap->getPixels()),
252 video_frame->visible_rect().width(), 265 video_frame->visible_rect().width(),
253 video_frame->visible_rect().height(), 266 video_frame->visible_rect().height(),
254 video_frame->stride(media::VideoFrame::kYPlane), 267 video_frame->stride(media::VideoFrame::kYPlane),
255 video_frame->stride(media::VideoFrame::kUPlane), 268 video_frame->stride(media::VideoFrame::kUPlane),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 ConvertVideoFrameToBitmap(video_frame, &last_frame_); 338 ConvertVideoFrameToBitmap(video_frame, &last_frame_);
326 last_frame_timestamp_ = video_frame->timestamp(); 339 last_frame_timestamp_ = video_frame->timestamp();
327 } 340 }
328 341
329 // Do a slower paint using |last_frame_|. 342 // Do a slower paint using |last_frame_|.
330 paint.setFilterBitmap(true); 343 paint.setFilterBitmap(true);
331 canvas->drawBitmapRect(last_frame_, NULL, dest, &paint); 344 canvas->drawBitmapRect(last_frame_, NULL, dest, &paint);
332 } 345 }
333 346
334 } // namespace media 347 } // namespace media
OLDNEW
« media/base/yuv_convert.h ('K') | « media/base/yuv_convert_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698