[FFmpeg-devel] [PATCH] avcodec/x86/hpeldsp: fix half pel interpolation

Henrik Gramner henrik at gramner.com
Fri Apr 27 20:21:45 EEST 2018


On Fri, Apr 27, 2018 at 4:47 PM, Jerome Borsboom
<jerome.borsboom at carpalis.nl> wrote:
> In the put_no_rnd_pixels functions, the psubusb instruction subtracts one from each
> unsigned byte to correct for the rouding that the PAVGB instruction performs. The psubusb
> instruction, however, uses saturation when the value does not fit in the operand type,
> i.e. an unsigned byte. In this particular case, this means that when the value of a pixel
> is 0, the psubusb instruction will return 0 instead of -1 as this value does not fit in
> an unsigned byte and is saturated to 0. The result is that the interpolated value is not
> corrected for the rounding that PAVGB performs and that the result will be off by one.

Looks correct. You could put it in a macro though instead of
duplicating the code, e.g.

%macro PAVGB_NO_RND 4 ; dst/src1, src2, tmp, pb_1
    pxor         %3, %1, %2
    pand         %3, %4
    PAVGB        %1, %2
    psubb        %1, %3
%endmacro


More information about the ffmpeg-devel mailing list