Re: [libav-devel] dca xll: Working audio

2014-05-08 Thread Niels Möller
ni...@lysator.liu.se (Niels Möller) writes:

 It seems to give reasonable output for the Master Audio 7.1.dts file,
 except that the LFE channel is messed up in some places.

I suspect this is not a bug in my code...

Let's I look at one sample where there's a large error, index 461360.
For the reference flac file, I have sample values

  -134990 -39862 -1678929 -248163 -116804 -112124 -1656 -34272

With avconv master I get

  -95623 -28254 -1187410 -159055 -83522 -103577

This is the core channels only, downmix version of the 7.1 data, and
without applying any lossless residuals. The inverse downmix scales all
channels by sqrt(2), and then undoes some mixing of the last two
surround channels. Ignore the surround stuff, and just scale the first
four channels. This gives

  -135231 -39959 -1679253 -224938

with errors

 -241-97 -324   23225

So the final channel, the LFE, gets a much worse error than the three
normal channels. In dcadec.c, there's a comment

   /* Generate LFE samples for this subsubframe FIXME!!! */

which looks like it predates the libav/ffmpeg fork. Does anyone remember
what the problem was?

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-05-08 Thread Kostya Shishkov
On Thu, May 08, 2014 at 02:25:40PM +0200, Niels Möller wrote:
 ni...@lysator.liu.se (Niels Möller) writes:
 
  It seems to give reasonable output for the Master Audio 7.1.dts file,
  except that the LFE channel is messed up in some places.
 
 I suspect this is not a bug in my code...
 
 Let's I look at one sample where there's a large error, index 461360.
 For the reference flac file, I have sample values
 
   -134990 -39862 -1678929 -248163 -116804 -112124 -1656 -34272
 
 With avconv master I get
 
   -95623 -28254 -1187410 -159055 -83522 -103577
 
 This is the core channels only, downmix version of the 7.1 data, and
 without applying any lossless residuals. The inverse downmix scales all
 channels by sqrt(2), and then undoes some mixing of the last two
 surround channels. Ignore the surround stuff, and just scale the first
 four channels. This gives
 
   -135231 -39959 -1679253 -224938
 
 with errors
 
  -241-97 -324   23225
 
 So the final channel, the LFE, gets a much worse error than the three
 normal channels. In dcadec.c, there's a comment
 
/* Generate LFE samples for this subsubframe FIXME!!! */
 
 which looks like it predates the libav/ffmpeg fork. Does anyone remember
 what the problem was?

It comes from the original libdts (now known as libdca) so no.
But IIRC D** decided to use IIR-based interpolation for LFE in case it's not
core-only so the problem lies in Calabasas, California.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-05-08 Thread Niels Möller
Kostya Shishkov kostya.shish...@gmail.com writes:

 But IIRC D** decided to use IIR-based interpolation for LFE in case it's not
 core-only so the problem lies in Calabasas, California.

Sounds like a mess... Any information about what that filter is like?

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-05-06 Thread Niels Möller
ni...@lysator.liu.se (Niels Möller) writes:

 I'm now looking at the Master Audio 7.1.dts file. There are 5.1 core
 channels, and the xll extension has two channel sets.

 Channel set 0 contain 6 residual channels, and from the channel mask,
 these are, in order, C, L, R, LFE1, Lss, Rss (surround side).

 Channel set 1 contain 2 non-residual channels, Lsr, Rsr (surround rear).
 And it has the downmix coefficients, and the BHierChSet flag set.

Implemented this now, mostly as described in previous mail. For residual
channels, also the core channels need to be scaled. For now, that's no
problem, because I do one channel set at a time, and by the time I get
to chset 1 which implies an inverse downmix, core and residual are
already added together for the first channel set.

It seems to give reasonable output for the Master Audio 7.1.dts file,
except that the LFE channel is messed up in some places.

I had to add a couple of additional hacks for channel order, and I also
had to implement fixed prediction, since that was used for one of the
frames in this file.

Available at my wip repo as usual.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-05-05 Thread Niels Möller
Kostya Shishkov kostya.shish...@gmail.com writes:

 Maybe someone can give you a sample with lossless-only tracks? IIRC it's quite
 common to have 7.1 lossless audio with 5.1 core channels with residue plus two
 fully lossless channels. And you'll have fun with remixing channel sets then.

Fun, indeed...

I'm now looking at the Master Audio 7.1.dts file. There are 5.1 core
channels, and the xll extension has two channel sets.

Channel set 0 contain 6 residual channels, and from the channel mask,
these are, in order, C, L, R, LFE1, Lss, Rss (surround side).

Channel set 1 contain 2 non-residual channels, Lsr, Rsr (surround rear).
And it has the downmix coefficients, and the BHierChSet flag set. There
appear to be 18 coefficients (2+1) * 6. All either zero or 1/sqrt(2)
(nine bit codes 256 and 473, respectively). To make sense of them, I can
arrange them in the following matrix:

   C   L   R LFE Lss Rss
  self?  0.7 0.7 0.7 0.7 0.7 0.7
  Lsr  0   0   0   0 0.7   0 
  Rsr  0   0   0   0   0 0.7

Ordered in the stream starting with the first column, i.e., 0.7, 0, 0,
0.7, 0, 0, ..., 0.7, 0, 0.7. I guess that this means that the downmix
was done as

  C'   = 0.7 C
  L'   = 0.7 L
  R'   = 0.7 R
  LFE' = 0.7 LFE
  Lss' = 0.7 Lss + 0.7 Lsr
  Rss' = 0.7 Rss + 0.7 Rsr

where C, L, ..., Rsr are the intended 7.1 audio, and C', L',..., Rss' is
the downmixed 5.1 audio coded by the first channel set (+ core).

Then, to undo this downmix and recover 7.1 audio, I have to compute

  C   = C' / 0.7
  L   = L' / 0.7
  R   = R' / 0.7
  LFE = LFE' / 0.7
  L   = L' / 0.7
  Lss = Lss' / 0.7 - Lsr
  Rss = Rss' / 0.7 - Lsr

Or in general, if column X is x_0, x_1, x_2, downmix is

  X' = x_0 X + x_1 Lsr + x_2 Rsr

and the inverse is

  X = X' / x_0 + (x_1 / x_0) Lsr + (x_1 / x_0) Rsr

And the inversion of x_0 is what the invDmixTab (D.11 in the spec) is
for.

Do I get this right?

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-05-02 Thread Tim Walker
On 28 Apr 2014, at 15:01, Hendrik Leppkes h.lepp...@gmail.com wrote:

 I also used to have a sample somewhere where all audible audio is in
 the lossless extension for all channels, playing just the core yielded
 nothing but silence.
 Maybe I can dig it up if its of interest.
 
 - Hendrik

Please do (more out of curiosity than any other reason though).

Tim
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-05-02 Thread Tim Walker

On 28 Apr 2014, at 14:44, Kostya Shishkov kostya.shish...@gmail.com wrote:

 On Mon, Apr 28, 2014 at 02:35:36PM +0200, Niels Möller wrote:
 After implementing proper channel reorder, I think the audio is pretty
 close to correct. Peak sample error for Master Audio 5.0 96khz.dts is
 now down to 115 (for 24-bit integer output). To be compared to 7183 if
 the core channels are upmixed but the xll residual data is ignored.
 
 Code in my public wip repo at http://www.southpole.se/~nisse/libav.git,
 branch xll.
 
 What's the next steps? I guess I should rebase or merge with the master
 branch, maybe remove or clean up debug output, and then post the patch
 here for review? (It might be possible to split it in pieces, but I
 doubt the history in my repo is very useful).
 
 Or you can work on integer mode for DTS.

Indeed, this will be needed for lossless eventually, so if you're not sure what 
to work on you might as well tackle it now :-)

Tim
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] dca xll: Working audio

2014-04-28 Thread Niels Möller
After implementing proper channel reorder, I think the audio is pretty
close to correct. Peak sample error for Master Audio 5.0 96khz.dts is
now down to 115 (for 24-bit integer output). To be compared to 7183 if
the core channels are upmixed but the xll residual data is ignored.

