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 #include "media/ffmpeg/ffmpeg_common.h" | 5 #include "media/ffmpeg/ffmpeg_common.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "media/base/decoder_buffer.h" | 9 #include "media/base/decoder_buffer.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 case AV_CODEC_ID_FLAC: | 77 case AV_CODEC_ID_FLAC: |
78 return kCodecFLAC; | 78 return kCodecFLAC; |
79 case AV_CODEC_ID_AMR_NB: | 79 case AV_CODEC_ID_AMR_NB: |
80 return kCodecAMR_NB; | 80 return kCodecAMR_NB; |
81 case AV_CODEC_ID_AMR_WB: | 81 case AV_CODEC_ID_AMR_WB: |
82 return kCodecAMR_WB; | 82 return kCodecAMR_WB; |
83 case AV_CODEC_ID_GSM_MS: | 83 case AV_CODEC_ID_GSM_MS: |
84 return kCodecGSM_MS; | 84 return kCodecGSM_MS; |
85 case AV_CODEC_ID_PCM_MULAW: | 85 case AV_CODEC_ID_PCM_MULAW: |
86 return kCodecPCM_MULAW; | 86 return kCodecPCM_MULAW; |
87 #ifndef CHROMIUM_OMIT_AV_CODEC_ID_OPUS | |
88 case AV_CODEC_ID_OPUS: | 87 case AV_CODEC_ID_OPUS: |
89 return kCodecOpus; | 88 return kCodecOpus; |
90 #endif | |
91 default: | 89 default: |
92 DVLOG(1) << "Unknown audio CodecID: " << codec_id; | 90 DVLOG(1) << "Unknown audio CodecID: " << codec_id; |
93 } | 91 } |
94 return kUnknownAudioCodec; | 92 return kUnknownAudioCodec; |
95 } | 93 } |
96 | 94 |
97 static AVCodecID AudioCodecToCodecID(AudioCodec audio_codec, | 95 static AVCodecID AudioCodecToCodecID(AudioCodec audio_codec, |
98 SampleFormat sample_format) { | 96 SampleFormat sample_format) { |
99 switch (audio_codec) { | 97 switch (audio_codec) { |
100 case kCodecAAC: | 98 case kCodecAAC: |
(...skipping 23 matching lines...) Expand all Loading... |
124 case kCodecFLAC: | 122 case kCodecFLAC: |
125 return AV_CODEC_ID_FLAC; | 123 return AV_CODEC_ID_FLAC; |
126 case kCodecAMR_NB: | 124 case kCodecAMR_NB: |
127 return AV_CODEC_ID_AMR_NB; | 125 return AV_CODEC_ID_AMR_NB; |
128 case kCodecAMR_WB: | 126 case kCodecAMR_WB: |
129 return AV_CODEC_ID_AMR_WB; | 127 return AV_CODEC_ID_AMR_WB; |
130 case kCodecGSM_MS: | 128 case kCodecGSM_MS: |
131 return AV_CODEC_ID_GSM_MS; | 129 return AV_CODEC_ID_GSM_MS; |
132 case kCodecPCM_MULAW: | 130 case kCodecPCM_MULAW: |
133 return AV_CODEC_ID_PCM_MULAW; | 131 return AV_CODEC_ID_PCM_MULAW; |
134 #ifndef CHROMIUM_OMIT_AV_CODEC_ID_OPUS | |
135 case kCodecOpus: | 132 case kCodecOpus: |
136 return AV_CODEC_ID_OPUS; | 133 return AV_CODEC_ID_OPUS; |
137 #endif | |
138 default: | 134 default: |
139 DVLOG(1) << "Unknown AudioCodec: " << audio_codec; | 135 DVLOG(1) << "Unknown AudioCodec: " << audio_codec; |
140 } | 136 } |
141 return AV_CODEC_ID_NONE; | 137 return AV_CODEC_ID_NONE; |
142 } | 138 } |
143 | 139 |
144 VideoCodec CodecIDToVideoCodec(AVCodecID codec_id) { | 140 VideoCodec CodecIDToVideoCodec(AVCodecID codec_id) { |
145 switch (codec_id) { | 141 switch (codec_id) { |
146 case AV_CODEC_ID_H264: | 142 case AV_CODEC_ID_H264: |
147 return kCodecH264; | 143 return kCodecH264; |
148 case AV_CODEC_ID_THEORA: | 144 case AV_CODEC_ID_THEORA: |
149 return kCodecTheora; | 145 return kCodecTheora; |
150 case AV_CODEC_ID_MPEG4: | 146 case AV_CODEC_ID_MPEG4: |
151 return kCodecMPEG4; | 147 return kCodecMPEG4; |
152 case AV_CODEC_ID_VP8: | 148 case AV_CODEC_ID_VP8: |
153 return kCodecVP8; | 149 return kCodecVP8; |
154 #ifndef CHROMIUM_OMIT_AV_CODEC_ID_VP9 | |
155 case AV_CODEC_ID_VP9: | 150 case AV_CODEC_ID_VP9: |
156 return kCodecVP9; | 151 return kCodecVP9; |
157 #endif | |
158 default: | 152 default: |
159 DVLOG(1) << "Unknown video CodecID: " << codec_id; | 153 DVLOG(1) << "Unknown video CodecID: " << codec_id; |
160 } | 154 } |
161 return kUnknownVideoCodec; | 155 return kUnknownVideoCodec; |
162 } | 156 } |
163 | 157 |
164 static AVCodecID VideoCodecToCodecID(VideoCodec video_codec) { | 158 static AVCodecID VideoCodecToCodecID(VideoCodec video_codec) { |
165 switch (video_codec) { | 159 switch (video_codec) { |
166 case kCodecH264: | 160 case kCodecH264: |
167 return AV_CODEC_ID_H264; | 161 return AV_CODEC_ID_H264; |
168 case kCodecTheora: | 162 case kCodecTheora: |
169 return AV_CODEC_ID_THEORA; | 163 return AV_CODEC_ID_THEORA; |
170 case kCodecMPEG4: | 164 case kCodecMPEG4: |
171 return AV_CODEC_ID_MPEG4; | 165 return AV_CODEC_ID_MPEG4; |
172 case kCodecVP8: | 166 case kCodecVP8: |
173 return AV_CODEC_ID_VP8; | 167 return AV_CODEC_ID_VP8; |
174 #ifndef CHROMIUM_OMIT_AV_CODEC_ID_VP9 | |
175 case kCodecVP9: | 168 case kCodecVP9: |
176 return AV_CODEC_ID_VP9; | 169 return AV_CODEC_ID_VP9; |
177 #endif | |
178 default: | 170 default: |
179 DVLOG(1) << "Unknown VideoCodec: " << video_codec; | 171 DVLOG(1) << "Unknown VideoCodec: " << video_codec; |
180 } | 172 } |
181 return AV_CODEC_ID_NONE; | 173 return AV_CODEC_ID_NONE; |
182 } | 174 } |
183 | 175 |
184 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) { | 176 static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) { |
185 // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the | 177 // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the |
186 // corresponding profiles with which they're used. | 178 // corresponding profiles with which they're used. |
187 profile &= ~FF_PROFILE_H264_CONSTRAINED; | 179 profile &= ~FF_PROFILE_H264_CONSTRAINED; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 return PIX_FMT_YUV420P; | 504 return PIX_FMT_YUV420P; |
513 case VideoFrame::YV12A: | 505 case VideoFrame::YV12A: |
514 return PIX_FMT_YUVA420P; | 506 return PIX_FMT_YUVA420P; |
515 default: | 507 default: |
516 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 508 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
517 } | 509 } |
518 return PIX_FMT_NONE; | 510 return PIX_FMT_NONE; |
519 } | 511 } |
520 | 512 |
521 } // namespace media | 513 } // namespace media |
OLD | NEW |