From: sgunderson@bigfoot.com <> Date: Thu, 29 May 2008 05:24:49 +0000 (-0700) Subject: Store the sampling factors explicitly in the struct, to make saving simpler. X-Git-Url: https://git.sesse.net/?p=qscale;a=commitdiff_plain;h=159a760e8c7f812bfb428fd90d660f19d3d710e8 Store the sampling factors explicitly in the struct, to make saving simpler. --- diff --git a/libqscale.c b/libqscale.c index fa7f2c3..538dd80 100644 --- a/libqscale.c +++ b/libqscale.c @@ -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); diff --git a/libqscale.h b/libqscale.h index f9853c6..2f40099 100644 --- a/libqscale.h +++ b/libqscale.h @@ -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;