Code in my public wip repo at http://www.southpole.se/~nisse/libav.git,
branch xll.

What's the next steps? I guess I should rebase or merge with the master
branch, maybe remove or clean up debug output, and then post the patch
here for review? (It might be possible to split it in pieces, but I
doubt the history in my repo is very useful).

It would also be good with some command line option to disable xll
processing (don't know how codec-specific options are done).

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-04-28 Thread Kostya Shishkov
On Mon, Apr 28, 2014 at 02:35:36PM +0200, Niels Möller wrote:
 After implementing proper channel reorder, I think the audio is pretty
 close to correct. Peak sample error for Master Audio 5.0 96khz.dts is
 now down to 115 (for 24-bit integer output). To be compared to 7183 if
 the core channels are upmixed but the xll residual data is ignored.
 
 Code in my public wip repo at http://www.southpole.se/~nisse/libav.git,
 branch xll.
 
 What's the next steps? I guess I should rebase or merge with the master
 branch, maybe remove or clean up debug output, and then post the patch
 here for review? (It might be possible to split it in pieces, but I
 doubt the history in my repo is very useful).

Maybe someone can give you a sample with lossless-only tracks? IIRC it's quite
common to have 7.1 lossless audio with 5.1 core channels with residue plus two
fully lossless channels. And you'll have fun with remixing channel sets then.

Or you can work on integer mode for DTS.

 It would also be good with some command line option to disable xll
 processing (don't know how codec-specific options are done).

There's an option for disable_xch already there, just follow the example.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] dca xll: Working audio

2014-04-28 Thread Hendrik Leppkes
On Mon, Apr 28, 2014 at 2:44 PM, Kostya Shishkov
kostya.shish...@gmail.com wrote:
 On Mon, Apr 28, 2014 at 02:35:36PM +0200, Niels Möller wrote:
 After implementing proper channel reorder, I think the audio is pretty
 close to correct. Peak sample error for Master Audio 5.0 96khz.dts is
 now down to 115 (for 24-bit integer output). To be compared to 7183 if
 the core channels are upmixed but the xll residual data is ignored.

 Code in my public wip repo at http://www.southpole.se/~nisse/libav.git,
 branch xll.

 What's the next steps? I guess I should rebase or merge with the master
 branch, maybe remove or clean up debug output, and then post the patch
 here for review? (It might be possible to split it in pieces, but I
 doubt the history in my repo is very useful).

 Maybe someone can give you a sample with lossless-only tracks? IIRC it's quite
 common to have 7.1 lossless audio with 5.1 core channels with residue plus two
 fully lossless channels. And you'll have fun with remixing channel sets then.

Samples for that are available in the usual places, ie this one should
do the trick:
http://samples.ffmpeg.org/A-codecs/DTS/dts/Master%20Audio%207.1%2024bit.dts

I also used to have a sample somewhere where all audible audio is in
the lossless extension for all channels, playing just the core yielded
nothing but silence.
Maybe I can dig it up if its of interest.

- Hendrik
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] dca xll: Working audio

2014-04-28 Thread Niels Möller
Kostya Shishkov kostya.shish...@gmail.com writes:

 Maybe someone can give you a sample with lossless-only tracks? IIRC it's quite
 common to have 7.1 lossless audio with 5.1 core channels with residue plus two
 fully lossless channels. And you'll have fun with remixing channel sets then.

I think I have two 7.1 samples, which I haven't dared trying yet. 

About the ch_mask in the channel header, you said it uses the
conventional order C, L, R, (for the 7.1 samples I have, according to
eac3to, they contain the channels C L R Ls Rs LFE Lw Rw ($40f) and C L
R LFE Lsr Rsr Lss Rss ($84b). Is there some authoritative spec for the
order used in xll? If I have understood correctly, libav uses the same
order as specified for .wav (which is different from xll),
(http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308%28v=vs.85%29.aspx).

 There's an option for disable_xch already there, just follow the example.

Ok, shouldn't be too hard.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel