libgphoto2 photo camera library (libgphoto2) Internals  2.5.23
jpeg.c File Reference
#include "config.h"
#include "jpeg.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gphoto2/gphoto2-file.h>

Go to the source code of this file.

Macros

#define nullpointerabort(pointer, name, val)   if (pointer==NULL) { printf(name " does not exist\n"); return val; }
 
#define nullpointerabortvoid(pointer, name)   if (pointer==NULL) { printf(name " does not exist\n"); return; }
 
#define CHECK_RESULT(result)   {int r = (result); if (r < 0) return (r);}
 
#define countof(array)   (sizeof(array) / sizeof((array)[0]))
 

Functions

chunkgpi_jpeg_chunk_new (int length)
 
chunkgpi_jpeg_chunk_new_filled (int length, char *data)
 
void gpi_jpeg_chunk_destroy (chunk *mychunk)
 
void gpi_jpeg_chunk_print (chunk *mychunk)
 
char gpi_jpeg_findff (int *location, chunk *picture)
 
char gpi_jpeg_findactivemarker (char *id, int *location, chunk *picture)
 
char * gpi_jpeg_markername (unsigned int c)
 
jpeggpi_jpeg_new ()
 
void gpi_jpeg_destroy (jpeg *myjpeg)
 
void gpi_jpeg_add_marker (jpeg *myjpeg, chunk *picture, int start, int end)
 
void gpi_jpeg_add_chunk (jpeg *myjpeg, chunk *source)
 
void gpi_jpeg_parse (jpeg *myjpeg, chunk *picture)
 
void gpi_jpeg_print (jpeg *myjpeg)
 
chunkgpi_jpeg_make_start ()
 
chunkgpi_jpeg_make_SOFC (int width, int height, char vh1, char vh2, char vh3, char q1, char q2, char q3)
 
chunkgpi_jpeg_makeSsSeAhAl (int huffset1, int huffset2, int huffset3)
 
void gpi_jpeg_print_quantization_table (jpeg_quantization_table *table)
 
chunkgpi_jpeg_make_quantization (const jpeg_quantization_table *table, char number)
 
jpeg_quantization_tablegpi_jpeg_quantization2table (chunk *qmarker)
 
jpeggpi_jpeg_header (int width, int height, char vh1, char vh2, char vh3, char q1, char q2, char q3, const jpeg_quantization_table *quant1, const jpeg_quantization_table *quant2, char huffset1, char huffset2, char huffset3, chunk *huff1, chunk *huff2, chunk *huff3, chunk *huff4)
 
char gpi_jpeg_write (CameraFile *file, const char *filename, jpeg *myjpeg)
 

Variables

const jpegmarker JPEG_MARKERS []
 
const char * JPEG_MARKERNAMES []
 

Detailed Description

Author
This code was written by Nathan Stenzel for gphoto
License
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file jpeg.c.

Macro Definition Documentation

◆ CHECK_RESULT

#define CHECK_RESULT (   result)    {int r = (result); if (r < 0) return (r);}

Definition at line 39 of file jpeg.c.

◆ countof

#define countof (   array)    (sizeof(array) / sizeof((array)[0]))

Definition at line 42 of file jpeg.c.

◆ nullpointerabort

#define nullpointerabort (   pointer,
  name,
  val 
)    if (pointer==NULL) { printf(name " does not exist\n"); return val; }

Definition at line 32 of file jpeg.c.

◆ nullpointerabortvoid

#define nullpointerabortvoid (   pointer,
  name 
)    if (pointer==NULL) { printf(name " does not exist\n"); return; }

Definition at line 36 of file jpeg.c.

Function Documentation

◆ gpi_jpeg_add_chunk()

void gpi_jpeg_add_chunk ( jpeg myjpeg,
chunk source 
)

Definition at line 178 of file jpeg.c.

References jpeg::count, jpeg::marker, and nullpointerabortvoid.

Referenced by gpi_jpeg_header().

◆ gpi_jpeg_add_marker()

void gpi_jpeg_add_marker ( jpeg myjpeg,
chunk picture,
int  start,
int  end 
)

◆ gpi_jpeg_chunk_destroy()

void gpi_jpeg_chunk_destroy ( chunk mychunk)

Definition at line 82 of file jpeg.c.

References chunk::data, nullpointerabortvoid, and chunk::size.

Referenced by gpi_jpeg_destroy().

◆ gpi_jpeg_chunk_new()

chunk* gpi_jpeg_chunk_new ( int  length)

◆ gpi_jpeg_chunk_new_filled()

chunk* gpi_jpeg_chunk_new_filled ( int  length,
char *  data 
)

Definition at line 70 of file jpeg.c.

References chunk::data, and gpi_jpeg_chunk_new().

Referenced by gpi_jpeg_make_start(), and gpi_jpeg_makeSsSeAhAl().

◆ gpi_jpeg_chunk_print()

void gpi_jpeg_chunk_print ( chunk mychunk)

Definition at line 91 of file jpeg.c.

References chunk::data, nullpointerabortvoid, and chunk::size.

Referenced by gpi_jpeg_add_marker(), and gpi_jpeg_print().

