swf_file_format_spec_v10.pdf を読んでみた

何気なく SWF の公式サイトを覗いてみたら、

SWF File Format Specification (Version 10)

何時の間にか*1 Version 10 が出てました。

 The SWF 10 specification expands text capabilities with support for
bidirectional text and complex scripts with the new DefineFont4 tag.
 The DefineBitsJPEG4 tag allows embedding JPEG images that have an alpha
channel for opacity and also a smoothing filter.
 SWF 10 also adds support for the free and open-source Speex voice codec
and for higher frequencies in the existing Nellymoser codec.

という事なので、拡張されたものを箇条書きにすると

  • DefineFont4 タグを追加 (今までより複雑な文字を扱える*2 )
  • DefineBitsJPEG4 タグを追加 (スムージングフィルタ)
  • 音声コーデックを増強 (Speex*3対応と Nellymoser の高周波対応)

の3点になります。

DefineBitsJPEG4

個人的に気になるのは、DefineBitsJPEG4 なので熟読しました。

DefineBitsJPEG3 の AlphaDataOffset(透明度データ) と ImageData(透明度を含まないRGBの画像データ)
の間にDeblockParam (2byte) が入るのが DefineBitsJPEG4 です。

 - DeblockParam 
 - UI16
    Parameter to be fed into the deblocking filter.
  The parameter describes a relative strength of the deblocking filter
  from 0-100% expressed in a normalized 8.8 fixed point format.

を元に説明すると、DefineBitsJPEG3 は、

 +---------------------------------------------------------------
 | tag | length |    length    |  image_id | offset_to_alpha | ..
 |  35 |  0x3f  |              |           |                 |
 +---------------------------------------------------------------
 <-- 2 bytes --> <-  4 bytes -> <-2 bytes-> <--  4 bytes -->
                                <--- length (最後まで)  ---

  ---+------------------------------+-------------------+
  .. | encoding_tables | image_data |   alpha(zlib圧縮) |
  ---+------------------------------+-------------------+
     <--    offse_to_alpha      --> <-contents 残り全部->

で、DefineBitsJPEG4 は、

 +---------------------------------------------------------------
 | tag | length |    length    |  image_id | offset_to_alpha | ..
 |  35 |  0x3f  |              |           |                 |
 +---------------------------------------------------------------
 <-- 2 bytes --> <-  4 bytes -> <-2 bytes-> <--  4 bytes -->
                                <--- length (最後まで)  ---

  ---+-------------+-----------------+------------+-------------------+
  .. |deblock_param| encoding_tables | image_data |   alpha(zlib圧縮) |
  ---+-------------+-----------------+------------+-------------------+
      <- 2 bytes ->                               <-contents 残り全部->
      <------------ offset_to_alpha ------------->

となります。 Wiki に早速追記 ↓

deblock_param は デブロッキングフィルタに渡す値で、デブロッキングフィルタは、
ブロックノイズの発生を抑えるのに H.264 で使われている技術だそうです。

さらに、「デブロッキング・フィルタ」は、圧縮によって歪んでしまった画像の
見栄えを向上させます。デジタル圧縮の際に画像をブロックごとに区切って扱うと、
ブロックごとに色や輝度が違ってしまうために、人間の目には、機械が区切った
ブロックが判別できてしまいます。これは俗にブロックノイズと呼ばれるのですが、
デブロッキング・フィルタでは、隣り合った2つのブロックが自然につながるように
画像を調整します。この仕組みによって、高い圧縮率で縮めたデータでも鑑賞できる
画像を作り出せるのです。

なるほど。概要は理解できました。

自分はフラッシュプレイヤーを作るわけではないので、とりあえず
今回増えた値の意味が分かればいいって事にしておきます。

もっと細かい差分

結構色々と、機能や仕様が fix されてます。

*1:実は去年の11月に出てたので浦島すぎるのですが、自分が気づいたのは今日なので…アンテナ低w

*2:具体的には、ヘブライ語アラビア語みたいに文字を左方向に読むのとか、タイ語みたいに色んな方向に続く文字まで表現できます。

*3:フリーのボイス向け音声コーデック