OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/channel_layout.h" | 15 #include "media/base/channel_layout.h" |
15 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
16 #include "media/video/video_decode_engine.h" | 17 #include "media/video/video_decode_engine.h" |
17 | 18 |
18 // Include FFmpeg header files. | 19 // Include FFmpeg header files. |
19 extern "C" { | 20 extern "C" { |
20 // Temporarily disable possible loss of data warning. | 21 // Temporarily disable possible loss of data warning. |
21 // TODO(scherkus): fix and upstream the compiler warnings. | 22 // TODO(scherkus): fix and upstream the compiler warnings. |
22 MSVC_PUSH_DISABLE_WARNING(4244); | 23 MSVC_PUSH_DISABLE_WARNING(4244); |
23 #include <libavcodec/avcodec.h> | 24 #include <libavcodec/avcodec.h> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 MEDIA_EXPORT base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, | 59 MEDIA_EXPORT base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, |
59 int64 timestamp); | 60 int64 timestamp); |
60 | 61 |
61 // Converts a base::TimeDelta into an int64 timestamp in |time_base| units. | 62 // Converts a base::TimeDelta into an int64 timestamp in |time_base| units. |
62 // For example if |timestamp| is 0.5 seconds and |time_base| is {1, 44100}, then | 63 // For example if |timestamp| is 0.5 seconds and |time_base| is {1, 44100}, then |
63 // the return value will be 22050 since that is how many 1/44100ths of a second | 64 // the return value will be 22050 since that is how many 1/44100ths of a second |
64 // represent 0.5 seconds. | 65 // represent 0.5 seconds. |
65 MEDIA_EXPORT int64 ConvertToTimeBase(const AVRational& time_base, | 66 MEDIA_EXPORT int64 ConvertToTimeBase(const AVRational& time_base, |
66 const base::TimeDelta& timestamp); | 67 const base::TimeDelta& timestamp); |
67 | 68 |
| 69 void AVCodecContextToAudioDecoderConfig( |
| 70 const AVCodecContext* codec_context, |
| 71 AudioDecoderConfig* config); |
| 72 void AudioDecoderConfigToAVCodecContext( |
| 73 const AudioDecoderConfig& config, |
| 74 AVCodecContext* codec_context); |
| 75 |
68 VideoCodec CodecIDToVideoCodec(CodecID codec_id); | 76 VideoCodec CodecIDToVideoCodec(CodecID codec_id); |
69 CodecID VideoCodecToCodecID(VideoCodec video_codec); | 77 CodecID VideoCodecToCodecID(VideoCodec video_codec); |
70 | 78 |
71 // Converts FFmpeg's channel layout to chrome's ChannelLayout. |channels| can | 79 // Converts FFmpeg's channel layout to chrome's ChannelLayout. |channels| can |
72 // be used when FFmpeg's channel layout is not informative in order to make a | 80 // be used when FFmpeg's channel layout is not informative in order to make a |
73 // good guess about the plausible channel layout based on number of channels. | 81 // good guess about the plausible channel layout based on number of channels. |
74 ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, | 82 ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, |
75 int channels); | 83 int channels); |
76 | 84 |
77 // Calculates duration of one frame in the |stream| based on its frame rate. | 85 // Calculates duration of one frame in the |stream| based on its frame rate. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 int GetNaturalHeight(AVStream* stream); | 118 int GetNaturalHeight(AVStream* stream); |
111 int GetNaturalWidth(AVStream* stream); | 119 int GetNaturalWidth(AVStream* stream); |
112 | 120 |
113 // Closes & destroys all AVStreams in the context and then closes & | 121 // Closes & destroys all AVStreams in the context and then closes & |
114 // destroys the AVFormatContext. | 122 // destroys the AVFormatContext. |
115 void DestroyAVFormatContext(AVFormatContext* format_context); | 123 void DestroyAVFormatContext(AVFormatContext* format_context); |
116 | 124 |
117 } // namespace media | 125 } // namespace media |
118 | 126 |
119 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 127 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
OLD | NEW |