SIMD/Uses/SAD: Difference between revisions

m
Line 23: Line 23:
The excerpts are part of a public-domain MPEG-1 video encoder and can be found in [https://github.com/maikmerten/mpeg/blob/master/me.c https://github.com/maikmerten/mpeg/blob/master/me.c], which contains all motion estimation routines.
The excerpts are part of a public-domain MPEG-1 video encoder and can be found in [https://github.com/maikmerten/mpeg/blob/master/me.c https://github.com/maikmerten/mpeg/blob/master/me.c], which contains all motion estimation routines.


The following C code computes the SAD for 16 consecutive pixels (one line in a 16x16 block). The pointers "bptr" and "cptr" point to pixels values (8 bit unsigned) in the current and a preceding frame. The variable "error", which is the accumulator for the SAD score, is initialized as zero.
The following C code computes the SAD for 16 consecutive pixels (one line in a 16x16 block). The pointers "bptr" and "cptr" point to pixel values (8 bit unsigned integers) in the current and a preceding frame. The variable "error", which is the accumulator for the SAD score, is initialized as zero.


  residue=(*(bptr++)-*(cptr++));
  residue=(*(bptr++)-*(cptr++));
51

edits