62 uint8_t *plane1, ptrdiff_t stride1,
70 for (block = 0; block < 2; block++) {
74 for (i = 0; i < 8; i++)
75 dst[i] = (tmp >> (i * 3)) & 0x7;
88 }
else if (code == 0) {
90 }
else if (code == 1) {
94 yo = (
uint8_t) (((8 - code) * yo0 +
95 (code - 1) * yo1) / 7);
99 }
else if (code == 7) {
102 yo = (
uint8_t) (((6 - code) * yo0 +
103 (code - 1) * yo1) / 5);
112 uint8_t *plane1, ptrdiff_t stride1,
126 for (y = 0; y < 4; y++) {
127 for (x = 0; x < 4; x++) {
128 int co_code = co_indices[x + y * 4];
129 int cg_code = cg_indices[x + y * 4];
150 for (y = 0; y < 4; y++) {
151 for (x = 0; x < 4; x++) {
152 int yo_code = yo_indices[x + y * 4];
161 uint8_t *unused0, ptrdiff_t unused1,
175 uint8_t *plane3, ptrdiff_t stride1,
183 yao_subblock(plane0 + 4, yo_indices, stride0, block + 16);
184 yao_subblock(plane3 + 4, a_indices, stride1, block + 24);
185 yao_subblock(plane0 + 8, yo_indices, stride0, block + 32);
186 yao_subblock(plane3 + 8, a_indices, stride1, block + 40);
187 yao_subblock(plane0 + 12, yo_indices, stride0, block + 48);
188 yao_subblock(plane3 + 12, a_indices, stride1, block + 56);
194 int slice,
int thread_nb)
202 int start_slice, end_slice;
205 end_slice = h_block * (slice + 1) / ctx->
slice_count;
208 for (y = start_slice; y < end_slice; y++) {
210 int off = y * w_block;
211 for (x = 0; x < w_block; x++) {
219 for (y = start_slice; y < end_slice; y++) {
222 int off = y * w_block;
223 for (x = 0; x < w_block; x++) {
233 end_slice = h_block * (slice + 1) / ctx->
slice_count;
235 for (y = start_slice; y < end_slice; y++) {
238 int off = y * w_block;
239 for (x = 0; x < w_block; x++) {
256 #define CHECKPOINT(x) \ 259 if (bytestream2_get_bytes_left(gbc) < 4) \ 260 return AVERROR_INVALIDDATA; \ 261 value = bytestream2_get_le32(gbc); \ 272 idx = (bytestream2_get_byte(gbc) + 2) * x; \ 274 av_log(avctx, AV_LOG_ERROR, "idx %d > %d\n", idx, pos); \ 275 return AVERROR_INVALIDDATA; \ 279 idx = (bytestream2_get_le16(gbc) + 0x102) * x; \ 281 av_log(avctx, AV_LOG_ERROR, "idx %d > %d\n", idx, pos); \ 282 return AVERROR_INVALIDDATA; \ 293 int idx = 0,
state = 0;
301 while (pos + 2 <= ctx->
tex_size / 4) {
319 prev = bytestream2_get_le32(gbc);
328 prev = bytestream2_get_le32(gbc);
346 int value, counter = 0, rshift = 10, lshift = 30;
348 mask = bytestream2_get_le32(gb) >> 2;
356 table[counter++] =
value;
361 input = bytestream2_get_le16(gb);
362 mask +=
input << lshift;
372 for (; !table[counter - 1]; counter--)
376 *nb_elements = counter;
379 memset(&table[counter], 0, 4 * (256 - counter));
389 unsigned table2[256] = { 0 };
391 int val0, val1,
i, j = 2, k = 0;
393 table2[0] = table0[0];
394 for (i = 0; i < nb_elements - 1; i++, table2[
i] = val0) {
395 val0 = table0[i + 1] + table2[
i];
401 }
while (!table2[k]);
405 for (i = 1024; i > 0; i--) {
406 for (table1[x].val1 = k; k < 256 && j > table2[k]; k++);
407 x = (x - 383) & 0x3FF;
412 memcpy(&table2[0], table0, 4 * nb_elements);
414 for (i = 0; i < 1024; i++) {
415 val0 = table1[
i].
val1;
421 table1[
i].
val2 = 10 - x;
422 table1[
i].
next = (val1 << table1[
i].
val2) - 1024;
431 int sum, x,
val, lshift, rshift,
ret,
i, idx;
432 int64_t size_in_bits;
433 unsigned endoffset, newoffset,
offset;
441 size_in_bits = bytestream2_get_le32(gb);
442 endoffset = ((size_in_bits + 7) >> 3) - 4;
447 next =
AV_RL32(src + endoffset);
448 rshift = (((size_in_bits & 0xFF) - 1) & 7) + 15;
449 lshift = 32 - rshift;
450 idx = (next >> rshift) & 0x3FF;
451 for (i = 0; i <
op_size; i++) {
452 dst[
i] = optable[idx].
val1;
453 val = optable[idx].
val2;
455 x = (next << lshift) >> 1 >> (31 -
val);
456 newoffset = offset - (sum >> 3);
458 idx = x + optable[idx].
next;
460 if (offset > endoffset)
473 int flag = bytestream2_peek_byte(gb);
475 if ((flag & 3) == 0) {
478 }
else if ((flag & 3) == 1) {
480 memset(dstp, bytestream2_get_byte(gb), op_size);
488 ret =
get_opcodes(gb, table, dstp, op_size, elements);
504 uint8_t *tptr0, *tptr1, *tptr3;
512 opcode = op_data[oi++];
514 v = bytestream2_get_byte(gb);
519 opcode = bytestream2_get_le16(gb);
521 }
while (opcode == 0xFFFF);
535 vv = (8 +
offset) * (bytestream2_get_le16(gb) + 1);
536 if (vv < 0 || vv > dst - tex_data)
542 tab0[0x9E3779B1 * (uint16_t)v >> 24] = dst;
543 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
546 AV_WL32(dst, bytestream2_get_le32(gb));
547 AV_WL32(dst + 4, bytestream2_get_le32(gb));
548 tab0[0x9E3779B1 *
AV_RL16(dst) >> 24] = dst;
549 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
552 tptr3 = tab1[bytestream2_get_byte(gb)];
555 AV_WL16(dst, bytestream2_get_le16(gb));
558 AV_WL16(dst + 5, bytestream2_get_le16(gb));
559 dst[7] = bytestream2_get_byte(gb);
560 tab0[0x9E3779B1 *
AV_RL16(dst) >> 24] = dst;
563 tptr3 = tab1[bytestream2_get_byte(gb)];
566 AV_WL16(dst, bytestream2_get_le16(gb));
567 AV_WL16(dst + 2, bytestream2_get_le16(gb));
568 dst[4] = bytestream2_get_byte(gb);
571 tab0[0x9E3779B1 *
AV_RL16(dst) >> 24] = dst;
572 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
575 tptr0 = tab1[bytestream2_get_byte(gb)];
578 tptr1 = tab1[bytestream2_get_byte(gb)];
581 AV_WL16(dst, bytestream2_get_le16(gb));
586 tab0[0x9E3779B1 *
AV_RL16(dst) >> 24] = dst;
589 v = (8 +
offset) * (bytestream2_get_le16(gb) + 1);
590 if (v < 0 || v > dst - tex_data)
593 AV_WL16(dst, bytestream2_get_le16(gb));
596 tab0[0x9E3779B1 *
AV_RL16(dst) >> 24] = dst;
597 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
600 tptr1 = tab0[bytestream2_get_byte(gb)];
604 AV_WL16(dst + 2, bytestream2_get_le16(gb));
605 AV_WL32(dst + 4, bytestream2_get_le32(gb));
606 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
609 tptr1 = tab0[bytestream2_get_byte(gb)];
612 tptr3 = tab1[bytestream2_get_byte(gb)];
618 AV_WL16(dst + 5, bytestream2_get_le16(gb));
619 dst[7] = bytestream2_get_byte(gb);
620 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
623 tptr1 = tab0[bytestream2_get_byte(gb)];
626 tptr3 = tab1[bytestream2_get_byte(gb)];
630 AV_WL16(dst + 2, bytestream2_get_le16(gb));
631 dst[4] = bytestream2_get_byte(gb);
634 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
637 tptr0 = tab0[bytestream2_get_byte(gb)];
640 tptr3 = tab1[bytestream2_get_byte(gb)];
643 tptr1 = tab1[bytestream2_get_byte(gb)];
653 tptr1 = tab0[bytestream2_get_byte(gb)];
656 v = (8 +
offset) * (bytestream2_get_le16(gb) + 1);
657 if (v < 0 || v > dst - tex_data)
663 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
667 AV_WL16(dst + 2, bytestream2_get_le16(gb));
668 AV_WL32(dst + 4, bytestream2_get_le32(gb));
669 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
672 tptr3 = tab1[bytestream2_get_byte(gb)];
678 AV_WL16(dst + 5, bytestream2_get_le16(gb));
679 dst[7] = bytestream2_get_byte(gb);
680 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
683 tptr3 = tab1[bytestream2_get_byte(gb)];
687 AV_WL16(dst + 2, bytestream2_get_le16(gb));
688 dst[4] = bytestream2_get_byte(gb);
691 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
694 tptr3 = tab1[bytestream2_get_byte(gb)];
697 tptr1 = tab1[bytestream2_get_byte(gb)];
707 v = (8 +
offset) * (bytestream2_get_le16(gb) + 1);
708 if (v < 0 || v > dst - tex_data)
713 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF
u) >> 24] = dst + 2;
724 if (dst - tex_data + 8 > tex_size)
738 int max_op_size0,
int max_op_size1)
740 uint8_t *dst, *
tab2[256] = { 0 }, *tab0[256] = { 0 }, *tab3[256] = { 0 }, *
tab1[256] = { 0 };
741 int op_offset = bytestream2_get_le32(gb);
742 unsigned op_size0 = bytestream2_get_le32(gb);
743 unsigned op_size1 = bytestream2_get_le32(gb);
745 int skip0, skip1, oi0 = 0, oi1 = 0;
746 int ret, state0 = 0, state1 = 0;
753 if (op_size0 > max_op_size0)
758 if (op_size1 > max_op_size1)
765 AV_WL32(dst, bytestream2_get_le32(gb));
766 AV_WL32(dst + 4, bytestream2_get_le32(gb));
767 AV_WL32(dst + 8, bytestream2_get_le32(gb));
768 AV_WL32(dst + 12, bytestream2_get_le32(gb));
770 tab0[0x9E3779B1 *
AV_RL16(dst) >> 24] = dst;
771 tab1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF) >> 24] = dst + 2;
772 tab2[0x9E3779B1 *
AV_RL16(dst + 8) >> 24] = dst + 8;
773 tab3[0x9E3779B1 * (
AV_RL32(dst + 10) & 0xFFFFFF) >> 24] = dst + 10;
775 while (dst + 10 < tex_data + tex_size) {
777 &dst, &state0, tab0,
tab1, 8);
781 &dst, &state1, tab2, tab3, 8);
786 bytestream2_seek(gb, data_start - 12 + op_offset + skip0 + skip1, SEEK_SET);
795 int op_offset = bytestream2_get_le32(gb);
796 unsigned op_size = bytestream2_get_le32(gb);
798 uint8_t *dst, *table0[256] = { 0 }, *table1[256] = { 0 };
799 int ret,
state = 0, skip, oi = 0, v, vv;
806 if (op_size > max_op_size)
813 v = bytestream2_get_le32(gb);
815 vv = bytestream2_get_le32(gb);
816 table0[0x9E3779B1 * (uint16_t)v >> 24] = dst;
818 table1[0x9E3779B1 * (
AV_RL32(dst + 2) & 0xFFFFFF) >> 24] = dst + 2;
821 while (dst < tex_data + tex_size) {
823 &dst, &state, table0, table1, 0);
883 while (pos + 2 <= ctx->
tex_size / 4) {
897 value = bytestream2_get_le32(gbc);
907 check = bytestream2_get_byte(gbc) + 1;
910 probe = bytestream2_get_le16(gbc);
912 }
while (probe == 0xFFFF);
914 while (check && pos + 4 <= ctx->
tex_size / 4) {
939 run = bytestream2_get_byte(gbc);
942 probe = bytestream2_get_le16(gbc);
944 }
while (probe == 0xFFFF);
958 idx = 8 + bytestream2_get_le16(gbc);
959 if (idx > pos || (
unsigned int)(pos - idx) + 2 > ctx->
tex_size / 4)
971 prev = bytestream2_get_le32(gbc);
975 prev = bytestream2_get_le32(gbc);
988 if (idx > pos || (
unsigned int)(pos - idx) + 2 > ctx->
tex_size / 4)
1000 if (op && (idx > pos || (
unsigned int)(pos - idx) + 2 > ctx->
tex_size / 4))
1005 prev = bytestream2_get_le32(gbc);
1014 prev = bytestream2_get_le32(gbc);
1048 const char *msgcomp, *msgtext;
1050 int version_major, version_minor = 0;
1051 int size = 0, old_type = 0;
1066 tag = bytestream2_get_le32(gbc);
1068 case MKBETAG(
'D',
'X',
'T',
'1'):
1076 case MKBETAG(
'D',
'X',
'T',
'5'):
1084 case MKBETAG(
'Y',
'C',
'G',
'6'):
1091 msgcomp =
"YOCOCG6";
1101 case MKBETAG(
'Y',
'G',
'1',
'0'):
1108 msgcomp =
"YAOCOCG10";
1120 size = tag & 0x00FFFFFF;
1121 old_type = tag >> 24;
1122 version_major = (old_type & 0x0F) - 1;
1124 if (old_type & 0x80) {
1132 if (old_type & 0x40) {
1137 }
else if (old_type & 0x20 || version_major == 1) {
1156 version_major = bytestream2_get_byte(gbc) - 1;
1157 version_minor = bytestream2_get_byte(gbc);
1160 if (bytestream2_get_byte(gbc)) {
1167 size = bytestream2_get_le32(gbc);
1170 "%s compression with %s texture (version %d.%d)\n",
1171 msgcomp, msgtext, version_major, version_minor);
1175 "Incomplete or invalid file (header %d, left %u).\n",
1196 for (i = 0; i < 4; i++) {
1204 ret = decompress_tex(avctx);
#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.
int(* dxt5_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
Texture block (4x4) module.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int dxv_decompress_dxt1(AVCodecContext *avctx)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int dxv_decompress_ycg6(AVCodecContext *avctx)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
static int get_opcodes(GetByteContext *gb, uint32_t *table, uint8_t *dst, int op_size, int nb_elements)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
The exact code depends on how similar the blocks are and how related they are to the block
static int dxv_decompress_dxt5(AVCodecContext *avctx)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int(* tex_funct_planar[2])(uint8_t *plane0, ptrdiff_t stride0, uint8_t *plane1, ptrdiff_t stride1, const uint8_t *block)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int yao_block(uint8_t *plane0, ptrdiff_t stride0, uint8_t *plane3, ptrdiff_t stride1, const uint8_t *block)
Multithreading support functions.
GLsizei GLboolean const GLfloat * value
#define u(width, name, range_min, range_max)
static int dxv_decompress_yg10(AVCodecContext *avctx)
static int dxv_decompress_yo(DXVContext *ctx, GetByteContext *gb, uint8_t *tex_data, int tex_size, uint8_t *op_data, int max_op_size)
static int fill_ltable(GetByteContext *gb, uint32_t *table, int *nb_elements)
static const uint16_t table[]
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int decompress_texture_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
static const uint16_t mask[17]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int dxv_close(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static int dxv_decompress_lzf(AVCodecContext *avctx)
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames.The frames must then be freed with ff_thread_release_buffer().Otherwise decode directly into the user-supplied frames.Call ff_thread_report_progress() after some part of the current picture has decoded.A good place to put this is where draw_horiz_band() is called-add this if it isn't called anywhere
static int yo_block(uint8_t *dst, ptrdiff_t stride, uint8_t *unused0, ptrdiff_t unused1, const uint8_t *block)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
av_cold void ff_texturedsp_init(TextureDSPContext *c)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static const ElemCat * elements[ELEMENT_COUNT]
static int dxv_decompress_opcodes(GetByteContext *gb, void *dstp, size_t op_size)
static void decompress_indices(uint8_t *dst, const uint8_t *src)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int dxv_decompress_cocg(DXVContext *ctx, GetByteContext *gb, uint8_t *tex_data, int tex_size, uint8_t *op_data0, uint8_t *op_data1, int max_op_size0, int max_op_size1)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static av_always_inline int bytestream2_tell(GetByteContext *g)
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Libavcodec external API header.
static int cocg_block(uint8_t *plane0, ptrdiff_t stride0, uint8_t *plane1, ptrdiff_t stride1, const uint8_t *block)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void yao_subblock(uint8_t *dst, uint8_t *yo_indices, ptrdiff_t stride, const uint8_t *block)
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2]...the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so...,+,-,+,-,+,+,-,+,-,+,...hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32-hcoeff[1]-hcoeff[2]-...a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2}an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||.........intra?||||:Block01:yes no||||:Block02:.................||||:Block03::y DC::ref index:||||:Block04::cb DC::motion x:||||.........:cr DC::motion y:||||.................|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------------------------------|||Y subbands||Cb subbands||Cr subbands||||------||------||------|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||------||------||------||||------||------||------|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||------||------||------||||------||------||------|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||------||------||------||||------||------||------|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------------------------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction------------|\Dequantization-------------------\||Reference frames|\IDWT|--------------|Motion\|||Frame 0||Frame 1||Compensation.OBMC v-------|--------------|--------------.\------> Frame n output Frame Frame<----------------------------------/|...|-------------------Range Coder:============Binary Range Coder:-------------------The implemented range coder is an adapted version based upon"Range encoding: an algorithm for removing redundancy from a digitised message."by G.N.N.Martin.The symbols encoded by the Snow range coder are bits(0|1).The associated probabilities are not fix but change depending on the symbol mix seen so far.bit seen|new state---------+-----------------------------------------------0|256-state_transition_table[256-old_state];1|state_transition_table[old_state];state_transition_table={0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:-------------------------FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1.the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
enum AVColorSpace colorspace
YUV colorspace type.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
static int dxv_init(AVCodecContext *avctx)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int probe(const AVProbeData *p)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int dxv_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
common internal api header.
#define MKBETAG(a, b, c, d)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static uint8_t half(int a, int b)
int(* tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static int fill_optable(unsigned *table0, OpcodeTable *table1, int nb_elements)
static int dxv_decompress_cgo(DXVContext *ctx, GetByteContext *gb, uint8_t *tex_data, int tex_size, uint8_t *op_data, int *oindex, int op_size, uint8_t **dstp, int *statep, uint8_t **tab0, uint8_t **tab1, int offset)
static int extract_component(int yo0, int yo1, int code)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static double val(void *priv, double ch)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int dxv_decompress_raw(AVCodecContext *avctx)
#define check(x, y, S, v)