Guard the lossless encoder (in flux) under a flag

Change-Id: I6dd8fd17089c199001c06b1afde14233dc3e3234
This commit is contained in:
Urvang Joshi
2012-04-11 09:52:13 +00:00
committed by James Zern
parent 09f7532cce
commit 6b38378acb
16 changed files with 82 additions and 4 deletions

View File

@ -8,6 +8,8 @@
// Author: Jyrki Alakuijala (jyrki@google.com)
//
#ifdef USE_LOSSLESS_ENCODER
#include <assert.h>
#include <math.h>
#include <stdint.h>
@ -785,3 +787,5 @@ Error:
free(stream);
return ok;
}
#endif

View File

@ -11,6 +11,8 @@
#ifndef WEBP_ENC_BACKWARD_REFERENCES_H_
#define WEBP_ENC_BACKWARD_REFERENCES_H_
#ifdef USE_LOSSLESS_ENCODER
#include <assert.h>
#include <stdint.h>
@ -231,4 +233,6 @@ int VP8LCalculateEstimateForPaletteSize(const uint32_t *argb,
}
#endif
#endif
#endif // WEBP_ENC_BACKWARD_REFERENCES_H_

View File

@ -117,8 +117,13 @@ int WebPValidateConfig(const WebPConfig* const config) {
return 0;
if (config->alpha_quality < 0 || config->alpha_quality > 100)
return 0;
#ifdef USE_LOSSLESS_ENCODER
if (config->lossless < 0 || config->lossless > 1)
return 0;
#else
if (config->lossless != 0)
return 0;
#endif
return 1;
}

View File

@ -8,6 +8,7 @@
// Author: Jyrki Alakuijala (jyrki@google.com)
//
#ifdef USE_LOSSLESS_ENCODER
#include <math.h>
#include <stdio.h>
@ -392,3 +393,5 @@ void VP8LHistogramRefine(VP8LHistogram** raw, int raw_size,
VP8LHistogramAdd(out[symbols[i]], raw[i]);
}
}
#endif

View File

@ -12,6 +12,8 @@
#ifndef WEBP_ENC_HISTOGRAM_H_
#define WEBP_ENC_HISTOGRAM_H_
#ifdef USE_LOSSLESS_ENCODER
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
@ -146,4 +148,6 @@ void VP8LHistogramRefine(VP8LHistogram** raw,
}
#endif
#endif
#endif // WEBP_ENC_HISTOGRAM_H_

View File

@ -105,6 +105,7 @@ int WebPPictureAlloc(WebPPicture* const picture) {
mem += uv0_size;
}
} else {
#ifdef USE_LOSSLESS_ENCODER
const uint64_t argb_size = (uint64_t)width * height;
const uint64_t total_size = argb_size * sizeof(*picture->argb);
if (width <= 0 || height <= 0 ||
@ -116,6 +117,9 @@ int WebPPictureAlloc(WebPPicture* const picture) {
picture->argb = (uint32_t*)malloc(total_size);
if (picture->argb == NULL) return 0;
picture->argb_stride = width;
#else
return 0;
#endif
}
}
return 1;
@ -129,14 +133,18 @@ static void WebPPictureGrabSpecs(const WebPPicture* const src,
dst->y = dst->u = dst->v = NULL;
dst->u0 = dst->v0 = NULL;
dst->a = NULL;
#ifdef USE_LOSSLESS_ENCODER
dst->argb = NULL;
#endif
}
// Release memory owned by 'picture'.
void WebPPictureFree(WebPPicture* const picture) {
if (picture != NULL) {
free(picture->y);
#ifdef USE_LOSSLESS_ENCODER
free(picture->argb);
#endif
WebPPictureGrabSpecs(NULL, picture);
}
}
@ -185,9 +193,13 @@ int WebPPictureCopy(const WebPPicture* const src, WebPPicture* const dst) {
}
#endif
} else {
#ifdef USE_LOSSLESS_ENCODER
CopyPlane((uint8_t*)src->argb, 4 * src->argb_stride,
(uint8_t*)dst->argb, 4 * dst->argb_stride,
4 * dst->width, dst->height);
#else
return 0;
#endif
}
return 1;
}
@ -524,6 +536,7 @@ static int Import(WebPPicture* const picture,
}
}
} else {
#ifdef USE_LOSSLESS_ENCODER
if (!import_alpha) {
for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) {
@ -551,6 +564,9 @@ static int Import(WebPPicture* const picture,
}
}
}
#else
return 0;
#endif
}
return 1;
}

View File

@ -10,6 +10,8 @@
// Author: Vikas Arora (vikaas.arora@gmail.com)
//
#ifdef USE_LOSSLESS_ENCODER
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@ -535,3 +537,5 @@ int VP8LEncodeImage(const WebPConfig* const config,
#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"
#endif
#endif

View File

@ -12,6 +12,8 @@
#ifndef WEBP_ENC_VP8LI_H_
#define WEBP_ENC_VP8LI_H_
#ifdef USE_LOSSLESS_ENCODER
#include "./histogram.h"
#include "../webp/encode.h"
#include "../utils/bit_writer.h"
@ -70,4 +72,6 @@ int VP8LEncodeImage(const WebPConfig* const config,
} // extern "C"
#endif
#endif
#endif /* WEBP_ENC_VP8LI_H_ */

View File

@ -364,10 +364,14 @@ int WebPEncode(const WebPConfig* const config, WebPPicture* const pic) {
}
DeleteVP8Encoder(enc);
} else {
#ifdef USE_LOSSLESS_ENCODER
if (pic->argb == NULL)
return WebPEncodingSetError(pic, VP8_ENC_ERROR_NULL_PARAMETER);
ok = VP8LEncodeImage(config, pic); // Sets pic->error in case of problem.
#else
return WebPEncodingSetError(pic, VP8_ENC_ERROR_INVALID_CONFIGURATION);
#endif
}
return ok;