| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // When lowres is non-zero, dimensions should be divided by 2^(lowres), but | 113 // When lowres is non-zero, dimensions should be divided by 2^(lowres), but |
| 114 // since we don't use this, just DCHECK that it's zero. | 114 // since we don't use this, just DCHECK that it's zero. |
| 115 // | 115 // |
| 116 // Always round up to a multiple of two to match VideoFrame restrictions on | 116 // Always round up to a multiple of two to match VideoFrame restrictions on |
| 117 // frame alignment. | 117 // frame alignment. |
| 118 DCHECK_EQ(codec_context->lowres, 0); | 118 DCHECK_EQ(codec_context->lowres, 0); |
| 119 gfx::Size coded_size( | 119 gfx::Size coded_size( |
| 120 RoundUp(std::max(size.width(), codec_context->coded_width), 2), | 120 RoundUp(std::max(size.width(), codec_context->coded_width), 2), |
| 121 RoundUp(std::max(size.height(), codec_context->coded_height), 2)); | 121 RoundUp(std::max(size.height(), codec_context->coded_height), 2)); |
| 122 | 122 |
| 123 if (!VideoFrame::IsValidConfig( | 123 if (!VideoFrame::IsValidConfig(format, VideoFrame::STORAGE_UNKNOWN, |
| 124 format, coded_size, gfx::Rect(size), natural_size)) | 124 coded_size, gfx::Rect(size), natural_size)) { |
| 125 return AVERROR(EINVAL); | 125 return AVERROR(EINVAL); |
| 126 } |
| 126 | 127 |
| 127 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( | 128 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( |
| 128 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp()); | 129 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp()); |
| 129 if (format == VideoFrame::YV12 && | 130 if (format == VideoFrame::YV12 && |
| 130 codec_context->colorspace == AVCOL_SPC_BT709) { | 131 codec_context->colorspace == AVCOL_SPC_BT709) { |
| 131 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, | 132 video_frame->metadata()->SetInteger(VideoFrameMetadata::COLOR_SPACE, |
| 132 VideoFrame::COLOR_SPACE_HD_REC709); | 133 VideoFrame::COLOR_SPACE_HD_REC709); |
| 133 } | 134 } |
| 134 | 135 |
| 135 for (int i = 0; i < 3; i++) { | 136 for (int i = 0; i < 3; i++) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 354 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 354 ReleaseFFmpegResources(); | 355 ReleaseFFmpegResources(); |
| 355 return false; | 356 return false; |
| 356 } | 357 } |
| 357 | 358 |
| 358 av_frame_.reset(av_frame_alloc()); | 359 av_frame_.reset(av_frame_alloc()); |
| 359 return true; | 360 return true; |
| 360 } | 361 } |
| 361 | 362 |
| 362 } // namespace media | 363 } // namespace media |
| OLD | NEW |