[FFmpeg-devel] [PATCH] RealMedia muxer: support audio codecs other than AC-3
Michael Niedermayer
michaelni
Sun May 16 20:35:43 CEST 2010
On Sat, May 15, 2010 at 08:30:37AM +0200, Francesco Lavra wrote:
> 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...
[...]
> utils.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 47 insertions(+), 5 deletions(-)
> 8014f5fbe7be074ec4046ac3a5bca8628b1bef3c B_utils.patch
> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c (revision 23141)
> +++ libavformat/utils.c (working copy)
> @@ -2575,6 +2575,47 @@
> 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 = s->oformat->codec_tag[n];
> + while (avctag->id != CODEC_ID_NONE) {
> + if ((avctag->tag == st->codec->codec_tag) ||
redundant
> + ((toupper((avctag->tag >> 0) & 0xFF) ==
> + toupper((st->codec->codec_tag >> 0) & 0xFF)) &&
> + (toupper((avctag->tag >> 8) & 0xFF) ==
> + toupper((st->codec->codec_tag >> 8) & 0xFF)) &&
> + (toupper((avctag->tag >> 16) & 0xFF) ==
> + toupper((st->codec->codec_tag >> 16) & 0xFF)) &&
> + (toupper((avctag->tag >> 24) & 0xFF) ==
> + toupper((st->codec->codec_tag >> 24) & 0xFF)))) {
ff_toupper4(unsigned int x)
{
return toupper( x &0xFF)
+ (toupper((x>>8 )&0xFF)<<8 )
+ (toupper((x>>16)&0xFF)<<16)
+ (toupper((x>>24)&0xFF)<<24);
}
this could also be used in MPV_common_init()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 1
"Used only once" - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100516/82885555/attachment.pgp>
More information about the ffmpeg-devel
mailing list