• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/mjpeg.h

Go to the documentation of this file.
00001 /*
00002  * MJPEG encoder and decoder
00003  * Copyright (c) 2000, 2001 Fabrice Bellard
00004  * Copyright (c) 2003 Alex Beregszaszi
00005  * Copyright (c) 2003-2004 Michael Niedermayer
00006  *
00007  * Support for external huffman table, various fixes (AVID workaround),
00008  * aspecting, new decode_frame mechanism and apple mjpeg-b support
00009  *                                  by Alex Beregszaszi
00010  *
00011  * This file is part of FFmpeg.
00012  *
00013  * FFmpeg is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Lesser General Public
00015  * License as published by the Free Software Foundation; either
00016  * version 2.1 of the License, or (at your option) any later version.
00017  *
00018  * FFmpeg is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public
00024  * License along with FFmpeg; if not, write to the Free Software
00025  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00026  */
00027 
00033 #ifndef AVCODEC_MJPEG_H
00034 #define AVCODEC_MJPEG_H
00035 
00036 #include "avcodec.h"
00037 #include "put_bits.h"
00038 
00039 
00040 /* JPEG marker codes */
00041 typedef enum {
00042     /* start of frame */
00043     SOF0  = 0xc0,       /* baseline */
00044     SOF1  = 0xc1,       /* extended sequential, huffman */
00045     SOF2  = 0xc2,       /* progressive, huffman */
00046     SOF3  = 0xc3,       /* lossless, huffman */
00047 
00048     SOF5  = 0xc5,       /* differential sequential, huffman */
00049     SOF6  = 0xc6,       /* differential progressive, huffman */
00050     SOF7  = 0xc7,       /* differential lossless, huffman */
00051     JPG   = 0xc8,       /* reserved for JPEG extension */
00052     SOF9  = 0xc9,       /* extended sequential, arithmetic */
00053     SOF10 = 0xca,       /* progressive, arithmetic */
00054     SOF11 = 0xcb,       /* lossless, arithmetic */
00055 
00056     SOF13 = 0xcd,       /* differential sequential, arithmetic */
00057     SOF14 = 0xce,       /* differential progressive, arithmetic */
00058     SOF15 = 0xcf,       /* differential lossless, arithmetic */
00059 
00060     DHT   = 0xc4,       /* define huffman tables */
00061 
00062     DAC   = 0xcc,       /* define arithmetic-coding conditioning */
00063 
00064     /* restart with modulo 8 count "m" */
00065     RST0  = 0xd0,
00066     RST1  = 0xd1,
00067     RST2  = 0xd2,
00068     RST3  = 0xd3,
00069     RST4  = 0xd4,
00070     RST5  = 0xd5,
00071     RST6  = 0xd6,
00072     RST7  = 0xd7,
00073 
00074     SOI   = 0xd8,       /* start of image */
00075     EOI   = 0xd9,       /* end of image */
00076     SOS   = 0xda,       /* start of scan */
00077     DQT   = 0xdb,       /* define quantization tables */
00078     DNL   = 0xdc,       /* define number of lines */
00079     DRI   = 0xdd,       /* define restart interval */
00080     DHP   = 0xde,       /* define hierarchical progression */
00081     EXP   = 0xdf,       /* expand reference components */
00082 
00083     APP0  = 0xe0,
00084     APP1  = 0xe1,
00085     APP2  = 0xe2,
00086     APP3  = 0xe3,
00087     APP4  = 0xe4,
00088     APP5  = 0xe5,
00089     APP6  = 0xe6,
00090     APP7  = 0xe7,
00091     APP8  = 0xe8,
00092     APP9  = 0xe9,
00093     APP10 = 0xea,
00094     APP11 = 0xeb,
00095     APP12 = 0xec,
00096     APP13 = 0xed,
00097     APP14 = 0xee,
00098     APP15 = 0xef,
00099 
00100     JPG0  = 0xf0,
00101     JPG1  = 0xf1,
00102     JPG2  = 0xf2,
00103     JPG3  = 0xf3,
00104     JPG4  = 0xf4,
00105     JPG5  = 0xf5,
00106     JPG6  = 0xf6,
00107     SOF48 = 0xf7,       
00108     LSE   = 0xf8,       
00109     JPG9  = 0xf9,
00110     JPG10 = 0xfa,
00111     JPG11 = 0xfb,
00112     JPG12 = 0xfc,
00113     JPG13 = 0xfd,
00114 
00115     COM   = 0xfe,       /* comment */
00116 
00117     TEM   = 0x01,       /* temporary private use for arithmetic coding */
00118 
00119     /* 0x02 -> 0xbf reserved */
00120 } JPEG_MARKER;
00121 
00122 static inline void put_marker(PutBitContext *p, int code)
00123 {
00124     put_bits(p, 8, 0xff);
00125     put_bits(p, 8, code);
00126 }
00127 
00128 #define PREDICT(ret, topleft, top, left, predictor)\
00129     switch(predictor){\
00130         case 1: ret= left; break;\
00131         case 2: ret= top; break;\
00132         case 3: ret= topleft; break;\
00133         case 4: ret= left   +   top - topleft; break;\
00134         case 5: ret= left   + ((top - topleft)>>1); break;\
00135         case 6: ret= top + ((left   - topleft)>>1); break;\
00136         default:\
00137         case 7: ret= (left + top)>>1; break;\
00138     }
00139 
00140 extern const uint8_t ff_mjpeg_bits_dc_luminance[];
00141 extern const uint8_t ff_mjpeg_val_dc[];
00142 
00143 extern const uint8_t ff_mjpeg_bits_dc_chrominance[];
00144 
00145 extern const uint8_t ff_mjpeg_bits_ac_luminance[];
00146 extern const uint8_t ff_mjpeg_val_ac_luminance[];
00147 
00148 extern const uint8_t ff_mjpeg_bits_ac_chrominance[];
00149 extern const uint8_t ff_mjpeg_val_ac_chrominance[];
00150 
00151 void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
00152                                   const uint8_t *bits_table,
00153                                   const uint8_t *val_table);
00154 
00155 #endif /* AVCODEC_MJPEG_H */

Generated on Fri Sep 16 2011 17:17:39 for FFmpeg by  doxygen 1.7.1