Hi,

On 12/16/2012 06:27 AM, Loren Merritt wrote:
> On Sat, 15 Dec 2012, Justin Ruggles wrote:
> 
>> +;------------------------------------------------------------------------------
>> +; void ff_quantize_int_rectangular/triangular(int16_t *dst, float *src,
>> +;                                             int *dither, int len);
>> +;------------------------------------------------------------------------------
>> +
>> +%macro QUANTIZE_INT 1
>> +cglobal quantize_int_%1, 4,5,6, dst, src, dither0, len, dither1
>> +    lea         lenq, [2*lend]
>> +    add         dstq, lenq
>> +    lea         srcq, [srcq+2*lenq]
>> +%ifidn %1, triangular
>> +    lea     dither1q, [dither0q+4*lenq]
>> +%endif
>> +    lea     dither0q, [dither0q+2*lenq]
>> +    neg         lenq
>> +    mova          m4, [pf_dither_scale]
>> +    mova          m5, [pf_s16_scale]
>> +.loop:
>> +    cvtdq2ps      m0, [dither0q+2*lenq]
>> +    cvtdq2ps      m1, [dither0q+2*lenq+mmsize]
> 
> Do you have to store dither in a format different than the asm works with?

That's the whole point of these functions. av_get_lfg() returns an
unsigned int, so instead of converting each value to float and scaling
individually, we can use SSE2 to do the conversion/scaling of multiple
values along with adding the noise to the samples.

For the triangular dither with high-pass it actually does convert/scale
the dither noise separately, filters it, then adds it into the samples.
But for the dither methods that don't require filtering, we can do it
all at once.

>> +%ifidn %1, triangular
>> +    cvtdq2ps      m2, [dither1q+2*lenq]
>> +    cvtdq2ps      m3, [dither1q+2*lenq+mmsize]
>> +    addps         m0, m2
>> +    addps         m1, m3
> 
> Can you add before converting, or does that overflow?

That overflows. The range on the dither noise is INT_MIN to INT_MAX.

Thanks,
Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to