alpaastero

Libav and Free Software development


Leave a comment

The Libav sprint

Four Libav developers met for a four-day sprint, including two OPW interns. It was productive: we discussed various aspects of the project and coded. There was not much pair programming, but everyone made progress. I wrapped up the RealAudio code, dropping SIPR support (it turned out that the old implementation I was using as a reference did not actually support SIPR-in-RealAudio; I wish I had realized that before spending a couple of weeks on it). I also added some tests, as there were none for RealAudio files (the RealAudio tests in Libav were all for RealAudio streams in RealMedia files). There was also a lot of delicious Libav chocolate.

At this point, I am implementing RealMedia demuxing.

Advertisements


1 Comment

Framecrc

Today, I learned how to use framecrc as a debug tool. Many Libav tests use framecrc to compare expected and actual decoding. While rewriting existing code, the output from the old and new versions of the code on the same sample can be checked; this makes a lot of mistakes clear quickly, including ones that can be quite difficult to debug otherwise.

Checking framecrcs interactively is straightforward: ./avconv -i somefile -c:a copy -f framecrc -. The -c:a copy specifies that the original, rather than decoded, packet should be used. The - at the end makes the output go to stdout, rather than a named file.

The output has several columns, for the stream index, dts, pts, duration, packet size, and crc:

0, 0, 0, 192, 2304, 0xbf0a6b45
0, 192, 192, 192, 2304, 0xdd016b78
0, 384, 384, 192, 2304, 0x18da71d6
0, 576, 576, 192, 2304, 0xcf5a6a07
0, 768, 768, 192, 2304, 0x3a84620a

It is also unusually simple to find out what the fields are, as libavformat/framecrcenc.c spells it out quite clearly:

static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
char buf[256];

snprintf(buf, sizeof(buf), “%d, %10″PRId64″, %10″PRId64″, %8d, %8d, 0x%08″PRIx32″\n”,
pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc);
avio_write(s->pb, buf, strlen(buf));
return 0;
}

Keiler, one of my Libav mentors, patiently explained the above; I hope documenting it helps other people who are starting with Libav development.