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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 MEDIA_EXPORT int64 ConvertToTimeBase(const AVRational& time_base, | 67 MEDIA_EXPORT int64 ConvertToTimeBase(const AVRational& time_base, |
68 const base::TimeDelta& timestamp); | 68 const base::TimeDelta& timestamp); |
69 | 69 |
70 void AVCodecContextToAudioDecoderConfig( | 70 void AVCodecContextToAudioDecoderConfig( |
71 const AVCodecContext* codec_context, | 71 const AVCodecContext* codec_context, |
72 AudioDecoderConfig* config); | 72 AudioDecoderConfig* config); |
73 void AudioDecoderConfigToAVCodecContext( | 73 void AudioDecoderConfigToAVCodecContext( |
74 const AudioDecoderConfig& config, | 74 const AudioDecoderConfig& config, |
75 AVCodecContext* codec_context); | 75 AVCodecContext* codec_context); |
76 | 76 |
77 VideoCodec CodecIDToVideoCodec(CodecID codec_id); | 77 void AVStreamToVideoDecoderConfig( |
78 CodecID VideoCodecToCodecID(VideoCodec video_codec); | 78 const AVStream* stream, |
| 79 VideoDecoderConfig* config); |
| 80 void VideoDecoderConfigToAVCodecContext( |
| 81 const VideoDecoderConfig& config, |
| 82 AVCodecContext* codec_context); |
79 | 83 |
80 // Converts FFmpeg's channel layout to chrome's ChannelLayout. |channels| can | 84 // Converts FFmpeg's channel layout to chrome's ChannelLayout. |channels| can |
81 // be used when FFmpeg's channel layout is not informative in order to make a | 85 // be used when FFmpeg's channel layout is not informative in order to make a |
82 // good guess about the plausible channel layout based on number of channels. | 86 // good guess about the plausible channel layout based on number of channels. |
83 ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, | 87 ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, |
84 int channels); | 88 int channels); |
85 | 89 |
86 // Converts FFmpeg's pixel formats to its corresponding supported video format. | 90 // Converts FFmpeg's pixel formats to its corresponding supported video format. |
87 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format); | 91 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format); |
88 | 92 |
89 // Converts video formats to its corresponding FFmpeg's pixel formats. | 93 // Converts video formats to its corresponding FFmpeg's pixel formats. |
90 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format); | 94 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format); |
91 | 95 |
92 // Calculates duration of one frame in the |stream| based on its frame rate. | 96 // Calculates the duration of one frame based on the frame rate specified by |
93 base::TimeDelta GetFrameDuration(AVStream* stream); | 97 // |config|. |
94 | 98 base::TimeDelta GetFrameDuration(const VideoDecoderConfig& config); |
95 // Calculates the natural width and height of the video using the video's | |
96 // encoded dimensions and sample_aspect_ratio. | |
97 gfx::Size GetNaturalSize(AVStream* stream); | |
98 | 99 |
99 // Closes & destroys all AVStreams in the context and then closes & | 100 // Closes & destroys all AVStreams in the context and then closes & |
100 // destroys the AVFormatContext. | 101 // destroys the AVFormatContext. |
101 void DestroyAVFormatContext(AVFormatContext* format_context); | 102 void DestroyAVFormatContext(AVFormatContext* format_context); |
102 | 103 |
103 } // namespace media | 104 } // namespace media |
104 | 105 |
105 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 106 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
OLD | NEW |