[FFmpeg-devel] [PATCH] fix utils.c:2125: undefined reference to `av_codec_get_tag'

Limin Wang lance.lmwang
Sun May 6 12:22:17 CEST 2007


Hi,

> On Sun, May 06, 2007 at 02:04:48PM +0800, Limin Wang wrote:
> [...]
> > Index: libavformat/avformat.h
> > ===================================================================
> > --- libavformat/avformat.h	(revision 8906)
> > +++ libavformat/avformat.h	(working copy)
> > @@ -123,7 +123,10 @@
> >  /*************************************************/
> >  /* input/output formats */
> >  
> > -struct AVCodecTag;
> > +typedef struct AVCodecTag {
> > +    int id;
> > +    unsigned int tag;
> > +} AVCodecTag;
> 
> this struct is not public! and does not belong into a public header

Agree, keep the struct in riff.h, but include riff.h in utils.c for I can't
use struct AVCodecTag in utils.c as gcc report "array type has incomplete
element type" error. If you have good way to fix it, then don't need riff.h,
and can move the struct to utils.c. 

In addition, move the codec_get_id() and codec_get_tag() from riff.c to riff.h
for utils.c will use it also. Maybe it's a separate patch? If yes, I'll
prepare for a separate patch.


Thanks,
Limin
-------------- next part --------------
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c	(revision 8911)
+++ libavformat/utils.c	(working copy)
@@ -2086,6 +2086,28 @@
     return 0;
 }
 
+#include "riff.h"
+unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
+{
+    int i;
+    for(i=0; tags && tags[i]; i++){
+        int tag= codec_get_tag(tags[i], id);
+        if(tag) return tag;
+    }
+    return 0;
+}
+
+enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
+{
+    int i;
+    for(i=0; tags && tags[i]; i++){
+        enum CodecID id= codec_get_id(tags[i], tag);
+        if(id!=CODEC_ID_NONE) return id;
+    }
+    return CODEC_ID_NONE;
+}
+
+
 int av_write_header(AVFormatContext *s)
 {
     int ret, i;
Index: libavformat/riff.c
===================================================================
--- libavformat/riff.c	(revision 8911)
+++ libavformat/riff.c	(working copy)
@@ -214,49 +214,6 @@
     { 0, 0 },
 };
 
-unsigned int codec_get_tag(const AVCodecTag *tags, int id)
-{
-    while (tags->id != CODEC_ID_NONE) {
-        if (tags->id == id)
-            return tags->tag;
-        tags++;
-    }
-    return 0;
-}
-
-enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
-{
-    while (tags->id != CODEC_ID_NONE) {
-        if(   toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
-           && toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
-           && toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
-           && toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
-            return tags->id;
-        tags++;
-    }
-    return CODEC_ID_NONE;
-}
-
-unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
-{
-    int i;
-    for(i=0; tags && tags[i]; i++){
-        int tag= codec_get_tag(tags[i], id);
-        if(tag) return tag;
-    }
-    return 0;
-}
-
-enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
-{
-    int i;
-    for(i=0; tags && tags[i]; i++){
-        enum CodecID id= codec_get_id(tags[i], tag);
-        if(id!=CODEC_ID_NONE) return id;
-    }
-    return CODEC_ID_NONE;
-}
-
 unsigned int codec_get_bmp_tag(int id)
 {
     return codec_get_tag(codec_bmp_tags, id);
Index: libavformat/riff.h
===================================================================
--- libavformat/riff.h	(revision 8911)
+++ libavformat/riff.h	(working copy)
@@ -44,8 +44,29 @@
 extern const AVCodecTag codec_bmp_tags[];
 extern const AVCodecTag codec_wav_tags[];
 
-unsigned int codec_get_tag(const AVCodecTag *tags, int id);
-enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag);
+static inline unsigned int codec_get_tag(const AVCodecTag *tags, int id)
+{
+    while (tags->id != CODEC_ID_NONE) {
+        if (tags->id == id)
+            return tags->tag;
+        tags++;
+    }
+    return 0;
+}
+
+static inline enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
+{
+    while (tags->id != CODEC_ID_NONE) {
+        if(   toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
+           && toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
+           && toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
+           && toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
+            return tags->id;
+        tags++;
+    }
+    return CODEC_ID_NONE;
+}
+
 /**
  * @deprecated Use av_codec_get_tag instead.
  */



More information about the ffmpeg-devel mailing list