1 /* GStreamer 2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> 3 * Copyright (C) 2012 Collabora Ltd. 4 * Author : Edward Hervey <edward@collabora.com> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public 17 * License along with this library; if not, write to the 18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 22 23 #ifndef __GST_JPEG_DEC_H__ 24 #define __GST_JPEG_DEC_H__ 25 26 27 #include <setjmp.h> 28 #include <gst/gst.h> 29 #include <gst/video/video.h> 30 #include <gst/video/gstvideodecoder.h> 31 #include <gst/base/gstadapter.h> 32 33 /* this is a hack hack hack to get around jpeglib header bugs... */ 34 #ifdef HAVE_STDLIB_H 35 # undef HAVE_STDLIB_H 36 #endif 37 #include <stdio.h> 38 #include <jpeglib.h> 39 40 G_BEGIN_DECLS 41 42 #define GST_TYPE_JPEG_DEC \ 43 (gst_jpeg_dec_get_type()) 44 #define GST_JPEG_DEC(obj) \ 45 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JPEG_DEC,GstJpegDec)) 46 #define GST_JPEG_DEC_CLASS(klass) \ 47 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JPEG_DEC,GstJpegDecClass)) 48 #define GST_IS_JPEG_DEC(obj) \ 49 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JPEG_DEC)) 50 #define GST_IS_JPEG_DEC_CLASS(klass) \ 51 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JPEG_DEC)) 52 53 typedef struct _GstJpegDec GstJpegDec; 54 typedef struct _GstJpegDecClass GstJpegDecClass; 55 56 struct GstJpegDecErrorMgr { 57 struct jpeg_error_mgr pub; /* public fields */ 58 jmp_buf setjmp_buffer; 59 }; 60 61 struct GstJpegDecSourceMgr { 62 struct jpeg_source_mgr pub; /* public fields */ 63 GstJpegDec *dec; 64 }; 65 66 /* Can't use GstBaseTransform, because GstBaseTransform 67 * doesn't handle the N buffers in, 1 buffer out case, 68 * but only the 1-in 1-out case */ 69 struct _GstJpegDec { 70 GstVideoDecoder decoder; 71 72 /* negotiated state */ 73 GstVideoCodecState *input_state; 74 GstVideoCodecFrame *current_frame; 75 GstMapInfo current_frame_map; 76 77 /* parse state */ 78 gboolean saw_header; 79 gint parse_entropy_len; 80 gint parse_resync; 81 82 /* properties */ 83 gint idct_method; 84 gint max_errors; /* ATOMIC */ 85 86 struct jpeg_decompress_struct cinfo; 87 struct GstJpegDecErrorMgr jerr; 88 struct GstJpegDecSourceMgr jsrc; 89 90 /* arrays for indirect decoding */ 91 gboolean idr_width_allocated; 92 guchar *idr_y[16],*idr_u[16],*idr_v[16]; 93 /* scratch buffer for direct decoding overflow */ 94 guchar *scratch; 95 guint scratch_size; 96 /* current (parsed) image size */ 97 guint rem_img_len; 98 }; 99 100 struct _GstJpegDecClass { 101 GstVideoDecoderClass decoder_class; 102 }; 103 104 GType gst_jpeg_dec_get_type(void); 105 106 107 G_END_DECLS 108 109 110 #endif /* __GST_JPEG_DEC_H__ */ 111