Lines Matching refs:bw
246 VP8LBitWriter* const bw, const uint8_t* code_length_bitdepth) { in StoreHuffmanTreeOfHuffmanTreeToBitMask() argument
261 VP8LWriteBits(bw, 4, codes_to_store - 4); in StoreHuffmanTreeOfHuffmanTreeToBitMask()
263 VP8LWriteBits(bw, 3, code_length_bitdepth[kStorageOrder[i]]); in StoreHuffmanTreeOfHuffmanTreeToBitMask()
284 VP8LBitWriter* const bw, in StoreHuffmanTreeToBitMask() argument
291 VP8LWriteBits(bw, huffman_code->code_lengths[ix], huffman_code->codes[ix]); in StoreHuffmanTreeToBitMask()
294 VP8LWriteBits(bw, 2, extra_bits); in StoreHuffmanTreeToBitMask()
297 VP8LWriteBits(bw, 3, extra_bits); in StoreHuffmanTreeToBitMask()
300 VP8LWriteBits(bw, 7, extra_bits); in StoreHuffmanTreeToBitMask()
306 static int StoreFullHuffmanCode(VP8LBitWriter* const bw, in StoreFullHuffmanCode() argument
322 VP8LWriteBits(bw, 1, 0); in StoreFullHuffmanCode()
336 StoreHuffmanTreeOfHuffmanTreeToBitMask(bw, code_length_bitdepth); in StoreFullHuffmanCode()
360 VP8LWriteBits(bw, 1, write_trimmed_length); in StoreFullHuffmanCode()
364 VP8LWriteBits(bw, 3, nbitpairs - 1); in StoreFullHuffmanCode()
366 VP8LWriteBits(bw, nbitpairs * 2, trimmed_length - 2); in StoreFullHuffmanCode()
368 StoreHuffmanTreeToBitMask(bw, tokens, length, &huffman_code); in StoreFullHuffmanCode()
376 static int StoreHuffmanCode(VP8LBitWriter* const bw, in StoreHuffmanCode() argument
394 VP8LWriteBits(bw, 4, 0x01); in StoreHuffmanCode()
397 VP8LWriteBits(bw, 1, 1); // Small tree marker to encode 1 or 2 symbols. in StoreHuffmanCode()
398 VP8LWriteBits(bw, 1, count - 1); in StoreHuffmanCode()
400 VP8LWriteBits(bw, 1, 0); // Code bit for small (1 bit) symbol value. in StoreHuffmanCode()
401 VP8LWriteBits(bw, 1, symbols[0]); in StoreHuffmanCode()
403 VP8LWriteBits(bw, 1, 1); in StoreHuffmanCode()
404 VP8LWriteBits(bw, 8, symbols[0]); in StoreHuffmanCode()
407 VP8LWriteBits(bw, 8, symbols[1]); in StoreHuffmanCode()
411 return StoreFullHuffmanCode(bw, huffman_code); in StoreHuffmanCode()
415 static void WriteHuffmanCode(VP8LBitWriter* const bw, in WriteHuffmanCode() argument
420 VP8LWriteBits(bw, depth, symbol); in WriteHuffmanCode()
424 VP8LBitWriter* const bw, int width, int histo_bits, in StoreImageToBitMask() argument
442 WriteHuffmanCode(bw, codes, literal_ix); in StoreImageToBitMask()
448 WriteHuffmanCode(bw, codes + k, code); in StoreImageToBitMask()
455 WriteHuffmanCode(bw, codes, 256 + code); in StoreImageToBitMask()
456 VP8LWriteBits(bw, n_bits, bits); in StoreImageToBitMask()
460 WriteHuffmanCode(bw, codes + 4, code); in StoreImageToBitMask()
461 VP8LWriteBits(bw, n_bits, bits); in StoreImageToBitMask()
472 static int EncodeImageNoHuffman(VP8LBitWriter* const bw, in EncodeImageNoHuffman() argument
497 VP8LWriteBits(bw, 1, 0); in EncodeImageNoHuffman()
502 if (!StoreHuffmanCode(bw, codes)) { in EncodeImageNoHuffman()
509 StoreImageToBitMask(bw, width, 0, &refs, histogram_symbols, huffman_codes); in EncodeImageNoHuffman()
519 static int EncodeImageInternal(VP8LBitWriter* const bw, in EncodeImageInternal() argument
573 VP8LWriteBits(bw, 1, use_color_cache); in EncodeImageInternal()
575 VP8LWriteBits(bw, 4, cache_bits); in EncodeImageInternal()
581 VP8LWriteBits(bw, 1, write_histogram_image); in EncodeImageInternal()
598 VP8LWriteBits(bw, 3, histogram_bits - 2); in EncodeImageInternal()
599 ok = EncodeImageNoHuffman(bw, histogram_argb, in EncodeImageInternal()
613 if (!StoreHuffmanCode(bw, codes)) goto Error; in EncodeImageInternal()
619 StoreImageToBitMask(bw, width, histogram_bits, &refs, in EncodeImageInternal()
642 VP8LBitWriter* const bw) { in EvalAndApplySubtractGreen() argument
671 VP8LWriteBits(bw, 1, TRANSFORM_PRESENT); in EvalAndApplySubtractGreen()
672 VP8LWriteBits(bw, 2, SUBTRACT_GREEN); in EvalAndApplySubtractGreen()
681 VP8LBitWriter* const bw) { in ApplyPredictFilter() argument
688 VP8LWriteBits(bw, 1, TRANSFORM_PRESENT); in ApplyPredictFilter()
689 VP8LWriteBits(bw, 2, PREDICTOR_TRANSFORM); in ApplyPredictFilter()
691 VP8LWriteBits(bw, 3, pred_bits - 2); in ApplyPredictFilter()
692 if (!EncodeImageNoHuffman(bw, enc->transform_data_, in ApplyPredictFilter()
701 VP8LBitWriter* const bw) { in ApplyCrossColorFilter() argument
709 VP8LWriteBits(bw, 1, TRANSFORM_PRESENT); in ApplyCrossColorFilter()
710 VP8LWriteBits(bw, 2, CROSS_COLOR_TRANSFORM); in ApplyCrossColorFilter()
712 VP8LWriteBits(bw, 3, ccolor_transform_bits - 2); in ApplyCrossColorFilter()
713 if (!EncodeImageNoHuffman(bw, enc->transform_data_, in ApplyCrossColorFilter()
737 VP8LBitWriter* const bw) { in WriteImageSize() argument
742 VP8LWriteBits(bw, VP8L_IMAGE_SIZE_BITS, width); in WriteImageSize()
743 VP8LWriteBits(bw, VP8L_IMAGE_SIZE_BITS, height); in WriteImageSize()
744 return !bw->error_; in WriteImageSize()
747 static int WriteRealAlphaAndVersion(VP8LBitWriter* const bw, int has_alpha) { in WriteRealAlphaAndVersion() argument
748 VP8LWriteBits(bw, 1, has_alpha); in WriteRealAlphaAndVersion()
749 VP8LWriteBits(bw, VP8L_VERSION_BITS, VP8L_VERSION); in WriteRealAlphaAndVersion()
750 return !bw->error_; in WriteRealAlphaAndVersion()
754 VP8LBitWriter* const bw, in WriteImage() argument
757 const uint8_t* const webpll_data = VP8LBitWriterFinish(bw); in WriteImage()
758 const size_t webpll_size = VP8LBitWriterNumBytes(bw); in WriteImage()
872 static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, in EncodePalette() argument
905 VP8LWriteBits(bw, 1, TRANSFORM_PRESENT); in EncodePalette()
906 VP8LWriteBits(bw, 2, COLOR_INDEXING_TRANSFORM); in EncodePalette()
908 VP8LWriteBits(bw, 8, palette_size - 1); in EncodePalette()
912 if (!EncodeImageNoHuffman(bw, palette, palette_size, 1, quality)) { in EncodePalette()
975 VP8LBitWriter* const bw) { in VP8LEncodeStream() argument
981 const size_t byte_position = VP8LBitWriterNumBytes(bw); in VP8LEncodeStream()
999 err = EncodePalette(bw, enc, quality); in VP8LEncodeStream()
1021 if (!EvalAndApplySubtractGreen(enc, enc->current_width_, height, bw)) { in VP8LEncodeStream()
1027 if (!ApplyPredictFilter(enc, enc->current_width_, height, quality, bw)) { in VP8LEncodeStream()
1034 if (!ApplyCrossColorFilter(enc, enc->current_width_, height, quality, bw)) { in VP8LEncodeStream()
1040 VP8LWriteBits(bw, 1, !TRANSFORM_PRESENT); // No more transforms. in VP8LEncodeStream()
1056 if (!EncodeImageInternal(bw, enc->argb_, enc->current_width_, height, in VP8LEncodeStream()
1073 stats->lossless_size = (int)(VP8LBitWriterNumBytes(bw) - byte_position); in VP8LEncodeStream()
1088 VP8LBitWriter bw; in VP8LEncodeImage() local
1100 if (!VP8LBitWriterInit(&bw, (width * height) >> 1)) { in VP8LEncodeImage()
1122 if (!WriteImageSize(picture, &bw)) { in VP8LEncodeImage()
1129 if (!WriteRealAlphaAndVersion(&bw, has_alpha)) { in VP8LEncodeImage()
1137 err = VP8LEncodeStream(config, picture, &bw); in VP8LEncodeImage()
1144 err = WriteImage(picture, &bw, &coded_size); in VP8LEncodeImage()
1162 if (bw.error_) err = VP8_ENC_ERROR_OUT_OF_MEMORY; in VP8LEncodeImage()
1163 VP8LBitWriterDestroy(&bw); in VP8LEncodeImage()