[FFmpeg-soc] [soc]: r391 - jpeg2000/j2kenc.c

Kamil Nowosad kamil.nowosad at gmail.com
Sun Jul 15 20:04:20 CEST 2007


Hi

On Fri, Jul 13, 2007 at 09:50:57PM +0200, Michael Niedermayer wrote:
> Hi
> 
> On Fri, Jul 13, 2007 at 11:36:29AM +0200, k.nowosad wrote:
> > Author: k.nowosad
> > Date: Fri Jul 13 11:36:28 2007
> > New Revision: 391
> > 
> > Log:
> > replaced rate_control with mechanism based on AVFrame.quality field
> [...]
> > @@ -1234,7 +1206,9 @@ static void encode_tile(J2kEncoderContex
> >      }
> >  
> >      av_log(s->avctx, AV_LOG_DEBUG, "rate control\n");
> > -    rate_control(s, tile, tileno);
> > +    truncpassess(s, tile, tile->mindr +
> > +            (tile->maxdr - tile->mindr) * s->picture->quality / (FF_LAMBDA_MAX-1));
> > +    encode_packets(s, tile, tileno);
> >      av_log(s->avctx, AV_LOG_DEBUG, "after rate control\n");
> >  }
> >  
> 
> can you explain what mindr and maxdr are doing? this does not seem
> correct
> if you wish to implement some spatial complexity adaptive quantization
> then that should depend on AVCodecContext.spatial_cplx_masking

mindr and maxdr are minimum and maximum rate-distortion slope values per
each coding pass in a tile. The possible threshold values lie between them. 
I've made the threshold proportional to AVFrame.quality. I have also
realized that the distribution of image sizes (depending on
AVFrame.quality) is better when the fraction (s->picture->quality /
(FF_LAMBDA_MAX - 1)) is squared. And it works well.
Are there any other rules which i should keep to?

> > @@ -1288,7 +1262,7 @@ static int encode_frame(AVCodecContext *
> >      s->Ysiz = avctx->height;
> >  
> >      s->nguardbits = 1;
> > -    s->maxtilelen = 5000;
> > +    s->picture->quality = FFMAX(--s->picture->quality, 0);
> 
> why -- ?

The quality is between 1 and FF_LAMBDA_MAX, but for my use it is better
when the range starts at 0 (see above). 
Apart from that, the best quality is set for default (when AVFrame.quality is 
0).

-- 
Best regards,
Kamil Nowosad



More information about the FFmpeg-soc mailing list