Go to the documentation of this file. 1 /*
2 * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * see https://multimedia.cx/huffyuv.txt for a description of
5 * the algorithm used
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * yuva, gray, 4:4:4, 4:1:1, 4:1:0 and >8 bit per sample support sponsored by NOA
24 */
25
26 /**
27 * @file
28 * huffyuv encoder
29 */
30
31 #include "config_components.h"
32
46
58 int vlc_n;
// number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
67
68 union {
71 };
78 int non_determ;
// non-deterministic, multi-threaded encoder allowed
80
82 const uint8_t *
src0,
const uint8_t *
src1,
int w)
83 {
86 } else {
87 s->hencdsp.diff_int16((uint16_t *)
dst, (
const uint16_t *)
src0, (
const uint16_t *)
src1,
s->n - 1,
w);
88 }
89 }
90
93 {
95 int min_width =
FFMIN(
w, 32);
96
98 for (
i = 0;
i < min_width;
i++) {
/* scalar loop before dsp call */
102 }
105 s->llvidencdsp.diff_bytes(
dst + 32,
src + 32,
src + 31,
w - 32);
107 } else {
108 const uint16_t *src16 = (
const uint16_t *)
src;
109 uint16_t *dst16 = ( uint16_t *)
dst;
110 for (
i = 0;
i < min_width;
i++) {
/* scalar loop before dsp call */
111 const int temp = src16[
i];
114 }
117 s->hencdsp.diff_int16(dst16 + 32, src16 + 32, src16 + 31,
s->n - 1,
w - 32);
119 }
120 }
121
123 const uint8_t *
src,
int w,
124 int *red, int *green, int *blue,
126 {
129 int min_width =
FFMIN(
w, 8);
134
135 for (
i = 0;
i < min_width;
i++) {
136 const int rt =
src[
i * 4 +
R];
137 const int gt =
src[
i * 4 +
G];
138 const int bt =
src[
i * 4 +
B];
139 const int at =
src[
i * 4 +
A];
148 }
149
150 s->llvidencdsp.diff_bytes(
dst + 32,
src + 32,
src + 32 - 4,
w * 4 - 32);
151
152 *red =
src[(
w - 1) * 4 +
R];
153 *green =
src[(
w - 1) * 4 +
G];
154 *blue =
src[(
w - 1) * 4 +
B];
156 }
157
159 const uint8_t *
src,
int w,
160 int *red, int *green, int *blue)
161 {
168 const int rt =
src[
i * 3 + 0];
169 const int gt =
src[
i * 3 + 1];
170 const int bt =
src[
i * 3 + 2];
171 dst[
i * 3 + 0] = rt -
r;
172 dst[
i * 3 + 1] = gt -
g;
173 dst[
i * 3 + 2] = bt -
b;
177 }
178
179 s->llvidencdsp.diff_bytes(
dst + 48,
src + 48,
src + 48 - 3,
w * 3 - 48);
180
181 *red =
src[(
w - 1) * 3 + 0];
182 *green =
src[(
w - 1) * 3 + 1];
183 *blue =
src[(
w - 1) * 3 + 2];
184 }
185
187 const uint8_t *
src1,
const uint8_t *
src2,
188 int w,
int *
left,
int *left_top)
189 {
192 } else {
193 s->hencdsp.sub_hfyu_median_pred_int16((uint16_t *)
dst, (
const uint16_t *)
src1, (
const uint16_t *)
src2,
s->n - 1,
w ,
left, left_top);
194 }
195 }
196
198 {
202
203 for (
i = 0;
i < n;) {
205 int repeat = 0;
206
207 for (;
i < n &&
len[
i] ==
val && repeat < 255;
i++)
208 repeat++;
209
210 av_assert0(val < 32 && val >0 && repeat < 256 && repeat>0);
211 if (repeat > 7) {
213 buf[
index++] = repeat;
214 } else {
216 }
217 }
218
220 }
221
223 {
226 int count = 3;
227
229 count = 1 +
s->alpha + 2*
s->chroma;
230
231 for (
i = 0;
i < count;
i++) {
234
238
240 }
242 }
243
245 {
250
253
257
262 #define STATS_OUT_SIZE 21*MAX_N*3 + 4
266 }
268
270 s->bps =
desc->comp[0].depth;
272 s->chroma =
desc->nb_components > 2;
274 s->chroma_h_shift =
desc->log2_chroma_w;
275 s->chroma_v_shift =
desc->log2_chroma_h;
276
280 if (avctx->
width & 1) {
283 }
285 break;
327 break;
329 s->bitstream_bpp = 32;
330 break;
332 s->bitstream_bpp = 24;
333 break;
334 default:
337 }
340
347 "context=1 is not compatible with "
348 "2 pass huffyuv encoding\n");
350 }
351 }
352
354 if (
s->interlaced != ( avctx->
height > 288 ))
356 "using huffyuv 2.2.0 or newer interlacing flag\n");
357 }
358
360 av_log(avctx,
AV_LOG_ERROR,
"Ver > 3 is under development, files encoded with it may not be decodable with future versions!!!\n"
361 "Use vstrict=-2 / -strict -2 to use it anyway.\n");
363 }
364
365 if (
s->bitstream_bpp >= 24 &&
s->predictor ==
MEDIAN &&
s->version <= 2) {
367 "Error: RGB is incompatible with median predictor\n");
369 }
370
371 avctx->
extradata[0] =
s->predictor | (
s->decorrelate << 6);
372 avctx->
extradata[2] =
s->interlaced ? 0x10 : 0x20;
375 if (
s->version < 3) {
378 } else {
379 avctx->
extradata[1] = ((
s->bps-1)<<4) |
s->chroma_h_shift | (
s->chroma_v_shift<<2);
385 }
387
390
391 for (
i = 0;
i < 4;
i++)
392 for (j = 0; j <
s->vlc_n; j++)
394
396 for (
i = 0;
i < 4;
i++) {
397 char *next;
398
399 for (j = 0; j <
s->vlc_n; j++) {
400 s->stats[
i][j] += strtol(
p, &next, 0);
401 if (next ==
p)
return -1;
403 }
404 }
405 if (
p[0] == 0 ||
p[1] == 0 ||
p[2] == 0)
break;
406 }
407 } else {
408 for (
i = 0;
i < 4;
i++)
409 for (j = 0; j <
s->vlc_n; j++) {
410 int d =
FFMIN(j,
s->vlc_n - j);
411
412 s->stats[
i][j] = 100000000 / (d*d + 1);
413 }
414 }
415
420
422 for (
i = 0;
i < 4;
i++) {
423 int pels = avctx->
width * avctx->
height / (
i ? 40 : 10);
424 for (j = 0; j <
s->vlc_n; j++) {
425 int d =
FFMIN(j,
s->vlc_n - j);
426 s->stats[
i][j] = pels/(d*d + 1);
427 }
428 }
429 } else {
430 for (
i = 0;
i < 4;
i++)
431 for (j = 0; j <
s->vlc_n; j++)
433 }
434
436
437 for (
int i = 0;
i < 3;
i++) {
441 }
442
443 return 0;
444 }
446 {
448 const uint8_t *y =
s->temp[0] +
offset;
449 const uint8_t *
u =
s->temp[1] +
offset / 2;
450 const uint8_t *v =
s->temp[2] +
offset / 2;
451
454 return -1;
455 }
456
457 #define LOAD4\
458 int y0 = y[2 * i];\
459 int y1 = y[2 * i + 1];\
460 int u0 = u[i];\
461 int v0 = v[i];
462
463 count /= 2;
464
466 for(
i = 0;
i < count;
i++) {
472 }
473 }
475 return 0;
477 for (
i = 0;
i < count;
i++) {
487 }
488 } else {
489 for(
i = 0;
i < count;
i++) {
495 }
496 }
497 return 0;
498 }
499
501 {
503
506 return -1;
507 }
508
509 #define LOADEND\
510 int y0 = s->temp[0][width-1];
511 #define LOADEND_14\
512 int y0 = s->temp16[0][width-1] & mask;
513 #define LOADEND_16\
514 int y0 = s->temp16[0][width-1];
515 #define STATEND\
516 s->stats[plane][y0]++;
517 #define STATEND_16\
518 s->stats[plane][y0>>2]++;
519 #define WRITEEND\
520 put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);
521 #define WRITEEND_16\
522 put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
523 put_bits(&s->pb, 2, y0&3);
524
525 #define LOAD2\
526 int y0 = s->temp[0][2 * i];\
527 int y1 = s->temp[0][2 * i + 1];
528 #define LOAD2_14\
529 int y0 = s->temp16[0][2 * i] & mask;\
530 int y1 = s->temp16[0][2 * i + 1] & mask;
531 #define LOAD2_16\
532 int y0 = s->temp16[0][2 * i];\
533 int y1 = s->temp16[0][2 * i + 1];
534 #define STAT2\
535 s->stats[plane][y0]++;\
536 s->stats[plane][y1]++;
537 #define STAT2_16\
538 s->stats[plane][y0>>2]++;\
539 s->stats[plane][y1>>2]++;
540 #define WRITE2\
541 put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);\
542 put_bits(&s->pb, s->len[plane][y1], s->bits[plane][y1]);
543 #define WRITE2_16\
544 put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
545 put_bits(&s->pb, 2, y0&3);\
546 put_bits(&s->pb, s->len[plane][y1>>2], s->bits[plane][y1>>2]);\
547 put_bits(&s->pb, 2, y1&3);
548
549 #define ENCODE_PLANE(LOAD, LOADEND, WRITE, WRITEEND, STAT, STATEND) \
550 do { \
551 if (s->flags & AV_CODEC_FLAG_PASS1) { \
552 for (int i = 0; i < count; i++) { \
553 LOAD; \
554 STAT; \
555 } \
556 if (width & 1) { \
557 LOADEND; \
558 STATEND; \
559 } \
560 } \
561 if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) \
562 return 0; \
563 \
564 if (s->context) { \
565 for (int i = 0; i < count; i++) { \
566 LOAD; \
567 STAT; \
568 WRITE; \
569 } \
570 if (width & 1) { \
571 LOADEND; \
572 STATEND; \
573 WRITEEND; \
574 } \
575 } else { \
576 for (int i = 0; i < count; i++) { \
577 LOAD; \
578 WRITE; \
579 } \
580 if (width & 1) { \
581 LOADEND; \
582 WRITEEND; \
583 } \
584 } \
585 } while (0)
586
589 }
else if (
s->bps <= 14) {
591
593 } else {
595 }
596 #undef LOAD2
597 #undef STAT2
598 #undef WRITE2
599 return 0;
600 }
601
603 {
605
608 return -1;
609 }
610
611 #define LOAD2\
612 int y0 = s->temp[0][2 * i];\
613 int y1 = s->temp[0][2 * i + 1];
614 #define STAT2\
615 s->stats[0][y0]++;\
616 s->stats[0][y1]++;
617 #define WRITE2\
618 put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\
619 put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
620
621 count /= 2;
622
624 for (
i = 0;
i < count;
i++) {
627 }
628 }
630 return 0;
631
633 for (
i = 0;
i < count;
i++) {
637 }
638 } else {
639 for (
i = 0;
i < count;
i++) {
642 }
643 }
644 return 0;
645 }
646
648 {
650
653 return -1;
654 }
655
656 #define LOAD_GBRA \
657 int g = s->temp[0][planes == 3 ? 3 * i + 1 : 4 * i + G]; \
658 int b =(s->temp[0][planes == 3 ? 3 * i + 2 : 4 * i + B] - g) & 0xFF;\
659 int r =(s->temp[0][planes == 3 ? 3 * i + 0 : 4 * i + R] - g) & 0xFF;\
660 int a = s->temp[0][planes * i + A];
661
662 #define STAT_BGRA \
663 s->stats[0][b]++; \
664 s->stats[1][g]++; \
665 s->stats[2][r]++; \
666 if (planes == 4) \
667 s->stats[2][a]++;
668
669 #define WRITE_GBRA \
670 put_bits(&s->pb, s->len[1][g], s->bits[1][g]); \
671 put_bits(&s->pb, s->len[0][b], s->bits[0][b]); \
672 put_bits(&s->pb, s->len[2][r], s->bits[2][r]); \
673 if (planes == 4) \
674 put_bits(&s->pb, s->len[2][a], s->bits[2][a]);
675
678 for (
i = 0;
i < count;
i++) {
681 }
683 for (
i = 0;
i < count;
i++) {
687 }
688 } else {
689 for (
i = 0;
i < count;
i++) {
692 }
693 }
694 return 0;
695 }
696
699 {
702 const int width2 = avctx->
width >> 1;
704 const int fake_ystride = (1 +
s->interlaced) *
p->linesize[0];
705 const int fake_ustride = (1 +
s->interlaced) *
p->linesize[1];
706 const int fake_vstride = (1 +
s->interlaced) *
p->linesize[2];
708
711
716
717 for (
i = 0;
i < 4;
i++)
718 for (j = 0; j <
s->vlc_n; j++)
719 s->stats[
i][j] >>= 1;
720 }
721
723
726 int lefty, leftu, leftv, y, cy;
727
732
736
738
740 int lefttopy, lefttopu, lefttopv;
741 cy = y = 1;
746
748 y++; cy++;
749 }
750
754
756
757 lefttopy =
p->data[0][3];
758 lefttopu =
p->data[1][1];
759 lefttopv =
p->data[2][1];
760 s->llvidencdsp.sub_median_pred(
s->temp[0],
p->data[0] + 4,
p->data[0] + fake_ystride + 4,
width - 4, &lefty, &lefttopy);
761 s->llvidencdsp.sub_median_pred(
s->temp[1],
p->data[1] + 2,
p->data[1] + fake_ustride + 2, width2 - 2, &leftu, &lefttopu);
762 s->llvidencdsp.sub_median_pred(
s->temp[2],
p->data[2] + 2,
p->data[2] + fake_vstride + 2, width2 - 2, &leftv, &lefttopv);
764 y++; cy++;
765
766 for (; y <
height; y++,cy++) {
767 const uint8_t *ydst, *udst, *vdst;
768
769 if (
s->bitstream_bpp == 12) {
770 while (2 * cy > y) {
771 ydst =
p->data[0] +
p->linesize[0] * y;
772 s->llvidencdsp.sub_median_pred(
s->temp[0], ydst - fake_ystride, ydst,
width, &lefty, &lefttopy);
774 y++;
775 }
777 }
778 ydst =
p->data[0] +
p->linesize[0] * y;
779 udst =
p->data[1] +
p->linesize[1] * cy;
780 vdst =
p->data[2] +
p->linesize[2] * cy;
781
782 s->llvidencdsp.sub_median_pred(
s->temp[0], ydst - fake_ystride, ydst,
width, &lefty, &lefttopy);
783 s->llvidencdsp.sub_median_pred(
s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu);
784 s->llvidencdsp.sub_median_pred(
s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv);
785
787 }
788 } else {
789 for (cy = y = 1; y <
height; y++, cy++) {
790 const uint8_t *ydst, *udst, *vdst;
791
792 /* encode a luma only line & y++ */
793 if (
s->bitstream_bpp == 12) {
794 ydst =
p->data[0] +
p->linesize[0] * y;
795
796 if (
s->predictor ==
PLANE &&
s->interlaced < y) {
797 s->llvidencdsp.diff_bytes(
s->temp[1], ydst, ydst - fake_ystride,
width);
798
800 } else {
802 }
804 y++;
806 }
807
808 ydst =
p->data[0] +
p->linesize[0] * y;
809 udst =
p->data[1] +
p->linesize[1] * cy;
810 vdst =
p->data[2] +
p->linesize[2] * cy;
811
812 if (
s->predictor ==
PLANE &&
s->interlaced < cy) {
813 s->llvidencdsp.diff_bytes(
s->temp[1], ydst, ydst - fake_ystride,
width);
814 s->llvidencdsp.diff_bytes(
s->temp[2], udst, udst - fake_ustride, width2);
815 s->llvidencdsp.diff_bytes(
s->temp[2] + width2, vdst, vdst - fake_vstride, width2);
816
820 } else {
824 }
825
827 }
828 }
830 const uint8_t *
data =
p->data[0] + (
height - 1) *
p->linesize[0];
831 const int stride = -
p->linesize[0];
832 const int fake_stride = -fake_ystride;
833 int leftr, leftg, leftb, lefta;
834
839
841 &leftr, &leftg, &leftb, &lefta);
843
844 for (
int y = 1; y <
height; y++) {
846 if (
s->predictor ==
PLANE &&
s->interlaced < y) {
847 s->llvidencdsp.diff_bytes(
s->temp[1],
dst,
dst - fake_stride,
width * 4);
849 &leftr, &leftg, &leftb, &lefta);
850 } else {
852 &leftr, &leftg, &leftb, &lefta);
853 }
855 }
857 const uint8_t *
data =
p->data[0] + (
height - 1) *
p->linesize[0];
858 const int stride = -
p->linesize[0];
859 const int fake_stride = -fake_ystride;
860 int leftr, leftg, leftb;
861
866
868 &leftr, &leftg, &leftb);
870
871 for (
int y = 1; y <
height; y++) {
873 if (
s->predictor ==
PLANE &&
s->interlaced < y) {
874 s->llvidencdsp.diff_bytes(
s->temp[1],
dst,
dst - fake_stride,
877 &leftr, &leftg, &leftb);
878 } else {
880 &leftr, &leftg, &leftb);
881 }
883 }
884 }
else if (
s->version > 2) {
885 int plane;
886 for (plane = 0; plane < 1 + 2*
s->chroma +
s->alpha; plane++) {
890 int fake_stride = fake_ystride;
891
892 if (
s->chroma && (plane == 1 || plane == 2)) {
893 w >>=
s->chroma_h_shift;
894 h >>=
s->chroma_v_shift;
895 fake_stride = plane == 1 ? fake_ustride : fake_vstride;
896 }
897
899
901
903 int lefttop;
904 y = 1;
907
909 y++;
910 }
911
912 lefttop =
p->data[plane][0];
913
915 const uint8_t *
dst =
p->data[plane] +
p->linesize[plane] * y;
916
918
920 }
921 } else {
922 for (y = 1; y <
h; y++) {
923 const uint8_t *
dst =
p->data[plane] +
p->linesize[plane] * y;
924
925 if (
s->predictor ==
PLANE &&
s->interlaced < y) {
927
929 } else {
931 }
932
934 }
935 }
936 }
937 } else {
939 }
941
946
948 int j;
951 for (
i = 0;
i < 4;
i++) {
952 for (j = 0; j <
s->vlc_n; j++) {
956 }
961 }
967 }
968
970
972 *got_packet = 1;
973
974 return 0;
975 }
976
978 {
980
982
983 for (
int i = 0;
i < 3;
i++)
985
986 return 0;
987 }
988
989 #define OFFSET(x) offsetof(HYuvEncContext, x)
990 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
991
993 /* ffvhuff-only options */
995 /* Common options */
996 { "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism",
1004 };
1005
1011 };
1012
1014 .
p.
name =
"huffyuv",
1028 };
1029
1030 #if CONFIG_FFVHUFF_ENCODER
1031 static const AVClass ff_class = {
1036 };
1037
1039 .
p.
name =
"ffvhuff",
1049 .p.priv_class = &ff_class,
1068 };
1069 #endif
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