[FFmpeg-cvslog] r24299 - in trunk/libavcodec: Makefile allcodecs.c ansi.c avcodec.h

Måns Rullgård mans
Sun Jul 18 10:25:36 CEST 2010


pross <subversion at mplayerhq.hu> writes:

> Author: pross
> Date: Sun Jul 18 10:03:35 2010
> New Revision: 24299
>
> Log:
> ASCII/ANSI art decoder
>
> Added:
>    trunk/libavcodec/ansi.c
> Modified:
>    trunk/libavcodec/Makefile
>    trunk/libavcodec/allcodecs.c
>    trunk/libavcodec/avcodec.h
>
> +#include "avcodec.h"
> +#include "cga_data.h"
> +#include <libavutil/lfg.h>

Use quotes for our headers, <> for system/external headers please.


[...]

> +/**
> + * Execute ANSI escape code
> + * @param <0 error
> + */
> +static int execute_code(AVCodecContext * avctx, int c)
> +{
> +    AnsiContext *s = avctx->priv_data;
> +    int ret, i, width, height;
> +    switch(c) {
> +    case 'A': //Cursor Up
> +        s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
> +        break;
> +    case 'B': //Cursor Down
> +        s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
> +        break;
> +    case 'C': //Cursor Right
> +        s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width  - FONT_WIDTH);
> +        break;
> +    case 'D': //Cursor Left
> +        s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
> +        break;
> +    case 'H': //Cursor Position
> +    case 'f': //Horizontal and Vertical Position
> +        s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
> +        s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH,     0, avctx->width  - FONT_WIDTH) : 0;
> +        break;

Using a couple of local variables for some of those sub-expressions
would probably improve readability a lot.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-cvslog mailing list