35 #define MOBI_RL_VLC_BITS 12 36 #define MOBI_MV_VLC_BITS 6 40 0x00, 0x04, 0x01, 0x02, 0x05, 0x08, 0x0C, 0x09, 0x06, 0x03, 0x07, 0x0A,
41 0x0D, 0x0E, 0x0B, 0x0F
46 { 10, 13, 13, 10, 16, 10, 13, 13, 13, 13, 16, 10, 16, 13, 13, 16 },
47 { 11, 14, 14, 11, 18, 11, 14, 14, 14, 14, 18, 11, 18, 14, 14, 18 },
48 { 13, 16, 16, 13, 20, 13, 16, 16, 16, 16, 20, 13, 20, 16, 16, 20 },
49 { 14, 18, 18, 14, 23, 14, 18, 18, 18, 18, 23, 14, 23, 18, 18, 23 },
50 { 16, 20, 20, 16, 25, 16, 20, 20, 20, 20, 25, 16, 25, 20, 20, 25 },
51 { 18, 23, 23, 18, 29, 18, 23, 23, 23, 23, 29, 18, 29, 23, 23, 29 },
56 { 20, 19, 19, 25, 18, 25, 19, 24, 24, 19, 20, 18, 32, 18, 20, 19, 19, 24, 24, 19, 19, 25, 18, 25, 18, 25, 18, 25, 19, 24, 24, 19,
57 19, 24, 24, 19, 18, 32, 18, 20, 18, 32, 18, 24, 24, 19, 19, 24, 24, 18, 25, 18, 25, 18, 19, 24, 24, 19, 18, 32, 18, 24, 24, 18,},
58 { 22, 21, 21, 28, 19, 28, 21, 26, 26, 21, 22, 19, 35, 19, 22, 21, 21, 26, 26, 21, 21, 28, 19, 28, 19, 28, 19, 28, 21, 26, 26, 21,
59 21, 26, 26, 21, 19, 35, 19, 22, 19, 35, 19, 26, 26, 21, 21, 26, 26, 19, 28, 19, 28, 19, 21, 26, 26, 21, 19, 35, 19, 26, 26, 19,},
60 { 26, 24, 24, 33, 23, 33, 24, 31, 31, 24, 26, 23, 42, 23, 26, 24, 24, 31, 31, 24, 24, 33, 23, 33, 23, 33, 23, 33, 24, 31, 31, 24,
61 24, 31, 31, 24, 23, 42, 23, 26, 23, 42, 23, 31, 31, 24, 24, 31, 31, 23, 33, 23, 33, 23, 24, 31, 31, 24, 23, 42, 23, 31, 31, 23,},
62 { 28, 26, 26, 35, 25, 35, 26, 33, 33, 26, 28, 25, 45, 25, 28, 26, 26, 33, 33, 26, 26, 35, 25, 35, 25, 35, 25, 35, 26, 33, 33, 26,
63 26, 33, 33, 26, 25, 45, 25, 28, 25, 45, 25, 33, 33, 26, 26, 33, 33, 25, 35, 25, 35, 25, 26, 33, 33, 26, 25, 45, 25, 33, 33, 25,},
64 { 32, 30, 30, 40, 28, 40, 30, 38, 38, 30, 32, 28, 51, 28, 32, 30, 30, 38, 38, 30, 30, 40, 28, 40, 28, 40, 28, 40, 30, 38, 38, 30,
65 30, 38, 38, 30, 28, 51, 28, 32, 28, 51, 28, 38, 38, 30, 30, 38, 38, 28, 40, 28, 40, 28, 30, 38, 38, 30, 28, 51, 28, 38, 38, 28,},
66 { 36, 34, 34, 46, 32, 46, 34, 43, 43, 34, 36, 32, 58, 32, 36, 34, 34, 43, 43, 34, 34, 46, 32, 46, 32, 46, 32, 46, 34, 43, 43, 34,
67 34, 43, 43, 34, 32, 58, 32, 36, 32, 58, 32, 43, 43, 34, 34, 43, 43, 32, 46, 32, 46, 32, 34, 43, 43, 34, 32, 58, 32, 43, 43, 32,},
72 15, 0, 2, 1, 4, 8, 12, 3, 11, 13, 14, 7, 10, 5, 9, 6,
77 0, 4, 1, 8, 2, 12, 3, 5, 10, 15, 7, 13, 14, 11, 9, 6,
82 0x00, 0x1F, 0x3F, 0x0F, 0x08, 0x04, 0x02, 0x01, 0x0B, 0x0E, 0x1B, 0x0D,
83 0x03, 0x07, 0x0C, 0x17, 0x1D, 0x0A, 0x1E, 0x05, 0x10, 0x2F, 0x37, 0x3B,
84 0x13, 0x3D, 0x3E, 0x09, 0x1C, 0x06, 0x15, 0x1A, 0x33, 0x11, 0x12, 0x14,
85 0x18, 0x20, 0x3C, 0x35, 0x19, 0x16, 0x3A, 0x30, 0x31, 0x32, 0x27, 0x34,
86 0x2B, 0x2D, 0x39, 0x38, 0x23, 0x36, 0x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11, 12, 12, 12, 12, 12,
125 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 7, 10, 10, 9,
126 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
127 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
128 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6,
129 6, 6, 6, 6, 6, 6, 5, 5, 5, 4, 2, 3, 4, 4,
133 0x0, 0x822, 0x803, 0xB, 0xA, 0xB81, 0xB61, 0xB41, 0xB21, 0x122,
134 0x102, 0xE2, 0xC2, 0xA2, 0x63, 0x43, 0x24, 0xC, 0x25, 0x2E1, 0x301,
135 0xBA1, 0xBC1, 0xBE1, 0xC01, 0x26, 0x44, 0x83, 0xA3, 0xC3, 0x142,
136 0x321, 0x341, 0xC21, 0xC41, 0xC61, 0xC81, 0xCA1, 0xCC1, 0xCE1, 0xD01,
137 0x0, 0x9, 0x8, 0xB01, 0xAE1, 0xAC1, 0xAA1, 0xA81, 0xA61, 0xA41, 0xA21,
138 0x802, 0x2C1, 0x2A1, 0x281, 0x261, 0x241, 0x221, 0x201, 0x1E1, 0x82,
139 0x62, 0x7, 0x6, 0xA01, 0x9E1, 0x9C1, 0x9A1, 0x981, 0x961, 0x941, 0x921,
140 0x1C1, 0x1A1, 0x42, 0x23, 0x5, 0x901, 0x8E1, 0x8C1, 0x8A1, 0x181, 0x161,
141 0x141, 0x4, 0x881, 0x861, 0x841, 0x821, 0x121, 0x101, 0xE1, 0xC1, 0x22,
142 0x3, 0xA1, 0x81, 0x61, 0x801, 0x1, 0x21, 0x41, 0x2,
146 0x0, 0x807, 0x806, 0x16, 0x15, 0x842, 0x823, 0x805, 0x1A1, 0xA3, 0x102, 0x83,
147 0x64, 0x44, 0x27, 0x14, 0x13, 0x17, 0x18, 0x28, 0x122, 0x862, 0x882, 0x9E1, 0xA01,
148 0x19, 0x1A, 0x1B, 0x29, 0xC3, 0x2A, 0x45, 0xE3, 0x1C1, 0x808, 0x8A2, 0x8C2, 0xA21,
149 0xA41, 0xA61, 0xA81, 0x0, 0x12, 0x11, 0x9C1, 0x9A1, 0x981, 0x961, 0x941, 0x822, 0x804,
150 0x181, 0x161, 0xE2, 0xC2, 0xA2, 0x63, 0x43, 0x26, 0x25, 0x10, 0x82, 0xF, 0xE, 0xD, 0x901,
151 0x8E1, 0x8C1, 0x803, 0x141, 0x121, 0x101, 0x921, 0x62, 0x24, 0xC, 0xB, 0xA, 0x881, 0x861,
152 0xC1, 0x8A1, 0xE1, 0x42, 0x23, 0x9, 0x802, 0xA1, 0x841, 0x821, 0x81, 0x61, 0x8, 0x7, 0x22,
153 0x6, 0x41, 0x5, 0x4, 0x801, 0x1, 0x2, 0x21, 0x3,
158 10, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7, 7, 7, 7, 6,
164 { 2, 3, 3, 5, 5, 4, 4, 5, 5, 2 },
165 { 2, 3, 4, 4, 3, 4, 4, 2 },
166 { 3, 4, 4, 2, 4, 4, 3, 2 },
167 { 1, 3, 4, 5, 5, 3, 3 },
168 { 2, 4, 4, 3, 3, 4, 4, 2 },
169 { 2, 3, 4, 4, 4, 4, 3, 2 },
170 { 2, 3, 4, 4, 4, 4, 3, 2 },
171 { 2, 2, 3, 4, 5, 5, 2 },
172 { 2, 3, 4, 4, 3, 4, 4, 2 },
173 { 2, 4, 4, 3, 4, 4, 3, 2 },
174 { 2, 3, 3, 5, 5, 4, 3, 2 },
175 { 2, 3, 4, 4, 3, 3, 2 },
176 { 1, 4, 4, 3, 3, 4, 4 },
177 { 2, 3, 4, 4, 3, 3, 2 },
178 { 2, 3, 4, 4, 3, 3, 2 },
179 { 3, 3, 2, 2, 3, 3 },
182 { 3, 4, 5, 5, 3, 5, 6, 6, 4, 1 },
183 { 2, 3, 4, 5, 5, 2, 3, 3 },
184 { 2, 4, 4, 3, 3, 4, 4, 2 },
185 { 1, 4, 4, 3, 4, 4, 3 },
186 { 3, 3, 2, 4, 5, 5, 3, 2 },
187 { 3, 4, 4, 3, 3, 3, 3, 2 },
188 { 1, 3, 3, 4, 4, 4, 5, 5 },
189 { 1, 4, 4, 3, 3, 4, 4 },
190 { 2, 4, 4, 3, 3, 4, 4, 2 },
191 { 1, 3, 3, 4, 4, 4, 5, 5 },
192 { 2, 3, 4, 4, 4, 4, 3, 2 },
193 { 2, 3, 3, 4, 4, 3, 2 },
194 { 1, 4, 4, 3, 3, 4, 4 },
195 { 1, 4, 4, 3, 3, 4, 4 },
196 { 2, 3, 3, 4, 4, 3, 2 },
197 { 2, 3, 3, 3, 3, 2 },
204 { 1, 8, 9, 4, 3, 2, 7, 5, 6, 0 },
205 { 0, 9, 5, 4, 2, 3, 8, 1 },
206 { 3, 9, 5, 0, 4, 8, 2, 1 },
207 { 1, 3, 4, 8, 5, 2, 0 },
208 { 0, 5, 4, 8, 2, 3, 9, 1 },
209 { 0, 3, 5, 9, 4, 8, 2, 1 },
210 { 0, 3, 9, 5, 8, 4, 2, 1 },
211 { 0, 2, 3, 4, 8, 5, 1 },
212 { 0, 3, 8, 4, 2, 5, 9, 1 },
213 { 2, 8, 9, 3, 5, 4, 0, 1 },
214 { 0, 4, 3, 8, 9, 5, 2, 1 },
215 { 0, 4, 8, 5, 3, 2, 1 },
216 { 1, 9, 4, 2, 0, 5, 3 },
217 { 2, 4, 9, 5, 3, 0, 1 },
218 { 0, 4, 9, 5, 3, 2, 1 },
219 { 5, 4, 1, 0, 3, 2 },
222 { 8, 2, 3, 6, 1, 7, 5, 4, 9, 0 },
223 { 9, 2, 3, 5, 4, 1, 8, 0 },
224 { 0, 5, 4, 2, 9, 3, 8, 1 },
225 { 1, 5, 4, 2, 8, 3, 0 },
226 { 2, 9, 8, 3, 5, 4, 0, 1 },
227 { 3, 5, 4, 2, 9, 8, 0, 1 },
228 { 1, 2, 0, 9, 8, 3, 5, 4 },
229 { 1, 8, 5, 2, 0, 4, 3 },
230 { 0, 5, 4, 2, 8, 3, 9, 1 },
231 { 1, 2, 0, 9, 8, 3, 5, 4 },
232 { 0, 3, 9, 8, 5, 4, 2, 1 },
233 { 0, 4, 3, 8, 5, 2, 1 },
234 { 1, 5, 4, 2, 0, 9, 3 },
235 { 1, 9, 5, 2, 0, 4, 3 },
236 { 0, 5, 3, 9, 4, 2, 1 },
237 { 0, 4, 5, 3, 2, 1 },
288 for (
int i = 0;
i < 2;
i++) {
290 for (
int j = 0; j < 16; j++) {
320 for (
int i = 0;
i < 6;
i++) {
336 if (quantizer < 12 || quantizer > 161)
344 for (
int i = 0;
i < 16;
i++)
347 for (
int i = 0;
i < 64;
i++)
350 for (
int i = 0;
i < 20;
i++)
358 unsigned a = rs[0] + rs[2];
359 unsigned b = rs[0] - rs[2];
360 unsigned c = rs[1] + ((
int)rs[3] >> 1);
361 unsigned d = ((
int)rs[1] >> 1) - rs[3];
372 unsigned x3, x2, x1, x0;
387 e = (unsigned)arr[7] + arr[1] - arr[3] - (arr[3] >> 1);
388 f = (unsigned)arr[7] - arr[1] + arr[5] + (arr[5] >> 1);
389 g = (unsigned)arr[5] - arr[3] - arr[7] - (arr[7] >> 1);
390 h = (unsigned)arr[5] + arr[3] + arr[1] + (arr[1] >> 1);
391 x3 = (unsigned)g + (h >> 2);
392 x2 = (unsigned)e + (f >> 2);
393 x1 = (e >> 2) - (
unsigned)
f;
394 x0 = (unsigned)h - (g >> 2);
396 arr[0] = tmp[0] + x0;
397 arr[1] = tmp[1] + x1;
398 arr[2] = tmp[2] + x2;
399 arr[3] = tmp[3] + x3;
400 arr[4] = tmp[3] - x3;
401 arr[5] = tmp[2] - x2;
402 arr[6] = tmp[1] - x1;
403 arr[7] = tmp[0] - x0;
414 *last = (n >> 11) == 1;
415 *run = (n >> 5) & 0x3F;
420 int bx,
int by,
int size,
int plane)
426 const int *qtab = s->
qtab[size == 8];
454 if (
pos >= size * size)
457 mat[ztab[
pos]] = qval *(unsigned)level;
465 idct(&mat[
y * size], size);
467 for (
int y = 0;
y <
size;
y++) {
468 for (
int x =
y + 1;
x <
size;
x++) {
469 int a = mat[
x * size +
y];
470 int b = mat[
y * size +
x];
472 mat[
y * size +
x] =
a;
473 mat[
x * size +
y] =
b;
476 idct(&mat[
y * size], size);
486 int bx,
int by,
int size,
int plane)
497 for (
int y = by;
y < by + 8;
y += 4) {
498 for (
int x = bx;
x < bx + 8;
x += 4) {
516 return size == 16 ? (x + 1) >> 1 : x;
524 if (b.
x == -1 && b.
y >= b.
size) {
525 ret.
x = -1, ret.
y = b.
size - 1;
526 }
else if (b.
x >= -1 && b.
y >= -1) {
527 ret.
x = b.
x, ret.
y = b.
y;
528 }
else if (b.
x == -1 && b.
y == -2) {
529 ret.
x = 0, ret.
y = -1;
530 }
else if (b.
x == -2 && b.
y == -1) {
531 ret.
x = -1, ret.
y = 0;
542 return ((a + b) + 1) / 2;
547 return ((a + b + b + c) * 2 / 4 + 1) / 2;;
588 if ((bxy.
x % 2) == 0) {
594 ba.
y = bxy.
y + bxy.
x / 2;
599 bb.
y = bxy.
y + bxy.
x / 2 + 1;
608 ba.
y = bxy.
y + bxy.
x / 2 + 1;
629 }
else if (bxy.
y == 0) {
636 }
else if (bxy.
x == 1) {
669 }
else if (bxy.
x == 0) {
676 }
else if (bxy.
y == 1) {
724 return half3(acc1, clr, acc2);
745 }
else if (bxy.
y == 1) {
750 }
else if (bxy.
x < bxy.
size - 1) {
755 }
else if (bxy.
y % 2 == 0) {
758 ba.
x = bxy.
y / 2 + bxy.
size - 1;
762 bb.
x = bxy.
y / 2 + bxy.
size;
769 ba.
x = bxy.
y / 2 + bxy.
size;
780 for (
int y = 0;
y <
size;
y++) {
781 memset(block, fill, size);
787 int w,
int h,
int ax,
int ay,
800 for (
int y = 0;
y <
size;
y++) {
802 for (
int x = 0;
x <
size;
x++) {
809 block[ax +
x + (ay +
y) * linesize] = val;
818 for (
int y = 0;
y <
h;
y++) {
819 for (
int x = 0;
x <
w;
x++) {
829 int pmode,
int add_coeffs,
int size,
int plane)
833 int w = avctx->
width >> !!plane, h = avctx->
height >> !!plane;
849 int bottommost = frame->
data[plane][(ay + size - 1) * frame->
linesize[plane] +
FFMAX(ax - 1, 0)];
850 int rightmost = frame->
data[plane][
FFMAX(ay - 1, 0) * frame->
linesize[plane] + ax + size - 1];
852 int r6 =
adjust(avg - bottommost, size);
853 int r9 =
adjust(avg - rightmost, size);
857 for (
int x = 0;
x <
size;
x++) {
859 arr1[
x] =
adjust(((bottommost - val) * (1 << shift)) + r6 * (
x + 1), size);
862 for (
int y = 0;
y <
size;
y++) {
864 arr2[
y] =
adjust(((rightmost - val) * (1 << shift)) + r9 * (
y + 1), size);
868 for (
int y = 0;
y <
size;
y++) {
869 for (
int x = 0;
x <
size;
x++) {
870 block[
x] = (((top[
x] + left[0] + ((arr1[
x] * (
y + 1) +
871 arr2[
y] * (
x + 1)) >> 2 * shift)) + 1) / 2) & 0xFF;
882 if (ax == 0 && ay == 0) {
884 }
else if (ax >= 1 && ay >= 1) {
890 fill = ((left + top) * 2 / (2 * size) + 1) / 2;
891 }
else if (ax >= 1) {
893 1, size, frame->
linesize[plane]) * 2 / size + 1) / 2;
894 }
else if (ay >= 1) {
896 size, 1, frame->
linesize[plane]) * 2 / size + 1) / 2;
902 size, frame->
linesize[plane], fill);
932 int index = (y & 0xC) | (x / 4 % 4);
940 val = x + (x >= val ? 1 : 0);
945 s->
pre[index + 5] = s->
pre[index + 8] = s->
pre[index + 9] =
val;
951 int x,
int y,
int pmode,
int has_coeffs,
int plane)
960 return predict_intra(avctx, frame, x, y, pmode, 0, 8, plane);
974 for (
int by = y; by < y + 8; by += 4) {
975 for (
int bx = x; bx < x + 8; bx += 4) {
976 int new_pmode = pmode;
980 ret =
predict_intra(avctx, frame, bx, by, new_pmode, flags & 1, 4, plane);
1009 ret =
process_block(avctx, frame, x + 8, y, -1, flags & 1, 0);
1013 ret =
process_block(avctx, frame, x, y + 8, -1, flags & 1, 0);
1017 ret =
process_block(avctx, frame, x + 8, y + 8, -1, flags & 1, 0);
1031 ret =
process_block(avctx, frame, x, y, pmode, flags & 1, 0);
1035 ret =
process_block(avctx, frame, x + 8, y, pmode, flags & 1, 0);
1039 ret =
process_block(avctx, frame, x, y + 8, pmode, flags & 1, 0);
1043 ret =
process_block(avctx, frame, x + 8, y + 8, pmode, flags & 1, 0);
1050 if (pmode_uv == 2) {
1073 return x == 16 ? 0 : x == 8 ? 1 : x == 4 ? 2 : x == 2 ? 3 : 0;
1078 int offsetm,
int offsetx,
int offsety)
1083 int fheight = avctx->
height;
1084 int fwidth = avctx->
width;
1097 if (mv.
x >= INT_MAX || mv.
y >= INT_MAX)
1100 motion[offsetm].
x = mv.
x;
1101 motion[offsetm].
y = mv.
y;
1103 for (
int i = 0;
i < 3;
i++) {
1104 int method, src_linesize, dst_linesize;
1108 offsetx = offsetx >> 1;
1109 offsety = offsety >> 1;
1113 height = height >> 1;
1114 fwidth = fwidth >> 1;
1115 fheight = fheight >> 1;
1124 method = (mv.
x & 1) | ((mv.
y & 1) << 1);
1129 if (offsetx + (mv.
x >> 1) < 0 ||
1130 offsety + (mv.
y >> 1) < 0 ||
1131 offsetx + width + (mv.
x + 1 >> 1) > fwidth ||
1132 offsety + height + (mv.
y + 1 >> 1) > fheight)
1137 src = s->
pic[sidx]->
data[
i] + offsetx + (mv.
x >> 1) +
1138 (offsety + (mv.
y >> 1)) * src_linesize;
1142 dst += dst_linesize;
1143 src += src_linesize;
1147 src = s->
pic[sidx]->
data[
i] + offsetx + (mv.
x >> 1) +
1148 (offsety + (mv.
y >> 1)) * src_linesize;
1151 dst[
x] = (
uint8_t)((src[
x] >> 1) + (src[
x + 1] >> 1));
1154 dst += dst_linesize;
1155 src += src_linesize;
1159 src = s->
pic[sidx]->
data[
i] + offsetx + (mv.
x >> 1) +
1160 (offsety + (mv.
y >> 1)) * src_linesize;
1163 dst[
x] = (
uint8_t)((src[
x] >> 1) + (src[
x + src_linesize] >> 1));
1166 dst += dst_linesize;
1167 src += src_linesize;
1171 src = s->
pic[sidx]->
data[
i] + offsetx + (mv.
x >> 1) +
1172 (offsety + (mv.
y >> 1)) * src_linesize;
1175 dst[
x] = (
uint8_t)((((src[
x] >> 1) + (src[
x + 1] >> 1)) >> 1) +
1176 (((src[
x + src_linesize] >> 1) + (src[
x + 1 + src_linesize] >> 1)) >> 1));
1179 dst += dst_linesize;
1180 src += src_linesize;
1187 int adjx = index == 8 ? 0 : width / 2;
1188 int adjy = index == 8 ? height / 2 : 0;
1190 width = width - adjx;
1191 height = height - adjy;
1194 for (
int i = 0;
i < 2;
i++) {
1201 offsetm, offsetx +
i * adjx, offsety +
i * adjy);
1225 (uint16_t *)pkt->
data,
1226 (pkt->
size + 1) >> 1);
1242 for (
int y = 0;
y < avctx->
height;
y += 16) {
1243 for (
int x = 0;
x < avctx->
width;
x += 16) {
1262 for (
int y = 0;
y < avctx->
height;
y += 16) {
1263 for (
int x = 0;
x < avctx->
width;
x += 16) {
1266 motion[0].
x =
mid_pred(motion[
x / 16 + 1].
x, motion[
x / 16 + 2].
x, motion[
x / 16 + 3].
x);
1267 motion[0].
y =
mid_pred(motion[
x / 16 + 1].
y, motion[
x / 16 + 2].
y, motion[
x / 16 + 3].
y);
1268 motion[
x / 16 + 2].
x = 0;
1269 motion[
x / 16 + 2].
y = 0;
1274 if (idx == 6 || idx == 7) {
1288 for (
int sy =
y; sy <
y + 16; sy += 8) {
1289 for (
int sx =
x; sx <
x + 16; sx += 8) {
1322 for (
int i = 0;
i < 6;
i++)
1335 for (
int i = 0;
i < 6;
i++) {
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static const uint16_t syms1[]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static const uint8_t quant4x4_tab[][16]
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
static int adjust(int x, int size)
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
static int predict_motion(AVCodecContext *avctx, int width, int height, int index, int offsetm, int offsetx, int offsety)
static const uint8_t block4x4_coefficients_tab[]
static av_cold void mobiclip_init_static(void)
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
static void block_fill_simple(uint8_t *block, int size, int linesize, int fill)
static int get_prediction(AVCodecContext *avctx, int x, int y, int size)
static int block_sum(const uint8_t *block, int w, int h, int linesize)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
#define FF_ARRAY_ELEMS(a)
static av_cold int mobiclip_close(AVCodecContext *avctx)
static uint8_t pick_7(BlockXY bxy)
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
static int get_sbits(GetBitContext *s, int n)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static uint8_t half3(int a, int b, int c)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
static int get_index(int x)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#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 void idct(int *arr, int size)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static uint8_t pick_left(BlockXY bxy)
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
Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
bitstream reader API header.
static const uint8_t pframe_block4x4_coefficients_tab[]
static const uint8_t bits0[]
static const uint8_t mv_bits[2][16][10]
static int get_bits_left(GetBitContext *gb)
static void mobiclip_flush(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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...
static int setup_qtables(AVCodecContext *avctx, int quantizer)
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static void read_run_encoding(AVCodecContext *avctx, int *last, int *run, int *level)
static int add_coefficients(AVCodecContext *avctx, AVFrame *frame, int bx, int by, int size, int plane)
static const uint16_t syms0[]
static uint8_t pick_6(BlockXY bxy)
enum AVPictureType pict_type
Picture type of the frame.
static void inverse4(unsigned *rs)
int width
picture width / height.
static uint8_t pick_5(BlockXY bxy)
static int add_pframe_coefficients(AVCodecContext *avctx, AVFrame *frame, int bx, int by, int size, int plane)
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
#define INIT_VLC_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap,symbols, symbols_wrap, symbols_size,offset, flags, static_size)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static av_cold int mobiclip_init(AVCodecContext *avctx)
static uint8_t pget(BlockXY b)
static int decode_macroblock(AVCodecContext *avctx, AVFrame *frame, int x, int y, int predict)
static const uint8_t quant8x8_tab[][64]
static const uint8_t pframe_block8x8_coefficients_tab[]
static const int8_t mv[256][2]
static int predict_intra(AVCodecContext *avctx, AVFrame *frame, int ax, int ay, int pmode, int add_coeffs, int size, int plane)
static const uint8_t zigzag4x4_tab[]
static const uint8_t mv_len[16]
Libavcodec external API header.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
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
static unsigned int get_bits1(GetBitContext *s)
static const uint8_t block8x8_coefficients_tab[]
enum AVColorSpace colorspace
YUV colorspace type.
int ff_init_vlc_from_lengths(VLC *vlc_arg, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
const uint8_t ff_zigzag_direct[64]
static int process_block(AVCodecContext *avctx, AVFrame *frame, int x, int y, int pmode, int has_coeffs, int plane)
static void block_fill(uint8_t *block, int size, int linesize, int w, int h, int ax, int ay, uint8_t(*pick)(BlockXY bxy))
AVCodec ff_mobiclip_decoder
static uint8_t half_horz(BlockXY bxy)
static uint8_t pick_above(BlockXY bxy)
static const uint8_t mv_syms[2][16][10]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define flags(name, subs,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
#define INIT_VLC_USE_NEW_STATIC
static uint8_t pick_8(BlockXY bxy)
static int mobiclip_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
static const uint8_t run_residue[2][256]
static int ff_thread_once(char *control, void(*routine)(void))
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static uint8_t half(int a, int b)
static VLC_TYPE vlc_buf[16716][2]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
static uint8_t pick_4(BlockXY bxy)
static uint8_t half_vert(BlockXY bxy)
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.