mjpeg.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. * @file
  29. * MJPEG encoder and decoder.
  30. */
  31. #ifndef AVCODEC_MJPEG_H
  32. #define AVCODEC_MJPEG_H
  33. /* JPEG marker codes */
  34. enum JpegMarker {
  35. /* start of frame */
  36. SOF0 = 0xc0, /* baseline */
  37. SOF1 = 0xc1, /* extended sequential, huffman */
  38. SOF2 = 0xc2, /* progressive, huffman */
  39. SOF3 = 0xc3, /* lossless, huffman */
  40. SOF5 = 0xc5, /* differential sequential, huffman */
  41. SOF6 = 0xc6, /* differential progressive, huffman */
  42. SOF7 = 0xc7, /* differential lossless, huffman */
  43. JPG = 0xc8, /* reserved for JPEG extension */
  44. SOF9 = 0xc9, /* extended sequential, arithmetic */
  45. SOF10 = 0xca, /* progressive, arithmetic */
  46. SOF11 = 0xcb, /* lossless, arithmetic */
  47. SOF13 = 0xcd, /* differential sequential, arithmetic */
  48. SOF14 = 0xce, /* differential progressive, arithmetic */
  49. SOF15 = 0xcf, /* differential lossless, arithmetic */
  50. DHT = 0xc4, /* define huffman tables */
  51. DAC = 0xcc, /* define arithmetic-coding conditioning */
  52. /* restart with modulo 8 count "m" */
  53. RST0 = 0xd0,
  54. RST1 = 0xd1,
  55. RST2 = 0xd2,
  56. RST3 = 0xd3,
  57. RST4 = 0xd4,
  58. RST5 = 0xd5,
  59. RST6 = 0xd6,
  60. RST7 = 0xd7,
  61. SOI = 0xd8, /* start of image */
  62. EOI = 0xd9, /* end of image */
  63. SOS = 0xda, /* start of scan */
  64. DQT = 0xdb, /* define quantization tables */
  65. DNL = 0xdc, /* define number of lines */
  66. DRI = 0xdd, /* define restart interval */
  67. DHP = 0xde, /* define hierarchical progression */
  68. EXP = 0xdf, /* expand reference components */
  69. APP0 = 0xe0,
  70. APP1 = 0xe1,
  71. APP2 = 0xe2,
  72. APP3 = 0xe3,
  73. APP4 = 0xe4,
  74. APP5 = 0xe5,
  75. APP6 = 0xe6,
  76. APP7 = 0xe7,
  77. APP8 = 0xe8,
  78. APP9 = 0xe9,
  79. APP10 = 0xea,
  80. APP11 = 0xeb,
  81. APP12 = 0xec,
  82. APP13 = 0xed,
  83. APP14 = 0xee,
  84. APP15 = 0xef,
  85. JPG0 = 0xf0,
  86. JPG1 = 0xf1,
  87. JPG2 = 0xf2,
  88. JPG3 = 0xf3,
  89. JPG4 = 0xf4,
  90. JPG5 = 0xf5,
  91. JPG6 = 0xf6,
  92. SOF48 = 0xf7, ///< JPEG-LS
  93. LSE = 0xf8, ///< JPEG-LS extension parameters
  94. JPG9 = 0xf9,
  95. JPG10 = 0xfa,
  96. JPG11 = 0xfb,
  97. JPG12 = 0xfc,
  98. JPG13 = 0xfd,
  99. COM = 0xfe, /* comment */
  100. TEM = 0x01, /* temporary private use for arithmetic coding */
  101. /* 0x02 -> 0xbf reserved */
  102. };
  103. #define PREDICT(ret, topleft, top, left, predictor)\
  104. switch(predictor){\
  105. case 0: ret= 0; break;\
  106. case 1: ret= left; break;\
  107. case 2: ret= top; break;\
  108. case 3: ret= topleft; break;\
  109. case 4: ret= left + top - topleft; break;\
  110. case 5: ret= left + ((top - topleft)>>1); break;\
  111. case 6: ret= top + ((left - topleft)>>1); break;\
  112. default:\
  113. case 7: ret= (left + top)>>1; break;\
  114. }
  115. #endif /* AVCODEC_MJPEG_H */