| 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 "webkit/media/crypto/ppapi/ffmpeg_cdm_video_decoder.h" | 5 #include "webkit/media/crypto/ppapi/ffmpeg_cdm_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
| 10 #include "media/base/limits.h" | 10 #include "media/base/limits.h" |
| 11 #include "media/ffmpeg/ffmpeg_common.h" | |
| 12 #include "webkit/media/crypto/ppapi/content_decryption_module.h" | 11 #include "webkit/media/crypto/ppapi/content_decryption_module.h" |
| 13 | 12 |
| 14 // Include FFmpeg header files. | 13 // Include FFmpeg header files. |
| 15 extern "C" { | 14 extern "C" { |
| 16 // Temporarily disable possible loss of data warning. | 15 // Temporarily disable possible loss of data warning. |
| 17 MSVC_PUSH_DISABLE_WARNING(4244); | 16 MSVC_PUSH_DISABLE_WARNING(4244); |
| 18 #include <libavcodec/avcodec.h> | 17 #include <libavcodec/avcodec.h> |
| 19 MSVC_POP_WARNING(); | 18 MSVC_POP_WARNING(); |
| 20 } // extern "C" | 19 } // extern "C" |
| 21 | 20 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (!IsValidOutputConfig(config.format, config.coded_size)) { | 117 if (!IsValidOutputConfig(config.format, config.coded_size)) { |
| 119 LOG(ERROR) << "Initialize(): invalid video decoder configuration."; | 118 LOG(ERROR) << "Initialize(): invalid video decoder configuration."; |
| 120 return false; | 119 return false; |
| 121 } | 120 } |
| 122 | 121 |
| 123 if (is_initialized_) { | 122 if (is_initialized_) { |
| 124 LOG(ERROR) << "Initialize(): Already initialized."; | 123 LOG(ERROR) << "Initialize(): Already initialized."; |
| 125 return false; | 124 return false; |
| 126 } | 125 } |
| 127 | 126 |
| 128 av_register_all(); | |
| 129 | |
| 130 // Release existing resources if necessary. | |
| 131 ReleaseFFmpegResources(); | |
| 132 | |
| 133 // Initialize AVCodecContext structure. | 127 // Initialize AVCodecContext structure. |
| 134 codec_context_ = avcodec_alloc_context3(NULL); | 128 codec_context_ = avcodec_alloc_context3(NULL); |
| 135 CdmVideoDecoderConfigToAVCodecContext(config, codec_context_); | 129 CdmVideoDecoderConfigToAVCodecContext(config, codec_context_); |
| 136 | 130 |
| 137 // Enable motion vector search (potentially slow), strong deblocking filter | 131 // Enable motion vector search (potentially slow), strong deblocking filter |
| 138 // for damaged macroblocks, and set our error detection sensitivity. | 132 // for damaged macroblocks, and set our error detection sensitivity. |
| 139 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; | 133 codec_context_->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK; |
| 140 codec_context_->err_recognition = AV_EF_CAREFUL; | 134 codec_context_->err_recognition = AV_EF_CAREFUL; |
| 141 codec_context_->thread_count = kDecodeThreads; | 135 codec_context_->thread_count = kDecodeThreads; |
| 142 codec_context_->opaque = this; | 136 codec_context_->opaque = this; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 av_free(codec_context_); | 306 av_free(codec_context_); |
| 313 codec_context_ = NULL; | 307 codec_context_ = NULL; |
| 314 } | 308 } |
| 315 if (av_frame_) { | 309 if (av_frame_) { |
| 316 av_free(av_frame_); | 310 av_free(av_frame_); |
| 317 av_frame_ = NULL; | 311 av_frame_ = NULL; |
| 318 } | 312 } |
| 319 } | 313 } |
| 320 | 314 |
| 321 } // namespace webkit_media | 315 } // namespace webkit_media |
| OLD | NEW |