opencv/3rdparty/openjpeg/openjp2/t1_ht_generate_luts.c
2023-05-24 21:02:11 +03:00

974 lines
36 KiB
C

//***************************************************************************/
// This software is released under the 2-Clause BSD license, included
// below.
//
// Copyright (c) 2021, Aous Naman
// Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
// Copyright (c) 2021, The University of New South Wales, Australia
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. 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.
//
// 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 (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//***************************************************************************/
// This file is part of the OpenJpeg software implementation.
// File: t1_ht_generate_luts.c
// Author: Aous Naman
// Date: 01 September 2021
//***************************************************************************/
#include <string.h>
#include <stdio.h>
#include <assert.h>
typedef int OPJ_BOOL;
#define OPJ_TRUE 1
#define OPJ_FALSE 0
#include "opj_stdint.h"
typedef int8_t OPJ_INT8;
typedef uint8_t OPJ_UINT8;
typedef int16_t OPJ_INT16;
typedef uint16_t OPJ_UINT16;
typedef int32_t OPJ_INT32;
typedef uint32_t OPJ_UINT32;
typedef int64_t OPJ_INT64;
typedef uint64_t OPJ_UINT64;
//************************************************************************/
/** @brief HT decoding tables, as given in the standard
*
* Data in the table is arranged in this format:
* c_q is the context for a quad
* rho is the signficance pattern for a quad
* u_off indicate if u value is 0 (u_off is 0), or communicated
* e_k, e_1 EMB patterns
* cwd VLC codeword
* cwd VLC codeword length
*/
typedef struct vlc_src_table {
int c_q, rho, u_off, e_k, e_1, cwd, cwd_len;
}
vlc_src_table_t;
// initial quad rows
static vlc_src_table_t tbl0[] = {
{0, 0x1, 0x0, 0x0, 0x0, 0x06, 4},
{0, 0x1, 0x1, 0x1, 0x1, 0x3F, 7},
{0, 0x2, 0x0, 0x0, 0x0, 0x00, 3},
{0, 0x2, 0x1, 0x2, 0x2, 0x7F, 7},
{0, 0x3, 0x0, 0x0, 0x0, 0x11, 5},
{0, 0x3, 0x1, 0x2, 0x2, 0x5F, 7},
{0, 0x3, 0x1, 0x3, 0x1, 0x1F, 7},
{0, 0x4, 0x0, 0x0, 0x0, 0x02, 3},
{0, 0x4, 0x1, 0x4, 0x4, 0x13, 6},
{0, 0x5, 0x0, 0x0, 0x0, 0x0E, 5},
{0, 0x5, 0x1, 0x4, 0x4, 0x23, 6},
{0, 0x5, 0x1, 0x5, 0x1, 0x0F, 7},
{0, 0x6, 0x0, 0x0, 0x0, 0x03, 6},
{0, 0x6, 0x1, 0x0, 0x0, 0x6F, 7},
{0, 0x7, 0x0, 0x0, 0x0, 0x2F, 7},
{0, 0x7, 0x1, 0x2, 0x2, 0x4F, 7},
{0, 0x7, 0x1, 0x2, 0x0, 0x0D, 6},
{0, 0x8, 0x0, 0x0, 0x0, 0x04, 3},
{0, 0x8, 0x1, 0x8, 0x8, 0x3D, 6},
{0, 0x9, 0x0, 0x0,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{7, 0xC, 0x0, 0x0, 0x0, 0x39, 6},
{7, 0xC, 0x1, 0x0, 0x0, 0x19, 6},
{7, 0xD, 0x0, 0x0, 0x0, 0x0C, 5},
{7, 0xD, 0x1, 0xD, 0x1, 0x47, 7},
{7, 0xD, 0x1, 0x1, 0x1, 0x07, 7},
{7, 0xD, 0x1, 0x5, 0x4, 0x09, 6},
{7, 0xD, 0x1, 0xD, 0x8, 0x1B, 7},
{7, 0xE, 0x0, 0x0, 0x0, 0x31, 6},
{7, 0xE, 0x1, 0xE, 0x2, 0x3B, 7},
{7, 0xE, 0x1, 0x2, 0x2, 0x5B, 7},
{7, 0xE, 0x1, 0xA, 0x8, 0x3E, 6},
{7, 0xE, 0x1, 0xE, 0x4, 0x0B, 7},
{7, 0xF, 0x0, 0x0, 0x0, 0x00, 3},
{7, 0xF, 0x1, 0xF, 0xF, 0x6B, 7},
{7, 0xF, 0x1, 0xF, 0x7, 0x2B, 7},
{7, 0xF, 0x1, 0xF, 0xB, 0x4B, 7},
{7, 0xF, 0x1, 0xF, 0x3, 0x11, 6},
{7, 0xF, 0x1, 0x7, 0x6, 0x21, 6},
{7, 0xF, 0x1, 0xF, 0xA, 0x01, 6},
{7, 0xF, 0x1, 0xF, 0x2, 0x0A, 5},
{7, 0xF, 0x1, 0xB, 0x9, 0x1E, 6},
{7, 0xF, 0x1, 0xF, 0xC, 0x0E, 6},
{7, 0xF, 0x1, 0xF, 0x8, 0x12, 5},
{7, 0xF, 0x1, 0xF, 0x5, 0x2E, 6},
{7, 0xF, 0x1, 0xF, 0x1, 0x02, 5},
{7, 0xF, 0x1, 0xF, 0x4, 0x1C, 5}
};
//************************************************************************/
/** @defgroup vlc_decoding_tables_grp VLC decoding tables
* @{
* VLC tables to decode VLC codewords to these fields: (in order) \n
* \li \c cwd_len : 3bits -> the codeword length of the VLC codeword;
* the VLC cwd is in the LSB of bitstream \n
* \li \c u_off : 1bit -> u_offset, which is 1 if u value is not 0 \n
* \li \c rho : 4bits -> significant samples within a quad \n
* \li \c e_1 : 4bits -> EMB e_1 \n
* \li \c e_k : 4bits -> EMB e_k \n
* \n
* The table index is 10 bits and composed of two parts: \n
* The 7 LSBs contain a codeword which might be shorter than 7 bits;
* this word is the next decoable bits in the bitstream. \n
* The 3 MSB is the context of for the codeword. \n
*/
/// @brief vlc_tbl0 contains decoding information for initial row of quads
int vlc_tbl0[1024] = { 0 };
/// @brief vlc_tbl1 contains decoding information for non-initial row of
/// quads
int vlc_tbl1[1024] = { 0 };
/// @}
//************************************************************************/
/** @ingroup vlc_decoding_tables_grp
* @brief Initializes vlc_tbl0 and vlc_tbl1 tables, from table0.h and
* table1.h
*/
OPJ_BOOL vlc_init_tables()
{
const OPJ_BOOL debug = OPJ_FALSE; //useful for checking
// number of entries in the table
size_t tbl0_size = sizeof(tbl0) / sizeof(vlc_src_table_t);
// number of entries in the table
size_t tbl1_size = sizeof(tbl1) / sizeof(vlc_src_table_t);
if (debug) {
memset(vlc_tbl0, 0, sizeof(vlc_tbl0)); //unnecessary
}
// this is to convert table entries into values for decoder look up
// There can be at most 1024 possibilities, not all of them are valid.
//
for (int i = 0; i < 1024; ++i) {
int cwd = i & 0x7F; // from i extract codeword
int c_q = i >> 7; // from i extract context
// See if this case exist in the table, if so then set the entry in
// vlc_tbl0
for (size_t j = 0; j < tbl0_size; ++j)
if (tbl0[j].c_q == c_q) // this is an and operation
if (tbl0[j].cwd == (cwd & ((1 << tbl0[j].cwd_len) - 1))) {
if (debug) {
assert(vlc_tbl0[i] == 0);
}
// Put this entry into the table
vlc_tbl0[i] = (tbl0[j].rho << 4) | (tbl0[j].u_off << 3)
| (tbl0[j].e_k << 12) | (tbl0[j].e_1 << 8) | tbl0[j].cwd_len;
}
}
if (debug) {
memset(vlc_tbl1, 0, sizeof(vlc_tbl1)); //unnecessary
}
// this the same as above but for non-initial rows
for (int i = 0; i < 1024; ++i) {
int cwd = i & 0x7F; //7 bits
int c_q = i >> 7;
for (size_t j = 0; j < tbl1_size; ++j)
if (tbl1[j].c_q == c_q) // this is an and operation
if (tbl1[j].cwd == (cwd & ((1 << tbl1[j].cwd_len) - 1))) {
if (debug) {
assert(vlc_tbl1[i] == 0);
}
vlc_tbl1[i] = (tbl1[j].rho << 4) | (tbl1[j].u_off << 3)
| (tbl1[j].e_k << 12) | (tbl1[j].e_1 << 8) | tbl1[j].cwd_len;
}
}
return OPJ_TRUE;
}
//************************************************************************/
/** @ingroup vlc_decoding_tables_grp
* @brief Initializes VLC tables vlc_tbl0 and vlc_tbl1
*/
OPJ_BOOL vlc_tables_initialized = OPJ_FALSE;