?? mp4_tables.c
字號:
/**************************************************************************
* *
* This code has been developed by Andrea Graziani. This software is an *
* implementation of a part of one or more MPEG-4 Video tools as *
* specified in ISO/IEC 14496-2 standard. Those intending to use this *
* software module in hardware or software products are advised that its *
* use may infringe existing patents or copyrights, and any such use *
* would be at such party's own risk. The original developer of this *
* software module and his/her company, and subsequent editors and their *
* companies (including Project Mayo), will have no liability for use of *
* this software or modifications or derivatives thereof. *
* *
* Project Mayo gives users of the Codec a license to this software *
* module or modifications thereof for use in hardware or software *
* products claiming conformance to the MPEG-4 Video Standard as *
* described in the Open DivX license. *
* *
* The complete Open DivX license can be found at *
* http://www.projectmayo.com/opendivx/license.php *
* *
**************************************************************************/
/**
* Copyright (C) 2001 - Project Mayo
*
* Andrea Graziani (Ag)
* Jonathan White
*
* DivX Advanced Research Center <darc@projectmayo.com>
*
**/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "portab.h"
#include "mp4_vars.h"
extern unsigned int zig_zag_scan[64];
extern unsigned int alternate_horizontal_scan[64];
extern unsigned int alternate_vertical_scan[64];
extern unsigned int intra_quant_matrix[64];
extern unsigned int nonintra_quant_matrix[64];
extern unsigned int msk[33];
extern int roundtab[16];
extern int saiAcLeftIndex[8];
extern int DQtab[4];
extern tab_type MCBPCtabIntra[32];
extern tab_type MCBPCtabInter[256];
extern tab_type CBPYtab[48];
extern tab_type MVtab0[14];
extern tab_type MVtab1[96];
extern tab_type MVtab2[124];
extern tab_type tableB16_1[112];
extern tab_type tableB16_2[96];
extern tab_type tableB16_3[120];
extern tab_type tableB17_1[112];
extern tab_type tableB17_2[96];
extern tab_type tableB17_3[120];
void save_tables(MP4_TABLES * tables)
{
// FILE * ftables;
memcpy(tables->zig_zag_scan, zig_zag_scan, sizeof(zig_zag_scan));
memcpy(tables->alternate_vertical_scan, alternate_vertical_scan, sizeof(alternate_vertical_scan));
memcpy(tables->alternate_horizontal_scan, alternate_horizontal_scan, sizeof(alternate_horizontal_scan));
memcpy(tables->intra_quant_matrix, intra_quant_matrix, sizeof(intra_quant_matrix));
memcpy(tables->nonintra_quant_matrix, nonintra_quant_matrix, sizeof(nonintra_quant_matrix));
memcpy(tables->msk, msk, sizeof(msk));
memcpy(tables->roundtab, roundtab, sizeof(roundtab));
memcpy(tables->saiAcLeftIndex, saiAcLeftIndex, sizeof( saiAcLeftIndex));
memcpy(tables->DQtab, DQtab, sizeof( DQtab));
memcpy(tables->MCBPCtabIntra, MCBPCtabIntra, sizeof( MCBPCtabIntra));
memcpy(tables->MCBPCtabInter, MCBPCtabInter, sizeof( MCBPCtabInter));
memcpy(tables->CBPYtab, CBPYtab, sizeof( CBPYtab));
memcpy(tables->MVtab0, MVtab0, sizeof( MVtab0));
memcpy(tables->MVtab1, MVtab1, sizeof( MVtab1));
memcpy(tables->MVtab2, MVtab2, sizeof( MVtab2));
memcpy(tables->tableB16_1, tableB16_1, sizeof( tableB16_1));
memcpy(tables->tableB16_2, tableB16_2, sizeof( tableB16_2));
memcpy(tables->tableB16_3, tableB16_3, sizeof( tableB16_3));
memcpy(tables->tableB17_1, tableB17_1, sizeof( tableB17_1));
memcpy(tables->tableB17_2, tableB17_2, sizeof( tableB17_2));
memcpy(tables->tableB17_3, tableB17_3, sizeof( tableB17_3));
// ftables = fopen("mp4_tables.bin", "wb");
// fwrite(tables, sizeof(char), sizeof(MP4_TABLES), ftables);
// fclose(ftables);
}
// zig-zag scan
unsigned int zig_zag_scan[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
};
// other scan orders
unsigned int alternate_horizontal_scan[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
};
unsigned int alternate_vertical_scan[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
};
unsigned int intra_quant_matrix[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
};
unsigned int nonintra_quant_matrix[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
};
// to mask the n least significant bits of an integer
unsigned int msk[33] =
{
0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
0xffffffff
};
int roundtab[16] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
int saiAcLeftIndex[8] =
{
0, 8,16,24,32,40,48,56
};
int DQtab[4] = {
-1, -2, 1, 2
};
tab_type MCBPCtabIntra[32] = {
{-1,0},
{20,6}, {36,6}, {52,6}, {4,4}, {4,4}, {4,4},
{4,4}, {19,3}, {19,3}, {19,3}, {19,3}, {19,3},
{19,3}, {19,3}, {19,3}, {35,3}, {35,3}, {35,3},
{35,3}, {35,3}, {35,3}, {35,3}, {35,3}, {51,3},
{51,3}, {51,3}, {51,3}, {51,3}, {51,3}, {51,3},
{51,3},
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -