안드로이드 전체 소스를 git에서 다운받아서 빌드하고 테스트 해보자.

개발환경
- OS : Ubuntu 8.10 desktop

구글도 우분투를 권장하고 있을 뿐만 아니라 안드로이드 개발에 있어서는 우분투에서 개발하는 것이 좋은 점이 많다. 특히 에뮬레이터 네트워크 이슈등으로 인해서.

안드로이드 전체 소스코드 빌드 방법에 대해서는 다음의 글을 참고하여 직접 해 본 것이다.
http://www.kandroid.org/board/board.php?board=androidsource&command=body&no=4

1. 환경설정

위의 kandroid.org 의 글에서처럼 필요한 패키지들을 설치해 준다.
다음의 예제들은 우분투 데스트탑 터미널이나 원격 터미널을 통해서 실행할 수 있다.

sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
sudo apt-get install valgrind

해당 패키지들을 설치하는 중에 의존성 에러등이 발생할 경우에는 해당 의존 패키지들을 설치해 준다. 대부분은 'yes'를 통해서 설치만 해 주면 된다.

다음으로는 Java SDK가 설치되어 있지 않다면 Java SDK를 설치해 주어야 한다. kandroid.org 글에서는 우분투 apt-get을 통한 SUN SDK를 설치하도록 되어 있는데 여기서는 아래의 링크를 통해서 SUN Java SDK 버전을 다운받아서 설치하도록 한다.

우분투에서 Java 설치하기

여기서 잠시 살펴볼 것은 현재 버전이 JDK1.6.0_14 임으로 update-alternatives를 다음과 같이 실행해 준다.

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/jdk1.6.0_14/bin/java" 1
sudo update-alternatives --config java

기존에 기설치된 JDK가 존재할 경우 -config 옵션을 통해서 선택하게 해 준다. 방금 설치한 JDK1.6.0_14 버전을 선택해 준다.

java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)

"java -version" 커맨드를 통해서 자바 버전을 확인해 본다.

다음은 repo 명령어를 실행하기 위해서 계정 내에서 bin 디렉토리를 만들어 준다.

mkdir bin

지금까지 설정한 환경에 대한 셋팅을 마무리한다.

vi ~/.bashrc


해당 파일에 다음을 추가한다.

export LANG=c
export PATH=/home/<user_home>/bin:$PATH:.
export JAVA_HOME=/usr/local/jdk1.6.0_14
export ANDROID_JAVA_HOME=$JAVA_HOME

시스템을 재로그인 하거나 원격일 경우 로그아웃 한 후 재접속해 준다.


2. git 설치

git는 최근의 연구대상이다. 인터넷을 통해서 많은 자료를 찾을 수 있다. 다음의 자료를 통해서 대략적인 것을 이해할 있다.

git 사용자 설명서

우분투 터미널에서 다음과 같은 명령어를 통해서 git 를 설치하고, android.git의 repo를 로컬로 옮겨온다.

sudo apt-get install git-core gnupg
curl http://android.git.kernel.org/repo >/home/<user_home>/bin/repo
repo 커맨드를 실행할 수 있는 파일로 변경해 준다.

chmod a+x ~/bin/repo


3. Android 소스 다운로드 하기

안드로이드 소스를 다운로드하기 위한 로컬의 저장소를 만들어주고, 해당 디렉토리로 이동한다.

mkdir mydroid & cd mydroid

android 소스가 존재하는 git 주소로 초기화 해 준다.

repo init -u git://android.git.kernel.org/platform/manifest.git

원격 git 주소와 로컬의 저장소를 동기화 해 준다. 이 과정이 안드로이드 소스를 다운로드 받는 것이다.

repo sync

이 과정을 통해서 안드로이드 소스를 다운받게 되는데 다운로드를 받아보니 현재(2009.06.16) 기존으로 1.4GB 이다. 따라서 식사시간 전에 sync를 걸어주는 게 좋다.
간혹 네트워크 상태가 좋치 않거나 서버와의 접속이 끊어지는 경우가 있다. repo sync 명령어를 계속해서 입력해 주면 된다.

사용자 삽입 이미지

4. Android 소스 빌드

안드로이드 소스 코드를 다 받게 되면 make 명령어를 통해서 빌드하게 된다.

cd mydroid
make


현재 테스트해 본 결과로는 별도의 에러가 발생하지 않는다. 하지만 Java 관련 명령어의 링크가 제대로 동작하지 않아 에러를 발생하는 경우를 볼 수 있었다. 예를 들면 다음의 에러와 같다.

build/core/product_config.mk:261: WARNING: adding test OTA key
============================================
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=
============================================
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
make: execvp: /bin/bash: Argument list too long
host Java: clearsilver (out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/classes)
/bin/bash: javac: command not found
make: *** [out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar] Error 41


javac 커맨드를 찾을 수 없다는 말이니깐 "sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/jdk1.6.0_14/bin/javac 1" 명령어를 통해서 해결할 수 있다.

javah, javadoc, jar 에 대해서도 동일한 에러가 발생하였음으로 위의 명령어를 통해서 해결할 수 있다.

빌드 시간이 2시간 남짓 걸렸다...ㅡㅡ;; 암튼 많은 시간을 투자해야 하니 처음부터 긴 시간을 각오하는게 좋다^^


5. 빌드 테스트

전체 소스 빌드를 성공하였다면 img 파일이 정상적으로 동작하는 지 살펴보아야 한다. "mydroid/out/target/product/generic" 디렉토리를 살펴보자. 아래의 그림과 같이 system.img, ramdisk.img, userdata.img 파일을 포함한 다양한 파일, 폴더가 생성되어져 있어야 한다.

사용자 삽입 이미지


이제 ramdisk.img, system.img, userdata.img 파일들을 이용하여 실제로 SDK의 에뮬레이터를 구동해 보면 된다.
이를 위해서 Android SDK1.5_r2 를 설치해 주어야 한다.

http://developer.android.com/sdk/1.5_r2/index.html

각 플랫폼에 맞는 SDK를 설치해 주면 된다. 만약 SDK1.5 버전을 최초로 설치하였다면 AVD(Android Virtual Device)를 생성해 주어야 한다. 다음과 같이 해 준다. 이 때 Android SDK 설치 디렉토리의 "ANDROID_HOME/tools" 디렉토리에서 해 주어야 한다.

./android create avd -n <device_name> -t 2

위의 명령어 옵션 중에 -n 다음에 붙는 것은 이미지의 이름이고, -t 다음에 붙는 것은 SDK 버전을 뜻한다. 인터넷 상에 Android SDK 1.5 설치 관련된 자료가 많으니 참고하길 바란다.

이제 모든 준비가 되었다. 에뮬레이터를 먼저 구동해 보고 Android SDK 1.5가 정상적으로 설치되었는지 확인해 다음 위에서 빌드한 파일로 테스트해 보자.

./emulator -avd <device_name>


위의 명령어를 통해서 에뮬레이터를 실행하면 SDK로 설치한 img 파일로 실행된다. App 들이 정상적으로 동작하는지 확인해 보자.

다음은 에뮬레이터를 종료시키고 빌드한 img 파일을 이용하여 에뮬레이터를 동작시켜 보자.

./emulator -adv <device_name> -ramdisk <file> -system <file> -initdata <file>


형태로 실행하면 되는데 <file> 에 해당하는 img 파일들을 절대경로로 지정해 주면 된다.
-ramdisk 다음의 파일을 "ramdisk.img", -system 다음의 파일은 "system.img", -initdata 다음의 파일은 "userdata.img" 이다.

Android SDK 1.x 에서는 -system 옵션이 -image 였다. 이전의 자료들을 보면 -image 옵션으로 설명한 곳들이 있으니 주의하기 바란다.

에뮬레이터가 정상적으로 구동하고 application 들이 정상적으로 구동되면 안드로이드 전체 소스 빌드를 성공한 것이다.

[출처] http://blog.wimy.com/313

우분투 10.04 에서 암호 및 암호화 키 문제 해결하기 - 우분투원

우분투 10.04 를 깔고나서, 우분투원을 사용하려고 하면, 이상하게 계속 기본 새 키 모음 암호를 입력하라고만 나오고 암호를 계속 입력해도 제대로 진행되지 않았다. 조금 살펴보니, 아무래도 기본키의 파일명에 한글(기본.keyring)이 있어서 그런것 같았다. 결과적으로, 이 문제를 해결하기 위해서 다음과 같이 하였다.

~/.gnome2/keyrings 의 모든 파일들을 삭제한다.
'프로그램 -> 보조 프로그램 -> 암호 및 암호화 키' 를 실행한다.
'파일 -> 새로 만들기...'
암호 키 모음 -> 계속
새 키 모음 이름을 'newkey' 입력 후 '추가' 버튼 누름
새 키 모음 암호 창에서 암호 입력 -> 확인 버튼
방금 만들어진 키에 오른 클릭 -> 기본으로 설정

기본키의 파일명이 기본.keyring 이던 것을 newkey.keyring 으로 생성해준 것이다.

이렇게 한 후 우분투원을 실행해보자.

1. 우분투 명령창에서 다음의 명령실행

sudo apt-get install tcl tk

우분투 command shell에서 다음의 명령을 순서대로 행한다

1. sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n

2. sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n libwxgtk2.8-dev libgtk2.0-dev

[출처] http://ubuntu-virginia.ubuntuforums.org/showthread.php?t=1264341

우분투에서 리눅스 커널 프로그래밍 / Linux kernel programming on Ubuntu

kernel programming using ubuntu

Hello,

I'm a linux kernel newbie and want to "play/dig deeper" into the linux kernel. I want to do this using Ubuntu (9.04 x86).

To be able to do this, I'd like to use the same kernel repository (pref.. svn) as the one that is being used by Ubuntu. I ofcourse won't be checking in any code into that repository. Can some one give me some pointers on how to go about doing this?

Re: kernel programming using ubuntu

just install the kernel source package:
sudo apt-get install linux-source
Thus you'll get always the same kernel-source as the currenty installed ubuntu-kernel.

Now move into the directory /usr/src .You will see a file called linux-source-2.6.28.tar.bz2
This is a zipped file. You can extract it with
cd /usr/src && sudo tar -xvjf linux-source-2.6.28.tar.bz2 in a terminal window
Now you have the linux-source code in the directory /usr/src/linux-source-2.6.28

If you want to compile your own kernel, take a look at the Master Kernel Thread: http://ubuntuforums.org/showthread.php?t=311158

But if it comes to point 4 (downloading the kernel sources from kernel.org), skip this point if you want the same kernel sources as your currently installed ubuntu, because if you download this source, you will get the sources from kernel.org, which does'nt have the ubuntu-patches
__________________
watch out where the huskies go
and don't you eat that yellow snow (Zappa)

http://www.youtube.com/watch?v=YGZ5isu23ow
http://www.youtube.com/watch?v=aKOy_q1ykP0

Last edited by hal10000; September 12th, 2009 at 04:44 AM..

[출처] http://linux.flyduck.com/moduleprog/lkp/


리눅스 커널 프로그래밍

다음은 리눅스 커널 프로그래밍을 공부에 도움이 되도록
제가 만든 자료입니다. 자세한 설명이나 깊은 내용은 없지만 유용하게 사용하시길 바랍니다.

강의자료

All files

Hello, World

Character Device Driver

Advanced Character Device Driver

