Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

jdatadst.c File Reference

#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"

Go to the source code of this file.


Data Structures

struct  my_destination_mgr

Defines

#define OUTPUT_BUF_SIZE   4096

Typedefs

typedef my_destination_mgrmy_dest_ptr

Functions

 init_destination (j_compress_ptr cinfo)
 empty_output_buffer (j_compress_ptr cinfo)
 term_destination (j_compress_ptr cinfo)
 jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)

Define Documentation

#define OUTPUT_BUF_SIZE   4096
 

Definition at line 34 of file jdatadst.c.

Referenced by empty_output_buffer(), init_destination(), and term_destination().


Typedef Documentation

typedef my_destination_mgr* my_dest_ptr
 

Definition at line 32 of file jdatadst.c.


Function Documentation

empty_output_buffer j_compress_ptr    cinfo
 

Definition at line 81 of file jdatadst.c.

References my_destination_mgr::buffer, jpeg_compress_struct::dest, ERREXIT, jpeg_destination_mgr::free_in_buffer, JFWRITE, jpeg_destination_mgr::next_output_byte, my_destination_mgr::outfile, OUTPUT_BUF_SIZE, and my_destination_mgr::pub.

Referenced by jpeg_stdio_dest().

00082 {
00083   my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
00084 
00085   if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
00086       (size_t) OUTPUT_BUF_SIZE)
00087     ERREXIT(cinfo, JERR_FILE_WRITE);
00088 
00089   dest->pub.next_output_byte = dest->buffer;
00090   dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
00091 
00092   return TRUE;
00093 }

init_destination j_compress_ptr    cinfo
 

Definition at line 43 of file jdatadst.c.

References my_destination_mgr::buffer, jpeg_compress_struct::dest, jpeg_destination_mgr::free_in_buffer, JOCTET, JPOOL_IMAGE, jpeg_destination_mgr::next_output_byte, OUTPUT_BUF_SIZE, my_destination_mgr::pub, and SIZEOF.

Referenced by jpeg_stdio_dest().

00044 {
00045   my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
00046 
00047   /* Allocate the output buffer --- it will be released when done with image */
00048   dest->buffer = (JOCTET *)
00049       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00050                                   OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
00051 
00052   dest->pub.next_output_byte = dest->buffer;
00053   dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
00054 }

jpeg_stdio_dest j_compress_ptr    cinfo,
FILE *    outfile
 

Definition at line 130 of file jdatadst.c.

References jpeg_compress_struct::dest, empty_output_buffer(), init_destination(), my_destination_mgr::outfile, my_destination_mgr::pub, and term_destination().

Referenced by main(), and write_JPEG_file().

00131 {
00132   my_dest_ptr dest;
00133 
00134   /* The destination object is made permanent so that multiple JPEG images
00135    * can be written to the same file without re-executing jpeg_stdio_dest.
00136    * This makes it dangerous to use this manager and a different destination
00137    * manager serially with the same JPEG object, because their private object
00138    * sizes may be different.  Caveat programmer.
00139    */
00140   if (cinfo->dest == NULL) {    /* first time for this JPEG object? */
00141     cinfo->dest = (struct jpeg_destination_mgr *)
00142       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
00143                                   SIZEOF(my_destination_mgr));
00144   }
00145 
00146   dest = (my_dest_ptr) cinfo->dest;
00147   dest->pub.init_destination = init_destination;
00148   dest->pub.empty_output_buffer = empty_output_buffer;
00149   dest->pub.term_destination = term_destination;
00150   dest->outfile = outfile;
00151 }

term_destination j_compress_ptr    cinfo
 

Definition at line 106 of file jdatadst.c.

References my_destination_mgr::buffer, jpeg_compress_struct::dest, ERREXIT, jpeg_destination_mgr::free_in_buffer, JFWRITE, my_destination_mgr::outfile, OUTPUT_BUF_SIZE, and my_destination_mgr::pub.

Referenced by jpeg_stdio_dest().

00107 {
00108   my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
00109   size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
00110 
00111   /* Write any data remaining in the buffer */
00112   if (datacount > 0) {
00113     if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
00114       ERREXIT(cinfo, JERR_FILE_WRITE);
00115   }
00116   fflush(dest->outfile);
00117   /* Make sure we wrote the output file OK */
00118   if (ferror(dest->outfile))
00119     ERREXIT(cinfo, JERR_FILE_WRITE);
00120 }
 

Powered by Plone

This site conforms to the following standards: