| 3322 | } |
| 3323 | |
| 3324 | static void new_audio_stream(AVFormatContext *oc) |
| 3325 | { |
| 3326 | AVStream *st; |
| 3327 | AVCodecContext *audio_enc; |
| 3328 | enum CodecID codec_id; |
| 3329 | |
| 3330 | st = av_new_stream(oc, oc->nb_streams); |
| 3331 | if (!st) { |
| 3332 | fprintf(stderr, "Could not alloc stream\n"); |
| 3333 | av_exit(1); |
| 3334 | } |
| 3335 | avcodec_get_context_defaults2(st->codec, AVMEDIA_TYPE_AUDIO); |
| 3336 | |
| 3337 | bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters; |
| 3338 | audio_bitstream_filters= NULL; |
| 3339 | |
| 3340 | avcodec_thread_init(st->codec, thread_count); |
| 3341 | |
| 3342 | audio_enc = st->codec; |
| 3343 | audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; |
| 3344 | |
| 3345 | if(audio_codec_tag) |
| 3346 | audio_enc->codec_tag= audio_codec_tag; |
| 3347 | |
| 3348 | if (oc->oformat->flags & AVFMT_GLOBALHEADER) { |
| 3349 | audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; |
| 3350 | avcodec_opts[AVMEDIA_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER; |
| 3351 | } |
| 3352 | if (audio_stream_copy) { |
| 3353 | st->stream_copy = 1; |
| 3354 | audio_enc->channels = audio_channels; |
| 3355 | audio_enc->sample_rate = audio_sample_rate; |
| 3356 | } else { |
| 3357 | AVCodec *codec; |
| 3358 | |
| 3359 | set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM); |
| 3360 | |
| 3361 | if (audio_codec_name) { |
| 3362 | codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1, |
| 3363 | audio_enc->strict_std_compliance); |
| 3364 | codec = avcodec_find_encoder_by_name(audio_codec_name); |
| 3365 | output_codecs[nb_ocodecs] = codec; |
| 3366 | } else { |
| 3367 | codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_AUDIO); |
| 3368 | codec = avcodec_find_encoder(codec_id); |
| 3369 | } |
| 3370 | audio_enc->codec_id = codec_id; |
| 3371 | |
| 3372 | if (audio_qscale > QSCALE_NONE) { |
| 3373 | audio_enc->flags |= CODEC_FLAG_QSCALE; |
| 3374 | audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale; |
| 3375 | } |
| 3376 | audio_enc->channels = audio_channels; |
| 3377 | audio_enc->sample_fmt = audio_sample_fmt; |
| 3378 | audio_enc->sample_rate = audio_sample_rate; |
| 3379 | audio_enc->channel_layout = channel_layout; |
| 3380 | if (avcodec_channel_layout_num_channels(channel_layout) != audio_channels) |
| 3381 | audio_enc->channel_layout = 0; |
no test coverage detected