vid_subs.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef NSVPLAY_SUBTITLES_H
  2. #define NSVPLAY_SUBTITLES_H
  3. #include "wa_ipc.h"
  4. //#include "main.h"
  5. //#include "../nsvbs.h"
  6. typedef struct
  7. {
  8. const char *language;
  9. const char *utf8_text;
  10. unsigned int start_frame, end_frame;
  11. unsigned char xPos, yPos;
  12. unsigned char colorRed, colorGreen, colorBlue;
  13. signed char fontSize;
  14. int extraDataSize;
  15. const void *extraData;
  16. } SUBTITLE_INFO;
  17. class SubsItem {
  18. public:
  19. SubsItem(unsigned int ptimestart, unsigned int ptimeend, const char *ptext) :
  20. timestart(ptimestart) , timeend(ptimeend) {
  21. text=_strdup(ptext);
  22. xPos=128;
  23. yPos=255;
  24. colorRed=colorGreen=colorBlue=0xff;
  25. extraDataSize=0;
  26. extraData=0;
  27. muxed_subtitle=0;
  28. fontSize=origFontSize=0;
  29. }
  30. ~SubsItem() {
  31. free((void*)text);
  32. if(extraDataSize) free((void *)extraData);
  33. }
  34. unsigned int timestart;
  35. unsigned int timeend;
  36. const char *text;
  37. unsigned char xPos, yPos;
  38. unsigned char colorRed, colorGreen, colorBlue;
  39. int extraDataSize;
  40. const void *extraData;
  41. int muxed_subtitle; //so we free it when we seek/display
  42. int fontSize;
  43. int origFontSize;
  44. };
  45. class Subtitles {
  46. public:
  47. Subtitles(const char *filename);
  48. SubsItem *getSubtitle(unsigned int time, unsigned int frame); // time in ms
  49. void addSubtitlePacket(SUBTITLE_INFO *sti);
  50. void setFontSizeModifier(int size) { m_font_size_mod=size; }
  51. private:
  52. void decodeSrtFile(char *text);
  53. unsigned int getTimeFromSrtText(const char *text);
  54. void decodeSubFile(char *text);
  55. //ClassList<SubsItem> m_subs; //FUCKO
  56. int m_frame_based;
  57. int m_last_sub;
  58. int m_font_size_mod;
  59. };
  60. #endif