Proc filesystem

Ioctl

Timer

System Call

Block Device Driver

Example : PC Speaker

[출처] http://osswin.sourceforge.net/

The OSSwin project: Open Source for Windows!

Support This Project

(24/12/2005): OSSwin now also has a separate games page. Go check it out and please promote the organization of an Open-Source-only LAN-party in your neighbourhood!

Please also report broken links to the osswin-users mailinglist, and if you really like this list and want to keep me motivated, then just send me something from my wishlist which can be found somewhere over here.

Cheers,
Bart Vandewoestyne

Audio editing tools

Tag tools:

Business Software

CAD software and Electronic Design Automation (EDA)

Calendar Software

CD Writing

Compression/ZIP

Databases

Desktop Environments & Windows shell replacements

Dictionaries

Drivers/Hardware

Educational

Emulators

Amiga:
Apple:
Atari:
DOS:
IA-32
Sega Master System:
Sega Genesis / Mega Drive
PowerPC
Sega Genesis / Sega CD / Sega 32X:
Sega Dreamcast:
Sega Saturn:
Super Nintendo
Nintendo 64
ZX Specrum
Other
  • QEMU [GNU GPL/GNU LGPL/MIT/BSD]

Encyclopedia

Filesharing

Ares
BitTorrent
Direct Connect:
Gnutella2/Shareaza
HeavyMole
IRC:
Kazaa/Fasttrack:
MUTE
NetMess:
OpenFT:
OpenNap/Napster:
Soulseek:
Others:

FTP clients

Firewall & NAT

Firewall:
NAT:

File systems (drivers)

Games

See this separate page and don't hesitate to organise the first Open-Source-Games-Only LAN-party in your neighbourghood!

Graphics

Instant Messaging

Internet Voice chat

SIP VoIP:

IRC clients

Mail & News

Accessing HTTPMail services like Hotmail, Yahoo,... (I need testers for this software, please mail me your experiences!)
  • YahooPOPs! [GNU GPL]
  • HotPOP3 [GNU GPL]
  • FreePOPs [GNU GPL]
  • MrPostman [GNU GPL] (Note: has been reported not to work with the current HotMail system...)
  • jHTTPMail [GNU LGPL] (how to use this??? is it a library ???)
  • HTTPMail [GNU LGPL] (how to use this??? is it a library???)
  • Blue HTTPMail [zlib/libpng License] (How to use this???)
Anti-Spam

Media Players (audio)

Media Players (video)

Media Players (codecs)

MC303 utilities

(only Linux, sorry... but i had to add this one ;-)

Networking tools

NTP clients

Office tools

Operating Systems

PostScript viewers

Programming

Ada:
Assembler:
Basic:
C:
Delphi:
Fortran:
Haskell:
Java:
Lua:
  • Lua [MIT license]
Mercury:
.NET
Pascal:
Perl:
PHP:
Prolog
Python:
Ruby:
Scheme:
IDE's:
Installer systems:
CVS:
Subversion:
Decompilers:
GUI toolkits
Computer Graphics libraries
  • SDL (Simple DirectMedia Layer) [GNU LGPL]
  • Little cms [GNU LGPL]
  • Mesa3D [MIT-style license]
  • G3D [BSD]
  • VTK (The Visualization Toolkit) [Other/Proprietary License???]
Libraries

Remote access

Sciences and Math

Mathematics:
Biology:
Geographic Information Systems:

Maybe there's more on the FreeGIS site, if you find stuff, please report it.

General:

Security, Privacy, Protection,...

Server software

CVS:
DHCP:
DNS:
FTP servers:
Identd:
Jabber servers:
Java/XML application server
Mail and News:
Webservers:
Napster servers:
NFS servers:
SSH-servers:
Other:

SCP (SecureCoPy) clients

Stream Downloaders

Text editors

Utilities

Video capture/processing

VJ Software

Web browsers

Webcam

Web editors

Webgrabbers and Download Managers

X-servers

Others

Valid XHTML 1.0! SourceForge.net Logo

Last Update: December 21st, 2009

[출처] http://www.opensourcewindows.org/

Web Browsing

firefox

Mozilla Firefox

The premier free, open-source browser. Tabs, pop-up blocking, themes, and extensions. Considered by many to be the world's best browser.
Download Page

Video Player, BitTorrent, Podcasting

miro

Miro

Beautiful interface. Plays any video type (much more than windows media player). Subscribe to video RSS, download, and watch all in one. Torrent support. Search and download from YouTube and others.
Download Page

IM - Instant Messaging

gaim

Pidgin

Connect to multiple IM accounts simultaneously in a single app, including: AOL IM, MSN, and Jabber.
Download Page

Video Converter- MP4, iPhone, Android

video converter

Miro Video Converter

Convert any type of video to mp4 or theora. Convert any video for use with iPhone, iPod, Android, etc. Very clean, easy to use interface.
Download Page

Download helpers

Skipscreen

SkipScreen

A Firefox extension that skips unnecessary clicks and wait times on Rapidshare, Megaupload, Mediafire, zShare, and more.
Download Page

E-mail

thunderbird

Mozilla Thunderbird

Powerful spam filtering, solid interface, and all the features you need.
Download Page

RSS

rssowl

RSSOwl

Solid cross-platform RSS client.
Download Page

Peer-to-Peer Filesharing

cabos

Cabos

A simple, easy to use filesharing program. Gnutella network.
Download Page
gnucleus

Gnucleus

A very good Gnutella search and download filesharing program.
Download Page

Video Playback

miro

Miro

Beautiful interface. Plays any video type (much more than windows media player). Subscribe to video RSS, download, and watch all in one. Torrent support. Search and download from YouTube and others.
Download Page
VLC

VLC

