mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-11 17:55:21 +00:00
mpeg12dec: Refactor mpeg1_decode_block_intra()
Reduce variable scope, improve variable name, drop pointless ff_dlog(), merge variable declaration and initialization, whitespace cosmetics.
This commit is contained in:
parent
cdbaa43604
commit
249827f736
@ -139,30 +139,33 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
|
||||
} while (0)
|
||||
|
||||
static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
||||
int16_t *block, int n)
|
||||
int16_t *block, int index)
|
||||
{
|
||||
int level, dc, diff, i, j, run;
|
||||
int component;
|
||||
RLTable *rl = &ff_rl_mpeg1;
|
||||
int dc, diff, i = 0, component;
|
||||
RLTable *rl = &ff_rl_mpeg1;
|
||||
uint8_t *const scantable = s->intra_scantable.permutated;
|
||||
const uint16_t *quant_matrix = s->intra_matrix;
|
||||
const int qscale = s->qscale;
|
||||
|
||||
/* DC coefficient */
|
||||
component = (n <= 3 ? 0 : n - 4 + 1);
|
||||
component = index <= 3 ? 0 : index - 4 + 1;
|
||||
|
||||
diff = decode_dc(&s->gb, component);
|
||||
if (diff >= 0xffff)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
dc = s->last_dc[component];
|
||||
dc += diff;
|
||||
s->last_dc[component] = dc;
|
||||
|
||||
block[0] = dc * quant_matrix[0];
|
||||
ff_dlog(s->avctx, "dc=%d diff=%d\n", dc, diff);
|
||||
i = 0;
|
||||
|
||||
{
|
||||
OPEN_READER(re, &s->gb);
|
||||
/* now quantify & encode AC coefficients */
|
||||
for (;;) {
|
||||
while (1) {
|
||||
int level, run, j;
|
||||
|
||||
UPDATE_CACHE(re, &s->gb);
|
||||
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
|
||||
TEX_VLC_BITS, 2, 0);
|
||||
@ -173,6 +176,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
||||
i += run;
|
||||
if (i > MAX_INDEX)
|
||||
break;
|
||||
|
||||
j = scantable[i];
|
||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||
level = (level - 1) | 1;
|
||||
@ -186,6 +190,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
||||
UPDATE_CACHE(re, &s->gb);
|
||||
level = SHOW_SBITS(re, &s->gb, 8);
|
||||
SKIP_BITS(re, &s->gb, 8);
|
||||
|
||||
if (level == -128) {
|
||||
level = SHOW_UBITS(re, &s->gb, 8) - 256;
|
||||
LAST_SKIP_BITS(re, &s->gb, 8);
|
||||
@ -193,9 +198,11 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
||||
level = SHOW_UBITS(re, &s->gb, 8);
|
||||
LAST_SKIP_BITS(re, &s->gb, 8);
|
||||
}
|
||||
|
||||
i += run;
|
||||
if (i > MAX_INDEX)
|
||||
break;
|
||||
|
||||
j = scantable[i];
|
||||
if (level < 0) {
|
||||
level = -level;
|
||||
@ -215,13 +222,13 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
|
||||
|
||||
check_scantable_index(s, i);
|
||||
|
||||
s->block_last_index[n] = i;
|
||||
s->block_last_index[index] = i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
|
||||
int ff_mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int index)
|
||||
{
|
||||
return mpeg1_decode_block_intra(s, block, n);
|
||||
return mpeg1_decode_block_intra(s, block, index);
|
||||
}
|
||||
|
||||
static inline int mpeg1_decode_block_inter(MpegEncContext *s,
|
||||
|
Loading…
Reference in New Issue
Block a user