FFmpeg
mjpeg.h
Go to the documentation of this file.
1 /*
2  * MJPEG encoder and decoder
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  * Copyright (c) 2003 Alex Beregszaszi
5  * Copyright (c) 2003-2004 Michael Niedermayer
6  *
7  * Support for external huffman table, various fixes (AVID workaround),
8  * aspecting, new decode_frame mechanism and apple mjpeg-b support
9  * by Alex Beregszaszi
10  *
11  * This file is part of FFmpeg.
12  *
13  * FFmpeg is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * FFmpeg is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with FFmpeg; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  */
27 
28 /**
29  * @file
30  * MJPEG encoder and decoder.
31  */
32 
33 #ifndef AVCODEC_MJPEG_H
34 #define AVCODEC_MJPEG_H
35 
36 /* JPEG marker codes */
37 enum JpegMarker {
38  /* start of frame */
39  SOF0 = 0xc0, /* baseline */
40  SOF1 = 0xc1, /* extended sequential, huffman */
41  SOF2 = 0xc2, /* progressive, huffman */
42  SOF3 = 0xc3, /* lossless, huffman */
43 
44  SOF5 = 0xc5, /* differential sequential, huffman */
45  SOF6 = 0xc6, /* differential progressive, huffman */
46  SOF7 = 0xc7, /* differential lossless, huffman */
47  JPG = 0xc8, /* reserved for JPEG extension */
48  SOF9 = 0xc9, /* extended sequential, arithmetic */
49  SOF10 = 0xca, /* progressive, arithmetic */
50  SOF11 = 0xcb, /* lossless, arithmetic */
51 
52  SOF13 = 0xcd, /* differential sequential, arithmetic */
53  SOF14 = 0xce, /* differential progressive, arithmetic */
54  SOF15 = 0xcf, /* differential lossless, arithmetic */
55 
56  DHT = 0xc4, /* define huffman tables */
57 
58  DAC = 0xcc, /* define arithmetic-coding conditioning */
59 
60  /* restart with modulo 8 count "m" */
61  RST0 = 0xd0,
62  RST1 = 0xd1,
63  RST2 = 0xd2,
64  RST3 = 0xd3,
65  RST4 = 0xd4,
66  RST5 = 0xd5,
67  RST6 = 0xd6,
68  RST7 = 0xd7,
69 
70  SOI = 0xd8, /* start of image */
71  EOI = 0xd9, /* end of image */
72  SOS = 0xda, /* start of scan */
73  DQT = 0xdb, /* define quantization tables */
74  DNL = 0xdc, /* define number of lines */
75  DRI = 0xdd, /* define restart interval */
76  DHP = 0xde, /* define hierarchical progression */
77  EXP = 0xdf, /* expand reference components */
78 
79  APP0 = 0xe0,
80  APP1 = 0xe1,
81  APP2 = 0xe2,
82  APP3 = 0xe3,
83  APP4 = 0xe4,
84  APP5 = 0xe5,
85  APP6 = 0xe6,
86  APP7 = 0xe7,
87  APP8 = 0xe8,
88  APP9 = 0xe9,
89  APP10 = 0xea,
90  APP11 = 0xeb,
91  APP12 = 0xec,
92  APP13 = 0xed,
93  APP14 = 0xee,
94  APP15 = 0xef,
95 
96  JPG0 = 0xf0,
97  JPG1 = 0xf1,
98  JPG2 = 0xf2,
99  JPG3 = 0xf3,
100  JPG4 = 0xf4,
101  JPG5 = 0xf5,
102  JPG6 = 0xf6,
103  SOF48 = 0xf7, ///< JPEG-LS
104  LSE = 0xf8, ///< JPEG-LS extension parameters
105  JPG9 = 0xf9,
106  JPG10 = 0xfa,
107  JPG11 = 0xfb,
108  JPG12 = 0xfc,
109  JPG13 = 0xfd,
110 
111  COM = 0xfe, /* comment */
112 
113  TEM = 0x01, /* temporary private use for arithmetic coding */
114 
115  /* 0x02 -> 0xbf reserved */
116 };
117 
118 #define PREDICT(ret, topleft, top, left, predictor)\
119  switch(predictor){\
120  case 0: ret= 0; break;\
121  case 1: ret= left; break;\
122  case 2: ret= top; break;\
123  case 3: ret= topleft; break;\
124  case 4: ret= left + top - topleft; break;\
125  case 5: ret= left + ((top - topleft)>>1); break;\
126  case 6: ret= top + ((left - topleft)>>1); break;\
127  default:\
128  case 7: ret= (left + top)>>1; break;\
129  }
130 
131 #endif /* AVCODEC_MJPEG_H */
DHP
@ DHP
Definition: mjpeg.h:76
SOS
@ SOS
Definition: mjpeg.h:72
SOF48
@ SOF48
JPEG-LS.
Definition: mjpeg.h:103
APP1
@ APP1
Definition: mjpeg.h:80
SOF0
@ SOF0
Definition: mjpeg.h:39
RST7
@ RST7
Definition: mjpeg.h:68
SOF11
@ SOF11
Definition: mjpeg.h:50
RST3
@ RST3
Definition: mjpeg.h:64
JPG4
@ JPG4
Definition: mjpeg.h:100
RST6
@ RST6
Definition: mjpeg.h:67
JpegMarker
JpegMarker
Definition: mjpeg.h:37
APP15
@ APP15
Definition: mjpeg.h:94
APP4
@ APP4
Definition: mjpeg.h:83
JPG5
@ JPG5
Definition: mjpeg.h:101
SOF3
@ SOF3
Definition: mjpeg.h:42
APP13
@ APP13
Definition: mjpeg.h:92
COM
@ COM
Definition: mjpeg.h:111
SOF5
@ SOF5
Definition: mjpeg.h:44
APP12
@ APP12
Definition: mjpeg.h:91
APP3
@ APP3
Definition: mjpeg.h:82
JPG10
@ JPG10
Definition: mjpeg.h:106
RST0
@ RST0
Definition: mjpeg.h:61
APP11
@ APP11
Definition: mjpeg.h:90
APP5
@ APP5
Definition: mjpeg.h:84
APP9
@ APP9
Definition: mjpeg.h:88
RST4
@ RST4
Definition: mjpeg.h:65
JPG13
@ JPG13
Definition: mjpeg.h:109
SOF13
@ SOF13
Definition: mjpeg.h:52
JPG12
@ JPG12
Definition: mjpeg.h:108
JPG9
@ JPG9
Definition: mjpeg.h:105
JPG6
@ JPG6
Definition: mjpeg.h:102
JPG2
@ JPG2
Definition: mjpeg.h:98
TEM
@ TEM
Definition: mjpeg.h:113
DRI
@ DRI
Definition: mjpeg.h:75
EXP
@ EXP
Definition: mjpeg.h:77
SOF14
@ SOF14
Definition: mjpeg.h:53
SOF15
@ SOF15
Definition: mjpeg.h:54
DQT
@ DQT
Definition: mjpeg.h:73
RST1
@ RST1
Definition: mjpeg.h:62
APP6
@ APP6
Definition: mjpeg.h:85
SOF10
@ SOF10
Definition: mjpeg.h:49
JPG0
@ JPG0
Definition: mjpeg.h:96
EOI
@ EOI
Definition: mjpeg.h:71
APP8
@ APP8
Definition: mjpeg.h:87
SOF9
@ SOF9
Definition: mjpeg.h:48
DAC
@ DAC
Definition: mjpeg.h:58
DHT
@ DHT
Definition: mjpeg.h:56
RST5
@ RST5
Definition: mjpeg.h:66
APP7
@ APP7
Definition: mjpeg.h:86
SOF2
@ SOF2
Definition: mjpeg.h:41
LSE
@ LSE
JPEG-LS extension parameters.
Definition: mjpeg.h:104
APP14
@ APP14
Definition: mjpeg.h:93
DNL
@ DNL
Definition: mjpeg.h:74
APP2
@ APP2
Definition: mjpeg.h:81
JPG3
@ JPG3
Definition: mjpeg.h:99
JPG11
@ JPG11
Definition: mjpeg.h:107
APP0
@ APP0
Definition: mjpeg.h:79
SOI
@ SOI
Definition: mjpeg.h:70
SOF1
@ SOF1
Definition: mjpeg.h:40
JPG1
@ JPG1
Definition: mjpeg.h:97
APP10
@ APP10
Definition: mjpeg.h:89
SOF7
@ SOF7
Definition: mjpeg.h:46
SOF6
@ SOF6
Definition: mjpeg.h:45
RST2
@ RST2
Definition: mjpeg.h:63
JPG
@ JPG
Definition: mjpeg.h:47