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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 CopyVpxImageTo(vpx_image, vpx_image_alpha, video_frame); | 443 CopyVpxImageTo(vpx_image, vpx_image_alpha, video_frame); |
444 (*video_frame)->set_timestamp(base::TimeDelta::FromMicroseconds(timestamp)); | 444 (*video_frame)->set_timestamp(base::TimeDelta::FromMicroseconds(timestamp)); |
445 return true; | 445 return true; |
446 } | 446 } |
447 | 447 |
448 void VpxVideoDecoder::CopyVpxImageTo(const vpx_image* vpx_image, | 448 void VpxVideoDecoder::CopyVpxImageTo(const vpx_image* vpx_image, |
449 const struct vpx_image* vpx_image_alpha, | 449 const struct vpx_image* vpx_image_alpha, |
450 scoped_refptr<VideoFrame>* video_frame) { | 450 scoped_refptr<VideoFrame>* video_frame) { |
451 CHECK(vpx_image); | 451 CHECK(vpx_image); |
452 CHECK(vpx_image->fmt == VPX_IMG_FMT_I420 || | 452 CHECK(vpx_image->fmt == VPX_IMG_FMT_I420 || |
453 vpx_image->fmt == VPX_IMG_FMT_YV12); | 453 vpx_image->fmt == VPX_IMG_FMT_YV12 || |
454 vpx_image->fmt == VPX_IMG_FMT_I444); | |
455 | |
456 VideoFrame::Format codec_format; | |
scherkus (not reviewing)
2014/05/29 02:30:26
nit: we typically try to initialize variables to s
sandersd (OOO until July 31)
2014/05/29 20:39:09
Done. I don't think that it's easier to read, but
| |
457 int uv_rows; | |
458 | |
459 if (vpx_image->fmt == VPX_IMG_FMT_I444) { | |
460 CHECK(!vpx_codec_alpha_); | |
461 codec_format = VideoFrame::YV24; | |
462 uv_rows = vpx_image->d_h; | |
463 } else { | |
464 codec_format = vpx_codec_alpha_ ? VideoFrame::YV12A : VideoFrame::YV12; | |
465 uv_rows = (vpx_image->d_h + 1) / 2; | |
466 } | |
454 | 467 |
455 gfx::Size size(vpx_image->d_w, vpx_image->d_h); | 468 gfx::Size size(vpx_image->d_w, vpx_image->d_h); |
456 | 469 |
457 if (!vpx_codec_alpha_ && memory_pool_) { | 470 if (!vpx_codec_alpha_ && memory_pool_) { |
458 *video_frame = VideoFrame::WrapExternalYuvData( | 471 *video_frame = VideoFrame::WrapExternalYuvData( |
459 VideoFrame::YV12, | 472 codec_format, |
460 size, gfx::Rect(size), config_.natural_size(), | 473 size, gfx::Rect(size), config_.natural_size(), |
461 vpx_image->stride[VPX_PLANE_Y], | 474 vpx_image->stride[VPX_PLANE_Y], |
462 vpx_image->stride[VPX_PLANE_U], | 475 vpx_image->stride[VPX_PLANE_U], |
463 vpx_image->stride[VPX_PLANE_V], | 476 vpx_image->stride[VPX_PLANE_V], |
464 vpx_image->planes[VPX_PLANE_Y], | 477 vpx_image->planes[VPX_PLANE_Y], |
465 vpx_image->planes[VPX_PLANE_U], | 478 vpx_image->planes[VPX_PLANE_U], |
466 vpx_image->planes[VPX_PLANE_V], | 479 vpx_image->planes[VPX_PLANE_V], |
467 kNoTimestamp(), | 480 kNoTimestamp(), |
468 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); | 481 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); |
469 return; | 482 return; |
470 } | 483 } |
471 | 484 |
472 *video_frame = frame_pool_.CreateFrame( | 485 *video_frame = frame_pool_.CreateFrame( |
473 vpx_codec_alpha_ ? VideoFrame::YV12A : VideoFrame::YV12, | 486 codec_format, |
474 size, | 487 size, |
475 gfx::Rect(size), | 488 gfx::Rect(size), |
476 config_.natural_size(), | 489 config_.natural_size(), |
477 kNoTimestamp()); | 490 kNoTimestamp()); |
478 | 491 |
479 CopyYPlane(vpx_image->planes[VPX_PLANE_Y], | 492 CopyYPlane(vpx_image->planes[VPX_PLANE_Y], |
480 vpx_image->stride[VPX_PLANE_Y], | 493 vpx_image->stride[VPX_PLANE_Y], |
481 vpx_image->d_h, | 494 vpx_image->d_h, |
482 video_frame->get()); | 495 video_frame->get()); |
483 CopyUPlane(vpx_image->planes[VPX_PLANE_U], | 496 CopyUPlane(vpx_image->planes[VPX_PLANE_U], |
484 vpx_image->stride[VPX_PLANE_U], | 497 vpx_image->stride[VPX_PLANE_U], |
485 (vpx_image->d_h + 1) / 2, | 498 uv_rows, |
486 video_frame->get()); | 499 video_frame->get()); |
487 CopyVPlane(vpx_image->planes[VPX_PLANE_V], | 500 CopyVPlane(vpx_image->planes[VPX_PLANE_V], |
488 vpx_image->stride[VPX_PLANE_V], | 501 vpx_image->stride[VPX_PLANE_V], |
489 (vpx_image->d_h + 1) / 2, | 502 uv_rows, |
490 video_frame->get()); | 503 video_frame->get()); |
491 if (!vpx_codec_alpha_) | 504 if (!vpx_codec_alpha_) |
492 return; | 505 return; |
493 if (!vpx_image_alpha) { | 506 if (!vpx_image_alpha) { |
494 MakeOpaqueAPlane( | 507 MakeOpaqueAPlane( |
495 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); | 508 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); |
496 return; | 509 return; |
497 } | 510 } |
498 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 511 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
499 vpx_image->stride[VPX_PLANE_Y], | 512 vpx_image->stride[VPX_PLANE_Y], |
500 vpx_image->d_h, | 513 vpx_image->d_h, |
501 video_frame->get()); | 514 video_frame->get()); |
502 } | 515 } |
503 | 516 |
504 } // namespace media | 517 } // namespace media |
OLD | NEW |