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

Baptiste Coudurier baptiste.coudurier
Wed Mar 19 11:59:21 CET 2008


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.

So I guess this will be delayed for some time, need some work...

[...]

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
SMARTJOG SAS                                     http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312




More information about the ffmpeg-devel mailing list