j = zigzag_direct[i];
j = s->intra_scantable.permutated[i];
static void encode_block(MpegEncContext *s, DCTELEM *block, int n){    int mant, nbits, code, i, j;    int component, dc, run, last_index, val;    MJpegContext *m = s->mjpeg_ctx;    UINT8 *huff_size_ac;    UINT16 *huff_code_ac;        /* DC coef */    component = (n <= 3 ? 0 : n - 4 + 1);    dc = block[0]; /* overflow is impossible */    val = dc - s->last_dc[component];    if (n < 4) {        mjpeg_encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance);        huff_size_ac = m->huff_size_ac_luminance;        huff_code_ac = m->huff_code_ac_luminance;    } else {        mjpeg_encode_dc(s, val, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);        huff_size_ac = m->huff_size_ac_chrominance;        huff_code_ac = m->huff_code_ac_chrominance;    }    s->last_dc[component] = dc;        /* AC coefs */        run = 0;    last_index = s->block_last_index[n];    for(i=1;i<=last_index;i++) {        j = zigzag_direct[i];        val = block[j];        if (val == 0) {            run++;        } else {            while (run >= 16) {                jput_bits(&s->pb, huff_size_ac[0xf0], huff_code_ac[0xf0]);                run -= 16;            }            mant = val;            if (val < 0) {                val = -val;                mant--;            }                        /* compute the log (XXX: optimize) */            nbits = 0;            while (val != 0) {                val = val >> 1;                nbits++;            }            code = (run << 4) | nbits;            jput_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]);                    jput_bits(&s->pb, nbits, mant & ((1 << nbits) - 1));            run = 0;        }    }    /* output EOB only if not already 64 values */    if (last_index < 63 || run != 0)        jput_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]);}