| 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 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 // Used for FFmpeg error codes. | 10 // Used for FFmpeg error codes. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // Converts a base::TimeDelta into an int64_t timestamp in |time_base| units. | 89 // Converts a base::TimeDelta into an int64_t timestamp in |time_base| units. |
| 90 // For example if |timestamp| is 0.5 seconds and |time_base| is {1, 44100}, then | 90 // For example if |timestamp| is 0.5 seconds and |time_base| is {1, 44100}, then |
| 91 // the return value will be 22050 since that is how many 1/44100ths of a second | 91 // the return value will be 22050 since that is how many 1/44100ths of a second |
| 92 // represent 0.5 seconds. | 92 // represent 0.5 seconds. |
| 93 MEDIA_EXPORT int64_t ConvertToTimeBase(const AVRational& time_base, | 93 MEDIA_EXPORT int64_t ConvertToTimeBase(const AVRational& time_base, |
| 94 const base::TimeDelta& timestamp); | 94 const base::TimeDelta& timestamp); |
| 95 | 95 |
| 96 // Converts an FFmpeg audio codec ID into its corresponding supported codec id. | 96 // Converts an FFmpeg audio codec ID into its corresponding supported codec id. |
| 97 MEDIA_EXPORT AudioCodec CodecIDToAudioCodec(AVCodecID codec_id); | 97 MEDIA_EXPORT AudioCodec CodecIDToAudioCodec(AVCodecID codec_id); |
| 98 | 98 |
| 99 // Allocates, populates and returns a wrapped AVCodecContext from the |
| 100 // AVCodecParameters in |stream|. On failure, returns a wrapped nullptr. |
| 101 // Wrapping helps ensure eventual destruction of the AVCodecContext. |
| 102 MEDIA_EXPORT std::unique_ptr<AVCodecContext, ScopedPtrAVFreeContext> |
| 103 AVStreamToAVCodecContext(const AVStream* stream); |
| 104 |
| 99 // Returns true if AVStream is successfully converted to a AudioDecoderConfig. | 105 // Returns true if AVStream is successfully converted to a AudioDecoderConfig. |
| 100 // Returns false if conversion fails, in which case |config| is not modified. | 106 // Returns false if conversion fails, in which case |config| is not modified. |
| 101 MEDIA_EXPORT bool AVStreamToAudioDecoderConfig(const AVStream* stream, | 107 MEDIA_EXPORT bool AVStreamToAudioDecoderConfig(const AVStream* stream, |
| 102 AudioDecoderConfig* config); | 108 AudioDecoderConfig* config); |
| 103 void AudioDecoderConfigToAVCodecContext( | 109 void AudioDecoderConfigToAVCodecContext( |
| 104 const AudioDecoderConfig& config, | 110 const AudioDecoderConfig& config, |
| 105 AVCodecContext* codec_context); | 111 AVCodecContext* codec_context); |
| 106 | 112 |
| 107 // Returns true if AVStream is successfully converted to a VideoDecoderConfig. | 113 // Returns true if AVStream is successfully converted to a VideoDecoderConfig. |
| 108 // Returns false if conversion fails, in which case |config| is not modified. | 114 // Returns false if conversion fails, in which case |config| is not modified. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 137 // Converts FFmpeg's pixel formats to its corresponding supported video format. | 143 // Converts FFmpeg's pixel formats to its corresponding supported video format. |
| 138 MEDIA_EXPORT VideoPixelFormat | 144 MEDIA_EXPORT VideoPixelFormat |
| 139 AVPixelFormatToVideoPixelFormat(AVPixelFormat pixel_format); | 145 AVPixelFormatToVideoPixelFormat(AVPixelFormat pixel_format); |
| 140 | 146 |
| 141 // Converts video formats to its corresponding FFmpeg's pixel formats. | 147 // Converts video formats to its corresponding FFmpeg's pixel formats. |
| 142 AVPixelFormat VideoPixelFormatToAVPixelFormat(VideoPixelFormat video_format); | 148 AVPixelFormat VideoPixelFormatToAVPixelFormat(VideoPixelFormat video_format); |
| 143 | 149 |
| 144 ColorSpace AVColorSpaceToColorSpace(AVColorSpace color_space, | 150 ColorSpace AVColorSpaceToColorSpace(AVColorSpace color_space, |
| 145 AVColorRange color_range); | 151 AVColorRange color_range); |
| 146 | 152 |
| 147 // Convert FFmpeg UTC representation (YYYY-MM-DD HH:MM:SS) to base::Time. | |
| 148 // Returns true and sets |*out| if |date_utc| contains a valid | |
| 149 // date string. Otherwise returns fals and timeline_offset is unmodified. | |
| 150 MEDIA_EXPORT bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out); | |
| 151 | |
| 152 // Returns a 32-bit hash for the given codec name. See the VerifyUmaCodecHashes | 153 // Returns a 32-bit hash for the given codec name. See the VerifyUmaCodecHashes |
| 153 // unit test for more information and code for generating the histogram XML. | 154 // unit test for more information and code for generating the histogram XML. |
| 154 MEDIA_EXPORT int32_t HashCodecName(const char* codec_name); | 155 MEDIA_EXPORT int32_t HashCodecName(const char* codec_name); |
| 155 | 156 |
| 156 } // namespace media | 157 } // namespace media |
| 157 | 158 |
| 158 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 159 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| OLD | NEW |