diff --git a/ChangeLog b/ChangeLog index 891fb78..10aac97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ User johns Date: + Try to use HBR (High Bit-Rate) for EAC3. Improved pass-through (PCM+EAC3) support. Support VDR 1.7.36 new build system. Improves VDPAU display preemption handling. diff --git a/audio.c b/audio.c index 369eec9..cc3869e 100644 --- a/audio.c +++ b/audio.c @@ -178,7 +178,7 @@ enum _audio_rates //Audio88200, ///< 88.2Khz //Audio96000, ///< 96.0Khz //Audio176400, ///< 176.4Khz - //Audio192000, ///< 192.0Khz + Audio192000, ///< 192.0Khz AudioRatesMax ///< max index }; @@ -190,7 +190,7 @@ static int AudioChannelMatrix[AudioRatesMax][9]; /// rates tables (must be sorted by frequency) static const unsigned AudioRatesTable[AudioRatesMax] = { - 44100, 48000, + 44100, 48000, 192000 }; //---------------------------------------------------------------------------- @@ -2794,6 +2794,7 @@ void AudioInit(void) // Check which channels/rates/formats are supported // FIXME: we force 44.1Khz and 48Khz must be supported equal // FIXME: should use bitmap of channels supported in RatesInHw + // FIXME: use loop over sample-rates freq = 44100; AudioRatesInHw[Audio44100] = 0; for (chan = 1; chan < 9; ++chan) { @@ -2821,12 +2822,30 @@ void AudioInit(void) tchan = chan; tfreq = freq; if (AudioUsedModule->Setup(&tfreq, &tchan, 0)) { - AudioChannelsInHw[chan] = 0; + //AudioChannelsInHw[chan] = 0; } else { AudioChannelsInHw[chan] = 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 for (u = 0; u < AudioRatesMax; ++u) { for (chan = 1; chan < 9; ++chan) { diff --git a/codec.c b/codec.c index 13801dc..07e4b96 100644 --- a/codec.c +++ b/codec.c @@ -976,21 +976,33 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder, if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == CODEC_ID_AC3) || (CodecPassthrough & CodecEAC3 && 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->SpdifIndex = 0; // reset buffer audio_decoder->SpdifCount = 0; *passthrough = 1; } - // channels not support? + // channels/sample-rate not support? if ((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; + // try EAC3 none HBR + audio_decoder->HwSampleRate /= 4; + if (audio_ctx->codec_id != CODEC_ID_EAC3 + || (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", @@ -1073,8 +1085,10 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, // build SPDIF header and append A52 audio to it // avpkt is the original data spdif = audio_decoder->Spdif; - spdif_sz = 6144; - // 24576 = 4 * 6144 + spdif_sz = 24576; // 4 * 6144 + if (audio_decoder->HwSampleRate == 48000) { + spdif_sz = 6144; + } if (spdif_sz < audio_decoder->SpdifIndex + avpkt->size + 8) { Error(_("codec/audio: decoded data smaller than encoded\n")); return -1; @@ -1087,7 +1101,7 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, // fscod2 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 // pack upto repeat EAC-3 pakets into one IEC 61937 burst