95
86
//----------------------------------------------------------
96
// INPUT HANDLER FROM MEMORY
87
// INPUT HANDLER FROM MEMORY
97
88
//----------------------------------------------------------
100
unsigned char *buffer;
91
unsigned char *buffer;
105
struct jpeg_source_mgr pub; /* public fields */
96
struct jpeg_source_mgr pub; /* public fields */
107
98
unsigned char *buffer;
152
143
if (cinfo->src == NULL)
153
{ /* first time for this JPEG object? */
144
{ /* first time for this JPEG object? */
154
145
cinfo->src = (struct jpeg_source_mgr *)(*cinfo->mem->alloc_small)
155
((j_common_ptr) cinfo, JPOOL_PERMANENT,
156
sizeof(my_source_mgr));
146
((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(my_source_mgr));
159
149
src = (my_src_ptr) cinfo->src;
160
src->pub.init_source = init_source;
161
src->pub.fill_input_buffer = fill_input_buffer;
162
src->pub.skip_input_data = skip_input_data;
163
src->pub.resync_to_restart = jpeg_resync_to_restart;
164
src->pub.term_source = term_source;
150
src->pub.init_source = init_source;
151
src->pub.fill_input_buffer = fill_input_buffer;
152
src->pub.skip_input_data = skip_input_data;
153
src->pub.resync_to_restart = jpeg_resync_to_restart;
154
src->pub.term_source = term_source;
166
src->pub.bytes_in_buffer = size;
167
src->pub.next_input_byte = buffer;
156
src->pub.bytes_in_buffer = size;
157
src->pub.next_input_byte = buffer;
169
159
src->buffer = buffer;
170
160
src->size = size;
174
#define MAKESTMT(stuff) do { stuff } while (0)
164
#define MAKESTMT(stuff) do { stuff } while (0)
176
166
#define INPUT_VARS(cinfo) \
177
167
struct jpeg_source_mgr * datasrc = (cinfo)->src; \
359
if ((infile = fopen(filename, "rb")) == NULL) {
360
/*fprintf(stderr, "can't open %s\n", filename);*/
349
if ((infile = fopen(filename, "rb")) == NULL) return 0;
364
351
cinfo->err = jpeg_std_error(&jerr);
365
352
jerr.error_exit = jpeg_error;
499
486
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
500
487
struct jpeg_error_mgr jerr;
502
if ((outfile = fopen(name, "wb")) == NULL) return(-1);
489
if ((outfile = fopen(name, "wb")) == NULL) return 0;
503
490
jpeg_default_quality = 75;
505
492
cinfo->err = jpeg_std_error(&jerr);
523
513
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
524
514
struct jpeg_error_mgr jerr;
526
if ((outfile = fopen(name, "wb")) == NULL) return(-1);
516
if ((outfile = fopen(name, "wb")) == NULL) return 0;
527
517
jpeg_default_quality = 90;
529
519
cinfo->err = jpeg_std_error(&jerr);
543
533
jpeg_destroy_compress(cinfo);
545
if (jpeg_failed) remove(name);
549
542
static int save_jstjpeg(char * name, struct ImBuf * ibuf)
551
544
char fieldname[1024];
552
545
struct ImBuf * tbuf;
554
/* extern rectcpy(); */
556
548
tbuf = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 24, IB_rect, 0);
557
549
tbuf->ftype = ibuf->ftype;
564
556
/* extra argument assumed to be 0 (nzc) */
565
/* rectop(tbuf, ibuf, 0, 0, 0, 0, 32767, 32767, rectcpy); */
566
557
IMB_rectop(tbuf, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
567
558
sprintf(fieldname, "%s.jf0", name);
569
if (save_vidjpeg(fieldname, tbuf) == 0) {
570
/* extra argument assumed to be 0 (nzc) */
571
/* rectop(tbuf, ibuf, 0, 0, tbuf->x, 0, 32767, 32767, rectcpy); */
572
IMB_rectop(tbuf, ibuf, 0, 0, tbuf->x, 0, 32767, 32767, IMB_rectcpy, 0);
560
returnval = save_vidjpeg(fieldname, tbuf) ;
561
if (returnval == 1) {
562
/* extra argument assumed to be 0 (nzc) */
563
IMB_rectop(tbuf, ibuf, 0, 0, tbuf->x, 0, 32767, 32767,
573
565
sprintf(fieldname, "%s.jf1", name);
574
save_vidjpeg(fieldname, tbuf);
566
returnval = save_vidjpeg(fieldname, tbuf);
579
571
IMB_freeImBuf(tbuf);
581
/* no return value was given, assuming 0 */
586
576
static int save_maxjpeg(char * name, struct ImBuf * ibuf)
589
579
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
590
580
struct jpeg_error_mgr jerr;
592
if ((outfile = fopen(name, "wb")) == NULL) return(-1);
582
if ((outfile = fopen(name, "wb")) == NULL) return 0;
593
583
jpeg_default_quality = 100;
595
585
cinfo->err = jpeg_std_error(&jerr);