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 /* libjpeg-turbo colorspace conversion */ 78 #ifdef JCS_EXTENSIONS 79 GstVideoFormat format; 80 J_COLOR_SPACE libjpeg_ext_format; 81 gboolean format_convert; 82 #endif 83 84 /* parse state */ 85 gboolean saw_header; 86 gint parse_entropy_len; 87 gint parse_resync; 88 89 /* properties */ 90 gint idct_method; 91 gint max_errors; /* ATOMIC */ 92 93 struct jpeg_decompress_struct cinfo; 94 struct GstJpegDecErrorMgr jerr; 95 struct GstJpegDecSourceMgr jsrc; 96 97 /* arrays for indirect decoding */ 98 gboolean idr_width_allocated; 99 guchar *idr_y[16],*idr_u[16],*idr_v[16]; 100 /* scratch buffer for direct decoding overflow */ 101 guchar *scratch; 102 guint scratch_size; 103 /* current (parsed) image size */ 104 guint rem_img_len; 105 }; 106 107 struct _GstJpegDecClass { 108 GstVideoDecoderClass decoder_class; 109 }; 110 111 GType gst_jpeg_dec_get_type(void); 112 113 114 G_END_DECLS 115 116 117 #endif /* __GST_JPEG_DEC_H__ */ 118