129a84457aed4c45bc900998b5e11c03023264208James Dong/* ------------------------------------------------------------------
229a84457aed4c45bc900998b5e11c03023264208James Dong * Copyright (C) 1998-2009 PacketVideo
329a84457aed4c45bc900998b5e11c03023264208James Dong *
429a84457aed4c45bc900998b5e11c03023264208James Dong * Licensed under the Apache License, Version 2.0 (the "License");
529a84457aed4c45bc900998b5e11c03023264208James Dong * you may not use this file except in compliance with the License.
629a84457aed4c45bc900998b5e11c03023264208James Dong * You may obtain a copy of the License at
729a84457aed4c45bc900998b5e11c03023264208James Dong *
829a84457aed4c45bc900998b5e11c03023264208James Dong *      http://www.apache.org/licenses/LICENSE-2.0
929a84457aed4c45bc900998b5e11c03023264208James Dong *
1029a84457aed4c45bc900998b5e11c03023264208James Dong * Unless required by applicable law or agreed to in writing, software
1129a84457aed4c45bc900998b5e11c03023264208James Dong * distributed under the License is distributed on an "AS IS" BASIS,
1229a84457aed4c45bc900998b5e11c03023264208James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1329a84457aed4c45bc900998b5e11c03023264208James Dong * express or implied.
1429a84457aed4c45bc900998b5e11c03023264208James Dong * See the License for the specific language governing permissions
1529a84457aed4c45bc900998b5e11c03023264208James Dong * and limitations under the License.
1629a84457aed4c45bc900998b5e11c03023264208James Dong * -------------------------------------------------------------------
1729a84457aed4c45bc900998b5e11c03023264208James Dong */
1829a84457aed4c45bc900998b5e11c03023264208James Dong/**
1929a84457aed4c45bc900998b5e11c03023264208James DongThis file contains declarations of internal functions for AVC decoder library.
2029a84457aed4c45bc900998b5e11c03023264208James Dong@publishedAll
2129a84457aed4c45bc900998b5e11c03023264208James Dong*/
2229a84457aed4c45bc900998b5e11c03023264208James Dong#ifndef AVCENC_LIB_H_INCLUDED
2329a84457aed4c45bc900998b5e11c03023264208James Dong#define AVCENC_LIB_H_INCLUDED
2429a84457aed4c45bc900998b5e11c03023264208James Dong
2529a84457aed4c45bc900998b5e11c03023264208James Dong#ifndef AVCLIB_COMMON_H_INCLUDED
2629a84457aed4c45bc900998b5e11c03023264208James Dong#include "avclib_common.h"
2729a84457aed4c45bc900998b5e11c03023264208James Dong#endif
2829a84457aed4c45bc900998b5e11c03023264208James Dong#ifndef AVCENC_INT_H_INCLUDED
2929a84457aed4c45bc900998b5e11c03023264208James Dong#include "avcenc_int.h"
3029a84457aed4c45bc900998b5e11c03023264208James Dong#endif
3129a84457aed4c45bc900998b5e11c03023264208James Dong
3229a84457aed4c45bc900998b5e11c03023264208James Dong#ifdef __cplusplus
3329a84457aed4c45bc900998b5e11c03023264208James Dongextern "C"
3429a84457aed4c45bc900998b5e11c03023264208James Dong{
3529a84457aed4c45bc900998b5e11c03023264208James Dong#endif
3629a84457aed4c45bc900998b5e11c03023264208James Dong    /*------------- block.c -------------------------*/
3729a84457aed4c45bc900998b5e11c03023264208James Dong
3829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
3929a84457aed4c45bc900998b5e11c03023264208James Dong    This function perform residue calculation, transform, quantize, inverse quantize,
4029a84457aed4c45bc900998b5e11c03023264208James Dong    inverse transform and residue compensation on a 4x4 block.
4129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
4229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "blkidx"  "raster scan block index of the current 4x4 block."
4329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the reconstructed block."
4429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org"    "Pointer to the original block."
4529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "coef_cost"  "Pointer to the coefficient cost to be filled in and returned."
4629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Number of non-zero coefficients."
4729a84457aed4c45bc900998b5e11c03023264208James Dong    */
4829a84457aed4c45bc900998b5e11c03023264208James Dong    int dct_luma(AVCEncObject *encvid, int blkidx, uint8 *cur, uint8 *org, int *coef_cost);
4929a84457aed4c45bc900998b5e11c03023264208James Dong
5029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
5129a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs IDCT on an INTER macroblock.
5229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCCommonObj."
5329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curL"   "Pointer to the origin of the macroblock on the current frame."
5429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the AVCMacroblock structure."
5529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picPitch" "Pitch of the current frame."
5629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void".
5729a84457aed4c45bc900998b5e11c03023264208James Dong    */
5829a84457aed4c45bc900998b5e11c03023264208James Dong    void MBInterIdct(AVCCommonObj *video, uint8 *curL, AVCMacroblock *currMB, int picPitch);
5929a84457aed4c45bc900998b5e11c03023264208James Dong
6029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
6129a84457aed4c45bc900998b5e11c03023264208James Dong    This function perform residue calculation, transform, quantize, inverse quantize,
6229a84457aed4c45bc900998b5e11c03023264208James Dong    inverse transform and residue compensation on a macroblock.
6329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
6429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curL"   "Pointer to the reconstructed MB."
6529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgL"    "Pointer to the original MB."
6629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
6729a84457aed4c45bc900998b5e11c03023264208James Dong    */
6829a84457aed4c45bc900998b5e11c03023264208James Dong    void dct_luma_16x16(AVCEncObject *encvid, uint8 *curL, uint8 *orgL);
6929a84457aed4c45bc900998b5e11c03023264208James Dong
7029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
7129a84457aed4c45bc900998b5e11c03023264208James Dong    This function perform residue calculation, transform, quantize, inverse quantize,
7229a84457aed4c45bc900998b5e11c03023264208James Dong    inverse transform and residue compensation for chroma components of an MB.
7329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
7429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curC"   "Pointer to the reconstructed MB."
7529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgC"    "Pointer to the original MB."
7629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cr"     "Flag whether it is Cr or not."
7729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
7829a84457aed4c45bc900998b5e11c03023264208James Dong    */
7929a84457aed4c45bc900998b5e11c03023264208James Dong    void dct_chroma(AVCEncObject *encvid, uint8 *curC, uint8 *orgC, int cr);
8029a84457aed4c45bc900998b5e11c03023264208James Dong
8129a84457aed4c45bc900998b5e11c03023264208James Dong    /*----------- init.c ------------------*/
8229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
8329a84457aed4c45bc900998b5e11c03023264208James Dong    This function interprets the encoding parameters provided by users in encParam.
8429a84457aed4c45bc900998b5e11c03023264208James Dong    The results are kept in AVCEncObject, AVCSeqParamSet, AVCPicParamSet and AVCSliceHeader.
8529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid"     "Pointer to AVCEncObject."
8629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encParam"   "Pointer to AVCEncParam."
8729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "extSPS"     "External SPS template to be followed. NULL if not present."
8829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "extPPS"     "External PPS template to be followed. NULL if not present."
8929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "see AVCEnc_Status."
9029a84457aed4c45bc900998b5e11c03023264208James Dong    */
9129a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status  SetEncodeParam(AVCHandle *avcHandle, AVCEncParams *encParam,
9229a84457aed4c45bc900998b5e11c03023264208James Dong                                  void *extSPS, void *extPPS);
9329a84457aed4c45bc900998b5e11c03023264208James Dong
9429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
9529a84457aed4c45bc900998b5e11c03023264208James Dong    This function verifies the encoding parameters whether they meet the set of supported
9629a84457aed4c45bc900998b5e11c03023264208James Dong    tool by a specific profile. If the profile is not set, it will just find the closest
9729a84457aed4c45bc900998b5e11c03023264208James Dong    profile instead of verifying it.
9829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCEncObject."
9929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "seqParam"   "Pointer to AVCSeqParamSet."
10029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picParam"   "Pointer to AVCPicParamSet."
10129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success,
10229a84457aed4c45bc900998b5e11c03023264208James Dong            AVCENC_PROFILE_NOT_SUPPORTED if the specified profile
10329a84457aed4c45bc900998b5e11c03023264208James Dong                is not supported by this version of the library,
10429a84457aed4c45bc900998b5e11c03023264208James Dong            AVCENC_TOOLS_NOT_SUPPORTED if any of the specified encoding tools are
10529a84457aed4c45bc900998b5e11c03023264208James Dong            not supported by the user-selected profile."
10629a84457aed4c45bc900998b5e11c03023264208James Dong    */
10729a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status VerifyProfile(AVCEncObject *video, AVCSeqParamSet *seqParam, AVCPicParamSet *picParam);
10829a84457aed4c45bc900998b5e11c03023264208James Dong
10929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
11029a84457aed4c45bc900998b5e11c03023264208James Dong    This function verifies the encoding parameters whether they meet the requirement
11129a84457aed4c45bc900998b5e11c03023264208James Dong    for a specific level. If the level is not set, it will just find the closest
11229a84457aed4c45bc900998b5e11c03023264208James Dong    level instead of verifying it.
11329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCEncObject."
11429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "seqParam"   "Pointer to AVCSeqParamSet."
11529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picParam"   "Pointer to AVCPicParamSet."
11629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success,
11729a84457aed4c45bc900998b5e11c03023264208James Dong            AVCENC_LEVEL_NOT_SUPPORTED if the specified level
11829a84457aed4c45bc900998b5e11c03023264208James Dong                is not supported by this version of the library,
11929a84457aed4c45bc900998b5e11c03023264208James Dong            AVCENC_LEVEL_FAIL if any of the encoding parameters exceed
12029a84457aed4c45bc900998b5e11c03023264208James Dong            the range of the user-selected level."
12129a84457aed4c45bc900998b5e11c03023264208James Dong    */
12229a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status VerifyLevel(AVCEncObject *video, AVCSeqParamSet *seqParam, AVCPicParamSet *picParam);
12329a84457aed4c45bc900998b5e11c03023264208James Dong
12429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
12529a84457aed4c45bc900998b5e11c03023264208James Dong    This funciton initializes the frame encoding by setting poc/frame_num related parameters. it
12629a84457aed4c45bc900998b5e11c03023264208James Dong    also performs motion estimation.
12729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the AVCEncObject."
12829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success, AVCENC_NO_PICTURE if there is no input picture
12929a84457aed4c45bc900998b5e11c03023264208James Dong            in the queue to encode, AVCENC_POC_FAIL or AVCENC_CONSECUTIVE_NONREF for POC
13029a84457aed4c45bc900998b5e11c03023264208James Dong            related errors, AVCENC_NEW_IDR if new IDR is detected."
13129a84457aed4c45bc900998b5e11c03023264208James Dong    */
13229a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status InitFrame(AVCEncObject *encvid);
13329a84457aed4c45bc900998b5e11c03023264208James Dong
13429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
13529a84457aed4c45bc900998b5e11c03023264208James Dong    This function initializes slice header related variables and other variables necessary
13629a84457aed4c45bc900998b5e11c03023264208James Dong    for decoding one slice.
13729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the AVCEncObject."
13829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success."
13929a84457aed4c45bc900998b5e11c03023264208James Dong    */
14029a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status InitSlice(AVCEncObject *encvid);
14129a84457aed4c45bc900998b5e11c03023264208James Dong
14229a84457aed4c45bc900998b5e11c03023264208James Dong    /*----------- header.c ----------------*/
14329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
14429a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs bitstream encoding of the sequence parameter set NAL.
14529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the AVCEncObject."
14629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
14729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or AVCENC_SPS_FAIL or others for unexpected failure which
14829a84457aed4c45bc900998b5e11c03023264208James Dong    should not occur. The SPS parameters should all be verified before this function is called."
14929a84457aed4c45bc900998b5e11c03023264208James Dong    */
15029a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeSPS(AVCEncObject *encvid, AVCEncBitstream *stream);
15129a84457aed4c45bc900998b5e11c03023264208James Dong
15229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
15329a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes the VUI parameters into the sequence parameter set bitstream.
15429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
15529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "vui"    "Pointer to AVCVUIParams."
15629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "nothing."
15729a84457aed4c45bc900998b5e11c03023264208James Dong    */
15829a84457aed4c45bc900998b5e11c03023264208James Dong    void EncodeVUI(AVCEncBitstream* stream, AVCVUIParams* vui);
15929a84457aed4c45bc900998b5e11c03023264208James Dong
16029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
16129a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes HRD parameters into the sequence parameter set bitstream
16229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
16329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "hrd"    "Pointer to AVCHRDParams."
16429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "nothing."
16529a84457aed4c45bc900998b5e11c03023264208James Dong    */
16629a84457aed4c45bc900998b5e11c03023264208James Dong    void EncodeHRD(AVCEncBitstream* stream, AVCHRDParams* hrd);
16729a84457aed4c45bc900998b5e11c03023264208James Dong
16829a84457aed4c45bc900998b5e11c03023264208James Dong
16929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
17029a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs bitstream encoding of the picture parameter set NAL.
17129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the AVCEncObject."
17229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
17329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or AVCENC_PPS_FAIL or others for unexpected failure which
17429a84457aed4c45bc900998b5e11c03023264208James Dong    should not occur. The SPS parameters should all be verified before this function is called."
17529a84457aed4c45bc900998b5e11c03023264208James Dong    */
17629a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodePPS(AVCEncObject *encvid, AVCEncBitstream *stream);
17729a84457aed4c45bc900998b5e11c03023264208James Dong
17829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
17929a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes slice header information which has been initialized or fabricated
18029a84457aed4c45bc900998b5e11c03023264208James Dong    prior to entering this funciton.
18129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the AVCEncObject."
18229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
18329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or bitstream fail statuses."
18429a84457aed4c45bc900998b5e11c03023264208James Dong    */
18529a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeSliceHeader(AVCEncObject *encvid, AVCEncBitstream *stream);
18629a84457aed4c45bc900998b5e11c03023264208James Dong
18729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
18829a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes reference picture list reordering relted syntax.
18929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "Pointer to AVCCommonObj."
19029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
19129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "sliceHdr" "Pointer to AVCSliceHdr."
19229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "slice_type" "Value of slice_type - 5 if greater than 5."
19329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success and AVCENC_FAIL otherwise."
19429a84457aed4c45bc900998b5e11c03023264208James Dong    */
19529a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ref_pic_list_reordering(AVCCommonObj *video, AVCEncBitstream *stream, AVCSliceHeader *sliceHdr, int slice_type);
19629a84457aed4c45bc900998b5e11c03023264208James Dong
19729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
19829a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes dec_ref_pic_marking related syntax.
19929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "Pointer to AVCCommonObj."
20029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream."
20129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "sliceHdr" "Pointer to AVCSliceHdr."
20229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success and AVCENC_FAIL otherwise."
20329a84457aed4c45bc900998b5e11c03023264208James Dong    */
20429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status dec_ref_pic_marking(AVCCommonObj *video, AVCEncBitstream *stream, AVCSliceHeader *sliceHdr);
20529a84457aed4c45bc900998b5e11c03023264208James Dong
20629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
20729a84457aed4c45bc900998b5e11c03023264208James Dong    This function initializes the POC related variables and the POC syntax to be encoded
20829a84457aed4c45bc900998b5e11c03023264208James Dong    to the slice header derived from the disp_order and is_reference flag of the original
20929a84457aed4c45bc900998b5e11c03023264208James Dong    input frame to be encoded.
21029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to the AVCEncObject."
21129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success,
21229a84457aed4c45bc900998b5e11c03023264208James Dong            AVCENC_POC_FAIL if the poc type is undefined or
21329a84457aed4c45bc900998b5e11c03023264208James Dong            AVCENC_CONSECUTIVE_NONREF if there are consecutive non-reference frame for POC type 2."
21429a84457aed4c45bc900998b5e11c03023264208James Dong    */
21529a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status InitPOC(AVCEncObject *video);
21629a84457aed4c45bc900998b5e11c03023264208James Dong
21729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
21829a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs POC related operation after a picture is decoded.
21929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "Pointer to AVCCommonObj."
22029a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS"
22129a84457aed4c45bc900998b5e11c03023264208James Dong    */
22229a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status PostPOC(AVCCommonObj *video);
22329a84457aed4c45bc900998b5e11c03023264208James Dong
22429a84457aed4c45bc900998b5e11c03023264208James Dong    /*----------- bitstream_io.c ----------------*/
22529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
22629a84457aed4c45bc900998b5e11c03023264208James Dong    This function initializes the bitstream structure with the information given by
22729a84457aed4c45bc900998b5e11c03023264208James Dong    the users.
22829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bitstream"  "Pointer to the AVCEncBitstream structure."
22929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "buffer"     "Pointer to the unsigned char buffer for output."
23029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "buf_size"   "The size of the buffer in bytes."
23129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "overrunBuffer"  "Pointer to extra overrun buffer."
23229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "oBSize"     "Size of overrun buffer in bytes."
23329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success, AVCENC_BITSTREAM_INIT_FAIL if fail"
23429a84457aed4c45bc900998b5e11c03023264208James Dong    */
23529a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status BitstreamEncInit(AVCEncBitstream *bitstream, uint8 *buffer, int buf_size,
23629a84457aed4c45bc900998b5e11c03023264208James Dong                                   uint8 *overrunBuffer, int oBSize);
23729a84457aed4c45bc900998b5e11c03023264208James Dong
23829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
23929a84457aed4c45bc900998b5e11c03023264208James Dong    This function writes the data from the cache into the bitstream buffer. It also adds the
24029a84457aed4c45bc900998b5e11c03023264208James Dong    emulation prevention code if necessary.
24129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream"     "Pointer to the AVCEncBitstream structure."
24229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
24329a84457aed4c45bc900998b5e11c03023264208James Dong    */
24429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status AVCBitstreamSaveWord(AVCEncBitstream *stream);
24529a84457aed4c45bc900998b5e11c03023264208James Dong
24629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
24729a84457aed4c45bc900998b5e11c03023264208James Dong    This function writes the codeword into the cache which will eventually be written to
24829a84457aed4c45bc900998b5e11c03023264208James Dong    the bitstream buffer.
24929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream"     "Pointer to the AVCEncBitstream structure."
25029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "nBits"      "Number of bits in the codeword."
25129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "code"       "The codeword."
25229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
25329a84457aed4c45bc900998b5e11c03023264208James Dong    */
25429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status BitstreamWriteBits(AVCEncBitstream *stream, int nBits, uint code);
25529a84457aed4c45bc900998b5e11c03023264208James Dong
25629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
25729a84457aed4c45bc900998b5e11c03023264208James Dong    This function writes one bit of data into the cache which will eventually be written
25829a84457aed4c45bc900998b5e11c03023264208James Dong    to the bitstream buffer.
25929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream"     "Pointer to the AVCEncBitstream structure."
26029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "code"       "The codeword."
26129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
26229a84457aed4c45bc900998b5e11c03023264208James Dong    */
26329a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status BitstreamWrite1Bit(AVCEncBitstream *stream, uint code);
26429a84457aed4c45bc900998b5e11c03023264208James Dong
26529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
26629a84457aed4c45bc900998b5e11c03023264208James Dong    This function adds trailing bits to the bitstream and reports back the final EBSP size.
26729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream"     "Pointer to the AVCEncBitstream structure."
26829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "nal_size"   "Output the final NAL size."
26929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success or AVCENC_BITSTREAM_BUFFER_FULL if fail."
27029a84457aed4c45bc900998b5e11c03023264208James Dong    */
27129a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status BitstreamTrailingBits(AVCEncBitstream *bitstream, uint *nal_size);
27229a84457aed4c45bc900998b5e11c03023264208James Dong
27329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
27429a84457aed4c45bc900998b5e11c03023264208James Dong    This function checks whether the current bit position is byte-aligned or not.
27529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the bitstream structure."
27629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "true if byte-aligned, false otherwise."
27729a84457aed4c45bc900998b5e11c03023264208James Dong    */
27829a84457aed4c45bc900998b5e11c03023264208James Dong    bool byte_aligned(AVCEncBitstream *stream);
27929a84457aed4c45bc900998b5e11c03023264208James Dong
28029a84457aed4c45bc900998b5e11c03023264208James Dong
28129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
28229a84457aed4c45bc900998b5e11c03023264208James Dong    This function checks the availability of overrun buffer and switches to use it when
28329a84457aed4c45bc900998b5e11c03023264208James Dong    normal bufffer is not big enough.
28429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the bitstream structure."
28529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "numExtraBytes" "Number of extra byte needed."
28629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS or AVCENC_FAIL."
28729a84457aed4c45bc900998b5e11c03023264208James Dong    */
28829a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtraBytes);
28929a84457aed4c45bc900998b5e11c03023264208James Dong
29029a84457aed4c45bc900998b5e11c03023264208James Dong
29129a84457aed4c45bc900998b5e11c03023264208James Dong    /*-------------- intra_est.c ---------------*/
29229a84457aed4c45bc900998b5e11c03023264208James Dong
29329a84457aed4c45bc900998b5e11c03023264208James Dong    /** This function performs intra/inter decision based on ABE.
29429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
29529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "min_cost"   "Best inter cost."
29629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curL"   "Pointer to the current MB origin in reconstructed frame."
29729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picPitch" "Pitch of the reconstructed frame."
29829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Boolean for intra mode."
29929a84457aed4c45bc900998b5e11c03023264208James Dong    */
30029a84457aed4c45bc900998b5e11c03023264208James Dong
30129a84457aed4c45bc900998b5e11c03023264208James Dong//bool IntraDecisionABE(AVCEncObject *encvid, int min_cost, uint8 *curL, int picPitch);
30229a84457aed4c45bc900998b5e11c03023264208James Dong    bool IntraDecision(int *min_cost, uint8 *cur, int pitch, bool ave);
30329a84457aed4c45bc900998b5e11c03023264208James Dong
30429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
30529a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs intra prediction mode search.
30629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
30729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mbnum"  "Current MB number."
30829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curL"   "Pointer to the current MB origin in reconstructed frame."
30929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picPitch" "Pitch of the reconstructed frame."
31029a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
31129a84457aed4c45bc900998b5e11c03023264208James Dong    */
31229a84457aed4c45bc900998b5e11c03023264208James Dong    void MBIntraSearch(AVCEncObject *encvid, int mbnum, uint8 *curL, int picPitch);
31329a84457aed4c45bc900998b5e11c03023264208James Dong
31429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
31529a84457aed4c45bc900998b5e11c03023264208James Dong    This function generates all the I16 prediction modes for an MB and keep it in
31629a84457aed4c45bc900998b5e11c03023264208James Dong    encvid->pred_i16.
31729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
31829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
31929a84457aed4c45bc900998b5e11c03023264208James Dong    */
32029a84457aed4c45bc900998b5e11c03023264208James Dong    void intrapred_luma_16x16(AVCEncObject *encvid);
32129a84457aed4c45bc900998b5e11c03023264208James Dong
32229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
32329a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculate the cost of all I16 modes and compare them to get the minimum.
32429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
32529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgY"   "Pointer to the original luma MB."
32629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "min_cost" "Pointer to the minimal cost so-far."
32729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
32829a84457aed4c45bc900998b5e11c03023264208James Dong    */
32929a84457aed4c45bc900998b5e11c03023264208James Dong    void find_cost_16x16(AVCEncObject *encvid, uint8 *orgY, int *min_cost);
33029a84457aed4c45bc900998b5e11c03023264208James Dong
33129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
33229a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates the cost of each I16 mode.
33329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org"    "Pointer to the original luma MB."
33429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org_pitch" "Stride size of the original frame."
33529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "pred"   "Pointer to the prediction values."
33629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "min_cost" "Minimal cost so-far."
33729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Cost"
33829a84457aed4c45bc900998b5e11c03023264208James Dong    */
33929a84457aed4c45bc900998b5e11c03023264208James Dong
34029a84457aed4c45bc900998b5e11c03023264208James Dong    int cost_i16(uint8 *org, int org_pitch, uint8 *pred, int min_cost);
34129a84457aed4c45bc900998b5e11c03023264208James Dong
34229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
34329a84457aed4c45bc900998b5e11c03023264208James Dong    This function generates all the I4 prediction modes and select the best one
34429a84457aed4c45bc900998b5e11c03023264208James Dong    for all the blocks inside a macroblock.It also calls dct_luma to generate the reconstructed
34529a84457aed4c45bc900998b5e11c03023264208James Dong    MB, and transform coefficients to be encoded.
34629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
34729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "min_cost" "Pointer to the minimal cost so-far."
34829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
34929a84457aed4c45bc900998b5e11c03023264208James Dong    */
35029a84457aed4c45bc900998b5e11c03023264208James Dong    void mb_intra4x4_search(AVCEncObject *encvid, int *min_cost);
35129a84457aed4c45bc900998b5e11c03023264208James Dong
35229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
35329a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates the most probable I4 mode of a given 4x4 block
35429a84457aed4c45bc900998b5e11c03023264208James Dong    from neighboring informationaccording to AVC/H.264 standard.
35529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCCommonObj."
35629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "blkidx" "The current block index."
35729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Most probable mode."
35829a84457aed4c45bc900998b5e11c03023264208James Dong    */
35929a84457aed4c45bc900998b5e11c03023264208James Dong    int FindMostProbableI4Mode(AVCCommonObj *video, int blkidx);
36029a84457aed4c45bc900998b5e11c03023264208James Dong
36129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
36229a84457aed4c45bc900998b5e11c03023264208James Dong    This function is where a lot of actions take place in the 4x4 block level inside
36329a84457aed4c45bc900998b5e11c03023264208James Dong    mb_intra4x4_search.
36429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
36529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "blkidx" "The current 4x4 block index."
36629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the reconstructed block."
36729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org"    "Pointer to the original block."
36829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Minimal cost, also set currMB->i4Mode"
36929a84457aed4c45bc900998b5e11c03023264208James Dong    */
37029a84457aed4c45bc900998b5e11c03023264208James Dong    int blk_intra4x4_search(AVCEncObject *encvid, int blkidx, uint8 *cur, uint8 *org);
37129a84457aed4c45bc900998b5e11c03023264208James Dong
37229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
37329a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates the cost of a given I4 prediction mode.
37429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org"    "Pointer to the original block."
37529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org_pitch"  "Stride size of the original frame."
37629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "pred"   "Pointer to the prediction block. (encvid->pred_i4)"
37729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cost"   "Pointer to the minimal cost (to be updated)."
37829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
37929a84457aed4c45bc900998b5e11c03023264208James Dong    */
38029a84457aed4c45bc900998b5e11c03023264208James Dong    void cost_i4(uint8 *org, int org_pitch, uint8 *pred, uint16 *cost);
38129a84457aed4c45bc900998b5e11c03023264208James Dong
38229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
38329a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs chroma intra search. Each mode is saved in encvid->pred_ic.
38429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
38529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
38629a84457aed4c45bc900998b5e11c03023264208James Dong    */
38729a84457aed4c45bc900998b5e11c03023264208James Dong    void chroma_intra_search(AVCEncObject *encvid);
38829a84457aed4c45bc900998b5e11c03023264208James Dong
38929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
39029a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates the cost of a chroma prediction mode.
39129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgCb"  "Pointer to the original Cb block."
39229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgCr"  "Pointer to the original Cr block."
39329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "org_pitch"  "Stride size of the original frame."
39429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "pred"   "Pointer to the prediction block (encvid->pred_ic)"
39529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mincost"    "Minimal cost so far."
39629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Cost."
39729a84457aed4c45bc900998b5e11c03023264208James Dong    */
39829a84457aed4c45bc900998b5e11c03023264208James Dong
39929a84457aed4c45bc900998b5e11c03023264208James Dong    int SATDChroma(uint8 *orgCb, uint8 *orgCr, int org_pitch, uint8 *pred, int mincost);
40029a84457aed4c45bc900998b5e11c03023264208James Dong
40129a84457aed4c45bc900998b5e11c03023264208James Dong    /*-------------- motion_comp.c ---------------*/
40229a84457aed4c45bc900998b5e11c03023264208James Dong
40329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
40429a84457aed4c45bc900998b5e11c03023264208James Dong    This is a main function to peform inter prediction.
40529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid"     "Pointer to AVCEncObject."
40629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"      "Pointer to AVCCommonObj."
40729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void".
40829a84457aed4c45bc900998b5e11c03023264208James Dong    */
40929a84457aed4c45bc900998b5e11c03023264208James Dong    void AVCMBMotionComp(AVCEncObject *encvid, AVCCommonObj *video);
41029a84457aed4c45bc900998b5e11c03023264208James Dong
41129a84457aed4c45bc900998b5e11c03023264208James Dong
41229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
41329a84457aed4c45bc900998b5e11c03023264208James Dong    This function is called for luma motion compensation.
41429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "ref"    "Pointer to the origin of a reference luma."
41529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picwidth"   "Width of the picture."
41629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picheight"  "Height of the picture."
41729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "x_pos"  "X-coordinate of the predicted block in quarter pel resolution."
41829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "y_pos"  "Y-coordinate of the predicted block in quarter pel resolution."
41929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "pred"   "Pointer to the output predicted block."
42029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "pred_pitch" "Width of pred."
42129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "blkwidth"   "Width of the current partition."
42229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "blkheight"  "Height of the current partition."
42329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
42429a84457aed4c45bc900998b5e11c03023264208James Dong    */
42529a84457aed4c45bc900998b5e11c03023264208James Dong    void eLumaMotionComp(uint8 *ref, int picwidth, int picheight,
42629a84457aed4c45bc900998b5e11c03023264208James Dong                         int x_pos, int y_pos,
42729a84457aed4c45bc900998b5e11c03023264208James Dong                         uint8 *pred, int pred_pitch,
42829a84457aed4c45bc900998b5e11c03023264208James Dong                         int blkwidth, int blkheight);
42929a84457aed4c45bc900998b5e11c03023264208James Dong
43029a84457aed4c45bc900998b5e11c03023264208James Dong    void eFullPelMC(uint8 *in, int inwidth, uint8 *out, int outpitch,
43129a84457aed4c45bc900998b5e11c03023264208James Dong                    int blkwidth, int blkheight);
43229a84457aed4c45bc900998b5e11c03023264208James Dong
43329a84457aed4c45bc900998b5e11c03023264208James Dong    void eHorzInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
43429a84457aed4c45bc900998b5e11c03023264208James Dong                        int blkwidth, int blkheight, int dx);
43529a84457aed4c45bc900998b5e11c03023264208James Dong
43629a84457aed4c45bc900998b5e11c03023264208James Dong    void eHorzInterp2MC(int *in, int inpitch, uint8 *out, int outpitch,
43729a84457aed4c45bc900998b5e11c03023264208James Dong                        int blkwidth, int blkheight, int dx);
43829a84457aed4c45bc900998b5e11c03023264208James Dong
43929a84457aed4c45bc900998b5e11c03023264208James Dong    void eHorzInterp3MC(uint8 *in, int inpitch, int *out, int outpitch,
44029a84457aed4c45bc900998b5e11c03023264208James Dong                        int blkwidth, int blkheight);
44129a84457aed4c45bc900998b5e11c03023264208James Dong
44229a84457aed4c45bc900998b5e11c03023264208James Dong    void eVertInterp1MC(uint8 *in, int inpitch, uint8 *out, int outpitch,
44329a84457aed4c45bc900998b5e11c03023264208James Dong                        int blkwidth, int blkheight, int dy);
44429a84457aed4c45bc900998b5e11c03023264208James Dong
44529a84457aed4c45bc900998b5e11c03023264208James Dong    void eVertInterp2MC(uint8 *in, int inpitch, int *out, int outpitch,
44629a84457aed4c45bc900998b5e11c03023264208James Dong                        int blkwidth, int blkheight);
44729a84457aed4c45bc900998b5e11c03023264208James Dong
44829a84457aed4c45bc900998b5e11c03023264208James Dong    void eVertInterp3MC(int *in, int inpitch, uint8 *out, int outpitch,
44929a84457aed4c45bc900998b5e11c03023264208James Dong                        int blkwidth, int blkheight, int dy);
45029a84457aed4c45bc900998b5e11c03023264208James Dong
45129a84457aed4c45bc900998b5e11c03023264208James Dong    void eDiagonalInterpMC(uint8 *in1, uint8 *in2, int inpitch,
45229a84457aed4c45bc900998b5e11c03023264208James Dong                           uint8 *out, int outpitch,
45329a84457aed4c45bc900998b5e11c03023264208James Dong                           int blkwidth, int blkheight);
45429a84457aed4c45bc900998b5e11c03023264208James Dong
45529a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaMotionComp(uint8 *ref, int picwidth, int picheight,
45629a84457aed4c45bc900998b5e11c03023264208James Dong                           int x_pos, int y_pos, uint8 *pred, int pred_pitch,
45729a84457aed4c45bc900998b5e11c03023264208James Dong                           int blkwidth, int blkheight);
45829a84457aed4c45bc900998b5e11c03023264208James Dong
45929a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaDiagonalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
46029a84457aed4c45bc900998b5e11c03023264208James Dong                                uint8 *pOut, int predPitch, int blkwidth, int blkheight);
46129a84457aed4c45bc900998b5e11c03023264208James Dong
46229a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaHorizontalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
46329a84457aed4c45bc900998b5e11c03023264208James Dong                                  uint8 *pOut, int predPitch, int blkwidth, int blkheight);
46429a84457aed4c45bc900998b5e11c03023264208James Dong
46529a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaVerticalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
46629a84457aed4c45bc900998b5e11c03023264208James Dong                                uint8 *pOut, int predPitch, int blkwidth, int blkheight);
46729a84457aed4c45bc900998b5e11c03023264208James Dong
46829a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaFullMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
46929a84457aed4c45bc900998b5e11c03023264208James Dong                            uint8 *pOut, int predPitch, int blkwidth, int blkheight);
47029a84457aed4c45bc900998b5e11c03023264208James Dong
47129a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaVerticalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
47229a84457aed4c45bc900998b5e11c03023264208James Dong                                 uint8 *pOut, int predPitch, int blkwidth, int blkheight);
47329a84457aed4c45bc900998b5e11c03023264208James Dong
47429a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaHorizontalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
47529a84457aed4c45bc900998b5e11c03023264208James Dong                                   uint8 *pOut, int predPitch, int blkwidth, int blkheight);
47629a84457aed4c45bc900998b5e11c03023264208James Dong
47729a84457aed4c45bc900998b5e11c03023264208James Dong    void eChromaDiagonalMC2_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
47829a84457aed4c45bc900998b5e11c03023264208James Dong                                 uint8 *pOut, int predPitch, int blkwidth, int blkheight);
47929a84457aed4c45bc900998b5e11c03023264208James Dong
48029a84457aed4c45bc900998b5e11c03023264208James Dong
48129a84457aed4c45bc900998b5e11c03023264208James Dong    /*-------------- motion_est.c ---------------*/
48229a84457aed4c45bc900998b5e11c03023264208James Dong
48329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
48429a84457aed4c45bc900998b5e11c03023264208James Dong    Allocate and initialize arrays necessary for motion search algorithm.
48529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "envid" "Pointer to AVCEncObject."
48629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVC_SUCCESS or AVC_MEMORY_FAIL."
48729a84457aed4c45bc900998b5e11c03023264208James Dong    */
48829a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status InitMotionSearchModule(AVCHandle *avcHandle);
48929a84457aed4c45bc900998b5e11c03023264208James Dong
49029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
49129a84457aed4c45bc900998b5e11c03023264208James Dong    Clean up memory allocated in InitMotionSearchModule.
49229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "envid" "Pointer to AVCEncObject."
49329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
49429a84457aed4c45bc900998b5e11c03023264208James Dong    */
49529a84457aed4c45bc900998b5e11c03023264208James Dong    void CleanMotionSearchModule(AVCHandle *avcHandle);
49629a84457aed4c45bc900998b5e11c03023264208James Dong
49729a84457aed4c45bc900998b5e11c03023264208James Dong
49829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
49929a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs motion estimation of all macroblocks in a frame during the InitFrame.
50029a84457aed4c45bc900998b5e11c03023264208James Dong    The goal is to find the best MB partition for inter and find out if intra search is needed for
50129a84457aed4c45bc900998b5e11c03023264208James Dong    any MBs. This intra MB tendency can be used for scene change detection.
50229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
50329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
50429a84457aed4c45bc900998b5e11c03023264208James Dong    */
50529a84457aed4c45bc900998b5e11c03023264208James Dong    void AVCMotionEstimation(AVCEncObject *encvid);
50629a84457aed4c45bc900998b5e11c03023264208James Dong
50729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
50829a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs repetitive edge padding to the reference picture by adding 16 pixels
50929a84457aed4c45bc900998b5e11c03023264208James Dong    around the luma and 8 pixels around the chromas.
51029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "refPic" "Pointer to the reference picture."
51129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
51229a84457aed4c45bc900998b5e11c03023264208James Dong    */
51329a84457aed4c45bc900998b5e11c03023264208James Dong    void  AVCPaddingEdge(AVCPictureData *refPic);
51429a84457aed4c45bc900998b5e11c03023264208James Dong
51529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
51629a84457aed4c45bc900998b5e11c03023264208James Dong    This function keeps track of intra refresh macroblock locations.
51729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the global array structure AVCEncObject."
51829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mblock" "Pointer to the array of AVCMacroblock structures."
51929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "totalMB" "Total number of MBs in a frame."
52029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "numRefresh" "Number of MB to be intra refresh in a single frame."
52129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
52229a84457aed4c45bc900998b5e11c03023264208James Dong    */
52329a84457aed4c45bc900998b5e11c03023264208James Dong    void AVCRasterIntraUpdate(AVCEncObject *encvid, AVCMacroblock *mblock, int totalMB, int numRefresh);
52429a84457aed4c45bc900998b5e11c03023264208James Dong
52529a84457aed4c45bc900998b5e11c03023264208James Dong#ifdef HTFM
52629a84457aed4c45bc900998b5e11c03023264208James Dong    void InitHTFM(VideoEncData *encvid, HTFM_Stat *htfm_stat, double *newvar, int *collect);
52729a84457aed4c45bc900998b5e11c03023264208James Dong    void UpdateHTFM(AVCEncObject *encvid, double *newvar, double *exp_lamda, HTFM_Stat *htfm_stat);
52829a84457aed4c45bc900998b5e11c03023264208James Dong    void CalcThreshold(double pf, double exp_lamda[], int nrmlz_th[]);
52929a84457aed4c45bc900998b5e11c03023264208James Dong    void    HTFMPrepareCurMB_AVC(AVCEncObject *encvid, HTFM_Stat *htfm_stat, uint8 *cur, int pitch);
53029a84457aed4c45bc900998b5e11c03023264208James Dong#endif
53129a84457aed4c45bc900998b5e11c03023264208James Dong
53229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
53329a84457aed4c45bc900998b5e11c03023264208James Dong    This function reads the input MB into a smaller faster memory space to minimize the cache miss.
53429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the global AVCEncObject."
53529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the original input macroblock."
53629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "pitch"  "Stride size of the input frame (luma)."
53729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
53829a84457aed4c45bc900998b5e11c03023264208James Dong    */
53929a84457aed4c45bc900998b5e11c03023264208James Dong    void    AVCPrepareCurMB(AVCEncObject *encvid, uint8 *cur, int pitch);
54029a84457aed4c45bc900998b5e11c03023264208James Dong
54129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
54229a84457aed4c45bc900998b5e11c03023264208James Dong    Performs motion vector search for a macroblock.
54329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject structure."
54429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the current macroblock in the input frame."
54529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "best_cand" "Array of best candidates (to be filled in and returned)."
54629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "i0"     "X-coordinate of the macroblock."
54729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "j0"     "Y-coordinate of the macroblock."
54829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "type_pred" "Indicates the type of operations."
54929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "FS_en"      "Flag for fullsearch enable."
55029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "hp_guess"   "Guess for half-pel search."
55129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
55229a84457aed4c45bc900998b5e11c03023264208James Dong    */
55329a84457aed4c45bc900998b5e11c03023264208James Dong    void AVCMBMotionSearch(AVCEncObject *encvid, uint8 *cur, uint8 *best_cand[],
55429a84457aed4c45bc900998b5e11c03023264208James Dong                           int i0, int j0, int type_pred, int FS_en, int *hp_guess);
55529a84457aed4c45bc900998b5e11c03023264208James Dong
55629a84457aed4c45bc900998b5e11c03023264208James Dong//AVCEnc_Status AVCMBMotionSearch(AVCEncObject *encvid, AVCMacroblock *currMB, int mbNum,
55729a84457aed4c45bc900998b5e11c03023264208James Dong//                           int num_pass);
55829a84457aed4c45bc900998b5e11c03023264208James Dong
55929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
56029a84457aed4c45bc900998b5e11c03023264208James Dong    Perform full-pel exhaustive search around the predicted MV.
56129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject structure."
56229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "prev"   "Pointer to the reference frame."
56329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the input macroblock."
56429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "imin"   "Pointer to minimal mv (x)."
56529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "jmin"   "Pointer to minimal mv (y)."
56629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "ilow, ihigh, jlow, jhigh"   "Lower bound on search range."
56729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cmvx, cmvy" "Predicted MV value."
56829a84457aed4c45bc900998b5e11c03023264208James Dong
56929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "The cost function of the best candidate."
57029a84457aed4c45bc900998b5e11c03023264208James Dong    */
57129a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCFullSearch(AVCEncObject *encvid, uint8 *prev, uint8 *cur,
57229a84457aed4c45bc900998b5e11c03023264208James Dong                      int *imin, int *jmin, int ilow, int ihigh, int jlow, int jhigh,
57329a84457aed4c45bc900998b5e11c03023264208James Dong                      int cmvx, int cmvy);
57429a84457aed4c45bc900998b5e11c03023264208James Dong
57529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
57629a84457aed4c45bc900998b5e11c03023264208James Dong    Select candidates from neighboring blocks according to the type of the
57729a84457aed4c45bc900998b5e11c03023264208James Dong    prediction selection.
57829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mvx"    "Pointer to the candidate, x-coordinate."
57929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mvy"    "Pointer to the candidate, y-coordinate."
58029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "num_can"    "Pointer to the number of candidates returned."
58129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "imb"    "The MB index x-coordinate."
58229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "jmb"    "The MB index y-coordinate."
58329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "type_pred"  "Type of the prediction."
58429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cmvx, cmvy" "Pointer to predicted MV (modified version)."
58529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
58629a84457aed4c45bc900998b5e11c03023264208James Dong    */
58729a84457aed4c45bc900998b5e11c03023264208James Dong    void AVCCandidateSelection(int *mvx, int *mvy, int *num_can, int imb, int jmb,
58829a84457aed4c45bc900998b5e11c03023264208James Dong                               AVCEncObject *encvid, int type_pred, int *cmvx, int *cmvy);
58929a84457aed4c45bc900998b5e11c03023264208James Dong
59029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
59129a84457aed4c45bc900998b5e11c03023264208James Dong    Utility function to move the values in the array dn according to the new
59229a84457aed4c45bc900998b5e11c03023264208James Dong    location to avoid redundant calculation.
59329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "dn" "Array of integer of size 9."
59429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "new_loc"    "New location index."
59529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
59629a84457aed4c45bc900998b5e11c03023264208James Dong    */
59729a84457aed4c45bc900998b5e11c03023264208James Dong    void AVCMoveNeighborSAD(int dn[], int new_loc);
59829a84457aed4c45bc900998b5e11c03023264208James Dong
59929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
60029a84457aed4c45bc900998b5e11c03023264208James Dong    Find minimum index of dn.
60129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "dn" "Array of integer of size 9."
60229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "The index of dn with the smallest dn[] value."
60329a84457aed4c45bc900998b5e11c03023264208James Dong    */
60429a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCFindMin(int dn[]);
60529a84457aed4c45bc900998b5e11c03023264208James Dong
60629a84457aed4c45bc900998b5e11c03023264208James Dong
60729a84457aed4c45bc900998b5e11c03023264208James Dong    /*------------- findhalfpel.c -------------------*/
60829a84457aed4c45bc900998b5e11c03023264208James Dong
60929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
61029a84457aed4c45bc900998b5e11c03023264208James Dong    Search for the best half-pel resolution MV around the full-pel MV.
61129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the global AVCEncObject structure."
61229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the current macroblock."
61329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mot"    "Pointer to the AVCMV array of the frame."
61429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "ncand"  "Pointer to the origin of the fullsearch result."
61529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "xpos"   "The current MB position in x."
61629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "ypos"   "The current MB position in y."
61729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "hp_guess"   "Input to help speedup the search."
61829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cmvx, cmvy" "Predicted motion vector use for mvcost."
61929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Minimal cost (SATD) without MV cost. (for rate control purpose)"
62029a84457aed4c45bc900998b5e11c03023264208James Dong    */
62129a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
62229a84457aed4c45bc900998b5e11c03023264208James Dong                         int xpos, int ypos, int hp_guess, int cmvx, int cmvy);
62329a84457aed4c45bc900998b5e11c03023264208James Dong
62429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
62529a84457aed4c45bc900998b5e11c03023264208James Dong    This function generates sub-pel pixels required to do subpel MV search.
62629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "subpel_pred" "Pointer to 2-D array, each array for each position."
62729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "ncand" "Pointer to the full-pel center position in ref frame."
62829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "lx" "Pitch of the ref frame."
62929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
63029a84457aed4c45bc900998b5e11c03023264208James Dong     */
63129a84457aed4c45bc900998b5e11c03023264208James Dong    void GenerateHalfPelPred(uint8 *subpel_pred, uint8 *ncand, int lx);
63229a84457aed4c45bc900998b5e11c03023264208James Dong
63329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
63429a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculate vertical interpolation at half-point of size 4x17.
63529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "dst" "Pointer to destination."
63629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "ref" "Pointer to the starting reference pixel."
63729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
63829a84457aed4c45bc900998b5e11c03023264208James Dong    */
63929a84457aed4c45bc900998b5e11c03023264208James Dong    void VertInterpWClip(uint8 *dst, uint8 *ref);
64029a84457aed4c45bc900998b5e11c03023264208James Dong
64129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
64229a84457aed4c45bc900998b5e11c03023264208James Dong    This function generates quarter-pel pixels around the best half-pel result
64329a84457aed4c45bc900998b5e11c03023264208James Dong    during the sub-pel MV search.
64429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bilin_base"  "Array of pointers to be used as basis for q-pel interp."
64529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "qpel_pred"  "Array of pointers pointing to quarter-pel candidates."
64629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "hpel_pos" "Best half-pel position at the center."
64729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
64829a84457aed4c45bc900998b5e11c03023264208James Dong    */
64929a84457aed4c45bc900998b5e11c03023264208James Dong    void GenerateQuartPelPred(uint8 **bilin_base, uint8 *qpel_pred, int hpel_pos);
65029a84457aed4c45bc900998b5e11c03023264208James Dong
65129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
65229a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates the SATD of a subpel candidate.
65329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cand"   "Pointer to a candidate."
65429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "cur"    "Pointer to the current block."
65529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "dmin"   "Min-so-far SATD."
65629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Sum of Absolute Transformed Difference."
65729a84457aed4c45bc900998b5e11c03023264208James Dong    */
65829a84457aed4c45bc900998b5e11c03023264208James Dong    int SATD_MB(uint8 *cand, uint8 *cur, int dmin);
65929a84457aed4c45bc900998b5e11c03023264208James Dong
66029a84457aed4c45bc900998b5e11c03023264208James Dong    /*------------- rate_control.c -------------------*/
66129a84457aed4c45bc900998b5e11c03023264208James Dong
66229a84457aed4c45bc900998b5e11c03023264208James Dong    /** This function is a utility function. It returns average QP of the previously encoded frame.
66329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "rateCtrl" "Pointer to AVCRateControl structure."
66429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "Average QP."
66529a84457aed4c45bc900998b5e11c03023264208James Dong    */
66629a84457aed4c45bc900998b5e11c03023264208James Dong    int GetAvgFrameQP(AVCRateControl *rateCtrl);
66729a84457aed4c45bc900998b5e11c03023264208James Dong
66829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
66929a84457aed4c45bc900998b5e11c03023264208James Dong    This function takes the timestamp of the input and determine whether it should be encoded
67029a84457aed4c45bc900998b5e11c03023264208James Dong    or skipped.
67129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the AVCEncObject structure."
67229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "rateCtrl"   "Pointer to the AVCRateControl structure."
67329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "modTime"    "The 32 bit timestamp of the input frame."
67429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "frameNum"   "Pointer to the frame number if to be encoded."
67529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVC_SUCCESS or else."
67629a84457aed4c45bc900998b5e11c03023264208James Dong    */
67729a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status RCDetermineFrameNum(AVCEncObject *encvid, AVCRateControl *rateCtrl, uint32 modTime, uint *frameNum);
67829a84457aed4c45bc900998b5e11c03023264208James Dong
67929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
68029a84457aed4c45bc900998b5e11c03023264208James Dong    This function updates the buffer fullness when frames are dropped either by the
68129a84457aed4c45bc900998b5e11c03023264208James Dong    rate control algorithm or by the users to make sure that target bit rate is still met.
68229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "Pointer to the common object structure."
68329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "rateCtrl" "Pointer to rate control structure."
68429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "frameInc" "Difference of the current frame number and previous frame number."
68529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
68629a84457aed4c45bc900998b5e11c03023264208James Dong    */
68729a84457aed4c45bc900998b5e11c03023264208James Dong    void RCUpdateBuffer(AVCCommonObj *video, AVCRateControl *rateCtrl, int frameInc);
68829a84457aed4c45bc900998b5e11c03023264208James Dong
68929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
69029a84457aed4c45bc900998b5e11c03023264208James Dong    This function initializes rate control module and allocates necessary bufferes to do the job.
69129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "avcHandle" "Pointer to the encoder handle."
69229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS or AVCENC_MEMORY_FAIL."
69329a84457aed4c45bc900998b5e11c03023264208James Dong    */
69429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status InitRateControlModule(AVCHandle *avcHandle);
69529a84457aed4c45bc900998b5e11c03023264208James Dong
69629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
69729a84457aed4c45bc900998b5e11c03023264208James Dong    This function frees buffers allocated in InitRateControlModule.
69829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "avcHandle" "Pointer to the encoder handle."
69929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
70029a84457aed4c45bc900998b5e11c03023264208James Dong    */
70129a84457aed4c45bc900998b5e11c03023264208James Dong    void CleanupRateControlModule(AVCHandle *avcHandle);
70229a84457aed4c45bc900998b5e11c03023264208James Dong
70329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
70429a84457aed4c45bc900998b5e11c03023264208James Dong    This function is called at the beginning of each GOP or the first IDR frame. It calculates
70529a84457aed4c45bc900998b5e11c03023264208James Dong    target bits for a GOP.
70629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the encoder object."
70729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
70829a84457aed4c45bc900998b5e11c03023264208James Dong    */
70929a84457aed4c45bc900998b5e11c03023264208James Dong    void RCInitGOP(AVCEncObject *encvid);
71029a84457aed4c45bc900998b5e11c03023264208James Dong
71129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
71229a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates target bits for a particular frame.
71329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to the AVCEncObject structure."
71429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
71529a84457aed4c45bc900998b5e11c03023264208James Dong    */
71629a84457aed4c45bc900998b5e11c03023264208James Dong    void RCInitFrameQP(AVCEncObject *video);
71729a84457aed4c45bc900998b5e11c03023264208James Dong
71829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
71929a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates QP for the upcoming frame or basic unit.
72029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the encoder object."
72129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "rateCtrl" "Pointer to the rate control object."
72229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "QP value ranging from 0-51."
72329a84457aed4c45bc900998b5e11c03023264208James Dong    */
72429a84457aed4c45bc900998b5e11c03023264208James Dong    int  RCCalculateQP(AVCEncObject *encvid, AVCRateControl *rateCtrl);
72529a84457aed4c45bc900998b5e11c03023264208James Dong
72629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
72729a84457aed4c45bc900998b5e11c03023264208James Dong    This function translates the luma QP to chroma QP and calculates lambda based on QP.
72829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to the AVCEncObject structure."
72929a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
73029a84457aed4c45bc900998b5e11c03023264208James Dong    */
73129a84457aed4c45bc900998b5e11c03023264208James Dong    void RCInitChromaQP(AVCEncObject *encvid);
73229a84457aed4c45bc900998b5e11c03023264208James Dong
73329a84457aed4c45bc900998b5e11c03023264208James Dong    /**
73429a84457aed4c45bc900998b5e11c03023264208James Dong    This function is called before encoding each macroblock.
73529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the encoder object."
73629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
73729a84457aed4c45bc900998b5e11c03023264208James Dong    */
73829a84457aed4c45bc900998b5e11c03023264208James Dong    void RCInitMBQP(AVCEncObject *encvid);
73929a84457aed4c45bc900998b5e11c03023264208James Dong
74029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
74129a84457aed4c45bc900998b5e11c03023264208James Dong    This function updates bits usage stats after encoding an macroblock.
74229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "Pointer to AVCCommonObj."
74329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "rateCtrl" "Pointer to AVCRateControl."
74429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "num_header_bits" "Number of bits used for MB header."
74529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "num_texture_bits" "Number of bits used for MB texture."
74629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
74729a84457aed4c45bc900998b5e11c03023264208James Dong    */
74829a84457aed4c45bc900998b5e11c03023264208James Dong    void RCPostMB(AVCCommonObj *video, AVCRateControl *rateCtrl, int num_header_bits, int num_texture_bits);
74929a84457aed4c45bc900998b5e11c03023264208James Dong
75029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
75129a84457aed4c45bc900998b5e11c03023264208James Dong    This function calculates the difference between prediction and original MB.
75229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the encoder object."
75329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock structure."
75429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgL" "Pointer to the original MB."
75529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "orgPitch" "Pointer to the original picture pitch."
75629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void."
75729a84457aed4c45bc900998b5e11c03023264208James Dong    */
75829a84457aed4c45bc900998b5e11c03023264208James Dong    void RCCalculateMAD(AVCEncObject *encvid, AVCMacroblock *currMB, uint8 *orgL, int orgPitch);
75929a84457aed4c45bc900998b5e11c03023264208James Dong
76029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
76129a84457aed4c45bc900998b5e11c03023264208James Dong    Restore QP related parameters of previous MB when current MB is skipped.
76229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock."
76329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to the common video structure."
76429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the global encoding structure."
76529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
76629a84457aed4c45bc900998b5e11c03023264208James Dong    */
76729a84457aed4c45bc900998b5e11c03023264208James Dong    void RCRestoreQP(AVCMacroblock *currMB, AVCCommonObj *video, AVCEncObject *encvid);
76829a84457aed4c45bc900998b5e11c03023264208James Dong
76929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
77029a84457aed4c45bc900998b5e11c03023264208James Dong    This function is called after done with a frame.
77129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to the encoder object."
77229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS or AVCENC_SKIPPED_PICTURE when bufer overflow (need to discard current frame)."
77329a84457aed4c45bc900998b5e11c03023264208James Dong    */
77429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status RCUpdateFrame(AVCEncObject *encvid);
77529a84457aed4c45bc900998b5e11c03023264208James Dong
77629a84457aed4c45bc900998b5e11c03023264208James Dong    /*--------- residual.c -------------------*/
77729a84457aed4c45bc900998b5e11c03023264208James Dong
77829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
77929a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes the intra pcm data and fill it in the corresponding location
78029a84457aed4c45bc900998b5e11c03023264208James Dong    on the current picture.
78129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCEncObject."
78229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS if success, or else for bitstream errors."
78329a84457aed4c45bc900998b5e11c03023264208James Dong    */
78429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeIntraPCM(AVCEncObject *video);
78529a84457aed4c45bc900998b5e11c03023264208James Dong
78629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
78729a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs CAVLC syntax encoding on the run and level information of the coefficients.
78829a84457aed4c45bc900998b5e11c03023264208James Dong    The level and run arrays are elements in AVCEncObject structure, populated by TransQuantZZ,
78929a84457aed4c45bc900998b5e11c03023264208James Dong    TransQuantIntraDC and TransQuantChromaDC functions.
79029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCEncObject."
79129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "type"   "One of AVCResidualType for a particular 4x4 block."
79229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bindx"  "Block index or number of nonzero coefficients for AVC_Intra16DC and AVC_ChromaDC mode."
79329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock structure."
79429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success."
79529a84457aed4c45bc900998b5e11c03023264208James Dong    \Note   "This function has 32-bit machine specific instruction!!!!"
79629a84457aed4c45bc900998b5e11c03023264208James Dong    */
79729a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status enc_residual_block(AVCEncObject *encvid, AVCResidualType type, int bindx, AVCMacroblock *currMB);
79829a84457aed4c45bc900998b5e11c03023264208James Dong
79929a84457aed4c45bc900998b5e11c03023264208James Dong
80029a84457aed4c45bc900998b5e11c03023264208James Dong    /*------------- sad.c ---------------------------*/
80129a84457aed4c45bc900998b5e11c03023264208James Dong
80229a84457aed4c45bc900998b5e11c03023264208James Dong
80329a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HalfPel_Cxhyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
80429a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HalfPel_Cyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
80529a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HalfPel_Cxh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
80629a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_Macroblock_C(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
80729a84457aed4c45bc900998b5e11c03023264208James Dong
80829a84457aed4c45bc900998b5e11c03023264208James Dong#ifdef HTFM /*  3/2/1, Hypothesis Testing Fast Matching */
80929a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HP_HTFM_Collectxhyh(uint8 *ref, uint8 *blk, int dmin_x, void *extra_info);
81029a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HP_HTFM_Collectyh(uint8 *ref, uint8 *blk, int dmin_x, void *extra_info);
81129a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HP_HTFM_Collectxh(uint8 *ref, uint8 *blk, int dmin_x, void *extra_info);
81229a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HP_HTFMxhyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
81329a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HP_HTFMyh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
81429a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HP_HTFMxh(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
81529a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HTFM_Collect(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
81629a84457aed4c45bc900998b5e11c03023264208James Dong    int AVCSAD_MB_HTFM(uint8 *ref, uint8 *blk, int dmin_lx, void *extra_info);
81729a84457aed4c45bc900998b5e11c03023264208James Dong#endif
81829a84457aed4c45bc900998b5e11c03023264208James Dong
81929a84457aed4c45bc900998b5e11c03023264208James Dong
82029a84457aed4c45bc900998b5e11c03023264208James Dong    /*------------- slice.c -------------------------*/
82129a84457aed4c45bc900998b5e11c03023264208James Dong
82229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
82329a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs the main encoding loop for a slice.
82429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "Pointer to AVCEncObject."
82529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success, AVCENC_PICTURE_READY for end-of-picture and
82629a84457aed4c45bc900998b5e11c03023264208James Dong             AVCENC_FAIL or AVCENC_SLICE_EMPTY otherwise."
82729a84457aed4c45bc900998b5e11c03023264208James Dong    */
82829a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status AVCEncodeSlice(AVCEncObject *encvid);
82929a84457aed4c45bc900998b5e11c03023264208James Dong
83029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
83129a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs the main encoding operation for one macroblock.
83229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "pointer to AVCEncObject."
83329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success, or other bitstream related failure status."
83429a84457aed4c45bc900998b5e11c03023264208James Dong    */
83529a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeMB(AVCEncObject *video);
83629a84457aed4c45bc900998b5e11c03023264208James Dong
83729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
83829a84457aed4c45bc900998b5e11c03023264208James Dong    This function calls prediction INTRA/INTER functions, transform,
83929a84457aed4c45bc900998b5e11c03023264208James Dong    quantization and zigzag scanning to get the run-level symbols.
84029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "encvid" "pointer to AVCEncObject."
84129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curL"   "pointer to Luma component of the current frame.
84229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curCb"  "pointer to Cb component of the current frame.
84329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curCr"  "pointer to Cr component of the current frame.
84429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void for now."
84529a84457aed4c45bc900998b5e11c03023264208James Dong     */
84629a84457aed4c45bc900998b5e11c03023264208James Dong    void MBPredTransQuantZZ(AVCEncObject *encvid, uint8 *curL, uint8 *curCb, uint8 *curCr);
84729a84457aed4c45bc900998b5e11c03023264208James Dong
84829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
84929a84457aed4c45bc900998b5e11c03023264208James Dong    This function copies the content of the prediction MB into the reconstructed YUV
85029a84457aed4c45bc900998b5e11c03023264208James Dong    frame directly.
85129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curL"   "Pointer to the destination Y component."
85229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curCb"  "Pointer to the destination Cb component."
85329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "curCr"  "Pointer to the destination Cr component."
85429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "predBlock"  "Pointer to the prediction MB."
85529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "picWidth"   "The width of the frame."
85629a84457aed4c45bc900998b5e11c03023264208James Dong    \return "None."
85729a84457aed4c45bc900998b5e11c03023264208James Dong    */
85829a84457aed4c45bc900998b5e11c03023264208James Dong    void Copy_MB(uint8 *curL, uint8 *curCb, uint8 *curCr, uint8 *predBlock, int picWidth);
85929a84457aed4c45bc900998b5e11c03023264208James Dong
86029a84457aed4c45bc900998b5e11c03023264208James Dong    /**
86129a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes the mb_type, CBP, prediction mode, ref idx and MV.
86229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock structure."
86329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video" "Pointer to the AVCEncObject structure."
86429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or else for fail."
86529a84457aed4c45bc900998b5e11c03023264208James Dong    */
86629a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeMBHeader(AVCMacroblock *currMB, AVCEncObject *video);
86729a84457aed4c45bc900998b5e11c03023264208James Dong
86829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
86929a84457aed4c45bc900998b5e11c03023264208James Dong    This function finds the right mb_type for a macroblock given the mbMode, CBP,
87029a84457aed4c45bc900998b5e11c03023264208James Dong    NumPart, PredPartMode.
87129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock structure."
87229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "slice_type" "Value of the slice_type."
87329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "mb_type."
87429a84457aed4c45bc900998b5e11c03023264208James Dong    */
87529a84457aed4c45bc900998b5e11c03023264208James Dong    uint InterpretMBType(AVCMacroblock *currMB, int slice_type);
87629a84457aed4c45bc900998b5e11c03023264208James Dong
87729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
87829a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes the mb_pred part of the macroblock data.
87929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to the AVCCommonObj structure."
88029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock structure."
88129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream structure."
88229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or bitstream fail status."
88329a84457aed4c45bc900998b5e11c03023264208James Dong    */
88429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream);
88529a84457aed4c45bc900998b5e11c03023264208James Dong
88629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
88729a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes the sub_mb_pred part of the macroblock data.
88829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to the AVCCommonObj structure."
88929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the current macroblock structure."
89029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream structure."
89129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or bitstream fail status."
89229a84457aed4c45bc900998b5e11c03023264208James Dong    */
89329a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status sub_mb_pred(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream);
89429a84457aed4c45bc900998b5e11c03023264208James Dong
89529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
89629a84457aed4c45bc900998b5e11c03023264208James Dong    This function interprets the sub_mb_type and sets necessary information
89729a84457aed4c45bc900998b5e11c03023264208James Dong    when the slice type is AVC_P_SLICE.
89829a84457aed4c45bc900998b5e11c03023264208James Dong    in the macroblock structure.
89929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mblock" "Pointer to current AVCMacroblock."
90029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "sub_mb_type" "From the syntax bitstream."
90129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
90229a84457aed4c45bc900998b5e11c03023264208James Dong    */
90329a84457aed4c45bc900998b5e11c03023264208James Dong    void InterpretSubMBTypeP(AVCMacroblock *mblock, uint *sub_mb_type);
90429a84457aed4c45bc900998b5e11c03023264208James Dong
90529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
90629a84457aed4c45bc900998b5e11c03023264208James Dong    This function interprets the sub_mb_type and sets necessary information
90729a84457aed4c45bc900998b5e11c03023264208James Dong    when the slice type is AVC_B_SLICE.
90829a84457aed4c45bc900998b5e11c03023264208James Dong    in the macroblock structure.
90929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "mblock" "Pointer to current AVCMacroblock."
91029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "sub_mb_type" "From the syntax bitstream."
91129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
91229a84457aed4c45bc900998b5e11c03023264208James Dong    */
91329a84457aed4c45bc900998b5e11c03023264208James Dong    void InterpretSubMBTypeB(AVCMacroblock *mblock, uint *sub_mb_type);
91429a84457aed4c45bc900998b5e11c03023264208James Dong
91529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
91629a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes intra 4x4 mode. It calculates the predicted I4x4 mode and the
91729a84457aed4c45bc900998b5e11c03023264208James Dong    remnant to be encoded.
91829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "video"  "Pointer to AVCEncObject structure."
91929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB" "Pointer to the AVCMacroblock structure."
92029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to AVCEncBitstream sructure."
92129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success."
92229a84457aed4c45bc900998b5e11c03023264208James Dong    */
92329a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeIntra4x4Mode(AVCCommonObj *video, AVCMacroblock *currMB, AVCEncBitstream *stream);
92429a84457aed4c45bc900998b5e11c03023264208James Dong
92529a84457aed4c45bc900998b5e11c03023264208James Dong    /*------------- vlc_encode.c -----------------------*/
92629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
92729a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes and writes a value into an Exp-Golomb codeword.
92829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bitstream" "Pointer to AVCEncBitstream."
92929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "codeNum" "Pointer to the value of the codeNum."
93029a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or bitstream error messages for fail."
93129a84457aed4c45bc900998b5e11c03023264208James Dong    */
93229a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ue_v(AVCEncBitstream *bitstream, uint codeNum);
93329a84457aed4c45bc900998b5e11c03023264208James Dong
93429a84457aed4c45bc900998b5e11c03023264208James Dong    /**
93529a84457aed4c45bc900998b5e11c03023264208James Dong    This function maps and encodes signed Exp-Golomb codes.
93629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bitstream" "Pointer to AVCEncBitstream."
93729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "value"  "Pointer to syntax element value."
93829a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS or AVCENC_FAIL."
93929a84457aed4c45bc900998b5e11c03023264208James Dong    */
94029a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status  se_v(AVCEncBitstream *bitstream, int value);
94129a84457aed4c45bc900998b5e11c03023264208James Dong
94229a84457aed4c45bc900998b5e11c03023264208James Dong    /**
94329a84457aed4c45bc900998b5e11c03023264208James Dong    This function maps and encodes truncated Exp-Golomb codes.
94429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bitstream" "Pointer to AVCEncBitstream."
94529a84457aed4c45bc900998b5e11c03023264208James Dong    \param "value"  "Pointer to syntax element value."
94629a84457aed4c45bc900998b5e11c03023264208James Dong    \param "range"  "Range of the value as input to determine the algorithm."
94729a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS or AVCENC_FAIL."
94829a84457aed4c45bc900998b5e11c03023264208James Dong    */
94929a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status te_v(AVCEncBitstream *bitstream, uint value, uint range);
95029a84457aed4c45bc900998b5e11c03023264208James Dong
95129a84457aed4c45bc900998b5e11c03023264208James Dong    /**
95229a84457aed4c45bc900998b5e11c03023264208James Dong    This function creates Exp-Golomb codeword from codeNum.
95329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "bitstream" "Pointer to AVCEncBitstream."
95429a84457aed4c45bc900998b5e11c03023264208James Dong    \param "codeNum" "Pointer to the codeNum value."
95529a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or bitstream error messages for fail."
95629a84457aed4c45bc900998b5e11c03023264208James Dong    */
95729a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status SetEGBitstring(AVCEncBitstream *bitstream, uint codeNum);
95829a84457aed4c45bc900998b5e11c03023264208James Dong
95929a84457aed4c45bc900998b5e11c03023264208James Dong    /**
96029a84457aed4c45bc900998b5e11c03023264208James Dong    This function performs CAVLC encoding of the CBP (coded block pattern) of a macroblock
96129a84457aed4c45bc900998b5e11c03023264208James Dong    by calling ue_v() and then mapping the CBP to the corresponding VLC codeNum.
96229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "currMB"  "Pointer to the current AVCMacroblock structure."
96329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream"  "Pointer to the AVCEncBitstream."
96429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "void"
96529a84457aed4c45bc900998b5e11c03023264208James Dong    */
96629a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status EncodeCBP(AVCMacroblock *currMB, AVCEncBitstream *stream);
96729a84457aed4c45bc900998b5e11c03023264208James Dong
96829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
96929a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes trailing ones and total coefficient.
97029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream."
97129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TrailingOnes"   "The trailing one variable output."
97229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TotalCoeff" "The total coefficient variable output."
97329a84457aed4c45bc900998b5e11c03023264208James Dong    \param "nC" "Context for number of nonzero coefficient (prediction context)."
97429a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or else for bitstream failure."
97529a84457aed4c45bc900998b5e11c03023264208James Dong    */
97629a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ce_TotalCoeffTrailingOnes(AVCEncBitstream *stream, int TrailingOnes, int TotalCoeff, int nC);
97729a84457aed4c45bc900998b5e11c03023264208James Dong
97829a84457aed4c45bc900998b5e11c03023264208James Dong    /**
97929a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes trailing ones and total coefficient for chroma DC block.
98029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream."
98129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TrailingOnes"   "The trailing one variable output."
98229a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TotalCoeff" "The total coefficient variable output."
98329a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or else for bitstream failure."
98429a84457aed4c45bc900998b5e11c03023264208James Dong    */
98529a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ce_TotalCoeffTrailingOnesChromaDC(AVCEncBitstream *stream, int TrailingOnes, int TotalCoeff);
98629a84457aed4c45bc900998b5e11c03023264208James Dong
98729a84457aed4c45bc900998b5e11c03023264208James Dong    /**
98829a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes total_zeros value as in Table 9-7 and 9-8.
98929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream."
99029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TotalZeros" "The total_zeros value."
99129a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TotalCoeff" "The total coefficient variable output."
99229a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or else for bitstream failure."
99329a84457aed4c45bc900998b5e11c03023264208James Dong    */
99429a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ce_TotalZeros(AVCEncBitstream *stream, int total_zeros, int TotalCoeff);
99529a84457aed4c45bc900998b5e11c03023264208James Dong
99629a84457aed4c45bc900998b5e11c03023264208James Dong    /**
99729a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes total_zeros VLC syntax for chroma DC as in Table 9-9.
99829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream."
99929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TotalZeros" "The total_zeros value."
100029a84457aed4c45bc900998b5e11c03023264208James Dong    \param "TotalCoeff" "The total coefficient variable output."
100129a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or else for bitstream failure."
100229a84457aed4c45bc900998b5e11c03023264208James Dong    */
100329a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ce_TotalZerosChromaDC(AVCEncBitstream *stream, int total_zeros, int TotalCoeff);
100429a84457aed4c45bc900998b5e11c03023264208James Dong
100529a84457aed4c45bc900998b5e11c03023264208James Dong    /**
100629a84457aed4c45bc900998b5e11c03023264208James Dong    This function encodes run_before VLC syntax as in Table 9-10.
100729a84457aed4c45bc900998b5e11c03023264208James Dong    \param "stream" "Pointer to the AVCEncBitstream."
100829a84457aed4c45bc900998b5e11c03023264208James Dong    \param "run_before" "The run_before value."
100929a84457aed4c45bc900998b5e11c03023264208James Dong    \param "zerosLeft"  "The context for number of zeros left."
101029a84457aed4c45bc900998b5e11c03023264208James Dong    \return "AVCENC_SUCCESS for success or else for bitstream failure."
101129a84457aed4c45bc900998b5e11c03023264208James Dong    */
101229a84457aed4c45bc900998b5e11c03023264208James Dong    AVCEnc_Status ce_RunBefore(AVCEncBitstream *stream, int run_before, int zerosLeft);
101329a84457aed4c45bc900998b5e11c03023264208James Dong
101429a84457aed4c45bc900998b5e11c03023264208James Dong#ifdef __cplusplus
101529a84457aed4c45bc900998b5e11c03023264208James Dong}
101629a84457aed4c45bc900998b5e11c03023264208James Dong#endif
101729a84457aed4c45bc900998b5e11c03023264208James Dong
101829a84457aed4c45bc900998b5e11c03023264208James Dong
101929a84457aed4c45bc900998b5e11c03023264208James Dong#endif /* _AVCENC_LIB_H_ */
102029a84457aed4c45bc900998b5e11c03023264208James Dong
1021