33 #define TM2_ESCAPE 0x80000000 
  130         huff->
bits[huff->
num] = prefix;
 
  135         if ((ret = 
tm2_read_tree(ctx, prefix << 1, length + 1, huff)) < 0)
 
  137         if ((ret = 
tm2_read_tree(ctx, (prefix << 1) | 1, length + 1, huff)) < 0)
 
  161     if ((huff.
nodes <= 0) || (huff.
nodes > 0x10000)) {
 
  163                "nodes: %i\n", huff.
nodes);
 
  189                        huff.
lens, 
sizeof(
int), 
sizeof(
int),
 
  190                        huff.
bits, 
sizeof(uint32_t), 
sizeof(uint32_t), 0);
 
  197             for (i = 0; i < code->
length; i++)
 
  225 #define TM2_OLD_HEADER_MAGIC 0x00000100 
  226 #define TM2_NEW_HEADER_MAGIC 0x00000101 
  252     if ((d < 1) || (d > 
TM2_DELTAS) || (mb < 1) || (mb > 32)) {
 
  257     for (i = 0; i < d; i++) {
 
  259         if (v & (1 << (mb - 1)))
 
  260             ctx->
deltas[stream_id][i] = v - (1 << 
mb);
 
  265         ctx->
deltas[stream_id][i] = 0;
 
  285     len  = bytestream2_get_be32(&gb);
 
  291     if (len >= INT_MAX/4-1 || len < 0 || skip > buf_size) {
 
  296     toks = bytestream2_get_be32(&gb);
 
  298         len = bytestream2_get_be32(&gb);
 
  300             len = bytestream2_get_be32(&gb);
 
  313     len = bytestream2_get_be32(&gb);
 
  330     if ((toks < 0) || (toks > 0xFFFFFF)) {
 
  337     len = bytestream2_get_be32(&gb);
 
  343         for (i = 0; i < toks; i++) {
 
  349             if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= 
TM2_DELTAS || ctx->
tokens[stream_id][i]<0) {
 
  351                        ctx->
tokens[stream_id][i], stream_id, i);
 
  356         for (i = 0; i < toks; i++) {
 
  358             if (stream_id <= TM2_MOT && ctx->tokens[stream_id][i] >= 
TM2_DELTAS) {
 
  360                        ctx->
tokens[stream_id][i], stream_id, i);
 
  389 #define TM2_INIT_POINTERS() \ 
  392     int Ystride, Ustride, Vstride;\ 
  394     Ystride = ctx->y_stride;\ 
  395     Vstride = ctx->uv_stride;\ 
  396     Ustride = ctx->uv_stride;\ 
  397     Y = (ctx->cur?ctx->Y2:ctx->Y1) + by * 4 * Ystride + bx * 4;\ 
  398     V = (ctx->cur?ctx->V2:ctx->V1) + by * 2 * Vstride + bx * 2;\ 
  399     U = (ctx->cur?ctx->U2:ctx->U1) + by * 2 * Ustride + bx * 2;\ 
  400     last = ctx->last + bx * 4;\ 
  401     clast = ctx->clast + bx * 4; 
  403 #define TM2_INIT_POINTERS_2() \ 
  405     int oYstride, oUstride, oVstride;\ 
  407     TM2_INIT_POINTERS();\ 
  411     Yo = (ctx->cur?ctx->Y1:ctx->Y2) + by * 4 * oYstride + bx * 4;\ 
  412     Vo = (ctx->cur?ctx->V1:ctx->V2) + by * 2 * oVstride + bx * 2;\ 
  413     Uo = (ctx->cur?ctx->U1:ctx->U2) + by * 2 * oUstride + bx * 2; 
  416 #define TM2_RECALC_BLOCK(CHR, stride, last, CD) {\ 
  417     CD[0] = CHR[1] - last[1];\ 
  418     CD[1] = (int)CHR[stride + 1] - (int)CHR[1];\ 
  419     last[0] = (int)CHR[stride + 0];\ 
  420     last[1] = (int)CHR[stride + 1];} 
  428     for (j = 0; j < 4; j++){
 
  430         for (i = 0; i < 4; i++){
 
  431             d        = deltas[i + j * 4];
 
  434             Y[i]     = av_clip_uint8(last[i]);
 
  444     for (j = 0; j < 2; j++) {
 
  445         for (i = 0; i < 2; i++)  {
 
  446             CD[j]   += deltas[i + j * 2];
 
  464     t        = (CD[0] + CD[1]) >> 1;
 
  465     l        = (prev - CD[0] - CD[1] + clast[1]) >> 1;
 
  466     CD[1]    = CD[0] + CD[1] - 
t;
 
  480     for (i = 0; i < 4; i++) {
 
  488     for (i = 0; i < 16; i++)
 
  502     deltas[1] = deltas[2] = deltas[3] = 0;
 
  506     deltas[1] = deltas[2] = deltas[3] = 0;
 
  510     for (i = 0; i < 16; i++)
 
  525     deltas[1] = deltas[2] = deltas[3] = 0;
 
  529     deltas[1] = deltas[2] = deltas[3] = 0;
 
  533     for (i = 0; i < 16; i++)
 
  542         last[0] = (last[-1] - ctx->
D[0] - ctx->
D[1] - ctx->
D[2] - ctx->
D[3] + last[1]) >> 1;
 
  544         last[0] = (last[1]  - ctx->
D[0] - ctx->
D[1] - ctx->
D[2] - ctx->
D[3])>> 1;
 
  545     last[2] = (last[1] + last[3]) >> 1;
 
  547     t1 = ctx->
D[0] + ctx->
D[1];
 
  549     ctx->
D[1] = t1 - (t1 >> 1);
 
  550     t2 = ctx->
D[2] + ctx->
D[3];
 
  552     ctx->
D[3] = t2 - (t2 >> 1);
 
  561     int left, right, 
diff;
 
  566     deltas[0] = deltas[1] = deltas[2] = deltas[3] = 0;
 
  569     deltas[0] = deltas[1] = deltas[2] = deltas[3] = 0;
 
  573     for (i = 0; i < 16; i++)
 
  576     ct = ctx->
D[0] + ctx->
D[1] + ctx->
D[2] + ctx->
D[3];
 
  579         left = last[-1] - ct;
 
  585     last[0] = left + (diff >> 2);
 
  586     last[1] = left + (diff >> 1);
 
  587     last[2] = right - (diff >> 2);
 
  592         ctx->
D[0] = (tp + (ct >> 2)) - left;
 
  594         ctx->
D[1] = (tp + (ct >> 1)) - left;
 
  596         ctx->
D[2] = ((tp + ct) - (ct >> 2)) - left;
 
  598         ctx->
D[3] = (tp + ct) - left;
 
  609     for (j = 0; j < 2; j++) {
 
  610         for (i = 0; i < 2; i++){
 
  614         U  += Ustride; 
V += Vstride;
 
  615         Uo += oUstride; Vo += oVstride;
 
  623     ctx->
D[0] = Yo[3] - last[3];
 
  624     ctx->
D[1] = Yo[3 + oYstride] - Yo[3];
 
  625     ctx->
D[2] = Yo[3 + oYstride * 2] - Yo[3 + oYstride];
 
  626     ctx->
D[3] = Yo[3 + oYstride * 3] - Yo[3 + oYstride * 2];
 
  628     for (j = 0; j < 4; j++) {
 
  629         for (i = 0; i < 4; i++) {
 
  645     for (j = 0; j < 2; j++) {
 
  646         for (i = 0; i < 2; i++) {
 
  661     ctx->
D[0] = Yo[3] - last[3];
 
  662     ctx->
D[1] = Yo[3 + oYstride] - Yo[3];
 
  663     ctx->
D[2] = Yo[3 + oYstride * 2] - Yo[3 + oYstride];
 
  664     ctx->
D[3] = Yo[3 + oYstride * 3] - Yo[3 + oYstride * 2];
 
  666     for (j = 0; j < 4; j++) {
 
  668         for (i = 0; i < 4; i++) {
 
  672         ctx->
D[j] = last[3] - d;
 
  686     mx = av_clip(mx, -(bx * 4 + 4), ctx->
avctx->
width  - bx * 4);
 
  687     my = av_clip(my, -(by * 4 + 4), ctx->
avctx->
height - by * 4);
 
  694     Yo += my * oYstride + mx;
 
  695     Uo += (my >> 1) * oUstride + (mx >> 1);
 
  696     Vo += (my >> 1) * oVstride + (mx >> 1);
 
  699     for (j = 0; j < 2; j++) {
 
  700         for (i = 0; i < 2; i++) {
 
  715     for (j = 0; j < 4; j++) {
 
  716         for (i = 0; i < 4; i++) {
 
  724     ctx->
D[0] = 
Y[3] - last[3];
 
  725     ctx->
D[1] = 
Y[3 + Ystride] - 
Y[3];
 
  726     ctx->
D[2] = Y[3 + Ystride * 2] - Y[3 + Ystride];
 
  727     ctx->
D[3] = Y[3 + Ystride * 3] - Y[3 + Ystride * 2];
 
  728     for (i = 0; i < 4; i++)
 
  729         last[i] = Y[i + Ystride * 3];
 
  749     memset(ctx->
last, 0, 4 * bw * 
sizeof(
int));
 
  750     memset(ctx->
clast, 0, 4 * bw * 
sizeof(
int));
 
  752     for (j = 0; j < bh; j++) {
 
  753         memset(ctx->
D, 0, 4 * 
sizeof(
int));
 
  754         memset(ctx->
CD, 0, 4 * 
sizeof(
int));
 
  755         for (i = 0; i < bw; i++) {
 
  789     Y = (ctx->
cur?ctx->
Y2:ctx->
Y1);
 
  790     U = (ctx->
cur?ctx->
U2:ctx->
U1);
 
  791     V = (ctx->
cur?ctx->
V2:ctx->
V1);
 
  793     for (j = 0; j < h; j++) {
 
  794         for (i = 0; i < w; i++) {
 
  795             int y = Y[i], 
u = U[i >> 1], 
v = V[i >> 1];
 
  796             dst[3*i+0] = av_clip_uint8(y + v);
 
  797             dst[3*i+1] = av_clip_uint8(y);
 
  798             dst[3*i+2] = av_clip_uint8(y + u);
 
  802         Y[-4]    = Y[-3]    = Y[-2]    = Y[-1] = Y[0];
 
  803         Y[w + 3] = Y[w + 2] = Y[w + 1] = Y[w]  = Y[w - 1];
 
  811         } 
else if (j == h - 1) {
 
  821             U[-2]     = U[-1] = U[0];
 
  822             V[-2]     = V[-1] = V[0];
 
  823             U[cw + 1] = U[cw] = U[cw - 1];
 
  824             V[cw + 1] = V[cw] = V[cw - 1];
 
  832             } 
else if (j == h - 1) {
 
  852 #define TM2_HEADER_SIZE 40 
  855                         void *
data, 
int *got_frame,
 
  860     int buf_size         = avpkt->
size & ~3;
 
  881         if (offset >= buf_size) {
 
  905     return (ret < 0) ? ret : buf_size;
 
  995     .
name           = 
"truemotion2",