Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Tiny JPEG Decompressor in C: Increase the descaling factor

chandlerbing65nm

Member level 4
Joined
Apr 5, 2018
Messages
76
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
679
Hello folks,

I am using this Tiny JPEG Decompressor for my embedded project in STM32F4. I realized that I needed my images to be further descaled down but the Tiny JPEG Decompressor only supports (1/2)^N (N = 0 to 3) descaling.

I've looked into its C source code but not sure where to edit it such that I can increase the descaling factor to N=4 and N=5.

This is the part where descaling takes place:
C:
/*-----------------------------------------------------------------------*/
/* Start to decompress the JPEG picture                                  */
/*-----------------------------------------------------------------------*/

JRESULT jd_decomp (
    JDEC* jd,                                /* Initialized decompression object */
    uint16_t (*outfunc)(JDEC*, void*, JRECT*),    /* RGB output function */
    uint8_t scale                            /* Output de-scaling factor (0 to 3) */
)
{
    uint16_t x, y, mx, my;
    uint16_t rst, rsc;
    JRESULT rc;


    if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR;
    jd->scale = scale;

    mx = jd->msx * 8; my = jd->msy * 8;            /* Size of the MCU (pixel) */

    jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0;    /* Initialize DC values */
    rst = rsc = 0;

    rc = JDR_OK;
    for (y = 0; y < jd->height; y += my) {        /* Vertical loop of MCUs */
        for (x = 0; x < jd->width; x += mx) {    /* Horizontal loop of MCUs */
            if (jd->nrst && rst++ == jd->nrst) {    /* Process restart interval if enabled */
                rc = restart(jd, rsc++);
                if (rc != JDR_OK) return rc;
                rst = 1;
            }
            rc = mcu_load(jd);                    /* Load an MCU (decompress huffman coded stream and apply IDCT) */
            if (rc != JDR_OK) return rc;
            rc = mcu_output(jd, outfunc, x, y);    /* Output the MCU (color space conversion, scaling and output) */
            if (rc != JDR_OK) return rc;
        }
    }

    return rc;
}

The C file can also be downloadable here: JPEG Decompressor Source Code

If someone can help, I'm very much thankful.

Regards,
Tim
 

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top