Chromium Code Reviews| Index: media/filters/ffmpeg_video_decoder.cc |
| diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc |
| index 9cb3d5f91895a852b5e7067477120a74e2c9613b..12d9e736edf1dcf302bc3e15b42bcabb62a52869 100644 |
| --- a/media/filters/ffmpeg_video_decoder.cc |
| +++ b/media/filters/ffmpeg_video_decoder.cc |
| @@ -66,6 +66,12 @@ static void ReleaseVideoBufferImpl(void* opaque, uint8* data) { |
| video_frame.swap(reinterpret_cast<VideoFrame**>(&opaque)); |
| } |
| +static size_t RoundUp(size_t value, size_t alignment) { |
| + // Check that |alignment| is a power of 2. |
| + DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1))); |
| + return ((value + (alignment - 1)) & ~(alignment - 1)); |
| +} |
| + |
| FFmpegVideoDecoder::FFmpegVideoDecoder( |
| const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
| : task_runner_(task_runner), state_(kUninitialized) {} |
| @@ -104,9 +110,13 @@ int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, |
| // |
| // When lowres is non-zero, dimensions should be divided by 2^(lowres), but |
| // since we don't use this, just DCHECK that it's zero. |
| + // |
| + // Always round up to a multiple of two to match VideoFrame restrictions on |
| + // frame alignment. |
| DCHECK_EQ(codec_context->lowres, 0); |
| - gfx::Size coded_size(std::max(size.width(), codec_context->coded_width), |
| - std::max(size.height(), codec_context->coded_height)); |
| + gfx::Size coded_size( |
| + RoundUp(std::max(size.width(), codec_context->coded_width), 2), |
| + RoundUp(std::max(size.height(), codec_context->coded_height), 2)); |
| if (!VideoFrame::IsValidConfig( |
|
scherkus (not reviewing)
2014/06/06 21:25:50
was this check failing with that test clip?
DaleCurtis
2014/06/06 21:33:06
Yes.
|
| format, coded_size, gfx::Rect(size), natural_size)) |