Plays more video files than most players: Quicktime, AVI, DIVX, OGG, and more. Pretty good interface.
Download Page
MPlayer

MPlayer

Similar to VLC-- plays loads of video formats.
Download Page
media player classic

Media Player Classic

Compact, but powerful media player. Plays anything under the sun. No install necessary.
Download Page

Word Processing / Office Suites

open office

OpenOffice.org

Big, full featured suite of tools for word processing and spreadsheets. Compatible with and a free replacement for Microsoft Word d0cuments. Also supports OpenDocument Format.
Download Page
abiword

AbiWord

A word processor. Leaner and quicker than OpenOffice. Compatible with Microsoft Word d0cuments and OpenDocument Format.
Download Page

Podcasting

juice

Juice

Solid podcasting client.
Download Page

DVD Ripping

handbrake

Handbrake

DVD to MPEG-4 ripper/converter.
Download Page

Sound Recording

audacity

Audacity

Simple sound recording tool.
Download Page

Graphics / Photo Editing

gimp

GIMP

Photo editing application that rivals Photoshop in features.
Download Page
paint.net

Paint.NET

Graphics editor with a very nice interface.
Download Page
inkscape

Inkscape

Vector graphics application.
Download Page

FTP / SFTP

filezilla

Filezilla

Excellent FTP program.
Download Page

IRC

xchat2

X-Chat 2

IRC client.
Download Page

Archiving

PeaZip

PeaZip

Fantastic archiving utility to extract and pack archives of an extensive amount of formats. PeaZip also features password protecting archives, keyfile support, system integration, a lovely interface, and much more.
Download Page

[출처] http://www.theosfiles.com/general/osf_free_oses.htm

Free OSes

A number of manufacturers and groups provide OSes for free individual use, or in some cases, unrestricted use! Like anything that's free, don't expect printed manuals, CD-ROMs, or free technical support. Other than that, there are few, if any strings attached. Also note that with the size of most OSes, downloads of 1 to 10 GB of data may not be that exciting, so paying for the DVD/CD-ROM or even a low-cost base package may be well worth it to you.

The OS Files LinkDownload Comments
FreeDOSdownload-pageAn independently developed DOS, with source code
RxDOSdownload-pageAn independently developed DOS, with source code
Debian Linuxdownload-pageLinux download FTP sites
Fedora Linuxdownload-pageRed Hat's free Linux
Koppix CD Linuxdownload-pageLinux that runs directly from CD
Mandriva Linuxdownload-pageLinux download page
PCLinuxOSdownload-pagePCLinuxOS download page
Red Hat Linuxdownload-pageRed Hat's download page
Slackware Linuxdownload-pageDownload from HTTP or FTP
SUSE Linuxdownload-pageDownload SUSE Linux
Ubuntu Linux download-pageDownload Ubuntu Linux
Darwindownload-pageDownload (requires agreement acceptance, etc.)
Free BSDdownload-pageFree Unix OS
NetBSDdownload-pageFree Unix OS, supported on many CPU platforms
OpenBSDdownload-pageFree Unix OS, supported on many CPU platforms
Solarisdownload-pageFree download
AROSdownload-pageFree, source code available
ReactOSdownload-pageFree Windows compatible OS
SkyOSdownload-pageGUI OS (in beta, was free, but now charging $30)
Visopsysdownload-pageFree, source code available

MPEG Audio Layer I/II/III frame header

There is no main file header in an MPEG audio file. An MPEG audio file is built up from a succession of smaller parts called frames. A frame is a datablock with its own header and audio information.

In the case of Layer I or Layer II, frames are some totally independent items, so you can cut any part of MPEG file and play it correctly. The player will then play the music starting to the first plain valid frame founded. However, in the case of Layer III, frames are not always independant. Due to the possible use of the "byte reservoir", wich is a kind of buffer, frames are often dependent of each other. In the worst case, 9 frames may be needed before beeing able to decode one frame.

When you want to read info about an MPEG audio file, it is usually enough to find the first frame, read its header and assume that the other frames are the same. But this is not always the case, as variable bitrate (VBR) files may be encountered. In a VBR file, the bitrate can be changed in each frame. It can be used, as an exemple to keep a constant sound quality during the whole file, by using more bits where the music need more to be encoded.

The frame header is 32 bits (4 bytes) length. The first twelve bits (or first eleven bits in the case of the MPEG 2.5 extension) of a frame header are always set to 1 and are called "frame sync".

Frames may have an optional CRC checksum. It is 16 bits long and, if it exists, follows the frame header. After the CRC comes the audio data. By re-calculating the CRC and comparing its value to the sored one, you can check if the frame has been altered during transmission of the bitstream.

Here is a presentation of the frame header content. Characters A to M are used to indicate different fields. In the table below, you can see details about the content of each field.

AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM

SignLength
(bits)
Position
(bits)
Description
A11(31-21)Frame sync (all bits must be set)
B2(20,19)MPEG Audio version ID
00 - MPEG Version 2.5 (later extension of MPEG2)
01 - reserved
10 - MPEG Version 2 (ISO/IEC 13818-3)
11 - MPEG Version 1 (ISO/IEC 11172-3)

Note: MPEG Version 2.5 was added lately to the MPEG 2 standard. It is an extension used for very low bitrate files, allowing the use of lower sampling frequencies. If your decoder does not support this extension, it is recommended for you to use 12 bits for synchronization instead of 11 bits.

C2(18,17)Layer description
00 - reserved
01 - Layer III
10 - Layer II
11 - Layer I
D1(16)Protection bit
0 - Protected by CRC (16bit CRC follows header)
1 - Not protected
E4(15,12)Bitrate index
bitsV1,L1V1,L2V1,L3V2,L1V2, L2 & L3
0000freefreefreefreefree
0001323232328
00106448404816
00119656485624
010012864566432
010116080648040
011019296809648
01112241129611256
100025612811212864
100128816012814480
101032019216016096
1011352224192176112
1100384256224192128
1101416320256224144
1110448384320256160
1111badbadbadbadbad

