Home | History | Annotate | Download | only in enc

Lines Matching defs:enc

143 static int VP8LEncAnalyze(VP8LEncoder* const enc, WebPImageHint image_hint) {
144 const WebPPicture* const pic = enc->pic_;
147 enc->use_palette_ =
148 AnalyzeAndCreatePalette(pic, enc->palette_, &enc->palette_size_);
151 if (enc->use_palette_ && enc->palette_size_ < MAX_COLORS_FOR_GRAPH) {
152 enc->use_palette_ = 0;
156 if (!enc->use_palette_) {
158 enc->use_predict_ = 1;
159 enc->use_cross_color_ = 1;
167 enc->use_predict_ = 1;
171 enc->use_cross_color_ = 1;
627 static int EvalAndApplySubtractGreen(VP8LEncoder* const enc,
630 if (!enc->use_palette_) {
632 const uint32_t* const argb = enc->argb_;
656 enc->use_subtract_green_ = (bit_cost_after < bit_cost_before);
657 if (enc->use_subtract_green_) {
660 VP8LSubtractGreenFromBlueAndRed(enc->argb_, width * height);
666 static int ApplyPredictFilter(const VP8LEncoder* const enc,
669 const int pred_bits = enc->transform_bits_;
673 VP8LResidualImage(width, height, pred_bits, enc->argb_, enc->argb_scratch_,
674 enc->transform_data_);
679 if (!EncodeImageNoHuffman(bw, enc->transform_data_,
686 static int ApplyCrossColorFilter(const VP8LEncoder* const enc,
689 const int ccolor_transform_bits = enc->transform_bits_;
695 enc->argb_, enc->transform_data_);
700 if (!EncodeImageNoHuffman(bw, enc->transform_data_,
783 static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc,
786 const int tile_size = 1 << enc->transform_bits_;
790 (uint64_t)VP8LSubSampleSize(width, enc->transform_bits_) *
791 (uint64_t)VP8LSubSampleSize(height, enc->transform_bits_);
799 enc->argb_ = mem;
801 enc->argb_scratch_ = mem;
803 enc->transform_data_ = mem;
804 enc->current_width_ = width;
837 // Note: Expects "enc->palette_" to be set properly.
838 // Also, "enc->palette_" will be modified after this call and should not be used
841 VP8LEncoder* const enc, int quality) {
844 const WebPPicture* const pic = enc->pic_;
848 uint32_t* const palette = enc->palette_;
849 const int palette_size = enc->palette_size_;
886 err = AllocateTransformBuffer(enc, VP8LSubSampleSize(width, xbits), height);
888 BundleColorMap(pic, xbits, enc->argb_, enc->current_width_);
915 static void InitEncParams(VP8LEncoder* const enc) {
916 const WebPConfig* const config = enc->config_;
917 const WebPPicture* const picture = enc->pic_;
920 enc->transform_bits_ = (method < 4) ? 5 : (method > 4) ? 3 : 4;
921 enc->histo_bits_ = GetHistoBits(config, picture);
922 enc->cache_bits_ = (quality <= 25.f) ? 0 : 7;
930 VP8LEncoder* const enc = (VP8LEncoder*)calloc(1, sizeof(*enc));
931 if (enc == NULL) {
935 enc->config_ = config;
936 enc->pic_ = picture;
937 return enc;
940 static void VP8LEncoderDelete(VP8LEncoder* enc) {
941 free(enc->argb_);
942 free(enc);
955 VP8LEncoder* const enc = VP8LEncoderNew(config, picture);
958 if (enc == NULL) {
963 InitEncParams(enc);
968 if (!VP8LEncAnalyze(enc, config->image_hint)) {
973 if (enc->use_palette_) {
974 err = ApplyPalette(bw, enc, quality);
977 enc
981 if (enc->argb_ == NULL) {
983 err = AllocateTransformBuffer(enc, width, height);
986 memcpy(enc->argb_ + y * width,
988 width * sizeof(*enc->argb_));
990 enc->current_width_ = width;
996 if (!EvalAndApplySubtractGreen(enc, enc->current_width_, height, bw)) {
1001 if (enc->use_predict_) {
1002 if (!ApplyPredictFilter(enc, enc->current_width_, height, quality, bw)) {
1008 if (enc->use_cross_color_) {
1009 if (!ApplyCrossColorFilter(enc, enc->current_width_, height, quality, bw)) {
1020 if (enc->cache_bits_ > 0) {
1021 if (!VP8LCalculateEstimateForCacheSize(enc->argb_, enc->current_width_,
1022 height, &enc->cache_bits_)) {
1031 if (!EncodeImageInternal(bw, enc->argb_, enc->current_width_, height,
1032 quality, enc->cache_bits_, enc->histo_bits_)) {
1040 if (enc->use_predict_) stats->lossless_features |= 1;
1041 if (enc->use_cross_color_) stats->lossless_features |= 2;
1042 if (enc->use_subtract_green_) stats->lossless_features |= 4;
1043 if (enc->use_palette_) stats->lossless_features |= 8;
1044 stats->histogram_bits = enc->histo_bits_;
1045 stats->transform_bits = enc->transform_bits_;
1046 stats->cache_bits = enc->cache_bits_;
1047 stats->palette_size = enc->palette_size_;
1052 VP8LEncoderDelete(enc);