Merge "speed-up GetResidualCost()"

This commit is contained in:
Pascal Massimino
2012-01-23 02:50:58 -08:00
committed by Gerrit Code Review
10 changed files with 163 additions and 144 deletions

View File

@ -26,7 +26,7 @@ extern "C" {
//------------------------------------------------------------------------------
int WebPPictureAlloc(WebPPicture* const picture) {
if (picture) {
if (picture != NULL) {
const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK;
const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT;
const int width = picture->width;
@ -109,7 +109,7 @@ int WebPPictureAlloc(WebPPicture* const picture) {
// into 'dst'. Mark 'dst' as not owning any memory. 'src' can be NULL.
static void WebPPictureGrabSpecs(const WebPPicture* const src,
WebPPicture* const dst) {
if (src) *dst = *src;
if (src != NULL) *dst = *src;
dst->y = dst->u = dst->v = NULL;
dst->u0 = dst->v0 = NULL;
dst->a = NULL;
@ -117,7 +117,7 @@ static void WebPPictureGrabSpecs(const WebPPicture* const src,
// Release memory owned by 'picture'.
void WebPPictureFree(WebPPicture* const picture) {
if (picture) {
if (picture != NULL) {
free(picture->y);
WebPPictureGrabSpecs(NULL, picture);
}
@ -126,7 +126,7 @@ void WebPPictureFree(WebPPicture* const picture) {
//------------------------------------------------------------------------------
// Picture copying
// TODO(skal): move to dsp/ ?
// Not worth moving to dsp/enc.c (only used here).
static void CopyPlane(const uint8_t* src, int src_stride,
uint8_t* dst, int dst_stride, int width, int height) {
while (height-- > 0) {
@ -196,13 +196,13 @@ int WebPPictureCrop(WebPPicture* const pic,
tmp.v, tmp.uv_stride, HALVE(width), HALVE(height));
}
if (tmp.a) {
if (tmp.a != NULL) {
const int a_offset = top * pic->a_stride + left;
CopyPlane(pic->a + a_offset, pic->a_stride,
tmp.a, tmp.a_stride, width, height);
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (tmp.u0) {
if (tmp.u0 != NULL) {
int w = width;
int l = left;
if (tmp.colorspace == WEBP_YUV422) {
@ -349,12 +349,12 @@ int WebPPictureRescale(WebPPicture* const pic, int width, int height) {
tmp.v,
HALVE(width), HALVE(height), tmp.uv_stride, work);
if (tmp.a) {
if (tmp.a != NULL) {
RescalePlane(pic->a, prev_width, prev_height, pic->a_stride,
tmp.a, width, height, tmp.a_stride, work);
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (tmp.u0) {
if (tmp.u0 != NULL) {
int s = 1;
if ((tmp.colorspace & WEBP_CSP_UV_MASK) == WEBP_YUV422) {
s = 2;
@ -383,7 +383,7 @@ typedef struct {
size_t* size;
} WebPMemoryWriter;
static void InitMemoryWriter(WebPMemoryWriter* const writer) {
static void WebPMemoryWriterInit(WebPMemoryWriter* const writer) {
*writer->mem = NULL;
*writer->size = 0;
writer->max_size = 0;
@ -413,7 +413,7 @@ static int WebPMemoryWrite(const uint8_t* data, size_t data_size,
*w->mem = new_mem;
w->max_size = next_max_size;
}
if (data_size) {
if (data_size > 0) {
memcpy((*w->mem) + (*w->size), data, data_size);
*w->size += data_size;
}
@ -735,7 +735,7 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
wrt.mem = output;
wrt.size = &output_size;
InitMemoryWriter(&wrt);
WebPMemoryWriterInit(&wrt);
ok = import(&pic, rgba, stride) && WebPEncode(&config, &pic);
WebPPictureFree(&pic);