2016-01-30 19:39:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Kieran Kunhya
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVCODEC_CFHD_H
|
|
|
|
#define AVCODEC_CFHD_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "avcodec.h"
|
2018-07-14 00:26:08 +02:00
|
|
|
#include "bytestream.h"
|
2016-01-30 19:39:48 +02:00
|
|
|
#include "get_bits.h"
|
2017-10-18 01:26:00 +02:00
|
|
|
#include "vlc.h"
|
2020-08-09 17:47:34 +02:00
|
|
|
#include "cfhddsp.h"
|
2016-01-30 19:39:48 +02:00
|
|
|
|
2020-07-25 18:18:18 +02:00
|
|
|
enum CFHDParam {
|
|
|
|
SampleType = 1,
|
|
|
|
SampleIndexTable = 2,
|
|
|
|
BitstreamMarker = 4,
|
2020-08-09 13:21:34 +02:00
|
|
|
VersionMajor = 5,
|
|
|
|
VersionMinor = 6,
|
|
|
|
VersionRevision = 7,
|
|
|
|
VersionEdit = 8,
|
2020-07-25 18:18:18 +02:00
|
|
|
TransformType = 10,
|
|
|
|
NumFrames = 11,
|
|
|
|
ChannelCount = 12,
|
|
|
|
WaveletCount = 13,
|
|
|
|
SubbandCount = 14,
|
|
|
|
NumSpatial = 15,
|
|
|
|
FirstWavelet = 16,
|
|
|
|
GroupTrailer = 18,
|
2020-08-04 14:45:48 +02:00
|
|
|
FrameType = 19,
|
2020-07-25 18:18:18 +02:00
|
|
|
ImageWidth = 20,
|
|
|
|
ImageHeight = 21,
|
2020-08-04 14:45:48 +02:00
|
|
|
FrameIndex = 23,
|
2020-07-25 18:18:18 +02:00
|
|
|
LowpassSubband = 25,
|
|
|
|
NumLevels = 26,
|
|
|
|
LowpassWidth = 27,
|
|
|
|
LowpassHeight = 28,
|
|
|
|
PixelOffset = 33,
|
|
|
|
LowpassQuantization=34,
|
|
|
|
LowpassPrecision = 35,
|
|
|
|
WaveletType = 37,
|
|
|
|
WaveletNumber = 38,
|
|
|
|
WaveletLevel = 39,
|
|
|
|
NumBands = 40,
|
|
|
|
HighpassWidth = 41,
|
|
|
|
HighpassHeight = 42,
|
|
|
|
LowpassBorder = 43,
|
|
|
|
HighpassBorder = 44,
|
|
|
|
LowpassScale = 45,
|
|
|
|
LowpassDivisor = 46,
|
|
|
|
SubbandNumber = 48,
|
|
|
|
BandWidth = 49,
|
|
|
|
BandHeight = 50,
|
|
|
|
SubbandBand = 51,
|
|
|
|
BandEncoding = 52,
|
|
|
|
Quantization = 53,
|
|
|
|
BandScale = 54,
|
|
|
|
BandHeader = 55,
|
|
|
|
BandTrailer = 56,
|
|
|
|
ChannelNumber = 62,
|
|
|
|
SampleFlags = 68,
|
2020-08-04 11:25:25 +02:00
|
|
|
FrameNumber = 69,
|
2020-07-25 18:18:18 +02:00
|
|
|
Precision = 70,
|
2020-08-03 22:41:45 +02:00
|
|
|
InputFormat = 71,
|
2020-07-25 18:18:18 +02:00
|
|
|
BandCodingFlags = 72,
|
2020-08-29 21:45:54 +02:00
|
|
|
PeakLevel = 74,
|
|
|
|
PeakOffsetLow = 75,
|
|
|
|
PeakOffsetHigh = 76,
|
2020-08-09 13:21:34 +02:00
|
|
|
Version = 79,
|
2020-08-04 14:45:48 +02:00
|
|
|
BandSecondPass = 82,
|
2020-07-25 18:18:18 +02:00
|
|
|
PrescaleTable = 83,
|
|
|
|
EncodedFormat = 84,
|
2020-08-29 21:45:54 +02:00
|
|
|
DisplayHeight = 85,
|
2020-07-25 18:18:18 +02:00
|
|
|
ChannelWidth = 104,
|
|
|
|
ChannelHeight = 105,
|
|
|
|
};
|
|
|
|
|
2016-01-30 19:39:48 +02:00
|
|
|
#define VLC_BITS 9
|
|
|
|
#define SUBBAND_COUNT 10
|
2020-08-04 14:45:48 +02:00
|
|
|
#define SUBBAND_COUNT_3D 17
|
2016-01-30 19:39:48 +02:00
|
|
|
|
|
|
|
typedef struct CFHD_RL_VLC_ELEM {
|
|
|
|
int16_t level;
|
|
|
|
int8_t len;
|
|
|
|
uint16_t run;
|
|
|
|
} CFHD_RL_VLC_ELEM;
|
|
|
|
|
|
|
|
#define DWT_LEVELS 3
|
2020-08-04 14:45:48 +02:00
|
|
|
#define DWT_LEVELS_3D 6
|
2016-01-30 19:39:48 +02:00
|
|
|
|
|
|
|
typedef struct SubBand {
|
2016-01-30 19:39:48 +02:00
|
|
|
ptrdiff_t stride;
|
2016-01-30 19:39:48 +02:00
|
|
|
int a_width;
|
|
|
|
int width;
|
|
|
|
int a_height;
|
|
|
|
int height;
|
2021-04-03 16:04:48 +02:00
|
|
|
int8_t read_ok;
|
2016-01-30 19:39:48 +02:00
|
|
|
} SubBand;
|
|
|
|
|
|
|
|
typedef struct Plane {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
ptrdiff_t stride;
|
|
|
|
|
|
|
|
int16_t *idwt_buf;
|
|
|
|
int16_t *idwt_tmp;
|
2020-08-04 14:45:48 +02:00
|
|
|
int idwt_size;
|
2016-01-30 19:39:48 +02:00
|
|
|
|
|
|
|
/* TODO: merge this into SubBand structure */
|
2020-08-04 14:45:48 +02:00
|
|
|
int16_t *subband[SUBBAND_COUNT_3D];
|
|
|
|
int16_t *l_h[10];
|
2016-01-30 19:39:48 +02:00
|
|
|
|
2020-08-04 14:45:48 +02:00
|
|
|
SubBand band[DWT_LEVELS_3D][4];
|
2016-01-30 19:39:48 +02:00
|
|
|
} Plane;
|
|
|
|
|
2018-05-22 17:40:21 +02:00
|
|
|
typedef struct Peak {
|
|
|
|
int level;
|
|
|
|
int offset;
|
2018-07-14 00:26:08 +02:00
|
|
|
GetByteContext base;
|
2018-05-22 17:40:21 +02:00
|
|
|
} Peak;
|
|
|
|
|
2016-01-30 19:39:48 +02:00
|
|
|
typedef struct CFHDContext {
|
|
|
|
AVCodecContext *avctx;
|
|
|
|
|
|
|
|
CFHD_RL_VLC_ELEM table_9_rl_vlc[2088];
|
|
|
|
VLC vlc_9;
|
|
|
|
|
|
|
|
CFHD_RL_VLC_ELEM table_18_rl_vlc[4572];
|
|
|
|
VLC vlc_18;
|
|
|
|
|
2020-08-03 09:33:36 +02:00
|
|
|
int lut[2][256];
|
|
|
|
|
2016-01-30 19:39:48 +02:00
|
|
|
GetBitContext gb;
|
|
|
|
|
2020-08-04 14:45:48 +02:00
|
|
|
int planes;
|
|
|
|
int frame_type;
|
|
|
|
int frame_index;
|
|
|
|
int sample_type;
|
|
|
|
int transform_type;
|
2016-01-30 19:39:48 +02:00
|
|
|
int coded_width;
|
|
|
|
int coded_height;
|
2017-10-18 03:05:09 +02:00
|
|
|
int cropped_height;
|
2016-01-30 19:39:48 +02:00
|
|
|
enum AVPixelFormat coded_format;
|
2018-05-22 17:40:21 +02:00
|
|
|
int progressive;
|
2016-01-30 19:39:48 +02:00
|
|
|
|
|
|
|
int a_width;
|
|
|
|
int a_height;
|
2016-02-15 23:39:27 +02:00
|
|
|
int a_format;
|
2021-04-03 14:40:50 +02:00
|
|
|
int a_transform_type;
|
2016-01-30 19:39:48 +02:00
|
|
|
|
2016-01-30 19:39:48 +02:00
|
|
|
int bpc; // bits per channel/component
|
2016-01-30 19:39:48 +02:00
|
|
|
int channel_cnt;
|
|
|
|
int subband_cnt;
|
2020-08-04 14:45:48 +02:00
|
|
|
int band_encoding;
|
2016-01-30 19:39:48 +02:00
|
|
|
int channel_num;
|
|
|
|
uint8_t lowpass_precision;
|
|
|
|
uint16_t quantisation;
|
|
|
|
|
|
|
|
int codebook;
|
2018-05-22 17:40:21 +02:00
|
|
|
int difference_coding;
|
2016-01-30 19:39:48 +02:00
|
|
|
int subband_num;
|
|
|
|
int level;
|
|
|
|
int subband_num_actual;
|
|
|
|
|
2020-08-09 13:02:46 +02:00
|
|
|
uint8_t prescale_table[8];
|
2016-01-30 19:39:48 +02:00
|
|
|
Plane plane[4];
|
2018-05-22 17:40:21 +02:00
|
|
|
Peak peak;
|
2020-08-09 17:47:34 +02:00
|
|
|
|
|
|
|
CFHDDSPContext dsp;
|
2016-01-30 19:39:48 +02:00
|
|
|
} CFHDContext;
|
|
|
|
|
|
|
|
int ff_cfhd_init_vlcs(CFHDContext *s);
|
|
|
|
|
|
|
|
#endif /* AVCODEC_CFHD_H */
|