format: Fix rate for HBR passthrough formats

Submitted by Arun Raghavan on May 22, 2018, 4:13 a.m.

Details

Message ID 20180522041321.12059-1-arun@arunraghavan.net
State New
Series "format: Fix rate for HBR passthrough formats"
Headers show

Commit Message

Arun Raghavan May 22, 2018, 4:13 a.m.
In high bitrate mode, we force 192kHz/8ch as the sample format, which is
the expectation for HBR formats (as that is what allows for the largest
possible packet size).
---
 src/pulsecore/core-format.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
index 862a74b5d..096acc3a2 100644
--- a/src/pulsecore/core-format.c
+++ b/src/pulsecore/core-format.c
@@ -248,6 +248,9 @@  int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *
 
     if (f->encoding == PA_ENCODING_EAC3_IEC61937)
         ss->rate *= 4;
+    else if ((f->encoding == PA_ENCODING_TRUEHD_IEC61937) ||
+             (f->encoding == PA_ENCODING_DTSHD_IEC61937))
+        ss->rate = 192000;
 
     return 0;
 }

Comments

Alexander E. Patrakov May 22, 2018, 11:02 a.m.
There is some Microsoft documentation that contradicts this code.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd316761(v=vs.85).aspx

"""
Dolby TrueHD (MAT)

Dolby TrueHD content is transmitted over IEC 60958 at 176.4 kHz / 8
channels (requiring an IEC 60958 frame rate of 705.6 kHz) for content
sample rates of 44.1, 88.2 and 176.4 kHz, and 192 kHz / 8 channels
(requiring an IEC 60958 frame rate of 768 kHz) for content sample
rates of 48, 96 and 192 kHz.
"""


2018-05-22 12:13 GMT+08:00 Arun Raghavan <arun@arunraghavan.net>:
> In high bitrate mode, we force 192kHz/8ch as the sample format, which is
> the expectation for HBR formats (as that is what allows for the largest
> possible packet size).
> ---
>  src/pulsecore/core-format.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
> index 862a74b5d..096acc3a2 100644
> --- a/src/pulsecore/core-format.c
> +++ b/src/pulsecore/core-format.c
> @@ -248,6 +248,9 @@ int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *
>
>      if (f->encoding == PA_ENCODING_EAC3_IEC61937)
>          ss->rate *= 4;
> +    else if ((f->encoding == PA_ENCODING_TRUEHD_IEC61937) ||
> +             (f->encoding == PA_ENCODING_DTSHD_IEC61937))
> +        ss->rate = 192000;
>
>      return 0;
>  }
> --
> 2.17.0
>
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
Arun Raghavan May 25, 2018, 2:15 p.m.
On Tue, 22 May 2018, at 4:32 PM, Alexander E. Patrakov wrote:
> There is some Microsoft documentation that contradicts this code.
> 
> https://msdn.microsoft.com/en-us/library/windows/desktop/dd316761(v=vs.85).aspx
> 
> """
> Dolby TrueHD (MAT)
> 
> Dolby TrueHD content is transmitted over IEC 60958 at 176.4 kHz / 8
> channels (requiring an IEC 60958 frame rate of 705.6 kHz) for content
> sample rates of 44.1, 88.2 and 176.4 kHz, and 192 kHz / 8 channels
> (requiring an IEC 60958 frame rate of 768 kHz) for content sample
> rates of 48, 96 and 192 kHz.
> """

Based on Peter's input in a private thread, seems this is not the case on Linux:

https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp#L135
https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp#L486

Cheers,
Arun
 
