Lines Matching refs:jd

134     JDEC * jd,              /* Pointer to the decompressor object */  in alloc_pool()  argument
143 if(jd->sz_pool >= ndata) { in alloc_pool()
144 jd->sz_pool -= ndata; in alloc_pool()
145 rp = (char *)jd->pool; /* Get start of available memory pool */ in alloc_pool()
146 jd->pool = (void *)(rp + ndata); /* Allocate required bytes */ in alloc_pool()
160 JDEC * jd, /* Pointer to the decompressor object */ in create_qt_tbl() argument
176 pb = alloc_pool(jd, 64 * sizeof(int32_t)); /* Allocate a memory block for the table */ in create_qt_tbl()
178 jd->qttbl[i] = pb; /* Register the table */ in create_qt_tbl()
196 JDEC * jd, /* Pointer to the decompressor object */ in create_huffman_tbl() argument
214 … pb = alloc_pool(jd, 16); /* Allocate a memory block for the bit distribution table */ in create_huffman_tbl()
216 jd->huffbits[num][cls] = pb; in create_huffman_tbl()
220 … ph = alloc_pool(jd, np * sizeof(uint16_t)); /* Allocate a memory block for the code word table */ in create_huffman_tbl()
222 jd->huffcode[num][cls] = ph; in create_huffman_tbl()
232 pd = alloc_pool(jd, np); /* Allocate a memory block for the decoded data */ in create_huffman_tbl()
234 jd->huffdata[num][cls] = pd; in create_huffman_tbl()
247 tbl_ac = alloc_pool(jd, HUFF_LEN * sizeof(uint16_t)); /* LUT for AC elements */ in create_huffman_tbl()
249 jd->hufflut_ac[num] = tbl_ac; in create_huffman_tbl()
253 tbl_dc = alloc_pool(jd, HUFF_LEN * sizeof(uint8_t)); /* LUT for AC elements */ in create_huffman_tbl()
255 jd->hufflut_dc[num] = tbl_dc; in create_huffman_tbl()
271 jd->longofs[num][cls] = i; /* Code table offset for long code */ in create_huffman_tbl()
287 JDEC * jd, /* Pointer to the decompressor object */ in huffext() argument
292 size_t dc = jd->dctr; in huffext()
293 uint8_t * dp = jd->dptr; in huffext()
298 const uint8_t * hb = jd->huffbits[id][cls]; /* Bit distribution table */ in huffext()
299 const uint16_t * hc = jd->huffcode[id][cls]; /* Code word table */ in huffext()
300 const uint8_t * hd = jd->huffdata[id][cls]; /* Data table */ in huffext()
303 bm = jd->dbit; /* Bit mask to extract */ in huffext()
309 dp = jd->inbuf; /* Top of input buffer */ in huffext()
310 dc = jd->infunc(jd, dp, JD_SZBUF); in huffext()
336 jd->dbit = bm; in huffext()
337 jd->dctr = dc; in huffext()
338 jd->dptr = dp; in huffext()
349 unsigned int nc, bl, wbit = jd->dbit % 32; in huffext()
350 uint32_t w = jd->wreg & ((1UL << wbit) - 1); in huffext()
354 if(jd->marker) { in huffext()
359 dp = jd->inbuf; /* Top of input buffer */ in huffext()
360 dc = jd->infunc(jd, dp, JD_SZBUF); in huffext()
367 if(d != 0) jd->marker = d; /* Not an escape of 0xFF but a marker */ in huffext()
380 jd->dctr = dc; in huffext()
381 jd->dptr = dp; in huffext()
382 jd->wreg = w; in huffext()
388 d = jd->hufflut_ac[id][d]; /* Table decode */ in huffext()
390 jd->dbit = wbit - (d >> 8); /* Snip the code length */ in huffext()
395 d = jd->hufflut_dc[id][d]; /* Table decode */ in huffext()
397 jd->dbit = wbit - (d >> 4); /* Snip the code length */ in huffext()
403 hb = jd->huffbits[id][cls] + HUFF_BIT; /* Bit distribution table */ in huffext()
404 hc = jd->huffcode[id][cls] + jd->longofs[id][cls]; /* Code word table */ in huffext()
405 hd = jd->huffdata[id][cls] + jd->longofs[id][cls]; /* Data table */ in huffext()
409 hb = jd->huffbits[id][cls]; /* Bit distribution table */ in huffext()
410 hc = jd->huffcode[id][cls]; /* Code word table */ in huffext()
411 hd = jd->huffdata[id][cls]; /* Data table */ in huffext()
420 jd->dbit = wbit - bl; /* Snip the huffman code */ in huffext()
440 JDEC * jd, /* Pointer to the decompressor object */ in bitext() argument
444 size_t dc = jd->dctr; in bitext()
445 uint8_t * dp = jd->dptr; in bitext()
449 uint8_t mbit = jd->dbit; in bitext()
455 dp = jd->inbuf; /* Top of input buffer */ in bitext()
456 dc = jd->infunc(jd, dp, JD_SZBUF); in bitext()
482 jd->dbit = mbit; in bitext()
483 jd->dctr = dc; in bitext()
484 jd->dptr = dp; in bitext()
488 unsigned int wbit = jd->dbit % 32; in bitext()
489 uint32_t w = jd->wreg & ((1UL << wbit) - 1); in bitext()
493 if(jd->marker) { in bitext()
498 dp = jd->inbuf; /* Top of input buffer */ in bitext()
499 dc = jd->infunc(jd, dp, JD_SZBUF); in bitext()
506 if(d != 0) jd->marker = d; /* Not an escape of 0xFF but a marker */ in bitext()
519 jd->wreg = w; in bitext()
520 jd->dbit = wbit - nbit; in bitext()
521 jd->dctr = dc; in bitext()
522 jd->dptr = dp; in bitext()
536 JDEC * jd, /* Pointer to the decompressor object */ in jd_restart() argument
541 uint8_t * dp = jd->dptr; in jd_restart()
542 size_t dc = jd->dctr; in jd_restart()
550 dp = jd->inbuf; in jd_restart()
551 dc = jd->infunc(jd, dp, JD_SZBUF); in jd_restart()
560 jd->dptr = dp; in jd_restart()
561 jd->dctr = dc; in jd_restart()
562 jd->dbit = 0; in jd_restart()
573 if(jd->marker) { /* Generate a maker if it has been detected */ in jd_restart()
574 marker = 0xFF00 | jd->marker; in jd_restart()
575 jd->marker = 0; in jd_restart()
581 dp = jd->inbuf; in jd_restart()
582 dc = jd->infunc(jd, dp, JD_SZBUF); in jd_restart()
588 jd->dptr = dp; in jd_restart()
589 jd->dctr = dc; in jd_restart()
597 jd->dbit = 0; /* Discard stuff bits */ in jd_restart()
600 jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Reset DC offset */ in jd_restart()
737 JDEC * jd /* Pointer to the decompressor object */ in jd_mcu_load() argument
740 int32_t * tmp = (int32_t *)jd->workbuf; /* Block working buffer for de-quantize and IDCT */ in jd_mcu_load()
747 nby = jd->msx * jd->msy; /* Number of Y blocks (1, 2 or 4) */ in jd_mcu_load()
748 bp = jd->mcubuf; /* Pointer to the first block of MCU */ in jd_mcu_load()
753 if(cmp && jd->ncomp != 3) { /* Clear C blocks if not exist (monochrome image) */ in jd_mcu_load()
761 d = huffext(jd, id, 0); /* Extract a huffman coded data (bit length) */ in jd_mcu_load()
764 d = jd->dcv[cmp]; /* DC value of previous block */ in jd_mcu_load()
766 e = bitext(jd, bc); /* Extract data bits */ in jd_mcu_load()
771 jd->dcv[cmp] = (int16_t)d; /* Save current DC value for next block */ in jd_mcu_load()
773 dqf = jd->qttbl[jd->qtid[cmp]]; /* De-quantizer table ID for this component */ in jd_mcu_load()
780 … d = huffext(jd, id, 1); /* Extract a huffman coded value (zero runs and bit length) */ in jd_mcu_load()
787 d = bitext(jd, bc); /* Extract data bits */ in jd_mcu_load()
798 jd->scale == in jd_mcu_load()
828 JDEC * jd, /* Pointer to the decompressor object */ in jd_mcu_output() argument
842 mx = jd->msx * 8; in jd_mcu_output()
843 my = jd->msy * 8; /* MCU size (pixel) */ in jd_mcu_output()
844 rx = (x + mx <= jd->width) ? mx : jd->width - in jd_mcu_output()
846 ry = (y + my <= jd->height) ? my : jd->height - y; in jd_mcu_output()
848 rx >>= jd->scale; in jd_mcu_output()
849 ry >>= jd->scale; in jd_mcu_output()
851 x >>= jd->scale; in jd_mcu_output()
852 y >>= jd->scale; in jd_mcu_output()
860 if(!JD_USE_SCALE || jd->scale != 3) { /* Not for 1/8 scaling */ in jd_mcu_output()
861 pix = (uint8_t *)jd->workbuf; in jd_mcu_output()
865 pc = py = jd->mcubuf; in jd_mcu_output()
894 mx >>= jd->scale; in jd_mcu_output()
899 s = d = (uint8_t *)jd->workbuf; in jd_mcu_output()
914 uint8_t * s = (uint8_t *)jd->workbuf; in jd_mcu_output()
927 if(outfunc) return outfunc(jd, jd->workbuf, &rect) ? JDR_OK : JDR_INTR; in jd_mcu_output()
942 JDEC * jd, /* Blank decompressor object */ in jd_prepare() argument
956 memset(jd, 0, sizeof( in jd_prepare()
958 jd->pool = pool; /* Work memory */ in jd_prepare()
959 jd->pool_original = pool; in jd_prepare()
960 jd->sz_pool = sz_pool; /* Size of given work memory */ in jd_prepare()
961 jd->infunc = infunc; /* Stream input function */ in jd_prepare()
962 jd->device = dev; /* I/O device identifier */ in jd_prepare()
964 jd->inbuf = seg = alloc_pool(jd, JD_SZBUF); /* Allocate stream input buffer */ in jd_prepare()
969 if(jd->infunc(jd, seg, 1) != 1) return JDR_INP; /* Err: SOI was not detected */ in jd_prepare()
976 if(jd->infunc(jd, seg, 4) != 4) return JDR_INP; in jd_prepare()
986 if(jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ in jd_prepare()
988 jd->width = LDB_WORD(&seg[3]); /* Image width in unit of pixel */ in jd_prepare()
989 jd->height = LDB_WORD(&seg[1]); /* Image height in unit of pixel */ in jd_prepare()
990 jd->ncomp = seg[5]; /* Number of color components */ in jd_prepare()
991 …if(jd->ncomp != 3 && jd->ncomp != 1) return JDR_FMT3; /* Err: Supports only Grayscale and Y/Cb/C… in jd_prepare()
994 for(i = 0; i < jd->ncomp; i++) { in jd_prepare()
1000 jd->msx = b >> 4; in jd_prepare()
1001 jd->msy = b & 15; /* Size of MCU [blocks] */ in jd_prepare()
1006jd->qtid[i] = seg[8 + 3 * i]; /* Get dequantizer table ID for this component */ in jd_prepare()
1007 if(jd->qtid[i] > 3) return JDR_FMT3; /* Err: Invalid ID */ in jd_prepare()
1013 if(jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ in jd_prepare()
1015 jd->nrst = LDB_WORD(seg); /* Get restart interval (MCUs) */ in jd_prepare()
1020 if(jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ in jd_prepare()
1022 rc = create_huffman_tbl(jd, seg, len); /* Create huffman tables */ in jd_prepare()
1028 if(jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ in jd_prepare()
1030 rc = create_qt_tbl(jd, seg, len); /* Create de-quantizer tables */ in jd_prepare()
1036 if(jd->infunc(jd, seg, len) != len) return JDR_INP; /* Load segment data */ in jd_prepare()
1038 if(!jd->width || !jd->height) return JDR_FMT1; /* Err: Invalid image size */ in jd_prepare()
1039 if(seg[0] != jd->ncomp) return JDR_FMT3; /* Err: Wrong color components */ in jd_prepare()
1042 for(i = 0; i < jd->ncomp; i++) { in jd_prepare()
1046 … if(!jd->huffbits[n][0] || !jd->huffbits[n][1]) { /* Check huffman table for this component */ in jd_prepare()
1049 … if(!jd->qttbl[jd->qtid[i]]) { /* Check dequantizer table for this component */ in jd_prepare()
1055 n = jd->msy * jd->msx; /* Number of Y blocks in the MCU */ in jd_prepare()
1059 jd->workbuf = alloc_pool(jd, in jd_prepare()
1061 if(!jd->workbuf) return JDR_MEM1; /* Err: not enough memory */ in jd_prepare()
1062jd->mcubuf = alloc_pool(jd, (n + 2) * 64 * sizeof(jd_yuv_t)); /* Allocate MCU working buffer */ in jd_prepare()
1063 if(!jd->mcubuf) return JDR_MEM1; /* Err: not enough memory */ in jd_prepare()
1067 jd->dctr = jd->infunc(jd, seg + ofs, (size_t)(JD_SZBUF - ofs)); in jd_prepare()
1069 jd->dptr = seg + ofs - (JD_FASTDECODE ? 0 : 1); in jd_prepare()
1090 if(jd->infunc(jd, 0, len) != len) return JDR_INP; in jd_prepare()
1103 JDEC * jd, /* Initialized decompression object */ in jd_decomp() argument
1114 jd->scale = scale; in jd_decomp()
1116 mx = jd->msx * 8; in jd_decomp()
1117 my = jd->msy * 8; /* Size of the MCU (pixel) */ in jd_decomp()
1119 jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */ in jd_decomp()
1123 for(y = 0; y < jd->height; y += my) { /* Vertical loop of MCUs */ in jd_decomp()
1124 for(x = 0; x < jd->width; x += mx) { /* Horizontal loop of MCUs */ in jd_decomp()
1125 if(jd->nrst && rst++ == jd->nrst) { /* Process restart interval if enabled */ in jd_decomp()
1126 rc = jd_restart(jd, rsc++); in jd_decomp()
1130 …rc = jd_mcu_load(jd); /* Load an MCU (decompress huffman coded stream, dequantize… in jd_decomp()
1132 … rc = jd_mcu_output(jd, outfunc, x, y); /* Output the MCU (YCbCr to RGB, scaling and output) */ in jd_decomp()