MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / add_ffmpeg_audio

Function add_ffmpeg_audio

libhb/stream.c:5480–5645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5478}
5479
5480static void add_ffmpeg_audio(hb_title_t *title, hb_stream_t *stream, int id)
5481{
5482 AVStream *st = stream->ffmpeg_ic->streams[id];
5483 AVCodecParameters * codecpar = st->codecpar;
5484 AVDictionaryEntry * tag_lang = av_dict_get(st->metadata, "language", NULL, 0);
5485 iso639_lang_t * lang = lang_for_code2(tag_lang != NULL ?
5486 tag_lang->value : "und");
5487 const char * name = ffmpeg_track_name(st, lang->iso639_2);
5488
5489 hb_audio_t * audio = calloc(1, sizeof(*audio));
5490 int ii;
5491 for (ii = 0; ii < st->codecpar->nb_coded_side_data; ii++)
5492 {
5493 AVPacketSideData *sd = &st->codecpar->coded_side_data[ii];
5494 switch (sd->type)
5495 {
5496 case AV_PKT_DATA_FALLBACK_TRACK:
5497 {
5498 if (sd->size == sizeof(int))
5499 {
5500 int fallback = *(int*)sd->data;
5501 if (audio->config.list_linked_index == NULL)
5502 {
5503 audio->config.list_linked_index = hb_list_init();
5504 }
5505 // This is not actually the "right" index to store
5506 // in list_linked_index. But we need the complete
5507 // audio list before we can correct it.
5508 //
5509 // This gets corrected in find_ffmpeg_fallback_audio
5510 // after all tracks have been scanned.
5511 hb_list_add_dup(audio->config.list_linked_index,
5512 &fallback, sizeof(fallback));
5513 }
5514 } break;
5515
5516 default:
5517 break;
5518 }
5519 }
5520 audio->id = id;
5521 audio->config.index = hb_list_count(title->list_audio);
5522 audio->config.in.track = id;
5523 audio->config.in.codec = HB_ACODEC_FFMPEG;
5524 audio->config.in.codec_param = codecpar->codec_id;
5525 // set the bitrate to 0; decavcodecaBSInfo will be called and fill the rest
5526 audio->config.in.bitrate = 0;
5527 audio->config.in.encoder_delay = codecpar->initial_padding;
5528
5529 // If we ever improve our pipeline to allow other time bases...
5530 // audio->config.in.timebase.num = st->time_base.num;
5531 // audio->config.in.timebase.den = st->time_base.den;
5532 audio->config.in.timebase.num = 1;
5533 audio->config.in.timebase.den = 90000;
5534
5535 // set the input codec and extradata for Passthru
5536 switch (codecpar->codec_id)
5537 {

Callers 1

ffmpeg_title_scanFunction · 0.85

Calls 8

lang_for_code2Function · 0.85
ffmpeg_track_nameFunction · 0.85
hb_list_initFunction · 0.85
hb_list_add_dupFunction · 0.85
hb_list_countFunction · 0.85
hb_set_extradataFunction · 0.85
set_audio_descriptionFunction · 0.85
hb_list_addFunction · 0.85

Tested by

no test coverage detected