From d1b45ae65b49e602c4fb649d0220cfb79ca7e3b4 Mon Sep 17 00:00:00 2001 From: Steve Underwood Date: Thu, 9 Aug 2012 21:58:22 +0800 Subject: [PATCH] A couple of typos in spandsp Improvements to image flattening in spandsp's image translate code --- libs/spandsp/src/image_translate.c | 16 +++++++--------- libs/spandsp/src/spandsp/ima_adpcm.h | 2 +- libs/spandsp/src/spandsp/private/ima_adpcm.h | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libs/spandsp/src/image_translate.c b/libs/spandsp/src/image_translate.c index 54037990fc..4ee2c211bf 100644 --- a/libs/spandsp/src/image_translate.c +++ b/libs/spandsp/src/image_translate.c @@ -163,10 +163,9 @@ static int image_gray16_to_colour16_row(uint16_t colour16[], uint16_t gray16[], for (i = pixels - 1; i >= 0; i--) { - /* TODO: need to balance the colours */ - colour16[3*i] = gray16[i]; - colour16[3*i + 1] = gray16[i]; - colour16[3*i + 2] = gray16[i]; + colour16[3*i] = saturateu16((gray16[i]*36532) >> 15); + colour16[3*i + 1] = saturateu16((gray16[i]*37216) >> 16); + colour16[3*i + 2] = saturateu16((gray16[i]*47900) >> 14); } return pixels; } @@ -178,10 +177,9 @@ static int image_gray16_to_colour8_row(uint8_t colour8[], uint16_t gray16[], int for (i = pixels - 1; i >= 0; i--) { - /* TODO: need to balance the colours */ - colour8[3*i] = gray16[i] >> 8; - colour8[3*i + 1] = gray16[i] >> 8; - colour8[3*i + 2] = gray16[i] >> 8; + colour8[3*i] = saturateu8((gray16[i]*36532) >> 23); + colour8[3*i + 1] = saturateu8((gray16[i]*37216) >> 24); + colour8[3*i + 2] = saturateu8((gray16[i]*47900) >> 22); } return pixels; } @@ -530,7 +528,7 @@ SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], else { i = s->output_width*s->output_bytes_per_pixel; - memcpy(buf, s->pixel_row[1], i); + memcpy(buf, s->pixel_row[0], i); } return i; } diff --git a/libs/spandsp/src/spandsp/ima_adpcm.h b/libs/spandsp/src/spandsp/ima_adpcm.h index 292bdd5d83..2942efa859 100644 --- a/libs/spandsp/src/spandsp/ima_adpcm.h +++ b/libs/spandsp/src/spandsp/ima_adpcm.h @@ -1,7 +1,7 @@ /* * SpanDSP - a series of DSP components for telephony * - * ima_adpcm.c - Conversion routines between linear 16 bit PCM data and + * ima_adpcm.h - Conversion routines between linear 16 bit PCM data and * IMA/DVI/Intel ADPCM format. * * Written by Steve Underwood diff --git a/libs/spandsp/src/spandsp/private/ima_adpcm.h b/libs/spandsp/src/spandsp/private/ima_adpcm.h index 21ead941af..2fc7d2c114 100644 --- a/libs/spandsp/src/spandsp/private/ima_adpcm.h +++ b/libs/spandsp/src/spandsp/private/ima_adpcm.h @@ -1,7 +1,7 @@ /* * SpanDSP - a series of DSP components for telephony * - * private/ima_adpcm.c - Conversion routines between linear 16 bit PCM data + * private/ima_adpcm.h - Conversion routines between linear 16 bit PCM data * and IMA/DVI/Intel ADPCM format. * * Written by Steve Underwood