[MPlayer-dev-eng] vbr mp3 runtime

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Sep 25 15:22:01 CEST 2011


On Thu, Sep 15, 2011 at 04:06:23PM +0200, Ingo Brückl wrote:
> +static unsigned int mp3_vbr_frames(stream_t *s, off_t off) {
> +  uint8_t hdr[HDR_SIZE];
> +  int framesize, chans, spf, layer;
> +  const off_t xing_offt[2][2] = {{32, 17}, {17, 9}};
> +
> +  if ((s->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK) {
> +
> +    if (!stream_seek(s, off)) return 0;
> +    if (stream_read(s, hdr, HDR_SIZE) != HDR_SIZE) return 0;

Since your code will break completely if HDR_SIZE is anything but 4,
using it serves at best as obfuscation.
Even more since stream_read_dword in all cases except maybe this first
should result in much more readable code.
And have you tested all cases? Because the FFmpeg code until recently
read things from the wrong place for one of the headers.

> @@ -382,6 +440,8 @@
>  	demux_info_add(demuxer,"Genre",genres[g]);
>        }
>      }
> +    if (duration) sh_audio->wf->nAvgBytesPerSec = demuxer->movi_end / duration;
> +    sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec;

Why not just move this to where sh_audio->i_bps is already assigned
currently?
Also I am not sure demuxer->movi_end is necessarily set/!= 0.


More information about the MPlayer-dev-eng mailing list