---
shame on Derek, even this version is less sloppy than his
---
libavcodec/fic.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
diff --git a/libavcodec/fic.c b/libavcodec/fic.c
index df03437..7234ea8 100644
--- a/libavcodec/fic.c
+++ b/libavcodec/fic.c
@@ -80,6 +80,53 @@ static const uint8_t fic_header[7] = { 0, 0, 1, 'F', 'I',
'C', 'V' };
#define FIC_HEADER_SIZE 27
+#define DCT_TEMPLATE(blk, step, shift) \
+ const int t0 = 27246 * blk[3 * step] + 18405 * blk[5 * step]; \
+ const int t1 = 27246 * blk[5 * step] - 18405 * blk[3 * step]; \
+ const int t2 = 6393 * blk[7 * step] + 32139 * blk[1 * step]; \
+ const int t3 = 6393 * blk[1 * step] - 32139 * blk[7 * step]; \
+ const int t4 = 5793 * (t2 + t0 + 0x800 >> 12); \
+ const int t5 = 5793 * (t3 + t1 + 0x800 >> 12); \
+ const int t6 = t2 - t0;\
+ const int t7 = t3 - t1;\
+ const int t8 = 17734 * blk[2 * step] - 42813 * blk[6 * step]; \
+ const int t9 = 17734 * blk[6 * step] + 42814 * blk[2 * step]; \
+ const int tA = (blk[0 * step] - blk[4 * step] << 15) + (1 << shift - 1);
\
+ const int tB = (blk[0 * step] + blk[4 * step] << 15) + (1 << shift - 1);
\
+ blk[0 * step] = ( t4 + t9 + tB) >> shift; \
+ blk[1 * step] = ( t6 + t7 + t8 + tA) >> shift; \
+ blk[2 * step] = ( t6 - t7 - t8 + tA) >> shift; \
+ blk[3 * step] = ( t5 - t9 + tB) >> shift; \
+ blk[4 * step] = ( -t5 - t9 + tB) >> shift; \
+ blk[5 * step] = (-(t6 - t7) - t8 + tA) >> shift; \
+ blk[6 * step] = (-(t6 + t7) + t8 + tA) >> shift; \
+ blk[7 * step] = ( -t4 + t9 + tB) >> shift; \
+
+static void fic_idct_put(uint8_t *dst, int stride, int16_t *block)
+{
+ int i, j;
+ int16_t *ptr;
+
+ ptr = block;
+ for (i = 0; i < 8; i++) {
+ DCT_TEMPLATE(ptr, 8, 13);
+ ptr++;
+ }
+
+ ptr = block;
+ for (i = 0; i < 8; i++) {
+ DCT_TEMPLATE(ptr, 1, 20);
+ ptr += 8;
+ }
+
+ ptr = block;
+ for (j = 0; j < 8; j++) {
+ for (i = 0; i < 8; i++)
+ dst[i] = av_clip_uint8(ptr[i]);
+ dst += stride;
+ ptr += 8;
+ }
+}
static int fic_decode_block(FICContext *ctx, GetBitContext *gb,
uint8_t *dst, int stride, int16_t *block)
{
@@ -101,9 +148,9 @@ static int fic_decode_block(FICContext *ctx, GetBitContext
*gb,
return AVERROR_INVALIDDATA;
for (i = 0; i < num_coeff; i++)
- block[ctx->scantable.permutated[i]] = get_se_golomb(gb) * ctx->qmat[i];
+ block[ff_zigzag_direct[i]] = get_se_golomb(gb) * ctx->qmat[i];
- ctx->dsp.idct_put(dst, stride, block);
+ fic_idct_put(dst, stride, block);
return 0;
}
--
1.7.9.5
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel