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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 int flags) { | 75 int flags) { |
76 // Don't use |codec_context_| here! With threaded decoding, | 76 // Don't use |codec_context_| here! With threaded decoding, |
77 // it will contain unsynchronized width/height/pix_fmt values, | 77 // it will contain unsynchronized width/height/pix_fmt values, |
78 // whereas |codec_context| contains the current threads's | 78 // whereas |codec_context| contains the current threads's |
79 // updated width/height/pix_fmt, which can change for adaptive | 79 // updated width/height/pix_fmt, which can change for adaptive |
80 // content. | 80 // content. |
81 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); | 81 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); |
82 if (format == VideoFrame::UNKNOWN) | 82 if (format == VideoFrame::UNKNOWN) |
83 return AVERROR(EINVAL); | 83 return AVERROR(EINVAL); |
84 DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16 || | 84 DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16 || |
85 format == VideoFrame::YV12J); | 85 format == VideoFrame::YV12J || format == VideoFrame::YV24); |
86 | 86 |
87 gfx::Size size(codec_context->width, codec_context->height); | 87 gfx::Size size(codec_context->width, codec_context->height); |
88 const int ret = av_image_check_size(size.width(), size.height(), 0, NULL); | 88 const int ret = av_image_check_size(size.width(), size.height(), 0, NULL); |
89 if (ret < 0) | 89 if (ret < 0) |
90 return ret; | 90 return ret; |
91 | 91 |
92 gfx::Size natural_size; | 92 gfx::Size natural_size; |
93 if (codec_context->sample_aspect_ratio.num > 0) { | 93 if (codec_context->sample_aspect_ratio.num > 0) { |
94 natural_size = GetNaturalSize(size, | 94 natural_size = GetNaturalSize(size, |
95 codec_context->sample_aspect_ratio.num, | 95 codec_context->sample_aspect_ratio.num, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 364 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
365 ReleaseFFmpegResources(); | 365 ReleaseFFmpegResources(); |
366 return false; | 366 return false; |
367 } | 367 } |
368 | 368 |
369 av_frame_.reset(av_frame_alloc()); | 369 av_frame_.reset(av_frame_alloc()); |
370 return true; | 370 return true; |
371 } | 371 } |
372 | 372 |
373 } // namespace media | 373 } // namespace media |
OLD | NEW |