| 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/ffmpeg_video_decoder.h" | 5 #include "media/filters/ffmpeg_video_decoder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (!VideoFrame::IsValidConfig(format, VideoFrame::STORAGE_UNKNOWN, | 126 if (!VideoFrame::IsValidConfig(format, VideoFrame::STORAGE_UNKNOWN, |
| 127 coded_size, gfx::Rect(size), natural_size)) { | 127 coded_size, gfx::Rect(size), natural_size)) { |
| 128 return AVERROR(EINVAL); | 128 return AVERROR(EINVAL); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // FFmpeg expects the initialize allocation to be zero-initialized. Failure | 131 // FFmpeg expects the initialize allocation to be zero-initialized. Failure |
| 132 // to do so can lead to unitialized value usage. See http://crbug.com/390941 | 132 // to do so can lead to unitialized value usage. See http://crbug.com/390941 |
| 133 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( | 133 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( |
| 134 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp); | 134 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp); |
| 135 | 135 |
| 136 if (!video_frame) |
| 137 return AVERROR(EINVAL); |
| 138 |
| 136 // Prefer the color space from the codec context. If it's not specified (or is | 139 // Prefer the color space from the codec context. If it's not specified (or is |
| 137 // set to an unsupported value), fall back on the value from the config. | 140 // set to an unsupported value), fall back on the value from the config. |
| 138 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace, | 141 ColorSpace color_space = AVColorSpaceToColorSpace(codec_context->colorspace, |
| 139 codec_context->color_range); | 142 codec_context->color_range); |
| 140 if (color_space == COLOR_SPACE_UNSPECIFIED) | 143 if (color_space == COLOR_SPACE_UNSPECIFIED) |
| 141 color_space = config_.color_space(); | 144 color_space = config_.color_space(); |
| 142 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, | 145 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, |
| 143 color_space); | 146 color_space); |
| 144 | 147 |
| 145 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED || | 148 if (codec_context->color_primaries != AVCOL_PRI_UNSPECIFIED || |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 389 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 387 ReleaseFFmpegResources(); | 390 ReleaseFFmpegResources(); |
| 388 return false; | 391 return false; |
| 389 } | 392 } |
| 390 | 393 |
| 391 av_frame_.reset(av_frame_alloc()); | 394 av_frame_.reset(av_frame_alloc()); |
| 392 return true; | 395 return true; |
| 393 } | 396 } |
| 394 | 397 |
| 395 } // namespace media | 398 } // namespace media |
| OLD | NEW |