mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
149 lines
5.4 KiB
C
149 lines
5.4 KiB
C
#ifndef TABLES_H_
|
|
#define TABLES_H_
|
|
/*****************************************************************************
|
|
* This file is part of uvg266 VVC encoder.
|
|
*
|
|
* Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
* are permitted provided that the following conditions are met:
|
|
*
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
|
* list of conditions and the following disclaimer.
|
|
*
|
|
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
* list of conditions and the following disclaimer in the documentation and/or
|
|
* other materials provided with the distribution.
|
|
*
|
|
* * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its
|
|
* contributors may be used to endorse or promote products derived from
|
|
* this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
* INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
* INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
****************************************************************************/
|
|
|
|
/**
|
|
* \ingroup Reconstruction
|
|
* \file
|
|
* Various tables.
|
|
*/
|
|
|
|
#include "global.h" // IWYU pragma: keep
|
|
|
|
|
|
static const uint32_t g_go_rice_pars[32] =
|
|
{
|
|
0, 0, 0, 0, 0, 0, 0, 1,
|
|
1, 1, 1, 1, 1, 1, 2, 2,
|
|
2, 2, 2, 2, 2, 2, 2, 2,
|
|
2, 2, 2, 2, 3, 3, 3, 3
|
|
};
|
|
|
|
static const uint32_t g_go_rice_pos0[3][32] =
|
|
{
|
|
{ 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8 },
|
|
{ 1, 1, 1, 1, 2, 3, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16 },
|
|
{ 1, 1, 2, 2, 2, 3, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16 }
|
|
};
|
|
|
|
/***
|
|
* List of indices for 4x4 coefficient groups within 8x8 transform block.
|
|
* First index: 0 = diagonal, 1 = vertical, 2 horizontal scan pattern.
|
|
* Second index: (log2 - 2) size of transform block. 4x4 .. 32x32
|
|
*/
|
|
static const uint32_t g_sig_last_scan_8x8[3][4] =
|
|
{ {0, 2, 1, 3},
|
|
{0, 1, 2, 3},
|
|
{0, 2, 1, 3}
|
|
};
|
|
|
|
/***
|
|
* List of indices for 4x4 coefficient groups within 16x16 transform block.
|
|
*/
|
|
static const uint32_t g_sig_last_scan_16x16[16] = {
|
|
0, 4, 1, 8,
|
|
5, 2, 12, 9,
|
|
6, 3, 13, 10,
|
|
7, 14, 11, 15
|
|
};
|
|
|
|
/***
|
|
* List of indices for 4x4 coefficient groups within 32x32 transform block.
|
|
*/
|
|
static const uint32_t g_sig_last_scan_32x32[64] = {
|
|
0, 8, 1, 16, 9, 2, 24, 17,
|
|
10, 3, 32, 25, 18, 11, 4, 40,
|
|
33, 26, 19, 12, 5, 48, 41, 34,
|
|
27, 20, 13, 6, 56, 49, 42, 35,
|
|
28, 21, 14, 7, 57, 50, 43, 36,
|
|
29, 22, 15, 58, 51, 44, 37, 30,
|
|
23, 59, 52, 45, 38, 31, 60, 53,
|
|
46, 39, 61, 54, 47, 62, 55, 63
|
|
};
|
|
|
|
/**
|
|
* List of pointers to coefficient group mappings.
|
|
* First index: (log2 - 1) of transform block size
|
|
* Second index: scan pattern 0 = diagonal, 1 = horizontal, 2 = vertical
|
|
*/
|
|
static const uint32_t * const g_sig_last_scan_cg[5][3] = {
|
|
{ g_sig_last_scan_8x8[0], g_sig_last_scan_8x8[1], g_sig_last_scan_8x8[2] }, // 4x4, only first element is used
|
|
{ g_sig_last_scan_8x8[0], g_sig_last_scan_8x8[1], g_sig_last_scan_8x8[2] },
|
|
{ g_sig_last_scan_8x8[0], g_sig_last_scan_8x8[1], g_sig_last_scan_8x8[2] },
|
|
{ g_sig_last_scan_16x16, 0, 0 },
|
|
{ g_sig_last_scan_32x32, 0, 0 }
|
|
};
|
|
|
|
|
|
static const uint32_t g_log2_sbb_size[7 + 1][7 + 1][2] =
|
|
//===== luma/chroma =====
|
|
{
|
|
{ { 0,0 },{ 0,1 },{ 0,2 },{ 0,3 },{ 0,4 },{ 0,4 },{ 0,4 },{ 0,4 } },
|
|
{ { 1,0 },{ 1,1 },{ 1,1 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 } },
|
|
{ { 2,0 },{ 1,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
|
|
{ { 3,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
|
|
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
|
|
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
|
|
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } },
|
|
{ { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }
|
|
};
|
|
|
|
|
|
typedef enum
|
|
{
|
|
SCAN_DIAG = 0 // up-right diagonal scan
|
|
//SCAN_HOR, // horizontal first scan
|
|
//SCAN_VER // vertical first scan
|
|
} coeff_scan_order_t;
|
|
|
|
|
|
/**
|
|
* List of mappings for coefficients within a transform block.
|
|
* First index: scan pattern 0 = diagonal, 1 = horizontal, 2 = vertical
|
|
* Second index: (log2 - 1) size of transform block. 2x2 .. 32x32
|
|
*/
|
|
extern const uint32_t* const uvg_g_sig_last_scan[3][5];
|
|
extern const int8_t uvg_g_convert_to_bit[LCU_WIDTH + 1];
|
|
extern const int8_t uvg_g_convert_to_log2[LCU_WIDTH + 1];
|
|
extern const uint32_t uvg_g_log2_sbb_size[7 + 1][7 + 1][2];
|
|
|
|
#define SCAN_GROUP_TYPES 2
|
|
#define MAX_LOG2_INDEX 7
|
|
|
|
#define SCAN_GROUP_UNGROUPED 0
|
|
#define SCAN_GROUP_4X4 1
|
|
|
|
uint32_t* uvg_get_scan_order_table(int scan_group, int scan_type, int log2_w, int log2_h);
|
|
|
|
#endif //TABLES_H_
|