Chromium Code Reviews| 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 #ifndef MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 5 #ifndef MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| 6 #define MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 6 #define MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| 7 | 7 |
| 8 // Used for FFmpeg error codes. | 8 // Used for FFmpeg error codes. |
| 9 #include <cerrno> | 9 #include <cerrno> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/time.h" | 13 #include "base/time.h" |
| 13 #include "media/base/audio_decoder_config.h" | 14 #include "media/base/audio_decoder_config.h" |
| 14 #include "media/base/channel_layout.h" | 15 #include "media/base/channel_layout.h" |
| 16 #include "media/base/decoder_buffer.h" | |
|
acolwell GONE FROM CHROMIUM
2012/09/20 00:16:21
move this into cc file too.
xhwang
2012/09/20 01:43:03
Done.
| |
| 15 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
| 16 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
| 17 #include "media/base/video_decoder_config.h" | 19 #include "media/base/video_decoder_config.h" |
| 18 | 20 |
| 19 // Include FFmpeg header files. | 21 // Include FFmpeg header files. |
| 20 extern "C" { | 22 extern "C" { |
| 21 // Temporarily disable possible loss of data warning. | 23 // Temporarily disable possible loss of data warning. |
| 22 // TODO(scherkus): fix and upstream the compiler warnings. | 24 // TODO(scherkus): fix and upstream the compiler warnings. |
| 23 MSVC_PUSH_DISABLE_WARNING(4244); | 25 MSVC_PUSH_DISABLE_WARNING(4244); |
| 24 #include <libavcodec/avcodec.h> | 26 #include <libavcodec/avcodec.h> |
| 25 #include <libavformat/avformat.h> | 27 #include <libavformat/avformat.h> |
| 26 #include <libavformat/avio.h> | 28 #include <libavformat/avio.h> |
| 27 #include <libavformat/url.h> | 29 #include <libavformat/url.h> |
| 28 #include <libavutil/avutil.h> | 30 #include <libavutil/avutil.h> |
| 29 #include <libavutil/mathematics.h> | 31 #include <libavutil/mathematics.h> |
| 30 #include <libavutil/log.h> | 32 #include <libavutil/log.h> |
| 31 #include <libavutil/imgutils.h> | 33 #include <libavutil/imgutils.h> |
| 32 MSVC_POP_WARNING(); | 34 MSVC_POP_WARNING(); |
| 33 } // extern "C" | 35 } // extern "C" |
| 34 | 36 |
| 35 namespace media { | 37 namespace media { |
| 36 | 38 |
| 37 class AudioDecoderConfig; | 39 class AudioDecoderConfig; |
| 38 class VideoDecoderConfig; | 40 class VideoDecoderConfig; |
| 39 | 41 |
| 42 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are | |
| 43 // padded. Using av_malloc with padding ensures FFmpeg only receives data | |
|
acolwell GONE FROM CHROMIUM
2012/09/20 00:16:21
Comment should be updated. We don't use av_malloc
xhwang
2012/09/20 01:43:03
Done.
| |
| 44 // padded and aligned to its specifications. | |
| 45 COMPILE_ASSERT(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE, | |
|
ddorwin
2012/09/19 23:59:18
Shouldn't the new constants be multiples (1 or gre
DaleCurtis
2012/09/20 00:00:04
Do this in the cc file instead.
xhwang
2012/09/20 01:43:03
This should be okay. (+dale to be sure.)
xhwang
2012/09/20 01:43:03
Done.
| |
| 46 decoder_buffer_padding_size_does_not_fit_ffmpeg_requirement); | |
| 47 // Why 32? This is the alignment size required by FFmpeg for input buffers. | |
| 48 COMPILE_ASSERT(DecoderBuffer::kAlignmentSize == 32, | |
|
DaleCurtis
2012/09/20 00:00:04
>= 32?
xhwang
2012/09/20 01:43:03
The alignment should be positive multiple of 32. E
| |
| 49 decoder_buffer_alignment_size_does_not_fit_ffmpeg_requirement); | |
| 50 | |
| 40 // Wraps FFmpeg's av_free() in a class that can be passed as a template argument | 51 // Wraps FFmpeg's av_free() in a class that can be passed as a template argument |
| 41 // to scoped_ptr_malloc. | 52 // to scoped_ptr_malloc. |
| 42 class ScopedPtrAVFree { | 53 class ScopedPtrAVFree { |
| 43 public: | 54 public: |
| 44 inline void operator()(void* x) const { | 55 inline void operator()(void* x) const { |
| 45 av_free(x); | 56 av_free(x); |
| 46 } | 57 } |
| 47 }; | 58 }; |
| 48 | 59 |
| 49 // This assumes that the AVPacket being captured was allocated outside of | 60 // This assumes that the AVPacket being captured was allocated outside of |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 // Converts an FFmpeg audio codec ID into its corresponding supported codec id. | 115 // Converts an FFmpeg audio codec ID into its corresponding supported codec id. |
| 105 AudioCodec CodecIDToAudioCodec(CodecID codec_id); | 116 AudioCodec CodecIDToAudioCodec(CodecID codec_id); |
| 106 | 117 |
| 107 // Closes & destroys all AVStreams in the context and then closes & | 118 // Closes & destroys all AVStreams in the context and then closes & |
| 108 // destroys the AVFormatContext. | 119 // destroys the AVFormatContext. |
| 109 void DestroyAVFormatContext(AVFormatContext* format_context); | 120 void DestroyAVFormatContext(AVFormatContext* format_context); |
| 110 | 121 |
| 111 } // namespace media | 122 } // namespace media |
| 112 | 123 |
| 113 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 124 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| OLD | NEW |