summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2010-04-09 11:46:38 +0000
committerHans de Goede <hdegoede@redhat.com>2010-04-09 11:46:38 +0000
commit4cdacdf94515b374908f3371864ad6d31ba95691 (patch)
tree6fe2f102886402a6602282bc204d9a5b2465a381
parentfaf22a9d68582d3ddf56ab5a5de87505c8f10203 (diff)
downloadlibgphoto2-4cdacdf94515b374908f3371864ad6d31ba95691.tar.gz
Move jpeg compression parameters to CameraPrivateLibrary
This is a preperation patch for adding storageinfo support. git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_4/libgphoto2@12930 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--camlibs/ax203/ax203.c12
-rw-r--r--camlibs/ax203/ax203.h5
-rw-r--r--camlibs/ax203/ax203_compress_jpeg.c23
3 files changed, 24 insertions, 16 deletions
diff --git a/camlibs/ax203/ax203.c b/camlibs/ax203/ax203.c
index 8ba329ecf..236f0006c 100644
--- a/camlibs/ax203/ax203.c
+++ b/camlibs/ax203/ax203.c
@@ -595,6 +595,15 @@ static int ax203_read_parameter_block(Camera *camera)
camera->pl->width, camera->pl->height,
camera->pl->compression_version, camera->pl->fs_start);
+ /* Set JPEG compression parameters based on the found resolution */
+ camera->pl->jpeg_optimize = 1;
+ if (camera->pl->width % 16 || camera->pl->height % 16) {
+ gp_log (GP_LOG_DEBUG, "ax203", "height or width not a "
+ "multiple of 16, forcing 1x subsampling");
+ camera->pl->jpeg_uv_subsample = 1;
+ } else
+ camera->pl->jpeg_uv_subsample = 2;
+
return GP_OK;
}
@@ -958,7 +967,8 @@ ax203_encode_image(Camera *camera, int **src, char *dest, int dest_size)
camera->pl->height);
return size;
case AX203_COMPRESSION_JPEG:
- return ax203_compress_jpeg (src, (uint8_t *)dest, dest_size,
+ return ax203_compress_jpeg (camera, src,
+ (uint8_t *)dest, dest_size,
camera->pl->width,
camera->pl->height);
}
diff --git a/camlibs/ax203/ax203.h b/camlibs/ax203/ax203.h
index 8fbddc593..9ed0dd696 100644
--- a/camlibs/ax203/ax203.h
+++ b/camlibs/ax203/ax203.h
@@ -90,6 +90,9 @@ struct _CameraPrivateLibrary {
/* EEPROM attributes */
int mem_size;
int has_4k_sectors;
+ /* Compression configuration settings */
+ int jpeg_uv_subsample;
+ int jpeg_optimize;
/* Driver configuration settings */
int syncdatetime;
};
@@ -164,7 +167,7 @@ void
ax203_encode_yuv_delta(int **src, char *dest, int width, int height);
int
-ax203_compress_jpeg(int **in, uint8_t *outbuf, int out_size,
+ax203_compress_jpeg(Camera *camera, int **in, uint8_t *outbuf, int out_size,
int width, int height);
#endif
diff --git a/camlibs/ax203/ax203_compress_jpeg.c b/camlibs/ax203/ax203_compress_jpeg.c
index 88e312a2d..2d5fcdc18 100644
--- a/camlibs/ax203/ax203_compress_jpeg.c
+++ b/camlibs/ax203/ax203_compress_jpeg.c
@@ -108,7 +108,7 @@ add_mcu_info(uint8_t *outbuf, int block_nr, int last_Y, int last_Cb,
}
int
-ax203_compress_jpeg(int **in, uint8_t *outbuf, int out_size,
+ax203_compress_jpeg(Camera *camera, int **in, uint8_t *outbuf, int out_size,
int width, int height)
{
struct jpeg_compress_struct cinfo;
@@ -121,21 +121,16 @@ ax203_compress_jpeg(int **in, uint8_t *outbuf, int out_size,
unsigned long regular_jpeg_size = 0, buf_size = 0;
int last_dc_val[3] = { 0, 0, 0 };
/* Compression configuration settings */
- int uv_subsample = 2;
- int optimize = TRUE;
+ int uv_subsample = camera->pl->jpeg_uv_subsample;
+ int optimize = camera->pl->jpeg_optimize;
- if (width % 8 || height % 8) {
+ i = 8 * uv_subsample;
+ if (width % i || height % i) {
gp_log (GP_LOG_ERROR, "ax203",
- "height and width must be a multiple of 8");
+ "height and width must be a multiple of %d", i);
return GP_ERROR_BAD_PARAMETERS;
}
- if (width % 16 || height % 16) {
- gp_log (GP_LOG_DEBUG, "ax203", "height or width not a "
- "multiple of 8, forcing 1x subsampling");
- uv_subsample = 1;
- }
-
/* We have a rgb24bit image in the desired dimensions, first we
compress it into a regular jpeg, which we use as a base for
creating the ax203 JPEG-ish format */
@@ -274,10 +269,10 @@ ax203_compress_jpeg(int **in, uint8_t *outbuf, int out_size,
uv_subsample, 0);
for (x = 0; x < width / (8 * uv_subsample); x++) {
- /* (Re)init our destination buffer */
- jpeg_mem_dest (&cinfo, &buf, &buf_size);
+ /* (Re)init our destination buffer */
+ jpeg_mem_dest (&cinfo, &buf, &buf_size);
- /* Add MCU info block to output */
+ /* Add MCU info block to output */
add_mcu_info (outbuf,
y * width / (8 * uv_subsample) + x,
last_dc_val[2], last_dc_val[0],