| 1 | diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
|
|---|
| 2 | index fde4e02..0ea14c6 100644
|
|---|
| 3 | --- a/libavcodec/mpeg12.c
|
|---|
| 4 | +++ b/libavcodec/mpeg12.c
|
|---|
| 5 | @@ -112,7 +112,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 6 | break;
|
|---|
| 7 | } else if (level != 0) {
|
|---|
| 8 | i += run;
|
|---|
| 9 | - j = scantable[i];
|
|---|
| 10 | + j = scantable[i & 63];
|
|---|
| 11 | level = (level * qscale * quant_matrix[j]) >> 4;
|
|---|
| 12 | level = (level - 1) | 1;
|
|---|
| 13 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 14 | @@ -128,7 +128,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 15 | level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8);
|
|---|
| 16 | }
|
|---|
| 17 | i += run;
|
|---|
| 18 | - j = scantable[i];
|
|---|
| 19 | + j = scantable[i & 63];
|
|---|
| 20 | if (level < 0) {
|
|---|
| 21 | level = -level;
|
|---|
| 22 | level = (level * qscale * quant_matrix[j]) >> 4;
|
|---|
| 23 | @@ -187,7 +187,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 24 |
|
|---|
| 25 | if (level != 0) {
|
|---|
| 26 | i += run;
|
|---|
| 27 | - j = scantable[i];
|
|---|
| 28 | + j = scantable[i & 63];
|
|---|
| 29 | level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
|---|
| 30 | level = (level - 1) | 1;
|
|---|
| 31 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 32 | @@ -203,7 +203,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 33 | level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
|
|---|
| 34 | }
|
|---|
| 35 | i += run;
|
|---|
| 36 | - j = scantable[i];
|
|---|
| 37 | + j = scantable[i & 63];
|
|---|
| 38 | if (level < 0) {
|
|---|
| 39 | level = -level;
|
|---|
| 40 | level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
|---|
| 41 | @@ -262,7 +262,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
|
|---|
| 42 |
|
|---|
| 43 | if (level != 0) {
|
|---|
| 44 | i += run;
|
|---|
| 45 | - j = scantable[i];
|
|---|
| 46 | + j = scantable[i & 63];
|
|---|
| 47 | level = ((level * 2 + 1) * qscale) >> 1;
|
|---|
| 48 | level = (level - 1) | 1;
|
|---|
| 49 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 50 | @@ -278,7 +278,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
|
|---|
| 51 | level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
|
|---|
| 52 | }
|
|---|
| 53 | i += run;
|
|---|
| 54 | - j = scantable[i];
|
|---|
| 55 | + j = scantable[i & 63];
|
|---|
| 56 | if (level < 0) {
|
|---|
| 57 | level = -level;
|
|---|
| 58 | level = ((level * 2 + 1) * qscale) >> 1;
|
|---|
| 59 | @@ -343,7 +343,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
|---|
| 60 |
|
|---|
| 61 | if (level != 0) {
|
|---|
| 62 | i += run;
|
|---|
| 63 | - j = scantable[i];
|
|---|
| 64 | + j = scantable[i & 63];
|
|---|
| 65 | level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
|---|
| 66 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 67 | SKIP_BITS(re, &s->gb, 1);
|
|---|
| 68 | @@ -354,7 +354,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
|---|
| 69 | level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
|---|
| 70 |
|
|---|
| 71 | i += run;
|
|---|
| 72 | - j = scantable[i];
|
|---|
| 73 | + j = scantable[i & 63];
|
|---|
| 74 | if (level < 0) {
|
|---|
| 75 | level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
|---|
| 76 | level = -level;
|
|---|
| 77 | @@ -412,7 +412,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|---|
| 78 |
|
|---|
| 79 | if (level != 0) {
|
|---|
| 80 | i += run;
|
|---|
| 81 | - j = scantable[i];
|
|---|
| 82 | + j = scantable[i & 63];
|
|---|
| 83 | level = ((level * 2 + 1) * qscale) >> 1;
|
|---|
| 84 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 85 | SKIP_BITS(re, &s->gb, 1);
|
|---|
| 86 | @@ -423,7 +423,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|---|
| 87 | level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
|---|
| 88 |
|
|---|
| 89 | i += run;
|
|---|
| 90 | - j = scantable[i];
|
|---|
| 91 | + j = scantable[i & 63];
|
|---|
| 92 | if (level < 0) {
|
|---|
| 93 | level = ((-level * 2 + 1) * qscale) >> 1;
|
|---|
| 94 | level = -level;
|
|---|
| 95 | @@ -489,7 +489,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 96 | break;
|
|---|
| 97 | } else if (level != 0) {
|
|---|
| 98 | i += run;
|
|---|
| 99 | - j = scantable[i];
|
|---|
| 100 | + j = scantable[i & 63];
|
|---|
| 101 | level = (level * qscale * quant_matrix[j]) >> 4;
|
|---|
| 102 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 103 | LAST_SKIP_BITS(re, &s->gb, 1);
|
|---|
| 104 | @@ -499,7 +499,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 105 | UPDATE_CACHE(re, &s->gb);
|
|---|
| 106 | level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
|---|
| 107 | i += run;
|
|---|
| 108 | - j = scantable[i];
|
|---|
| 109 | + j = scantable[i & 63];
|
|---|
| 110 | if (level < 0) {
|
|---|
| 111 | level = (-level * qscale * quant_matrix[j]) >> 4;
|
|---|
| 112 | level = -level;
|
|---|
| 113 | @@ -526,6 +526,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|---|
| 114 | static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
|---|
| 115 | {
|
|---|
| 116 | int level, dc, diff, j, run;
|
|---|
| 117 | + int i=0;
|
|---|
| 118 | int component;
|
|---|
| 119 | RLTable *rl;
|
|---|
| 120 | uint8_t * scantable = s->intra_scantable.permutated;
|
|---|
| 121 | @@ -562,8 +563,8 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
|---|
| 122 | if (level == 127) {
|
|---|
| 123 | break;
|
|---|
| 124 | } else if (level != 0) {
|
|---|
| 125 | - scantable += run;
|
|---|
| 126 | - j = *scantable;
|
|---|
| 127 | + i += run;
|
|---|
| 128 | + j = scantable[i & 63];
|
|---|
| 129 | level = (level * qscale * quant_matrix[j]) >> 4;
|
|---|
| 130 | level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
|---|
| 131 | LAST_SKIP_BITS(re, &s->gb, 1);
|
|---|
| 132 | @@ -572,8 +573,8 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
|---|
| 133 | run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
|
|---|
| 134 | UPDATE_CACHE(re, &s->gb);
|
|---|
| 135 | level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
|---|
| 136 | - scantable += run;
|
|---|
| 137 | - j = *scantable;
|
|---|
| 138 | + i += run;
|
|---|
| 139 | + j = scantable[ i & 63];
|
|---|
| 140 | if (level < 0) {
|
|---|
| 141 | level = (-level * qscale * quant_matrix[j]) >> 4;
|
|---|
| 142 | level = -level;
|
|---|