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

📄 mp4_enc_tables.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 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) 2003-2007 Intel Corporation. All Rights Reserved.
//
//  Description:    class ippVideoEncoderMPEG4 (tables)
//
*/

#include "umc_defs.h"

#if defined (UMC_ENABLE_MPEG4_VIDEO_ENCODER)

#include "mp4_enc.hpp"

#pragma warning(disable : 279)      // controlling expression is constant

namespace MPEG4_ENC
{

const Ipp8u mp4_DefaultIntraQuantMatrix[64] = {
     8, 17, 18, 19, 21, 23, 25, 27, 17, 18, 19, 21, 23, 25, 27, 28,
    20, 21, 22, 23, 24, 26, 28, 30, 21, 22, 23, 24, 26, 28, 30, 32,
    22, 23, 24, 26, 28, 30, 32, 35, 23, 24, 26, 28, 30, 32, 35, 38,
    25, 26, 28, 30, 32, 35, 38, 41, 27, 28, 30, 32, 35, 38, 41, 45
};

const Ipp8u mp4_DefaultNonIntraQuantMatrix[64] = {
    16, 17, 18, 19, 20, 21, 22, 23, 17, 18, 19, 20, 21, 22, 23, 24,
    18, 19, 20, 21, 22, 23, 24, 25, 19, 20, 21, 22, 23, 24, 26, 27,
    20, 21, 22, 23, 25, 26, 27, 28, 21, 22, 23, 24, 26, 27, 28, 30,
    22, 23, 24, 26, 27, 28, 30, 31, 23, 24, 25, 27, 28, 30, 31, 33
};

const Ipp8u mp4_ZigZagScan[64] = {
     0,  1,  8, 16,  9,  2,  3, 10, 17, 24, 32, 25, 18, 11,  4,  5,
    12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13,  6,  7, 14, 21, 28,
    35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
    58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
};

const Ipp8u mp4_AltVertScan[64] = {
     0,  8, 16, 24,  1,  9,  2, 10, 17, 25, 32, 40, 48, 56, 57, 49,
    41, 33, 26, 18,  3, 11,  4, 12, 19, 27, 34, 42, 50, 58, 35, 43,
    51, 59, 20, 28,  5, 13,  6, 14, 21, 29, 36, 44, 52, 60, 37, 45,
    53, 61, 22, 30,  7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63
};

const Ipp8u mp4_HorScan[64] = {
     0,  1,  2,  3,  8,  9, 16, 17, 10, 11,  4,  5,  6,  7, 15, 14,
    13, 12, 19, 18, 24, 25, 32, 33, 26, 27, 20, 21, 22, 23, 28, 29,
    30, 31, 34, 35, 40, 41, 48, 49, 42, 43, 36, 37, 38, 39, 44, 45,
    46, 47, 50, 51, 56, 57, 58, 59, 52, 53, 54, 55, 60, 61, 62, 63
};


const int mp4_DC_VLC_Threshold[8] = {512, 13, 15, 17, 19, 21, 23, 0};

// table B-7
const mp4_VLC mp4_VLC_MCBPC_TB7[20] = {
    {1, 1}, {3, 4}, {2, 4}, {5, 6}, {3, 3}, {7, 7}, {6, 7}, {5, 9},
    {2, 3}, {5, 7}, {4, 7}, {5, 8}, {3, 5}, {4, 8}, {3, 8}, {3, 7},
    {4, 6}, {4, 9}, {3, 9}, {2, 9}
};

// table B-8
const mp4_VLC mp4_VLC_CBPY_TB8[16] = {
    {0x3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},
    {0x2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}
};

// table B-12
const mp4_VLC mp4_VLC_MVD_TB12[65] = {
    {0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12}, {0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12},
    {0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11}, {0x11, 11}, {0x13, 11}, {0x15, 11}, {0x17, 11},
    {0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11}, {0x21, 11}, {0x23, 11}, {0x13, 10}, {0x15, 10},
    {0x17, 10}, {0x07,  8}, {0x09,  8}, {0x0b,  8}, {0x07,  7}, {0x03,  5}, {0x03,  4}, {0x03,  3},
    {0x01,  1}, {0x02,  3}, {0x02,  4}, {0x02,  5}, {0x06,  7}, {0x0a,  8}, {0x08,  8}, {0x06,  8},
    {0x16, 10}, {0x14, 10}, {0x12, 10}, {0x22, 11}, {0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11},
    {0x18, 11}, {0x16, 11}, {0x14, 11}, {0x12, 11}, {0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11},
    {0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, {0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13},
    {0x04, 13}
};

#define DCSL(q) (q <= 4) ? 8 : (q <= 8) ? (q << 1) : (q <= 24) ? (q + 8) : ((q << 1) - 16)

const Ipp8u mp4_DCScalerLuma[32] = {
    DCSL( 0), DCSL( 1), DCSL( 2), DCSL( 3), DCSL( 4), DCSL( 5), DCSL( 6), DCSL( 7),
    DCSL( 8), DCSL( 9), DCSL(10), DCSL(11), DCSL(12), DCSL(13), DCSL(14), DCSL(15),
    DCSL(16), DCSL(17), DCSL(18), DCSL(19), DCSL(20), DCSL(21), DCSL(22), DCSL(23),
    DCSL(24), DCSL(25), DCSL(26), DCSL(27), DCSL(28), DCSL(29), DCSL(30), DCSL(31)
};

#undef DCSC
#define DCSC(q) (q <= 4) ? 8 : (q <= 24) ? ((q + 13) >> 1) : (q - 6)

const Ipp8u mp4_DCScalerChroma[32] = {
    DCSC( 0), DCSC( 1), DCSC( 2), DCSC( 3), DCSC( 4), DCSC( 5), DCSC( 6), DCSC( 7),
    DCSC( 8), DCSC( 9), DCSC(10), DCSC(11), DCSC(12), DCSC(13), DCSC(14), DCSC(15),
    DCSC(16), DCSC(17), DCSC(18), DCSC(19), DCSC(20), DCSC(21), DCSC(22), DCSC(23),
    DCSC(24), DCSC(25), DCSC(26), DCSC(27), DCSC(28), DCSC(29), DCSC(30), DCSC(31)
};

#undef DCSC

const Ipp8u mp4_cCbCrMvRound16[16] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};

#define DI(b) ((1 << 18) + b) / b

const Ipp32s mp4_DivIntraDivisor[47] = {
    DI( 1), DI( 1), DI( 2), DI( 3), DI( 4), DI( 5), DI( 6), DI( 7), DI( 8), DI( 9),
    DI(10), DI(11), DI(12), DI(13), DI(14), DI(15), DI(16), DI(17), DI(18), DI(19),
    DI(20), DI(21), DI(22), DI(23), DI(24), DI(25), DI(26), DI(27), DI(28), DI(29),
    DI(30), DI(31), DI(32), DI(33), DI(34), DI(35), DI(36), DI(37), DI(38), DI(39),
    DI(40), DI(41), DI(42), DI(43), DI(44), DI(45), DI(46)
};

#undef DI

#define SF  20. / 6.
const Ipp8u mp4_MV_Weigth[32] = {
    0, (Ipp8u)( 1.115*SF+0.5), (Ipp8u)( 1.243*SF+0.5), (Ipp8u)( 1.386*SF+0.5),
       (Ipp8u)( 1.546*SF+0.5), (Ipp8u)( 1.723*SF+0.5), (Ipp8u)( 1.922*SF+0.5), (Ipp8u)( 2.143*SF+0.5),
       (Ipp8u)( 2.389*SF+0.5), (Ipp8u)( 2.664*SF+0.5), (Ipp8u)( 2.970*SF+0.5), (Ipp8u)( 3.311*SF+0.5),
       (Ipp8u)( 3.692*SF+0.5), (Ipp8u)( 4.117*SF+0.5), (Ipp8u)( 4.590*SF+0.5), (Ipp8u)( 5.118*SF+0.5),
       (Ipp8u)( 5.707*SF+0.5), (Ipp8u)( 6.363*SF+0.5), (Ipp8u)( 7.095*SF+0.5), (Ipp8u)( 7.911*SF+0.5),
       (Ipp8u)( 8.821*SF+0.5), (Ipp8u)( 9.835*SF+0.5), (Ipp8u)(10.966*SF+0.5), (Ipp8u)(12.227*SF+0.5),
       (Ipp8u)(13.633*SF+0.5), (Ipp8u)(15.201*SF+0.5), (Ipp8u)(16.949*SF+0.5), (Ipp8u)(18.898*SF+0.5),
       (Ipp8u)(21.072*SF+0.5), (Ipp8u)(23.495*SF+0.5), (Ipp8u)(26.197*SF+0.5), (Ipp8u)(29.209*SF+0.5)
};

#undef SF

const Ipp32s mp4_Inter_Favor[32] = {
    0, 10, 29, 54, 85, 121, 160, 204, 251, 301, 354, 411, 470, 532, 597, 665, 735, 807,
    882, 959, 1038, 1120, 1204, 1290, 1378, 1468, 1560, 1654, 1750, 1848, 1947, 2049
};

// table B-13
const Ipp8u mp4_VLC_DCSIZE_TB13_len[13] = {
    3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11
};

// table B-14
const Ipp8u mp4_VLC_DCSIZE_TB14_len[13] = {
    2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
};

// table B-16
static const int l0_offs_TB16[15] = {
    0, 27, 37, 42, 46, 49, 52, 55, 58, 60, 62, 63, 64, 65, 66
};
static const int l0_lmax_TB16[15] = {
    27, 10, 5, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1
};
static const int l1_offs_TB16[21] = {
    67, 75, 78, 80, 82, 84, 86, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101
};
static const int l1_lmax_TB16[21] = {
    8, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
static const mp4_VLC vlc_TB16[102] = {
    {0x04,  3}, {0x0c,  4}, {0x1e,  5}, {0x1a,  6}, {0x18,  6}, {0x2a,  7}, {0x26,  7}, {0x24,  7},
    {0x2e,  8}, {0x3e,  9}, {0x3c,  9}, {0x3a,  9}, {0x4a, 10}, {0x48, 10}, {0x46, 10}, {0x42, 10},
    {0x42, 11}, {0x40, 11}, {0x1e, 11}, {0x1c, 11}, {0x0e, 12}, {0x0c, 12}, {0x40, 12}, {0x42, 12},

⌨️ 快捷键说明

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