2010年6月16日 星期三

Mpeg2 video note

opencore小記:

在取m2v height and width的時候 必須從Sequence Header的第5,6,7,byte去取

ex:seqence header buffer :  00  00  01  B3  xx  xx  xx

其中width是前三個x也就是12個bits,height 是後三個x

但因為最小單位是byte的原故所以要手動拆第6個byte

這裡用的方法是:
tempW=(int)pNalBuffer[4];
tempW=(tempW<<4)+(pNalBuffer[5]>>4);
tempH=(int)pNalBuffer[5];
tempH=(tempH<<8)+(pNalBuffer[6]);



不知道有沒有更好的解法~



Matlab 型態轉換

一開始覺得Matlab是一個彈性很高的語言

很多變數都不需經過宣告就可以只接使用和傳遞

可是到了最近

發現以前在資工上程式語言的書上提到的一些毛病都一一浮現出來了= =

其中卡了兩三天的issue就是型態的轉換

其實只要這麼下就好了...

dec2hex(typecast(int8(bytex(i)),'uint8'));

%cast int8 variable to unsigned int8,then transfer to hex from decimal

%aim:big5 to utf-8