[MPlayer-users] wrong length and bitrate with FLAC

Ilja Sekler ilja_sekler_ at gmx.de
Sun Nov 25 16:13:19 CET 2012


Am 25.11.2012 12:59, schrieb Reimar Döffinger:

> On Fri, Nov 23, 2012 at 11:39:43AM +0100, Ilja Sekler wrote:
> 
>>>> <http://lists.mplayerhq.hu/pipermail/mplayer-users/2012-November/085621.html>,
>>>> reverting the checkin from r35333 fixes the issue with long
>>>> FLAC files.
>>> 
>>> That would be wrong, you just don't notice because now _your_
>>> files are too short :-) (the issue would become visible for files
>>> around 100 hours long).
>> 
>> It is IMHO quite safe to assume that no one would ever get FLAC
>> files with such an incredible length :-) For real life cases, it
>> just works right.
> 
> Yes, but there is a difference between "working right" and
> "correct", the former one usually making the code a nightmare to
> maintain in the long run.

I'm aware of it and very sorry if it sounded like neglecting flawless
logic. The problem is that I mostly can't judge what is logically
correct in C, but can easily see whether something is "working right"
when using an application for my everyday computing needs.

Could you please shed a bit of light on how you calculated the lenght of
a FLAC file sufficient to make things go wrong?

> Anyway, should be fixed in r35469.

Yes, it is, thank you very much.

########################################################################

svn log -v -r 35469
------------------------------------------------------------------------
r35469 | reimar | 2012-11-25 12:37:52 +0100 (Sun, 25 Nov 2012) | 2 lines
Changed paths:
   M /trunk/libmpdemux/demux_audio.c

Fix bitrate calculation for FLAC files.

------------------------------------------------------------------------


svn diff -r 35468:35469
Index: libmpdemux/demux_audio.c
===================================================================
--- libmpdemux/demux_audio.c	(Revision 35468)
+++ libmpdemux/demux_audio.c	(Revision 35469)
@@ -603,8 +603,9 @@
 	      int32_t srate;
 	      stream_skip(s, 14);
 	      srate = stream_read_int24(s) >> 4;
-	      num_samples  = (uint64_t)stream_read_int24(s) << 16;
-	      num_samples |= stream_read_word(s);
+	      num_samples  = stream_read_char(s) & 0xf;
+	      num_samples <<= 32;
+	      num_samples |= stream_read_dword(s);
 	      if (num_samples && srate)
 	        sh_audio->i_bps = size * srate / num_samples;
 	    }


########################################################################

-- 
Regards

Ilja


More information about the MPlayer-users mailing list