2004-04-06 Lutz Mueller <lutz@users.sourceforge.net>
* camtojpeg.[c,h] * jpegtab_f.h: New file submitted by Michael Haardt <michael@moria.de>. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@7167 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2004-04-06 Lutz Mueller <lutz@users.sourceforge.net>
|
||||
|
||||
* camtojpeg.[c,h]
|
||||
* jpegtab_f.h: New file submitted by Michael Haardt
|
||||
<michael@moria.de>.
|
||||
|
||||
2004-03-23 Lutz Mueller <lutz@users.sourceforge.net>
|
||||
|
||||
* casio-qv.c (camera_init): Patch by Michael Haardt
|
||||
|
||||
135
camlibs/casio/camtojpeg.c
Normal file
135
camlibs/casio/camtojpeg.c
Normal file
@@ -0,0 +1,135 @@
|
||||
/* camtojpeg.c
|
||||
*
|
||||
* Copyright (c) 2004 Michael Haardt
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gphoto2-library.h>
|
||||
|
||||
#include "cam2jpgtab.h"
|
||||
#include "jpegtab_f.h"
|
||||
#include "camtojpeg.h"
|
||||
|
||||
static unsigned int u16(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned int)(*buf)<<8) | ((unsigned int)*(buf+1));
|
||||
}
|
||||
|
||||
static unsigned int u32(const unsigned char *buf)
|
||||
{
|
||||
return ((unsigned int)(*buf)<<24) | ((unsigned int)*(buf+1)<<16)
|
||||
|((unsigned int)*(buf+2)<<8) | ((unsigned int)*(buf+3));
|
||||
}
|
||||
|
||||
int QVcamtojpeg(const unsigned char *cam, long int camSize, unsigned char **jpeg, long int *jpegSize)
|
||||
{
|
||||
int areaNum;
|
||||
int ysize;
|
||||
int usize;
|
||||
int vsize;
|
||||
unsigned char *dst;
|
||||
|
||||
areaNum = u16(cam); /* areaNum == 0x03 */
|
||||
ysize = u16(cam + 2);
|
||||
usize = u16(cam + 4);
|
||||
vsize = u16(cam + 6);
|
||||
|
||||
*jpeg=malloc(*jpegSize=
|
||||
(
|
||||
sizeof(soi)+sizeof(app0)
|
||||
+sizeof(dqt0)+64
|
||||
+sizeof(dqt1)+64
|
||||
+sizeof(sof)+sizeof(dht)
|
||||
+sizeof(sos_y)+ysize
|
||||
+sizeof(sos_u)+usize
|
||||
+sizeof(sos_v)+vsize
|
||||
+sizeof(eoi)
|
||||
));
|
||||
|
||||
dst=*jpeg;
|
||||
memcpy(dst,soi,sizeof(soi)); dst+=sizeof(soi);
|
||||
memcpy(dst,app0,sizeof(app0)); dst+=sizeof(app0);
|
||||
|
||||
cam+=8;
|
||||
|
||||
memcpy(dst,dqt0,sizeof(dqt0)); dst+=sizeof(dqt0);
|
||||
memcpy(dst,cam,64); dst+=64; cam+=64;
|
||||
|
||||
memcpy(dst,dqt1,sizeof(dqt1)); dst+=sizeof(dqt1);
|
||||
memcpy(dst,cam,64); dst+=64; cam+=64;
|
||||
|
||||
memcpy(dst,sof,sizeof(sof)); dst+=sizeof(sof);
|
||||
memcpy(dst,dht,sizeof(dht)); dst+=sizeof(dht);
|
||||
|
||||
memcpy(dst,sos_y,sizeof(sos_y)); dst+=sizeof(sos_y);
|
||||
memcpy(dst,cam,ysize); dst+=ysize; cam+=ysize;
|
||||
|
||||
memcpy(dst,sos_u,sizeof(sos_u)); dst+=sizeof(sos_u);
|
||||
memcpy(dst,cam,usize); dst+=usize; cam+=usize;
|
||||
|
||||
memcpy(dst,sos_v,sizeof(sos_v)); dst+=sizeof(sos_v);
|
||||
memcpy(dst,cam,vsize); dst+=vsize; cam+=vsize;
|
||||
|
||||
memcpy(dst,eoi,sizeof(eoi));
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int QVfinecamtojpeg(const unsigned char *cam, long int camSize, unsigned char **jpeg, long int *jpegSize)
|
||||
{
|
||||
int size;
|
||||
static const unsigned char c[1] = { 1 };
|
||||
unsigned char *dst;
|
||||
|
||||
size = u32(cam + 4);
|
||||
|
||||
*jpeg=malloc(*jpegSize=
|
||||
(
|
||||
sizeof(soi)+sizeof(app_f)
|
||||
+sizeof(dqt_f)+64+1+64
|
||||
+sizeof(sof_f)+sizeof(dht_f)
|
||||
+sizeof(sos_f)+size
|
||||
+sizeof(eoi)
|
||||
));
|
||||
|
||||
dst=*jpeg;
|
||||
memcpy(dst,soi,sizeof(soi)); dst+=sizeof(soi);
|
||||
memcpy(dst,app_f,sizeof(app_f)); dst+=sizeof(app_f);
|
||||
|
||||
cam+=8;
|
||||
|
||||
memcpy(dst,dqt_f,sizeof(dqt_f)); dst+=sizeof(dqt_f);
|
||||
memcpy(dst,cam,64); dst+=64; cam+=64;
|
||||
|
||||
memcpy(dst,c,sizeof(c)); dst+=sizeof(c);
|
||||
memcpy(dst,cam,64); dst+=64; cam+=64;
|
||||
|
||||
memcpy(dst,sof_f,sizeof(sof_f)); dst+=sizeof(sof_f);
|
||||
memcpy(dst,dht_f,sizeof(dht_f)); dst+=sizeof(dht_f);
|
||||
|
||||
memcpy(dst,sos_f,sizeof(sos_f)); dst+=sizeof(sos_f);
|
||||
memcpy(dst,cam,size); dst+=size; cam+=size;
|
||||
|
||||
memcpy(dst,eoi,sizeof(eoi));
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
27
camlibs/casio/camtojpeg.h
Normal file
27
camlibs/casio/camtojpeg.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* camtojpeg.h
|
||||
*
|
||||
* Copyright (c) 2004 Michael Haardt
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CASIO_QV_CAMTOJPEG_H__
|
||||
#define __CASIO_QV_CAMTOJPEG_H__
|
||||
|
||||
int QVcamtojpeg(const unsigned char *cam, long int camSize, unsigned char **jpeg, long int *jpegSize);
|
||||
int QVfinecamtojpeg(const unsigned char *cam, long int camSize, unsigned char **jpeg, long int *jpegSize);
|
||||
|
||||
#endif
|
||||
105
camlibs/casio/jpegtab_f.h
Normal file
105
camlibs/casio/jpegtab_f.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
|
||||
This file is taken from qvplay version 0.95, written by:
|
||||
|
||||
Ken-ichi HAYASHI <xg2k-hys@asahi-net.or.jp>
|
||||
Jun-ichiro "itojun" Itoh <itojun@itojun.org>
|
||||
|
||||
Notes from qvplay:
|
||||
|
||||
You can use the entire source code of this archive in your software,
|
||||
but I assume no resuponsibilitiy for the results of the usage of the
|
||||
source code.
|
||||
Use at your own risk.
|
||||
|
||||
If you want to need some kind of 'license',
|
||||
you can choice 'BSD style license' or 'LGPL'.
|
||||
It is great presure you describe at README file of your software,
|
||||
"This software has QVplay's source code.".
|
||||
|
||||
*/
|
||||
|
||||
static u_char app_f[] ={
|
||||
0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46,
|
||||
0x00, 0x01, 0x01, 0x01, 0x01, 0x2c, 0x01, 0x2c,
|
||||
0x00, 0x00
|
||||
};
|
||||
|
||||
static u_char dqt_f[] ={
|
||||
0xff, 0xdb, 0x00, 0x84, 0x00
|
||||
};
|
||||
|
||||
static u_char sof_f[]={
|
||||
0xff, 0xc0, 0x00, 0x11, 0x08, 0x01, 0xe0, 0x02,
|
||||
0x80, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01,
|
||||
0x03, 0x11, 0x01
|
||||
};
|
||||
|
||||
static u_char dht_f[] ={
|
||||
0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x01, 0x05,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02,
|
||||
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
|
||||
0x0b, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||
0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x10, 0x00,
|
||||
0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05,
|
||||
0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01,
|
||||
0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21,
|
||||
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22,
|
||||
0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23,
|
||||
0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24,
|
||||
0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29,
|
||||
0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a,
|
||||
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
|
||||
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
|
||||
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||||
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
||||
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
|
||||
0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||||
0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
|
||||
0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
|
||||
0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5,
|
||||
0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3,
|
||||
0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1,
|
||||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
|
||||
0xfa, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04,
|
||||
0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01,
|
||||
0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04,
|
||||
0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07,
|
||||
0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14,
|
||||
0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
|
||||
0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16,
|
||||
0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
|
||||
0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36,
|
||||
0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
|
||||
0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56,
|
||||
0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
|
||||
0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76,
|
||||
0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85,
|
||||
0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
|
||||
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
|
||||
0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2,
|
||||
0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
|
||||
0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
|
||||
0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
|
||||
0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
|
||||
0xf7, 0xf8, 0xf9, 0xfa
|
||||
};
|
||||
|
||||
static u_char sos_f[] ={
|
||||
0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02,
|
||||
0x11, 0x03, 0x11, 0x00, 0x3f, 0x00
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user