summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/slice.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-12-07 13:00:31 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-12-07 13:00:31 +0000
commit2b5f979d75a3d1c85b498c87ba6ae4c98c3011bc (patch)
treed9c40aa330a2bd973794eca11c86d559549422ca /apps/plugins/mpegplayer/slice.c
parent5886efabf5e4c96a8a96836d665aad935c727e31 (diff)
downloadrockbox-2b5f979d75a3d1c85b498c87ba6ae4c98c3011bc.zip
rockbox-2b5f979d75a3d1c85b498c87ba6ae4c98c3011bc.tar.gz
rockbox-2b5f979d75a3d1c85b498c87ba6ae4c98c3011bc.tar.bz2
rockbox-2b5f979d75a3d1c85b498c87ba6ae4c98c3011bc.tar.xz
Reformat and code police (tabs, trailing whitespace, annoying overuse of parentheses, etc.) in libmpeg2 so I can stomach working on it. Don't call IDCT functions through pointers - I don't feel like extracting that change just for relevance sake.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15892 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer/slice.c')
-rw-r--r--apps/plugins/mpegplayer/slice.c1453
1 files changed, 886 insertions, 567 deletions
diff --git a/apps/plugins/mpegplayer/slice.c b/apps/plugins/mpegplayer/slice.c
index 7c1c07b..a039eb8 100644
--- a/apps/plugins/mpegplayer/slice.c
+++ b/apps/plugins/mpegplayer/slice.c
@@ -30,11 +30,6 @@
#include "attributes.h"
#include "mpeg2_internal.h"
-extern mpeg2_mc_t mpeg2_mc;
-extern void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
-extern void (* mpeg2_idct_add) (int last, int16_t * block,
- uint8_t * dest, int stride);
-
#include "vlc.h"
static inline int get_macroblock_modes (mpeg2_decoder_t * const decoder)
@@ -42,18 +37,20 @@ static inline int get_macroblock_modes (mpeg2_decoder_t * const decoder)
#define bit_buf (decoder->bitstream_buf)
#define bits (decoder->bitstream_bits)
#define bit_ptr (decoder->bitstream_ptr)
+
int macroblock_modes;
const MBtab * tab;
- switch (decoder->coding_type) {
+ switch (decoder->coding_type)
+ {
case I_TYPE:
-
tab = MB_I + UBITS (bit_buf, 1);
DUMPBITS (bit_buf, bits, tab->len);
macroblock_modes = tab->modes;
- if ((! (decoder->frame_pred_frame_dct)) &&
- (decoder->picture_structure == FRAME_PICTURE)) {
+ if (!(decoder->frame_pred_frame_dct) &&
+ decoder->picture_structure == FRAME_PICTURE)
+ {
macroblock_modes |= UBITS (bit_buf, 1) * DCT_TYPE_INTERLACED;
DUMPBITS (bit_buf, bits, 1);
}
@@ -61,55 +58,75 @@ static inline int get_macroblock_modes (mpeg2_decoder_t * const decoder)
return macroblock_modes;
case P_TYPE:
-
tab = MB_P + UBITS (bit_buf, 5);
DUMPBITS (bit_buf, bits, tab->len);
macroblock_modes = tab->modes;
- if (decoder->picture_structure != FRAME_PICTURE) {
- if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) {
+ if (decoder->picture_structure != FRAME_PICTURE)
+ {
+ if (macroblock_modes & MACROBLOCK_MOTION_FORWARD)
+ {
macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
DUMPBITS (bit_buf, bits, 2);
}
+
return macroblock_modes | MACROBLOCK_MOTION_FORWARD;
- } else if (decoder->frame_pred_frame_dct) {
+ }
+ else if (decoder->frame_pred_frame_dct)
+ {
if (macroblock_modes & MACROBLOCK_MOTION_FORWARD)
macroblock_modes |= MC_FRAME << MOTION_TYPE_SHIFT;
+
return macroblock_modes | MACROBLOCK_MOTION_FORWARD;
- } else {
- if (macroblock_modes & MACROBLOCK_MOTION_FORWARD) {
+ }
+ else
+ {
+ if (macroblock_modes & MACROBLOCK_MOTION_FORWARD)
+ {
macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
DUMPBITS (bit_buf, bits, 2);
}
- if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN)) {
+
+ if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN))
+ {
macroblock_modes |= UBITS (bit_buf, 1) * DCT_TYPE_INTERLACED;
DUMPBITS (bit_buf, bits, 1);
}
+
return macroblock_modes | MACROBLOCK_MOTION_FORWARD;
}
case B_TYPE:
-
tab = MB_B + UBITS (bit_buf, 6);
DUMPBITS (bit_buf, bits, tab->len);
macroblock_modes = tab->modes;
- if (decoder->picture_structure != FRAME_PICTURE) {
- if (! (macroblock_modes & MACROBLOCK_INTRA)) {
+ if (decoder->picture_structure != FRAME_PICTURE)
+ {
+ if (! (macroblock_modes & MACROBLOCK_INTRA))
+ {
macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
DUMPBITS (bit_buf, bits, 2);
}
+
return macroblock_modes;
- } else if (decoder->frame_pred_frame_dct) {
+ }
+ else if (decoder->frame_pred_frame_dct)
+ {
/* if (! (macroblock_modes & MACROBLOCK_INTRA)) */
macroblock_modes |= MC_FRAME << MOTION_TYPE_SHIFT;
return macroblock_modes;
- } else {
+ }
+ else
+ {
if (macroblock_modes & MACROBLOCK_INTRA)
goto intra;
+
macroblock_modes |= UBITS (bit_buf, 2) << MOTION_TYPE_SHIFT;
DUMPBITS (bit_buf, bits, 2);
- if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN)) {
+
+ if (macroblock_modes & (MACROBLOCK_INTRA | MACROBLOCK_PATTERN))
+ {
intra:
macroblock_modes |= UBITS (bit_buf, 1) * DCT_TYPE_INTERLACED;
DUMPBITS (bit_buf, bits, 1);
@@ -118,7 +135,6 @@ static inline int get_macroblock_modes (mpeg2_decoder_t * const decoder)
}
case D_TYPE:
-
DUMPBITS (bit_buf, bits, 1);
return MACROBLOCK_INTRA;
@@ -143,10 +159,13 @@ static inline void get_quantizer_scale (mpeg2_decoder_t * const decoder)
decoder->quantizer_matrix[0] =
decoder->quantizer_prescale[0][quantizer_scale_code];
+
decoder->quantizer_matrix[1] =
decoder->quantizer_prescale[1][quantizer_scale_code];
+
decoder->quantizer_matrix[2] =
decoder->chroma_quantizer[0][quantizer_scale_code];
+
decoder->quantizer_matrix[3] =
decoder->chroma_quantizer[1][quantizer_scale_code];
#undef bit_buf
@@ -165,11 +184,13 @@ static inline int get_motion_delta (mpeg2_decoder_t * const decoder,
int sign;
const MVtab * tab;
- if (bit_buf & 0x80000000) {
+ if (bit_buf & 0x80000000)
+ {
DUMPBITS (bit_buf, bits, 1);
return 0;
- } else if (bit_buf >= 0x0c000000) {
-
+ }
+ else if (bit_buf >= 0x0c000000)
+ {
tab = MV_4 + UBITS (bit_buf, 4);
delta = (tab->delta << f_code) + 1;
bits += tab->len + f_code + 1;
@@ -183,9 +204,9 @@ static inline int get_motion_delta (mpeg2_decoder_t * const decoder,
bit_buf <<= f_code;
return (delta ^ sign) - sign;
-
- } else {
-
+ }
+ else
+ {
tab = MV_10 + UBITS (bit_buf, 10);
delta = (tab->delta << f_code) + 1;
bits += tab->len + 1;
@@ -194,7 +215,8 @@ static inline int get_motion_delta (mpeg2_decoder_t * const decoder,
sign = SBITS (bit_buf, 1);
bit_buf <<= 1;
- if (f_code) {
+ if (f_code)
+ {
NEEDBITS (bit_buf, bits, bit_ptr);
delta += UBITS (bit_buf, f_code);
DUMPBITS (bit_buf, bits, f_code);
@@ -224,6 +246,7 @@ static inline int get_dmv (mpeg2_decoder_t * const decoder)
tab = DMV_2 + UBITS (bit_buf, 2);
DUMPBITS (bit_buf, bits, tab->len);
return tab->dmv;
+
#undef bit_buf
#undef bits
#undef bit_ptr
@@ -239,14 +262,14 @@ static inline int get_coded_block_pattern (mpeg2_decoder_t * const decoder)
NEEDBITS (bit_buf, bits, bit_ptr);
- if (bit_buf >= 0x20000000) {
-
+ if (bit_buf >= 0x20000000)
+ {
tab = CBP_7 + (UBITS (bit_buf, 7) - 16);
DUMPBITS (bit_buf, bits, tab->len);
return tab->cbp;
-
- } else {
-
+ }
+ else
+ {
tab = CBP_9 + UBITS (bit_buf, 9);
DUMPBITS (bit_buf, bits, tab->len);
return tab->cbp;
@@ -262,25 +285,33 @@ static inline int get_luma_dc_dct_diff (mpeg2_decoder_t * const decoder)
#define bit_buf (decoder->bitstream_buf)
#define bits (decoder->bitstream_bits)
#define bit_ptr (decoder->bitstream_ptr)
+
const DCtab * tab;
int size;
int dc_diff;
- if (bit_buf < 0xf8000000) {
+ if (bit_buf < 0xf8000000)
+ {
tab = DC_lum_5 + UBITS (bit_buf, 5);
size = tab->size;
- if (size) {
+
+ if (size)
+ {
bits += tab->len + size;
bit_buf <<= tab->len;
dc_diff =
UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size);
bit_buf <<= size;
return dc_diff << decoder->intra_dc_precision;
- } else {
+ }
+ else
+ {
DUMPBITS (bit_buf, bits, 3);
return 0;
}
- } else {
+ }
+ else
+ {
tab = DC_long + (UBITS (bit_buf, 9) - 0x1e0);
size = tab->size;
DUMPBITS (bit_buf, bits, tab->len);
@@ -289,6 +320,7 @@ static inline int get_luma_dc_dct_diff (mpeg2_decoder_t * const decoder)
DUMPBITS (bit_buf, bits, size);
return dc_diff << decoder->intra_dc_precision;
}
+
#undef bit_buf
#undef bits
#undef bit_ptr
@@ -299,25 +331,33 @@ static inline int get_chroma_dc_dct_diff (mpeg2_decoder_t * const decoder)
#define bit_buf (decoder->bitstream_buf)
#define bits (decoder->bitstream_bits)
#define bit_ptr (decoder->bitstream_ptr)
+
const DCtab * tab;
int size;
int dc_diff;
- if (bit_buf < 0xf8000000) {
+ if (bit_buf < 0xf8000000)
+ {
tab = DC_chrom_5 + UBITS (bit_buf, 5);
size = tab->size;
- if (size) {
+
+ if (size)
+ {
bits += tab->len + size;
bit_buf <<= tab->len;
dc_diff =
UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size);
bit_buf <<= size;
return dc_diff << decoder->intra_dc_precision;
- } else {
+ }
+ else
+ {
DUMPBITS (bit_buf, bits, 2);
return 0;
}
- } else {
+ }
+ else
+ {
tab = DC_long + (UBITS (bit_buf, 10) - 0x3e0);
size = tab->size;
DUMPBITS (bit_buf, bits, tab->len + 1);
@@ -326,17 +366,18 @@ static inline int get_chroma_dc_dct_diff (mpeg2_decoder_t * const decoder)
DUMPBITS (bit_buf, bits, size);
return dc_diff << decoder->intra_dc_precision;
}
+
#undef bit_buf
#undef bits
#undef bit_ptr
}
-#define SATURATE(val) \
-do { \
- val <<= 4; \
- if (unlikely (val != (int16_t) val)) \
- val = (SBITS (val, 1) ^ 2047) << 4; \
-} while (0)
+#define SATURATE(val) \
+ do { \
+ val <<= 4; \
+ if (unlikely (val != (int16_t) val)) \
+ val = (SBITS (val, 1) ^ 2047) << 4; \
+ } while (0)
static void get_intra_block_B14 (mpeg2_decoder_t * const decoder,
const uint16_t * const quant_matrix)
@@ -361,9 +402,10 @@ static void get_intra_block_B14 (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
- while (1) {
- if (bit_buf >= 0x28000000) {
-
+ while (1)
+ {
+ if (bit_buf >= 0x28000000)
+ {
tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
i += tab->run;
@@ -387,9 +429,9 @@ static void get_intra_block_B14 (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
- } else if (bit_buf >= 0x04000000) {
-
+ }
+ else if (bit_buf >= 0x04000000)
+ {
tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
i += tab->run;
@@ -416,23 +458,30 @@ static void get_intra_block_B14 (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
- } else if (bit_buf >= 0x02000000) {
+ }
+ else if (bit_buf >= 0x02000000)
+ {
tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00800000) {
+ }
+ else if (bit_buf >= 0x00800000)
+ {
tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00200000) {
+ }
+ else if (bit_buf >= 0x00200000)
+ {
tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else {
+ }
+ else
+ {
tab = DCT_16 + UBITS (bit_buf, 16);
bit_buf <<= 16;
GETWORD (bit_buf, bits + 16, bit_ptr);
@@ -442,6 +491,7 @@ static void get_intra_block_B14 (mpeg2_decoder_t * const decoder,
}
break; /* illegal, check needed to avoid buffer overflow */
}
+
dest[63] ^= mismatch & 16;
DUMPBITS (bit_buf, bits, 2); /* dump end of block code */
decoder->bitstream_buf = bit_buf;
@@ -472,14 +522,16 @@ static void get_intra_block_B15 (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
- while (1) {
- if (bit_buf >= 0x04000000) {
-
+ while (1)
+ {
+ if (bit_buf >= 0x04000000)
+ {
tab = DCT_B15_8 + (UBITS (bit_buf, 8) - 4);
i += tab->run;
- if (i < 64) {
+ if (i < 64)
+ {
normal_code:
j = scan[i];
bit_buf <<= tab->len;
@@ -497,9 +549,9 @@ static void get_intra_block_B15 (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
- } else {
-
+ }
+ else
+ {
/* end of block. I commented out this code because if we */
/* dont exit here we will still exit at the later test :) */
@@ -525,24 +577,31 @@ static void get_intra_block_B15 (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
}
- } else if (bit_buf >= 0x02000000) {
+ }
+ else if (bit_buf >= 0x02000000)
+ {
tab = DCT_B15_10 + (UBITS (bit_buf, 10) - 8);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00800000) {
+ }
+ else if (bit_buf >= 0x00800000)
+ {
tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00200000) {
+ }
+ else if (bit_buf >= 0x00200000)
+ {
tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else {
+ }
+ else
+ {
tab = DCT_16 + UBITS (bit_buf, 16);
bit_buf <<= 16;
GETWORD (bit_buf, bits + 16, bit_ptr);
@@ -552,6 +611,7 @@ static void get_intra_block_B15 (mpeg2_decoder_t * const decoder,
}
break; /* illegal, check needed to avoid buffer overflow */
}
+
dest[63] ^= mismatch & 16;
DUMPBITS (bit_buf, bits, 4); /* dump end of block code */
decoder->bitstream_buf = bit_buf;
@@ -581,15 +641,21 @@ static int get_non_intra_block (mpeg2_decoder_t * const decoder,
bit_ptr = decoder->bitstream_ptr;
NEEDBITS (bit_buf, bits, bit_ptr);
- if (bit_buf >= 0x28000000) {
+
+ if (bit_buf >= 0x28000000)
+ {
tab = DCT_B14DC_5 + (UBITS (bit_buf, 5) - 5);
goto entry_1;
- } else
+ }
+ else
+ {
goto entry_2;
+ }
- while (1) {
- if (bit_buf >= 0x28000000) {
-
+ while (1)
+ {
+ if (bit_buf >= 0x28000000)
+ {
tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
entry_1:
@@ -614,12 +680,11 @@ static int get_non_intra_block (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
}
entry_2:
- if (bit_buf >= 0x04000000) {
-
+ if (bit_buf >= 0x04000000)
+ {
tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
i += tab->run;
@@ -647,23 +712,30 @@ static int get_non_intra_block (mpeg2_decoder_t * const decoder,
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
- } else if (bit_buf >= 0x02000000) {
+ }
+ else if (bit_buf >= 0x02000000)
+ {
tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00800000) {
+ }
+ else if (bit_buf >= 0x00800000)
+ {
tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00200000) {
+ }
+ else if (bit_buf >= 0x00200000)
+ {
tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else {
+ }
+ else
+ {
tab = DCT_16 + UBITS (bit_buf, 16);
bit_buf <<= 16;
GETWORD (bit_buf, bits + 16, bit_ptr);
@@ -673,6 +745,7 @@ static int get_non_intra_block (mpeg2_decoder_t * const decoder,
}
break; /* illegal, check needed to avoid buffer overflow */
}
+
dest[63] ^= mismatch & 16;
DUMPBITS (bit_buf, bits, 2); /* dump end of block code */
decoder->bitstream_buf = bit_buf;
@@ -702,9 +775,10 @@ static void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder)
NEEDBITS (bit_buf, bits, bit_ptr);
- while (1) {
- if (bit_buf >= 0x28000000) {
-
+ while (1)
+ {
+ if (bit_buf >= 0x28000000)
+ {
tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
i += tab->run;
@@ -730,9 +804,9 @@ static void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder)
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
- } else if (bit_buf >= 0x04000000) {
-
+ }
+ else if (bit_buf >= 0x04000000)
+ {
tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
i += tab->run;
@@ -750,10 +824,13 @@ static void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder)
DUMPBITS (bit_buf, bits, 12);
NEEDBITS (bit_buf, bits, bit_ptr);
val = SBITS (bit_buf, 8);
- if (! (val & 0x7f)) {
+
+ if (! (val & 0x7f))
+ {
DUMPBITS (bit_buf, bits, 8);
val = UBITS (bit_buf, 8) + 2 * val;
}
+
val = (val * quant_matrix[j]) / 16;
/* oddification */
@@ -766,23 +843,30 @@ static void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder)
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
- } else if (bit_buf >= 0x02000000) {
+ }
+ else if (bit_buf >= 0x02000000)
+ {
tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00800000) {
+ }
+ else if (bit_buf >= 0x00800000)
+ {
tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00200000) {
+ }
+ else if (bit_buf >= 0x00200000)
+ {
tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else {
+ }
+ else
+ {
tab = DCT_16 + UBITS (bit_buf, 16);
bit_buf <<= 16;
GETWORD (bit_buf, bits + 16, bit_ptr);
@@ -792,6 +876,7 @@ static void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder)
}
break; /* illegal, check needed to avoid buffer overflow */
}
+
DUMPBITS (bit_buf, bits, 2); /* dump end of block code */
decoder->bitstream_buf = bit_buf;
decoder->bitstream_bits = bits;
@@ -818,15 +903,20 @@ static int get_mpeg1_non_intra_block (mpeg2_decoder_t * const decoder)
bit_ptr = decoder->bitstream_ptr;
NEEDBITS (bit_buf, bits, bit_ptr);
- if (bit_buf >= 0x28000000) {
+ if (bit_buf >= 0x28000000)
+ {
tab = DCT_B14DC_5 + (UBITS (bit_buf, 5) - 5);
goto entry_1;
- } else
+ }
+ else
+ {
goto entry_2;
+ }
- while (1) {
- if (bit_buf >= 0x28000000) {
-
+ while (1)
+ {
+ if (bit_buf >= 0x28000000)
+ {
tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5);
entry_1:
@@ -853,12 +943,11 @@ static int get_mpeg1_non_intra_block (mpeg2_decoder_t * const decoder)
NEEDBITS (bit_buf, bits, bit_ptr);
continue;
-
}
entry_2:
- if (bit_buf >= 0x04000000) {
-
+ if (bit_buf >= 0x04000000)
+ {
tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4);
i += tab->run;
@@ -876,10 +965,13 @@ static int get_mpeg1_non_intra_block (mpeg2_decoder_t * const decoder)
DUMPBITS (bit_buf, bits, 12);
NEEDBITS (bit_buf, bits, bit_ptr);
val = SBITS (bit_buf, 8);
- if (! (val & 0x7f)) {
+
+ if (! (val & 0x7f))
+ {
DUMPBITS (bit_buf, bits, 8);
val = UBITS (bit_buf, 8) + 2 * val;
}
+
val = 2 * (val + SBITS (val, 1)) + 1;
val = (val * quant_matrix[j]) / 32;
@@ -894,22 +986,30 @@ static int get_mpeg1_non_intra_block (mpeg2_decoder_t * const decoder)
continue;
- } else if (bit_buf >= 0x02000000) {
+ }
+ else if (bit_buf >= 0x02000000)
+ {
tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00800000) {
+ }
+ else if (bit_buf >= 0x00800000)
+ {
tab = DCT_13 + (UBITS (bit_buf, 13) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else if (bit_buf >= 0x00200000) {
+ }
+ else if (bit_buf >= 0x00200000)
+ {
tab = DCT_15 + (UBITS (bit_buf, 15) - 16);
i += tab->run;
if (i < 64)
goto normal_code;
- } else {
+ }
+ else
+ {
tab = DCT_16 + UBITS (bit_buf, 16);
bit_buf <<= 16;
GETWORD (bit_buf, bits + 16, bit_ptr);
@@ -919,6 +1019,7 @@ static int get_mpeg1_non_intra_block (mpeg2_decoder_t * const decoder)
}
break; /* illegal, check needed to avoid buffer overflow */
}
+
DUMPBITS (bit_buf, bits, 2); /* dump end of block code */
decoder->bitstream_buf = bit_buf;
decoder->bitstream_bits = bits;
@@ -933,23 +1034,37 @@ static inline void slice_intra_DCT (mpeg2_decoder_t * const decoder,
#define bit_buf (decoder->bitstream_buf)
#define bits (decoder->bitstream_bits)
#define bit_ptr (decoder->bitstream_ptr)
+
NEEDBITS (bit_buf, bits, bit_ptr);
/* Get the intra DC coefficient and inverse quantize it */
if (cc == 0)
- decoder->DCTblock[0] =
- decoder->dc_dct_pred[0] += get_luma_dc_dct_diff (decoder);
+ {
+ decoder->dc_dct_pred[0] += get_luma_dc_dct_diff (decoder);
+ decoder->DCTblock[0] = decoder->dc_dct_pred[0];
+
+ }
else
- decoder->DCTblock[0] =
- decoder->dc_dct_pred[cc] += get_chroma_dc_dct_diff (decoder);
+ {
+ decoder->dc_dct_pred[cc] += get_chroma_dc_dct_diff (decoder);
+ decoder->DCTblock[0] = decoder->dc_dct_pred[cc];
+ }
- if (decoder->mpeg1) {
+ if (decoder->mpeg1)
+ {
if (decoder->coding_type != D_TYPE)
get_mpeg1_intra_block (decoder);
- } else if (decoder->intra_vlc_format)
+ }
+ else if (decoder->intra_vlc_format)
+ {
get_intra_block_B15 (decoder, decoder->quantizer_matrix[cc ? 2 : 0]);
+ }
else
+ {
get_intra_block_B14 (decoder, decoder->quantizer_matrix[cc ? 2 : 0]);
+ }
+
mpeg2_idct_copy (decoder->DCTblock, dest, stride);
+
#undef bit_buf
#undef bits
#undef bit_ptr
@@ -962,289 +1077,366 @@ static inline void slice_non_intra_DCT (mpeg2_decoder_t * const decoder,
int last;
if (decoder->mpeg1)
+ {
last = get_mpeg1_non_intra_block (decoder);
+ }
else
+ {
last = get_non_intra_block (decoder,
decoder->quantizer_matrix[cc ? 3 : 1]);
+ }
+
mpeg2_idct_add (last, decoder->DCTblock, dest, stride);
}
-#define MOTION_420(table,ref,motion_x,motion_y,size,y) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_420(table, ref, motion_x, motion_y, size, y) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y_ ## size)) { \
- pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
- motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y_ ## size)) \
+ { \
+ pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
+ motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
ref[0] + (pos_x >> 1) + (pos_y >> 1) * decoder->stride, \
- decoder->stride, size); \
- motion_x /= 2; motion_y /= 2; \
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
- offset = (((decoder->offset + motion_x) >> 1) + \
- ((((decoder->v_offset + motion_y) >> 1) + y/2) * \
- decoder->uv_stride)); \
- table[4+xy_half] (decoder->dest[1] + y/2 * decoder->uv_stride + \
- (decoder->offset >> 1), ref[1] + offset, \
- decoder->uv_stride, size/2); \
- table[4+xy_half] (decoder->dest[2] + y/2 * decoder->uv_stride + \
- (decoder->offset >> 1), ref[2] + offset, \
+ decoder->stride, size); \
+ \
+ motion_x /= 2; \
+ motion_y /= 2; \
+ xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
+ offset = ((decoder->offset + motion_x) >> 1) + \
+ ((((decoder->v_offset + motion_y) >> 1) + y/2) * \
+ decoder->uv_stride); \
+ \
+ table[4+xy_half] (decoder->dest[1] + y/2 * decoder->uv_stride + \
+ (decoder->offset >> 1), ref[1] + offset, \
+ decoder->uv_stride, size/2); \
+ table[4+xy_half] (decoder->dest[2] + y/2 * decoder->uv_stride + \
+ (decoder->offset >> 1), ref[2] + offset, \
decoder->uv_stride, size/2)
-#define MOTION_FIELD_420(table,ref,motion_x,motion_y,dest_field,op,src_field) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = decoder->v_offset + motion_y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_FIELD_420(table, ref, motion_x, motion_y, \
+ dest_field, op, src_field) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = decoder->v_offset + motion_y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y)) { \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y)) \
+ { \
pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
- motion_y = pos_y - decoder->v_offset; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
- decoder->offset, \
- (ref[0] + (pos_x >> 1) + \
- ((pos_y op) + src_field) * decoder->stride), \
- 2 * decoder->stride, 8); \
- motion_x /= 2; motion_y /= 2; \
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
- offset = (((decoder->offset + motion_x) >> 1) + \
- (((decoder->v_offset >> 1) + (motion_y op) + src_field) * \
- decoder->uv_stride)); \
+ motion_y = pos_y - decoder->v_offset; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
+ decoder->offset, \
+ (ref[0] + (pos_x >> 1) + \
+ ((pos_y op) + src_field) * decoder->stride), \
+ 2 * decoder->stride, 8); \
+ \
+ motion_x /= 2; \
+ motion_y /= 2; \
+ xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
+ offset = ((decoder->offset + motion_x) >> 1) + \
+ (((decoder->v_offset >> 1) + (motion_y op) + src_field) * \
+ decoder->uv_stride); \
+ \
table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride + \
- (decoder->offset >> 1), ref[1] + offset, \
- 2 * decoder->uv_stride, 4); \
+ (decoder->offset >> 1), ref[1] + offset, \
+ 2 * decoder->uv_stride, 4); \
table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride + \
- (decoder->offset >> 1), ref[2] + offset, \
+ (decoder->offset >> 1), ref[2] + offset, \
2 * decoder->uv_stride, 4)
-#define MOTION_DMV_420(table,ref,motion_x,motion_y) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = decoder->v_offset + motion_y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_DMV_420(table, ref, motion_x, motion_y) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = decoder->v_offset + motion_y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y)) { \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y)) \
+ { \
pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
- motion_y = pos_y - decoder->v_offset; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
- table[xy_half] (decoder->dest[0] + decoder->offset, \
- ref[0] + offset, 2 * decoder->stride, 8); \
+ motion_y = pos_y - decoder->v_offset; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
+ table[xy_half] (decoder->dest[0] + decoder->offset, \
+ ref[0] + offset, 2 * decoder->stride, 8); \
table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset, \
- ref[0] + decoder->stride + offset, \
- 2 * decoder->stride, 8); \
- motion_x /= 2; motion_y /= 2; \
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
- offset = (((decoder->offset + motion_x) >> 1) + \
- (((decoder->v_offset >> 1) + (motion_y & ~1)) * \
- decoder->uv_stride)); \
+ ref[0] + decoder->stride + offset, \
+ 2 * decoder->stride, 8); \
+ \
+ motion_x /= 2; \
+ motion_y /= 2; \
+ xy_half = ((motion_y & 1) << 1) | (motion_x & 1); \
+ offset = ((decoder->offset + motion_x) >> 1) + \
+ (((decoder->v_offset >> 1) + (motion_y & ~1)) * \
+ decoder->uv_stride); \
+ \
table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1), \
- ref[1] + offset, 2 * decoder->uv_stride, 4); \
- table[4+xy_half] (decoder->dest[1] + decoder->uv_stride + \
- (decoder->offset >> 1), \
- ref[1] + decoder->uv_stride + offset, \
- 2 * decoder->uv_stride, 4); \
+ ref[1] + offset, 2 * decoder->uv_stride, 4); \
+ table[4+xy_half] (decoder->dest[1] + decoder->uv_stride + \
+ (decoder->offset >> 1), \
+ ref[1] + decoder->uv_stride + offset, \
+ 2 * decoder->uv_stride, 4); \
table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1), \
- ref[2] + offset, 2 * decoder->uv_stride, 4); \
- table[4+xy_half] (decoder->dest[2] + decoder->uv_stride + \
- (decoder->offset >> 1), \
- ref[2] + decoder->uv_stride + offset, \
+ ref[2] + offset, 2 * decoder->uv_stride, 4); \
+ table[4+xy_half] (decoder->dest[2] + decoder->uv_stride + \
+ (decoder->offset >> 1), \
+ ref[2] + decoder->uv_stride + offset, \
2 * decoder->uv_stride, 4)
-#define MOTION_ZERO_420(table,ref) \
- table[0] (decoder->dest[0] + decoder->offset, \
- (ref[0] + decoder->offset + \
+#define MOTION_ZERO_420(table, ref) \
+ table[0] (decoder->dest[0] + decoder->offset, \
+ (ref[0] + decoder->offset + \
decoder->v_offset * decoder->stride), decoder->stride, 16); \
- offset = ((decoder->offset >> 1) + \
- (decoder->v_offset >> 1) * decoder->uv_stride); \
+ \
+ offset = ((decoder->offset >> 1) + \
+ (decoder->v_offset >> 1) * decoder->uv_stride); \
+ \
table[4] (decoder->dest[1] + (decoder->offset >> 1), \
- ref[1] + offset, decoder->uv_stride, 8); \
+ ref[1] + offset, decoder->uv_stride, 8); \
table[4] (decoder->dest[2] + (decoder->offset >> 1), \
ref[2] + offset, decoder->uv_stride, 8)
-#define MOTION_422(table,ref,motion_x,motion_y,size,y) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_422(table, ref, motion_x, motion_y, size, y) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y_ ## size)) { \
- pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
- motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride; \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y_ ## size)) \
+ { \
+ pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
+ motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride; \
+ \
table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
- ref[0] + offset, decoder->stride, size); \
- offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
- motion_x /= 2; \
- xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
- table[4+xy_half] (decoder->dest[1] + y * decoder->uv_stride + \
- (decoder->offset >> 1), ref[1] + offset, \
+ ref[0] + offset, decoder->stride, size); \
+ \
+ offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
+ motion_x /= 2; \
+ xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
+ \
+ table[4+xy_half] (decoder->dest[1] + y * decoder->uv_stride + \
+ (decoder->offset >> 1), ref[1] + offset, \
decoder->uv_stride, size); \
- table[4+xy_half] (decoder->dest[2] + y * decoder->uv_stride + \
- (decoder->offset >> 1), ref[2] + offset, \
+ table[4+xy_half] (decoder->dest[2] + y * decoder->uv_stride + \
+ (decoder->offset >> 1), ref[2] + offset, \
decoder->uv_stride, size)
-#define MOTION_FIELD_422(table,ref,motion_x,motion_y,dest_field,op,src_field) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = decoder->v_offset + motion_y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_FIELD_422(table, ref, motion_x, motion_y, \
+ dest_field, op, src_field) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = decoder->v_offset + motion_y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y)) { \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y)) \
+ { \
pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
- motion_y = pos_y - decoder->v_offset; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride; \
- table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
- decoder->offset, ref[0] + offset, \
- 2 * decoder->stride, 8); \
- offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
- motion_x /= 2; \
- xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
+ motion_y = pos_y - decoder->v_offset; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride; \
+ \
+ table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
+ decoder->offset, ref[0] + offset, \
+ 2 * decoder->stride, 8); \
+ \
+ offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
+ motion_x /= 2; \
+ xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
+ \
table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride + \
- (decoder->offset >> 1), ref[1] + offset, \
- 2 * decoder->uv_stride, 8); \
+ (decoder->offset >> 1), ref[1] + offset, \
+ 2 * decoder->uv_stride, 8); \
table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride + \
- (decoder->offset >> 1), ref[2] + offset, \
+ (decoder->offset >> 1), ref[2] + offset, \
2 * decoder->uv_stride, 8)
-#define MOTION_DMV_422(table,ref,motion_x,motion_y) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = decoder->v_offset + motion_y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_DMV_422(table, ref, motion_x, motion_y) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = decoder->v_offset + motion_y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y)) { \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y)) \
+ { \
pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
- motion_y = pos_y - decoder->v_offset; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
- table[xy_half] (decoder->dest[0] + decoder->offset, \
- ref[0] + offset, 2 * decoder->stride, 8); \
+ motion_y = pos_y - decoder->v_offset; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
+ \
+ table[xy_half] (decoder->dest[0] + decoder->offset, \
+ ref[0] + offset, 2 * decoder->stride, 8); \
table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset, \
- ref[0] + decoder->stride + offset, \
- 2 * decoder->stride, 8); \
- offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
- motion_x /= 2; \
- xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
+ ref[0] + decoder->stride + offset, \
+ 2 * decoder->stride, 8); \
+ \
+ offset = (offset + (motion_x & (motion_x < 0))) >> 1; \
+ motion_x /= 2; \
+ xy_half = ((pos_y & 1) << 1) | (motion_x & 1); \
+ \
table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1), \
- ref[1] + offset, 2 * decoder->uv_stride, 8); \
- table[4+xy_half] (decoder->dest[1] + decoder->uv_stride + \
- (decoder->offset >> 1), \
- ref[1] + decoder->uv_stride + offset, \
- 2 * decoder->uv_stride, 8); \
+ ref[1] + offset, 2 * decoder->uv_stride, 8); \
+ table[4+xy_half] (decoder->dest[1] + decoder->uv_stride + \
+ (decoder->offset >> 1), \
+ ref[1] + decoder->uv_stride + offset, \
+ 2 * decoder->uv_stride, 8); \
table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1), \
- ref[2] + offset, 2 * decoder->uv_stride, 8); \
- table[4+xy_half] (decoder->dest[2] + decoder->uv_stride + \
- (decoder->offset >> 1), \
- ref[2] + decoder->uv_stride + offset, \
+ ref[2] + offset, 2 * decoder->uv_stride, 8); \
+ table[4+xy_half] (decoder->dest[2] + decoder->uv_stride + \
+ (decoder->offset >> 1), \
+ ref[2] + decoder->uv_stride + offset, \
2 * decoder->uv_stride, 8)
-#define MOTION_ZERO_422(table,ref) \
- offset = decoder->offset + decoder->v_offset * decoder->stride; \
- table[0] (decoder->dest[0] + decoder->offset, \
- ref[0] + offset, decoder->stride, 16); \
- offset >>= 1; \
+#define MOTION_ZERO_422(table, ref) \
+ offset = decoder->offset + decoder->v_offset * decoder->stride; \
+ table[0] (decoder->dest[0] + decoder->offset, \
+ ref[0] + offset, decoder->stride, 16); \
+ offset >>= 1; \
table[4] (decoder->dest[1] + (decoder->offset >> 1), \
- ref[1] + offset, decoder->uv_stride, 16); \
+ ref[1] + offset, decoder->uv_stride, 16); \
table[4] (decoder->dest[2] + (decoder->offset >> 1), \
ref[2] + offset, decoder->uv_stride, 16)
-#define MOTION_444(table,ref,motion_x,motion_y,size,y) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_444(table, ref, motion_x, motion_y, size, y) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = 2 * decoder->v_offset + motion_y + 2 * y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y_ ## size)) { \
- pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
- motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride; \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y_ ## size)) \
+ { \
+ pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size; \
+ motion_y = pos_y - 2 * decoder->v_offset - 2 * y; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride; \
+ \
table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
- ref[0] + offset, decoder->stride, size); \
+ ref[0] + offset, decoder->stride, size); \
table[xy_half] (decoder->dest[1] + y * decoder->stride + decoder->offset, \
- ref[1] + offset, decoder->stride, size); \
+ ref[1] + offset, decoder->stride, size); \
table[xy_half] (decoder->dest[2] + y * decoder->stride + decoder->offset, \
ref[2] + offset, decoder->stride, size)
-#define MOTION_FIELD_444(table,ref,motion_x,motion_y,dest_field,op,src_field) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = decoder->v_offset + motion_y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_FIELD_444(table, ref, motion_x, motion_y, \
+ dest_field, op, src_field) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = decoder->v_offset + motion_y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y)) { \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y)) \
+ { \
pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
- motion_y = pos_y - decoder->v_offset; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride; \
- table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
- decoder->offset, ref[0] + offset, \
- 2 * decoder->stride, 8); \
- table[xy_half] (decoder->dest[1] + dest_field * decoder->stride + \
- decoder->offset, ref[1] + offset, \
- 2 * decoder->stride, 8); \
- table[xy_half] (decoder->dest[2] + dest_field * decoder->stride + \
- decoder->offset, ref[2] + offset, \
+ motion_y = pos_y - decoder->v_offset; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride; \
+ \
+ table[xy_half] (decoder->dest[0] + dest_field * decoder->stride + \
+ decoder->offset, ref[0] + offset, \
+ 2 * decoder->stride, 8); \
+ table[xy_half] (decoder->dest[1] + dest_field * decoder->stride + \
+ decoder->offset, ref[1] + offset, \
+ 2 * decoder->stride, 8); \
+ table[xy_half] (decoder->dest[2] + dest_field * decoder->stride + \
+ decoder->offset, ref[2] + offset, \
2 * decoder->stride, 8)
-#define MOTION_DMV_444(table,ref,motion_x,motion_y) \
- pos_x = 2 * decoder->offset + motion_x; \
- pos_y = decoder->v_offset + motion_y; \
- if (unlikely (pos_x > decoder->limit_x)) { \
+#define MOTION_DMV_444(table, ref, motion_x, motion_y) \
+ pos_x = 2 * decoder->offset + motion_x; \
+ pos_y = decoder->v_offset + motion_y; \
+ \
+ if (unlikely (pos_x > decoder->limit_x)) \
+ { \
pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x; \
- motion_x = pos_x - 2 * decoder->offset; \
- } \
- if (unlikely (pos_y > decoder->limit_y)) { \
+ motion_x = pos_x - 2 * decoder->offset; \
+ } \
+ \
+ if (unlikely (pos_y > decoder->limit_y)) \
+ { \
pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y; \
- motion_y = pos_y - decoder->v_offset; \
- } \
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
- offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
- table[xy_half] (decoder->dest[0] + decoder->offset, \
- ref[0] + offset, 2 * decoder->stride, 8); \
+ motion_y = pos_y - decoder->v_offset; \
+ } \
+ \
+ xy_half = ((pos_y & 1) << 1) | (pos_x & 1); \
+ offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride; \
+ \
+ table[xy_half] (decoder->dest[0] + decoder->offset, \
+ ref[0] + offset, 2 * decoder->stride, 8); \
table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset, \
- ref[0] + decoder->stride + offset, \
- 2 * decoder->stride, 8); \
- table[xy_half] (decoder->dest[1] + decoder->offset, \
- ref[1] + offset, 2 * decoder->stride, 8); \
+ ref[0] + decoder->stride + offset, \
+ 2 * decoder->stride, 8); \
+ table[xy_half] (decoder->dest[1] + decoder->offset, \
+ ref[1] + offset, 2 * decoder->stride, 8); \
table[xy_half] (decoder->dest[1] + decoder->stride + decoder->offset, \
- ref[1] + decoder->stride + offset, \
- 2 * decoder->stride, 8); \
- table[xy_half] (decoder->dest[2] + decoder->offset, \
- ref[2] + offset, 2 * decoder->stride, 8); \
+ ref[1] + decoder->stride + offset, \
+ 2 * decoder->stride, 8); \
+ table[xy_half] (decoder->dest[2] + decoder->offset, \
+ ref[2] + offset, 2 * decoder->stride, 8); \
table[xy_half] (decoder->dest[2] + decoder->stride + decoder->offset, \
- ref[2] + decoder->stride + offset, \
+ ref[2] + decoder->stride + offset, \
2 * decoder->stride, 8)
-#define MOTION_ZERO_444(table,ref) \
- offset = decoder->offset + decoder->v_offset * decoder->stride; \
- table[0] (decoder->dest[0] + decoder->offset, \
- ref[0] + offset, decoder->stride, 16); \
- table[4] (decoder->dest[1] + decoder->offset, \
- ref[1] + offset, decoder->stride, 16); \
+#define MOTION_ZERO_444(table, ref) \
+ offset = decoder->offset + decoder->v_offset * decoder->stride; \
+ \
+ table[0] (decoder->dest[0] + decoder->offset, \
+ ref[0] + offset, decoder->stride, 16); \
+ table[4] (decoder->dest[1] + decoder->offset, \
+ ref[1] + offset, decoder->stride, 16); \
table[4] (decoder->dest[2] + (decoder->offset >> 1), \
ref[2] + offset, decoder->stride, 16)
@@ -1260,17 +1452,17 @@ static void motion_mp1 (mpeg2_decoder_t * const decoder,
unsigned int pos_x, pos_y, xy_half, offset;
NEEDBITS (bit_buf, bits, bit_ptr);
- motion_x = (motion->pmv[0][0] +
+ motion_x = motion->pmv[0][0] +
(get_motion_delta (decoder,
- motion->f_code[0]) << motion->f_code[1]));
+ motion->f_code[0]) << motion->f_code[1]);
motion_x = bound_motion_vector (motion_x,
motion->f_code[0] + motion->f_code[1]);
motion->pmv[0][0] = motion_x;
NEEDBITS (bit_buf, bits, bit_ptr);
- motion_y = (motion->pmv[0][1] +
+ motion_y = motion->pmv[0][1] +
(get_motion_delta (decoder,
- motion->f_code[0]) << motion->f_code[1]));
+ motion->f_code[0]) << motion->f_code[1]);
motion_y = bound_motion_vector (motion_y,
motion->f_code[0] + motion->f_code[1]);
motion->pmv[0][1] = motion_y;
@@ -1278,227 +1470,228 @@ static void motion_mp1 (mpeg2_decoder_t * const decoder,
MOTION_420 (table, motion->ref[0], motion_x, motion_y, 16, 0);
}
-#define MOTION_FUNCTIONS(FORMAT,MOTION,MOTION_FIELD,MOTION_DMV,MOTION_ZERO) \
+#define MOTION_FUNCTIONS(FORMAT, MOTION, MOTION_FIELD, \
+ MOTION_DMV, MOTION_ZERO) \
\
-static void motion_fr_frame_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
+static void motion_fr_frame_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+{ \
+ int motion_x, motion_y; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
motion->f_code[1]); \
- motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
+ motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
+ motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
\
- MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0); \
-} \
+ MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0); \
+} \
\
-static void motion_fr_field_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
+static void motion_fr_field_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y, field; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+{ \
+ int motion_x, motion_y, field; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- field = UBITS (bit_buf, 1); \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ field = UBITS (bit_buf, 1); \
DUMPBITS (bit_buf, bits, 1); \
\
- motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
+ motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[0][0] = motion_x; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[0][0] = motion_x; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_y = ((motion->pmv[0][1] >> 1) + \
- get_motion_delta (decoder, motion->f_code[1])); \
- /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
- motion->pmv[0][1] = motion_y << 1; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_y = ((motion->pmv[0][1] >> 1) + \
+ get_motion_delta (decoder, motion->f_code[1])); \
+ /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
+ motion->pmv[0][1] = motion_y << 1; \
\
MOTION_FIELD (table, motion->ref[0], motion_x, motion_y, 0, & ~1, field); \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- field = UBITS (bit_buf, 1); \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ field = UBITS (bit_buf, 1); \
DUMPBITS (bit_buf, bits, 1); \
\
- motion_x = motion->pmv[1][0] + get_motion_delta (decoder, \
+ motion_x = motion->pmv[1][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[1][0] = motion_x; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[1][0] = motion_x; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_y = ((motion->pmv[1][1] >> 1) + \
- get_motion_delta (decoder, motion->f_code[1])); \
- /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
- motion->pmv[1][1] = motion_y << 1; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_y = ((motion->pmv[1][1] >> 1) + \
+ get_motion_delta (decoder, motion->f_code[1])); \
+ /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
+ motion->pmv[1][1] = motion_y << 1; \
\
MOTION_FIELD (table, motion->ref[0], motion_x, motion_y, 1, & ~1, field); \
-} \
+} \
\
-static void motion_fr_dmv_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
- mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y, dmv_x, dmv_y, m, other_x, other_y; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+static void motion_fr_dmv_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
+ mpeg2_mc_fct * const * const table) \
+{ \
+ int motion_x, motion_y, dmv_x, dmv_y, m, other_x, other_y; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
(void)table; \
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
- NEEDBITS (bit_buf, bits, bit_ptr); \
- dmv_x = get_dmv (decoder); \
- \
- motion_y = ((motion->pmv[0][1] >> 1) + \
- get_motion_delta (decoder, motion->f_code[1])); \
- /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y << 1; \
- dmv_y = get_dmv (decoder); \
- \
- m = decoder->top_field_first ? 1 : 3; \
- other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x; \
- other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y - 1; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ dmv_x = get_dmv (decoder); \
+ \
+ motion_y = ((motion->pmv[0][1] >> 1) + \
+ get_motion_delta (decoder, motion->f_code[1])); \
+ /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */ \
+ motion->pmv[1][1] = motion->pmv[0][1] = motion_y << 1; \
+ dmv_y = get_dmv (decoder); \
+ \
+ m = decoder->top_field_first ? 1 : 3; \
+ other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x; \
+ other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y - 1; \
MOTION_FIELD (mpeg2_mc.put, motion->ref[0], other_x, other_y, 0, | 1, 0); \
\
- m = decoder->top_field_first ? 3 : 1; \
- other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x; \
- other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y + 1; \
+ m = decoder->top_field_first ? 3 : 1; \
+ other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x; \
+ other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y + 1; \
MOTION_FIELD (mpeg2_mc.put, motion->ref[0], other_x, other_y, 1, & ~1, 0);\
\
- MOTION_DMV (mpeg2_mc.avg, motion->ref[0], motion_x, motion_y); \
-} \
+ MOTION_DMV (mpeg2_mc.avg, motion->ref[0], motion_x, motion_y); \
+} \
\
-static void motion_reuse_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
- mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+static void motion_reuse_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
+ mpeg2_mc_fct * const * const table) \
+{ \
+ int motion_x, motion_y; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
- motion_x = motion->pmv[0][0]; \
- motion_y = motion->pmv[0][1]; \
+ motion_x = motion->pmv[0][0]; \
+ motion_y = motion->pmv[0][1]; \
\
- MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0); \
-} \
+ MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0); \
+} \
\
-static void motion_zero_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
- mpeg2_mc_fct * const * const table) \
-{ \
+static void motion_zero_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
+ mpeg2_mc_fct * const * const table) \
+{ \
unsigned int offset; \
\
- motion->pmv[0][0] = motion->pmv[0][1] = 0; \
- motion->pmv[1][0] = motion->pmv[1][1] = 0; \
+ motion->pmv[0][0] = motion->pmv[0][1] = 0; \
+ motion->pmv[1][0] = motion->pmv[1][1] = 0; \
\
MOTION_ZERO (table, motion->ref[0]); \
-} \
+} \
\
-static void motion_fi_field_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
+static void motion_fi_field_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y; \
- uint8_t ** ref_field; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+{ \
+ int motion_x, motion_y; \
+ uint8_t ** ref_field; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
DUMPBITS (bit_buf, bits, 1); \
\
- motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
+ motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
motion->f_code[1]); \
- motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
+ motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
+ motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
\
- MOTION (table, ref_field, motion_x, motion_y, 16, 0); \
-} \
+ MOTION (table, ref_field, motion_x, motion_y, 16, 0); \
+} \
\
-static void motion_fi_16x8_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
+static void motion_fi_16x8_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y; \
- uint8_t ** ref_field; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+{ \
+ int motion_x, motion_y; \
+ uint8_t ** ref_field; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
DUMPBITS (bit_buf, bits, 1); \
\
- motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
+ motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[0][0] = motion_x; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[0][0] = motion_x; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
motion->f_code[1]); \
- motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
- motion->pmv[0][1] = motion_y; \
+ motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
+ motion->pmv[0][1] = motion_y; \
\
MOTION (table, ref_field, motion_x, motion_y, 8, 0); \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ ref_field = motion->ref2[UBITS (bit_buf, 1)]; \
DUMPBITS (bit_buf, bits, 1); \
\
- motion_x = motion->pmv[1][0] + get_motion_delta (decoder, \
+ motion_x = motion->pmv[1][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[1][0] = motion_x; \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[1][0] = motion_x; \
\
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_y = motion->pmv[1][1] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_y = motion->pmv[1][1] + get_motion_delta (decoder, \
motion->f_code[1]); \
- motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
- motion->pmv[1][1] = motion_y; \
+ motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
+ motion->pmv[1][1] = motion_y; \
\
MOTION (table, ref_field, motion_x, motion_y, 8, 8); \
-} \
+} \
\
-static void motion_fi_dmv_##FORMAT (mpeg2_decoder_t * const decoder, \
- motion_t * const motion, \
- mpeg2_mc_fct * const * const table) \
-{ \
- int motion_x, motion_y, other_x, other_y; \
- unsigned int pos_x, pos_y, xy_half, offset; \
+static void motion_fi_dmv_##FORMAT (mpeg2_decoder_t * const decoder, \
+ motion_t * const motion, \
+ mpeg2_mc_fct * const * const table) \
+{ \
+ int motion_x, motion_y, other_x, other_y; \
+ unsigned int pos_x, pos_y, xy_half, offset; \
\
(void)table; \
- NEEDBITS (bit_buf, bits, bit_ptr); \
- motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ motion_x = motion->pmv[0][0] + get_motion_delta (decoder, \
motion->f_code[0]); \
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
- NEEDBITS (bit_buf, bits, bit_ptr); \
- other_x = ((motion_x + (motion_x > 0)) >> 1) + get_dmv (decoder); \
+ motion_x = bound_motion_vector (motion_x, motion->f_code[0]); \
+ motion->pmv[1][0] = motion->pmv[0][0] = motion_x; \
+ NEEDBITS (bit_buf, bits, bit_ptr); \
+ other_x = ((motion_x + (motion_x > 0)) >> 1) + get_dmv (decoder); \
\
- motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
+ motion_y = motion->pmv[0][1] + get_motion_delta (decoder, \
motion->f_code[1]); \
- motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
- other_y = (((motion_y + (motion_y > 0)) >> 1) + get_dmv (decoder) + \
- decoder->dmv_offset); \
+ motion_y = bound_motion_vector (motion_y, motion->f_code[1]); \
+ motion->pmv[1][1] = motion->pmv[0][1] = motion_y; \
+ other_y = (((motion_y + (motion_y > 0)) >> 1) + get_dmv (decoder) + \
+ decoder->dmv_offset); \
\
- MOTION (mpeg2_mc.put, motion->ref[0], motion_x, motion_y, 16, 0); \
- MOTION (mpeg2_mc.avg, motion->ref[1], other_x, other_y, 16, 0); \
-} \
+ MOTION (mpeg2_mc.put, motion->ref[0], motion_x, motion_y, 16, 0); \
+ MOTION (mpeg2_mc.avg, motion->ref[1], other_x, other_y, 16, 0); \
+} \
MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420,
MOTION_ZERO_420)
@@ -1534,16 +1727,21 @@ static void motion_fi_conceal (mpeg2_decoder_t * const decoder)
NEEDBITS (bit_buf, bits, bit_ptr);
DUMPBITS (bit_buf, bits, 1); /* remove field_select */
- tmp = (decoder->f_motion.pmv[0][0] +
- get_motion_delta (decoder, decoder->f_motion.f_code[0]));
+ tmp = decoder->f_motion.pmv[0][0] +
+ get_motion_delta (decoder, decoder->f_motion.f_code[0]);
tmp = bound_motion_vector (tmp, decoder->f_motion.f_code[0]);
- decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[0][0] = tmp;
+
+ decoder->f_motion.pmv[1][0] =
+ decoder->f_motion.pmv[0][0] = tmp;
NEEDBITS (bit_buf, bits, bit_ptr);
+
tmp = (decoder->f_motion.pmv[0][1] +
- get_motion_delta (decoder, decoder->f_motion.f_code[1]));
+ get_motion_delta (decoder, decoder->f_motion.f_code[1]));
tmp = bound_motion_vector (tmp, decoder->f_motion.f_code[1]);
- decoder->f_motion.pmv[1][1] = decoder->f_motion.pmv[0][1] = tmp;
+
+ decoder->f_motion.pmv[1][1] =
+ decoder->f_motion.pmv[0][1] = tmp;
DUMPBITS (bit_buf, bits, 1); /* remove marker_bit */
}
@@ -1552,34 +1750,44 @@ static void motion_fi_conceal (mpeg2_decoder_t * const decoder)
#undef bits
#undef bit_ptr
-#define MOTION_CALL(routine,direction) \
-do { \
- if ((direction) & MACROBLOCK_MOTION_FORWARD) \
- routine (decoder, &(decoder->f_motion), mpeg2_mc.put); \
- if ((direction) & MACROBLOCK_MOTION_BACKWARD) \
- routine (decoder, &(decoder->b_motion), \
- ((direction) & MACROBLOCK_MOTION_FORWARD ? \
- mpeg2_mc.avg : mpeg2_mc.put)); \
+#define MOTION_CALL(routine, direction) \
+do { \
+ if ((direction) & MACROBLOCK_MOTION_FORWARD) \
+ routine (decoder, &decoder->f_motion, mpeg2_mc.put); \
+ \
+ if ((direction) & MACROBLOCK_MOTION_BACKWARD) \
+ { \
+ routine (decoder, &decoder->b_motion, \
+ ((direction) & MACROBLOCK_MOTION_FORWARD ? \
+ mpeg2_mc.avg : mpeg2_mc.put)); \
+ } \
} while (0)
-#define NEXT_MACROBLOCK \
+#define NEXT_MACROBLOCK \
do { \
decoder->offset += 16; \
- if (decoder->offset == decoder->width) { \
+ \
+ if (decoder->offset == decoder->width) \
+ { \
do { /* just so we can use the break statement */ \
- if (decoder->convert) { \
+ if (decoder->convert) \
+ { \
decoder->convert (decoder->convert_id, decoder->dest, \
decoder->v_offset); \
if (decoder->coding_type == B_TYPE) \
break; \
} \
+ \
decoder->dest[0] += decoder->slice_stride; \
decoder->dest[1] += decoder->slice_uv_stride; \
decoder->dest[2] += decoder->slice_uv_stride; \
} while (0); \
+ \
decoder->v_offset += 16; \
+ \
if (decoder->v_offset > decoder->limit_y) \
return; \
+ \
decoder->offset = 0; \
} \
} while (0)
@@ -1606,7 +1814,8 @@ void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
decoder->b_motion.ref[0][1] = backward_fbuf[1] + (offset >> 1);
decoder->b_motion.ref[0][2] = backward_fbuf[2] + (offset >> 1);
- if (decoder->picture_structure != FRAME_PICTURE) {
+ if (decoder->picture_structure != FRAME_PICTURE)
+ {
decoder->dmv_offset = bottom_field ? 1 : -1;
decoder->f_motion.ref2[0] = decoder->f_motion.ref[bottom_field];
decoder->f_motion.ref2[1] = decoder->f_motion.ref[!bottom_field];
@@ -1639,44 +1848,59 @@ void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
decoder->limit_y_8 = 2 * height - 16;
decoder->limit_y = height - 16;
- if (decoder->mpeg1) {
+ if (decoder->mpeg1)
+ {
decoder->motion_parser[0] = motion_zero_420;
decoder->motion_parser[MC_FRAME] = motion_mp1;
decoder->motion_parser[4] = motion_reuse_420;
- } else if (decoder->picture_structure == FRAME_PICTURE) {
- if (decoder->chroma_format == 0) {
+ }
+ else if (decoder->picture_structure == FRAME_PICTURE)
+ {
+ if (decoder->chroma_format == 0)
+ {
decoder->motion_parser[0] = motion_zero_420;
decoder->motion_parser[MC_FIELD] = motion_fr_field_420;
decoder->motion_parser[MC_FRAME] = motion_fr_frame_420;
decoder->motion_parser[MC_DMV] = motion_fr_dmv_420;
decoder->motion_parser[4] = motion_reuse_420;
- } else if (decoder->chroma_format == 1) {
+ }
+ else if (decoder->chroma_format == 1)
+ {
decoder->motion_parser[0] = motion_zero_422;
decoder->motion_parser[MC_FIELD] = motion_fr_field_422;
decoder->motion_parser[MC_FRAME] = motion_fr_frame_422;
decoder->motion_parser[MC_DMV] = motion_fr_dmv_422;
decoder->motion_parser[4] = motion_reuse_422;
- } else {
+ }
+ else
+ {
decoder->motion_parser[0] = motion_zero_444;
decoder->motion_parser[MC_FIELD] = motion_fr_field_444;
decoder->motion_parser[MC_FRAME] = motion_fr_frame_444;
decoder->motion_parser[MC_DMV] = motion_fr_dmv_444;
decoder->motion_parser[4] = motion_reuse_444;
}
- } else {
- if (decoder->chroma_format == 0) {
+ }
+ else
+ {
+ if (decoder->chroma_format == 0)
+ {
decoder->motion_parser[0] = motion_zero_420;
decoder->motion_parser[MC_FIELD] = motion_fi_field_420;
decoder->motion_parser[MC_16X8] = motion_fi_16x8_420;
decoder->motion_parser[MC_DMV] = motion_fi_dmv_420;
decoder->motion_parser[4] = motion_reuse_420;
- } else if (decoder->chroma_format == 1) {
+ }
+ else if (decoder->chroma_format == 1)
+ {
decoder->motion_parser[0] = motion_zero_422;
decoder->motion_parser[MC_FIELD] = motion_fi_field_422;
decoder->motion_parser[MC_16X8] = motion_fi_16x8_422;
decoder->motion_parser[MC_DMV] = motion_fi_dmv_422;
decoder->motion_parser[4] = motion_reuse_422;
- } else {
+ }
+ else
+ {
decoder->motion_parser[0] = motion_zero_444;
decoder->motion_parser[MC_FIELD] = motion_fi_field_444;
decoder->motion_parser[MC_16X8] = motion_fi_16x8_444;
@@ -1691,6 +1915,7 @@ static inline int slice_init (mpeg2_decoder_t * const decoder, int code)
#define bit_buf (decoder->bitstream_buf)
#define bits (decoder->bitstream_bits)
#define bit_ptr (decoder->bitstream_ptr)
+
int offset;
const MBAtab * mba;
@@ -1702,14 +1927,19 @@ static inline int slice_init (mpeg2_decoder_t * const decoder, int code)
decoder->b_motion.pmv[0][0] = decoder->b_motion.pmv[0][1] = 0;
decoder->b_motion.pmv[1][0] = decoder->b_motion.pmv[1][1] = 0;
- if (decoder->vertical_position_extension) {
+ if (decoder->vertical_position_extension)
+ {
code += UBITS (bit_buf, 3) << 7;
DUMPBITS (bit_buf, bits, 3);
}
+
decoder->v_offset = (code - 1) * 16;
offset = 0;
+
if (!(decoder->convert) || decoder->coding_type != B_TYPE)
+ {
offset = (code - 1) * decoder->slice_stride;
+ }
decoder->dest[0] = decoder->picture_dest[0] + offset;
offset >>= (2 - decoder->chroma_format);
@@ -1719,51 +1949,68 @@ static inline int slice_init (mpeg2_decoder_t * const decoder, int code)
get_quantizer_scale (decoder);
/* ignore intra_slice and all the extra data */
- while (bit_buf & 0x80000000) {
+ while (bit_buf & 0x80000000)
+ {
DUMPBITS (bit_buf, bits, 9);
NEEDBITS (bit_buf, bits, bit_ptr);
}
/* decode initial macroblock address increment */
offset = 0;
- while (1) {
- if (bit_buf >= 0x08000000) {
+ while (1)
+ {
+ if (bit_buf >= 0x08000000)
+ {
mba = MBA_5 + (UBITS (bit_buf, 6) - 2);
break;
- } else if (bit_buf >= 0x01800000) {
+ }
+ else if (bit_buf >= 0x01800000)
+ {
mba = MBA_11 + (UBITS (bit_buf, 12) - 24);
break;
- } else switch (UBITS (bit_buf, 12)) {
- case 8: /* macroblock_escape */
- offset += 33;
- DUMPBITS (bit_buf, bits, 11);
- NEEDBITS (bit_buf, bits, bit_ptr);
- continue;
- case 15: /* macroblock_stuffing (MPEG1 only) */
- bit_buf &= 0xfffff;
- DUMPBITS (bit_buf, bits, 11);
- NEEDBITS (bit_buf, bits, bit_ptr);
- continue;
- default: /* error */
- return 1;
+ }
+ else
+ {
+ switch (UBITS (bit_buf, 12))
+ {
+ case 8: /* macroblock_escape */
+ offset += 33;
+ DUMPBITS (bit_buf, bits, 11);
+ NEEDBITS (bit_buf, bits, bit_ptr);
+ continue;
+ case 15: /* macroblock_stuffing (MPEG1 only) */
+ bit_buf &= 0xfffff;
+ DUMPBITS (bit_buf, bits, 11);
+ NEEDBITS (bit_buf, bits, bit_ptr);
+ continue;
+ default: /* error */
+ return 1;
+ }
}
}
+
DUMPBITS (bit_buf, bits, mba->len + 1);
decoder->offset = (offset + mba->mba) << 4;
- while (decoder->offset - decoder->width >= 0) {
+ while (decoder->offset - decoder->width >= 0)
+ {
decoder->offset -= decoder->width;
- if (!(decoder->convert) || decoder->coding_type != B_TYPE) {
+
+ if (!(decoder->convert) || decoder->coding_type != B_TYPE)
+ {
decoder->dest[0] += decoder->slice_stride;
decoder->dest[1] += decoder->slice_uv_stride;
decoder->dest[2] += decoder->slice_uv_stride;
}
+
decoder->v_offset += 16;
}
+
if (decoder->v_offset > decoder->limit_y)
return 1;
return 0;
+
#undef bit_buf
#undef bits
#undef bit_ptr
@@ -1781,7 +2028,8 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
if (slice_init (decoder, code))
return;
- while (1) {
+ while (1)
+ {
int macroblock_modes;
int mba_inc;
const MBAtab * mba;
@@ -1794,28 +2042,34 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
if (macroblock_modes & MACROBLOCK_QUANT)
get_quantizer_scale (decoder);
- if (macroblock_modes & MACROBLOCK_INTRA) {
-
+ if (macroblock_modes & MACROBLOCK_INTRA)
+ {
int DCT_offset, DCT_stride;
int offset;
uint8_t * dest_y;
- if (decoder->concealment_motion_vectors) {
+ if (decoder->concealment_motion_vectors)
+ {
if (decoder->picture_structure == FRAME_PICTURE)
motion_fr_conceal (decoder);
else
motion_fi_conceal (decoder);
- } else {
+ }
+ else
+ {
decoder->f_motion.pmv[0][0] = decoder->f_motion.pmv[0][1] = 0;
decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[1][1] = 0;
decoder->b_motion.pmv[0][0] = decoder->b_motion.pmv[0][1] = 0;
decoder->b_motion.pmv[1][0] = decoder->b_motion.pmv[1][1] = 0;
}
- if (macroblock_modes & DCT_TYPE_INTERLACED) {
+ if (macroblock_modes & DCT_TYPE_INTERLACED)
+ {
DCT_offset = decoder->stride;
DCT_stride = decoder->stride * 2;
- } else {
+ }
+ else
+ {
DCT_offset = decoder->stride * 8;
DCT_stride = decoder->stride;
}
@@ -1826,27 +2080,38 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
slice_intra_DCT (decoder, 0, dest_y + 8, DCT_stride);
slice_intra_DCT (decoder, 0, dest_y + DCT_offset, DCT_stride);
slice_intra_DCT (decoder, 0, dest_y + DCT_offset + 8, DCT_stride);
- if (likely (decoder->chroma_format == 0)) {
+
+ if (likely (decoder->chroma_format == 0))
+ {
slice_intra_DCT (decoder, 1, decoder->dest[1] + (offset >> 1),
decoder->uv_stride);
slice_intra_DCT (decoder, 2, decoder->dest[2] + (offset >> 1),
decoder->uv_stride);
- if (decoder->coding_type == D_TYPE) {
+
+ if (decoder->coding_type == D_TYPE)
+ {
NEEDBITS (bit_buf, bits, bit_ptr);
DUMPBITS (bit_buf, bits, 1);
}
- } else if (likely (decoder->chroma_format == 1)) {
+ }
+ else if (likely (decoder->chroma_format == 1))
+ {
uint8_t * dest_u = decoder->dest[1] + (offset >> 1);
uint8_t * dest_v = decoder->dest[2] + (offset >> 1);
+
DCT_stride >>= 1;
DCT_offset >>= 1;
+
slice_intra_DCT (decoder, 1, dest_u, DCT_stride);
slice_intra_DCT (decoder, 2, dest_v, DCT_stride);
slice_intra_DCT (decoder, 1, dest_u + DCT_offset, DCT_stride);
slice_intra_DCT (decoder, 2, dest_v + DCT_offset, DCT_stride);
- } else {
+ }
+ else
+ {
uint8_t * dest_u = decoder->dest[1] + offset;
uint8_t * dest_v = decoder->dest[2] + offset;
+
slice_intra_DCT (decoder, 1, dest_u, DCT_stride);
slice_intra_DCT (decoder, 2, dest_v, DCT_stride);
slice_intra_DCT (decoder, 1, dest_u + DCT_offset, DCT_stride);
@@ -1858,52 +2123,66 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
slice_intra_DCT (decoder, 2, dest_v + DCT_offset + 8,
DCT_stride);
}
- } else {
-
+ }
+ else
+ {
motion_parser_t * parser;
parser =
decoder->motion_parser[macroblock_modes >> MOTION_TYPE_SHIFT];
MOTION_CALL (parser, macroblock_modes);
- if (macroblock_modes & MACROBLOCK_PATTERN) {
+ if (macroblock_modes & MACROBLOCK_PATTERN)
+ {
int coded_block_pattern;
int DCT_offset, DCT_stride;
- if (macroblock_modes & DCT_TYPE_INTERLACED) {
+ if (macroblock_modes & DCT_TYPE_INTERLACED)
+ {
DCT_offset = decoder->stride;
DCT_stride = decoder->stride * 2;
- } else {
+ }
+ else
+ {
DCT_offset = decoder->stride * 8;
DCT_stride = decoder->stride;
}
coded_block_pattern = get_coded_block_pattern (decoder);
- if (likely (decoder->chroma_format == 0)) {
+ if (likely (decoder->chroma_format == 0))
+ {
int offset = decoder->offset;
uint8_t * dest_y = decoder->dest[0] + offset;
+
if (coded_block_pattern & 1)
slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride);
+
if (coded_block_pattern & 2)
slice_non_intra_DCT (decoder, 0, dest_y + 8,
DCT_stride);
+
if (coded_block_pattern & 4)
slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset,
DCT_stride);
+
if (coded_block_pattern & 8)
slice_non_intra_DCT (decoder, 0,
dest_y + DCT_offset + 8,
DCT_stride);
+
if (coded_block_pattern & 16)
slice_non_intra_DCT (decoder, 1,
decoder->dest[1] + (offset >> 1),
decoder->uv_stride);
+
if (coded_block_pattern & 32)
slice_non_intra_DCT (decoder, 2,
decoder->dest[2] + (offset >> 1),
decoder->uv_stride);
- } else if (likely (decoder->chroma_format == 1)) {
+ }
+ else if (likely (decoder->chroma_format == 1))
+ {
int offset;
uint8_t * dest_y;
@@ -1912,14 +2191,18 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
offset = decoder->offset;
dest_y = decoder->dest[0] + offset;
+
if (coded_block_pattern & 1)
slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride);
+
if (coded_block_pattern & 2)
slice_non_intra_DCT (decoder, 0, dest_y + 8,
DCT_stride);
+
if (coded_block_pattern & 4)
slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset,
DCT_stride);
+
if (coded_block_pattern & 8)
slice_non_intra_DCT (decoder, 0,
dest_y + DCT_offset + 8,
@@ -1927,23 +2210,29 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
DCT_stride >>= 1;
DCT_offset = (DCT_offset + offset) >> 1;
+
if (coded_block_pattern & 16)
slice_non_intra_DCT (decoder, 1,
decoder->dest[1] + (offset >> 1),
DCT_stride);
+
if (coded_block_pattern & 32)
slice_non_intra_DCT (decoder, 2,
decoder->dest[2] + (offset >> 1),
DCT_stride);
+
if (coded_block_pattern & (2 << 30))
slice_non_intra_DCT (decoder, 1,
decoder->dest[1] + DCT_offset,
DCT_stride);
+
if (coded_block_pattern & (1 << 30))
slice_non_intra_DCT (decoder, 2,
decoder->dest[2] + DCT_offset,
DCT_stride);
- } else {
+ }
+ else
+ {
int offset;
uint8_t * dest_y, * dest_u, * dest_v;
@@ -1957,12 +2246,15 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
if (coded_block_pattern & 1)
slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride);
+
if (coded_block_pattern & 2)
slice_non_intra_DCT (decoder, 0, dest_y + 8,
DCT_stride);
+
if (coded_block_pattern & 4)
slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset,
DCT_stride);
+
if (coded_block_pattern & 8)
slice_non_intra_DCT (decoder, 0,
dest_y + DCT_offset + 8,
@@ -1970,24 +2262,31 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
if (coded_block_pattern & 16)
slice_non_intra_DCT (decoder, 1, dest_u, DCT_stride);
+
if (coded_block_pattern & 32)
slice_non_intra_DCT (decoder, 2, dest_v, DCT_stride);
+
if (coded_block_pattern & (32 << 26))
slice_non_intra_DCT (decoder, 1, dest_u + DCT_offset,
DCT_stride);
+
if (coded_block_pattern & (16 << 26))
slice_non_intra_DCT (decoder, 2, dest_v + DCT_offset,
DCT_stride);
+
if (coded_block_pattern & (8 << 26))
slice_non_intra_DCT (decoder, 1, dest_u + 8,
DCT_stride);
+
if (coded_block_pattern & (4 << 26))
slice_non_intra_DCT (decoder, 2, dest_v + 8,
DCT_stride);
+
if (coded_block_pattern & (2 << 26))
slice_non_intra_DCT (decoder, 1,
dest_u + DCT_offset + 8,
DCT_stride);
+
if (coded_block_pattern & (1 << 26))
slice_non_intra_DCT (decoder, 2,
dest_v + DCT_offset + 8,
@@ -2003,46 +2302,66 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
NEEDBITS (bit_buf, bits, bit_ptr);
mba_inc = 0;
- while (1) {
- if (bit_buf >= 0x10000000) {
+
+ while (1)
+ {
+ if (bit_buf >= 0x10000000)
+ {
mba = MBA_5 + (UBITS (bit_buf, 5) - 2);
break;
- } else if (bit_buf >= 0x03000000) {
+ }
+ else if (bit_buf >= 0x03000000)
+ {
mba = MBA_11 + (UBITS (bit_buf, 11) - 24);
break;
- } else switch (UBITS (bit_buf, 11)) {
- case 8: /* macroblock_escape */
- mba_inc += 33;
- /* pass through */
- case 15: /* macroblock_stuffing (MPEG1 only) */
- DUMPBITS (bit_buf, bits, 11);
- NEEDBITS (bit_buf, bits, bit_ptr);
- continue;
- default: /* end of slice, or error */
- return;
+ }
+ else
+ {
+ switch (UBITS (bit_buf, 11))
+ {
+ case 8: /* macroblock_escape */
+ mba_inc += 33;
+ /* pass through */
+ case 15: /* macroblock_stuffing (MPEG1 only) */
+ DUMPBITS (bit_buf, bits, 11);
+ NEEDBITS (bit_buf, bits, bit_ptr);
+ continue;
+ default: /* end of slice, or error */
+ return;
+ }
}
}
+
DUMPBITS (bit_buf, bits, mba->len);
mba_inc += mba->mba;
- if (mba_inc) {
+ if (mba_inc)
+ {
decoder->dc_dct_pred[0] = decoder->dc_dct_pred[1] =
decoder->dc_dct_pred[2] = 16384;
- if (decoder->coding_type == P_TYPE) {
- do {
+ if (decoder->coding_type == P_TYPE)
+ {
+ do
+ {
MOTION_CALL (decoder->motion_parser[0],
MACROBLOCK_MOTION_FORWARD);
NEXT_MACROBLOCK;
- } while (--mba_inc);
- } else {
- do {
+ }
+ while (--mba_inc);
+ }
+ else
+ {
+ do
+ {
MOTION_CALL (decoder->motion_parser[4], macroblock_modes);
NEXT_MACROBLOCK;
- } while (--mba_inc);
+ }
+ while (--mba_inc);
}
}
}
+
#undef bit_buf
#undef bits
#undef bit_ptr