[FFmpeg-devel] Realmedia patch

Michael Niedermayer michaelni
Thu Aug 28 00:36:48 CEST 2008


On Wed, Aug 27, 2008 at 04:08:06PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Wed, Aug 27, 2008 at 9:24 AM, Olivier Galibert <galibert at pobox.com> wrote:
> > On Wed, Aug 27, 2008 at 09:09:07AM -0400, Ronald S. Bultje wrote:
> >> On Wed, Aug 27, 2008 at 9:04 AM, Reimar D?ffinger
> >> <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> >> > On Wed, Aug 27, 2008 at 07:53:14AM -0400, Ronald S. Bultje wrote:
> >> >> I tried the following:
> >> >>
> >> >>     int i;
> >> >>     char *orig_buf = buf;
> >> >>     const char hex_table[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
> >> >>                                  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
> >> >
> >> > Why not static?
> >>
> >> Ah, now it gets interesting. So, I first made it static const (or
> >> const static), but since it's const, I figured it didn't make a
> >> difference except for keeping it alive between multiple function-calls
> >> which doesn't seem all that useful, so I removed it. Apparently I'm
> >> not quite getting it, so: what's the difference between const static
> >> and "just" const? Is one more efficient in memory-usage than the
> >> other?
> >
> > Actually the code produced by gcc 4.1.1 on x86_64 and x86 is strictly
> > identical whether there is static or not, and corresponds to what a
> > naive compiler would do with static added.
> 
> Then I guess static is the way to go, new patch attached.
> 
> Other suggested improvements are not added since I don't see any
> noticeable speed gain at -O2.
> 
> Ronald

> Index: ffmpeg-svn/libavformat/utils.c
> ===================================================================
> --- ffmpeg-svn.orig/libavformat/utils.c	2008-08-27 16:02:47.000000000 -0400
> +++ ffmpeg-svn/libavformat/utils.c	2008-08-27 16:05:44.000000000 -0400
> @@ -3207,22 +3207,16 @@
>      }
>  }
>  
> -static void digit_to_char(char *dst, uint8_t src)
> -{
> -    if (src < 10) {
> -        *dst = '0' + src;
> -    } else {
> -        *dst = 'A' + src - 10;
> -    }
> -}
> -
>  char *ff_data_to_hex(char *buff, const uint8_t *src, int s)
>  {
>      int i;
> -
> -    for(i = 0; i < s; i++) {
> -        digit_to_char(buff + 2 * i, src[i] >> 4);
> -        digit_to_char(buff + 2 * i + 1, src[i] & 0xF);
> +    static const char hex_table[16] = { '0', '1', '2', '3', '4', '5',
> +                                        '6', '7', '8', '9', 'A', 'B',
> +                                        'C', 'D', 'E', 'F' };

please put 4 of them on each line, that way it will look like a
pretty square ;)

patch ok except that nitpick

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- 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/20080828/0217a172/attachment.pgp>



More information about the ffmpeg-devel mailing list