lossless: fix crunch mode w/WEBP_REDUCE_SIZE

WEBP_REDUCE_SIZE was introduced to bring down the library size by
removing cropping and scaling support. Previously WebPPictureView() was
only used with these two, but in
  ec178f2c Add progress hook granularity in lossless
an additional use was added in VP8LEncodeStream() when extra side
configurations are used in crunch mode (-mt, quality == 100 & method ==
6 or quality >= 75 & method == 5 with a palette present currently).

WebPPictureView() and, for coherency, WebPPictureIsView() are
restored in this configuration to avoid affecting the general encode
path.

Previously WebPPictureView() was assumed to always succeed in these
cases which could result in crashes with WEBP_REDUCE_SIZE defined.

Bug: chromium:1345547
Bug: chromium:1345595
Bug: chromium:1345772
Bug: chromium:1345804
Change-Id: Ifecde36a726a434510478a764514b1469942c684
(cherry picked from commit 84163d9d02)
This commit is contained in:
James Zern 2022-07-20 19:27:26 -07:00
parent bfad7ab589
commit e626925cef

View File

@ -13,14 +13,15 @@
#include "src/webp/encode.h" #include "src/webp/encode.h"
#if !defined(WEBP_REDUCE_SIZE)
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "src/enc/vp8i_enc.h" #include "src/enc/vp8i_enc.h"
#if !defined(WEBP_REDUCE_SIZE)
#include "src/utils/rescaler_utils.h" #include "src/utils/rescaler_utils.h"
#include "src/utils/utils.h" #include "src/utils/utils.h"
#endif // !defined(WEBP_REDUCE_SIZE)
#define HALVE(x) (((x) + 1) >> 1) #define HALVE(x) (((x) + 1) >> 1)
@ -56,6 +57,7 @@ static int AdjustAndCheckRectangle(const WebPPicture* const pic,
return 1; return 1;
} }
#if !defined(WEBP_REDUCE_SIZE)
int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) { int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
if (src == NULL || dst == NULL) return 0; if (src == NULL || dst == NULL) return 0;
if (src == dst) return 1; if (src == dst) return 1;
@ -81,6 +83,7 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
} }
return 1; return 1;
} }
#endif // !defined(WEBP_REDUCE_SIZE)
int WebPPictureIsView(const WebPPicture* picture) { int WebPPictureIsView(const WebPPicture* picture) {
if (picture == NULL) return 0; if (picture == NULL) return 0;
@ -120,6 +123,7 @@ int WebPPictureView(const WebPPicture* src,
return 1; return 1;
} }
#if !defined(WEBP_REDUCE_SIZE)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Picture cropping // Picture cropping
@ -277,23 +281,6 @@ int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
return 0; return 0;
} }
int WebPPictureIsView(const WebPPicture* picture) {
(void)picture;
return 0;
}
int WebPPictureView(const WebPPicture* src,
int left, int top, int width, int height,
WebPPicture* dst) {
(void)src;
(void)left;
(void)top;
(void)width;
(void)height;
(void)dst;
return 0;
}
int WebPPictureCrop(WebPPicture* pic, int WebPPictureCrop(WebPPicture* pic,
int left, int top, int width, int height) { int left, int top, int width, int height) {
(void)pic; (void)pic;