NOTES: All values are in kbps
V1 - MPEG Version 1
V2 - MPEG Version 2 and Version 2.5
L1 - Layer I
L2 - Layer II
L3 - Layer III

"free" means free format. The free bitrate must remain constant, an must be lower than the maximum allowed bitrate. Decoders are not required to support decoding of free bitrate streams.
"bad" means that the value is unallowed.

MPEG files may feature variable bitrate (VBR). Each frame may then be created with a different bitrate. It may be used in all layers. Layer III decoders must support this method. Layer I & II decoders may support it.

For Layer II there are some combinations of bitrate and mode which are not allowed. Here is a list of allowed combinations.

bitrate
single channel
stereo
intensity stereo
dual channel
free
yes
yes
yes
yes
32
yes
no
no
no
48
yes
no
no
no
56
yes
no
no
no
64
yes
yes
yes
yes
80
yes
no
no
no
96
yes
yes
yes
yes
112
yes
yes
yes
yes
128
yes
yes
yes
yes
160
yes
yes
yes
yes
192
yes
yes
yes
yes
224
no
yes
yes
yes
256
no
yes
yes
yes
320
no
yes
yes
yes
384
no
yes
yes
yes

F2(11,10)Sampling rate frequency index
bitsMPEG1MPEG2MPEG2.5
0044100Hz22050Hz11025Hz
0148000Hz24000Hz12000Hz
1032000Hz16000Hz8000Hz
11reserv.reserv.reserv.
G1(9)Padding bit
0 - frame is not padded
1 - frame is padded with one extra slot

Padding is used to exactly fit the bitrate.As an example: 128kbps 44.1kHz layer II uses a lot of 418 bytes and some of 417 bytes long frames to get the exact 128k bitrate. For Layer I slot is 32 bits long, for Layer II and Layer III slot is 8 bits long.
H1(8)Private bit. This one is only informative.
I2(7,6)Channel Mode
00 - Stereo
01 - Joint stereo (Stereo)
10 - Dual channel (2 mono channels)
11 - Single channel (Mono)

Note: Dual channel files are made of two independant mono channel. Each one uses exactly half the bitrate of the file. Most decoders output them as stereo, but it might not always be the case.
One example of use would be some speech in two different languages carried in the same bitstream, and then an appropriate decoder would decode only the choosen language.
J2(5,4)Mode extension (Only used in Joint stereo)

Mode extension is used to join informations that are of no use for stereo effect, thus reducing needed bits. These bits are dynamically determined by an encoder in Joint stereo mode, and Joint Stereo can be changed from one frame to another, or even switched on or off.

Complete frequency range of MPEG file is divided in subbands There are 32 subbands. For Layer I & II these two bits determine frequency range (bands) where intensity stereo is applied. For Layer III these two bits determine which type of joint stereo is used (intensity stereo or m/s stereo). Frequency range is determined within decompression algorithm.

Layer I and IILayer III
valueLayer I & II
00bands 4 to 31
01bands 8 to 31
10bands 12 to 31
11bands 16 to 31
Intensity stereoMS stereo
offoff
onoff
offon
onon

K1(3)Copyright
0 - Audio is not copyrighted
1 - Audio is copyrighted

The copyright has the same meaning as the copyright bit on CDs and DAT tapes, i.e. telling that it is illegal to copy the contents if the bit is set.
L1(2)Original
0 - Copy of original media
1 - Original media

The original bit indicates, if it is set, that the frame is located on its original media.
M2(1,0)Emphasis
00 - none
01 - 50/15 ms
10 - reserved
11 - CCIT J.17

The emphasis indication is here to tell the decoder that the file must be de-emphasized, ie the decoder must 're-equalize' the sound after a Dolby-like noise supression. It is rarely used.

© 1999-2001 Gabriel Bouvigne for MP3'Tech - www.mp3-tech.org

MPEG1 Audio Layer3

mp3 파일은 여러개의 AAU(Audio Access Uint)들과 1개의 AudioTag로 이루어져 있다.

AAU AAU AAU ... Audio Tag

 

각각의 AAU들은 다음과 같은 구조를 가진다.

Header CRC SideInfo Main Data

 

AAU의 사이즈는 다음과 같다.

144*BitRate/샘플링주파수+Padding 

mp3는 프레임당 1152 비트가 할당되기 때문에 바이트 계산하면 144바이트가 된다. BitRate와 샘플링주파수는 헤더정보에서 얻을 수 있다. 파일 Size가 3985814 바이트이고 샘플링 주파수가 44.1khz, BitRate가 128kbit인 mp3파일의 프레임 Size는 144*128000 / 441000 로 약 417바이트가 되며 프레임당 약 9558바이트의 Size가된다.

 


1. Header

mp3 파일에는 각각의 AAU마다 헤더가 따로 존재한다. 그러므로 각 AAU들은 독립적으로 decode될 수 있다. 그러나 대부분의 mp3에서 모든 헤더들은 동일하므로, 전체를 디코딩할 시에는 첫 번째 AAU의 헤더만을 읽는다.

Header는 32비트의 길이를 갖고 13개의 항목으로 구성되어 있다.

 

