summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.c3
-rw-r--r--libhb/common.h2
-rw-r--r--libhb/deca52.c8
-rw-r--r--libhb/decavcodec.c22
-rw-r--r--libhb/declpcm.c1
-rw-r--r--libhb/scan.c40
6 files changed, 69 insertions, 7 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 813ece48e..720ff4976 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -3431,7 +3431,8 @@ void hb_audio_config_init(hb_audio_config_t * audiocfg)
audiocfg->in.samplerate = -1;
audiocfg->in.samples_per_frame = -1;
audiocfg->in.bitrate = -1;
- audiocfg->in.channel_layout = -1;
+ audiocfg->in.matrix_encoding = AV_MATRIX_ENCODING_NONE;
+ audiocfg->in.channel_layout = 0;
audiocfg->in.channel_map = NULL;
audiocfg->lang.description[0] = 0;
audiocfg->lang.simple[0] = 0;
diff --git a/libhb/common.h b/libhb/common.h
index cf037e579..eece75e55 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -677,6 +677,7 @@ struct hb_audio_config_s
PRIVATE int samplerate; /* Input sample rate (Hz) */
PRIVATE int samples_per_frame; /* Number of samples per frame */
PRIVATE int bitrate; /* Input bitrate (bps) */
+ PRIVATE int matrix_encoding; /* Source matrix encoding mode, set by the audio decoder */
PRIVATE uint64_t channel_layout; /* Source channel layout, set by the audio decoder */
PRIVATE hb_chan_map_t * channel_map; /* Source channel map, set by the audio decoder */
} in;
@@ -1010,6 +1011,7 @@ typedef struct hb_work_info_s
uint64_t channel_layout;
hb_chan_map_t * channel_map;
int samples_per_frame;
+ int matrix_encoding;
};
};
} hb_work_info_t;
diff --git a/libhb/deca52.c b/libhb/deca52.c
index 5dde0378a..015d00b39 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -537,6 +537,14 @@ static int deca52BSInfo( hb_work_object_t *w, const hb_buffer_t *b,
info->mode = raw & 0x7; /* bsmod is the following 3 bits */
info->samples_per_frame = 1536;
+ if ((flags & A52_CHANNEL_MASK) == A52_DOLBY)
+ {
+ info->matrix_encoding = AV_MATRIX_ENCODING_DOLBY;
+ }
+ else
+ {
+ info->matrix_encoding = AV_MATRIX_ENCODING_NONE;
+ }
info->channel_layout = (acmod2layout[(flags & A52_CHANNEL_MASK)] |
lfeon2layout[(flags & A52_LFE) != 0]);
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 1e760583b..73692de5f 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -721,10 +721,30 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
if (truehd_mono)
{
info->channel_layout = AV_CH_LAYOUT_MONO;
+ info->matrix_encoding = AV_MATRIX_ENCODING_NONE;
}
else
{
- info->channel_layout = frame->channel_layout;
+ AVFrameSideData *side_data;
+ if ((side_data =
+ av_frame_get_side_data(frame,
+ AV_FRAME_DATA_MATRIXENCODING)) != NULL)
+ {
+ info->matrix_encoding = *side_data->data;
+ }
+ else
+ {
+ info->matrix_encoding = AV_MATRIX_ENCODING_NONE;
+ }
+ if (info->matrix_encoding == AV_MATRIX_ENCODING_DOLBY ||
+ info->matrix_encoding == AV_MATRIX_ENCODING_DPLII)
+ {
+ info->channel_layout = AV_CH_LAYOUT_STEREO_DOWNMIX;
+ }
+ else
+ {
+ info->channel_layout = frame->channel_layout;
+ }
}
ret = 1;
diff --git a/libhb/declpcm.c b/libhb/declpcm.c
index a8f2e32d4..156b58056 100644
--- a/libhb/declpcm.c
+++ b/libhb/declpcm.c
@@ -378,6 +378,7 @@ static int declpcmBSInfo( hb_work_object_t *w, const hb_buffer_t *b,
info->rate_base = 1;
info->bitrate = bitrate;
info->flags = ( b->data[3] << 16 ) | ( b->data[4] << 8 ) | b->data[5];
+ info->matrix_encoding = AV_MATRIX_ENCODING_NONE;
info->channel_layout = hdr2layout[nchannels - 1];
info->channel_map = &hb_libav_chan_map;
info->samples_per_frame = ( duration * rate ) / 90000;
diff --git a/libhb/scan.c b/libhb/scan.c
index 6dc5f6fc6..fc13810ed 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -1029,6 +1029,7 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
audio->config.in.samplerate = info.rate;
audio->config.in.samples_per_frame = info.samples_per_frame;
audio->config.in.bitrate = info.bitrate;
+ audio->config.in.matrix_encoding = info.matrix_encoding;
audio->config.in.channel_layout = info.channel_layout;
audio->config.in.channel_map = info.channel_map;
audio->config.in.version = info.version;
@@ -1145,11 +1146,7 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
break;
}
- if (audio->config.in.channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
- {
- strcat(audio->config.lang.description, " (Dolby Surround)");
- }
- else if (audio->config.in.channel_layout)
+ if (audio->config.in.channel_layout)
{
int lfes = (!!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY) +
!!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY_2));
@@ -1157,6 +1154,39 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
char *desc = audio->config.lang.description +
strlen(audio->config.lang.description);
sprintf(desc, " (%d.%d ch)", channels - lfes, lfes);
+
+ // describe the matrix encoding mode, if any
+ switch (audio->config.in.matrix_encoding)
+ {
+ case AV_MATRIX_ENCODING_DOLBY:
+ if (audio->config.in.codec == HB_ACODEC_AC3 ||
+ audio->config.in.codec_param == AV_CODEC_ID_AC3 ||
+ audio->config.in.codec_param == AV_CODEC_ID_EAC3 ||
+ audio->config.in.codec_param == AV_CODEC_ID_TRUEHD)
+ {
+ strcat(audio->config.lang.description, " (Dolby Surround)");
+ break;
+ }
+ strcat(audio->config.lang.description, " (Lt/Rt)");
+ break;
+ case AV_MATRIX_ENCODING_DPLII:
+ strcat(audio->config.lang.description, " (Dolby Pro Logic II)");
+ break;
+ case AV_MATRIX_ENCODING_DPLIIX:
+ strcat(audio->config.lang.description, " (Dolby Pro Logic IIx)");
+ break;
+ case AV_MATRIX_ENCODING_DPLIIZ:
+ strcat(audio->config.lang.description, " (Dolby Pro Logic IIz)");
+ break;
+ case AV_MATRIX_ENCODING_DOLBYEX:
+ strcat(audio->config.lang.description, " (Dolby Digital EX)");
+ break;
+ case AV_MATRIX_ENCODING_DOLBYHEADPHONE:
+ strcat(audio->config.lang.description, " (Dolby Headphone)");
+ break;
+ default:
+ break;
+ }
}
hb_log( "scan: audio 0x%x: %s, rate=%dHz, bitrate=%d %s", audio->id,