159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* ------------------------------------------------------------------
259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * Copyright (C) 1998-2009 PacketVideo
359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *
459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * Licensed under the Apache License, Version 2.0 (the "License");
559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * you may not use this file except in compliance with the License.
659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * You may obtain a copy of the License at
759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *
859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *      http://www.apache.org/licenses/LICENSE-2.0
959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong *
1059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * Unless required by applicable law or agreed to in writing, software
1159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * distributed under the License is distributed on an "AS IS" BASIS,
1259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * express or implied.
1459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * See the License for the specific language governing permissions
1559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * and limitations under the License.
1659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong * -------------------------------------------------------------------
1759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong */
1859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
1959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#ifndef _MP4LIB_INT_H_
2059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#define _MP4LIB_INT_H_
2159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
2259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#include "mp4def.h"
2359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#include "mp4enc_api.h"
2459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#include "rate_control.h"
2559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
2659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* BitstreamEncVideo will be modified */
2759f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagBitstream
2859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
2959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int(*writeVideoPacket)(UChar *buf, Int nbytes_required);   /*write video packet out */
3059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar *bitstreamBuffer; /*buffer to hold one video packet*/
3159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int bufferSize; /*total bitstream buffer size in bytes */
3259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int byteCount;  /*how many bytes already encoded*/
3359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt word;      /*hold one word temporarily */
3459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int bitLeft;    /*number of bits left in "word" */
3559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar* overrunBuffer;  /* pointer to overrun buffer */
3659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int oBSize;     /* length of overrun buffer */
3759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    struct tagVideoEncData *video;
3859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} BitstreamEncVideo;
3959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
4059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagVOP
4159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
4259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PIXEL   *yChan;             /* The Y component */
4359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PIXEL   *uChan;             /* The U component */
4459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    PIXEL   *vChan;             /* The V component */
4559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     frame;              /* frame number */
4659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     volID;              /* Layer number */
4759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    //Int       timeStamp;          /* Vop TimeStamp in msec */
4859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
4959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Syntax elements copied from VOL (standard) */
5059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     width;              /* Width (multiple of 16) */
5159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     height;             /* Height (multiple of 16) */
5259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     pitch;              /* Pitch (differs from width for UMV case) */
5359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     padded;     /* flag whether this frame has been padded */
5459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
5559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Actual syntax elements for VOP (standard) */
5659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     predictionType;     /* VOP prediction type */
5759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     timeInc;            /* VOP time increment (relative to last mtb) */
5859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     vopCoded;
5959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     roundingType;
6059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     intraDCVlcThr;
6159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     quantizer;          /* VOP quantizer */
6259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     fcodeForward;       /* VOP dynamic range of motion vectors */
6359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     fcodeBackward;      /* VOP dynamic range of motion vectors */
6459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     refSelectCode;      /* enhancement layer reference select code */
6559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
6659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* H.263 parameters */
6759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     gobNumber;
6859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     gobFrameID;
6959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     temporalRef;        /* temporal reference, roll over at 256 */
7059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     temporalInterval;   /* increase every 256 temporalRef */
7159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
7259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} Vop;
7359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
7459f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagVol
7559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
7659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     volID;              /* VOL identifier (for tracking) */
7759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     shortVideoHeader;   /* shortVideoHeader mode */
7859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     GOVStart;           /* Insert GOV Header */
7959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     timeIncrementResolution;    /* VOL time increment */
8059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nbitsTimeIncRes;    /* number of bits for time increment */
8159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     timeIncrement;      /* time increment */
8259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     moduloTimeBase;     /* internal decoder clock */
8359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     prevModuloTimeBase; /* in case of pre-frameskip */
8459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
8559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     fixedVopRate;
8659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    BitstreamEncVideo  *stream; /* library bitstream buffer (input buffer) */
8759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
8859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* VOL Dimensions */
8959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     width;              /* Width */
9059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     height;             /* Height */
9159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
9259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Error Resilience Flags */
9359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     ResyncMarkerDisable; /* VOL Disable Resynch Markers */
9459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     useReverseVLC;      /* VOL reversible VLCs */
9559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     dataPartitioning;   /* VOL data partitioning */
9659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
9759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Quantization related parameters */
9859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     quantPrecision;     /* Quantizer precision */
9959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     quantType;          /* MPEG-4 or H.263 Quantization Type */
10059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
10159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Added loaded quant mat, 05/22/2000 */
10259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     loadIntraQuantMat;      /* Load intra quantization matrix */
10359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     loadNonIntraQuantMat;   /* Load nonintra quantization matrix */
10459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     iqmat[64];          /* Intra quant.matrix */
10559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     niqmat[64];         /* Non-intra quant.matrix */
10659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
10759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
10859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Parameters used for scalability */
10959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     scalability;        /* VOL scalability (flag) */
11059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     scalType;           /* temporal = 0, spatial = 1, both = 2 */
11159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
11259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     refVolID;           /* VOL id of reference VOL */
11359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     refSampDir;         /* VOL resol. of ref. VOL */
11459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     horSamp_n;          /* VOL hor. resampling of ref. VOL given by */
11559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     horSamp_m;          /* sampfac = hor_samp_n/hor_samp_m      */
11659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     verSamp_n;          /* VOL ver. resampling of ref. VOL given by */
11759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     verSamp_m;          /* sampfac = ver_samp_n/ver_samp_m      */
11859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     enhancementType;    /* VOL type of enhancement layer */
11959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
12059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* These variables were added since they are used a lot. */
12159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nMBPerRow, nMBPerCol;   /* number of MBs in each row & column    */
12259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nTotalMB;
12359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nBitsForMBID;           /* how many bits required for MB number? */
12459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
12559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* for short video header */
12659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nMBinGOB;           /* number of MBs in GOB, 05/22/00 */
12759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nGOBinVop;          /* number of GOB in Vop  05/22/00 */
12859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} Vol;
12959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
13059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagMacroBlock
13159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
13259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     mb_x;               /* X coordinate */
13359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     mb_y;               /* Y coordinate */
13459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Short   block[9][64];       /* 4-Y, U and V blocks , and AAN Scale*/
13559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} MacroBlock;
13659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
13759f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagRunLevelBlock
13859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
13959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int run[64];        /* Runlength */
14059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int level[64];      /* Abs(level) */
14159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int s[64];          /* sign level */
14259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} RunLevelBlock;
14359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
14459f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagHeaderInfoDecVideo
14559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
14659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar       *Mode;              /* Modes INTRA/INTER/etc. */
14759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar       *CBP;               /* MCBPC/CBPY stuff */
14859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} HeaderInfoEncVideo;
14959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
15059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef Short typeDCStore[6];   /* ACDC */
15159f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef Short typeDCACStore[4][8];
15259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
15359f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagMOT
15459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
15559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int x;  /* half-pel resolution x component */
15659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int y;      /* half-pel resolution y component */
15759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int sad;  /* SAD */
15859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} MOT;
15959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
16059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagHintTrackInfo
16159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
16259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar MTB;
16359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar LayerID;
16459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar CodeType;
16559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar RefSelCode;
16659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
16759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} HintTrackInfo;
16859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
16959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
17059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagVideoEncParams
17159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
17259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    //Int       Width;                  /* Input Width */
17359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    //Int       Height;                 /* Input Height */
17459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    //float FrameRate;              /* Input Frame Rate */
17559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt    TimeIncrementRes;       /* timeIncrementRes */
17659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
17759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /*VOL Parameters */
17859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     nLayers;
17959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     LayerWidth[4];          /* Encoded Width */
18059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     LayerHeight[4];         /* Encoded Height */
18159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float   LayerFrameRate[4];      /* Encoded Frame Rate */
18259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     LayerBitRate[4];        /* Encoded BitRate */
18359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     LayerMaxBitRate[4];     /* Maximum Encoded BitRate */
18459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float   LayerMaxFrameRate[4];   /* Maximum Encoded Frame Rate */
18559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     LayerMaxMbsPerSec[4];   /* Maximum mbs per second, according to the specified profile and level */
18659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     LayerMaxBufferSize[4];  /* Maximum buffer size, according to the specified profile and level */
18759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
18859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    ResyncMarkerDisable;    /* Disable Resync Marker */
18959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    DataPartitioning;       /* Base Layer Data Partitioning */
19059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    ReversibleVLC;          /* RVLC when Data Partitioning */
19159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    ACDCPrediction;         /* AC/DC Prediction    */
19259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     QuantType[4];           /* H263, MPEG2 */
19359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     InitQuantBvop[4];
19459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     InitQuantPvop[4];
19559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     InitQuantIvop[4];
19659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     ResyncPacketsize;
19759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
19859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     RoundingType;
19959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     IntraDCVlcThr;
20059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
20159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Rate Control Parameters */
20259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    MP4RateControlType  RC_Type;        /*Constant Q, M4 constantRate, VM5+, M4RC,MPEG2TM5 */
20359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
20459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Intra Refresh Parameters */
20559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     IntraPeriod;            /* Intra update period */
20659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     Refresh;                /* Number of MBs refresh in each frame */
20759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Other Parameters */
20859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    SceneChange_Det;        /* scene change detection */
20959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    FineFrameSkip_Enabled;  /* src rate resolution frame skipping */
21059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    VBR_Enabled;            /* VBR rate control */
21159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    NoFrameSkip_Enabled;    /* do not allow frame skip */
21259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    NoPreSkip_Enabled;      /* do not allow pre-skip */
21359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
21459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    H263_Enabled;           /* H263 Short Header */
21559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    GOV_Enabled;            /* GOV Header Enabled */
21659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    SequenceStartCode;      /* This probably should be removed */
21759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    FullSearch_Enabled;     /* full-pel exhaustive search motion estimation */
21859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    HalfPel_Enabled;        /* Turn Halfpel ME on or off */
21959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    MV8x8_Enabled;          /* Enable 8x8 motion vectors */
22059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Bool    RD_opt_Enabled;         /* Enable operational R-D optimization */
22159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     GOB_Header_Interval;        /* Enable encoding GOB header in H263_WITH_ERR_RES and SHORT_HERDER_WITH_ERR_RES */
22259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     SearchRange;            /* Search range for 16x16 motion vector */
22359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     MemoryUsage;            /* Amount of memory allocated */
22459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     GetVolHeader[2];        /* Flag to check if Vol Header has been retrieved */
22559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     BufferSize[2];          /* Buffer Size for Base and Enhance Layers */
22659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     ProfileLevel[2];        /* Profile and Level for encoding purposes */
22759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float   VBV_delay;              /* VBV buffer size in the form of delay */
22859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     maxFrameSize;           /* maximum frame size(bits) for H263/Short header mode, k*16384 */
22959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     profile_table_index;    /* index for profile and level tables given the specified profile and level */
23059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
23159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} VideoEncParams;
23259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
23359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* platform dependent functions */
23459f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagFuncPtr
23559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
23659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong//  Int (*SAD_MB_HalfPel)(UChar *ref,UChar *blk,Int dmin_lx,Int xh,Int yh,void *extra_info);
23759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int(*SAD_MB_HalfPel[4])(UChar*, UChar*, Int, void *);
23859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int(*SAD_Blk_HalfPel)(UChar *ref, UChar *blk, Int dmin, Int lx, Int rx, Int xh, Int yh, void *extra_info);
23959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int(*SAD_Macroblock)(UChar *ref, UChar *blk, Int dmin_lx, void *extra_info);
24059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int(*SAD_Block)(UChar *ref, UChar *blk, Int dmin, Int lx, void *extra_info);
24159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int(*SAD_MB_PADDING)(UChar *ref, UChar *blk, Int dmin, Int lx, void *extra_info); /*, 4/21/01 */
24259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    void (*ComputeMBSum)(UChar *cur, Int lx, MOT *mot_mb);
24359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    void (*ChooseMode)(UChar *Mode, UChar *cur, Int lx, Int min_SAD);
24459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    void (*GetHalfPelMBRegion)(UChar *cand, UChar *hmem, Int lx);
24559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    void (*blockIdct)(Int *block);
24659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
24759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
24859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} FuncPtr;
24959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
25059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* 04/09/01, for multipass rate control */
25159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
25259f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagRDInfo
25359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
25459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int QP;
25559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int actual_bits;
25659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float mad;
25759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float R_D;
25859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} RDInfo;
25959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
26059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagMultiPass
26159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
26259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* multipass rate control data */
26359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int target_bits;    /* target bits for current frame, = rc->T */
26459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int actual_bits;    /* actual bits for current frame obtained after encoding, = rc->Rc*/
26559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int QP;             /* quantization level for current frame, = rc->Qc*/
26659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int prev_QP;        /* quantization level for previous frame */
26759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int prev_prev_QP;   /* quantization level for previous frame before last*/
26859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float mad;          /* mad for current frame, = video->avgMAD*/
26959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int bitrate;        /* bitrate for current frame */
27059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float framerate;    /* framerate for current frame*/
27159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
27259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int nRe_Quantized;  /* control variable for multipass encoding, */
27359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* 0 : first pass */
27459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* 1 : intermediate pass(quantization and VLC loop only) */
27559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* 2 : final pass(de-quantization, idct, etc) */
27659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* 3 : macroblock level rate control */
27759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
27859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int encoded_frames;     /* counter for all encoded frames */
27959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int re_encoded_frames;  /* counter for all multipass encoded frames*/
28059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int re_encoded_times;   /* counter for all times of multipass frame encoding */
28159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
28259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Multiple frame prediction*/
28359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    RDInfo **pRDSamples;        /* pRDSamples[30][32], 30->30fps, 32 -> 5 bit quantizer, 32 candidates*/
28459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int framePos;               /* specific position in previous multiple frames*/
28559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int frameRange;             /* number of overall previous multiple frames */
28659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int samplesPerFrame[30];    /* number of samples per frame, 30->30fps */
28759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
28859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Bit allocation for scene change frames and high motion frames */
28959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float sum_mad;
29059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int counter_BTsrc;  /* BT = Bit Transfer, bit transfer from low motion frames or less complicatedly compressed frames */
29159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int counter_BTdst;  /* BT = Bit Transfer, bit transfer to scene change frames or high motion frames or more complicatedly compressed frames */
29259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float sum_QP;
29359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int diff_counter;   /* diff_counter = -diff_counter_BTdst, or diff_counter_BTsrc */
29459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
29559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* For target bitrate or framerate update */
29659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float target_bits_per_frame;        /* = C = bitrate/framerate */
29759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float target_bits_per_frame_prev;   /* previous C */
29859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float aver_mad;                     /* so-far average mad could replace sum_mad */
29959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float aver_mad_prev;                /* previous average mad */
30059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int   overlapped_win_size;          /* transition period of time */
30159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int   encoded_frames_prev;          /* previous encoded_frames */
30259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} MultiPass;
30359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
30459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* End */
30559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
30659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#ifdef HTFM
30759f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagHTFM_Stat
30859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
30959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int abs_dif_mad_avg;
31059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt countbreak;
31159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int offsetArray[16];
31259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int offsetRef[16];
31359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} HTFM_Stat;
31459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#endif
31559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
31659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/* Global structure that can be passed around */
31759f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagVideoEncData
31859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
31959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* VOL Header Initialization */
32059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   volInitialize[4];       /* Used to Write VOL Headers */
32159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Data For Layers (Scalability) */
32259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     numberOfLayers;     /* Number of Layers */
32359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vol     **vol;              /* Data stored for each VOL */
32459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
32559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Data used for encoding frames */
32659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    VideoEncFrameIO *input;     /* original input frame */
32759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *currVop;           /* Current reconstructed VOP */
32859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *prevBaseVop;       /* Previous reference Base Vop */
32959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *nextBaseVop;       /* Next reference Base Vop */
33059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *prevEnhanceVop;/* Previous Enhancement Layer Vop */
33159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *forwardRefVop;     /* Forward Reference VOP */
33259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *backwardRefVop;    /* Backward Reference VOP */
33359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
33459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* scratch memory */
33559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    BitstreamEncVideo  *bitstream1; /* Used for data partitioning */
33659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    BitstreamEncVideo  *bitstream2; /* and combined modes as      */
33759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    BitstreamEncVideo  *bitstream3; /* intermediate storages      */
33859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
33959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   *overrunBuffer;  /* extra output buffer to prevent current skip due to output buffer overrun*/
34059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     oBSize;     /* size of allocated overrun buffer */
34159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
34259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int dc_scalar_1;            /*dc scalar for Y block */
34359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int dc_scalar_2;            /*dc scalar for U, V block*/
34459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
34559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Annex L Rate Control */
34659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    rateControl     *rc[4];         /* Pointer to Rate Control structure*/
34759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* 12/25/00, each R.C. for each layer */
34859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
34959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /********* motion compensation related variables ****************/
35059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    MOT     **mot;              /* Motion vectors */
35159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /*  where [mbnum][0] = 1MV.
35259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong        [mbnum][1...4] = 4MVs
35359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong        [mbnum][5] = backward MV.
35459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong        [mbnum][6] = delta MV for direct mode.
35559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong        [mbnum][7] = nothing yet. */
35659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   *intraArray;            /* Intra Update Arrary */
35759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float   sumMAD;             /* SAD/MAD for frame */
35859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
35959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* to speedup the SAD calculation */
36059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    void *sad_extra_info;
36159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#ifdef HTFM
36259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int nrmlz_th[48];       /* Threshold for fast SAD calculation using HTFM */
36359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    HTFM_Stat htfm_stat;    /* For statistics collection */
36459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#endif
36559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
36659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /*Tao 04/09/00  For DCT routine */
36759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar currYMB[256];     /* interleaved current macroblock in HTFM order */
36859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    MacroBlock  *outputMB;          /* Output MB to VLC encode */
36959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   predictedMB[384];   /* scrath memory for predicted value */
37059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    RunLevelBlock RLB[6];       /* Run and Level of coefficients! */
37159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Short   dataBlock[128];     /* DCT block data before and after quant/dequant*/
37259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
37359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   bitmaprow[8];       /* Need to keep it for ACDCPrediction, 8 bytes for alignment, need only 6 */
37459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   bitmapcol[6][8];
37559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt    bitmapzz[6][2]; /* for zigzag bitmap */
37659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     zeroMV;         /* flag for zero MV */
37759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
37859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     usePrevQP;      /* flag for intraDCVlcThreshold switch decision */
37959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     QP_prev;            /* use for DQUANT calculation */
38059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     *acPredFlag;        /* */
38159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    typeDCStore     *predDC;        /* The DC coeffs for each MB */
38259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    typeDCACStore   *predDCAC_row;
38359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    typeDCACStore   *predDCAC_col;
38459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
38559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
38659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   *sliceNo;           /* Slice Number for each MB */
38759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
38859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     header_bits;        /* header bits in frmae */
38959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    HeaderInfoEncVideo  headerInfo; /* MB Header information */
39059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   zz_direction;       /* direction of zigzag scan */
39159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UChar   *QPMB;              /* Quantizer value for each MB */
39259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
39359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Miscellaneous data points to be passed */
39459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float   FrameRate;          /* Src frame Rate */
39559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
39659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    ULong   nextModTime;        /* expected next frame time */
39759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt    prevFrameNum[4];    /* previous frame number starting from modTimeRef */
39859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt    modTimeRef;     /* Reference modTime update every I-Vop*/
39959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    UInt    refTick[4];         /* second aligned referenc tick */
40059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     relLayerCodeTime[4];/* Next coding time for each Layer relative to highest layer */
40159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
40259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    ULong   modTime;            /* Input frame modTime */
40359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     currLayer;          /* Current frame layer  */
40459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     mbnum;              /*  Macroblock number */
40559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
40659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* slice coding, state variables */
40759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Vop     *tempForwRefVop;
40859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     tempRefSelCode;
40959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     end_of_buf;         /* end of bitstream buffer flag */
41059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     slice_coding;       /* flag for slice based coding */
41159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     totalSAD;           /* So far total SAD for a frame */
41259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     numIntra;           /* So far number of Intra MB */
41359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     offset;             /* So far MB offset */
41459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     ind_x, ind_y;       /* So far MB coordinate */
41559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     collect;
41659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int     hp_guess;
41759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /*********************************/
41859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
41959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    HintTrackInfo hintTrackInfo;    /* hintTrackInfo */
42059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* IntraPeriod, Timestamp, etc. */
42159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float       nextEncIVop;    /* counter til the next I-Vop */
42259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    float       numVopsInGOP;   /* value at the beginning of nextEncIVop */
42359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
42459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* platform dependent functions */
42559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    FuncPtr     *functionPointer;   /* structure containing platform dependent functions */
42659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
42759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    /* Application controls */
42859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    VideoEncControls    *videoEncControls;
42959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    VideoEncParams      *encParams;
43059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
43159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    MultiPass *pMP[4]; /* for multipass encoding, 4 represents 4 layer encoding */
43259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
43359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} VideoEncData;
43459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
43559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*************************************************************/
43659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*                  VLC structures                           */
43759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*************************************************************/
43859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
43959f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct tagVLCtable
44059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
44159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    unsigned int code; /* right justified */
44259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    int len;
44359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong} VLCtable, *LPVLCtable;
44459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
44559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
44659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*************************************************************/
44759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*                  Approx DCT                               */
44859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*************************************************************/
44959f566c4ec3dfc097ad8163523e522280b27e5c3James Dongtypedef struct struct_approxDCT  approxDCT;
45059f566c4ec3dfc097ad8163523e522280b27e5c3James Dongstruct struct_approxDCT
45159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
45259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Void(*BlockDCT8x8)(Int *, Int *, UChar *, UChar *, Int, Int);
45359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Void(*BlockDCT8x8Intra)(Int *, Int *, UChar *, UChar *, Int, Int);
45459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Void(*BlockDCT8x8wSub)(Int *, Int *, UChar *, UChar *, Int, Int);
45559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong};
45659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
45759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*************************************************************/
45859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*                  QP structure                             */
45959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong/*************************************************************/
46059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
46159f566c4ec3dfc097ad8163523e522280b27e5c3James Dongstruct QPstruct
46259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong{
46359f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int QPx2 ;
46459f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int QP;
46559f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int QPdiv2;
46659f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int QPx2plus;
46759f566c4ec3dfc097ad8163523e522280b27e5c3James Dong    Int Addition;
46859f566c4ec3dfc097ad8163523e522280b27e5c3James Dong};
46959f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
47059f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
47159f566c4ec3dfc097ad8163523e522280b27e5c3James Dong#endif /* _MP4LIB_INT_H_ */
47259f566c4ec3dfc097ad8163523e522280b27e5c3James Dong
473