+ diff = compareregions(s, bx, by);
+ if(diff < 24 /*TODO: should be a parameter- good values are between 32 and 48 */) {
+ swf_SetBits(tag, 1,1); /* cod=1, block skipped */
+ copyregion(s, s->current, s->oldpic, bx, by);
+ return;
+ }
+
+ getregion(&fb, s->current, bx, by, s->width);
+
+ //if(diff < 128)
+ if(1)
+ {
+ /* mvd (0,0) block (mode=0) */
+ int t;
+ memcpy(&fbdiff, &fb, sizeof(fblock_t));
+ getregion(&fbold, s->oldpic, bx, by, s->linex);
+ yuvdiff(&fbdiff, &fbold);
+ //getregiondiff(&fbdiff, s->oldpic, s->current, bx, by, s->linex);
+ dodct(&fbdiff);
+ has_dc = 0;
+
+ quantize(&fbdiff, &b, has_dc, *quant);
+ getblockpatterns(&b, &cbpybits, &cbpcbits, has_dc);
+ mode = 0; // mvd w/o mvd24
+ swf_SetBits(tag,0,1); // COD
+ codehuffman(tag, mcbpc_inter, mode*4+cbpcbits);
+ codehuffman(tag, cbpy, cbpybits^15);
+
+ /* 0,0 */
+ codehuffman(tag, mvd, 32);
+ codehuffman(tag, mvd, 32);
+
+ /* luminance */
+ encode8x8(tag, b.y1, has_dc, cbpybits&8);
+ encode8x8(tag, b.y2, has_dc, cbpybits&4);
+ encode8x8(tag, b.y3, has_dc, cbpybits&2);
+ encode8x8(tag, b.y4, has_dc, cbpybits&1);
+
+ /* chrominance */
+ encode8x8(tag, b.u, has_dc, cbpcbits&2);
+ encode8x8(tag, b.v, has_dc, cbpcbits&1);
+
+ /* -- reconstruction -- */
+ dequantize(&b, 0, *quant);
+
+ doidct(&b);
+ for(t=0;t<64;t++) {
+ b.y1[t] = truncate256(b.y1[t] + (int)fbold.y1[t]);
+ b.y2[t] = truncate256(b.y2[t] + (int)fbold.y2[t]);
+ b.y3[t] = truncate256(b.y3[t] + (int)fbold.y3[t]);
+ b.y4[t] = truncate256(b.y4[t] + (int)fbold.y4[t]);
+ b.u[t] = truncate256(b.u[t] + (int)fbold.u[t]);
+ b.v[t] = truncate256(b.v[t] + (int)fbold.v[t]);