[FFmpeg-devel] [PATCH] Re: Reworking the codec lookup system

Nicolas George nicolas.george
Wed Jun 13 17:13:06 CEST 2007


Le quartidi 24 prairial, an CCXV, Michael Niedermayer a ?crit?:
> users dont read avcodec.h or the doxygen docs about CodecID, its developers
> who do

I was thinking about users of lavc, who are themselves developers: they need
to know what the field is supposed to mean, and how they are supposed to
handle it in their program, but not how the decoders actually work.

>	 and we should not attempt to hide such details from them otherwise
> they for example might spend a lot of time writing code to distingush a
> mpeg1 from a mpeg2 stream beliving they have to in order to decode it

I strongly disagree with that: people who program using lavc must not assume
that the result of avcodec_find_decoder(CODEC_ID_MPEG1VIDEO) will be able to
decode MPEG2 streams, otherwise, their program will mysteriously stop
working if built against a version of lavc with two separate minimalist

The fact that the native MPEG decoder is able to decode both MPEG1 and MPEG2
is an useful feature indeed. But I believe it must be specifically documented
as an exception to the general rule (one way to do it would be to declare a
decoder with a name like "mpeg12" or even "mpeg_1_or_2"). If such exceptions
were to become common, it would be necessary to adapt the data structures to
account for them, but one step at a time.

I have reworked the patch to take your comments into account. I have also
removed the comment for the id field, since it was redundant with the
comment for the CodecID type.


  Nicolas George

Index: libavcodec/avcodec.h
--- libavcodec/avcodec.h	(revision 9303)
+++ libavcodec/avcodec.h	(working copy)
@@ -44,6 +44,12 @@
 #define AV_TIME_BASE_Q          (AVRational){1, AV_TIME_BASE}
+ * Identifies the syntax and semantics of the bitstream.
+ * The principle is roughly:
+ * Two decoders with the same ID can decode the same streams.
+ * Two encoders with the same ID can encode compatible streams.
+ * There may be slight deviations from the principle due to implementation
+ * details.
  * If you add a codec ID to this list, add it so that
  * 1. no value of a existing codec ID changes (that would break ABI),
@@ -2119,6 +2125,12 @@
  * AVCodec.
 typedef struct AVCodec {
+    /**
+     * Name of the codec implementation.
+     * The name is globally unique among encoders and among decoders (but an
+     * encoder and a decoder can share the same name).
+     * This is the primary way to find a codec from the user perspective.
+     */
     const char *name;
     enum CodecType type;
     enum CodecID id;
-------------- 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/20070613/8212f8ae/attachment.pgp>

More information about the ffmpeg-devel mailing list