github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/webp/libwebp/src/enc/layer.c (about)

     1  // Copyright 2011 Google Inc. All Rights Reserved.
     2  //
     3  // Use of this source code is governed by a BSD-style license
     4  // that can be found in the COPYING file in the root of the source
     5  // tree. An additional intellectual property rights grant can be found
     6  // in the file PATENTS. All contributing project authors may
     7  // be found in the AUTHORS file in the root of the source tree.
     8  // -----------------------------------------------------------------------------
     9  //
    10  // Enhancement layer (for YUV444/422)
    11  //
    12  // Author: Skal (pascal.massimino@gmail.com)
    13  
    14  #include <stdlib.h>
    15  
    16  #include "./vp8enci.h"
    17  
    18  //------------------------------------------------------------------------------
    19  
    20  void VP8EncInitLayer(VP8Encoder* const enc) {
    21    enc->use_layer_ = (enc->pic_->u0 != NULL);
    22    enc->layer_data_size_ = 0;
    23    enc->layer_data_ = NULL;
    24    if (enc->use_layer_) {
    25      VP8BitWriterInit(&enc->layer_bw_, enc->mb_w_ * enc->mb_h_ * 3);
    26    }
    27  }
    28  
    29  void VP8EncCodeLayerBlock(VP8EncIterator* it) {
    30    (void)it;   // remove a warning
    31  }
    32  
    33  int VP8EncFinishLayer(VP8Encoder* const enc) {
    34    if (enc->use_layer_) {
    35      enc->layer_data_ = VP8BitWriterFinish(&enc->layer_bw_);
    36      enc->layer_data_size_ = VP8BitWriterSize(&enc->layer_bw_);
    37    }
    38    return 1;
    39  }
    40  
    41  void VP8EncDeleteLayer(VP8Encoder* enc) {
    42    free(enc->layer_data_);
    43  }
    44