[FFmpeg-soc] [soc]: r852 - dirac/libavcodec/dirac.c

Aurelien Jacobs aurel at gnuage.org
Thu Aug 16 13:57:04 CEST 2007


On Thu, 16 Aug 2007 13:47:30 +0200 (CEST)
marco <subversion at mplayerhq.hu> wrote:

> Author: marco
> Date: Thu Aug 16 13:47:29 2007
> New Revision: 852
> 
> Log:
> simplify chroma dimension calculations
> 
> Modified:
>    dirac/libavcodec/dirac.c
> 
> Modified: dirac/libavcodec/dirac.c
> ==============================================================================
> --- dirac/libavcodec/dirac.c	(original)
> +++ dirac/libavcodec/dirac.c	Thu Aug 16 13:47:29 2007
> @@ -422,32 +422,11 @@ static void parse_sequence_parameters(Di
>      if (get_bits1(gb))
>          s->sequence.chroma_format = svq3_get_ue_golomb(gb);
>  
> -    /* Override the chroma dimensions.  */
> -    switch (s->sequence.chroma_format) {
> -    case 0:
> -        /* 4:4:4 */
> -        s->sequence.chroma_width = s->sequence.luma_width;
> -        s->sequence.chroma_height = s->sequence.luma_height;
> -        s->chroma_hratio = 1;
> -        s->chroma_vratio = 1;
> -        break;
> -
> -    case 1:
> -        /* 4:2:2 */
> -        s->sequence.chroma_width = s->sequence.luma_width >> 1;
> -        s->sequence.chroma_height = s->sequence.luma_height;
> -        s->chroma_hratio = 1;
> -        s->chroma_vratio = 2;
> -        break;
> -
> -    case 2:
> -        /* 4:2:0 */
> -        s->sequence.chroma_width = s->sequence.luma_width >> 1;
> -        s->sequence.chroma_height = s->sequence.luma_height >> 1;
> -        s->chroma_hratio = 2;
> -        s->chroma_vratio = 2;
> -        break;
> -    }
> +    /* Calculate the chroma dimensions.  */
> +    s->chroma_hratio = 1 + (s->sequence.chroma_format > 1);
> +    s->chroma_vratio = 1 + (s->sequence.chroma_format > 0);
> +    s->sequence.chroma_width  = s->sequence.luma_width  / s->chroma_hratio;
> +    s->sequence.chroma_height = s->sequence.luma_height / s->chroma_vratio;

New code is not equivalent to the old one. You must invert hratio and vratio
in the last two lines to get somehting equivalent:

    s->sequence.chroma_width  = s->sequence.luma_width  / s->chroma_vratio;
    s->sequence.chroma_height = s->sequence.luma_height / s->chroma_hratio;

(this looks strange in regards to the variable names, so maybe it's the value
of hratio and vratio which should be inverted in the 4:2:2 case)

Aurel



More information about the FFmpeg-soc mailing list