[Ffmpeg-devel] MMF Update

Michael Niedermayer michaelni
Mon Apr 23 14:25:20 CEST 2007


Hi

On Mon, Apr 23, 2007 at 11:48:47AM +0100, Robert Keevil wrote:
> Hi,
> 
> The attached is a slight reworking of a previous patch
> (http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-May/011145.html)
> which primarily adds a CRC to the generated files.
> 
> I don't know if this patch is the right way to go about it, but I
> would welcome any comments.
[...]
> +    char metadata[520];
> +    int copystatus = 0;
> +    int copycounts = 0;
> +    int copyoffset = 0;
>  
> +    sscanf(s->copyright, ":%d:%d:%n", &copystatus, &copycounts, &copyoffset);

what is copy* ?


> +    if(copyoffset == 0) { copystatus = copycounts = 0; }
> +
>      rate = mmf_rate_code(s->streams[0]->codec->sample_rate);
>      if(rate < 0) {
>          av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d\n", s->streams[0]->codec->sample_rate);
> @@ -76,9 +84,21 @@
>      put_byte(pb, 0); /* class */
>      put_byte(pb, 0); /* type */
>      put_byte(pb, 0); /* code type */
> -    put_byte(pb, 0); /* status */
> -    put_byte(pb, 0); /* counts */
> +    put_byte(pb, copystatus & 0xff); /* copy status */
> +    put_byte(pb, copycounts & 0xff); /* copy counts */
>      put_tag(pb, "VN:libavcodec,"); /* metadata ("ST:songtitle,VN:version,...") */
> +    if(s->title[0] != '\0') {
> +        snprintf(metadata, sizeof(metadata), "ST:%s,", s->title);
> +        put_tag(pb, metadata);
> +    }
> +    if(s->author[0] != '\0') {
> +        snprintf(metadata, sizeof(metadata), "SW:%s,", s->author);
> +        put_tag(pb, metadata);
> +    }
> +    if(s->copyright[copyoffset] != '\0') {
> +        snprintf(metadata, sizeof(metadata), "CR:%s,", &s->copyright[copyoffset]);
> +        put_tag(pb, metadata);
> +	}

tabs are forbidden in svn

also the metadata stuff is unrelated to the crcs and must be in a seperate
patch


>      end_tag_be(pb, pos);
>  
>      put_buffer(pb, "ATR\x00", 4);
> @@ -125,12 +145,42 @@
>      }
>  }
>  
> +uint32_t av_crc_url(const AVCRC *ctx, uint32_t crc, AVFormatContext *s, size_t length){
> +    ByteIOContext pb1, *pb = &pb1;
> +    size_t pos = 0;
> +
> +    if (url_fopen(pb, s->filename, URL_RDONLY) < 0)
> +        goto fail;
> +
> +#ifndef CONFIG_SMALL
> +        if(!ctx[256])
> +            while(pos<length-3){
> +                crc ^= le2me_32(get_le32(pb));
> +                pos+=4;
> +                crc =  ctx[3*256 + ( crc     &0xFF)]
> +                      ^ctx[2*256 + ((crc>>8 )&0xFF)]
> +                      ^ctx[1*256 + ((crc>>16)&0xFF)]
> +                      ^ctx[0*256 + ((crc>>24)     )];
> +            }
> +#endif
> +
> +    while(pos<length){
> +        crc = ctx[((uint8_t)crc) ^ get_byte(pb)] ^ (crc >> 8);
> +        pos++;
> +    }
> +
> +fail:
> +    url_fclose(pb);
> +    return bswap_16(~crc & 0xffff);
> +}

code duplication


[...]
-- 
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/20070423/65b23a4f/attachment.pgp>



More information about the ffmpeg-devel mailing list