patch for DCA "floating point output" option
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case. This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h: #define CONFIG_AUDIO_NONSHORT 1 I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature. Gr??e *?* Regards... *Mathias Rauen* Ernst-M?ller-Allee 10 Germany *?* 37520 Osterode dear at madshi.net <mailto:dear at madshi.net> *?* www.madshi.net <http://www.madshi.net>
On Fri, Jan 04, 2008 at 01:36:50PM +0100, madshi wrote:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes
from the MLP/TrueHD decoder which offers a similar feature.
[...]
+#ifdef CONFIG_AUDIO_NONSHORT + samples[k] = s->samples[j + k * 256] / 32768.0f;
isnt there a more efficient way than to scale each individual sample? besides this, the patch looks good [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
Michael Niedermayer schrieb:
On Fri, Jan 04, 2008 at 01:36:50PM +0100, madshi wrote:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes
from the MLP/TrueHD decoder which offers a similar feature.
[...]
+#ifdef CONFIG_AUDIO_NONSHORT + samples[k] = s->samples[j + k * 256] / 32768.0f;
isnt there a more efficient way than to scale each individual sample?
To be honest, I'm not sure. I don't know the libav tool functions well. Maybe there's a call which can scale a whole floating point buffer more efficiently than scaling each sample separately? Another option would be to try to scale elsewhere in the DCA decoder code where it may be more efficient. But I was afraid of breaking something. Also I wanted to keep the changes to the source code as small as possible. I've made a similar patch for the (native) AC3 decoder and there it was the other way round: I had to disable a multiply of 32767.0f for floating point output. It seems to me that the DCA compiler internally works with unscaled samples while the AC3 decoder internally works with scaled samples, but I'm not really sure.
besides this, the patch looks good
Thanks! madshi.
Michael Niedermayer wrote:
On Fri, Jan 04, 2008 at 01:36:50PM +0100, madshi wrote:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes
from the MLP/TrueHD decoder which offers a similar feature.
[...]
+#ifdef CONFIG_AUDIO_NONSHORT + samples[k] = s->samples[j + k * 256] / 32768.0f;
isnt there a more efficient way than to scale each individual sample?
besides this, the patch looks good [...]
I looked through the scaling issue before and something isn't right with regard to the scaling, there are 2 cases where magic constants are used to get the correct scale, I havn't tracked it down and the specification is unclear in the matter. But the patch is ok and something like this will be needed in the future for all codecs. I'll apply it soon. MvH Benjamin Larsson
madshi <dear at madshi.net> writes:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature.
+#ifdef CONFIG_AUDIO_NONSHORT
That's a rather useless name. Can't you think of anything better? -- M?ns Rullg?rd mans at mansr.com
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature.
+#ifdef CONFIG_AUDIO_NONSHORT
That's a rather useless name. Can't you think of anything better?
It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder... Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples. Whatever, any name is fine with me. Just let's use the same constant name for all decoders, please. madshi.
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature.
+#ifdef CONFIG_AUDIO_NONSHORT
That's a rather useless name. Can't you think of anything better?
It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder...
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it? -- M?ns Rullg?rd mans at mansr.com
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature.
+#ifdef CONFIG_AUDIO_NONSHORT
That's a rather useless name. Can't you think of anything better?
It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder...
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it?
Well, the point of the constant is to allow the decoder to output whatever sample format suits best. It may be floating point or 24 bit integer or even the usual 16 bit integer. Of course the decoder must set the "sample_fmt" field to the correct value. My patch does that. The MLP/TrueHD decoder does that, too. A different solution would be to use specific constants for specific bitdepths/formats. E.g. "CONFIG_AUDIO_FLOAT". But this doesn't fit every purpose. E.g. lossless audio decoders should really output their data in the native format. For MLP/TrueHD that can be either 16 bit integer or 24 bit integer, but not floating point. For lossy codecs like AC3 and DTS however the best output format is floating point. Personally, I want every decoder to output the most ideal format and bitdepth for the audio track. And this is not the same for every decoder. So the "non short" flag just tells the decoder to output what it likes best.
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature.
+#ifdef CONFIG_AUDIO_NONSHORT
That's a rather useless name. Can't you think of anything better?
It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder...
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it?
Well, the point of the constant is to allow the decoder to output whatever sample format suits best. It may be floating point or 24 bit integer or even the usual 16 bit integer. Of course the decoder must set the "sample_fmt" field to the correct value. My patch does that. The MLP/TrueHD decoder does that, too.
I figured as much, but the name doesn't convey that very well. Perhaps something like "native" would be better than "nonshort".
Personally, I want every decoder to output the most ideal format and bitdepth for the audio track. And this is not the same for every decoder. So the "non short" flag just tells the decoder to output what it likes best.
I agree. This is how video is handled. To do this for audio, we'd first need a generic way of converting between different sample formats. -- M?ns Rullg?rd mans at mansr.com
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
Not sure whether the DCA maintainers will like this patch. But maybe they will, so I'm posting it here just in case.
This patch adds optional floating point output to the DCA decoder. This optional feature must be enabled at compile time by adding the following switch to config.h:
#define CONFIG_AUDIO_NONSHORT 1
I'm using this solution in my eac3to tool because 16bit PCM just doesn't cut it for a good audio transcoding tool. The idea for this option comes from the MLP/TrueHD decoder which offers a similar feature.
+#ifdef CONFIG_AUDIO_NONSHORT
That's a rather useless name. Can't you think of anything better?
It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder...
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it?
Well, the point of the constant is to allow the decoder to output whatever sample format suits best. It may be floating point or 24 bit integer or even the usual 16 bit integer. Of course the decoder must set the "sample_fmt" field to the correct value. My patch does that. The MLP/TrueHD decoder does that, too.
I figured as much, but the name doesn't convey that very well. Perhaps something like "native" would be better than "nonshort".
"native" sounds very good to me!
Personally, I want every decoder to output the most ideal format and bitdepth for the audio track. And this is not the same for every decoder. So the "non short" flag just tells the decoder to output what it likes best.
I agree. This is how video is handled. To do this for audio, we'd first need a generic way of converting between different sample formats.
For ffmpeg yes. For libav not necessarily. Personally, I'm only using libav and my application can handle any sample format and bitdepth. So personally I want all libav decoders to always output in their native format. I understand that for ffmpeg in its current formt this is problematic, though.
On Sat, Jan 19, 2008 at 05:10:01PM +0100, madshi wrote:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
> Not sure whether the DCA maintainers will like this patch. But maybe > they will, so I'm posting it here just in case. > > This patch adds optional floating point output to the DCA > decoder. This optional feature must be enabled at compile time by > adding the following switch to config.h: > > #define CONFIG_AUDIO_NONSHORT 1 > > I'm using this solution in my eac3to tool because 16bit PCM just > doesn't cut it for a good audio transcoding tool. The idea for this > option comes from the MLP/TrueHD decoder which offers a similar > feature. > > +#ifdef CONFIG_AUDIO_NONSHORT > > > That's a rather useless name. Can't you think of anything better?
It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder...
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it?
Well, the point of the constant is to allow the decoder to output whatever sample format suits best. It may be floating point or 24 bit integer or even the usual 16 bit integer. Of course the decoder must set the "sample_fmt" field to the correct value. My patch does that. The MLP/TrueHD decoder does that, too.
I figured as much, but the name doesn't convey that very well. Perhaps something like "native" would be better than "nonshort".
"native" sounds very good to me!
Changing the name from CONFIG_AUDIO_NONSHORT will break applications using it, also it is independant of this patch, that is adding float output support vs. changing API.
Personally, I want every decoder to output the most ideal format and bitdepth for the audio track. And this is not the same for every decoder. So the "non short" flag just tells the decoder to output what it likes best.
I agree. This is how video is handled. To do this for audio, we'd first need a generic way of converting between different sample formats.
For ffmpeg yes. For libav not necessarily. Personally, I'm only
Yes, adding float support to ffmpeg.c or generic audio format convertion to lavc are all seperate things. No need to make them artificially dependant [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
Michael Niedermayer <michaelni at gmx.at> writes:
On Sat, Jan 19, 2008 at 05:10:01PM +0100, madshi wrote:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
> madshi <dear at madshi.net> writes: > > > > >> Not sure whether the DCA maintainers will like this patch. But maybe >> they will, so I'm posting it here just in case. >> >> This patch adds optional floating point output to the DCA >> decoder. This optional feature must be enabled at compile time by >> adding the following switch to config.h: >> >> #define CONFIG_AUDIO_NONSHORT 1 >> >> I'm using this solution in my eac3to tool because 16bit PCM just >> doesn't cut it for a good audio transcoding tool. The idea for this >> option comes from the MLP/TrueHD decoder which offers a similar >> feature. >> >> +#ifdef CONFIG_AUDIO_NONSHORT >> >> >> > That's a rather useless name. Can't you think of anything better? > > > > It was not my idea. The same constant is already used by the MLP/TrueHD decoder. I thought that it doesn't make sense to use a different name for every decoder...
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it?
Well, the point of the constant is to allow the decoder to output whatever sample format suits best. It may be floating point or 24 bit integer or even the usual 16 bit integer. Of course the decoder must set the "sample_fmt" field to the correct value. My patch does that. The MLP/TrueHD decoder does that, too.
I figured as much, but the name doesn't convey that very well. Perhaps something like "native" would be better than "nonshort".
"native" sounds very good to me!
Changing the name from CONFIG_AUDIO_NONSHORT will break applications using it, also it is independant of this patch, that is adding float output support vs. changing API.
How can renaming a CONFIG_ symbol break the API? In fact, I can't see that's ever set, so renaming it will certainly make no difference.
Personally, I want every decoder to output the most ideal format and bitdepth for the audio track. And this is not the same for every decoder. So the "non short" flag just tells the decoder to output what it likes best.
I agree. This is how video is handled. To do this for audio, we'd first need a generic way of converting between different sample formats.
For ffmpeg yes. For libav not necessarily. Personally, I'm only
Yes, adding float support to ffmpeg.c or generic audio format convertion to lavc are all seperate things. No need to make them artificially dependant
What I'm saying is that if we change the output format of audio decoders, we will have to change ffmpeg.c somehow, or it simply will not work. -- M?ns Rullg?rd mans at mansr.com
On Sat, Jan 19, 2008 at 07:41:11PM +0000, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
On Sat, Jan 19, 2008 at 05:10:01PM +0100, madshi wrote:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
M?ns Rullg?rd schrieb:
madshi <dear at madshi.net> writes:
> M?ns Rullg?rd schrieb: > > >> madshi <dear at madshi.net> writes: >> >> >> >> >>> Not sure whether the DCA maintainers will like this patch. But maybe >>> they will, so I'm posting it here just in case. >>> >>> This patch adds optional floating point output to the DCA >>> decoder. This optional feature must be enabled at compile time by >>> adding the following switch to config.h: >>> >>> #define CONFIG_AUDIO_NONSHORT 1 >>> >>> I'm using this solution in my eac3to tool because 16bit PCM just >>> doesn't cut it for a good audio transcoding tool. The idea for this >>> option comes from the MLP/TrueHD decoder which offers a similar >>> feature. >>> >>> +#ifdef CONFIG_AUDIO_NONSHORT >>> >>> >>> >> That's a rather useless name. Can't you think of anything better? >> >> >> >> > It was not my idea. The same constant is already used by the > MLP/TrueHD decoder. I thought that it doesn't make sense to > use a different name for every decoder... > > Besides, I don't think that the name is useless. Currently the decoders > all output "short" samples (shorter than they should be). "non short" > simply means that the decoders stop shorten the audio samples. > > The name is equally non-descriptive for any decoder. If the output is not 'short', then what is it?
Well, the point of the constant is to allow the decoder to output whatever sample format suits best. It may be floating point or 24 bit integer or even the usual 16 bit integer. Of course the decoder must set the "sample_fmt" field to the correct value. My patch does that. The MLP/TrueHD decoder does that, too.
I figured as much, but the name doesn't convey that very well. Perhaps something like "native" would be better than "nonshort".
"native" sounds very good to me!
Changing the name from CONFIG_AUDIO_NONSHORT will break applications using it, also it is independant of this patch, that is adding float output support vs. changing API.
How can renaming a CONFIG_ symbol break the API?
just read the archives, its quite common that such changes break applications useing their own system for setting CONFIG_* ignoring that is BOFH attitude [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle
Michael Niedermayer <michaelni at gmx.at> writes:
On Sat, Jan 19, 2008 at 07:41:11PM +0000, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
Changing the name from CONFIG_AUDIO_NONSHORT will break applications using it, also it is independant of this patch, that is adding float output support vs. changing API.
How can renaming a CONFIG_ symbol break the API?
just read the archives, its quite common that such changes break applications useing their own system for setting CONFIG_*
CONFIG_* has never been part of the public API. The only apps that would be affected are those that include a copy of FFmpeg and bypass the configure script. By doing this, they have taken upon themselves the task of tracking any non-API changes to FFmpeg that affect them. Tough luck for them. -- M?ns Rullg?rd mans at mansr.com
Hi, On Jan 19, 2008 10:19 AM, madshi <dear at madshi.net> wrote:
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
So, video can "negotiate" an output (at least some decoders can), why can't audio do that? Why do we need a compile option if it could be chosen at runtime within the decoder (isn't that what enum SampleFormat is for?). Ronald
On Sat, Jan 19, 2008 at 11:44:04AM -0500, Ronald S. Bultje wrote:
Hi,
On Jan 19, 2008 10:19 AM, madshi <dear at madshi.net> wrote:
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
So, video can "negotiate" an output (at least some decoders can), why can't
No, video decoders just always output the native format. Applications using lavc must then convert if needed. Rich
Hi, On Jan 19, 2008 12:38 PM, Rich Felker <dalias at aerifal.cx> wrote:
On Sat, Jan 19, 2008 at 11:44:04AM -0500, Ronald S. Bultje wrote:
On Jan 19, 2008 10:19 AM, madshi <dear at madshi.net> wrote:
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
So, video can "negotiate" an output (at least some decoders can), why can't
No, video decoders just always output the native format. Applications using lavc must then convert if needed.
Sounds sane also. Let's do that for audio then (i.e. use enum SampleFormat for real!). Ronald
On Sat, Jan 19, 2008 at 12:39:28PM -0500, Ronald S. Bultje wrote:
Hi,
On Jan 19, 2008 12:38 PM, Rich Felker <dalias at aerifal.cx> wrote:
On Sat, Jan 19, 2008 at 11:44:04AM -0500, Ronald S. Bultje wrote:
On Jan 19, 2008 10:19 AM, madshi <dear at madshi.net> wrote:
Besides, I don't think that the name is useless. Currently the decoders all output "short" samples (shorter than they should be). "non short" simply means that the decoders stop shorten the audio samples.
So, video can "negotiate" an output (at least some decoders can), why can't
No, video decoders just always output the native format. Applications using lavc must then convert if needed.
Sounds sane also. Let's do that for audio then (i.e. use enum SampleFormat for real!).
Well it's a lot less clear what's "native" for audio (i.e. more dependent on the implementation - a fixedpoint implementation would likely consider 16bit or 24bit integers to be native). For video it's pretty clear. Rich
participants (6)
-
banan@ludd.ltu.se -
dalias@aerifal.cx -
dear@madshi.net -
mans@mansr.com -
michaelni@gmx.at -
rsbultje@gmail.com