1
0

avi_mjpg_decoder.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "../Plugins/Input/in_avi/ifc_avivideodecoder.h"
  3. #include "../Plugins/Input/in_avi/svc_avidecoder.h"
  4. #include "../nsavi/avi_header.h"
  5. #include "loader_jpg.h"
  6. extern "C"
  7. {
  8. #undef FAR
  9. #include "jpeglib.h"
  10. };
  11. // {F54E12B2-1B6B-48ac-B65D-F33B690A4F81}
  12. static const GUID avi_jpeg_guid =
  13. { 0xf54e12b2, 0x1b6b, 0x48ac, { 0xb6, 0x5d, 0xf3, 0x3b, 0x69, 0xa, 0x4f, 0x81 } };
  14. class AVIDecoderCreator : public svc_avidecoder
  15. {
  16. public:
  17. static const char *getServiceName() { return "JPEG AVI Decoder"; }
  18. static GUID getServiceGuid() { return avi_jpeg_guid; }
  19. int CreateVideoDecoder(const nsavi::AVIH *avi_header, const nsavi::STRH *stream_header, const nsavi::STRF *stream_format, const nsavi::STRD *stream_data, ifc_avivideodecoder **decoder);
  20. protected:
  21. RECVS_DISPATCH;
  22. };
  23. class AVIMJPEG : public ifc_avivideodecoder
  24. {
  25. public:
  26. AVIMJPEG(nsavi::video_format *stream_format);
  27. static AVIMJPEG *CreateDecoder(nsavi::video_format *stream_format);
  28. int GetOutputProperties(int *x, int *y, int *color_format, double *aspect_ratio, int *flip);
  29. int DecodeChunk(uint16_t type, const void *inputBuffer, size_t inputBufferBytes);
  30. void Flush();
  31. void Close();
  32. int GetPicture(void **data, void **decoder_data);
  33. void FreePicture(void *data, void *decoder_data);
  34. private:
  35. nsavi::video_format *stream_format;
  36. JpgLoad *jpegLoader;
  37. int width, height;
  38. int image_size;
  39. void *decoded_image; // UYVY
  40. bool image_outputted;
  41. jpeg_decompress_struct cinfo;
  42. jpeg_error_mgr jerr;
  43. protected:
  44. RECVS_DISPATCH;
  45. };