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

Unified Diff: media/filters/vpx_video_decoder.cc

Issue 1520313002: Don't assume correct image format in CopyVpxImageToVideoFrame() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/filters/vpx_video_decoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/vpx_video_decoder.cc
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index d9721b0c9474e6aa83867d395d8dbad900473aaf..1e041e6a611346d9ac38025206732e967c19bfc7 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -463,7 +463,9 @@ bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer,
return false;
}
- CopyVpxImageToVideoFrame(vpx_image, video_frame);
+ if (!CopyVpxImageToVideoFrame(vpx_image, video_frame))
+ return false;
+
(*video_frame)->set_timestamp(base::TimeDelta::FromMicroseconds(timestamp));
// Default to the color space from the config, but if the bistream specifies
@@ -543,18 +545,25 @@ bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer,
return true;
}
-void VpxVideoDecoder::CopyVpxImageToVideoFrame(
+bool VpxVideoDecoder::CopyVpxImageToVideoFrame(
const struct vpx_image* vpx_image,
scoped_refptr<VideoFrame>* video_frame) {
DCHECK(vpx_image);
- DCHECK(vpx_image->fmt == VPX_IMG_FMT_I420 ||
- vpx_image->fmt == VPX_IMG_FMT_I444);
- VideoPixelFormat codec_format = PIXEL_FORMAT_YV12;
- if (vpx_image->fmt == VPX_IMG_FMT_I444)
- codec_format = PIXEL_FORMAT_YV24;
- else if (vpx_codec_alpha_)
- codec_format = PIXEL_FORMAT_YV12A;
+ VideoPixelFormat codec_format;
+ switch (vpx_image->fmt) {
+ case VPX_IMG_FMT_I420:
+ codec_format = vpx_codec_alpha_ ? PIXEL_FORMAT_YV12A : PIXEL_FORMAT_YV12;
mcasas 2015/12/15 17:04:54 VpxVideoDecoder should not be used for YV12 if th
vignesh 2015/12/15 17:10:23 The comment on [1] may be perceived as ambiguous.
+ break;
+
+ case VPX_IMG_FMT_I444:
+ codec_format = PIXEL_FORMAT_YV24;
+ break;
+
+ default:
+ DLOG(ERROR) << "Unsupported pixel format: " << vpx_image->fmt;
+ return false;
+ }
// The mixed |w|/|d_h| in |coded_size| is intentional. Setting the correct
// coded width is necessary to allow coalesced memory access, which may avoid
@@ -585,7 +594,7 @@ void VpxVideoDecoder::CopyVpxImageToVideoFrame(
"Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame",
memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame());
- return;
+ return true;
}
DCHECK(codec_format == PIXEL_FORMAT_YV12 ||
@@ -606,6 +615,8 @@ void VpxVideoDecoder::CopyVpxImageToVideoFrame(
(*video_frame)->visible_data(VideoFrame::kVPlane),
(*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(),
coded_size.height());
+
+ return true;
}
} // namespace media
« no previous file with comments | « media/filters/vpx_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698