[FFmpeg-devel] [PATCH] RealMedia muxer: support audio codecs other than AC-3

Francesco Lavra francescolavra
Sat May 15 08:30:37 CEST 2010


On Sat, 2010-05-15 at 08:28 +0200, Francesco Lavra wrote:
> On Sun, 2010-05-09 at 22:56 +0200, Michael Niedermayer wrote:
> > [...]
> > >  utils.c |   29 ++++++++++++++++++++++++-----
> > >  1 file changed, 24 insertions(+), 5 deletions(-)
> > > ac17a932410847e0eac6b42bd8a7184ed2ec522a  02_utils.patch
> > > Index: libavformat/utils.c
> > > ===================================================================
> > > --- libavformat/utils.c	(revision 23062)
> > > +++ libavformat/utils.c	(working copy)
> > > @@ -2023,30 +2023,49 @@
> > >      return ret;
> > >  }
> > >  
> > > -unsigned int ff_codec_get_tag(const AVCodecTag *tags, int id)
> > > +static const AVCodecTag *find_avcodectag_from_id(const AVCodecTag *tags, int id)
> > >  {
> > >      while (tags->id != CODEC_ID_NONE) {
> > >          if (tags->id == id)
> > > -            return tags->tag;
> > > +            return tags;
> > >          tags++;
> > >      }
> > >      return 0;
> > >  }
> > >  
> > > -enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
> > > +static const AVCodecTag *find_avcodectag_from_tag(const AVCodecTag *tags,
> > > +                                                  unsigned int tag)
> > >  {
> > >      int i;
> > >      for(i=0; tags[i].id != CODEC_ID_NONE;i++) {
> > >          if(tag == tags[i].tag)
> > > -            return tags[i].id;
> > > +            return tags + i;
> > >      }
> > >      for(i=0; tags[i].id != CODEC_ID_NONE; i++) {
> > >          if(   toupper((tag >> 0)&0xFF) == toupper((tags[i].tag >> 0)&0xFF)
> > >             && toupper((tag >> 8)&0xFF) == toupper((tags[i].tag >> 8)&0xFF)
> > >             && toupper((tag >>16)&0xFF) == toupper((tags[i].tag >>16)&0xFF)
> > >             && toupper((tag >>24)&0xFF) == toupper((tags[i].tag >>24)&0xFF))
> > > -            return tags[i].id;
> > > +            return tags + i;
> > >      }
> > > +    return 0;
> > 
> > return NULL
> 
> Fixed, although patcheck doesn't like NULLs. Likewise, changed
> find_avcodectag_from_id() too.
> 
> > >  utils.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
> > >  1 file changed, 51 insertions(+), 5 deletions(-)
> > > 21388c149c24ae10c10565ce74cf1d75005e1f95  03_utils.patch
> > > Index: libavformat/utils.c
> > > ===================================================================
> > > --- libavformat/utils.c	(revision 23062)
> > > +++ libavformat/utils.c	(working copy)
> > > @@ -2594,6 +2594,51 @@
> > >      return 0;
> > >  }
> > >  
> > > +static int validate_codec_tag(AVFormatContext *s, AVStream *st)
> > > +{
> > > +    const AVCodecTag *avctag;
> > > +    int n;
> > > +    enum CodecID id = CODEC_ID_NONE;
> > > +    unsigned int tag = 0;
> > > +
> > > +    /**
> > > +     * Check that tag + id is in the table
> > > +     * If neither is in the table -> OK
> > > +     * If tag is in the table with another id -> FAIL
> > > +     * If id is in the table with another tag -> FAIL unless strict < normal
> > > +     */
> > > +    for (n = 0; s->oformat->codec_tag[n]; n++) {
> > 
> > > +        avctag = find_avcodectag_from_tag(s->oformat->codec_tag[n],
> > > +                                          st->codec->codec_tag);
> > > +        while (avctag) {
> > > +            id = avctag->id;
> > > +            if (id == st->codec->codec_id)
> > > +                break;
> > > +            avctag = find_avcodectag_from_tag(avctag + 1, st->codec->codec_tag);
> > > +        }
> > > +        if (id == st->codec->codec_id)
> > > +            break;
> > 
> > a goto would simplify this
> 
> Simplified even further without goto.
> 
> > besides, iam not sure if it wouldnt be  simpler to just write a loop that
> > goes over all AVCodecTag and compares id and tag instead of trying to use 
> > find_avcodectag_from_tag() ...
> 
> B_utils.patch contains an alternative implementation which doesn't
> require find_avcodectag_from_tag() and find_avcodectag_from_id().
> Both options A (A_01_utils.patch + A_02_utils.patch) and B
> (B_utils.patch) pass regression tests and FATE.

And of course the missing patches...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: A_01_utils.patch
Type: text/x-patch
Size: 1810 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100515/3a30407f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A_02_utils.patch
Type: text/x-patch
Size: 2275 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100515/3a30407f/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: B_utils.patch
Type: text/x-patch
Size: 2618 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100515/3a30407f/attachment-0002.bin>



More information about the ffmpeg-devel mailing list