[FFmpeg-devel] [PATCH] mxf umid generation

Michael Niedermayer michaelni
Sun Mar 8 00:36:39 CET 2009


On Sat, Mar 07, 2009 at 02:48:49PM -0800, Baptiste Coudurier wrote:
> On 3/6/2009 7:44 PM, Michael Niedermayer wrote:
> > On Fri, Mar 06, 2009 at 07:28:55PM -0800, Baptiste Coudurier wrote:
> >> Hi,
> >>
> >> It seems some products really check umid and base themself on its
> >> uniqueness, so it seems better to actually try to generate a unique number.
> >>
> >> Is the approach in the patch acceptable ? If no, 
> > 
> > 
> > 
> >> any other suggestion ?
> > 
> > yes, add a random_seed.c/h
> > that does:
> > 1. try to get a uint32 from reading /dev/(u)random
> > 2. try to get a uint32 from LSB of rdtsc (and similar for ppc/bfin see 
> >    libavutil/timer.h)
> > 3. md5 or sha1 of the first frame or extradata
> > 
> 
> Like this ?
> 
> -- 
> Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> checking for life_signs in -lkenny... no
> FFmpeg maintainer                                  http://www.ffmpeg.org

> Index: libavutil/random_seed.c
> ===================================================================
> --- libavutil/random_seed.c	(revision 0)
> +++ libavutil/random_seed.c	(revision 0)
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier at gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include "timer.h"
> +#include "random_seed.h"
> +

> +/*
> + * Get a seed to use in conjuction with random functions
> + */

missing /**
and should be in the header


> +uint32_t ff_random_get_seed(void)
> +{
> +    uint32_t seed;
> +    int fd;
> +

> +    if ((fd = open("/dev/random", O_RDONLY)) != -1) {
> +        read(fd, &seed, 4);
> +        close(fd);
> +        return seed;
> +    }
> +    if ((fd = open("/dev/urandom", O_RDONLY)) != -1) {
> +        read(fd, &seed, 4);
> +        close(fd);
> +        return seed;
> +    }

if((fd = open("/dev/random", O_RDONLY)) == -1)
    fd = open("/dev/urandom", O_RDONLY);
if(fd != -1){
    read(fd, &seed, 4);
    close(fd);
    return seed;
}
[...]

> Property changes on: libavutil\random_seed.c
> ___________________________________________________________________
> Added: svn:eol-style
>    + LF

intended?

except these ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I hate to see young programmers poisoned by the kind of thinking
Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik
-------------- 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/20090308/16c39358/attachment.pgp>



More information about the ffmpeg-devel mailing list