ID3 的語系設定

客戶又抱怨為啥我們的 ID3 顯示經常是亂碼, 競爭者每次都對, 一定不是運氣的關係… 於是我只好又求助 Google 大神了. 果然, ID3 的規格是這樣寫的, 無論有幾個 frame, 每個 frame 都由 frame ID, frame size 和 flag 共 10 個 bytes 開頭, 後續至少有 1 byte 的 content. 如果 frame ID = TLAN, 就表示 ID3 的語系寫在後面的 3 個 bytes 裡面. [1]

這三個 bytes 採用  ISO 3166-1 alpha-3 的定義 [2], 包括簡體 (CHN), 繁體 (TWN) 都有. 據說本來這個定義是用在護照上面, 機器讀到這個代號, 就知道這是哪個國家. 

那麼, 既有 alpha-3, 也會有 alpha-2 嗎?有! 此時中國是 CN, 台灣就是  TW, 美國就是 US [3]. 1但是兩個字母的組合太少, 辨識上比較困難. 南韓叫做 KR, 北韓叫做 KP, 就是沒人認領 KO (knock out)…

[REF]

1.  http://www.id3.org/id3v2.3.0#ISO-639-2

2. http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

3.  http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

真假 QuickTime

我們的客戶一直強調不可以播 Quick Time 格式. 但是什麼是 Quick Time 格式呢? 我 Google 了一下, 但是 keyword 不對, 怎麼也抓不到重點. 像是 "wiki quicktime" 這些都沒用. 唯一有用的 keyword 是 "quicktime spec.", 只有願意看規格的人才找得到答案. :D

 Apple 認為 Quick Time 格式是 MPEG4 的基礎, 雖然 quick time 和 MPEG4 長得很像, 但是 Quick Time 是 Apple 的智慧財產權, 和 MPEG4 不能混為一談!如果因為長得很像, 就當做同一個東西的話, Apple 豈不是要和 MPEG-LA  分權利金了嗎?當然不行囉!

Important:  The QuickTime File Format has been used as the basis of the MPEG-4 standard and the JPEG-2000 standard, developed by the International Organization for Standardization (ISO). While these file types have similar structures and contain many functionally identical elements, they are distinct file types.

QuickTime file format 由一個個的 atom 組成, 每個 atom 都和 MPEG-4 的 box 差不多. 再強調一次, 只是看起來很像…

Note: An atom, as described in this document, is functionally identical to a box, as described in the ISO specifications for MPEG-4 and JPEG-2000. An atom that includes version and flags fields is functionally identical to a full box as defined in those specifications.

對於一個典型的 MOV 檔, 它就是以 movie atom, movie data atom 所構成的 quick time file. 這個 movie atom 後面會跟著 4 bytes 的 atome size, 接著就是 4 個 byte 的 atom type. 當 atom type = ftyp, 那麼它可能就是一個 MPEG-4 或是 JPEG2000.

緊接在 ftyp 後面就是這個 atom 的 data, data 的開頭則可能是 major band.

Major_Brand

A 32-bit unsigned integer that should be set to 'qt  ' for QuickTime movie files. If a file is compatible with multiple brands, all such brands are listed in the Compatible_Brands fields, and the Major_Brand identifies the preferred brand or best use.

 所以 ftypqt 連在一起, 就是 quick time 的 MPEG04. 除了 major band 還有 compatible band, 它包含了 major band.

Compatible_Brands

A series of unsigned 32-bit integers listing compatible file formats. The major brand must appear in the list of compatible brands. One or more “placeholder” entries with value zero are permitted; such entries should be ignored.

如果 compatible band 沒有一個是 qt, 那麼這個 file 就不是 Quicktime movie. 因此, 判斷方式很明顯了. 就算附檔名看起來一樣, 檔案結構很相似, 但是有個明顯的標記區分著 QuickTime 和一般 MPEG4 或 MOV, 賴也賴不掉~~~

Note: A common source of this error is an MPEG-4 file incorrectly named with the .mov file extension or with the MIME type incorrectly set to “video/quicktime”. MPEG-4 files are automatically imported by QuickTime only when they are correctly identified as MPEG-4 files using the Mac OS file type, file extension, or MIME type.

[ref] 

在 Mac 底下用 UART debug

MBP 又出新款, 感覺我的這台又貶值了許多. 總之, 今天的主題是, 怎樣在 MacBook 下透過 UART debug.

首先我們要買一條 USB 轉 RS232 的線, 它不算貴 (360 NTD), 所以還要多買幾樣東西才能達到 PCHOME 的免運費標準. 我買的這條是 Atake 的, driver 在這裡抓:rs232-newdriver-091031.zip.

接下來安裝 Mac OS 10 的 driver, 重新開機後, 上面會出現一個像是電話的 icon.

