QDraw: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
m (revert spam)
(add link to Apple PICT documents; expand the description a bit (still very incomplete))
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
''This page is based on the codec description written by Konstantin Shishkov found in the document Description of the Apple Quicktime Animation (RLE) Format located at [http://multimedia.cx/qtrle.txt http://multimedia.cx/qtrle.txt].''
''This page is based on the codec description written by Konstantin Shishkov found in the document Description of the Apple QuickTime Animation (RLE) Format located at [http://multimedia.cx/qtrle.txt http://multimedia.cx/qtrle.txt].''


* FOURCCs: qdrw
* FourCC: qdrw
* Company: [[Apple]]
* Company: [[Apple]]
* Specification: [http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-333.html http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-333.html]
* Samples: [http://samples.mplayerhq.hu/V-codecs/QT-qdrw/ http://samples.mplayerhq.hu/V-codecs/QT-qdrw/]


QDraw is another RLE format supported by the Quicktime multimedia system. It is identified by the FOURCC 'qdrw'. QDraw frames contain palettized 8-bit pixel data and transport their own palette data within frames.
QDraw is really just a standard QuickDraw PICT resource inside of a QuickTime container. It is identified by the FOURCC 'qdrw'. The PICT format can support both vector- and raster-based images.
 
However, only v2 8-bit paletted PackBits images have been found in QuickTime files so far. Most of this document is based on this assumption as well as having no other QuickDraw opcodes present in the frame and is therefore incomplete.


== Data Format ==
== Data Format ==
Line 12: Line 16:
An encoded QDraw frame is laid out as follows:
An encoded QDraw frame is laid out as follows:


   bytes 0-103    unknown
   bytes 0-1      low two bytes of the frame size
  bytes 2-103    QuickDraw header/opcode data
   bytes 104-107  number of colors - 1
   bytes 104-107  number of colors - 1
   bytes 108..    color table (8 bytes per entry)
   bytes 108..    color table (8 bytes per entry)
Line 25: Line 30:
Thus, the color table can update arbitrary entries in the palette.
Thus, the color table can update arbitrary entries in the palette.


Following the color table are 18 undetermined bytes. After these bytes, there is a series of RLE-encoded lines. For each line in the image:
Following the color table are 18 bytes describing the PackBits source/destination rectangles and mode. After these bytes, there is a series of RLE-encoded lines using the standard PackBits compression (if mode is 0 "default" or greater than 2). For each line in the image:


   first 2 bytes indicate size in bytes of compressed line
   if (row bytes is > 250)
    two bytes compressed line size
  else
    one byte compressed line size
   while (remaining bytes in compressed line)
   while (remaining bytes in compressed line)
     code = next byte in encoded frame
     code = next byte in encoded frame

Latest revision as of 22:06, 12 November 2011

This page is based on the codec description written by Konstantin Shishkov found in the document Description of the Apple QuickTime Animation (RLE) Format located at http://multimedia.cx/qtrle.txt.

QDraw is really just a standard QuickDraw PICT resource inside of a QuickTime container. It is identified by the FOURCC 'qdrw'. The PICT format can support both vector- and raster-based images.

However, only v2 8-bit paletted PackBits images have been found in QuickTime files so far. Most of this document is based on this assumption as well as having no other QuickDraw opcodes present in the frame and is therefore incomplete.

Data Format

All multi-byte numbers are encoded in big-endian format.

An encoded QDraw frame is laid out as follows:

 bytes 0-1      low two bytes of the frame size
 bytes 2-103    QuickDraw header/opcode data
 bytes 104-107  number of colors - 1
 bytes 108..    color table (8 bytes per entry)

One color table entry is laid out as:

 byte 0-1   index of palette table entry to replace
 byte 2-3   16-bit red component
 byte 4-5   16-bit green component
 byte 6-7   16-bit blue component

Thus, the color table can update arbitrary entries in the palette.

Following the color table are 18 bytes describing the PackBits source/destination rectangles and mode. After these bytes, there is a series of RLE-encoded lines using the standard PackBits compression (if mode is 0 "default" or greater than 2). For each line in the image:

 if (row bytes is > 250)
   two bytes compressed line size
 else
   one byte compressed line size

 while (remaining bytes in compressed line)
   code = next byte in encoded frame
   if (top bit is set (code & 0x80))
     output next byte in encoded frame to decoded frame (257-code) 
        times
   else
     copy (code + 1) bytes from encoded frame to decoded frame