[MPlayer-dev-eng] Re: [PATCH] encoding audio with libavcodec

Arpi arpi at thot.banki.hu
Mon Nov 3 12:26:56 CET 2003


Hi,

> I wrote:
> > [imaadpcm] sound is distorted a bit.
> 
> This seems to be a bug in the libavcodec encoder...
> Except for that it's working fine for me now.
> 
> Arpi, can you comment on the muxer_avi change?
> This basically reverts the r1.4->r1.5 change (log message "fixed AVI header
> creation - now should be compatible with NaNdub"), the offending line is
> 
> |#define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(((wf)->cbSize)?((wf)->cbSize-2):0))

WTF

> which unconditionally subtracts 2 from cbSize.  For MP3 audio Virtualdub
> complains the header is too short (30 vs. 28 bytes) and for adpcm the 2
> additional bytes are not written at all.
> 
> I think
> #define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(wf)->cbSize)
> should be correct.

I think it comes from the problem of badly padded WAVEFORMATEX struct:

typedef struct __attribute__((__packed__)) _WAVEFORMATEX {
  WORD   wFormatTag;
  WORD   nChannels;
  DWORD  nSamplesPerSec;
  DWORD  nAvgBytesPerSec;
  WORD   nBlockAlign;
  WORD   wBitsPerSample;
  WORD   cbSize;
} WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;

it's 2+2+4+4+2+2+2 = 18 bytes long, but if you define it wihtout the
__attribute__((__packed__)), you'll get sizeof(WAVEFORMATEX) == 20.
that packed sttribute was not there long time ago, so i guess that
unconditional -2 was there to "fix" this...

so it's ok to revert, imho.


A'rpi / Astral & ESP-team

--
Developer of MPlayer G2, the Movie Framework for all - http://www.MPlayerHQ.hu



More information about the MPlayer-dev-eng mailing list