cbs_jpeg.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_CBS_JPEG_H
  19. #define AVCODEC_CBS_JPEG_H
  20. #include <stddef.h>
  21. #include <stdint.h>
  22. #include "libavutil/buffer.h"
  23. enum {
  24. JPEG_MARKER_SOF0 = 0xc0,
  25. JPEG_MARKER_SOF1 = 0xc1,
  26. JPEG_MARKER_SOF2 = 0xc2,
  27. JPEG_MARKER_SOF3 = 0xc3,
  28. JPEG_MARKER_DHT = 0xc4,
  29. JPEG_MARKER_SOI = 0xd8,
  30. JPEG_MARKER_EOI = 0xd9,
  31. JPEG_MARKER_SOS = 0xda,
  32. JPEG_MARKER_DQT = 0xdb,
  33. JPEG_MARKER_APPN = 0xe0,
  34. JPEG_MARKER_JPGN = 0xf0,
  35. JPEG_MARKER_COM = 0xfe,
  36. };
  37. enum {
  38. JPEG_MAX_COMPONENTS = 255,
  39. JPEG_MAX_HEIGHT = 65535,
  40. JPEG_MAX_WIDTH = 65535,
  41. };
  42. typedef struct JPEGRawFrameHeader {
  43. uint16_t Lf;
  44. uint8_t P;
  45. uint16_t Y;
  46. uint16_t X;
  47. uint16_t Nf;
  48. uint8_t C [JPEG_MAX_COMPONENTS];
  49. uint8_t H [JPEG_MAX_COMPONENTS];
  50. uint8_t V [JPEG_MAX_COMPONENTS];
  51. uint8_t Tq[JPEG_MAX_COMPONENTS];
  52. } JPEGRawFrameHeader;
  53. typedef struct JPEGRawScanHeader {
  54. uint16_t Ls;
  55. uint8_t Ns;
  56. uint8_t Cs[JPEG_MAX_COMPONENTS];
  57. uint8_t Td[JPEG_MAX_COMPONENTS];
  58. uint8_t Ta[JPEG_MAX_COMPONENTS];
  59. uint8_t Ss;
  60. uint8_t Se;
  61. uint8_t Ah;
  62. uint8_t Al;
  63. } JPEGRawScanHeader;
  64. typedef struct JPEGRawScan {
  65. JPEGRawScanHeader header;
  66. uint8_t *data;
  67. size_t data_size;
  68. AVBufferRef *data_ref;
  69. } JPEGRawScan;
  70. typedef struct JPEGRawQuantisationTable {
  71. uint8_t Pq;
  72. uint8_t Tq;
  73. uint16_t Q[64];
  74. } JPEGRawQuantisationTable;
  75. typedef struct JPEGRawQuantisationTableSpecification {
  76. uint16_t Lq;
  77. JPEGRawQuantisationTable table[4];
  78. } JPEGRawQuantisationTableSpecification;
  79. typedef struct JPEGRawHuffmanTable {
  80. uint8_t Tc;
  81. uint8_t Th;
  82. uint8_t L[16];
  83. uint8_t V[224];
  84. } JPEGRawHuffmanTable;
  85. typedef struct JPEGRawHuffmanTableSpecification {
  86. uint16_t Lh;
  87. JPEGRawHuffmanTable table[8];
  88. } JPEGRawHuffmanTableSpecification;
  89. typedef struct JPEGRawApplicationData {
  90. uint16_t Lp;
  91. uint8_t *Ap;
  92. AVBufferRef *Ap_ref;
  93. } JPEGRawApplicationData;
  94. typedef struct JPEGRawComment {
  95. uint16_t Lc;
  96. uint8_t *Cm;
  97. AVBufferRef *Cm_ref;
  98. } JPEGRawComment;
  99. #endif /* AVCODEC_CBS_JPEG_H */