[libav-devel] [PATCH] mpeg4videoenc: K&R formatting cosmetics

Diego Biurrun diego at biurrun.de
Mon Nov 18 19:47:40 CET 2013


On Mon, Nov 18, 2013 at 02:01:50PM +0100, Vittorio Giovara wrote:
> 
> --- a/libavcodec/mpeg4videoenc.c
> +++ b/libavcodec/mpeg4videoenc.c
> @@ -283,85 +294,98 @@ static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
>          }
>      }
> -    /*if(i<=last_index)*/{
> -        int level = block[ scan_table[i] ];
> -        int run = i - last_non_zero - 1;
> -        if((level&(~127)) == 0){
> -            const int index= UNI_MPEG4_ENC_INDEX(1, run, level);
> +    /* if (i <= last_index) */ {
> +        int level = block[scan_table[i]];
> +        int run   = i - last_non_zero - 1;

The comment is wrongly indented.

> @@ -369,159 +393,163 @@ static int mpeg4_get_block_length(MpegEncContext * s, int16_t * block, int n, in
>          }
>      }
> -    /*if(i<=last_index)*/{
> -        int level = block[ scan_table[i] ];
> -        int run = i - last_non_zero - 1;
> +    /* if (i <= last_index) */ {
> +        int level = block[scan_table[i]];
> +        int run   = i - last_non_zero - 1;

same

> -        for (i = 0; i < 6; i++) {
> +        for (i = 0; i < 6; i++)
>              if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i)) & 1) == 0) {
>                  s->block_last_index[i] = -1;
>                  s->dsp.clear_block(s->block[i]);
>              }
> -        }
>      } else {
> -        for (i = 0; i < 6; i++) {
> +        for (i = 0; i < 6; i++)
>              if (s->block_last_index[i] >= 0)
>                  cbp |= 1 << (5 - i);
> -        }
>      }
>      return cbp;
>  }

Maybe keep those?   I don't care.

> -void ff_mpeg4_encode_mb(MpegEncContext * s,
> +void ff_mpeg4_encode_mb(MpegEncContext *s,
>                          int16_t block[6][64],

Coalesce these two lines while you're at it.

> @@ -670,162 +711,159 @@ void ff_mpeg4_encode_mb(MpegEncContext * s,
>  
>                  ff_h263_encode_motion_vector(s, s->mv[0][0][0] - pred_x,
> -                                                s->mv[0][0][1] - pred_y, s->f_code);
> +                                             s->mv[0][0][1] - pred_y, s->f_code);
>                  ff_h263_encode_motion_vector(s, s->mv[0][1][0] - pred_x,
> -                                                s->mv[0][1][1] - pred_y, s->f_code);
> +                                             s->mv[0][1][1] - pred_y, s->f_code);

You broke lines after each argument for these functions above ..

> -                    ff_h263_encode_motion_vector(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x,
> -                                                    s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
> +                    ff_h263_encode_motion_vector(s,
> +                                                 s->current_picture.motion_val[0][s->block_index[i]][0] - pred_x,
> +                                                 s->current_picture.motion_val[0][s->block_index[i]][1] - pred_y,
> +                                                 s->f_code);

.. like here for example.

> -        if(interleaved_stats){
> -            s->i_tex_bits+= get_bits_diff(s);
> -        }
> +        if (interleaved_stats)
> +            s->i_tex_bits += get_bits_diff(s);
> +
>          s->i_count++;

I'd not add an empty line here.

> @@ -859,53 +900,56 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){
> -    if(s->avctx->level != FF_LEVEL_UNKNOWN){
> +    if (s->avctx->level != FF_LEVEL_UNKNOWN) {
>          profile_and_level_indication |= s->avctx->level;
> -    }else{
> -        profile_and_level_indication |= 1; //level 1
> +    } else {
> +        profile_and_level_indication |= 1;   // level 1
>      }
>  
> -    if(profile_and_level_indication>>4 == 0xF){
> -        vo_ver_id= 5;
> -    }else{
> -        vo_ver_id= 1;
> +    if (profile_and_level_indication >> 4 == 0xF) {
> +        vo_ver_id = 5;
> +    } else {
> +        vo_ver_id = 1;
>      }

Drop {}.

> @@ -1343,7 +1400,7 @@ AVCodec ff_mpeg4_encoder = {
>      .init           = encode_init,
>      .encode2        = ff_MPV_encode_picture,
>      .close          = ff_MPV_encode_end,
> -    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
> +    .pix_fmts       = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE     },

stray amount of spaces added at the end

Just fix some of these comments and push.

Diego


More information about the libav-devel mailing list