| Index: third_party/libwebp/enc/syntax.c
|
| diff --git a/third_party/libwebp/enc/syntax.c b/third_party/libwebp/enc/syntax.c
|
| index 08cfe79ece4f73970842eb10fd637599439b2770..d1ff0a53c309b1cbc41f8c8e0cb47fe3e8f1c201 100644
|
| --- a/third_party/libwebp/enc/syntax.c
|
| +++ b/third_party/libwebp/enc/syntax.c
|
| @@ -263,53 +263,16 @@ static int EmitPartitionsSize(const VP8Encoder* const enc,
|
|
|
| //------------------------------------------------------------------------------
|
|
|
| -#ifdef WEBP_EXPERIMENTAL_FEATURES
|
| -
|
| -#define KTRAILER_SIZE 8
|
| -
|
| -static int WriteExtensions(VP8Encoder* const enc) {
|
| - uint8_t buffer[KTRAILER_SIZE];
|
| - VP8BitWriter* const bw = &enc->bw_;
|
| - WebPPicture* const pic = enc->pic_;
|
| -
|
| - // Layer (bytes 0..3)
|
| - PutLE24(buffer + 0, enc->layer_data_size_);
|
| - buffer[3] = enc->pic_->colorspace & WEBP_CSP_UV_MASK;
|
| - if (enc->layer_data_size_ > 0) {
|
| - assert(enc->use_layer_);
|
| - // append layer data to last partition
|
| - if (!VP8BitWriterAppend(&enc->parts_[enc->num_parts_ - 1],
|
| - enc->layer_data_, enc->layer_data_size_)) {
|
| - return WebPEncodingSetError(pic, VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY);
|
| - }
|
| - }
|
| -
|
| - buffer[KTRAILER_SIZE - 1] = 0x01; // marker
|
| - if (!VP8BitWriterAppend(bw, buffer, KTRAILER_SIZE)) {
|
| - return WebPEncodingSetError(pic, VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY);
|
| - }
|
| - return 1;
|
| -}
|
| -
|
| -#endif /* WEBP_EXPERIMENTAL_FEATURES */
|
| -
|
| -//------------------------------------------------------------------------------
|
| -
|
| -static size_t GeneratePartition0(VP8Encoder* const enc) {
|
| +static int GeneratePartition0(VP8Encoder* const enc) {
|
| VP8BitWriter* const bw = &enc->bw_;
|
| const int mb_size = enc->mb_w_ * enc->mb_h_;
|
| uint64_t pos1, pos2, pos3;
|
| -#ifdef WEBP_EXPERIMENTAL_FEATURES
|
| - const int need_extensions = enc->use_layer_;
|
| -#endif
|
|
|
| pos1 = VP8BitWriterPos(bw);
|
| - VP8BitWriterInit(bw, mb_size * 7 / 8); // ~7 bits per macroblock
|
| -#ifdef WEBP_EXPERIMENTAL_FEATURES
|
| - VP8PutBitUniform(bw, need_extensions); // extensions
|
| -#else
|
| + if (!VP8BitWriterInit(bw, mb_size * 7 / 8)) { // ~7 bits per macroblock
|
| + return WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY);
|
| + }
|
| VP8PutBitUniform(bw, 0); // colorspace
|
| -#endif
|
| VP8PutBitUniform(bw, 0); // clamp type
|
|
|
| PutSegmentHeader(bw, enc);
|
| @@ -324,21 +287,17 @@ static size_t GeneratePartition0(VP8Encoder* const enc) {
|
| VP8CodeIntraModes(enc);
|
| VP8BitWriterFinish(bw);
|
|
|
| -#ifdef WEBP_EXPERIMENTAL_FEATURES
|
| - if (need_extensions && !WriteExtensions(enc)) {
|
| - return 0;
|
| - }
|
| -#endif
|
| -
|
| pos3 = VP8BitWriterPos(bw);
|
|
|
| if (enc->pic_->stats) {
|
| enc->pic_->stats->header_bytes[0] = (int)((pos2 - pos1 + 7) >> 3);
|
| enc->pic_->stats->header_bytes[1] = (int)((pos3 - pos2 + 7) >> 3);
|
| enc->pic_->stats->alpha_data_size = (int)enc->alpha_data_size_;
|
| - enc->pic_->stats->layer_data_size = (int)enc->layer_data_size_;
|
| }
|
| - return !bw->error_;
|
| + if (bw->error_) {
|
| + return WebPEncodingSetError(enc->pic_, VP8_ENC_ERROR_OUT_OF_MEMORY);
|
| + }
|
| + return 1;
|
| }
|
|
|
| void VP8EncFreeBitWriters(VP8Encoder* const enc) {
|
| @@ -360,7 +319,8 @@ int VP8EncWrite(VP8Encoder* const enc) {
|
| int p;
|
|
|
| // Partition #0 with header and partition sizes
|
| - ok = !!GeneratePartition0(enc);
|
| + ok = GeneratePartition0(enc);
|
| + if (!ok) return 0;
|
|
|
| // Compute VP8 size
|
| vp8_size = VP8_FRAME_HEADER_SIZE +
|
|
|