[FFmpeg-devel] [PATCH] Mimic decoder

Vitor Sessak vitor1001
Fri Mar 14 23:07:54 CET 2008


Hi

Ramiro Polla wrote:
> Hello Michael,
> 
> Michael Niedermayer wrote:
>> On Tue, Mar 11, 2008 at 06:51:49PM -0300, Ramiro Polla wrote:
>>> Hello,
>>>
>>> I have taken libmimic [0] and used it to implement a native Mimic [1] 
>>> decoder for FFmpeg.

If you don't mind some nitpicking...

[...]

> 
>     return 1;
> }
> 
> static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVPicture *src)
> {
>     int i;
>     dst->data[0] = src->data[0]+( ctx->avctx->height    -1)*src->linesize[0];
>     dst->data[1] = src->data[2]+((ctx->avctx->height>>1)-1)*src->linesize[2];
>     dst->data[2] = src->data[1]+((ctx->avctx->height>>1)-1)*src->linesize[1];
>     for(i = 0 ; i < 3 ; i++)
>         dst->linesize[i] = -src->linesize[i];
> }

Maybe adding a comment:

/**
  * Flip the buffer upside-down and put it in the YVU order to match the
  * way Mimic encodes frames.
  */
static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVPicture *src)

> static int decode(MimicContext *ctx, int quality, int num_coeffs,
>                   int is_pframe)
> {
>     int y, x, plane, offset;
>     DECLARE_ALIGNED_16(DCTELEM, dct_block[64]);
>     uint8_t *src, *dst, *p;
>     AVPicture cur_frame;
>     AVPicture prev_frame;
>     uint8_t *base_src;
>     uint8_t *base_dst;
> 
>     prepare_avpic(ctx, &cur_frame , (AVPicture*) &ctx->picture   );
>     prepare_avpic(ctx, &prev_frame, (AVPicture*) &ctx->prev_frame);
> 
>     for(plane = 0; plane < 3; plane++) {
>         const int is_chroma = !!plane;
>         const int qscale = is_chroma ? av_clip(10000-quality, 1000, 10000)<<2 :
>                                        av_clip(10000-quality, 2000, 10000)<<2 ;

const int qscale =
     av_clip(10000-quality, is_chroma ? 1000 : 2000, 10000)<<2;

or more obfuscated

const int qscale =
     av_clip(10000-quality, 2000 >> is_chroma, 10000)<<2;


>         const int stride = cur_frame.linesize[plane];
>         base_src = prev_frame.data[plane];
>         base_dst = cur_frame. data[plane];
>         offset = 0;
>         for(y = 0 ; y < ctx->num_vblocks[plane] ; y++) {
>             unsigned int num_rows = 8;
>             /* The last row of blocks in chrominance for 160x120 resolution
>              * is half the normal height and must be accounted for. */
>             if(is_chroma &&
>                y + 1 == ctx->num_vblocks[plane] && ctx->avctx->height & 15)
>                 num_rows = 4;
>             src = base_src + offset;
>             dst = base_dst + offset;

uint8_t *src = base_src + offset;
uint8_t *dst = base_dst + offset;

[...]

>     21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,  0,
>      6, 10, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26,
>     26, 26, 27,  0, 10, 27, 27, 27, 28, 28, 28, 28,
>     29, 29, 29, 29, 30, 30, 30,
> };
> 
> /*
>  * initialize_vlcdec_lookup
>  *
>  * Internal helper-function used to initialize
>  * the lookup-table used by the VLC-decoder.
>  */
> static void initialize_vlcdec_lookup(int8_t lookup_tbl[8][128])

/**
  * Internal helper-function used to initialize
  * the lookup-table used by the VLC-decoder.
  */
static void initialize_vlcdec_lookup(int8_t lookup_tbl[8][128])

If this function do not go away...

-Vitor




More information about the ffmpeg-devel mailing list