⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 h263.h

📁 audio-video-codecs.rar语音编解码器
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ///////////////////////////////////////////////////////////////////////
//
//               INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright(c) 2005-2007 Intel Corporation. All Rights Reserved.
//
//  Description:    H.263+ header.
//
*/

#ifndef _H263_H_
#define _H263_H_

#ifdef _OPENMP
#define _OMP_KARABAS
#endif

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "vm_debug.h"
#include "ippdefs.h"
#include "ippcore.h"
#include "ipps.h"
#include "ippi.h"
#include "ippvc.h"
#include "vm_debug.h"
#include "vm_thread.h"
//#include "ippcc.h"

#pragma warning(disable : 4710) // function not inlined
#pragma warning(disable : 4514) // unreferenced inline function has been removed CL
#pragma warning(disable : 4100) // unreferenced formal parameter CL

#ifdef __cplusplus
extern "C" {
#endif

#if defined(__INTEL_COMPILER) || defined(_MSC_VER)
    #define __INLINE static __inline
#elif defined( __GNUC__ )
    #define __INLINE static __inline__
#else
    #define __INLINE static
#endif

#if defined(__INTEL_COMPILER) && !defined(_WIN32_WCE)
    #define __ALIGN16(type, name, size) \
        __declspec (align(16)) type name[size]
#else
    #if defined(_WIN64) || defined(WIN64) || defined(LINUX64)
        #define __ALIGN16(type, name, size) \
            Ipp8u _a16_##name[(size)*sizeof(type)+15]; type *name = (type*)(((Ipp64s)(_a16_##name) + 15) & ~15)
    #else
        #define __ALIGN16(type, name, size) \
            Ipp8u _a16_##name[(size)*sizeof(type)+15]; type *name = (type*)(((Ipp32s)(_a16_##name) + 15) & ~15)
    #endif
#endif

#define h263_CLIP(x, min, max) if ((x) < (min)) (x) = (min); else if ((x) > (max)) (x) = (max)
#define h263_CLIPR(x, max) if ((x) > (max)) (x) = (max)
#define h263_SWAP(type, x, y) {type t = (x); (x) = (y); (y) = t;}
#define h263_ABS(a) ((a) >= 0 ? (a) : -(a))

/* Timer Info */

#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)

    #include <windows.h>

    typedef struct _h263_Timer {
        LARGE_INTEGER  count;
        LARGE_INTEGER  start;
        LARGE_INTEGER  stop;
        Ipp32s         calls;
    } h263_Timer;

    __INLINE void h263_TimerStart(h263_Timer *t)
    {
        QueryPerformanceCounter(&t->start);
    }

    __INLINE void h263_TimerStop(h263_Timer *t)
    {
        QueryPerformanceCounter(&t->stop);
        t->count.QuadPart += t->stop.QuadPart - t->start.QuadPart;
        t->calls ++;
    }

    #define TIMER_FREQ_TYPE LARGE_INTEGER

    __INLINE void h263_GetTimerFreq(TIMER_FREQ_TYPE *f)
    {
        QueryPerformanceFrequency(f);
    }

    __INLINE Ipp64f h263_GetTimerSec(h263_Timer *t, TIMER_FREQ_TYPE f)
    {
        return (Ipp64f)t->count.QuadPart / (Ipp64f)f.QuadPart;
    }

#else  // LINUX

    #include <time.h>

    typedef struct _h263_Timer {
        clock_t  count;
        clock_t  start;
        clock_t  stop;
        Ipp32s   calls;
    } h263_Timer;

    __INLINE void h263_TimerStart(h263_Timer *t)
    {
        t->start = clock();
    }

    __INLINE void h263_TimerStop(h263_Timer *t)
    {
        t->stop = clock();
        t->count += t->stop - t->start;
        t->calls ++;
    }

    #define TIMER_FREQ_TYPE Ipp32s

    __INLINE void h263_GetTimerFreq(TIMER_FREQ_TYPE *f)
    {
        *f = CLOCKS_PER_SEC;
    }

    __INLINE Ipp64f h263_GetTimerSec(h263_Timer *t, TIMER_FREQ_TYPE f)
    {
        return (Ipp64f)t->count / (Ipp64f)f;
    }
#endif

#define H263_PIC_TIME_INCR_RESOLUTION 1800000
#define H263_DEFAULT_FRAME_INTERVAL 60*1001

/* number of exterior MB */
#define H263_NUM_EXT_MB 1

#define H263_MAX_ENH_LAYERS 14

/* Statistic Info */
typedef struct _h263_Statistic {
    // Sequence Info
    Ipp32s      nPic;
    Ipp32s      nPic_I;
    Ipp32s      nPic_P;
    Ipp32s      nPic_PB;
    Ipp32s      nPic_B;
    Ipp32s      nPic_EI;
    Ipp32s      nPic_EP;
#ifdef H263_FULL_STAT
    Ipp32s      nMB;
    Ipp32s      nMB_INTER;
    Ipp32s      nMB_INTER_Q;
    Ipp32s      nMB_INTRA;
    Ipp32s      nMB_INTRA_Q;
    Ipp32s      nMB_INTER4V;
    Ipp32s      nMB_INTER4V_Q;
    Ipp32s      nMB_INTERPOLATE_PB;
    Ipp32s      nMB_INTERPOLATE_iPB;
    Ipp32s      nMB_BACKWARD_iPB;
    Ipp32s      nMB_FORWARD_iPB;
    Ipp32s      nMB_NOTCODED;
    Ipp32s      nMB_DIRECT_B;
    Ipp32s      nMB_INTERPOLATE_B;
    Ipp32s      nMB_BACKWARD_B;
    Ipp32s      nMB_FORWARD_B;
    Ipp32s      nB_INTRA_DC;
    Ipp32s      nB_INTRA_AC;
    Ipp32s      nB_INTER_C;
    Ipp32s      nB_INTER_NC;
#endif
    // app Timing Info
    h263_Timer  time_DecodeShow;    // decode + draw + file reading
    h263_Timer  time_Decode;        // decode + file reading
    h263_Timer  time_DecodeOnly;    // decode only
} h263_Statistic;

__INLINE void h263_StatisticInc(Ipp32s *s)
{
    *s = (*s) + 1;
}

// when using Full Statistic, FPS is less
#ifdef H263_FULL_STAT
#define h263_StatisticInc_(s) h263_StatisticInc(s)
#define h263_TimerStart_(t) h263_TimerStart(t)
#define h263_TimerStop_(t) h263_TimerStop(t)
#else
#define h263_StatisticInc_(s)
#define h263_TimerStart_(t)
#define h263_TimerStop_(t)
#endif

/* status codes */
typedef enum {
    H263_STATUS_OK           =  0,   // no error
    H263_STATUS_NO_MEM       = -1,   // out of memory
    H263_STATUS_FILE_ERROR   = -2,   // file error
    H263_STATUS_NOTSUPPORT   = -3,   // not supported mode
    H263_STATUS_PARSE_ERROR  = -4,   // failure in H.263++ stream parsing
    H263_STATUS_ERROR        = -5    // unknown/unspecified error
} h263_Status;

/* H.263++ code values */
/* ITU-T Recommendation H.263, Table 5 */
enum {
    H263_ASPECT_RATIO_FORBIDDEN  = 0,
    H263_ASPECT_RATIO_1_1        = 1,
    H263_ASPECT_RATIO_12_11      = 2,
    H263_ASPECT_RATIO_10_11      = 3,
    H263_ASPECT_RATIO_16_11      = 4,
    H263_ASPECT_RATIO_40_33      = 5,
    H263_ASPECT_RATIO_EXTPAR     = 15
};

enum {
    H263_PIC_TYPE_I    = 0,
    H263_PIC_TYPE_P    = 1,
    H263_PIC_TYPE_iPB  = 2,
    H263_PIC_TYPE_B    = 3,
    H263_PIC_TYPE_EI   = 4,
    H263_PIC_TYPE_EP   = 5,
    H263_PIC_TYPE_PB   = 6
};

enum {
  H263_SCALABILITY_NONE       = 0,
  H263_SCALABILITY_TEMPORAL   = 1,
  H263_SCALABILITY_SNR        = 2,
  H263_SCALABILITY_SPATIAL_X  = 3,
  H263_SCALABILITY_SPATIAL_Y  = 4,
  H263_SCALABILITY_SPATIAL_XY = 5
};

#define H263_HEADER_MARKER  0x145  /* 1010 0010 1   */
#define H263_MV_MARKER      0x1    /* 0000 0000 01  */

/* Frame Info */
typedef struct _h263_Frame {
    Ipp8u*      apY;        // allocated with border
    Ipp8u*      apCb;       // allocated with border
    Ipp8u*      apCr;       // allocated with border
    Ipp32s      stepY;
    Ipp32s      stepCr;
    Ipp32s      stepCb;
    Ipp8u*      pY;         // real pointer
    Ipp8u*      pCb;        // real pointer
    Ipp8u*      pCr;        // real pointer
    Ipp32s      type;
    Ipp64s      time;
/* used for scalability, resize, can be calculated from width/height */
    Ipp32s      mbPerRow;
    Ipp32s      mbPerCol;
/* used for resampling */
    Ipp32s      width;
    Ipp32s      height;
    Ipp32u      mid;
} h263_Frame;

/* Block Info for Intra Prediction */
typedef struct _h263_IntraPredBlock {
    struct _h263_IntraPredBlock  *predA;
    struct _h263_IntraPredBlock  *predC;
    Ipp16s      dct_acA[8];
    Ipp16s      dct_acC[8];
    Ipp16s      dct_dc;
} h263_IntraPredBlock;

/* Buffer for Intra Prediction */
typedef struct _h263_IntraPredBuff {
    h263_IntraPredBlock  *block;
} h263_IntraPredBuff;

/* MacroBlock Info Data Partitioned mode */
/*
typedef struct _h263_DataPartMacroBlock {
    Ipp16s          dct_dc[6];
    Ipp8u           type;
    Ipp8u           not_coded;
    Ipp8u           mcsel;
    Ipp8u           ac_pred_flag;
    Ipp8u           pat;
    Ipp8u           quant;
} h263_DataPartMacroBlock;
*/

/* MacroBlock Info for Motion */
typedef struct _h263_MacroBlock {
    IppMotionVector mv[4];
    Ipp8u           type; /* OBMC */
    Ipp8u           quant;
} h263_MacroBlock;

typedef struct _h263_PTYPEmodes {
    Ipp32s      UMV;
    Ipp32s      SAC;
    Ipp32s      advPred;
    Ipp32s      PBframes;
    Ipp32s      resample;
    Ipp32s      redResUp;
} h263_PTYPEmodes;

typedef struct _h263_OPPTYPEmodes {
  Ipp8u  UMV;
  Ipp8u  SAC;
  Ipp8u  advPred;
  Ipp8u  advIntra;
  Ipp8u  deblockFilt;
  Ipp8u  sliceStruct;
  Ipp8u  RPS;
  Ipp8u  ISD;
  Ipp8u  altInterVLC;
  Ipp8u  modQuant;
} h263_OPPTYPEmodes;

typedef struct _h263_PictureFormat {
  Ipp32s  PAR_code;
  Ipp32s  PAR_width;
  Ipp32s  PAR_height;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -