| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/media/crypto/ppapi/ffmpeg_cdm_video_decoder.h" | 5 #include "media/cdm/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 "webkit/renderer/media/crypto/ppapi/cdm/content_decryption_module.h" | |
| 12 | 11 |
| 13 // Include FFmpeg header files. | 12 // Include FFmpeg header files. |
| 14 extern "C" { | 13 extern "C" { |
| 15 // Temporarily disable possible loss of data warning. | 14 // Temporarily disable possible loss of data warning. |
| 16 MSVC_PUSH_DISABLE_WARNING(4244); | 15 MSVC_PUSH_DISABLE_WARNING(4244); |
| 17 #include <libavcodec/avcodec.h> | 16 #include <libavcodec/avcodec.h> |
| 18 MSVC_POP_WARNING(); | 17 MSVC_POP_WARNING(); |
| 19 } // extern "C" | 18 } // extern "C" |
| 20 | 19 |
| 21 namespace webkit_media { | 20 namespace media { |
| 22 | 21 |
| 23 static const int kDecodeThreads = 1; | 22 static const int kDecodeThreads = 1; |
| 24 | 23 |
| 25 static cdm::VideoFormat PixelFormatToCdmVideoFormat(PixelFormat pixel_format) { | 24 static cdm::VideoFormat PixelFormatToCdmVideoFormat(PixelFormat pixel_format) { |
| 26 switch (pixel_format) { | 25 switch (pixel_format) { |
| 27 case PIX_FMT_YUV420P: | 26 case PIX_FMT_YUV420P: |
| 28 return cdm::kYv12; | 27 return cdm::kYv12; |
| 29 default: | 28 default: |
| 30 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; | 29 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; |
| 31 } | 30 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 DVLOG(1) << "Reset()"; | 191 DVLOG(1) << "Reset()"; |
| 193 avcodec_flush_buffers(codec_context_); | 192 avcodec_flush_buffers(codec_context_); |
| 194 } | 193 } |
| 195 | 194 |
| 196 // static | 195 // static |
| 197 bool FFmpegCdmVideoDecoder::IsValidOutputConfig(cdm::VideoFormat format, | 196 bool FFmpegCdmVideoDecoder::IsValidOutputConfig(cdm::VideoFormat format, |
| 198 const cdm::Size& data_size) { | 197 const cdm::Size& data_size) { |
| 199 return ((format == cdm::kYv12 || format == cdm::kI420) && | 198 return ((format == cdm::kYv12 || format == cdm::kI420) && |
| 200 (data_size.width % 2) == 0 && (data_size.height % 2) == 0 && | 199 (data_size.width % 2) == 0 && (data_size.height % 2) == 0 && |
| 201 data_size.width > 0 && data_size.height > 0 && | 200 data_size.width > 0 && data_size.height > 0 && |
| 202 data_size.width <= media::limits::kMaxDimension && | 201 data_size.width <= limits::kMaxDimension && |
| 203 data_size.height <= media::limits::kMaxDimension && | 202 data_size.height <= limits::kMaxDimension && |
| 204 data_size.width * data_size.height <= media::limits::kMaxCanvas); | 203 data_size.width * data_size.height <= limits::kMaxCanvas); |
| 205 } | 204 } |
| 206 | 205 |
| 207 cdm::Status FFmpegCdmVideoDecoder::DecodeFrame( | 206 cdm::Status FFmpegCdmVideoDecoder::DecodeFrame( |
| 208 const uint8_t* compressed_frame, | 207 const uint8_t* compressed_frame, |
| 209 int32_t compressed_frame_size, | 208 int32_t compressed_frame_size, |
| 210 int64_t timestamp, | 209 int64_t timestamp, |
| 211 cdm::VideoFrame* decoded_frame) { | 210 cdm::VideoFrame* decoded_frame) { |
| 212 DVLOG(1) << "DecodeFrame()"; | 211 DVLOG(1) << "DecodeFrame()"; |
| 213 DCHECK(decoded_frame); | 212 DCHECK(decoded_frame); |
| 214 | 213 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 avcodec_close(codec_context_); | 334 avcodec_close(codec_context_); |
| 336 av_free(codec_context_); | 335 av_free(codec_context_); |
| 337 codec_context_ = NULL; | 336 codec_context_ = NULL; |
| 338 } | 337 } |
| 339 if (av_frame_) { | 338 if (av_frame_) { |
| 340 av_free(av_frame_); | 339 av_free(av_frame_); |
| 341 av_frame_ = NULL; | 340 av_frame_ = NULL; |
| 342 } | 341 } |
| 343 } | 342 } |
| 344 | 343 |
| 345 } // namespace webkit_media | 344 } // namespace media |
| OLD | NEW |