]> git.sesse.net Git - qscale/commitdiff
Store the sampling factors explicitly in the struct, to make saving simpler.
authorsgunderson@bigfoot.com <>
Thu, 29 May 2008 05:24:49 +0000 (22:24 -0700)
committersgunderson@bigfoot.com <>
Thu, 29 May 2008 05:24:49 +0000 (22:24 -0700)
libqscale.c
libqscale.h

index fa7f2c3f8018c7329632a884eadb9699cc03866c..538dd80079ce340915b47ba1cd4351b79e7020ba 100644 (file)
@@ -74,6 +74,15 @@ qscale_img *qscale_load_jpeg_from_stdio(FILE *file)
        img->w2 = dinfo.image_width * dinfo.comp_info[2].h_samp_factor / dinfo.max_h_samp_factor;
        img->h2 = dinfo.image_height * dinfo.comp_info[2].v_samp_factor / dinfo.max_v_samp_factor;
 
+       img->samp_h0 = dinfo.comp_info[0].h_samp_factor;
+       img->samp_v0 = dinfo.comp_info[0].v_samp_factor;
+
+       img->samp_h1 = dinfo.comp_info[1].h_samp_factor;
+       img->samp_v1 = dinfo.comp_info[1].v_samp_factor;
+
+       img->samp_h2 = dinfo.comp_info[2].h_samp_factor;
+       img->samp_v2 = dinfo.comp_info[2].v_samp_factor;
+
        img->data_y  = (JSAMPLE*)memalign(16, dinfo.comp_info[0].height_in_blocks * dinfo.comp_info[0].width_in_blocks * DCTSIZE * DCTSIZE);
        img->data_cb = (JSAMPLE*)memalign(16, dinfo.comp_info[1].height_in_blocks * dinfo.comp_info[1].width_in_blocks * DCTSIZE * DCTSIZE);
        img->data_cr = (JSAMPLE*)memalign(16, dinfo.comp_info[2].height_in_blocks * dinfo.comp_info[2].width_in_blocks * DCTSIZE * DCTSIZE);
@@ -484,6 +493,15 @@ qscale_img *qscale_scale(qscale_img *src, unsigned width, unsigned height, unsig
        dst->w2 = width * samp_h2 / max_samp_h;
        dst->h2 = height * samp_v2 / max_samp_v;
 
+       dst->samp_h0 = samp_h0;
+       dst->samp_v0 = samp_v0;
+
+       dst->samp_h1 = samp_h1;
+       dst->samp_v1 = samp_v1;
+
+       dst->samp_h2 = samp_h2;
+       dst->samp_v2 = samp_v2;
+
        unsigned dstride0 = (dst->w0 + DCTSIZE-1) & ~(DCTSIZE-1);
        unsigned dstride1 = (dst->w1 + DCTSIZE-1) & ~(DCTSIZE-1);
        unsigned dstride2 = (dst->w2 + DCTSIZE-1) & ~(DCTSIZE-1);
index f9853c6ab232bf431ed9458912332c0ac59cc81f..2f40099cd469ad378fa8fabe8f243d9ed097838e 100644 (file)
@@ -13,6 +13,11 @@ typedef struct {
        unsigned w1, h1;
        unsigned w2, h2;
 
+       /* Sampling factors */
+       unsigned samp_h0, samp_v0;
+       unsigned samp_h1, samp_v1;
+       unsigned samp_h2, samp_v2;
+
        /* The data itself */
        JSAMPLE *data_y, *data_cb, *data_cr;
 } qscale_img;