From f1e771735ae84c4b3afcb91e1029f48fe0c91690 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 6 May 2014 01:59:30 -0700 Subject: [PATCH] remove all unused layer code Change-Id: I220590162b24c70f404fe3087f19dd3e6cac3608 --- Android.mk | 2 -- Makefile.vc | 2 -- examples/cwebp.c | 4 ---- makefile.unix | 2 -- src/dec/Makefile.am | 1 - src/dec/layer.c | 30 ----------------------------- src/dec/vp8.c | 31 ------------------------------ src/dec/vp8i.h | 8 -------- src/enc/Makefile.am | 1 - src/enc/frame.c | 10 ---------- src/enc/layer.c | 44 ------------------------------------------- src/enc/syntax.c | 46 --------------------------------------------- src/enc/vp8enci.h | 12 ------------ src/enc/webpenc.c | 9 --------- src/webp/decode.h | 2 +- src/webp/encode.h | 2 +- 16 files changed, 2 insertions(+), 204 deletions(-) delete mode 100644 src/dec/layer.c delete mode 100644 src/enc/layer.c diff --git a/Android.mk b/Android.mk index f56bc887..99996599 100644 --- a/Android.mk +++ b/Android.mk @@ -18,7 +18,6 @@ LOCAL_SRC_FILES := \ src/dec/frame.c \ src/dec/idec.c \ src/dec/io.c \ - src/dec/layer.c \ src/dec/quant.c \ src/dec/tree.c \ src/dec/vp8.c \ @@ -48,7 +47,6 @@ LOCAL_SRC_FILES := \ src/enc/frame.c \ src/enc/histogram.c \ src/enc/iterator.c \ - src/enc/layer.c \ src/enc/picture.c \ src/enc/quant.c \ src/enc/syntax.c \ diff --git a/Makefile.vc b/Makefile.vc index 95ccad73..7a70e9f8 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -156,7 +156,6 @@ DEC_OBJS = \ $(DIROBJ)\dec\frame.obj \ $(DIROBJ)\dec\idec.obj \ $(DIROBJ)\dec\io.obj \ - $(DIROBJ)\dec\layer.obj \ $(DIROBJ)\dec\quant.obj \ $(DIROBJ)\dec\tree.obj \ $(DIROBJ)\dec\vp8.obj \ @@ -210,7 +209,6 @@ ENC_OBJS = \ $(DIROBJ)\enc\frame.obj \ $(DIROBJ)\enc\histogram.obj \ $(DIROBJ)\enc\iterator.obj \ - $(DIROBJ)\enc\layer.obj \ $(DIROBJ)\enc\picture.obj \ $(DIROBJ)\enc\quant.obj \ $(DIROBJ)\enc\syntax.obj \ diff --git a/examples/cwebp.c b/examples/cwebp.c index efce204c..d52b319d 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -273,10 +273,6 @@ static void PrintExtraInfoLossy(const WebPPicture* const pic, int short_output, fprintf(stderr, " transparency: %6d (%.1f dB)\n", stats->alpha_data_size, stats->PSNR[4]); } - if (stats->layer_data_size) { - fprintf(stderr, " enhancement: %6d\n", - stats->layer_data_size); - } fprintf(stderr, " Residuals bytes " "|segment 1|segment 2|segment 3" "|segment 4| total\n"); diff --git a/makefile.unix b/makefile.unix index 6aea2365..17b1d451 100644 --- a/makefile.unix +++ b/makefile.unix @@ -91,7 +91,6 @@ DEC_OBJS = \ src/dec/frame.o \ src/dec/idec.o \ src/dec/io.o \ - src/dec/layer.o \ src/dec/quant.o \ src/dec/tree.o \ src/dec/vp8.o \ @@ -134,7 +133,6 @@ ENC_OBJS = \ src/enc/frame.o \ src/enc/histogram.o \ src/enc/iterator.o \ - src/enc/layer.o \ src/enc/picture.o \ src/enc/quant.o \ src/enc/syntax.o \ diff --git a/src/dec/Makefile.am b/src/dec/Makefile.am index 0b5c29a6..d0e0333b 100644 --- a/src/dec/Makefile.am +++ b/src/dec/Makefile.am @@ -9,7 +9,6 @@ libwebpdecode_la_SOURCES += decode_vp8.h libwebpdecode_la_SOURCES += frame.c libwebpdecode_la_SOURCES += idec.c libwebpdecode_la_SOURCES += io.c -libwebpdecode_la_SOURCES += layer.c libwebpdecode_la_SOURCES += quant.c libwebpdecode_la_SOURCES += tree.c libwebpdecode_la_SOURCES += vp8.c diff --git a/src/dec/layer.c b/src/dec/layer.c deleted file mode 100644 index dacb9e23..00000000 --- a/src/dec/layer.c +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -// -// Use of this source code is governed by a BSD-style license -// that can be found in the COPYING file in the root of the source -// tree. An additional intellectual property rights grant can be found -// in the file PATENTS. All contributing project authors may -// be found in the AUTHORS file in the root of the source tree. -// ----------------------------------------------------------------------------- -// -// Enhancement layer (for YUV444/422) -// -// Author: Skal (pascal.massimino@gmail.com) - -#include -#include - -#include "./vp8i.h" - -//------------------------------------------------------------------------------ - -int VP8DecodeLayer(VP8Decoder* const dec) { - assert(dec); - assert(dec->layer_data_size_ > 0); - (void)dec; - - // TODO: handle enhancement layer here. - - return 1; -} - diff --git a/src/dec/vp8.c b/src/dec/vp8.c index b4c1968d..c5e280d9 100644 --- a/src/dec/vp8.c +++ b/src/dec/vp8.c @@ -363,28 +363,6 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) { VP8ParseProba(br, dec); -#ifdef WEBP_EXPERIMENTAL_FEATURES - // Extensions - if (dec->pic_hdr_.colorspace_) { - const size_t kTrailerSize = 8; - const uint8_t kTrailerMarker = 0x01; - const uint8_t* ext_buf = buf - kTrailerSize; - size_t size; - - if (frm_hdr->partition_length_ < kTrailerSize || - ext_buf[kTrailerSize - 1] != kTrailerMarker) { - return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR, - "RIFF: Inconsistent extra information."); - } - - // Layer - size = (ext_buf[0] << 0) | (ext_buf[1] << 8) | (ext_buf[2] << 16); - dec->layer_data_size_ = size; - dec->layer_data_ = NULL; // will be set later - dec->layer_colorspace_ = ext_buf[3]; - } -#endif - // sanitized state dec->ready_ = 1; return 1; @@ -629,15 +607,6 @@ static int ParseFrame(VP8Decoder* const dec, VP8Io* io) { if (!WebPWorkerSync(&dec->worker_)) return 0; } - // Finish -#ifdef WEBP_EXPERIMENTAL_FEATURES - if (dec->layer_data_size_ > 0) { - if (!VP8DecodeLayer(dec)) { - return 0; - } - } -#endif - return 1; } diff --git a/src/dec/vp8i.h b/src/dec/vp8i.h index 1efe3f5c..35a757b7 100644 --- a/src/dec/vp8i.h +++ b/src/dec/vp8i.h @@ -297,11 +297,6 @@ struct VP8Decoder { size_t alpha_data_size_; int is_alpha_decoded_; // true if alpha_data_ is decoded in alpha_plane_ uint8_t* alpha_plane_; // output. Persistent, contains the whole data. - - // extensions - int layer_colorspace_; - const uint8_t* layer_data_; // compressed layer data (if present) - size_t layer_data_size_; }; //------------------------------------------------------------------------------ @@ -349,9 +344,6 @@ int VP8DecodeMB(VP8Decoder* const dec, VP8BitReader* const token_br); const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, int row, int num_rows); -// in layer.c -int VP8DecodeLayer(VP8Decoder* const dec); - //------------------------------------------------------------------------------ #ifdef __cplusplus diff --git a/src/enc/Makefile.am b/src/enc/Makefile.am index 0f6c96e0..78659264 100644 --- a/src/enc/Makefile.am +++ b/src/enc/Makefile.am @@ -12,7 +12,6 @@ libwebpencode_la_SOURCES += filter.c libwebpencode_la_SOURCES += frame.c libwebpencode_la_SOURCES += histogram.c libwebpencode_la_SOURCES += iterator.c -libwebpencode_la_SOURCES += layer.c libwebpencode_la_SOURCES += picture.c libwebpencode_la_SOURCES += quant.c libwebpencode_la_SOURCES += syntax.c diff --git a/src/enc/frame.c b/src/enc/frame.c index 3ef95303..91ec0bcb 100644 --- a/src/enc/frame.c +++ b/src/enc/frame.c @@ -716,11 +716,6 @@ int VP8EncLoop(VP8Encoder* const enc) { } else { // reset predictors after a skip ResetAfterSkip(&it); } -#ifdef WEBP_EXPERIMENTAL_FEATURES - if (enc->use_layer_) { - VP8EncCodeLayerBlock(&it); - } -#endif StoreSideInfo(&it); VP8StoreFilterStats(&it); VP8IteratorExport(&it); @@ -788,11 +783,6 @@ int VP8EncTokenLoop(VP8Encoder* const enc) { RecordTokens(&it, &info, &enc->tokens_); size_p0 += info.H; distortion += info.D; -#ifdef WEBP_EXPERIMENTAL_FEATURES - if (enc->use_layer_) { - VP8EncCodeLayerBlock(&it); - } -#endif if (is_last_pass) { StoreSideInfo(&it); VP8StoreFilterStats(&it); diff --git a/src/enc/layer.c b/src/enc/layer.c deleted file mode 100644 index 0a4c8cec..00000000 --- a/src/enc/layer.c +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -// -// Use of this source code is governed by a BSD-style license -// that can be found in the COPYING file in the root of the source -// tree. An additional intellectual property rights grant can be found -// in the file PATENTS. All contributing project authors may -// be found in the AUTHORS file in the root of the source tree. -// ----------------------------------------------------------------------------- -// -// Enhancement layer (for YUV444/422) -// -// Author: Skal (pascal.massimino@gmail.com) - -#include - -#include "./vp8enci.h" -#include "../utils/utils.h" - -//------------------------------------------------------------------------------ - -void VP8EncInitLayer(VP8Encoder* const enc) { - enc->use_layer_ = (enc->pic_->u0 != NULL); - enc->layer_data_size_ = 0; - enc->layer_data_ = NULL; - if (enc->use_layer_) { - VP8BitWriterInit(&enc->layer_bw_, enc->mb_w_ * enc->mb_h_ * 3); - } -} - -void VP8EncCodeLayerBlock(VP8EncIterator* it) { - (void)it; // remove a warning -} - -int VP8EncFinishLayer(VP8Encoder* const enc) { - if (enc->use_layer_) { - enc->layer_data_ = VP8BitWriterFinish(&enc->layer_bw_); - enc->layer_data_size_ = VP8BitWriterSize(&enc->layer_bw_); - } - return 1; -} - -void VP8EncDeleteLayer(VP8Encoder* enc) { - WebPSafeFree(enc->layer_data_); -} diff --git a/src/enc/syntax.c b/src/enc/syntax.c index 08cfe79e..7802cc0c 100644 --- a/src/enc/syntax.c +++ b/src/enc/syntax.c @@ -263,53 +263,14 @@ 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) { 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 VP8PutBitUniform(bw, 0); // colorspace -#endif VP8PutBitUniform(bw, 0); // clamp type PutSegmentHeader(bw, enc); @@ -324,19 +285,12 @@ 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_; } diff --git a/src/enc/vp8enci.h b/src/enc/vp8enci.h index 39430bbd..f09cdb98 100644 --- a/src/enc/vp8enci.h +++ b/src/enc/vp8enci.h @@ -426,12 +426,6 @@ struct VP8Encoder { uint32_t alpha_data_size_; WebPWorker alpha_worker_; - // enhancement layer - int use_layer_; - VP8BitWriter layer_bw_; - uint8_t* layer_data_; - size_t layer_data_size_; - // quantization info (one set of DC/AC dequant factor per segment) VP8SegmentInfo dqm_[NUM_MB_SEGMENTS]; int base_quant_; // nominal quantizer value. Only used @@ -537,12 +531,6 @@ int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data - // in layer.c -void VP8EncInitLayer(VP8Encoder* const enc); // init everything -void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock -int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding -void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory - // in filter.c // SSIM utils diff --git a/src/enc/webpenc.c b/src/enc/webpenc.c index ec8cebcf..6275f45d 100644 --- a/src/enc/webpenc.c +++ b/src/enc/webpenc.c @@ -254,9 +254,6 @@ static VP8Encoder* InitVP8Encoder(const WebPConfig* const config, ResetBoundaryPredictions(enc); VP8GetResidualCostInit(); VP8EncInitAlpha(enc); -#ifdef WEBP_EXPERIMENTAL_FEATURES - VP8EncInitLayer(enc); -#endif // lower quality means smaller output -> we modulate a little the page // size based on quality. This is just a crude 1rst-order prediction. @@ -271,9 +268,6 @@ static int DeleteVP8Encoder(VP8Encoder* enc) { int ok = 1; if (enc != NULL) { ok = VP8EncDeleteAlpha(enc); -#ifdef WEBP_EXPERIMENTAL_FEATURES - VP8EncDeleteLayer(enc); -#endif VP8TBufferClear(&enc->tokens_); WebPSafeFree(enc); } @@ -386,9 +380,6 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) { ok = ok && VP8EncTokenLoop(enc); } ok = ok && VP8EncFinishAlpha(enc); -#ifdef WEBP_EXPERIMENTAL_FEATURES - ok = ok && VP8EncFinishLayer(enc); -#endif ok = ok && VP8EncWrite(enc); StoreStats(enc); diff --git a/src/webp/decode.h b/src/webp/decode.h index 606d6ba2..580274c8 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define WEBP_DECODER_ABI_VERSION 0x0204 // MAJOR(8b) + MINOR(8b) +#define WEBP_DECODER_ABI_VERSION 0x0205 // MAJOR(8b) + MINOR(8b) // Note: forward declaring enumerations is not allowed in (strict) C and C++, // the types are left here for reference. diff --git a/src/webp/encode.h b/src/webp/encode.h index 130f7ccb..718575a3 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define WEBP_ENCODER_ABI_VERSION 0x0204 // MAJOR(8b) + MINOR(8b) +#define WEBP_ENCODER_ABI_VERSION 0x0205 // MAJOR(8b) + MINOR(8b) // Note: forward declaring enumerations is not allowed in (strict) C and C++, // the types are left here for reference.