◆ gpi_jpeg_destroy()

void gpi_jpeg_destroy ( jpeg myjpeg)

Definition at line 154 of file jpeg.c.

References jpeg::count, gpi_jpeg_chunk_destroy(), and jpeg::marker.

◆ gpi_jpeg_findactivemarker()

char gpi_jpeg_findactivemarker ( char *  id,
int *  location,
chunk picture 
)

Definition at line 119 of file jpeg.c.

References chunk::data, gpi_jpeg_findff(), nullpointerabort, and chunk::size.

Referenced by gpi_jpeg_parse().

◆ gpi_jpeg_findff()

char gpi_jpeg_findff ( int *  location,
chunk picture 
)

Definition at line 101 of file jpeg.c.

References chunk::data, and nullpointerabort.

Referenced by gpi_jpeg_findactivemarker().

◆ gpi_jpeg_header()

jpeg* gpi_jpeg_header ( int  width,
int  height,
char  vh1,
char  vh2,
char  vh3,
char  q1,
char  q2,
char  q3,
const jpeg_quantization_table quant1,
const jpeg_quantization_table quant2,
char  huffset1,
char  huffset2,
char  huffset3,
chunk huff1,
chunk huff2,
chunk huff3,
chunk huff4 
)

◆ gpi_jpeg_make_quantization()

chunk* gpi_jpeg_make_quantization ( const jpeg_quantization_table table,
char  number 
)

Definition at line 294 of file jpeg.c.

References chunk::data, gpi_jpeg_chunk_new(), and number.

Referenced by gpi_jpeg_header().

◆ gpi_jpeg_make_SOFC()

chunk* gpi_jpeg_make_SOFC ( int  width,
int  height,
char  vh1,
char  vh2,
char  vh3,
char  q1,
char  q2,
char  q3 
)

Definition at line 241 of file jpeg.c.

References chunk::data, and gpi_jpeg_chunk_new().

Referenced by gpi_jpeg_header().

◆ gpi_jpeg_make_start()

chunk* gpi_jpeg_make_start ( )

Definition at line 231 of file jpeg.c.

References gpi_jpeg_chunk_new_filled().

Referenced by gpi_jpeg_header().

◆ gpi_jpeg_makeSsSeAhAl()

chunk* gpi_jpeg_makeSsSeAhAl ( int  huffset1,
int  huffset2,
int  huffset3 
)

Definition at line 265 of file jpeg.c.

References chunk::data, and gpi_jpeg_chunk_new_filled().

Referenced by gpi_jpeg_header().

◆ gpi_jpeg_markername()

char* gpi_jpeg_markername ( unsigned int  c)

Definition at line 131 of file jpeg.c.

References countof, JPEG_MARKERNAMES, and JPEG_MARKERS.

Referenced by gpi_jpeg_print().

◆ gpi_jpeg_new()

jpeg* gpi_jpeg_new ( )

Definition at line 146 of file jpeg.c.

References jpeg::count.

Referenced by gpi_jpeg_header().

◆ gpi_jpeg_parse()

void gpi_jpeg_parse ( jpeg myjpeg,
chunk picture 
)

◆ gpi_jpeg_print()

void gpi_jpeg_print ( jpeg myjpeg)

◆ gpi_jpeg_print_quantization_table()

void gpi_jpeg_print_quantization_table ( jpeg_quantization_table table)

Definition at line 278 of file jpeg.c.

References nullpointerabortvoid.

◆ gpi_jpeg_quantization2table()

jpeg_quantization_table* gpi_jpeg_quantization2table ( chunk qmarker)

Definition at line 318 of file jpeg.c.

References chunk::data.

◆ gpi_jpeg_write()

char gpi_jpeg_write ( CameraFile file,
const char *  filename,
jpeg myjpeg 
)

Variable Documentation

◆ JPEG_MARKERNAMES

const char* JPEG_MARKERNAMES[]
Initial value:
= {
"Start", "Comment", "APPO",
"Quantization table", "Huffman table", "SOFC0",
"SsSeAhAl", "End of image"
}

Definition at line 49 of file jpeg.c.

Referenced by gpi_jpeg_markername().

◆ JPEG_MARKERS

const jpegmarker JPEG_MARKERS[]
Initial value:

Definition at line 43 of file jpeg.c.

Referenced by gpi_jpeg_markername().

JPEG_EOI
@ JPEG_EOI
Definition: jpeg.h:32
JPEG_APPO
@ JPEG_APPO
Definition: jpeg.h:30
JPEG_START
@ JPEG_START
Definition: jpeg.h:30
JPEG_HUFFMAN
@ JPEG_HUFFMAN
Definition: jpeg.h:31
JPEG_SOFC0
@ JPEG_SOFC0
Definition: jpeg.h:31
JPEG_QUANTIZATION
@ JPEG_QUANTIZATION
Definition: jpeg.h:31
JPEG_COMMENT
@ JPEG_COMMENT
Definition: jpeg.h:30
JPEG_SSSEAHAL
@ JPEG_SSSEAHAL
Definition: jpeg.h:32