[FFmpeg-devel] [PATCH] fix utils.c:2125: undefined reference to `av_codec_get_tag'
Limin Wang
lance.lmwang
Sun May 6 08:04:48 CEST 2007
Hi,
> Generic functions should be moved to some other file. The riff.c file
> is for stuff common between all the riff based formats and should not
> be built unless such a format is enabled.
I move these generic functions and stuff to utils.c, please review whether
it's OK.
Thanks,
Limin
-------------- next part --------------
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 8906)
+++ libavformat/utils.c (working copy)
@@ -2086,6 +2086,50 @@
return 0;
}
+static 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 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;
+}
+
+
int av_write_header(AVFormatContext *s)
{
int ret, i;
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;
struct AVFormatContext;
Index: libavformat/riff.c
===================================================================
--- libavformat/riff.c (revision 8906)
+++ libavformat/riff.c (working copy)
@@ -237,26 +237,6 @@
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 8906)
+++ libavformat/riff.h (working copy)
@@ -27,15 +27,11 @@
#ifndef FF_RIFF_H
#define FF_RIFF_H
+#include "avformat.h"
offset_t start_tag(ByteIOContext *pb, const char *tag);
void end_tag(ByteIOContext *pb, offset_t start);
-typedef struct AVCodecTag {
- int id;
- unsigned int tag;
-} AVCodecTag;
-
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
int put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
int wav_codec_get_id(unsigned int tag, int bps);
More information about the ffmpeg-devel
mailing list