SoC 2010 ASF Demuxer

From VideoLAN Wiki
Jump to navigation Jump to search
This project is part of Google Summer of Code 2010.
Student: Juho Vähä-Herttua
Mentor: Ilkka Ollakka

ASF and other demuxer support


I was selected to do a project related to ASF and Matroska demuxers, but since there's some overlap related to Matroska, my main goal now is to improve both the ASF demuxer and muxer as much as I can and then find another similar project to work on the rest of the time. It's worth to note that the timeline on this website is just a suggestion, and it's no problem to work on small independent patches during the time as well. I like to do things well on the first try, that's why the schedule is not made too tight.


I'm a student at Aalto University School of Science and Technology and I hope this is my final year here. I've been a student since 2003 and plan to graduate during summer 2010. Partly because of all this I might have some other things to take care of until the end of June. The plan is to work full time on this project from July to August however. I have a personal website that I made some years ago, it has most of the useful information about myself.


Date Period Description
April 26 - May 24 Community bonding Getting more familiar with the VLC code base, some small fixes.
May 24 - May 30 Week 1 Review all the existing code, map out needed features.
May 31 - June 6 Week 2 Start cleaning up the demuxer code, go through existing related bugs.
June 7 - June 13 Week 3 Write a working VLC demuxer plugin with a clear API.
June 14 - June 20 Week 4 Work on an API to combine the demuxing and muxing code together.
June 21 - June 27 Week 5 Finish and review the muxing code, write some test cases.
June 28 - July 4 Week 6 Write a working VLC muxer plugin using the rewritten muxer.
July 5 - July 11 Week 7 Extra cleaning up period, because there's always something that slips the deadline.
July 12 - July 18 Week 8 (small extra project, to be discussed with mentors)
July 19 - July 25 Week 9 (small extra project, to be discussed with mentors)
July 26 - August 1 Week 10 Start finishing up (write test suites, run code with valgrind).
August 2 - August 8 Week 11 Continue finishing up.
August 9 - August 15 Week 12 Finish up and do any final testing.

Produced code

For convenience everything is hosted in my personal github repository. There are at least three branches available, plus possibly some extra branches depending on the need. The meaning of the branches is as follows:

master - Follows the VLC master in git:// plus patches
vlc-1.1 - Follows the VLC 1.1 in git:// plus patches
libasf - Branched from VLC 1.1 for now because it's more stable, will contain experimental ASF code

The new code will first enter the libasf branch and when it's stable enough I will port it for the 1.2 version and push to master. The main idea is to have only that kind of code that can be merged to upstream is in master and vlc-1.1 branches. The vlc-1.1 branch is mainly for patching possible small issues that come up in VLC 1.1 or backporting changes from master when appropriate.

Weekly progress

Week 1

The ASF demuxer codebase is pretty clean and straightforward, except for the patches that add DVR-MS, they are not so clearly described but can be seen easily in commit 308d7c4354df86074583e4635cde5cfbb705e00c. There's things like "64 bytes we don't know much about" that should be cleared out. The DEMUX_SET_TIME falls back to the SeekPercent which should be improved so that it would seek to video keyframes. Right now seeking in files without index often result in garbage on the screen for a while. There's comments like "/* FIXME I have to do that for some file, I don't known why */" where I have some kind of idea why it has to be done for some file, these should be commented and cleared up.

The ASF muxer has very limited capabilities of editing the metadata of generated ASF file. Only the basic metadata set "title, author, copyright, comment, rating" can be modified, plus two additional options "packet-size" and "bitrate-override". The header serialization is done by writing the headers statically byte by byte. It would make sense to use the ASF header structs already used in the ASF demuxer and serialize those to the output for more flexibility. The muxer also seems to create an index object in the end of the stream, but the index object doesn't seem to contain any index entries. If the index is really to be used, it should create a proper seeking index at least.

Week 2

No work done because busy with master's thesis and graduation. Some questions discussed with mentors through email though.

Week 3

Committed an initial asf plugin with libasf, noticed that the libasf interfaces are still not quite flexible enough when it comes to the header values required to maintain compatibility with earlier asf demuxer. Since the header handling needs to be redone anyway to support muxing, it's now the plan to first skip to implementing a header structure that's easy to parse/serialize and base the new asf plugin on that. Basically this means switching weeks 3 and 4 in the plan.

Week 4

Note to self about compiling qt4 on Mac OSX. Make a 32-bit build and:

export CC=/Developer/usr/bin/llvm-gcc-4.2
export CXX=/Developer/usr/bin/llvm-g++-4.2
export OBJC=/Developer/usr/bin/llvm-gcc-4.2
export QT4_CFLAGS="-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -F/Library/Frameworks"
export QT4_LIBS="-F/Library/Frameworks -L/Library/Frameworks -framework QtGui -framework QtCore"
mkdir build-qt4; cd build-qt4
../configure --enable-debug --enable-qt4

There's many problems with the build, but audio plays ok.

Week 5

Made a list of all known ASF objects in a header file, most of the week went spending Finnish midsummer though....

Week 6

Started with an attempt to merge the VLC's ASF code into libasf that I've used elsewhere. This was largely a wasted effort though, since the libasf.c in VLC is a _huge_ piece of code and rewriting that by hand is not sensible. It should be either run through some regexps or not done at all, I think it makes more sense to port the changes from libasf to VLC instead, which would make more sense.

What wasn't so much wasted effort was the reviewing of the VLC's ASF code though, and I merged two small changes to my VLC 1.1 tree, they can be applied to 1.2 tree instead since they're not _really_ broken. (doesn't effect much anything)