길이 설명
11 동기패턴 모두 1로 설정
2 MPEG Audio Version ID 00 - MPEG Version 2.5
01 - reserved
10 - MPEG Version 2
11 - MPEG Version 1(mp3의 경우)
2 Layer 정의 00 - reserved
01 - Layer III
10 - Layer II
11 - Layer I
1 Checksum 설정유무 0 - Error 체크 있음
1 - Error 체크 없음
4 BitRate
MPEG1
Layer1
MPEG1
Layer2
MPEG1
Layer3
MPEG2
Layer1
MPEG2
Layer2,3
0000 free free free free free
0001 32 32 32 32 8
0010 64 48 40 48 16
0011 96 56 48 56 24
0100 128 64 56 64 32
0101 160 80 64 80 40
0110 192 96 80 96 48
0111 224 112 96 112 56
1000 256 128 112 128 64
1001 288 160 128 144 80
1010 320 192 160 160 96
1011 352 224 192 176 112
1100 384 256 224 192 128
1101 416 320 256 224 144
1110 448 384 320 256 160
1111 bad bad bad bad bad
2 샘플링 주파수
MPEG1 MPEG2 MPEG2.5
00 44100 22050 11025
01 48000 24000 12000
10 32000 16000 8000
11 reserved reserved reserved
1 Padding bit 0 - frame is not padded
1 - frame is padded with one extra bit
1 개별용도비트 특별히 사용되지 않음
2 Channel Mode 00 - Stereo
01 - Joint Stereo
10 - Dual Channel
11 - Single Channel
2 확장 Mode(Joint Stereo에서만 사용)
Layer 1,2 Layer 3
Intensity
stereo
MS
stereo
00 subbands 4 to 31 off off
01 subbnads 8 to 31 on off
10 subbnads 12 to 31 off on
11 subbnads 16 to 31 on on
1 Copyright 0 - Audio is not copyrighted
1 - Audio is copyrighted
1 Original 0 - 복사본
1 - 원본
2 Emphasis  

2. CRC

CRC Check는 프레임의 오류를 검사하기 위한 정보를 가진다.

 


3. SideInfo

mp3에서 주요하게 사용되는 압축 알고리즘에는 Scalefactor, Huffman 부호화, 양자화 등이 있다. 실제 각 프레임의 메인데이터를 decoding 하는 데 필요한 정보들을 담고 있다.

 

길이 사이드인포 요소 설명
9 main_data_end mp3 Player 프로그램의 버퍼상에서 비트스트림의 위치
3 Private_bits  
1 Scfsi Scalefactor 디코딩에사용
12 Part2_3_length 허프만 디코딩에 사용
9 Big_values 허프만 디코딩에 사용
8 Global_gain 역양자화에 사용
4 Scalefac_compress Scalefactor Encoding시에 사용
1 Blocksplit_flag  
2 Block_type  
1 Switch_point  
5 Table_select 허프만 디코딩에 사용
3 Subblock_gain 역양자화에 사용
4 Region_address1 허프만 디코딩에 사용
3 Region_address2 허프만 디코딩에 사용
1 Preflag 역양자화에 사용
1 Scalefac_scale Scalefactor 디코딩에 사용, 역양자화에 사용
1 Count1table_select 허프만 코딩에 사용

 

다음에 이 정보를 저장하기 위한 자료구조가 있다.

