2016-01-30 17:39:48 +00: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 "libavutil/avassert.h"
|
|
|
|
|
|
|
|
#include "avcodec.h"
|
2018-07-13 22:26:08 +00:00
|
|
|
#include "bytestream.h"
|
2016-01-30 17:39:48 +00:00
|
|
|
#include "get_bits.h"
|
2017-10-17 23:26:00 +00:00
|
|
|
#include "vlc.h"
|
2016-01-30 17:39:48 +00:00
|
|
|
|
2016-01-30 17:39:48 +00:00
|
|
|
#define VLC_BITS 9
|
|
|
|
#define SUBBAND_COUNT 10
|
2016-01-30 17:39:48 +00:00
|
|
|
|
|
|
|
typedef struct CFHD_RL_VLC_ELEM {
|
|
|
|
int16_t level;
|
|
|
|
int8_t len;
|
|
|
|
uint16_t run;
|
|
|
|
} CFHD_RL_VLC_ELEM;
|
|
|
|
|
|
|
|
#define DWT_LEVELS 3
|
|
|
|
|
|
|
|
typedef struct SubBand {
|
|
|
|
int level;
|
|
|
|
int orientation;
|
2016-01-30 17:39:48 +00:00
|
|
|
ptrdiff_t stride;
|
2016-01-30 17:39:48 +00:00
|
|
|
int a_width;
|
|
|
|
int width;
|
|
|
|
int a_height;
|
|
|
|
int height;
|
|
|
|
int pshift;
|
|
|
|
int quant;
|
|
|
|
uint8_t *ibuf;
|
|
|
|
} SubBand;
|
|
|
|
|
|
|
|
typedef struct Plane {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
ptrdiff_t stride;
|
|
|
|
|
|
|
|
int16_t *idwt_buf;
|
|
|
|
int16_t *idwt_tmp;
|
|
|
|
|
|
|
|
/* TODO: merge this into SubBand structure */
|
2016-01-30 17:39:48 +00:00
|
|
|
int16_t *subband[SUBBAND_COUNT];
|
2016-01-30 17:39:48 +00:00
|
|
|
int16_t *l_h[8];
|
|
|
|
|
|
|
|
SubBand band[DWT_LEVELS][4];
|
|
|
|
} Plane;
|
|
|
|
|
2018-05-22 15:40:21 +00:00
|
|
|
typedef struct Peak {
|
|
|
|
int level;
|
|
|
|
int offset;
|
2018-07-13 22:26:08 +00:00
|
|
|
GetByteContext base;
|
2018-05-22 15:40:21 +00:00
|
|
|
} Peak;
|
|
|
|
|
2016-01-30 17:39:48 +00: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;
|
|
|
|
|
|
|
|
GetBitContext gb;
|
|
|
|
|
|
|
|
int coded_width;
|
|
|
|
int coded_height;
|
2017-10-18 01:05:09 +00:00
|
|
|
int cropped_height;
|
2016-01-30 17:39:48 +00:00
|
|
|
enum AVPixelFormat coded_format;
|
2018-05-22 15:40:21 +00:00
|
|
|
int progressive;
|
2016-01-30 17:39:48 +00:00
|
|
|
|
|
|
|
int a_width;
|
|
|
|
int a_height;
|
2016-02-15 21:39:27 +00:00
|
|
|
int a_format;
|
2016-01-30 17:39:48 +00:00
|
|
|
|
2016-01-30 17:39:48 +00:00
|
|
|
int bpc; // bits per channel/component
|
2016-01-30 17:39:48 +00:00
|
|
|
int channel_cnt;
|
|
|
|
int subband_cnt;
|
|
|
|
int channel_num;
|
|
|
|
uint8_t lowpass_precision;
|
|
|
|
uint16_t quantisation;
|
|
|
|
int wavelet_depth;
|
|
|
|
int pshift;
|
|
|
|
|
|
|
|
int codebook;
|
2018-05-22 15:40:21 +00:00
|
|
|
int difference_coding;
|
2016-01-30 17:39:48 +00:00
|
|
|
int subband_num;
|
|
|
|
int level;
|
|
|
|
int subband_num_actual;
|
|
|
|
|
|
|
|
uint8_t prescale_shift[3];
|
|
|
|
Plane plane[4];
|
2018-05-22 15:40:21 +00:00
|
|
|
Peak peak;
|
2016-01-30 17:39:48 +00:00
|
|
|
} CFHDContext;
|
|
|
|
|
|
|
|
int ff_cfhd_init_vlcs(CFHDContext *s);
|
|
|
|
|
|
|
|
#endif /* AVCODEC_CFHD_H */
|