[FFmpeg-soc] [soc]: r769 - in jpeg2000: checkout.sh ffmpeg.patch j2k.c j2k.h j2kenc.c

Michael Niedermayer michaelni at gmx.at
Wed Aug 15 02:26:16 CEST 2007


Hi

On Tue, Aug 14, 2007 at 01:03:03PM +0200, k.nowosad wrote:
> Author: k.nowosad
> Date: Tue Aug 14 13:03:03 2007
> New Revision: 769
> 
> Log:
> moved common functions for encoder and decoder into j2k.c
[...]
> +void ff_j2k_printv(int *tab, int l)
> +{
> +    int i;
> +    for (i = 0; i < l; i++)
> +        printf("%.3d ", tab[i]);
> +    printf("\n");

av_log()


[...]
> +int ff_j2k_ceildivpow2(int a, int b)
> +{
> +    return (a + (1 << b) - 1)>> b;
> +}
> +
> +int ff_j2k_ceildiv(int a, int b)
> +{
> +    return (a + b - 1) / b;
> +}

maybe it would be better if these where static inline in a header



> +
> +/* tag tree routines */
> +
> +/** allocate the memory for tag tree */
> +//TODO: optimize (too many mallocs)
> +static J2kTgtNode *tag_tree_alloc(int w, int h)
> +{

> +    int i;
> +   J2kTgtNode *t = av_malloc(w*h*sizeof(J2kTgtNode));

indention


> +    if (t == NULL)
> +        return NULL;

> +    for (i = 0; i < w*h; i++){
> +        t[i].val = 0;
> +        t[i].vis = 0;
> +    }

av_mallocz() or memset(0) would avoid this


[...]

> +int ff_j2k_getnbctxno(int flag, int bandno)
> +{
> +    int h, v, d;
> +
> +    h = ((flag & J2K_T1_SIG_E) ? 1:0)+
> +        ((flag & J2K_T1_SIG_W) ? 1:0);
> +    v = ((flag & J2K_T1_SIG_N) ? 1:0)+
> +        ((flag & J2K_T1_SIG_S) ? 1:0);
> +    d = ((flag & J2K_T1_SIG_NE) ? 1:0)+
> +        ((flag & J2K_T1_SIG_NW) ? 1:0)+
> +        ((flag & J2K_T1_SIG_SE) ? 1:0)+
> +        ((flag & J2K_T1_SIG_SW) ? 1:0);
> +    switch(bandno){
> +        case 0: // LL || LH
> +        case 2:
> +            if (h == 2) return 8;
> +            if (h == 1){
> +                if (v >= 1) return 7;
> +                if (d >= 1) return 6;
> +                return 5;
> +            }
> +            if (v == 2) return 4;
> +            if (v == 1) return 3;
> +            if (d >= 2) return 2;
> +            if (d == 1) return 1;
> +            return 0;
> +        case 1: // HL
> +            if (v == 2) return 8;
> +            if (v == 1){
> +                if (h >= 1) return 7;
> +                if (d >= 1) return 6;
> +                return 5;
> +            }
> +            if (h == 2) return 4;
> +            if (h == 1) return 3;
> +            if (d >= 2) return 2;
> +            if (d >= 1) return 1;
> +            return 0;
> +        case 3:
> +            if (d >= 3) return 8;
> +            if (d == 2){
> +                if (h+v >= 1) return 7;
> +                return 6;
> +            }
> +            if (d == 1){
> +                if (h+v >= 2) return 5;
> +                if (h+v == 1) return 4;
> +                return 3;
> +            }
> +            if (h+v >= 2) return 2;
> +            if (h+v == 1) return 1;
> +            return 0;
> +    }
> +    assert(0);
> +}

this could be optimized to

return lut[flag&255][bandno];
with lut 1024 byte 

or

return lut[lut2[flag&255]][bandno];
with lut2 256 byte and lut 180 byte



> +
> +int ff_j2k_getrefctxno(int flag)
> +{
> +    if (!(flag & J2K_T1_REF)){
> +        if (flag & J2K_T1_SIG_NB)
> +            return 15;
> +        return 14;
> +    }
> +    return 16;
> +}
> +

> +int ff_j2k_getsgnctxno(int flag, int *xorbit)
> +{
> +    int vcontrib, hcontrib;
> +    const int contribtab[3][3] = {{0, -1, 1}, {-1, -1, 0}, {1, 0, 1}};
> +    const int ctxlbltab[3][3] = {{13, 12, 11}, {10, 9, 10}, {11, 12, 13}};
> +    const int xorbittab[3][3] = {{1, 1, 1,}, {1, 0, 0}, {0, 0, 0}};
> +
> +    hcontrib = contribtab[flag & J2K_T1_SIG_E ? flag & J2K_T1_SGN_E ? 1:2:0]
> +                         [flag & J2K_T1_SIG_W ? flag & J2K_T1_SGN_W ? 1:2:0]+1;
> +    vcontrib = contribtab[flag & J2K_T1_SIG_S ? flag & J2K_T1_SGN_S ? 1:2:0]
> +                         [flag & J2K_T1_SIG_N ? flag & J2K_T1_SGN_N ? 1:2:0]+1;
> +    *xorbit = xorbittab[hcontrib][vcontrib];
> +    return ctxlbltab[hcontrib][vcontrib];
> +}

lut[flag&15][(flag>>8)&15]
needs just 256 byte


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20070815/e43f66f6/attachment.pgp>


More information about the FFmpeg-soc mailing list