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

📄 umc_h264_dec_bitstream_cabac.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*
//
//              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) 2003-2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_H264_VIDEO_DECODER)

#include "umc_h264_dec.h"
#include "umc_h264_bitstream.h"
#include "umc_h264_bitstream_inlines.h"
#include "umc_h264_dec_internal_cabac.h"
#include "vm_types.h"
#include <ippi.h>

using namespace UMC;

namespace UMCH264DecodingFunctional
{

template <class T> inline
T Clip3(T Min, T Max, T Value)
{
    if (Value < Min)
        return Min;
    else if (Value > Max)
        return Max;
    else
        return Value;

} //T Clip3(T Min, T Max, T Value)

static
void InitializeContext(CABAC_CONTEXT *pContext, Ipp8s m, Ipp8s n, Ipp32s SliceQPy
#ifdef STORE_CABAC_BITS
#ifdef CABAC_CONTEXTS_COMP
                       , Ipp32s ctxIdx
#endif
#endif
                       )
{
    Ipp32s preCtxState;

    preCtxState = Clip3(1, 126, ((m * SliceQPy) >> 4) + n);
    if (preCtxState <= 63)
    {
        pContext->pStateIdxAndVal = Ipp8u((63 - preCtxState) * 2);
    }
    else
    {
        pContext->pStateIdxAndVal = Ipp8u((preCtxState - 64) * 2 + 1);
    }
#ifdef STORE_CABAC_BITS
#ifdef CABAC_CONTEXTS_COMP
    if(cabac_bits==NULL) cabac_bits=fopen(__CABAC_FILE__,"w+t");
    if(cabac_bits)
        fprintf(cabac_bits,"ctx_ini %d %d %d\n",ctxIdx,pContext->pStateIdx,pContext->valMPS);
#endif
#endif

} // void InitializeContext(CABAC_CONTEXT *pContext, Ipp8s m, Ipp8s n, Ipp8u SliceQPy)

typedef struct INITIALIZE_VALUES
{
    Ipp8s m;
    Ipp8s n;

} INITIALIZE_VALUES;

// See table 9-12 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_0_10[11] =
{
    {20, -15},
    {2, 54},
    {3, 74},
    {20, -15},
    {2, 54},
    {3, 74},
    {-28, 127},
    {-23, 104},
    {-6, 53},
    {-1, 54},
    {7, 51},
};

// See table 9-17 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_60_69[10] =
{
    {0, 41},
    {0, 63},
    {0, 63},
    {0, 63},
    {-9, 83},
    {4, 86},
    {0, 97},
    {-7, 72},
    {13, 41},
    {3, 62},
};

// See table 9-18 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_70_104_intra[35] =
{
    {0, 11},
    {1, 55},
    {0, 69},
    {-17, 127},
    {-13, 102},
    {0, 82},
    {-7, 74},
    {-21, 107},
    {-27, 127},
    {-31, 127},
    {-24, 127},
    {-18, 95},
    {-27, 127},
    {-21, 114},
    {-30, 127},
    {-17, 123},
    {-12, 115},
    {-16, 122},
    {-11, 115},
    {-12, 63},
    {-2, 68},
    {-15, 84},
    {-13, 104},
    {-3, 70},
    {-8, 93},
    {-10, 90},
    {-30, 127},
    {-1, 74},
    {-6, 97},
    {-7, 91},
    {-20, 127},
    {-4, 56},
    {-5, 82},
    {-7, 76},
    {-22, 125},
};

// See table 9-19 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_105_165_intra[61] =
{
    {-7, 93},
    {-11, 87},
    {-3, 77},
    {-5, 71},
    {-4, 63},
    {-4, 68},
    {-12, 84},
    {-7, 62},
    {-7, 65},
    {8, 61},
    {5, 56},
    {-2, 66},
    {1, 64},
    {0, 61},
    {-2, 78},
    {1, 50},
    {7, 52},
    {10, 35},
    {0, 44},
    {11, 38},
    {1, 45},
    {0, 46},
    {5, 44},
    {31, 17},
    {1, 51},
    {7, 50},
    {28, 19},
    {16, 33},
    {14, 62},
    {-13, 108},
    {-15, 100},
    {-13, 101},
    {-13, 91},
    {-12, 94},
    {-10, 88},
    {-16, 84},
    {-10, 86},
    {-7, 83},
    {-13, 87},
    {-19, 94},
    {1, 70},
    {0, 72},
    {-5, 74},
    {18, 59},
    {-8, 102},
    {-15, 100},
    {0, 95},
    {-4, 75},
    {2, 72},
    {-11, 75},
    {-3, 71},
    {15, 46},
    {-13, 69},
    {0, 62},
    {0, 65},
    {21, 37},
    {-15, 72},
    {9, 57},
    {16, 54},
    {0, 62},
    {12, 72},
};

// See table 9-20 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_166_226_intra[61] =
{
    {24, 0},
    {15, 9},
    {8, 25},
    {13, 18},
    {15, 9},
    {13, 19},
    {10, 37},
    {12, 18},
    {6, 29},
    {20, 33},
    {15, 30},
    {4, 45},
    {1, 58},
    {0, 62},
    {7, 61},
    {12, 38},
    {11, 45},
    {15, 39},
    {11, 42},
    {13, 44},
    {16, 45},
    {12, 41},
    {10, 49},
    {30, 34},
    {18, 42},
    {10, 55},
    {17, 51},
    {17, 46},
    {0, 89},
    {26, -19},
    {22, -17},
    {26, -17},
    {30, -25},
    {28, -20},
    {33, -23},
    {37, -27},
    {33, -23},
    {40, -28},
    {38, -17},
    {33, -11},
    {40, -15},
    {41, -6},
    {38, 1},
    {41, 17},
    {30, -6},
    {27, 3},
    {26, 22},
    {37, -16},
    {35, -4},
    {38, -8},
    {38, -3},
    {37, 3},
    {38, 5},
    {42, 0},
    {35, 16},
    {39, 22},
    {14, 48},
    {27, 37},
    {21, 60},
    {12, 68},
    {2, 97},
};

// See table 9-21 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_227_275_intra[49] =
{
    {-3, 71},
    {-6, 42},
    {-5, 50},
    {-3, 54},
    {-2, 62},
    {0, 58},
    {1, 63},
    {-2, 72},
    {-1, 74},
    {-9, 91},
    {-5, 67},
    {-5, 27},
    {-3, 39},
    {-2, 44},
    {0, 46},
    {-16, 64},
    {-8, 68},
    {-10, 78},
    {-6, 77},
    {-10, 86},
    {-12, 92},
    {-15, 55},
    {-10, 60},
    {-6, 62},
    {-4, 65},
    {-12, 73},
    {-8, 76},
    {-7, 80},
    {-9, 88},
    {-17, 110},
    {-11, 97},
    {-20, 84},
    {-11, 79},
    {-6, 73},
    {-4, 74},
    {-13, 86},
    {-13, 96},
    {-11, 97},
    {-19, 117},
    {-8, 78},
    {-5, 33},
    {-4, 48},
    {-2, 53},
    {-3, 62},
    {-13, 71},
    {-10, 79},
    {-12, 86},
    {-13, 90},
    {-14, 97},
};

// See table 9-22 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_277_337_intra[61] =
{
    {-6, 93},
    {-6, 84},
    {-8, 79},
    {0, 66},
    {-1, 71},
    {0, 62},
    {-2, 60},
    {-2, 59},
    {-5, 75},
    {-3, 62},
    {-4, 58},
    {-9, 66},
    {-1, 79},
    {0, 71},
    {3, 68},
    {10, 44},
    {-7, 62},
    {15, 36},
    {14, 40},
    {16, 27},
    {12, 29},
    {1, 44},
    {20, 36},
    {18, 32},
    {5, 42},
    {1, 48},
    {10, 62},
    {17, 46},
    {9, 64},
    {-12, 104},
    {-11, 97},
    {-16, 96},
    {-7, 88},
    {-8, 85},
    {-7, 85},
    {-9, 85},
    {-13, 88},
    {4, 66},
    {-3, 77},
    {-3, 76},
    {-6, 76},
    {10, 58},
    {-1, 76},
    {-1, 83},
    {-7, 99},
    {-14, 95},
    {2, 95},
    {0, 76},
    {-5, 74},
    {0, 70},
    {-11, 75},
    {1, 68},
    {0, 65},
    {-14, 73},
    {3, 62},
    {4, 62},
    {-1, 68},
    {-13, 75},
    {11, 55},
    {5, 64},
    {12, 70},
};

// See table 9-23 of H.264 standard
static
INITIALIZE_VALUES M_and_N_for_ctxIdx_338_398_intra[61] =
{
    {15, 6},
    {6, 19},
    {7, 16},
    {12, 14},
    {18, 13},
    {13, 11},
    {13, 15},
    {15, 16},
    {12, 23},
    {13, 23},
    {15, 20},
    {14, 26},
    {14, 44},
    {17, 40},
    {17, 47},
    {24, 17},
    {21, 21},
    {25, 22},
    {31, 27},
    {22, 29},
    {19, 35},
    {14, 50},
    {10, 57},
    {7, 63},
    {-2, 77},
    {-4, 82},
    {-3, 94},
    {9, 69},
    {-12, 109},
    {36, -35},
    {36, -34},
    {32, -26},
    {37, -30},
    {44, -32},
    {34, -18},
    {34, -15},
    {40, -15},
    {33, -7},
    {35, -5},
    {33, 0},
    {38, 2},
    {33, 13},
    {23, 35},
    {13, 58},
    {29, -3},
    {26, 0},
    {22, 30},
    {31, -7},
    {35, -15},
    {34, -3},
    {34, 3},
    {36, -1},
    {34, 5},
    {32, 11},
    {35, 5},
    {34, 12},
    {39, 11},
    {30, 29},
    {34, 26},
    {29, 39},
    {19, 66},
};

static
INITIALIZE_VALUES M_and_N_for_ctxIdx_399_401_intra[3] =
{
    {31,21},
    {31,31},
    {25,50},
};

static
INITIALIZE_VALUES M_and_N_for_ctxIdx_402_459_intra[58] =
{
    {-17,120},
    {-20,112},
    {-18,114},
    {-11, 85},
    {-15, 92},
    {-14, 89},
    {-26, 71},
    {-15, 81},
    {-14, 80},
    {  0, 68},
    {-14, 70},
    {-24, 56},

⌨️ 快捷键说明

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