Category Archives: Programming

I (Heart) Autotools

Oh, autotools– what would I do without you? Recognizing your utility places me in a minority. I know you are woefully underappreciated and catch a lot of flack for your apparent complexity. But this is largely because many programmers refuse to face up to the fact that the complexity of building a program is commensurate with the complexity of the program itself. They might not like you but don’t take it personally as they are invariably at a loss to produce a superior solution. You do most everything that developers need from a build system– they just need to find a decent tutorial, reference, or –best of all — another source package that implements the same feature they need; there must be thousands of examples to choose from.

Basic FFmpeg Hacking

A few more people have expressed interest in writing file demuxers and audio/video decoders for the FFmpeg project. I present herewith a brief guide to creating both demuxers and decoders for that project.

Start with the demuxer:

  • copy one of the simpler formats (libavformat/idcin.c or idroq.c) to a new file and start modifying the key parts
  • edit libavformat/allformats.c and libavformat/avformat.h and add the proper _init() function
  • edit libavformat/Makefile and add the new file to the end of the OBJS list

You should be able to build the new demuxer module into the project now. Check ‘ffmpeg -formats’ to make sure. You can use printf()’s or gdb along with the ffmpeg for debugging.

Next is the video decoder:

  • copy one of the simpler video decoders (libavcodec/msrle.c or msvideo1.c) to a new file and start modifying the key parts
  • edit libavcodec/avcodec.h and add a new CODEC_ID; also add the new data structure declared at the end of the new file
  • edit libavcodec/allcodecs.c and add the new data structure there as well
  • edit libavcodec/Makefile and add the new file to the end of the OBJS list

It helps to recompile the entire project after adding a new CODEC_ID just to make sure it “takes”. ‘ffmpeg -formats’ should now report the new format. Proceed with development and debugging. Note that in libavcodec, printf()s are forbidden. Use av_log(NULL, AV_LOG_INFO, …) instead.

On Portable Programs

Someone once asked on one of the xine mailing lists, “Is xine big endian or little endian?” Clearly, the person was confused but his heart was in the right place: He had heard about the endianness issue and that it affects machine portability somehow. Here is Multimedia Mike’s quick and easy guide to what you need to know about endianness and platform portability:


When the CPU interacts with the outside world, the CPU needs to worry about endianness.

Continue reading