|
|
|
@ -47,7 +47,8 @@ typedef struct TgqContext { |
|
|
|
|
GetByteContext gb; |
|
|
|
|
} TgqContext; |
|
|
|
|
|
|
|
|
|
static av_cold int tgq_decode_init(AVCodecContext *avctx){ |
|
|
|
|
static av_cold int tgq_decode_init(AVCodecContext *avctx) |
|
|
|
|
{ |
|
|
|
|
TgqContext *s = avctx->priv_data; |
|
|
|
|
uint8_t idct_permutation[64]; |
|
|
|
|
s->avctx = avctx; |
|
|
|
@ -58,7 +59,8 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx){ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb){ |
|
|
|
|
static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb) |
|
|
|
|
{ |
|
|
|
|
uint8_t *perm = s->scantable.permutated; |
|
|
|
|
int i, j, value; |
|
|
|
|
block[0] = get_sbits(gb, 8) * s->qtable[0]; |
|
|
|
@ -103,7 +105,9 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb |
|
|
|
|
block[0] += 128 << 4; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], int mb_x, int mb_y){ |
|
|
|
|
static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], |
|
|
|
|
int mb_x, int mb_y) |
|
|
|
|
{ |
|
|
|
|
int linesize = s->frame.linesize[0]; |
|
|
|
|
uint8_t *dest_y = s->frame.data[0] + (mb_y * 16 * linesize) + mb_x * 16; |
|
|
|
|
uint8_t *dest_cb = s->frame.data[1] + (mb_y * 8 * s->frame.linesize[1]) + mb_x * 8; |
|
|
|
@ -119,7 +123,9 @@ static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], int mb_x, int m |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline void tgq_dconly(TgqContext *s, unsigned char *dst, int dst_stride, int dc){ |
|
|
|
|
static inline void tgq_dconly(TgqContext *s, unsigned char *dst, |
|
|
|
|
int dst_stride, int dc) |
|
|
|
|
{ |
|
|
|
|
int level = av_clip_uint8((dc*s->qtable[0] + 2056) >> 4); |
|
|
|
|
int j; |
|
|
|
|
for (j = 0; j < 8; j++) |
|
|
|
@ -142,7 +148,8 @@ static void tgq_idct_put_mb_dconly(TgqContext *s, int mb_x, int mb_y, const int8 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){ |
|
|
|
|
static void tgq_decode_mb(TgqContext *s, int mb_y, int mb_x) |
|
|
|
|
{ |
|
|
|
|
int mode; |
|
|
|
|
int i; |
|
|
|
|
int8_t dc[6]; |
|
|
|
@ -174,18 +181,21 @@ static void tgq_decode_mb(TgqContext *s, int mb_y, int mb_x){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void tgq_calculate_qtable(TgqContext *s, int quant){ |
|
|
|
|
static void tgq_calculate_qtable(TgqContext *s, int quant) |
|
|
|
|
{ |
|
|
|
|
int i, j; |
|
|
|
|
const int a = (14 * (100 - quant)) / 100 + 1; |
|
|
|
|
const int b = (11 * (100 - quant)) / 100 + 4; |
|
|
|
|
for (j = 0; j < 8; j++) |
|
|
|
|
for (i = 0; i < 8; i++) |
|
|
|
|
s->qtable[j*8+i] = ((a*(j+i)/(7+7) + b)*ff_inv_aanscales[j*8+i])>>(14-4); |
|
|
|
|
s->qtable[j * 8 + i] = ((a * (j + i) / (7 + 7) + b) * |
|
|
|
|
ff_inv_aanscales[j * 8 + i]) >> (14 - 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int tgq_decode_frame(AVCodecContext *avctx, |
|
|
|
|
void *data, int *got_frame, |
|
|
|
|
AVPacket *avpkt){ |
|
|
|
|
AVPacket *avpkt) |
|
|
|
|
{ |
|
|
|
|
const uint8_t *buf = avpkt->data; |
|
|
|
|
int buf_size = avpkt->size; |
|
|
|
|
TgqContext *s = avctx->priv_data; |
|
|
|
@ -233,7 +243,8 @@ static int tgq_decode_frame(AVCodecContext *avctx, |
|
|
|
|
return avpkt->size; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static av_cold int tgq_decode_end(AVCodecContext *avctx){ |
|
|
|
|
static av_cold int tgq_decode_end(AVCodecContext *avctx) |
|
|
|
|
{ |
|
|
|
|
TgqContext *s = avctx->priv_data; |
|
|
|
|
if (s->frame.data[0]) |
|
|
|
|
s->avctx->release_buffer(avctx, &s->frame); |
|
|
|
|