You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.8 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * jpegutils.h: Some Utility programs for dealing with
  3. * JPEG encoded images
  4. *
  5. * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de>
  6. * Copyright (C) 2001 pHilipp Zabel <pzabel@gmx.de>
  7. * Copyright (C) 2008 Angel Carpintero <motiondevelop@gmail.com>
  8. *
  9. */
  10. #ifndef __JPEGUTILS_H__
  11. #define __JPEGUTILS_H__
  12. /*
  13. * jpeg_data: buffer with input / output jpeg
  14. * len: Length of jpeg buffer
  15. * itype: Y4M_ILACE_NONE: Not interlaced
  16. * Y4M_ILACE_TOP_FIRST: Interlaced, top-field-first
  17. * Y4M_ILACE_BOTTOM_FIRST: Interlaced, bottom-field-first
  18. * ctype Chroma format for decompression.
  19. * Currently always 420 and hence ignored.
  20. * raw0 buffer with input / output raw Y channel
  21. * raw1 buffer with input / output raw U/Cb channel
  22. * raw2 buffer with input / output raw V/Cr channel
  23. * width width of Y channel (width of U/V is width/2)
  24. * height height of Y channel (height of U/V is height/2)
  25. */
  26. #include <stdlib.h>
  27. #include <stdint.h>
  28. #include <stdio.h>
  29. #include <malloc.h>
  30. #include <string.h>
  31. #define Y4M_ILACE_NONE 0 /* non-interlaced, progressive frame */
  32. #define Y4M_ILACE_TOP_FIRST 1 /* interlaced, top-field first */
  33. #define Y4M_ILACE_BOTTOM_FIRST 2 /* interlaced, bottom-field first */
  34. #define Y4M_ILACE_MIXED 3 /* mixed, "refer to frame header" */
  35. #define Y4M_CHROMA_420JPEG 0 /* 4:2:0, H/V centered, for JPEG/MPEG-1 */
  36. #define Y4M_CHROMA_420MPEG2 1 /* 4:2:0, H cosited, for MPEG-2 */
  37. #define Y4M_CHROMA_420PALDV 2 /* 4:2:0, alternating Cb/Cr, for PAL-DV */
  38. #define Y4M_CHROMA_444 3 /* 4:4:4, no subsampling, phew. */
  39. #define Y4M_CHROMA_422 4 /* 4:2:2, H cosited */
  40. #define Y4M_CHROMA_411 5 /* 4:1:1, H cosited */
  41. #define Y4M_CHROMA_MONO 6 /* luma plane only */
  42. #define Y4M_CHROMA_444ALPHA 7 /* 4:4:4 with an alpha channel */
  43. int decode_jpeg_raw(unsigned char *jpeg_data, int len,
  44. int itype, int ctype, unsigned int width,
  45. unsigned int height, unsigned char *raw0,
  46. unsigned char *raw1, unsigned char *raw2);
  47. int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len,
  48. int itype, int ctype, unsigned int width,
  49. unsigned int height, unsigned char *raw0,
  50. unsigned char *raw1, unsigned char *raw2);
  51. int encode_jpeg_raw(unsigned char *jpeg_data, int len, int quality,
  52. int itype, int ctype, unsigned int width,
  53. unsigned int height, unsigned char *raw0,
  54. unsigned char *raw1, unsigned char *raw2);
  55. #endif