點選這個 icon, 會進入網路選項. 接著進入右下角的 “進階…". 莫驚慌, “進階" 裡面沒啥東西. 此時要選擇的 modem 是 null modem, 速率看狀況. 但撥號前等撥號音, 可以避免它亂撥號, 否則會收不到 QA board 傳回的 print, 也就是所謂的打印信息.

此外, 就是要記得把終端機打開, 終端機命令取消.

當然, 這有點投機取巧. 對 MBP 來說, 我開了視窗卻沒撥號, 只是一個暫態. 因此相關的視窗是以 “連線中" 的方式佔據了前景, 只能放大還不能縮小. 不過, 在沒有更高科技的解法之前, 大家也可以像我一樣湊合著用.

3GP 和 3G2 的音視頻格式差異

3GP 和 3G2 是手機上的錄影格式, 也用在 MMS (Multimedia Message Service), IMS (IP Multimedia Subsystem), MBMS (Multimedia Broadcast  / Multicast Service) 和 PSS (Personal Public Service) 的影音服務上. 他們主要的差異是用在不同的電話系統, 一個用在 GSM, 另一個用在 CDMA.

Video 的部份看起來是互通的, 但是 audio 看起來差很大.

分類
異同
3GP (for GSM) 3G2 (for CDMA)
video 共同 MPEG4, H263, H264
不同 ? ?
audio 共同 AMR-NB,AMR-WB,LC-AAC,HE-AAC V1
不同 AWR-WB+, HE-AAC V2

EVRC,EVRC-B,EVRC-WB,

13K (QCELP), SMV,VMR-WB

AIFF 小檔案

AIFF 全名 audio interchange file format, 我們沒說要支援, 結果播起來有聲音, 被客戶發 bug, 成了傷腦筋的問題.

為什麼沒有支援也可以播呢?因為它有時並沒有壓縮, 和純 PCM 的 wave 檔差不多.

如果名稱是 *.AIFF 或 *.AIF, 檔案是 little endian. 如果名稱是 *.AIFC, 則為 big endian.

不過 iTune 的 AIFF 內容其實是 AIFC. 這就是為何我們改口說 "乾脆支援 AIFF 算了!" 結果反而又被發 3 個 bug 的原因.

 AIFF 和 WAV (RIFF)  檔簡單比較一下:

RIFF Note AIFF Note
Chunk ID RIFF Chunk ID FORM
Chunk Size 4 Bytes Chunk Size 4 Bytes
RIFF DATA WAVE form data AIFF
 一到多個 chunk   各種 chunk 1
Offset Size Description Value
0x00 4 Chunk ID "fmt " (0x666D7420)
0x04 4 Chunk Data Size 16 + extra format bytes
0x08 2 Compression code 1 – 65,535
0x0a 2 Number of channels 1 – 65,535
0x0c 4 Sample rate 1 – 0xFFFFFFFF
0x10 4 Average bytes per second 1 – 0xFFFFFFFF
0x14 2 Block align 1 – 65,535
0x16 2 Significant bits per sample 2 – 65,535
0x18 2 Extra format bytes 0 – 65,535
0x1a Extra format bytes *
Common Chunk
Sound Data Chunk
Name Chunk
Author Chunk
Copyright Chunk
Annotation Chunk
Audio Recording Chunk
Application Chunk
ID3 Chunk
MIDI Data Chunk
未壓縮
Code Description
0 (0x0000) Unknown
1 (0x0001) PCM/uncompressed
2 (0x0002) Microsoft ADPCM
6 (0x0006) ITU G.711 a-law
7 (0x0007) ITU G.711 µ-law
17 (0x0011) IMA ADPCM
19 (0x0013) ADPCM (Sierra)
20 (0x0016) ITU G.723 ADPCM (Yamaha)
49 (0x0031) GSM 6.10
64 (0x0040) ITU G.721 ADPCM
80 (0x0050) MPEG
257 (0x0101) IBM µ-law
258 (0x0102) IBM a-law
259 (0x0103) IBM AVC Adaptive Differential PCM
65,536 (0xFFFF) Experimental

NONE (未壓縮)

fl32 (32 bits floating)
fl64 (64 bits floating)
a-law
u-law
FL32 (32 bits floating)
ADP4 (4:1 Intel/DVI ADPCM)
ima4 (IMA 4:1)
ACE2 (ACE 2-to-1)
ACE8 (ACE 8-to-3)
DWVW(Delta With Variable Word Width)
MAC3 (MACE 3-to-1)
MAC6 (MACE 6-to-1)
Qclp (Qualcomm PureVoice)
QDMC (QDesign Music)
rt24 (RT24 50:1)
rt29 (RT29 50:1) 

壓縮格式, 寫在 Common chunk