Bug 2807 - AVI Output Fix from Avery Lee
Status: RESOLVED DUPLICATE of bug 2808
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Video
Version: unspecified
Hardware: All All
: P2 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2006-07-29 19:45 EDT by Zachary J. Slater
Modified: 2007-05-21 11:26:53 EDT
0 users

See Also:



Description Zachary J. Slater 2006-07-29 19:45:04 EDT
E-mail from author follows:

I am the author of a video program for Windows called VirtualDub. Recently
a user reported a compatibility issue with AVI files written by ioquake3, a
Quake III Arena derivative for which you are listed as a contact on the web
page at http://icculus.org/quake3/.

I took a look at two of the AVIs produced by ioquake3, and both of them had
significant errors in RIFF structure -- specifically, the lengths of
several LIST chunks in the header were incorrect. This prevents both
VirtualDub's AVI parser and the Microsoft DirectShow AVI Splitter from
reading the files. I suspect that the problem is the following code in
ioquake3's cl_avi.c:

static ID_INLINE void END_CHUNK( void )
{
  int endIndex = bufIndex;

  if( afd.chunkStackTop <= 0 )
  {
    Com_Error( ERR_DROP, "ERROR: Bottom of chunkstack breached\n" );
  }

  afd.chunkStackTop--;
  bufIndex = afd.chunkStack[ afd.chunkStackTop ];
  bufIndex += 4;
  WRITE_4BYTES( endIndex - bufIndex - 1 );
  bufIndex = endIndex;
  bufIndex = PAD( bufIndex, 2 );
}


The length field for a LIST chunk should be set to the size of all
enclosing chunks plus the list type field, but not the LIST FOURCC itself
or the length field. Since the START_CHUNK() function pushes the location
of the chunk FOURCC onto the stack, I think the code should be this:

static ID_INLINE void END_CHUNK( void )
{
  int endIndex = bufIndex;

  if( afd.chunkStackTop <= 0 )
  {
    Com_Error( ERR_DROP, "ERROR: Bottom of chunkstack breached\n" );
  }

  afd.chunkStackTop--;
  bufIndex = afd.chunkStack[ afd.chunkStackTop ];
  WRITE_4BYTES( endIndex - bufIndex - 8 );
  bufIndex = endIndex;
  bufIndex = PAD( bufIndex, 2 );
}

This should improve the compatibility of AVI files produced by ioquake3
without side effects.
Comment 1 Thilo Schulz 2006-07-30 06:59:35 EDT
If I apply this author's modifications I get this:

thilo@Thilo ~/.q3a/baseq3/videos $ mplayer video0002.avi
MPlayer 1.0pre8-3.4.5 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 Processor 3200+ (Family: 15, Model: 31, Stepping: 0)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2


Playing video0002.avi.

AVI file format detected.
AVI: Missing video stream!? Contact the author, it may be a bug :(


Exiting... (End of file)


The way it is now works with mplayer.
Comment 2 Thilo Schulz 2006-07-31 09:09:23 EDT

*** This bug has been marked as a duplicate of 2808 ***
Comment 3 Ryan C. Gordon 2007-05-21 11:26:53 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.