[FFmpeg-devel] Reworking the codec lookup system

Nicolas George nicolas.george
Sun Jun 10 12:38:10 CEST 2007


Hi.

Some time ago, it was noted here that, if ffmpeg is built with both the
native Vorbis encoder and the libvorbis one, it is not possible to select
one in particular in command line. Furthermore, the selection of the encoder
uses at least two table lookups, which is unnecessary.

I would like to work on that, but before delving into the code, I would like
to design things cleanly.



The first step, I believe, is to settle on the vocabulary, and especially:
what, exactly, is a "codec"?

What I am about to write is a series of trivialities for people aware of
video encoding, but I want things to be absolutely clear.

We have (in ffmpeg and elsewhere) several pieces of code that can convert a
video into a stream of bytes, and others (sometimes with a lot of shared
codes) that can convert a stream of bytes into a video. Let us call the
first ones "encoders", and the second ones "decoders". At the very least,
for each encoder, there is a decoder able to read the resulting stream, and
for each decoder, there is an encoder able to produce an useful stream.

But sometimes, a decoder is able to decode streams produced by different
encoders, and several decoders are able to decode streams produced by one
encoder.

In general, except for bugs and unsupported features, the condition "being
able to produce a stream for the same decoder" will induce an equivalence
relation on the encoders, and the condition "being able to decode a stream
from the same decoder" will induce an equivalence relation on the decoders.

For example, the commercial DivX 5 encoder, the XviD encoder and
mpeg4_encoder from lavc all produce streams that can be decoded by the
proprietary DivX 5 encoder, the XviD decoder and mpeg4_decoder from lavc. It
works because they all obey the MPEG-4 standard.

Of course, everything is the same with audio instead of video.

(End of trivialities.)

Now, we need a name for (1) the individual pieces of code and (2) the
equivalence classes. And one of these names will probably be "codec".

I believe that "codec" should be used for the individual pieces of code.

As for the equivalence classes, the word that immediately comes to mind is
"format", but it has already been used for container formats. My other
proposals are: "standard", "encoding format", and "codec family", with a
slight preference for the last one.



Then, how do we do with ffmpeg? Here is my proposal:

- Each encoder or decoder structure has a codec name. The codec name is
  globally unique (except that an encoder and a decoder can have the same).

- Each codec structure has a codec family name.

- Each codec structure has a priority value, to set the preference between
  codecs belonging to the same codec family.

- Codec names are in lowercase. Codec family names are in uppercase.

- When looking for a codec by name, ffmpeg will first look for an exact
  match on the codec name field. If there is none, it will look for a
  case-insensitive match on the codec family name field and take the best
  priority.

- CodecIDs are no longer used.


Before ranting some more, I would like to know what people here think about
that battle plan.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 185 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070610/475e0a10/attachment.pgp>



More information about the ffmpeg-devel mailing list