Monday, October 24, 2005

Nice impositions



I will use google before asking dumb questions...

ID3 Tags in Mp3

Finally im blogging after week. Actually i was busy with my diwali purchases and tightly engaged with office work. Yea, finally we are going to release our DVD player. Now the finishing touches are going on.

Today i written code to parse ID3 tag from mp3 files. Actually the format of ID3 tag varies from its version. The first and basic version is v1.0. According to this version the ID3 tag appears at the end of the mp3 file. It begins from 128th byte from the end of file, from this place we have to read the following structure

struct ID3v1Tag
{
char Signature[3]; // Should be 'TAG'
char SongName[30];
char Artist[30];
char Album[30];
char Year[4];
char Comment[30];
char Genre[1];
};

After reading this we need to check whether the Signature contains 'TAG' or not. This is signature of ID3v1 tag. All other fields are self explainary except the Genre. The Genre is 8 bit number denotes the Genre index. We can populate a array with list of genres and use this to retrieve the string form of genre.

The ID3v1.1 tag is slightly varies from v1.0. The difference is the byte before last byte in Comment field is used as a field to denote the track's index in original Audio CD.

The ID3v2 and its variation revision 3(not sure is this a revision or minor no) varies completely from its first version. Actually this version of ID3 tag can be found at any place inside mp3 file. But usually it can be located at the begining or end of the file. The data structure of this tag is pretty complex and you need to do few clicks in google to get info/sample for this.

I also started learning linux device driver last week. It seems to be complex but anyway im studying. I hope i will gain some knowledge atleast to write a simple driver. Actually i planned to write a simple driver which hijacks keyboard and modifies the scancode for keys. But for that i have to learn more chapters from "Linux Device Drivers".

Monday, October 17, 2005


Intelligent_Bot

Struggling with Stack Overflow

Hmm... after my week-ends im writing the blog.
Actually i spend my week-ends mostly in getting a stack overflow to work, but not yet get succeed. But i came to know one interesting thing, when i try disassemble my C code i found some extra assembly code which are not related to my code. I really surprise and i tried to compile using both gcc and g++. But both produces the same object file(with extra asm codes). So i jump into researching and found that the compiler produce these extra asm codes for memory alignment. Let me explain the screnario with an example

#include

int main ()
{
return 0;
}


this is my code and does nothing. I compiled like this

g++ test.cpp -o test
and objdump of assembly

objdump -d test
08048364
:
8048364: 55 push %ebp
8048365: 89 e5 mov %esp,%ebp
8048367: 83 ec 08 sub $0x8,%esp
804836a: 83 e4 f0 and $0xfffffff0,%esp
804836d: b8 00 00 00 00 mov $0x0,%eax
8048372: 29 c4 sub %eax,%esp
8048374: b8 00 00 00 00 mov $0x0,%eax
8048379: c9 leave
804837a: c3 ret
804837b: 90 nop
lets analyze the code
8048364: 55 push %ebp
8048365: 89 e5 mov %esp,%ebp
this belongs to function prolog

8048374: b8 00 00 00 00 mov $0x0,%eax
8048379: c9 leave
804837a: c3 ret
this is function epilog
so from where comes the following opcodes?????????

8048367: 83 ec 08 sub $0x8,%esp
804836a: 83 e4 f0 and $0xfffffff0,%esp
804836d: b8 00 00 00 00 mov $0x0,%eax
8048372: 29 c4 sub %eax,%esp
after a severe search i found that these are lines produced by compiler for memory alignment. also i found we can easily turn of this by including -Os (optimise for size) compiler options

g++ -Os test.cpp -o test
objdump -d test
...
08048364
:
8048364: 55 push %ebp
8048365: 89 e5 mov %esp,%ebp
8048367: 31 c0 xor %eax,%eax
8048369: c9 leave
804836a: c3 ret
804836b: 90 nop
...
surprised??????? yea even i felt the same.

But still dont know how to make the stack overflow work, let see atleast today i can get it to work

Saturday, October 15, 2005

Subtitles for Video Files

For the past two day i am working on module that enables subtitles for normal video files (i.e. AVI and etc). Initially i wonder how i am going to enable subtitle text for video files but after seeing the subtitle text files (SRT, SUB and etc) i really made it easily.
These files are nothing but ASCII files but in some format. For example SRT is one of the subtitle format file which usually contains the start time, end time and the subtitle text. Some formats are more easy than other. The only variation to this VobSub. VobSub is nothing but the ripping for subtitles from DVD. So usually it is in the format of bitmaps. I think this requires a little bit work to incorperate in our player. But today i finished the SRT subtitle file format somehow and waiting for bugs reports.