cr88192

BTIC5B, Working Spec

Dec 2nd, 2021
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. BTIC 5B
  2. * FOURCC: 'bt5b'
  3. * Will use a differential encoding for endpoints.
  4. * Will use an otherwise similar design to BT5A.
  5. * Focus primarily on 4x4 blocks within an RGB555 colorspace.
  6.  
  7.  
  8. === TLV ===
  9.  
  10. Frame TLV:
  11. * 0x00..0x1F: 8K, TWOCC
  12. * 0x20..0x3F: 8K, FOURCC
  13. * 0x40..0x5F: 512M, TWOCC
  14. * 0x60..0x7F: 512M, FOURCC
  15. * 0x80..0x9F: 2M, TWOCC
  16. * 0xA0..0xBF: 2M, FOURCC
  17.  
  18. TwoCC:
  19. * 'IX': Image Data (I-Frame), No LZ
  20. * 'PX': Image Data (P-Frame), No LZ
  21. * 'HX': Optional Header
  22. * 'PT': Color Palette
  23.  
  24. * 'Z3': Frame Encoded with RP2
  25. * 'Z4': Frame Encoded with LZ4
  26. ** LZ Compressed frames will be preceded by a small 32-bit header:
  27. *** (23: 0): Uncompressed Size
  28. *** (31:24): Reserved / Zero
  29. ** LZ may not be applied recursively.
  30.  
  31. Header:
  32. * u16 width; //image frame width
  33. * u16 height; //image frame height
  34. * u16 flags; //some control flags
  35. ** 1: Uses simple skip rather than motion compensation.
  36. *** This mode does not need a second block buffer or copying in the decoder.
  37.  
  38. The frame size will be internally padded up to a multiple of 4 pixels, though the width and height will represent the actual / non-padded resolution.
  39.  
  40.  
  41. === Image Data ===
  42.  
  43. The encoded stream will be byte-based.
  44.  
  45.  
  46. ==== Color Endpoints ====
  47.  
  48. When relevant, a pair of endpoint colors may be encoded.
  49.  
  50. This will nominally use 15-bit conjoined endpoint vectors:
  51. * ( 0): 0
  52. * ( 1): Dy0
  53. * ( 5: 2): Cb
  54. * ( 6): Dy1
  55. * (10: 7): Cg
  56. * ( 11): Dy2
  57. * (15:12): Cr
  58.  
  59. Conceptually, the conjoined endpoint will be decoded to RGB555 endpoints as:
  60. * Ar=(Cr*2)+Dy*2
  61. * Ag=(Cg*2)+Dy*2
  62. * Ab=(Cb*2)+Dy*2
  63. * Br=(Cr*2)-Dy*2
  64. * Bg=(Cg*2)-Dy*2
  65. * Bb=(Cb*2)-Dy*2
  66.  
  67. Note that these calculations will not saturate and carry may effect the LSB of the decoded 555 endpoints. In effect, the application of the delta will be via a 16-bit add operation.
  68.  
  69. Delta Endpoints:
  70. * ( 0): 1
  71. * (2:1): dDy
  72. ** 0: dDy=-1 / A and B
  73. ** 1: dDy= 0 / A only
  74. ** 2: dDy=+1 / B only
  75. ** 3: Escape (Endpoint Pair)
  76. * (7:3): Delta
  77. ** Encoded as a 3*3*3 Blocks
  78. *** Each delta is 0/1/2 -> -1/0/+1
  79. *** Dv5=(dCr*9)+(dCg*3)+dCb;
  80. *** Valid range is 00..1A
  81. ** 1B : 15 / 30 bit Delta (3x 5-bit / 6x 5-bit)
  82. ** 1C..1D: 17-bit Delta (2x 7^3, Mod 360^2)
  83. ** 1E..1F: 9-bit Delta (7^3)
  84. *** Each component encodes -3..+3
  85. *** These deltas are only valid for Endpoint Pairs.
  86.  
  87.  
  88. Endpoint Pair:
  89. * ( 2: 0): 111
  90. * ( 6: 3): Bb
  91. * (11: 7): Bg
  92. * (16:12): Br
  93. * (21:17): Ab
  94. * (26:22): Ag
  95. * (31:27): Ar
  96.  
  97.  
  98. A delta endpoint may be used when the block endpoints are similar to the prior endpoint.
  99.  
  100. The interpretation of a delta endpoint will depend on the mode from the prior endpoint. If a conjoined endpoint, the delta will apply to the center value (with A and B being recalculated). If an endpoint pair, the delta may be applied to each color in the pair (Dy is ignored).
  101.  
  102.  
  103. ==== Pixel Blocks ====
  104.  
  105. Blocks may be encoded in several forms:
  106. * 2x2x1, 2x2 with 1 bit selectors.
  107. * 2x2x2, 2x2 with 2 bit selectors.
  108. * 4x4x1, 4x4 with 1 bit selectors.
  109. * 4x4x2, 4x4 with 2 bit selectors.
  110.  
  111. With a 1 bit selector:
  112. * 1: Color A (Max)
  113. * 0: Color B (Min)
  114.  
  115. With a 2 bit selector:
  116. * 3: Color A (Max)
  117. * 2: 2/3*ColorA + 1/3*ColorB
  118. * 1: 1/3*ColorA + 2/3*ColorB
  119. * 0: Color B (Min)
  120.  
  121. The 2-bit selector will be defined as an approximation:
  122. * 11/32 + 21/32
  123.  
  124.  
  125. Within each block, pixels will be stored in raster order starting from the least significant bit. By convention, within an AVI or BMP container, the raster origin will be defined as the lower-left corner.
  126.  
  127.  
  128. ==== Pattern Table ====
  129.  
  130. The pattern table will consist of 64 patterns.
  131. * The low 3 bits will encode a horizontal sign and frequency.
  132. * The high 3 bits will encode a verical sign and frequency.
  133.  
  134. The frequency field:
  135. * 0: 2, 2, 2, 2,
  136. * 1: 4, 2, -2, -4,
  137. * 2: 4, -1, 1, -4,
  138. * 3: 4, -4, 4, -4,
  139. * 4: -2, -2, -2, -2,
  140. * 5: -4, -2, 2, 4,
  141. * 6: -4, 1, -1, 4,
  142. * 7: -4, 4, -4, 4
  143.  
  144. The pattern table will be generated by adding the horizontal and vertical fields (similar to a matrix multiply), and comparing each component result with zero.
  145.  
  146.  
  147. ==== Blocks and Commands ====
  148.  
  149. Pattern Table Reference:
  150. * ( 0): 0
  151. * ( 1): p (Endpoint Present)
  152. * ( 7: 2): Pattern Table Index
  153. * ( 8+): (p==1): Endpoint.
  154.  
  155. Small Motion Vector / Skip (P-Frame):
  156. * ( 1: 0): 01
  157. * ( 4: 2): Dx (-3..+3), Dx!=7
  158. * ( 7: 5): Dy (-3..+3), Dy!=7
  159. ** Copy block with the given motion vector delta.
  160. ** Dx=7 (Dy=0..6): Copy Run of 1..7 blocks relative to last vector.
  161. ** Dy=7 (Dx=0..6): Reset motion vector to Zero, do a Skip run.
  162. * Dx=7, Dy=7: Copy a longer run of blocks (Last Vector).
  163. ** (15:8): Run of 4-258 Blocks (FF=Reserved)
  164.  
  165. Small 2x2 Block:
  166. * ( 2: 0): 011
  167. * ( 3): p (Endpoint Present)
  168. * ( 7: 4): 2x2x1
  169. * ( 8+): (p==1): Endpoint.
  170.  
  171. Small Run (4x4x1):
  172. * ( 4: 0): 00111
  173. * ( 5): p (Endpoint Present)
  174. * ( 7: 6): nn
  175. * ( 8+): (p==1): Endpoint
  176. * ( 8++): (nn+1) * 4x4x1
  177.  
  178. Small Run (2x2x1):
  179. * ( 5: 0): 010111
  180. * ( 7: 6): nn
  181. * ( 8+): (nn+1) * (2 * 2x2x1)
  182.  
  183. Small Run (2x2x2):
  184. * ( 5: 0): 110111
  185. * ( 7: 6): nn
  186. * ( 8+): (nn+1) * (2x2x2)
  187.  
  188. Small Run (Flat):
  189. * ( 4: 0): 01111
  190. * ( 7: 5): nnp
  191. ** Run of 1-4 blocks, Flat Color (p: Color Bit)
  192.  
  193. Small Run, Flat Color per Block:
  194. * ( 5: 0): 011111
  195. * ( 7: 6): nn
  196. ** Run of 1-4 blocks, Endpoint Per Block
  197.  
  198. Bigger 4x4x2 Block:
  199. * ( 6: 0): 0111111
  200. * ( 7): p (Endpoint Present)
  201. * (39: 8): Pixel Bits, 4x4x2
  202. * ( 40+): (p!=0): Endpoint
  203.  
  204. * ( 7: 0): 11111111
  205. * (10: 8): 011
  206. * ( 11): p (Color Selector)
  207. * (15:12): nnnn
  208. ** Run of n*4+8 blocks (8..68), Flat Color
  209.  
Advertisement
Add Comment
Please, Sign In to add comment