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/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/channel_layout.h" | 14 #include "media/base/channel_layout.h" |
15 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
16 #include "media/base/video_decoder_config.h" | 16 #include "media/base/video_decoder_config.h" |
17 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
18 #include "media/ffmpeg/ffmpeg_deleters.h" | 18 #include "media/ffmpeg/ffmpeg_deleters.h" |
19 | 19 |
20 // Include FFmpeg header files. | 20 // Include FFmpeg header files. |
21 extern "C" { | 21 extern "C" { |
22 // Disable deprecated features which result in spammy compile warnings. This | |
23 // list of defines must mirror those in the 'defines' section of the ffmpeg.gyp | |
24 // file or the headers below will generate different structures. | |
25 #define FF_API_PIX_FMT_DESC 0 | |
wolenetz
2014/05/20 22:37:10
I would prefer these be exported by ffmpeg.gyp and
DaleCurtis
2014/05/20 23:00:45
Hmm, I don't really like using direct_dependent_se
| |
26 #define FF_API_OLD_DECODE_AUDIO 0 | |
27 #define FF_API_DESTRUCT_PACKET 0 | |
28 #define FF_API_GET_BUFFER 0 | |
29 | |
22 // Temporarily disable possible loss of data warning. | 30 // Temporarily disable possible loss of data warning. |
23 // TODO(scherkus): fix and upstream the compiler warnings. | 31 // TODO(scherkus): fix and upstream the compiler warnings. |
24 MSVC_PUSH_DISABLE_WARNING(4244); | 32 MSVC_PUSH_DISABLE_WARNING(4244); |
25 #include <libavcodec/avcodec.h> | 33 #include <libavcodec/avcodec.h> |
26 #include <libavformat/avformat.h> | 34 #include <libavformat/avformat.h> |
27 #include <libavformat/avio.h> | 35 #include <libavformat/avio.h> |
28 #include <libavutil/audioconvert.h> | 36 #include <libavutil/audioconvert.h> |
29 #include <libavutil/avutil.h> | 37 #include <libavutil/avutil.h> |
30 #include <libavutil/mathematics.h> | 38 #include <libavutil/mathematics.h> |
31 #include <libavutil/log.h> | 39 #include <libavutil/log.h> |
(...skipping 22 matching lines...) Expand all Loading... | |
54 | 62 |
55 inline void ScopedPtrAVFreeContext::operator()(void* x) const { | 63 inline void ScopedPtrAVFreeContext::operator()(void* x) const { |
56 AVCodecContext* codec_context = static_cast<AVCodecContext*>(x); | 64 AVCodecContext* codec_context = static_cast<AVCodecContext*>(x); |
57 av_free(codec_context->extradata); | 65 av_free(codec_context->extradata); |
58 avcodec_close(codec_context); | 66 avcodec_close(codec_context); |
59 av_free(codec_context); | 67 av_free(codec_context); |
60 } | 68 } |
61 | 69 |
62 inline void ScopedPtrAVFreeFrame::operator()(void* x) const { | 70 inline void ScopedPtrAVFreeFrame::operator()(void* x) const { |
63 AVFrame* frame = static_cast<AVFrame*>(x); | 71 AVFrame* frame = static_cast<AVFrame*>(x); |
64 avcodec_free_frame(&frame); | 72 av_frame_free(&frame); |
65 } | 73 } |
66 | 74 |
67 // Converts an int64 timestamp in |time_base| units to a base::TimeDelta. | 75 // Converts an int64 timestamp in |time_base| units to a base::TimeDelta. |
68 // For example if |timestamp| equals 11025 and |time_base| equals {1, 44100} | 76 // For example if |timestamp| equals 11025 and |time_base| equals {1, 44100} |
69 // then the return value will be a base::TimeDelta for 0.25 seconds since that | 77 // then the return value will be a base::TimeDelta for 0.25 seconds since that |
70 // is how much time 11025/44100ths of a second represents. | 78 // is how much time 11025/44100ths of a second represents. |
71 MEDIA_EXPORT base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, | 79 MEDIA_EXPORT base::TimeDelta ConvertFromTimeBase(const AVRational& time_base, |
72 int64 timestamp); | 80 int64 timestamp); |
73 | 81 |
74 // Converts a base::TimeDelta into an int64 timestamp in |time_base| units. | 82 // Converts a base::TimeDelta into an int64 timestamp in |time_base| units. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format); | 126 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format); |
119 | 127 |
120 // Convert FFmpeg UTC representation (YYYY-MM-DD HH:MM:SS) to base::Time. | 128 // Convert FFmpeg UTC representation (YYYY-MM-DD HH:MM:SS) to base::Time. |
121 // Returns true and sets |*out| if |date_utc| contains a valid | 129 // Returns true and sets |*out| if |date_utc| contains a valid |
122 // date string. Otherwise returns fals and timeline_offset is unmodified. | 130 // date string. Otherwise returns fals and timeline_offset is unmodified. |
123 MEDIA_EXPORT bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out); | 131 MEDIA_EXPORT bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out); |
124 | 132 |
125 } // namespace media | 133 } // namespace media |
126 | 134 |
127 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 135 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
OLD | NEW |