info->sample_bit_depth = context->bits_per_raw_sample;
int bps = av_get_bits_per_sample(context->codec_id);
- int channels = av_get_channel_layout_nb_channels(frame->channel_layout);
- if (bps > 0)
+ int channels;
+ if (frame->channel_layout != 0)
{
- info->bitrate = bps * channels * info->rate.num;
+ channels = av_get_channel_layout_nb_channels(
+ frame->channel_layout);
}
- else if (context->bit_rate > 0)
+ else
{
- info->bitrate = context->bit_rate;
+ channels = frame->channels;
}
- else
+
+ info->bitrate = bps * channels * info->rate.num;
+ if (info->bitrate <= 0)
{
- info->bitrate = 1;
+ if (context->bit_rate > 0)
+ {
+ info->bitrate = context->bit_rate;
+ }
+ else
+ {
+ info->bitrate = 1;
+ }
}
if (truehd_mono)
info->channel_layout = frame->channel_layout;
}
}
+ if (info->channel_layout == 0)
+ {
+ // Channel layout was not set. Guess a layout based
+ // on number of channels.
+ info->channel_layout = av_get_default_channel_layout(
+ frame->channels);
+ }
if (context->codec_id == AV_CODEC_ID_AC3 ||
context->codec_id == AV_CODEC_ID_EAC3)
{
else
{
AVFrameSideData *side_data;
+ uint64_t channel_layout;
if ((side_data =
av_frame_get_side_data(pv->frame,
AV_FRAME_DATA_DOWNMIX_INFO)) != NULL)
center_mix_level,
downmix_info->lfe_mix_level);
}
- hb_audio_resample_set_channel_layout(pv->resample,
- pv->frame->channel_layout);
+ channel_layout = pv->frame->channel_layout;
+ if (channel_layout == 0)
+ {
+ channel_layout = av_get_default_channel_layout(
+ pv->frame->channels);
+ }
+ hb_audio_resample_set_channel_layout(pv->resample, channel_layout);
hb_audio_resample_set_sample_fmt(pv->resample,
pv->frame->format);
if (hb_audio_resample_update(pv->resample))