[Vorbis] oggdec.exe not using album gain stdout option
Ian Malone
ibmalone at gmail.com
Tue Oct 24 14:36:06 PDT 2006
Jeremy R. Donnell wrote:
>
> On 10/24/06, Ian Malone <ibmalone at gmail.com> wrote:
>> Jeremy R. Donnell wrote:
>>
>> >
>> >
>> > line 775 of oggdec.c
>> >
>> > if(!send_to_stdout && audiophile || radio)
>> > {
>> > fprintf(stderr, audiophile
>> > ? " Running in Album/Audiophile mode\n\n"
>> > : " Running in Track/Radio mode\n\n");
>> > /* We are using ReplayGain tags, so get the scale for gain
>> > adjustment. */
>> > scale = get_scale(file_names[i], audiophile, radio);
>> > }
>> > else
>> > scale = 1.0;
>> >
>> > It seems to me from looking at that code that it shouldn't do either
>> track
>> > or album gain when stdout is selected, but that contradicts the actual
>> > results that I've obtained. Perhaps I don't fully grasp the logical
>> > operator
>> > rules in C? In C# this would dump to the else as soon as
>> !send_to_stdout
>> > evaluated as false, and the audiophile and radio operands would not
>> even be
>> > evaluated. I'm thinking that the correct solution would be to take the
>> > !send_to_stdout out of the first if statement and add it in before the
>> > fprintf() call. In fact, I've seen the "Running in Track/Radio mode"
>> > message
>> > when using the options "-r -o".
>>
>> '&&' binds more tightly than '||', is this actually different in C#?
>> This if clause is equivalent to
>> ((!send_to_stdout && audiophile) || radio)
>>
> In C#, '&&' and '||' are called conditional-AND/OR operators. They
> will short-circuit evaluation of the expression when possible. See
> here:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfandandoperator.asp
>
In plain old C they are short circuit operators, but && has higher
priority the result is that for
#1 && #2 || #3
If #1 true, evaluate #2, if #2 true condition is true, skip#3
if #2 false evaluate #3
If #1 false, skip #2, evaluate #3
The short circuiting has a bearing on side effects of the expression
(e.g. if #1, #2 or #3 are function calls, or increment/decrement
operators), but not on the priority.
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_7_2_1.asp>
It looks like C# follows the C convention for priority although,
as you point out, complex logical operations are best parenthesised.
> Either way, I think the logic in oggdec is not right unless it was the
> intention to prevent using album gain with the stdout option.
>
I agree. I wonder if the intention was that per-track gain to
stdout would be for streaming (that variable name 'radio' intrigues
me, unless it's simply an old name for per-track rpg; like audiophile
is for album rpg).
--
imalone
More information about the Vorbis
mailing list