"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/jdatasrc.c" (9 Jan 2007, 1841 Bytes) of package /linux/privat/old/quicktime4linux-2.3-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include "jpeglib.h"
    4 #include "jerror.h"
    5 
    6 typedef struct {
    7     struct jpeg_source_mgr pub; /* public fields */
    8 
    9     JOCTET * buffer;        /* start of buffer */
   10     int bytes;             /* total size of buffer */
   11 } my_source_mgr;
   12 
   13 typedef my_source_mgr * my_src_ptr;
   14 
   15 METHODDEF(void)
   16 quicktime_jpeg_init_source (j_decompress_ptr cinfo)
   17 {
   18   my_src_ptr src = (my_src_ptr) cinfo->src;
   19 }
   20 
   21 METHODDEF(boolean)
   22 quicktime_jpeg_fill_input_buffer (j_decompress_ptr cinfo)
   23 {
   24   my_src_ptr src = (my_src_ptr) cinfo->src;
   25 
   26   src->buffer[0] = (JOCTET) 0xFF;
   27   src->buffer[1] = (JOCTET) JPEG_EOI;
   28   src->pub.next_input_byte = src->buffer;
   29   src->pub.bytes_in_buffer = 2;
   30 
   31   return TRUE;
   32 }
   33 
   34 
   35 METHODDEF(void)
   36 quicktime_jpeg_skip_input_data (j_decompress_ptr cinfo, long num_bytes)
   37 {
   38     my_src_ptr src = (my_src_ptr) cinfo->src;
   39 
   40     src->pub.next_input_byte += (size_t) num_bytes;
   41     src->pub.bytes_in_buffer -= (size_t) num_bytes;
   42 }
   43 
   44 
   45 METHODDEF(void)
   46 quicktime_jpeg_term_source (j_decompress_ptr cinfo)
   47 {
   48 }
   49 
   50 GLOBAL(void)
   51 jpeg_buffer_src (j_decompress_ptr cinfo, unsigned char *buffer, long bytes)
   52 {
   53   my_src_ptr src;
   54 
   55   if (cinfo->src == NULL) { /* first time for this JPEG object? */
   56     cinfo->src = (struct jpeg_source_mgr *)
   57       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
   58                   sizeof(my_source_mgr));
   59     src = (my_src_ptr) cinfo->src;
   60   }
   61 
   62   src = (my_src_ptr) cinfo->src;
   63   src->pub.init_source = quicktime_jpeg_init_source;
   64   src->pub.fill_input_buffer = quicktime_jpeg_fill_input_buffer;
   65   src->pub.skip_input_data = quicktime_jpeg_skip_input_data;
   66   src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
   67   src->pub.term_source = quicktime_jpeg_term_source;
   68   src->pub.bytes_in_buffer = bytes;
   69   src->pub.next_input_byte = buffer;
   70   src->buffer = buffer;
   71   src->bytes = bytes;
   72 }