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

Michael Niedermayer michaelni at gmx.at
Sun Jul 15 22:13:47 CEST 2007


Hi

On Sun, Jul 15, 2007 at 08:04:20PM +0200, Kamil Nowosad wrote:
> 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?

yes you should try to gobally minimize distortion + bitrate*AVFrame.quality
this is proofably optimal in the distortion per bitrate sense
having a distortion which is weighted by some psychovissual factor can make
sense but it does not appear that the mindr/maxdr code is such a
psychovissual factor?

also 2 independant things (tiles or otherwise) can be optimally encoded
by independantly finding the minimum of distortion + bitrate*AVFrame.quality
for each (the proof is trivial, the sum of the 2 minima is of course the global
minimum if both are independant)



> 
> > > @@ -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).

whats wrong with s->picture->quality-1 ?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I count him braver who overcomes his desires than him who conquers his
enemies for the hardest victory is over self. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20070715/4f536ca8/attachment.pgp>


More information about the FFmpeg-soc mailing list