[FFmpeg-devel] [PATCH] fix utils.c:2125: undefined reference to `av_codec_get_tag'
Michael Niedermayer
michaelni
Wed Jul 4 22:09:58 CEST 2007
Hi
On Sun, May 06, 2007 at 06:22:17PM +0800, Limin Wang wrote:
> 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
> 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)
> +{
#includes should be at the top of the file not interspaced between functions
[...]
> 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;
> +}
these functions are not speed critical and so they do not belong into the
header
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070704/00d81a3c/attachment.pgp>
More information about the ffmpeg-devel
mailing list