2010年4月16日 星期五

JPEG Library Study

 jpeg_write_raw_data() -->

jpeg_write_raw_data() 每次16行,也就是一個 imcu row

encode_mcu_huff() 被 call 8160 次
encode_one_block() 被 call 65280次

2010年4月13日 星期二

Warning: Image exceeds specified memory size by 9280 bytes and may not run.

When makeimg, there is the warning above.
AUTOSIZE
要修改 config.bib 或 eboot.bib

ce.bib 也是最終的 bib

WINCE 6 SD Card driver build error, PBInitEnv.bat

In AU1200 BSP, build SD Card driver has the following error!
There is no SDbus.lib.
So remove SD Card driver.
In platform.bib we want to remove BSP_SDHC_AU1X,
and it is defined in PBInitEnv.bat.

But PBInitEnv.bat is created by system.
When u setup catalog item. It will write variables to pbinitenv.bat.

2010年3月11日 星期四

MP4 格式解密

根據 14496-12  ISO base media file format,
以下幾個atom是必要的

ftyp
moov
         mvhd
         trak
                tkhd
                mdia
                        mdhd
                        hdlr
                        minf
                                dinf
                                       dref
                                stbl
                                      stsd
                                      stts
                                      stsc
                                      stco

但根據實測,少了 stss, quicktime 無法正常播放。

stco 是fill 資料chunk 的offset,而且以file 開頭來計算。

2010年2月1日 星期一

JPEG emit_bits_s

emit_bits_s()  called by encode_one_block() in jchuff.c
所做的事就是單純地把bit 輸出

put_buffer 32bit 只用到右邊24bit
每次進來的bits 最多是16bit
再加上之前殘餘的最多不超過8bit( <= 7bit )
所以24bit 就足夠了


At most 16 bits can be passed to emit_bits

 in one call, and we never retain more than 7 bits in put_buffer
 between calls, so 24 bits are sufficient.

前次殘餘的bit + 這次進來的 bit
超過8bit 就輸出一個byte

1. 進來的code
2. 往左shift 靠在第24bit的位置
3. OR 之前的bit
4. 每8個bit 輸出一個byte 直到資料小於8bit

MP4 Audio Mux & AAC header format

用 DVBPortal (mp4creator) mux AVC & AAC
總共有2個trak
2個 mdat section




AAC Header
(參考 http://mp4tech.net/document/audiocomp/0000207.asp )

 http://www.hydrogenaudio.org/forums/lofiversion/index.php/t21617.html



AAC的音频文件格式有以下两种:
ADIF:Audio Data Interchange Format 音频数据交换格式。这种格式的特征是可以确定的找到这个音频数据的开始,不需进行在音频数据流中间开始的解码,即它的解码必须在明确定义的开始处进行。故这种格式常用在磁盘文件中。

ADTS:Audio Data Transport Stream 音频数据传输流。这种格式的特征是它是一个有同步字的比特流,解码可以在这个流中任何位置开始。它的特征类似于mp3数据流格式。


Mux 完在mp4 mdat section 中的aac 比原始的aac 少了n個 7bytes的header
這些header 的格式為 FF F1 DC 40 XX XX XX

emphasis field 2 bit 現在沒有用了,所以是 Fixed header( 28bits) + Variable header(28bits) = 7 bytes

sync word  12bit : 1111 1111 1111  所以是 FF F

ID 1     0: MPEG-4, 1: MPEG-2

layer 2 always: '00'


protection_absent 1

profile 2

sampling_frequency_index 4

private_bit 1

channel_configuration 3

original/copy 1

home 1

ADTS Variable header: these can change from frame to frame


copyright_identification_bit 1

copyright_identification_start 1

aac_frame_length 13 length of the frame including header (in bytes)

adts_buffer_fullness 11 0x7FF indicates VBR

no_raw_data_blocks_in_frame 2

ADTS Error check

crc_check 16 only if protection_absent == 0

After that come (no_raw_data_blocks_in_frame+1) raw_data_blocks.

Some elaborations:

profile

bits ID == 1 (MPEG-2 profile) ID == 0 (MPEG-4 Object type)

00 (0) Main profile AAC MAIN

01 (1) Low Complexity profile (LC) AAC LC

10 (2) Scalable Sample Rate profile (SSR) AAC SSR

11 (3) (reserved) AAC LTP



 
ADTS詳細格式請參考 14496-3
由上可知 AAC Frame Length 為13bit, 所以一個AAC Frame最大值為8K
ADIF格式主要是應用在一般的檔案資料中,而ADTS格式則主要利用在網路的傳輸 上,為了避免傳輸產生的錯誤,ADTS格式在AAC檔案的每一個音框(frame)中都傳一次檔 頭;而ADIF格式只有一個檔頭。


ADTS 每一個frame前都有加檔頭 7bytes,
然後檔頭後面的格式 為raw format
有七種格式
常見的為
CPE
請參考 14496-3
http://www.aeroquartet.com/movierepair/aac.html


CPE 格式

21 0B CF or 21 0B CD

0010 0001 0000 1011 1100


1. 前3個bit 代表格式 在這邊 001 代表 此frame 為CPE ( Channel Pair Element )
其它還有 000   SCE ( Single Channel Element )
                 010  CCE
                 011  LFE ....
2. 再來 4個bit 為 element_instance_tag
3. 再來1個bit 為 common_window
4. 如果 common_windows 為1 在CPE中 接下來就是 ics_info
5. window_sequence 如果等於 EIGHT_SHORT_SEQUENCE (10) 就 ...
在此我們可以看到 window_sequence 不等於 EIGHT_SHORT_SEQUENCE
6. maxsfb 在此為 6bit 101111 (47)  剛好是呼叫 AACQuantize() 時 參數num_cb 的值

2010年1月6日 星期三

Y Color Range, Color space problem

Old standard use ITU 601
HD format use ITU 709

ITU 709 使用不同的轉換公式

Rec. 601 Y' = 0.299 R' + 0.587 G' + 0.114 B'
Rec. 709 Y' = 0.2126 R' + 0.7152 G' + 0.0722 B'

請參考
http://www.glennchan.info/articles/technical/hd-versus-sd-color-space/hd-versus-sd-color-space.htm
還有Rec. 709 in wikipedia
http://en.wikipedia.org/wiki/Rec._709

http://dcmc.ee.ncku.edu.tw/pdf/course/Reports/Adaptive_Logarithmic_Mapping_For_Displaying_High_Contrast_Scenes.pdf

sRGB 和 Rec. 709 的primaries 一樣

Color 校正討論
http://my3c.com/D5/archiver/?tid-3187.html


Color system  ( Color appearance model )

CIEXYZ 1931
CIELAB 1976

Munsell 1930s
CIECAM 2002

CIECAM02 is used in Windows Vista's Windows Color System.