// 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. // ----------------------------------------------------------------------------- // // VP8Iterator: block iterator // // Author: Skal ([email protected]) #include <string.h> #include "src/enc/vp8i_enc.h" //------------------------------------------------------------------------------ // VP8Iterator //------------------------------------------------------------------------------ static void InitLeft(VP8EncIterator* const it) { … } static void InitTop(VP8EncIterator* const it) { … } void VP8IteratorSetRow(VP8EncIterator* const it, int y) { … } void VP8IteratorReset(VP8EncIterator* const it) { … } void VP8IteratorSetCountDown(VP8EncIterator* const it, int count_down) { … } int VP8IteratorIsDone(const VP8EncIterator* const it) { … } void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { … } int VP8IteratorProgress(const VP8EncIterator* const it, int delta) { … } //------------------------------------------------------------------------------ // Import the source samples into the cache. Takes care of replicating // boundary pixels if necessary. static WEBP_INLINE int MinSize(int a, int b) { … } static void ImportBlock(const uint8_t* src, int src_stride, uint8_t* dst, int w, int h, int size) { … } static void ImportLine(const uint8_t* src, int src_stride, uint8_t* dst, int len, int total_len) { … } void VP8IteratorImport(VP8EncIterator* const it, uint8_t* const tmp_32) { … } //------------------------------------------------------------------------------ // Copy back the compressed samples into user space if requested. static void ExportBlock(const uint8_t* src, uint8_t* dst, int dst_stride, int w, int h) { … } void VP8IteratorExport(const VP8EncIterator* const it) { … } //------------------------------------------------------------------------------ // Non-zero contexts setup/teardown // Nz bits: // 0 1 2 3 Y // 4 5 6 7 // 8 9 10 11 // 12 13 14 15 // 16 17 U // 18 19 // 20 21 V // 22 23 // 24 DC-intra16 // Convert packed context to byte array #define BIT … void VP8IteratorNzToBytes(VP8EncIterator* const it) { … } void VP8IteratorBytesToNz(VP8EncIterator* const it) { … } #undef BIT //------------------------------------------------------------------------------ // Advance to the next position, doing the bookkeeping. void VP8IteratorSaveBoundary(VP8EncIterator* const it) { … } int VP8IteratorNext(VP8EncIterator* const it) { … } //------------------------------------------------------------------------------ // Helper function to set mode properties void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode) { … } void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes) { … } void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode) { … } void VP8SetSkip(const VP8EncIterator* const it, int skip) { … } void VP8SetSegment(const VP8EncIterator* const it, int segment) { … } //------------------------------------------------------------------------------ // Intra4x4 sub-blocks iteration // // We store and update the boundary samples into an array of 37 pixels. They // are updated as we iterate and reconstructs each intra4x4 blocks in turn. // The position of the samples has the following snake pattern: // // 16|17 18 19 20|21 22 23 24|25 26 27 28|29 30 31 32|33 34 35 36 <- Top-right // --+-----------+-----------+-----------+-----------+ // 15| 19| 23| 27| 31| // 14| 18| 22| 26| 30| // 13| 17| 21| 25| 29| // 12|13 14 15 16|17 18 19 20|21 22 23 24|25 26 27 28| // --+-----------+-----------+-----------+-----------+ // 11| 15| 19| 23| 27| // 10| 14| 18| 22| 26| // 9| 13| 17| 21| 25| // 8| 9 10 11 12|13 14 15 16|17 18 19 20|21 22 23 24| // --+-----------+-----------+-----------+-----------+ // 7| 11| 15| 19| 23| // 6| 10| 14| 18| 22| // 5| 9| 13| 17| 21| // 4| 5 6 7 8| 9 10 11 12|13 14 15 16|17 18 19 20| // --+-----------+-----------+-----------+-----------+ // 3| 7| 11| 15| 19| // 2| 6| 10| 14| 18| // 1| 5| 9| 13| 17| // 0| 1 2 3 4| 5 6 7 8| 9 10 11 12|13 14 15 16| // --+-----------+-----------+-----------+-----------+ // Array to record the position of the top sample to pass to the prediction // functions in dsp.c. static const uint8_t VP8TopLeftI4[16] = …; void VP8IteratorStartI4(VP8EncIterator* const it) { … } int VP8IteratorRotateI4(VP8EncIterator* const it, const uint8_t* const yuv_out) { … } //------------------------------------------------------------------------------