MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / get_audio_flags

Function get_audio_flags

libavformat/flvenc.c:140–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138} FLVContext;
139
140static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
141{
142 int flags = (par->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT
143 : FLV_SAMPLESSIZE_8BIT;
144
145 if (par->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
146 return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ |
147 FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
148 if (par->codec_id == AV_CODEC_ID_OPUS || par->codec_id == AV_CODEC_ID_FLAC
149 || par->codec_id == AV_CODEC_ID_AC3 || par->codec_id == AV_CODEC_ID_EAC3)
150 return FLV_CODECID_EX_HEADER; // only needed for codec support check
151 else if (par->codec_id == AV_CODEC_ID_SPEEX) {
152 if (par->sample_rate != 16000) {
153 av_log(s, AV_LOG_ERROR,
154 "FLV only supports wideband (16kHz) Speex audio\n");
155 return AVERROR(EINVAL);
156 }
157 if (par->ch_layout.nb_channels != 1) {
158 av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
159 return AVERROR(EINVAL);
160 }
161 return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
162 } else {
163 switch (par->sample_rate) {
164 case 48000:
165 // 48khz mp3 is stored with 44k1 samplerate identifier
166 if (par->codec_id == AV_CODEC_ID_MP3) {
167 flags |= FLV_SAMPLERATE_44100HZ;
168 break;
169 } else {
170 goto error;
171 }
172 case 44100:
173 flags |= FLV_SAMPLERATE_44100HZ;
174 break;
175 case 22050:
176 flags |= FLV_SAMPLERATE_22050HZ;
177 break;
178 case 11025:
179 flags |= FLV_SAMPLERATE_11025HZ;
180 break;
181 case 16000: // nellymoser only
182 case 8000: // nellymoser only
183 case 5512: // not MP3
184 if (par->codec_id != AV_CODEC_ID_MP3) {
185 flags |= FLV_SAMPLERATE_SPECIAL;
186 break;
187 }
188 default:
189error:
190 av_log(s, AV_LOG_ERROR,
191 "FLV does not support sample rate %d, "
192 "choose from (44100, 22050, 11025)\n", par->sample_rate);
193 return AVERROR(EINVAL);
194 }
195 }
196
197 if (par->ch_layout.nb_channels > 1)

Callers 3

flv_write_codec_headerFunction · 0.85
flv_initFunction · 0.85
flv_write_packetFunction · 0.85

Calls 2

av_logFunction · 0.85
avcodec_get_nameFunction · 0.85

Tested by

no test coverage detected