> 2018-05-22 12:13 GMT+08:00 Arun Raghavan <arun@arunraghavan.net>:
> > In high bitrate mode, we force 192kHz/8ch as the sample format, which is
> > the expectation for HBR formats (as that is what allows for the largest
> > possible packet size).
> > ---
> >  src/pulsecore/core-format.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
> > index 862a74b5d..096acc3a2 100644
> > --- a/src/pulsecore/core-format.c
> > +++ b/src/pulsecore/core-format.c
> > @@ -248,6 +248,9 @@ int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *
> >
> >      if (f->encoding == PA_ENCODING_EAC3_IEC61937)
> >          ss->rate *= 4;
> > +    else if ((f->encoding == PA_ENCODING_TRUEHD_IEC61937) ||
> > +             (f->encoding == PA_ENCODING_DTSHD_IEC61937))
> > +        ss->rate = 192000;
> >
> >      return 0;
> >  }
> > --
> > 2.17.0
> >
> > _______________________________________________
> > pulseaudio-discuss mailing list
> > pulseaudio-discuss@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> 
> 
> 
> -- 
> Alexander E. Patrakov
Alexander E. Patrakov May 26, 2018, 9:47 a.m.
2018-05-25 22:15 GMT+08:00 Arun Raghavan <arun@arunraghavan.net>:
> On Tue, 22 May 2018, at 4:32 PM, Alexander E. Patrakov wrote:
>> There is some Microsoft documentation that contradicts this code.
>>
>> https://msdn.microsoft.com/en-us/library/windows/desktop/dd316761(v=vs.85).aspx
>>
>> """
>> Dolby TrueHD (MAT)
>>
>> Dolby TrueHD content is transmitted over IEC 60958 at 176.4 kHz / 8
>> channels (requiring an IEC 60958 frame rate of 705.6 kHz) for content
>> sample rates of 44.1, 88.2 and 176.4 kHz, and 192 kHz / 8 channels
>> (requiring an IEC 60958 frame rate of 768 kHz) for content sample
>> rates of 48, 96 and 192 kHz.
>> """
>
> Based on Peter's input in a private thread, seems this is not the case on Linux:
>
> https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp#L135
> https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp#L486

I have looked, and also obtained a copy of IEC 61937-5-2006 standard,
and I think I understand where this discrepancy comes from. The issue
is that the standard does not define at all what to do if the sample
rate of DTS audio is not a multiple of 48 kHz. I.e., it does not even
cover the DTS CD case (44.1 kHz) that de-facto exists!

Still, I think that diverging from what Windows does is not a good
thing. Has anyone tested that passthrough works with DTS-HD streams
that are not with a sample rate that is a multiple of 48 kHz? Does
anyone have such DTS-HD stream at all?

>
> Cheers,
> Arun
>
>> 2018-05-22 12:13 GMT+08:00 Arun Raghavan <arun@arunraghavan.net>:
>> > In high bitrate mode, we force 192kHz/8ch as the sample format, which is
>> > the expectation for HBR formats (as that is what allows for the largest
>> > possible packet size).
>> > ---
>> >  src/pulsecore/core-format.c | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>> > diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
>> > index 862a74b5d..096acc3a2 100644
>> > --- a/src/pulsecore/core-format.c
>> > +++ b/src/pulsecore/core-format.c
>> > @@ -248,6 +248,9 @@ int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *
>> >
>> >      if (f->encoding == PA_ENCODING_EAC3_IEC61937)
>> >          ss->rate *= 4;
>> > +    else if ((f->encoding == PA_ENCODING_TRUEHD_IEC61937) ||
>> > +             (f->encoding == PA_ENCODING_DTSHD_IEC61937))
>> > +        ss->rate = 192000;
>> >
>> >      return 0;
>> >  }
>> > --
>> > 2.17.0
>> >
>> > _______________________________________________
>> > pulseaudio-discuss mailing list
>> > pulseaudio-discuss@lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>>
>>
>>
>> --
>> Alexander E. Patrakov
Peter Fr├╝hberger May 26, 2018, 9:59 a.m.
Hi
Am Sa., 26. Mai 2018 um 11:47 Uhr schrieb Alexander E. Patrakov <
patrakov@gmail.com>:

