jpeg2000: cosmetics & restructuring from jpeg2000

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-05-26 19:18:31 +02:00
parent 228ce33606
commit b01e61a47d
1 changed files with 21 additions and 16 deletions

View File

@ -51,10 +51,12 @@ Jpeg2000TgtNode *ff_j2k_tag_tree_init(int w, int h)
{
int pw = w, ph = h;
Jpeg2000TgtNode *res, *t, *t2;
int32_t tt_size;
t = res = av_mallocz(tag_tree_size(w, h)*sizeof(Jpeg2000TgtNode));
tt_size = tag_tree_size(w, h);
if (res == NULL)
t = res = av_mallocz(tt_size, sizeof(*t));
if (!res)
return NULL;
while (w > 1 || h > 1) {
@ -67,9 +69,9 @@ Jpeg2000TgtNode *ff_j2k_tag_tree_init(int w, int h)
t2 = t + pw * ph;
for (i = 0; i < ph; i++)
for (j = 0; j < pw; j++) {
for (j = 0; j < pw; j++)
t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];
}
t = t2;
}
t[0].parent = NULL;
@ -129,18 +131,21 @@ static int getsigctxno(int flag, int bandno)
return 0;
}
static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
static int getsgnctxno(int flag, uint8_t *xorbit)
{
int vcontrib, hcontrib;
static const int contribtab[3][3] = {{0, -1, 1}, {-1, -1, 0}, {1, 0, 1}};
static const int ctxlbltab[3][3] = {{13, 12, 11}, {10, 9, 10}, {11, 12, 13}};
static const int xorbittab[3][3] = {{1, 1, 1,}, {1, 0, 0}, {0, 0, 0}};
hcontrib = contribtab[flag & JPEG2000_T1_SIG_E ? flag & JPEG2000_T1_SGN_E ? 1 : 2 : 0]
[flag & JPEG2000_T1_SIG_W ? flag & JPEG2000_T1_SGN_W ? 1 : 2 : 0] + 1;
vcontrib = contribtab[flag & JPEG2000_T1_SIG_S ? flag & JPEG2000_T1_SGN_S ? 1 : 2 : 0]
[flag & JPEG2000_T1_SIG_N ? flag & JPEG2000_T1_SGN_N ? 1 : 2 : 0] + 1;
*xorbit = xorbittab[hcontrib][vcontrib];
return ctxlbltab[hcontrib][vcontrib];
}