od - dump files in octal and other formats

-N, --read-bytes=BYTES
       limit dump to BYTES input bytes


[ocmpadm@TBMCU 3gp]$ od -N 1  ../wav/test2.wav
0000000 000122
0000001
[ocmpadm@TBMCU 3gp]$ od -N 2  ../wav/test2.wav
0000000 044522
0000002

1 byte 를 볼 때. 2 bytes 를 볼 때,
위와 같이 8진수 000122 , 044522 가 나온다.

[ocmpadm@TBMCU 3gp]$ od -N 3  ../wav/test2.wav
0000000 044522 000106
0000003
[ocmpadm@TBMCU 3gp]$ od -N 4  ../wav/test2.wav
0000000 044522 043106
0000004
3 bytes, 4 bytes 도 마찬가지

[ocmpadm@TBMCU 3gp]$ od -N 16  ../wav/test2.wav
0000000 044522 043106 000226 000002 040527 042526 066546 020164
0000020

[ocmpadm@TBMCU 3gp]$ od -N 32  ../wav/test2.wav
0000000 044522 043106 000226 000002 040527 042526 066546 020164
0000020 000020 000000 000001
000001
000001 017500 000000 037200 000000
0000040

한 라인에 16 bytes 를 보여준다.

헥사에디터처럼 ASCII 코드로 변환된 값을 볼 수 없을까?
[ocmpadm@TBMCU 3gp]$ od -N 32 -a  ../wav/test2.wav
0000000   R   I   F   F syn nul stx nul   W   A   V   E   f   m   t  sp
0000020 dle nul nul nul soh nul soh nul   @  us nul nul nul   > nul nul
[ocmpadm@TBMCU 3gp]$ od -N 32 -t a  ../wav/test2.wav
0000000   R   I   F   F syn nul stx nul   W   A   V   E   f   m   t  sp
0000020 dle nul nul nul soh nul soh nul   @  us nul nul nul   > nul nul
0000040

오.. -t a 또는 -a 를 사용하면 된다.

-t, --format=TYPE
       select output format or formats

 Traditional format specifications may be intermixed; they accumulate:
     -a     same as -t a,  select named characters

     -b     same as -t oC, select octal bytes

     -c     same as -t c,  select ASCII characters or backslash escapes

     -d     same as -t u2, select unsigned decimal shorts

     -f     same as -t fF, select floats

     -h     same as -t x2, select hexadecimal shorts

     -i     same as -t d2, select decimal shorts

     -l     same as -t d4, select decimal longs

     -o     same as -t o2, select octal shorts

     -x     same as -t x2, select hexadecimal shorts


044522 043106
R  I   F  F

[ASCII 코드]
R 122
I 111
F 106
F 106

R - 122(8) -> 52(16) -> 01010010(2)
I - 111(8) -> 49(16) -> 01001001(2)

[RI 값을 순차로 적으면]
R        I
01010010 01001001

[od 결과값 word(2bytes)]
044522(8)
I        R
01001001 01010010

=> 바이트의 순서가 순차가 아님.
하위바이트(Little-Endian)가 먼저 나온다.

아래는 WAV Format
The canonical WAVE format starts with the RIFF header:0         4   ChunkID          Contains the letters "RIFF" in ASCII form                               (0x52494646 big-endian form).4         4   ChunkSize        36 + SubChunk2Size, or more precisely:                               4 + (8 + SubChunk1Size) + (8 + SubChunk2Size)                               This is the size of the rest of the chunk                                following this number.  This is the size of the                                entire file in bytes minus 8 bytes for the                               two fields not included in this count:                               ChunkID and ChunkSize.8         4   Format           Contains the letters "WAVE"                               (0x57415645 big-endian form).The "WAVE" format consists of two subchunks: "fmt " and "data":The "fmt " subchunk describes the sound data's format:12        4   Subchunk1ID      Contains the letters "fmt "                               (0x666d7420 big-endian form).16        4   Subchunk1Size    16 for PCM.  This is the size of the                               rest of the Subchunk which follows this number.20        2   AudioFormat      PCM = 1 (i.e. Linear quantization)                               Values other than 1 indicate some                                form of compression.22        2   NumChannels      Mono = 1, Stereo = 2, etc.24        4   SampleRate       8000, 44100, etc.28        4   ByteRate         == SampleRate * NumChannels * BitsPerSample/832        2   BlockAlign       == NumChannels * BitsPerSample/8                               The number of bytes for one sample including                               all channels. 
34        2   BitsPerSample    8 bits = 8, 16 bits = 16, etc.          2   ExtraParamSize   if PCM, then doesn't exist          X   ExtraParams      space for extra parametersThe "data" subchunk contains the size of the data and the actual sound:36        4   Subchunk2ID      Contains the letters "data"                               (0x64617461 big-endian form).40        4   Subchunk2Size    == NumSamples * NumChannels * BitsPerSample/8                               This is the number of bytes in the data.                               You can also think of this as the size                               of the read of the subchunk following this                                number.44        *   Data             The actual sound data.

'OS > linux / unix' 카테고리의 다른 글

vim tip - tabstop, sts, sw / ESC  (0) 2010.07.31
fedora 12 - core dump file 생성 안되는 문제  (0) 2010.07.22
howtoforge.com  (0) 2010.06.22
emacs 사용기  (0) 2010.06.21
sip tcpdump option  (0) 2010.06.10
Latest update: 2010. 7. 9. 16:14