> 2018-05-25 22:15 GMT+08:00 Arun Raghavan <arun@arunraghavan.net>:
> > On Tue, 22 May 2018, at 4:32 PM, Alexander E. Patrakov wrote:
> >> There is some Microsoft documentation that contradicts this code.
> >>
> >>
> https://msdn.microsoft.com/en-us/library/windows/desktop/dd316761(v=vs.85).aspx
> >>
> >> """
> >> Dolby TrueHD (MAT)
> >>
> >> Dolby TrueHD content is transmitted over IEC 60958 at 176.4 kHz / 8
> >> channels (requiring an IEC 60958 frame rate of 705.6 kHz) for content
> >> sample rates of 44.1, 88.2 and 176.4 kHz, and 192 kHz / 8 channels
> >> (requiring an IEC 60958 frame rate of 768 kHz) for content sample
> >> rates of 48, 96 and 192 kHz.
> >> """
> >
> > Based on Peter's input in a private thread, seems this is not the case
> on Linux:
> >
> >
> https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp#L135
> >
> https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp#L486
>
> I have looked, and also obtained a copy of IEC 61937-5-2006 standard,
> and I think I understand where this discrepancy comes from. The issue
> is that the standard does not define at all what to do if the sample
> rate of DTS audio is not a multiple of 48 kHz. I.e., it does not even
> cover the DTS CD case (44.1 kHz) that de-facto exists!
>
> Still, I think that diverging from what Windows does is not a good
> thing. Has anyone tested that passthrough works with DTS-HD streams
> that are not with a sample rate that is a multiple of 48 kHz? Does
> anyone have such DTS-HD stream at all?
>

We are using this in kodi since first introducing HBR bitstream support.
For DTS our sync code also can cope with 44.1 khz. But recently an issue
occured for DTS-HD HR vs. DTS-HD MA that some new receivers don't like
being sent 192/8, see this discussion here:
https://github.com/Nevcairiel/LAVFilters/issues/167 - this most likely
means that we have to distinguish between different DTS-HD formats.
Hendrik's workaround was:
https://github.com/Nevcairiel/LAVFilters/commit/3ec0521e8aa68047c08fa9d518327e6fd36c827d
sending 192 khz / 2 channels for HR bitrates.

Peter

>
> >
> > Cheers,
> > Arun
> >
> >> 2018-05-22 12:13 GMT+08:00 Arun Raghavan <arun@arunraghavan.net>:
> >> > In high bitrate mode, we force 192kHz/8ch as the sample format, which
> is
> >> > the expectation for HBR formats (as that is what allows for the
> largest
> >> > possible packet size).
> >> > ---
> >> >  src/pulsecore/core-format.c | 3 +++
> >> >  1 file changed, 3 insertions(+)
> >> >
> >> > diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
> >> > index 862a74b5d..096acc3a2 100644
> >> > --- a/src/pulsecore/core-format.c
> >> > +++ b/src/pulsecore/core-format.c
> >> > @@ -248,6 +248,9 @@ int pa_format_info_to_sample_spec_fake(const
> pa_format_info *f, pa_sample_spec *
> >> >
> >> >      if (f->encoding == PA_ENCODING_EAC3_IEC61937)
> >> >          ss->rate *= 4;
> >> > +    else if ((f->encoding == PA_ENCODING_TRUEHD_IEC61937) ||
> >> > +             (f->encoding == PA_ENCODING_DTSHD_IEC61937))
> >> > +        ss->rate = 192000;
> >> >
> >> >      return 0;
> >> >  }
> >> > --
> >> > 2.17.0
> >> >
> >> > _______________________________________________
> >> > pulseaudio-discuss mailing list
> >> > pulseaudio-discuss@lists.freedesktop.org
> >> > https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
> >>
> >>
> >>
> >> --
> >> Alexander E. Patrakov
>
>
>
> --
> Alexander E. Patrakov
>