OLD | NEW |
---|---|
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/vpx_video_decoder.h" | 5 #include "media/filters/vpx_video_decoder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 330 |
331 state_ = kNormal; | 331 state_ = kNormal; |
332 reset_cb_.Run(); | 332 reset_cb_.Run(); |
333 reset_cb_.Reset(); | 333 reset_cb_.Reset(); |
334 } | 334 } |
335 | 335 |
336 void VpxVideoDecoder::CopyVpxImageTo(const vpx_image* vpx_image, | 336 void VpxVideoDecoder::CopyVpxImageTo(const vpx_image* vpx_image, |
337 const struct vpx_image* vpx_image_alpha, | 337 const struct vpx_image* vpx_image_alpha, |
338 scoped_refptr<VideoFrame>* video_frame) { | 338 scoped_refptr<VideoFrame>* video_frame) { |
339 CHECK(vpx_image); | 339 CHECK(vpx_image); |
340 CHECK_EQ(vpx_image->d_w % 2, 0U); | |
341 CHECK_EQ(vpx_image->d_h % 2, 0U); | |
342 CHECK(vpx_image->fmt == VPX_IMG_FMT_I420 || | 340 CHECK(vpx_image->fmt == VPX_IMG_FMT_I420 || |
343 vpx_image->fmt == VPX_IMG_FMT_YV12); | 341 vpx_image->fmt == VPX_IMG_FMT_YV12); |
344 | 342 |
345 gfx::Size size(vpx_image->d_w, vpx_image->d_h); | 343 gfx::Size size(vpx_image->d_w, vpx_image->d_h); |
346 | 344 |
347 *video_frame = VideoFrame::CreateFrame( | 345 *video_frame = VideoFrame::CreateFrame( |
348 vpx_codec_alpha_ ? VideoFrame::YV12A : VideoFrame::YV12, | 346 vpx_codec_alpha_ ? VideoFrame::YV12A : VideoFrame::YV12, |
349 size, | 347 size, |
350 gfx::Rect(size), | 348 gfx::Rect(size), |
351 config_.natural_size(), | 349 config_.natural_size(), |
352 kNoTimestamp()); | 350 kNoTimestamp()); |
353 | 351 |
354 CopyYPlane(vpx_image->planes[VPX_PLANE_Y], | 352 CopyYPlane(vpx_image->planes[VPX_PLANE_Y], |
355 vpx_image->stride[VPX_PLANE_Y], | 353 vpx_image->stride[VPX_PLANE_Y], |
356 vpx_image->d_h, | 354 vpx_image->d_h, |
357 video_frame->get()); | 355 video_frame->get()); |
358 CopyUPlane(vpx_image->planes[VPX_PLANE_U], | 356 CopyUPlane(vpx_image->planes[VPX_PLANE_U], |
359 vpx_image->stride[VPX_PLANE_U], | 357 vpx_image->stride[VPX_PLANE_U], |
360 vpx_image->d_h / 2, | 358 (1 + vpx_image->d_h) / 2, |
scherkus (not reviewing)
2013/12/02 20:27:33
nit: can we swap the order of the variable and the
vignesh
2013/12/02 21:07:34
Done.
| |
361 video_frame->get()); | 359 video_frame->get()); |
362 CopyVPlane(vpx_image->planes[VPX_PLANE_V], | 360 CopyVPlane(vpx_image->planes[VPX_PLANE_V], |
363 vpx_image->stride[VPX_PLANE_V], | 361 vpx_image->stride[VPX_PLANE_V], |
364 vpx_image->d_h / 2, | 362 (1 + vpx_image->d_h) / 2, |
365 video_frame->get()); | 363 video_frame->get()); |
366 if (!vpx_codec_alpha_) | 364 if (!vpx_codec_alpha_) |
367 return; | 365 return; |
368 if (!vpx_image_alpha) { | 366 if (!vpx_image_alpha) { |
369 MakeOpaqueAPlane( | 367 MakeOpaqueAPlane( |
370 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); | 368 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); |
371 return; | 369 return; |
372 } | 370 } |
373 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 371 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
374 vpx_image->stride[VPX_PLANE_Y], | 372 vpx_image->stride[VPX_PLANE_Y], |
375 vpx_image->d_h, | 373 vpx_image->d_h, |
376 video_frame->get()); | 374 video_frame->get()); |
377 } | 375 } |
378 | 376 |
379 } // namespace media | 377 } // namespace media |
OLD | NEW |