38 #define SUBBAND_COUNT 10
78 int64_t abslevel = abs(level);
79 return (abslevel + ((768 * abslevel * abslevel * abslevel) / (255 * 255 * 255))) *
FFSIGN(level) * quantisation;
82 static inline void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride,
88 for (i = 0; i <
len; i++) {
90 tmp = (11*low[0*low_stride] - 4*low[1*low_stride] + low[2*low_stride] + 4) >> 3;
91 output[(2*i+0)*out_stride] = (tmp + high[0*high_stride]) >> 1;
95 tmp = ( 5*low[0*low_stride] + 4*low[1*low_stride] - low[2*low_stride] + 4) >> 3;
96 output[(2*i+1)*out_stride] = (tmp - high[0*high_stride]) >> 1;
99 }
else if (i == len-1) {
100 tmp = ( 5*low[i*low_stride] + 4*low[(i-1)*low_stride] - low[(i-2)*low_stride] + 4) >> 3;
101 output[(2*i+0)*out_stride] = (tmp + high[i*high_stride]) >> 1;
105 tmp = (11*low[i*low_stride] - 4*low[(i-1)*low_stride] + low[(i-2)*low_stride] + 4) >> 3;
106 output[(2*i+1)*out_stride] = (tmp - high[i*high_stride]) >> 1;
110 tmp = (low[(i-1)*low_stride] - low[(i+1)*low_stride] + 4) >> 3;
111 output[(2*i+0)*out_stride] = (tmp + low[i*low_stride] + high[i*high_stride]) >> 1;
115 tmp = (low[(i+1)*low_stride] - low[(i-1)*low_stride] + 4) >> 3;
116 output[(2*i+1)*out_stride] = (tmp + low[i*low_stride] - high[i*high_stride]) >> 1;
125 filter(output, 1, low, 1, high, 1, width, 0);
130 filter(output, 1, low, 1, high, 1, width, clip);
133 static void vert_filter(int16_t *output,
int out_stride, int16_t *low,
int low_stride,
134 int16_t *high,
int high_stride,
int len)
136 filter(output, out_stride, low, low_stride, high, high_stride, len, 0);
144 for (i = 0; i < 3; i++) {
162 for (i = 0; i < 3; i++) {
166 int w8, h8, w4, h4, w2, h2;
167 height =
FFALIGN(height / 8, 2) * 8;
197 for(k = 0; k < 4; k++) {
227 int ret = 0, i, j,
plane, got_buffer = 0;
237 uint16_t tagu = bytestream2_get_be16(&gb);
238 int16_t
tag = (int16_t)tagu;
239 int8_t tag8 = (int8_t)(tagu >> 8);
240 uint16_t abstag = abs(tag);
241 int8_t abs_tag8 = abs(tag8);
242 uint16_t data = bytestream2_get_be16(&gb);
243 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
245 }
else if (tag == 20) {
248 }
else if (tag == 21) {
251 }
else if (tag == 101) {
254 }
else if (tag == 12) {
262 }
else if (tag == 14) {
269 }
else if (tag == 62) {
278 }
else if (tag == 48) {
293 }
else if (tag == 51) {
301 }
else if (tag == 35)
303 else if (tag == 53) {
306 }
else if (tag == 109) {
311 }
else if (tag == 27) {
320 }
else if (tag == 28) {
330 else if (tag == 10) {
337 }
else if (abstag >= 0x4000 && abstag <= 0x40ff) {
338 av_log(avctx,
AV_LOG_DEBUG,
"Small chunk length %"PRIu16
" %s\n", data * 4, tag < 0 ?
"optional" :
"required");
340 }
else if (tag == 23) {
345 }
else if (tag == 2) {
352 for (i = 0; i <
data; i++) {
353 uint16_t tag2 = bytestream2_get_be16(&gb);
354 uint16_t val2 = bytestream2_get_be16(&gb);
357 }
else if (tag == 41) {
366 }
else if (tag == 42) {
374 }
else if (tag == 49) {
383 }
else if (tag == 50) {
391 }
else if (tag == 71) {
394 }
else if (tag == 72) {
397 }
else if (tag == 70) {
400 if (!(s->
bpc == 10 || s->
bpc == 12)) {
405 }
else if (tag == 84) {
445 if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||
452 av_log(avctx,
AV_LOG_DEBUG,
"Start of lowpass coeffs component %"PRIu16
" height:%d, width:%d\n", s->
channel_num, lowpass_height, lowpass_width);
453 for (i = 0; i < lowpass_height; i++) {
454 for (j = 0; j < lowpass_width; j++)
455 coeff_data[j] = bytestream2_get_be16u(&gb);
457 coeff_data += lowpass_width;
461 if (lowpass_height & 1) {
462 memcpy(&coeff_data[lowpass_height * lowpass_width],
463 &coeff_data[(lowpass_height - 1) * lowpass_width],
464 lowpass_width *
sizeof(*coeff_data));
467 av_log(avctx,
AV_LOG_DEBUG,
"Lowpass coefficients %"PRIu16
"\n", lowpass_width * lowpass_height);
476 int expected = highpass_height * highpass_stride;
477 int a_expected = highpass_a_height * highpass_a_width;
479 int count = 0, bytes;
481 if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < expected) {
504 if (count > expected)
508 for (i = 0; i <
run; i++)
509 *coeff_data++ = coeff;
518 if (level == 255 && run == 2)
523 if (count > expected)
527 for (i = 0; i <
run; i++)
528 *coeff_data++ = coeff;
534 if (count > expected) {
548 av_log(avctx,
AV_LOG_DEBUG,
"End subband coeffs %i extra %i\n", count, count - expected);
552 if (highpass_height & 1) {
553 memcpy(&coeff_data[highpass_height * highpass_stride],
554 &coeff_data[(highpass_height - 1) * highpass_stride],
555 highpass_stride *
sizeof(*coeff_data));
572 for (plane = 0; plane < 3 && !ret; plane++) {
577 int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : 0;
578 int16_t *low, *high, *output, *dst;
587 av_log(avctx,
AV_LOG_DEBUG,
"Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
592 for (i = 0; i < lowpass_width; i++) {
593 vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
603 for (i = 0; i < lowpass_width; i++) {
605 vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
614 for (i = 0; i < lowpass_height * 2; i++) {
616 low += lowpass_width;
617 high += lowpass_width;
618 output += lowpass_width * 2;
622 for (i = 0; i < lowpass_height * 2; i++) {
623 for (j = 0; j < lowpass_width * 2; j++)
626 output += lowpass_width * 2;
642 av_log(avctx,
AV_LOG_DEBUG,
"Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
647 for (i = 0; i < lowpass_width; i++) {
648 vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
657 for (i = 0; i < lowpass_width; i++) {
658 vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
667 for (i = 0; i < lowpass_height * 2; i++) {
669 low += lowpass_width;
670 high += lowpass_width;
671 output += lowpass_width * 2;
675 for (i = 0; i < lowpass_height * 2; i++) {
676 for (j = 0; j < lowpass_width * 2; j++)
679 output += lowpass_width * 2;
694 av_log(avctx,
AV_LOG_DEBUG,
"Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);
699 for (i = 0; i < lowpass_width; i++) {
700 vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);
709 for (i = 0; i < lowpass_width; i++) {
710 vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);
716 dst = (int16_t *)pic->
data[act_plane];
719 for (i = 0; i < lowpass_height * 2; i++) {
721 low += lowpass_width;
722 high += lowpass_width;
723 dst += pic->
linesize[act_plane] / 2;
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_cold int init(AVCodecContext *avctx)
static int dequant_and_decompand(int level, int quantisation)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static void horiz_filter(int16_t *output, int16_t *low, int16_t *high, int width)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, uint8_t clip)
static int alloc_buffers(AVCodecContext *avctx)
static int get_bits_count(const GetBitContext *s)
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
CFHD_RL_VLC_ELEM table_18_rl_vlc[4572]
CFHD_RL_VLC_ELEM table_9_rl_vlc[2088]
uint8_t prescale_shift[3]
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void vert_filter(int16_t *output, int out_stride, int16_t *low, int low_stride, int16_t *high, int high_stride, int len)
static void horiz_filter_clip(int16_t *output, int16_t *low, int16_t *high, int width, uint8_t clip)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
#define CLOSE_READER(name, gb)
static void init_frame_defaults(CFHDContext *s)
SubBand band[DWT_LEVELS][4]
int width
picture width / height.
static void init_plane_defaults(CFHDContext *s)
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
#define OPEN_READER(name, gb)
BYTE int const BYTE int int int height
static av_cold int cfhd_close_decoder(AVCodecContext *avctx)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
refcounted data buffer API
static av_cold int cfhd_decode_init(AVCodecContext *avctx)
#define AV_PIX_FMT_GBRP12
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define AV_PIX_FMT_YUV422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void free_buffers(AVCodecContext *avctx)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
GLint GLenum GLboolean GLsizei stride
common internal api header.
common internal and external API header
static double clip(void *opaque, double val)
Clip value val in the minval - maxval range.
struct AVCodecInternal * internal
Private context used for internal data.
static const double coeff[2][5]
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
int ff_cfhd_init_vlcs(CFHDContext *s)
#define av_malloc_array(a, b)
uint8_t lowpass_precision
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.