--- postprocessing.c 2003/12/21 19:42:07 1.1.4.4 +++ postprocessing.c 2004/04/01 11:11:28 1.3 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: postprocessing.c,v 1.1.4.4 2003/12/21 19:42:07 Isibaar Exp $ + * $Id: postprocessing.c,v 1.3 2004/04/01 11:11:28 suxen_drol Exp $ * ****************************************************************************/ @@ -33,6 +33,10 @@ #include "../utils/emms.h" #include "postprocessing.h" +/* function pointers */ +IMAGEBRIGHTNESS_PTR image_brightness; + + /* Some useful (and fast) macros Note that the MIN/MAX macros assume signed shift - if your compiler doesn't do signed shifts, use the default MIN/MAX macros from global.h */ @@ -51,7 +55,7 @@ void image_postproc(XVID_POSTPROC *tbls, IMAGE * img, int edged_width, const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride, - int flags, int frame_num, int bvop) + int flags, int brightness, int frame_num, int bvop) { const int edged_width2 = edged_width /2; int i,j; @@ -104,6 +108,10 @@ add_noise(tbls, img->y, img->y, edged_width, mb_width*16, mb_height*16, frame_num % 3, tbls->prev_quant); } + + if (brightness != 0) { + image_brightness(img->y, edged_width, mb_width*16, mb_height*16, brightness); + } } /******************************************************************************/ @@ -169,7 +177,7 @@ a31 = ((s[1]<<1) - s[2] * 5 + s[3] * 5 - (s[4]<<1)); \ a32 = ((s[5]<<1) - s[6] * 5 + s[7] * 5 - (s[8]<<1)); \ \ - diff = (5 * ((SIGN(a30) * MIN(tbls->xvid_abs_tbl[a30 + 255], MIN(tbls->xvid_abs_tbl[a31 + 255], tbls->xvid_abs_tbl[a32 + 255]))) - a30) + 32) >> 6; \ + diff = (5 * ((SIGN(a30) * MIN(FAST_ABS(a30), MIN(FAST_ABS(a31), FAST_ABS(a32)))) - a30) + 32) >> 6; \ limit = (s[4] - s[5]) / 2; \ \ if (limit > 0) \ @@ -370,3 +378,17 @@ src += stride; } } + + +void image_brightness_c(uint8_t *dst, int stride, int width, int height, int offset) +{ + int x,y; + + for(y = 0; y < height; y++) + { + for(x = 0; x < width; x++) + { + dst[y*stride + x] = CLIP( dst[y*stride + x] + offset, 0, 255); + } + } +}