jpeg_parser.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (c) 2020, Actions Semi Co., Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. ******************************************************************************
  8. * @file jpeg_parser.h
  9. * @brief JPEG parser module driver.
  10. *
  11. */
  12. #ifndef __JPEG_PARSER_H__
  13. #define __JPEG_PARSER_H__
  14. #include <string.h>
  15. #include <assert.h>
  16. #include <video/jpeg_hw/jpeg_hw.h>
  17. typedef enum{
  18. EN_NOSUPPORT = -5,
  19. EN_DECERR,
  20. EN_FILEISEND,
  21. EN_FILESTARTPOS,
  22. EN_MEMERR,
  23. EN_NORMAL,
  24. }rt_status_t;
  25. typedef struct jpeg_parser_info {
  26. uint8_t *jpeg_base;
  27. uint32_t jpeg_size;
  28. uint32_t jpeg_current_offset;
  29. uint32_t thumbnailoffset;
  30. struct jpeg_info_t jpeg_info;
  31. uint32_t nodata:1;
  32. } jpeg_parser_info_t;
  33. typedef enum { /* JPEG marker codes */
  34. M_SOF0 = 0xc0,
  35. M_SOF1 = 0xc1,
  36. M_SOF2 = 0xc2,
  37. M_SOF3 = 0xc3,
  38. M_SOF5 = 0xc5,
  39. M_SOF6 = 0xc6,
  40. M_SOF7 = 0xc7,
  41. M_JPG = 0xc8,
  42. M_SOF9 = 0xc9,
  43. M_SOF10 = 0xca,
  44. M_SOF11 = 0xcb,
  45. M_SOF13 = 0xcd,
  46. M_SOF14 = 0xce,
  47. M_SOF15 = 0xcf,
  48. M_DHT = 0xc4,
  49. M_DAC = 0xcc,
  50. M_RST0 = 0xd0,
  51. M_RST1 = 0xd1,
  52. M_RST2 = 0xd2,
  53. M_RST3 = 0xd3,
  54. M_RST4 = 0xd4,
  55. M_RST5 = 0xd5,
  56. M_RST6 = 0xd6,
  57. M_RST7 = 0xd7,
  58. M_SOI = 0xd8,
  59. M_EOI = 0xd9,
  60. M_SOS = 0xda,
  61. M_DQT = 0xdb,
  62. M_DNL = 0xdc,
  63. M_DRI = 0xdd,
  64. M_DHP = 0xde,
  65. M_EXP = 0xdf,
  66. M_APP0 = 0xe0,
  67. M_APP1 = 0xe1,
  68. M_APP2 = 0xe2,
  69. M_APP3 = 0xe3,
  70. M_APP4 = 0xe4,
  71. M_APP5 = 0xe5,
  72. M_APP6 = 0xe6,
  73. M_APP7 = 0xe7,
  74. M_APP8 = 0xe8,
  75. M_APP9 = 0xe9,
  76. M_APP10 = 0xea,
  77. M_APP11 = 0xeb,
  78. M_APP12 = 0xec,
  79. M_APP13 = 0xed,
  80. M_APP14 = 0xee,
  81. M_APP15 = 0xef,
  82. M_JPG0 = 0xf0,
  83. M_JPG13 = 0xfd,
  84. M_COM = 0xfe,
  85. M_TEM = 0x01,
  86. M_ERROR = 0x100,
  87. M_NODATA = 0x200
  88. } JPEG_MARKER;
  89. typedef struct{
  90. JPEG_MARKER marker;
  91. int (*marker_pro)(struct jpeg_parser_info *);
  92. }jpeg_marker_handle_t;
  93. #define ACHuf_0 (JPEG_VLCTABLE_RAM)
  94. #define ACHuf_1 (ACHuf_0 + 162)
  95. #define DCHuf_0 (ACHuf_1 + 162)
  96. #define DCHuf_1 (DCHuf_0 + 12)
  97. #define QT_0 (JPEG_IQTABLE_RAM)
  98. #define QT_1 (JPEG_IQTABLE_RAM+64)
  99. #define QT_2 (JPEG_IQTABLE_RAM+128)
  100. #define SHIFTVAL 10
  101. int jpeg_parser_process(struct jpeg_parser_info *parser_info, int mode);
  102. #endif