[MPlayer-dev-eng] [PATCH] read wav files in nBlockAlign chunks

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Jan 14 10:45:14 CET 2006


Hi,
On Sat, Jan 14, 2006 at 12:58:58AM +0100, Roberto Togni wrote:
> On Sat, 7 Jan 2006 00:26:45 +0100
> Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> > First, I think nBlockAlign might be 0. Second, it can be very small
> > (esp. for raw files), resulting in a very high demuxing overhead.
> > Can't you just round nAvgBytesPerSec by nBlockAlign (if non-zero)?
> > 
> Attached patch does it, please test.

Oops, completely forgot about that. I actually wanted to suggest a
different approach.
The difference:
I think your approach might break the alignment with very low bitrate
files.
On the other hand, my patch might cause problems with very large values
of nBlockAlign - though I just checked, nBlockAlign is only 16 bits
(unsigned) so I think it might actually be better ("accidentially"
rounding the block size to at most 64k should rarely be problematic).
Of course my "formula" is more ugly though ;-)

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.42
diff -u -r1.42 demux_audio.c
--- libmpdemux/demux_audio.c	18 Nov 2005 14:39:18 -0000	1.42
+++ libmpdemux/demux_audio.c	14 Jan 2006 09:35:54 -0000
@@ -428,7 +442,10 @@
       }
     } break;
   case WAV : {
+    unsigned align = sh_audio->wf->nBlockAlign;
     l = sh_audio->wf->nAvgBytesPerSec;
+    if (align)
+      l = (l + align - 1) / align * align;
     dp = new_demux_packet(l);
     l = stream_read(s,dp->buffer,l);
     priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps;


More information about the MPlayer-dev-eng mailing list