29#define VECTOR_VLC_BITS 6
32 2, 4, 4, 4, 4, 2, 4, 4,
33 6, 6, 6, 6, 6, 6, 6, 6
76 if (avctx->
width & 15)
107 return x >= 1 && x <= 5 ? 1 << x : 0;
112 return x >= 1 && x <= 4 ? 1 << x : 1;
127 int book1 = -256 *
seed[3];
128 int book2 = -128 *
seed[4];
129 int book3 = -128 *
seed[5];
130 int book4 = -128 *
seed[6];
132 for (
int i = -128;
i < 128;
i++) {
133 s->codebook[0][(uint8_t)
i] = book1;
134 s->codebook[1][(uint8_t)
i] =
bias(book2,
seed[0]);
135 s->codebook[2][(uint8_t)
i] =
bias(book3,
seed[1]);
136 s->codebook[3][(uint8_t)
i] =
bias(book4,
seed[2]);
138 book1 += 2 *
seed[3];
148 uint8_t * vectors =
s->vectors;
149 uint8_t * vectors_end =
s->vectors + (
width *
height * 3) / 2;
159 uint8_t *
dst = vectors;
166 if (
dst >= vectors_end - 1)
201 int16_t * c0 =
s->coeff;
202 int16_t *
c1 =
s->coeff + coeff_width;
203 int16_t * c0_125 =
s->coeff + (coeff_width >> 3);
204 int16_t * c1_125 =
s->coeff + coeff_width + (coeff_width >> 3);
205 int16_t * c0_25 =
s->coeff + (coeff_width >> 2);
206 int16_t * c1_25 =
s->coeff + coeff_width + (coeff_width >> 2);
207 int16_t * c0_5 =
s->coeff + (coeff_width >> 1);
208 int16_t * c1_5 =
s->coeff + coeff_width + (coeff_width >> 1);
211 c0[0] =
s->codebook[0][v[0]];
212 c0[1] =
s->codebook[0][v[1]];
215 c1[0] =
s->codebook[0][v[2]];
216 c1[1] =
s->codebook[0][v[3]];
219 c0_125[0] =
s->codebook[1][v[4]];
220 c0_125[1] =
s->codebook[1][v[5]];
223 c1_125[0] =
s->codebook[1][v[6]];
224 c1_125[1] =
s->codebook[1][v[7]];
227 c0_25[0] =
s->codebook[2][v[8]];
228 c0_25[1] =
s->codebook[2][v[9]];
229 c0_25[2] =
s->codebook[2][v[10]];
230 c0_25[3] =
s->codebook[2][v[11]];
233 c1_25[0] =
s->codebook[2][v[12]];
234 c1_25[1] =
s->codebook[2][v[13]];
235 c1_25[2] =
s->codebook[2][v[14]];
236 c1_25[3] =
s->codebook[2][v[15]];
239 if (v[16] | v[17] | v[18] | v[19]) {
240 c0_5[0] =
s->codebook[3][v[16]];
241 c0_5[1] =
s->codebook[3][v[17]];
242 c0_5[2] =
s->codebook[3][v[18]];
243 c0_5[3] =
s->codebook[3][v[19]];
245 c0_5[0] = c0_5[1] = c0_5[2] = c0_5[3] = 0;
248 if (v[20] | v[21] | v[22] | v[23]) {
249 c0_5[4] =
s->codebook[3][v[20]];
250 c0_5[5] =
s->codebook[3][v[21]];
251 c0_5[6] =
s->codebook[3][v[22]];
252 c0_5[7] =
s->codebook[3][v[23]];
254 c0_5[4] = c0_5[5] = c0_5[6] = c0_5[7] = 0;
258 if (v[24] | v[25] | v[26] | v[27]) {
259 c1_5[0] =
s->codebook[3][v[24]];
260 c1_5[1] =
s->codebook[3][v[25]];
261 c1_5[2] =
s->codebook[3][v[26]];
262 c1_5[3] =
s->codebook[3][v[27]];
264 c1_5[0] = c1_5[1] = c1_5[2] = c1_5[3] = 0;
267 if (v[28] | v[29] | v[30] | v[31]) {
268 c1_5[4] =
s->codebook[3][v[28]];
269 c1_5[5] =
s->codebook[3][v[29]];
270 c1_5[6] =
s->codebook[3][v[30]];
271 c1_5[7] =
s->codebook[3][v[31]];
273 c1_5[4] = c1_5[5] = c1_5[6] = c1_5[7] = 0;
283 int s0 =
a[0] + (
b[0] >> 1);
285 for (
int i = 0;
i <
width / 2 - 1;
i++) {
287 s0 =
a[
i + 1] + ((
b[
i] +
b[
i + 1]) >> 1);
288 dst[
i * 2 + 1] = ((
dst[
i * 2] + s0) >> 1) - 2 *
b[
i];
297 return x >= -128 ? x <= 127 ? x + 0x80 : 0x00 : 0xFF;
302 int s0 =
a[0] + (
b[0] >> 1);
305 for (
int i = 0;
i <
width / 2 - 1;
i++) {
307 tmp =
a[
i + 1] + ((
b[
i] +
b[
i + 1]) >> 1);
318 const int16_t *
coeff;
321 int v0 =
s->coeff[
i];
323 s->coeff[
i] = v0 - v1;
343 uint8_t * vectors =
s->vectors;
344 uint8_t * y =
s->frame->data[0];
345 uint8_t *
u =
s->frame->data[1];
346 uint8_t * v =
s->frame->data[2];
348 for (
int j = 0; j <
height / 4; j++) {
351 vectors += 2 *
width;
352 y += 2 *
s->frame->linesize[0];
357 u += 2 *
s->frame->linesize[1];
361 vectors += 2 *
width;
362 y += 2 *
s->frame->linesize[0];
367 v += 2 *
s->frame->linesize[2];
376 const uint8_t * buf = avpkt->
data;
377 int cache,
seed[7], gamma, contrast;
387 if (((buf[0] >> 1) & 7) != 5) {
402 contrast =
AV_RL16(buf + 2) >> 1;
403 if (gamma || contrast)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_vqc_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_sbits(GetBitContext *s, int n)
static int get_bits_left(GetBitContext *gb)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define u(width, name, range_min, range_max)
static int ff_thread_once(char *control, void(*routine)(void))
Memory handling functions.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
#define av_malloc_array(a, b)
#define avpriv_request_sample(...)
static const double coeff[2][5]
#define VLC_INIT_STATIC_TABLE_FROM_LENGTHS(vlc_table, nb_bits, nb_codes, lens, lens_wrap, syms, syms_wrap, syms_size, offset, flags)
static VLCElem vector_vlc[1<< VECTOR_VLC_BITS]
static void load_coeffs(VqcContext *s, const uint8_t *v, int width, int coeff_width)
static int bias(int x, int c)
static void decode_frame(VqcContext *s, int width, int height)
static const int8_t vector_symbols[]
static int vqc_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static const uint8_t vector_nbits[]
static av_cold int vqc_decode_init(AVCodecContext *avctx)
static void transform1(const int16_t *a, const int16_t *b, int16_t *dst, int width)
static int decode_vectors(VqcContext *s, const uint8_t *buf, int size, int width, int height)
static av_cold void vqc_init_static_data(void)
static int seed_pow1(int x)
static av_cold int vqc_decode_end(AVCodecContext *avctx)
static void transform2(const int16_t *a, const int16_t *b, uint8_t *dst, int width)
static int seed_pow2(int x)
static void decode_strip(VqcContext *s, uint8_t *dst, int stride, int width)
static void seed_codebooks(VqcContext *s, const int *seed)