Try to use HBR (High Bit-Rate) for EAC3.

This commit is contained in:
Johns 2013-02-11 23:40:09 +01:00
parent 2cd667fb44
commit 54255e7b57
3 changed files with 46 additions and 12 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Date: Date:
Try to use HBR (High Bit-Rate) for EAC3.
Improved pass-through (PCM+EAC3) support. Improved pass-through (PCM+EAC3) support.
Support VDR 1.7.36 new build system. Support VDR 1.7.36 new build system.
Improves VDPAU display preemption handling. Improves VDPAU display preemption handling.

25
audio.c
View File

@ -178,7 +178,7 @@ enum _audio_rates
//Audio88200, ///< 88.2Khz //Audio88200, ///< 88.2Khz
//Audio96000, ///< 96.0Khz //Audio96000, ///< 96.0Khz
//Audio176400, ///< 176.4Khz //Audio176400, ///< 176.4Khz
//Audio192000, ///< 192.0Khz Audio192000, ///< 192.0Khz
AudioRatesMax ///< max index AudioRatesMax ///< max index
}; };
@ -190,7 +190,7 @@ static int AudioChannelMatrix[AudioRatesMax][9];
/// rates tables (must be sorted by frequency) /// rates tables (must be sorted by frequency)
static const unsigned AudioRatesTable[AudioRatesMax] = { static const unsigned AudioRatesTable[AudioRatesMax] = {
44100, 48000, 44100, 48000, 192000
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -2794,6 +2794,7 @@ void AudioInit(void)
// Check which channels/rates/formats are supported // Check which channels/rates/formats are supported
// FIXME: we force 44.1Khz and 48Khz must be supported equal // FIXME: we force 44.1Khz and 48Khz must be supported equal
// FIXME: should use bitmap of channels supported in RatesInHw // FIXME: should use bitmap of channels supported in RatesInHw
// FIXME: use loop over sample-rates
freq = 44100; freq = 44100;
AudioRatesInHw[Audio44100] = 0; AudioRatesInHw[Audio44100] = 0;
for (chan = 1; chan < 9; ++chan) { for (chan = 1; chan < 9; ++chan) {
@ -2821,12 +2822,30 @@ void AudioInit(void)
tchan = chan; tchan = chan;
tfreq = freq; tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) { if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
AudioChannelsInHw[chan] = 0; //AudioChannelsInHw[chan] = 0;
} else { } else {
AudioChannelsInHw[chan] = chan; AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio48000] |= (1 << chan); AudioRatesInHw[Audio48000] |= (1 << chan);
} }
} }
freq = 192000;
AudioRatesInHw[Audio192000] = 0;
for (chan = 1; chan < 9; ++chan) {
int tchan;
int tfreq;
if (!AudioChannelsInHw[chan]) {
continue;
}
tchan = chan;
tfreq = freq;
if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) {
//AudioChannelsInHw[chan] = 0;
} else {
AudioChannelsInHw[chan] = chan;
AudioRatesInHw[Audio192000] |= (1 << chan);
}
}
// build channel support and conversion table // build channel support and conversion table
for (u = 0; u < AudioRatesMax; ++u) { for (u = 0; u < AudioRatesMax; ++u) {
for (chan = 1; chan < 9; ++chan) { for (chan = 1; chan < 9; ++chan) {

32
codec.c
View File

@ -976,21 +976,33 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder,
if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == CODEC_ID_AC3) if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == CODEC_ID_AC3)
|| (CodecPassthrough & CodecEAC3 || (CodecPassthrough & CodecEAC3
&& audio_ctx->codec_id == CODEC_ID_EAC3)) { && audio_ctx->codec_id == CODEC_ID_EAC3)) {
if (audio_ctx->codec_id == CODEC_ID_EAC3) {
// EAC3 over HDMI some receivers need HBR
audio_decoder->HwSampleRate *= 4;
}
audio_decoder->HwChannels = 2; audio_decoder->HwChannels = 2;
audio_decoder->SpdifIndex = 0; // reset buffer audio_decoder->SpdifIndex = 0; // reset buffer
audio_decoder->SpdifCount = 0; audio_decoder->SpdifCount = 0;
*passthrough = 1; *passthrough = 1;
} }
// channels not support? // channels/sample-rate not support?
if ((err = if ((err =
AudioSetup(&audio_decoder->HwSampleRate, AudioSetup(&audio_decoder->HwSampleRate,
&audio_decoder->HwChannels, *passthrough))) { &audio_decoder->HwChannels, *passthrough))) {
Debug(3, "codec/audio: audio setup error\n"); // try EAC3 none HBR
// FIXME: handle errors audio_decoder->HwSampleRate /= 4;
audio_decoder->HwChannels = 0; if (audio_ctx->codec_id != CODEC_ID_EAC3
audio_decoder->HwSampleRate = 0; || (err =
return err; AudioSetup(&audio_decoder->HwSampleRate,
&audio_decoder->HwChannels, *passthrough))) {
Debug(3, "codec/audio: audio setup error\n");
// FIXME: handle errors
audio_decoder->HwChannels = 0;
audio_decoder->HwSampleRate = 0;
return err;
}
} }
Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n", Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n",
@ -1073,8 +1085,10 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder,
// build SPDIF header and append A52 audio to it // build SPDIF header and append A52 audio to it
// avpkt is the original data // avpkt is the original data
spdif = audio_decoder->Spdif; spdif = audio_decoder->Spdif;
spdif_sz = 6144; spdif_sz = 24576; // 4 * 6144
// 24576 = 4 * 6144 if (audio_decoder->HwSampleRate == 48000) {
spdif_sz = 6144;
}
if (spdif_sz < audio_decoder->SpdifIndex + avpkt->size + 8) { if (spdif_sz < audio_decoder->SpdifIndex + avpkt->size + 8) {
Error(_("codec/audio: decoded data smaller than encoded\n")); Error(_("codec/audio: decoded data smaller than encoded\n"));
return -1; return -1;
@ -1087,7 +1101,7 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder,
// fscod2 // fscod2
repeat = eac3_repeat[(avpkt->data[4] & 0x30) >> 4]; repeat = eac3_repeat[(avpkt->data[4] & 0x30) >> 4];
} }
//fprintf(stderr, "repeat %d\n", repeat); // fprintf(stderr, "repeat %d %d\n", repeat, avpkt->size);
// copy original data for output // copy original data for output
// pack upto repeat EAC-3 pakets into one IEC 61937 burst // pack upto repeat EAC-3 pakets into one IEC 61937 burst