📄 umc_base_bitstream.cpp
字号:
//
// 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) 2004 - 2007 Intel Corporation. All Rights Reserved.
//
#include <string.h>
#include "umc_base_bitstream.h"
#include "umc_h264_config.h"
//#define PRINT_CABAC_RANGE
#if defined PRINT_CABAC_RANGE
Ipp32s print_cabac_range;
#endif // PRINT_CABAC_RANGE
// ---------------------------------------------------------------------------
// CBaseBitstream::CBaseBitstream()
// Default constructor.
// ---------------------------------------------------------------------------
namespace UMC_H264_ENCODER
{
// Range table
const Ipp8u rangeTabLPS[64][4]=
{
{ 128, 176, 208, 240},
{ 128, 167, 197, 227},
{ 128, 158, 187, 216},
{ 123, 150, 178, 205},
{ 116, 142, 169, 195},
{ 111, 135, 160, 185},
{ 105, 128, 152, 175},
{ 100, 122, 144, 166},
{ 95, 116, 137, 158},
{ 90, 110, 130, 150},
{ 85, 104, 123, 142},
{ 81, 99, 117, 135},
{ 77, 94, 111, 128},
{ 73, 89, 105, 122},
{ 69, 85, 100, 116},
{ 66, 80, 95, 110},
{ 62, 76, 90, 104},
{ 59, 72, 86, 99},
{ 56, 69, 81, 94},
{ 53, 65, 77, 89},
{ 51, 62, 73, 85},
{ 48, 59, 69, 80},
{ 46, 56, 66, 76},
{ 43, 53, 63, 72},
{ 41, 50, 59, 69},
{ 39, 48, 56, 65},
{ 37, 45, 54, 62},
{ 35, 43, 51, 59},
{ 33, 41, 48, 56},
{ 32, 39, 46, 53},
{ 30, 37, 43, 50},
{ 29, 35, 41, 48},
{ 27, 33, 39, 45},
{ 26, 31, 37, 43},
{ 24, 30, 35, 41},
{ 23, 28, 33, 39},
{ 22, 27, 32, 37},
{ 21, 26, 30, 35},
{ 20, 24, 29, 33},
{ 19, 23, 27, 31},
{ 18, 22, 26, 30},
{ 17, 21, 25, 28},
{ 16, 20, 23, 27},
{ 15, 19, 22, 25},
{ 14, 18, 21, 24},
{ 14, 17, 20, 23},
{ 13, 16, 19, 22},
{ 12, 15, 18, 21},
{ 12, 14, 17, 20},
{ 11, 14, 16, 19},
{ 11, 13, 15, 18},
{ 10, 12, 15, 17},
{ 10, 12, 14, 16},
{ 9, 11, 13, 15},
{ 9, 11, 12, 14},
{ 8, 10, 12, 14},
{ 8, 9, 11, 13},
{ 7, 9, 11, 12},
{ 7, 9, 10, 12},
{ 7, 8, 10, 11},
{ 6, 8, 9, 11},
{ 6, 7, 9, 10},
{ 6, 7, 8, 9},
{ 2, 2, 2, 2}
};
const Ipp16u transIdxMPS[64] =
{
1,2,3,4,5,6,7,8,9,10, // Trans
11,12,13,14,15,16,17,18,19,20, // index
21,22,23,24,25,26,27,28,29,30, // array.
31,32,33,34,35,36,37,38,39,40, // Needed
41,42,43,44,45,46,47,48,49,50, // for
51,52,53,54,55,56,57,58,59,60, // CABAC
61,62,62,63 // coding.
};
const Ipp16u transIdxLPS[64] =
{
0, 0, 1, 2, 2, 4, 4, 5, 6, 7, // Trans
8, 9, 9,11,11,12,13,13,15,15, // index
16,16,18,18,19,19,21,21,22,22, // array.
23,24,24,25,26,26,27,27,28,29, // Needed
29,30,30,30,31,32,32,33,33,33, // for
34,34,35,35,35,36,36,36,37,37, // CABAC
37,38,38,63 // coding.
};
#define ENC_B_BITS (10)
#define ENC_FULL_RANGE (1 << (ENC_B_BITS-0))
#define ENC_HALF_RANGE (1 << (ENC_B_BITS-1))
#define ENC_QUARTER_RANGE (1 << (ENC_B_BITS-2))
typedef struct INITIALIZE_VALUES
{
Ipp8s m;
Ipp8s n;
} INITIALIZE_VALUES;
// See table 9-12 of H.264 standard
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
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
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
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
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
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
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},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -