DiracInAVI

From Diracvideo

Jump to: navigation, search

[edit] Dirac AVI Muxing

The FOURCC used for Dirac is 'drac'.

The AVISTREAMHEADER is used to identify a stream, and it must contain the following:

  • fcc = FOURCC('strh')
  • cb = sizeof(AVISTREAMHEADER) - sizeof(fcc) - sizeof(cb)
  • fcctype = FOURCC('vids')
  • fccHandler = FOURCC('drac')
  • dwFlags = 0 or AVISF_DISABLED
  • dwSampleSize = 0
  • dwRate = frame rate denominator
  • dwScale = frame rate numerator
  • Remaining fields will have to be filled in as needed. Most can default to zero.

A BITMAPINFOHEADER is put inside the stream identification header, it should be written as followed:

  • biSize must be set to sizeof(BITMAPINFOHEADER)
  • biWidth must to the width the video is encoded with
  • biHeight must to the height the video is encoded with
  • biPlanes must be set to 1
  • biBitCount should be set to 0x7f00 + a value from SchroChromaFormat (SCHRO_CHROMA_444 = 0, SCHRO_CHROMA_422 = 1 or SCHRO_CHROMA_420 = 2), so that decoders can guess the chroma format without examining the first sequence header.
  • biCompression must be set to FOURCC('drac')
  • biSizeImage must be zero
  • The remaining fields must be zero

[edit] Streamed mapping

In AVI itself the mapping has to be done slightly different. AVI assumes that every AVI chunk contains 1 *decodable* video frame. Schroedinger doesn't work this way, so the only way to do this is by inserting multiple schroedinger frames in a single video frame, and pad with zero-sized avi chunks where needed.

Since you can parse the length fom a schroedinger packet easily, this is not really hard. It's 'B','B','C','D', control byte, (big endian 4 bytes, 32 bits total)length.

The problem is how to do it while leaving seeking to a random point in the file working correctly. AVI has a concept of 'keyframes', every 'keyframe' must start with a dirac sequence header, and must have at least 1 I-frame.

Zero-sized chunks don't have to exist on the disk, a mention in the avi index of a chunk of size zero is sufficient as well.

Because of this, decoders should decode only 1 frame per chunk given, whether the frame is empty or not. Upon encountering a new sequence header, it must send all the frames that were still left in the buffer though, however this should not happen, unless the avi was encoded wrongly. A decoder may issue a warning for this case, since for every avi chunk there should be a decodable frame. An empty frame should just be decodable with previously given data. I'm not sure if implementations of the avi parser will send empty frames or not, though, if they don't then just decode everything immediately.


Personal tools