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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // When lowres is non-zero, dimensions should be divided by 2^(lowres), but | 118 // When lowres is non-zero, dimensions should be divided by 2^(lowres), but |
119 // since we don't use this, just DCHECK that it's zero. | 119 // since we don't use this, just DCHECK that it's zero. |
120 // | 120 // |
121 // Always round up to a multiple of two to match VideoFrame restrictions on | 121 // Always round up to a multiple of two to match VideoFrame restrictions on |
122 // frame alignment. | 122 // frame alignment. |
123 DCHECK_EQ(codec_context->lowres, 0); | 123 DCHECK_EQ(codec_context->lowres, 0); |
124 gfx::Size coded_size( | 124 gfx::Size coded_size( |
125 RoundUp(std::max(size.width(), codec_context->coded_width), 2), | 125 RoundUp(std::max(size.width(), codec_context->coded_width), 2), |
126 RoundUp(std::max(size.height(), codec_context->coded_height), 2)); | 126 RoundUp(std::max(size.height(), codec_context->coded_height), 2)); |
127 | 127 |
128 if (!VideoFrame::IsValidConfig( | 128 if (!VideoFrame::IsValidConfig(format, VideoFrame::TEXTURE_NONE, coded_size, |
129 format, coded_size, gfx::Rect(size), natural_size)) | 129 gfx::Rect(size), natural_size)) |
130 return AVERROR(EINVAL); | 130 return AVERROR(EINVAL); |
131 | 131 |
132 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( | 132 scoped_refptr<VideoFrame> video_frame = frame_pool_.CreateFrame( |
133 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp()); | 133 format, coded_size, gfx::Rect(size), natural_size, kNoTimestamp()); |
134 | 134 |
135 for (int i = 0; i < 3; i++) { | 135 for (int i = 0; i < 3; i++) { |
136 frame->data[i] = video_frame->data(i); | 136 frame->data[i] = video_frame->data(i); |
137 frame->linesize[i] = video_frame->stride(i); | 137 frame->linesize[i] = video_frame->stride(i); |
138 } | 138 } |
139 | 139 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 353 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
354 ReleaseFFmpegResources(); | 354 ReleaseFFmpegResources(); |
355 return false; | 355 return false; |
356 } | 356 } |
357 | 357 |
358 av_frame_.reset(av_frame_alloc()); | 358 av_frame_.reset(av_frame_alloc()); |
359 return true; | 359 return true; |
360 } | 360 } |
361 | 361 |
362 } // namespace media | 362 } // namespace media |
OLD | NEW |