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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 return; | 94 return; |
95 } | 95 } |
96 | 96 |
97 // Initialize AVCodecContext structure. | 97 // Initialize AVCodecContext structure. |
98 codec_context_ = avcodec_alloc_context(); | 98 codec_context_ = avcodec_alloc_context(); |
99 VideoDecoderConfigToAVCodecContext(config, codec_context_); | 99 VideoDecoderConfigToAVCodecContext(config, codec_context_); |
100 | 100 |
101 // Enable motion vector search (potentially slow), strong deblocking filter | 101 // Enable motion vector search (potentially slow), strong deblocking filter |
102 // for damaged macroblocks, and set our error detection sensitivity. | 102 // for damaged macroblocks, and set our error detection sensitivity. |
103 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; | 103 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; |
104 codec_context_->error_recognition = FF_ER_CAREFUL; | 104 codec_context_->err_recognition = AV_EF_CAREFUL; |
105 codec_context_->thread_count = GetThreadCount(codec_context_->codec_id); | 105 codec_context_->thread_count = GetThreadCount(codec_context_->codec_id); |
106 | 106 |
107 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); | 107 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); |
108 if (!codec) { | 108 if (!codec) { |
109 callback.Run(PIPELINE_ERROR_DECODE); | 109 callback.Run(PIPELINE_ERROR_DECODE); |
110 return; | 110 return; |
111 } | 111 } |
112 | 112 |
113 if (avcodec_open(codec_context_, codec) < 0) { | 113 if (avcodec_open2(codec_context_, codec, NULL) < 0) { |
114 callback.Run(PIPELINE_ERROR_DECODE); | 114 callback.Run(PIPELINE_ERROR_DECODE); |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 // Success! | 118 // Success! |
119 state_ = kNormal; | 119 state_ = kNormal; |
120 av_frame_ = avcodec_alloc_frame(); | 120 av_frame_ = avcodec_alloc_frame(); |
121 natural_size_ = config.natural_size(); | 121 natural_size_ = config.natural_size(); |
122 frame_rate_numerator_ = config.frame_rate_numerator(); | 122 frame_rate_numerator_ = config.frame_rate_numerator(); |
123 frame_rate_denominator_ = config.frame_rate_denominator(); | 123 frame_rate_denominator_ = config.frame_rate_denominator(); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { | 406 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { |
407 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); | 407 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); |
408 size_t width = codec_context_->width; | 408 size_t width = codec_context_->width; |
409 size_t height = codec_context_->height; | 409 size_t height = codec_context_->height; |
410 | 410 |
411 return VideoFrame::CreateFrame(format, width, height, | 411 return VideoFrame::CreateFrame(format, width, height, |
412 kNoTimestamp(), kNoTimestamp()); | 412 kNoTimestamp(), kNoTimestamp()); |
413 } | 413 } |
414 | 414 |
415 } // namespace media | 415 } // namespace media |
OLD | NEW |