English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
[Caml-list] doing MMX through ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-21 (09:13)
From: Sebastian Egner <sebastian.egner@p...>
Subject: Re: [Caml-list] doing MMX through ocaml
> Brian Hurt wrote:
> > I'm pretty sure you need at least SSE for MPEG.  The core function is 
> > 8x8 2D FFT.  You *might* be able to do in fixed point (and thus in 
> > but the SSE version would be a lot easier to get right.
> It's actually an 8x8 Discrete Cosine Transform.  It can be done in fixed
> point.  IIRC, you need 18 bits.
>  - ken

As far as I know, the computationally most intensive part of an MPEG2
decoder are the 8x8 IDCT, the motion compensation, and the YCrCb -> RGB
color space conversion. To get an impression, I ported the IDCT and MC
from 'libmpeg2' to Ocaml, and optimized it with an eye on the assembly 
Performance will be fine---as far as one can come without saturated SIMD
ops (e.g. MMX). 'Libmpeg2' is a good open source starting point; it
it clean, reasonably well structured, and relatively small.

The real pain in writing an MPEG2 decoder is probably the complexity
of options (MPEG2 is infamous in that respect), and right now I do not
have a lot of time to spend on such an enterprise.

Some advice on going about an MPEG2 decoder in Ocaml to whom it might
concern: 1. Keep the standard document (ISO) close. 2. Make a choice
which options and configurations to support (and test!). 3. Don't
try too hard to convert 'libmpeg2' literally, but design parts from
scratch. 'Libmpeg2' uses the C preprocessor to do extensive strength
reduction, i.e. generating specialized functions for the various signal
representations (RGB|BGR, 444|422|420, etc.) Since the representation
affects the inner loops, you must do strength reduction in Ocaml, too.
However, the Ocaml compiler is straight, and this means you must find
other ways to have simple but efficient source code. 4. KISS: Keep it
simple and stupid! Forget about the little shop of MPEG2 horror (e.g.
transport streams without a single I-frame, the hell of timecodes etc.).