Index: media/filters/ffmpeg_video_decoder.cc |
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc |
index fdf8dc5841a8085c4831026dd693b6fe3e994acf..a356fab6418596556836d6e41fa548fb05303268 100644 |
--- a/media/filters/ffmpeg_video_decoder.cc |
+++ b/media/filters/ffmpeg_video_decoder.cc |
@@ -127,12 +127,17 @@ int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, |
scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( |
format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp()); |
+ // FFmpeg expects the initialize allocation to be zero-initialized. Failure |
+ // to do so can lead to unitialized value usage. See http://crbug.com/390941 |
+ const size_t data_size = VideoFrame::AlignedAllocationSize(video_frame); |
+ memset(video_frame->data(0), 0, data_size); |
DaleCurtis
2015/07/09 21:35:11
We don't want to do this here actually, as now mem
emircan
2015/07/09 22:12:18
Done. I added |zero_out_memory| bool to carry that
|
+ |
if (codec_context->colorspace == AVCOL_SPC_BT709) { |
video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, |
VideoFrame::COLOR_SPACE_HD_REC709); |
} |
- for (int i = 0; i < 3; i++) { |
+ for (size_t i = 0; i < VideoFrame::NumPlanes(video_frame->format()); i++) { |
frame->data[i] = video_frame->data(i); |
frame->linesize[i] = video_frame->stride(i); |
} |
@@ -148,7 +153,7 @@ int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, |
video_frame.swap(reinterpret_cast<VideoFrame**>(&opaque)); |
frame->buf[0] = |
av_buffer_create(frame->data[0], |
- VideoFrame::AllocationSize(format, coded_size), |
DaleCurtis
2015/07/09 21:36:22
Hmm, I think we were intentionally using the lower
emircan
2015/07/09 22:12:17
I see. It looked like a mistake to me in the begin
DaleCurtis
2015/07/09 22:21:16
Hmm, I see, we can try it your way and see what fa
emircan
2015/07/09 23:16:27
Done.
emircan
2015/07/10 18:43:40
Well, bots showed that it didn't work out. Reverti
|
+ data_size, |
ReleaseVideoBufferImpl, |
opaque, |
0); |