| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, | 80 int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, |
| 81 AVFrame* frame, | 81 AVFrame* frame, |
| 82 int flags) { | 82 int flags) { |
| 83 // Don't use |codec_context_| here! With threaded decoding, | 83 // Don't use |codec_context_| here! With threaded decoding, |
| 84 // it will contain unsynchronized width/height/pix_fmt values, | 84 // it will contain unsynchronized width/height/pix_fmt values, |
| 85 // whereas |codec_context| contains the current threads's | 85 // whereas |codec_context| contains the current threads's |
| 86 // updated width/height/pix_fmt, which can change for adaptive | 86 // updated width/height/pix_fmt, which can change for adaptive |
| 87 // content. | 87 // content. |
| 88 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); | 88 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); |
| 89 if (format == VideoFrame::YV12 && |
| 90 codec_context->colorspace == AVCOL_SPC_BT709) { |
| 91 format = VideoFrame::YV12HD; |
| 92 } |
| 93 |
| 89 if (format == VideoFrame::UNKNOWN) | 94 if (format == VideoFrame::UNKNOWN) |
| 90 return AVERROR(EINVAL); | 95 return AVERROR(EINVAL); |
| 91 DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16 || | 96 DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16 || |
| 92 format == VideoFrame::YV12J || format == VideoFrame::YV24); | 97 format == VideoFrame::YV12J || format == VideoFrame::YV24 || |
| 98 format == VideoFrame::YV12HD); |
| 93 | 99 |
| 94 gfx::Size size(codec_context->width, codec_context->height); | 100 gfx::Size size(codec_context->width, codec_context->height); |
| 95 const int ret = av_image_check_size(size.width(), size.height(), 0, NULL); | 101 const int ret = av_image_check_size(size.width(), size.height(), 0, NULL); |
| 96 if (ret < 0) | 102 if (ret < 0) |
| 97 return ret; | 103 return ret; |
| 98 | 104 |
| 99 gfx::Size natural_size; | 105 gfx::Size natural_size; |
| 100 if (codec_context->sample_aspect_ratio.num > 0) { | 106 if (codec_context->sample_aspect_ratio.num > 0) { |
| 101 natural_size = GetNaturalSize(size, | 107 natural_size = GetNaturalSize(size, |
| 102 codec_context->sample_aspect_ratio.num, | 108 codec_context->sample_aspect_ratio.num, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 351 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 346 ReleaseFFmpegResources(); | 352 ReleaseFFmpegResources(); |
| 347 return false; | 353 return false; |
| 348 } | 354 } |
| 349 | 355 |
| 350 av_frame_.reset(av_frame_alloc()); | 356 av_frame_.reset(av_frame_alloc()); |
| 351 return true; | 357 return true; |
| 352 } | 358 } |
| 353 | 359 |
| 354 } // namespace media | 360 } // namespace media |
| OLD | NEW |