typedef struct { unsigned long part2_3_length;unsigned long big_values;unsigned long global_gain;unsigned long scalefac_compress;unsigned long window_switching_flag;unsigned long block_type;unsigned long mixed_block_flag;unsigned long table_select[3];unsigned long subblock_gain[3];unsigned long region0_count;unsigned long region1_count;unsigned long preflag;unsigned long scalefac_scale;unsigned long count1table_select;}gr_info_s;typedef struct {unsigned long main_data_begin;unsigned long private_bits; struct {unsigned long scfsi[4]; gr_info_s gr[2]; // 메인데이터는 2개의 granule로 구성}ch[2]; }III_side_info_t;

사이드인포의 크기는 채널에 따라 그 크기가 달라지는데 Mono일 경우 136bits, Stereo일 경우 256bits이다.(메인데이터는 2개의 granule로 나누어지고 각각의 granule은 채널로 나뉘어짐) 사이드인포 정보 중에서 granule별 채널별로 갖고 있는 정보가 있기 때문에 채널에 따라서 그 크기가 다른 것이다.

다음은 사이드 인포 정보를 얻기 위한 소스 코드이다.

// Mono : 136 bits (= 17 bytes)// Stereo : 256 bits (= 32 bytes) BOOL get_side_info(uunsigned long channels, III_side_info_t *side_info) {int ch, gr;side_info->main_data_begin = get_bits(9);if (channels == 1) side_info->private_bits = get_bits(5);else side_info->private_bits = get_bits(3);for (ch=0; chch[ch].scfsi[0] = get_bits(1);side_info->ch[ch].scfsi[1] = get_bits(1);side_info->ch[ch].scfsi[2] = get_bits(1);side_info->ch[ch].scfsi[3] = get_bits(1);}for (gr=0; gr<2; gr++) {for (ch=0; chch[ch].gr[gr].part2_3_length = get_bits(12);  side_info->ch[ch].gr[gr].big_values = get_bits(9);  side_info->ch[ch].gr[gr].global_gain = get_bits(8);  side_info->ch[ch].gr[gr].scalefac_compress = get_bits(4);  side_info->ch[ch].gr[gr].window_switching_flag = get_bits(1);  // window_switching_flag 는 blocksplit_flag와 같다.   // mixed_block_flag 는 switch_point와 같다.   if (side_info->ch[ch].gr[gr].window_switching_flag) // 22 bits   {    side_info->ch[ch].gr[gr].block_type = get_bits(2);   side_info->ch[ch].gr[gr].mixed_block_flag = get_bits(1);   side_info->ch[ch].gr[gr].table_select[0] = get_bits(5);   side_info->ch[ch].gr[gr].table_select[1] = get_bits(5);   side_info->ch[ch].gr[gr].subblock_gain[0] = get_bits(3);   side_info->ch[ch].gr[gr].subblock_gain[1] = get_bits(3);   side_info->ch[ch].gr[gr].subblock_gain[2] = get_bits(3);   if (side_info->ch[ch].gr[gr].block_type == 0)    return(FALSE);   else if (side_info->ch[ch].gr[gr].block_type == 2 && side_info->ch[ch].gr[gr].mixed_block_flag == 0)    side_info->ch[ch].gr[gr].region0_count = 8;   else     side_info->ch[ch].gr[gr].region0_count = 7;   side_info->ch[ch].gr[gr].region1_count = 20 - side_info->ch[ch].gr[gr].region0_count;  }   else // 22 bits   {    side_info->ch[ch].gr[gr].table_select[0] = get_bits(5);   side_info->ch[ch].gr[gr].table_select[1] = get_bits(5);   side_info->ch[ch].gr[gr].table_select[2] = get_bits(5);   side_info->ch[ch].gr[gr].region0_count = get_bits(4);   side_info->ch[ch].gr[gr].region1_count = get_bits(3);   side_info->ch[ch].gr[gr].block_type = 0;  }  side_info->ch[ch].gr[gr].preflag = get_bits(1);  side_info->ch[ch].gr[gr].scalefac_scale = get_bits(1);  side_info->ch[ch].gr[gr].count1table_select = get_bits(1);} }return(TRUE);}

4. Main Data

메인데이터는 실질적인 오디오 데이터가 실려있는 영역을 말한다. mp3의 메인데이터는 한 프레임이 1152개의 Sample 데이터를 갖는다.

granule은 메인데이터가 처리되는 기본단위다. mp3 부호화 방법중 주파수 등분할 방식인 32 서브밴드 방법이 있다. 각 서브밴드는 18개의 sample 데이터를 갖는다. 32*18 = 576 이라는 크기값이 나오며 이것을 한 개의 granule단위로 처리하게된다.

mp3는 2개의 granule로 구성되어 1152개의 Sample 데이터를 갖게된다. 각 granule안에서는 채널별로 decoding된다.

 


5. 오디오 태그 (Audio Tag)

오디오 태그는 AAU의 집합 끝 부분 즉 mp3파일의 마지막 부분 128바이트를 말한다. Artist정보, 곡의 제목, 앨범 Title, 출판년도 등의 mp3파일 전체의 부가정보를 담고 있다. 장르에 대한 인덱스는 생략한다.

길이(byte) 설명
3 Tag ID
30 Title
30 Artist
30 Album
4 Year
30 Comment
1 장르

 


6. mp3 데이터 복원

사이드 인포 디코드 (Side Information Decode)

SideInfo는 mp3의 실제 음향 데이터인 MainData 부분 앞에 위치하며 압축데이터를 복원할 때 필요한 정보들의 집합체이다. SideInfo 정보를 읽어 각 알고리즘 ②,③,④,⑤,⑥ 에서 사용할 수 있게 재배치한다.

스케일 펙터 디코드 (Scalfactors Decode)

스케일 펙터는 각 밴드의 샘플 데이터 부호화의 한 과정이다. 하나의 밴드 내의 36개 샘플 데이터(Layer III 의 경우 1152/32 = 36 즉 각 서브밴드 당 36 샘플)는 파형과 배율로 분리된다. 파형을 최대 진폭이 1.0이 되도록 정규화 하는데, 그때의 배율이 스케일 펙터로서 부호화 된다. 이 과정을 거치면 Band의 Sample Data 들은 비슷한 값들끼리 모이게 되고, 양자화잡음의 발생을 제한할 수 있기 때문에 청각심리 효과가 작용하여 이들 잡음이 감지되지 않게 된다.

적응 비트 할당이란 각 프레임, 각 서브밴드 마다 비트를 조정하는 것을 말한다. 스케일 펙터와 조합해서 크리티컬 밴드(임계대역폭)를 고려한 마스킹 레벨 한도 내에서 양자화를 함으로써 마스킹 효과를 더욱 효과적으로 이용 할 수 있다. 즉 마스킹의 효과로 인하여 인식되지 않는 주파수 대역에 대해서는 비트를 할당하지 않는다.

허프만 디코드 (Huffman Decode)

허프만 부호화 테이블을 이용하여 복호화 한다. 이때 사용되는 허프만 테이블은 신호의 통계적 편중을 주파수 대역별로 최적화 하여 만들어진 표준화 테이블이라고 한다. 이는 무손실 압축 방법으로 MPEG, JPEG 등에 주로 사용되는 압축기법이므로 자료를 찾는데 무리가 없을 것이므로 여기서는 그냥 넘어가도록 하겠다.

역양자화 (Dequantization)

역양자화는 양자화를 복원하는 방법이다. 양자화는 데이터의 손실이 오더라도 사람이 감각적으로 감지하기 힘들게 된다면 어느정도의 데이터에 손실을 가하여 압축률을 높이는 방법이다. 역시 허프만 부호화와 함께 주로 사용되는 기법이다.

IMDCT(Inverse Modified Discrete Cosine Transform)

MDCT는 시간 영역 데이터를 주파수 영역으로 변환하는 것이므로, IMDCT는 역으로 주파수 영역 데이터를 시간영역 데이터로 복호화 한다. 디코딩과정에서 IMDCT는 전체 처리과정에서 CPU점유율 30%이상 많은 연산을 필요로 한다.

32서브밴드 통합 필터뱅크(32 Subband Synthesis Filter Bank)

 

크리티컬 밴드 등의 청각특성을 효율적으로 이용하기 위해서는 우선 신호를 주파수 성분으로 나누는 것이 필요하다. 이 때문에 Encoder에서는 전 대역을 32개의 밴드로 등간격 주파수폭으로 세분하여 서브밴드 부호화 하므로 Decoder에서 다시 이를 복호화 한다.

그러나 통상의 필터로 1/32의 주파수대역을 취하는 경우 이상적인 필터가 아니기 때문에 부 표본화의 시점에서 앨리어싱을 일으킨다. 앨리어싱 잡음을 소거하기 위해 폴리페이즈 필터뱅크라고 불리는 필터를 사용하며 이 방법은 주로 Layer I, II 에서 사용된다. Layer III 에서는 MDCT(Modified Discrete Cosine Transform : 변형이산 여현변화)를 복합적으로 사용하고 있다.

 


7. 참고 자료

3차원 이미지를 느낄 수 있는 새로운 형태의 헤드-업 가상현실 (HUVR) 장치 개발
KISTI 미리안글로벌동향브리핑2010-07-29
미국 UCSD (University of California, San Diego)의 연구원들은 사용자가 3차원 이미지를 볼 수 있을 뿐만 아니라, 그것을 느낄 수도 있는, 새로운 방식의 상대적으로 저비용 가상현실 장치를 개발하였다.

헤 드-업 가상현실 (Heads-Up Virtual Reality, HUVR; 호버(hover)라고 발음함) 장치는 소비자의 3차원 HDTV 패널과 거울을 연상하여 생각하면 된다. 즉, 거울(패널)에 주변 공간에 대한 그래픽 이미지를 투영시키는 것이다. 정확한 투시도를 발생시키기 위해 사용자의 머리 위치를 따라 움직임의 경로를 추적하고, 사용자는 생성된 이미지와의 상호작용을 위해 터치 피드백 햅틱 장치를 사용한다. 즉, 실존하는 3차원 물체처럼, 이미지의 면과 윤곽을 만지는 것이 가능하다.

HUVR 은 손과 눈의 조화가 요구되는 적업에 이상적이며, 구조공학, 기계공학, 고고학, 의학의 훈련 및 교육에서 매우 적절하다. 예를 들어, 본 장치는 MRI에서 얻어진 사람의 뇌에 대한 3차원 이미지를 시각화하고 손으로 다루는데 사용될 수 있다.

“기 존 상용 게임 컨트롤러와 유사한 HUVR의 촉감 피드백 장치를 사용하여, 내과 의사들은 뇌 속의 상태를 살펴보기보다 실제로 느낄 수 있다. 이 장치는 네트워크로 연결되어, 다른 연구자들과 함께 해당 물체를 함께 보고 느낄 수 있다.”라고 UCSD의 Calit2 (California Institute for Telecommunications and Information Technology) 연구팀 소속의 과학자인 Tom DeFanti은 말하였다. DeFanti는 Calit2의 가상현실 설계 엔지니어인 Greg Dawe와 본 장치를 개발하였다. HUVR은 DeFanti가 개발한 장치보다 12년 전에 개발된 PARIS 장치로부터 발전된 것이다.

PARIS (Personal Augmented Reality Interactive System)는 HUVR과 유사한 투사 기술(projection technology)을 사용하지만, 낮은 해상도에, 너무 움직이 많고, 고가이다. PARIS는 이미지를 렌더링 하기 위해, 실리콘 그래픽스社의 컴퓨터를 필요하며, 그 비용은 100,000 달러 (약 1.2억원;1,200원 환율기준)가 넘는다. (PARIS는 여전히 운용되고 있지만, 현재 게임 PC로 운용 중이다.

최 근 55인치 액티브 스테레오 패널 TV은 더 가볍고, 휴대가 용이하며, 가격이 더 저렴한 HUVR 개발의 핵심이었다. 2300 달러 (약 276만원;1,200원 환율기준)짜리 삼성 3D TV 패널로 구축된 HUVR은 더 밝아져, PARIS보다 시각적인 예민함이 더 높아져 사용자의 만족도가 증가하였다.

비록 패시브(passive) 스테레오 3D HDTV를 이용할 수 있지만 (이것을 이용하여 DeFanti는 NexCave라 불리는 새로운 VR 장치를 개발함), 액티브 스테레오 방식이 HUVR에 필요하다. 액티브 스테레오 방식은 눈의 왼쪽과 오른쪽에 분리된 이미지를 생성시켜, 사용자의 액티브 안경(active eyewear)로 왼쪽과 오른쪽 눈 시야에 분리되어 이미지가 나타난다. 이 이미지는 3D HDTV의 120Hz 이미지로써 싱크되어 깜빡거린다. 패시브 스테레오 방식에서 사용되는 편극(polarization) 방식은 거울에 반사될 때 편극이 유지 되지 않아, HUVR에서는 액티브 스테레오 방식이 필요하다.

HUVR의 다음 개발 단계는 더욱 저렴하고, 좋은 품질의 헤드 트래커(사용자의 시각 초점 추적 장치)를 개발하는 것이다. (현재 상업용으로 나온 것은 5,000 (600만원;1,200원 환율기준) ~ 20,000(2400만원;1,200원 환율기준) 달러 사이이다.)

사진 1. Calit2 가상현실 설계 엔지니어인 Greg Dawe가 3D HDTV 패널을 결합한 HUVR 장치를 시연하고 있다. 이것을 통해 사용자는 3차원 물체를 볼 수 있을 뿐만 아니라, 촉감을 느낄 수 있다.

사진 2. Calit2 시각화 전문가인 Andrew Prudhomme가 HUVR의 촉각 피드백 컨트롤러를 조종하고 있다.

'Computer Science' 카테고리의 다른 글

mp3 파일 헤더  (0) 2010.08.01
Mp3 파일 구조  (0) 2010.08.01
ubuntu 이클립스 cdt 설치  (0) 2010.07.20
리얼타겟에서 안드로이드 프로그래밍  (0) 2010.07.18
Android 빌드  (0) 2010.07.13

+ Recent posts