Subversion Repositories Kolibri OS

Rev

Rev 1696 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. #define BLACK_MAGIC_SOUND
  3. #define BLACK_MAGIC_VIDEO
  4.  
  5. typedef unsigned int color_t;
  6. typedef unsigned int count_t;
  7.  
  8. typedef struct
  9. {
  10.     int  left;
  11.     int  top;
  12.     int  right;
  13.     int  bottom;
  14. }rect_t;
  15.  
  16. typedef struct
  17. {
  18.     uint32_t    width;
  19.     uint32_t    height;
  20.     uint32_t    pitch;
  21.     uint32_t    handle;
  22.     uint8_t    *data;
  23. }bitmap_t;
  24.  
  25. typedef struct render  render_t;
  26.  
  27. struct render
  28. {
  29.     uint32_t   caps;
  30.     uint32_t   ctx_width;
  31.     uint32_t   ctx_height;
  32.     uint32_t   win_width;
  33.     uint32_t   win_height;
  34.  
  35.     bitmap_t   bitmap[4];
  36.     uint32_t   ctx_format;
  37.     int        target;
  38.     enum{
  39.       EMPTY, INIT }state;
  40.     enum{
  41.       NORMAL, MINIMIZED, ROLLED
  42.     }win_state;
  43.  
  44.     void (*draw)(render_t *render, AVPicture *picture);
  45. };
  46.  
  47. typedef struct
  48. {
  49.     volatile uint32_t   lock;
  50.     char               *buffer;
  51.     volatile uint32_t   count;
  52. }astream_t;
  53.  
  54. typedef struct
  55. {
  56.   unsigned int  code;
  57.   unsigned int  sender;
  58.   unsigned int  stream;
  59.   unsigned int  offset;
  60.   unsigned int  size;
  61.   unsigned int  unused[2];
  62. }SND_EVENT;
  63.  
  64. typedef struct
  65. {
  66.   unsigned      handle;
  67.   unsigned      io_code;
  68.   void          *input;
  69.   int           inp_size;
  70.   void          *output;
  71.   int           out_size;
  72. }ioctl_t;
  73.  
  74. typedef struct {
  75.     AVPacketList *first_pkt;
  76.     AVPacketList *last_pkt;
  77.     int size;
  78.     int count;
  79.     volatile uint32_t lock;
  80. } queue_t;
  81.  
  82. int put_packet(queue_t *q, AVPacket *pkt);
  83. int get_packet(queue_t *q, AVPacket *pkt);
  84.  
  85.  
  86. extern astream_t astream;
  87. extern AVRational video_time_base;
  88.  
  89. render_t *create_render(uint32_t width, uint32_t height,
  90.                         uint32_t ctx_format, uint32_t flags);
  91.  
  92. int init_render(render_t *render, int width, int height);
  93. void render_adjust_size(render_t *render);
  94.  
  95. int init_audio(int format);
  96. int audio_thread(void *param);
  97.  
  98. int init_video(AVCodecContext *ctx);
  99. int video_thread(void *param);
  100.  
  101. int decode_video(AVCodecContext  *ctx, queue_t *qv);
  102. int decode_audio(AVCodecContext  *ctx, queue_t *qa);
  103.  
  104. double get_master_clock();
  105.  
  106.  
  107. int create_thread(int (*proc)(void *param), void *param, int stack_size);
  108.  
  109. void mutex_lock(volatile uint32_t *val);
  110.  
  111. static inline void mutex_unlock(volatile uint32_t *val)
  112. {
  113.     *val = 0;
  114. }
  115.  
  116. static inline void GetNotify(void *event)
  117. {
  118.     __asm__ __volatile__ (
  119.     "int $0x40"
  120.     ::"a"(68),"b"(14),"c"(event));
  121. }
  122.  
  123. static inline uint32_t check_os_event()
  124. {
  125.     uint32_t val;
  126.     __asm__ __volatile__(
  127.     "int $0x40"
  128.     :"=a"(val)
  129.     :"a"(11));
  130.     return val;
  131. };
  132.  
  133. static inline uint32_t get_os_button()
  134. {
  135.     uint32_t val;
  136.     __asm__ __volatile__(
  137.     "int $0x40"
  138.     :"=a"(val)
  139.     :"a"(17));
  140.     return val>>8;
  141. };
  142.  
  143. static inline void yield(void)
  144. {
  145.     __asm__ __volatile__(
  146.     "int $0x40"
  147.     ::"a"(68), "b"(1));
  148. };
  149.  
  150. static inline void delay(uint32_t time)
  151. {
  152.     __asm__ __volatile__(
  153.     "int $0x40"
  154.     ::"a"(5), "b"(time));
  155. };
  156.  
  157. static inline draw_bitmap(void *bitmap, int x, int y, int w, int h)
  158. {
  159.     __asm__ __volatile__(
  160.     "int $0x40"
  161.     ::"a"(7), "b"(bitmap),
  162.       "c"((w << 16) | h),
  163.       "d"((x << 16) | y));
  164. }
  165.  
  166. static inline void BeginDraw(void)
  167. {
  168.     __asm__ __volatile__(
  169.     "int $0x40" ::"a"(12),"b"(1));
  170. };
  171.  
  172. static inline void EndDraw(void)
  173. {
  174.     __asm__ __volatile__(
  175.     "int $0x40" ::"a"(12),"b"(2));
  176. };
  177.  
  178.  
  179. static inline void DrawWindow(int x, int y, int w, int h, char *name,
  180.                        color_t workcolor, uint32_t style)
  181. {
  182.  
  183.     __asm__ __volatile__(
  184.     "int $0x40"
  185.     ::"a"(0),
  186.       "b"((x << 16) | (w & 0xFFFF)),
  187.       "c"((y << 16) | (h & 0xFFFF)),
  188.       "d"((style << 24) | (workcolor & 0xFFFFFF)),
  189.       "D"(name));
  190. };
  191.  
  192. static inline void get_proc_info(char *info)
  193. {
  194.     __asm__ __volatile__(
  195.     "int $0x40"
  196.     ::"a"(9), "b"(info), "c"(-1)
  197.     :"memory");
  198. }
  199.  
  200. #define HW_BIT_BLIT         (1<<0)      /* BGRX blitter             */
  201. #define HW_TEX_BLIT         (1<<1)      /* stretch blit             */
  202. #define HW_VID_BLIT         (1<<2)      /* planar and packed video  */
  203.  
  204. uint32_t InitPixlib(uint32_t flags);
  205.  
  206. int create_bitmap(bitmap_t *bitmap);
  207. int resize_bitmap(bitmap_t *bitmap);
  208. int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
  209.                 int w, int h);
  210.  
  211.  
  212.