[FFmpeg-devel] [PATCH] mpeg2 non linear quantizer full support

Michael Niedermayer michaelni
Wed Mar 19 15:56:25 CET 2008


On Wed, Mar 19, 2008 at 11:59:21AM +0100, Baptiste Coudurier wrote:
> Hi,
> 
> Michael Niedermayer wrote:
> > On Tue, Mar 18, 2008 at 03:55:32PM +0100, Baptiste Coudurier wrote:
> >> Hi,
> >>
> >> Michael Niedermayer wrote:
> >>> On Wed, Mar 12, 2008 at 07:38:42PM +0100, Baptiste Coudurier wrote:
> >>>> Hi,
> >>>>
> >>>> $subject.
> >>>>
> >>>> Diff for some files is to show possible simplifications of existing
> >>>> code. I'll of course split the commits. Only mpeg-2 unquantize functions
> >>>> are affected.
> >>>>
> >>>> Regression tests pass.
> >>> [...]
> >>>
> >>>
> >>>> Index: libavcodec/mpegvideo.c
> >>>> ===================================================================
> >>>> --- libavcodec/mpegvideo.c	(revision 12407)
> >>>> +++ libavcodec/mpegvideo.c	(working copy)
> >>>> @@ -33,6 +33,7 @@
> >>>>  #include "mpegvideo_common.h"
> >>>>  #include "mjpegenc.h"
> >>>>  #include "msmpeg4.h"
> >>>> +#include "mpeg12.h"
> >>>>  #include "faandct.h"
> >>>>  #include <limits.h>
> >>>>  
> >>>> @@ -2149,6 +2150,8 @@
> >>>>          block[0] = block[0] * s->y_dc_scale;
> >>>>      else
> >>>>          block[0] = block[0] * s->c_dc_scale;
> >>>> +
> >>>> +    qscale = s->qscale_table[qscale];
> >>> Doing the remaping in the dequant function means that its done 6 times (
> >>> 4 luma and 2 chroma) for 420, it might be more efficient to do it at some
> >>> oher place or maybe even keep qscale some linear quantizer scale instead
> >>> of a possibly non linear qp.
> >>> That is have 2 variables, qp which might be non linear and qscale which is
> >>> always the actual scale with which things get multiplied. Although iam not
> >>> sure if this really is better, maybe there are some problems iam missing ...
> >>>
> >>>
> >> Ok, I added a qp field, which is updated in ff_set_qscale.
> >> Regression tests still pass.
> > [...]
> >> Index: libavcodec/mpegvideo_enc.c
> >> ===================================================================
> >> --- libavcodec/mpegvideo_enc.c	(revision 12488)
> >> +++ libavcodec/mpegvideo_enc.c	(working copy)
> >> @@ -34,6 +34,7 @@
> >>  #include "mjpegenc.h"
> >>  #include "msmpeg4.h"
> >>  #include "h263.h"
> >> +#include "mpeg12.h"
> >>  #include "faandct.h"
> >>  #include <limits.h>
> >>  
> >> @@ -75,13 +76,14 @@
> >>  static uint8_t default_mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
> >>  static uint8_t default_fcode_tab[MAX_MV*2+1];
> >>  
> >> -void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],
> >> -                           const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra)
> >> +void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint8_t *qscale_table,
> >> +                       const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra, uint64_t numerator)
> >>  {
> > 
> > s/qscale_table/qp2qscale_table/
> > (here and the other table names as well)
> > 
> > The idea behind the naming is that
> > QP     == (abstract) Quantization Parameter
> > qscale == linear (de)Quantization SCALE factor
> > 
> > This might need some seperate/cosmetic renaming, not sure ...
> 
> Humm maybe you can have a brillant idea avoiding all the renaming,
> I fear this would be a huge patch.

I wish i had a brillant idea ...
The whole mess happened because I and fabrice ignored the distinction between
QP and linear qscale ...

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080319/e2eeea5d/attachment.pgp>



More information about the ffmpeg-devel mailing list