Rev 6118 | Rev 6133 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6118 | Rev 6121 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | #include "pixlib3.h" |
2 | #include "pixlib3.h" |
3 | 3 | ||
4 | #define BLACK_MAGIC_SOUND |
4 | #define BLACK_MAGIC_SOUND |
5 | #define BLACK_MAGIC_VIDEO |
5 | #define BLACK_MAGIC_VIDEO |
6 | 6 | ||
7 | typedef unsigned int color_t; |
7 | typedef unsigned int color_t; |
8 | typedef unsigned int count_t; |
8 | typedef unsigned int count_t; |
9 | 9 | ||
10 | typedef struct render render_t; |
10 | typedef struct render render_t; |
11 | typedef struct vstate vst_t; |
11 | typedef struct vstate vst_t; |
12 | 12 | ||
13 | #define HAS_LEFT (1<<0) |
13 | #define HAS_LEFT (1<<0) |
14 | #define HAS_TOP (1<<1) |
14 | #define HAS_TOP (1<<1) |
15 | #define HAS_RIGHT (1<<2) |
15 | #define HAS_RIGHT (1<<2) |
16 | #define HAS_BOTTOM (1<<3) |
16 | #define HAS_BOTTOM (1<<3) |
17 | 17 | ||
- | 18 | typedef struct |
|
- | 19 | { |
|
- | 20 | enum AVPixelFormat format; |
|
- | 21 | AVPicture picture; |
|
- | 22 | int planar; |
|
- | 23 | double pts; |
|
- | 24 | volatile int ready; |
|
- | 25 | }vframe_t; |
|
- | 26 | ||
18 | struct render |
27 | struct render |
19 | { |
28 | { |
20 | vst_t *vst; |
29 | vst_t *vst; |
21 | uint32_t caps; |
30 | uint32_t caps; |
22 | uint32_t ctx_width; |
31 | uint32_t ctx_width; |
23 | uint32_t ctx_height; |
32 | uint32_t ctx_height; |
24 | uint32_t win_width; |
33 | uint32_t win_width; |
25 | uint32_t win_height; |
34 | uint32_t win_height; |
26 | 35 | ||
27 | rect_t rc_client; |
36 | rect_t rc_client; |
28 | rect_t rcvideo; |
37 | rect_t rcvideo; |
29 | rect_t rcleft; |
38 | rect_t rcleft; |
30 | rect_t rctop; |
39 | rect_t rctop; |
31 | rect_t rcright; |
40 | rect_t rcright; |
32 | rect_t rcbottom; |
41 | rect_t rcbottom; |
33 | 42 | ||
34 | uint32_t layout; |
43 | uint32_t layout; |
35 | bitmap_t *bitmap[4]; |
44 | bitmap_t *bitmap[4]; |
36 | bitmap_t *last_bitmap; |
45 | bitmap_t *last_bitmap; |
37 | 46 | ||
38 | uint32_t ctx_format; |
47 | uint32_t ctx_format; |
39 | int target; |
48 | int target; |
40 | 49 | ||
41 | window_t *win; |
50 | window_t *win; |
42 | enum{ |
51 | enum{ |
43 | EMPTY, INIT }state; |
52 | EMPTY, INIT }state; |
44 | enum win_state win_state; |
53 | enum win_state win_state; |
45 | 54 | ||
46 | void (*draw)(render_t *render, AVPicture *picture); |
55 | void (*draw)(render_t *render, AVPicture *picture); |
47 | }; |
56 | }; |
48 | 57 | ||
49 | enum player_state |
58 | enum player_state |
50 | { |
59 | { |
51 | CLOSED = 0, |
60 | CLOSED = 0, |
52 | PREPARE, |
61 | PREPARE, |
53 | STOP, |
62 | STOP, |
54 | PAUSE, |
63 | PAUSE, |
55 | PLAY, |
64 | PLAY, |
56 | REWIND, |
65 | REWIND, |
57 | PLAY_2_STOP, |
66 | PLAY_2_STOP, |
58 | PLAY_2_PAUSE, |
67 | PLAY_2_PAUSE, |
59 | PAUSE_2_PLAY, |
68 | PAUSE_2_PLAY, |
60 | REWIND_2_PLAY, |
69 | REWIND_2_PLAY, |
61 | }; |
70 | }; |
62 | 71 | ||
63 | #define ID_PLAY 100 |
72 | #define ID_PLAY 100 |
64 | #define ID_STOP 101 |
73 | #define ID_STOP 101 |
65 | #define ID_PROGRESS 102 |
74 | #define ID_PROGRESS 102 |
66 | #define ID_VOL_LEVEL 103 |
75 | #define ID_VOL_LEVEL 103 |
67 | #define ID_VOL_CTRL 104 |
76 | #define ID_VOL_CTRL 104 |
68 | 77 | ||
69 | typedef struct |
78 | typedef struct |
70 | { |
79 | { |
71 | mutex_t lock; |
80 | mutex_t lock; |
72 | char *buffer; |
81 | char *buffer; |
73 | int count; |
82 | int count; |
74 | }astream_t; |
83 | }astream_t; |
75 | 84 | ||
76 | typedef struct |
85 | typedef struct |
77 | { |
86 | { |
78 | unsigned int code; |
87 | unsigned int code; |
79 | unsigned int sender; |
88 | unsigned int sender; |
80 | unsigned int stream; |
89 | unsigned int stream; |
81 | unsigned int offset; |
90 | unsigned int offset; |
82 | unsigned int size; |
91 | unsigned int size; |
83 | unsigned int unused[2]; |
92 | unsigned int unused[2]; |
84 | }SND_EVENT; |
93 | }SND_EVENT; |
85 | 94 | ||
86 | 95 | ||
87 | typedef struct { |
96 | typedef struct { |
88 | AVPacketList *first_pkt; |
97 | AVPacketList *first_pkt; |
89 | AVPacketList *last_pkt; |
98 | AVPacketList *last_pkt; |
90 | int size; |
99 | int size; |
91 | int count; |
100 | int count; |
92 | mutex_t lock; |
101 | mutex_t lock; |
93 | } queue_t; |
102 | } queue_t; |
94 | 103 | ||
95 | int put_packet(queue_t *q, AVPacket *pkt); |
104 | int put_packet(queue_t *q, AVPacket *pkt); |
96 | int get_packet(queue_t *q, AVPacket *pkt); |
105 | int get_packet(queue_t *q, AVPacket *pkt); |
97 | 106 | ||
98 | struct vstate |
107 | struct vstate |
99 | { |
108 | { |
100 | AVFormatContext *fCtx; /* format context */ |
109 | AVFormatContext *fCtx; /* format context */ |
101 | AVCodecContext *vCtx; /* video decoder context */ |
110 | AVCodecContext *vCtx; /* video decoder context */ |
102 | AVCodecContext *aCtx; /* audio decoder context */ |
111 | AVCodecContext *aCtx; /* audio decoder context */ |
103 | AVCodec *vCodec; /* video codec */ |
112 | AVCodec *vCodec; /* video codec */ |
104 | AVCodec *aCodec; /* audio codec */ |
113 | AVCodec *aCodec; /* audio codec */ |
105 | int vStream; /* video stream index */ |
114 | int vStream; /* video stream index */ |
106 | int aStream; /* audio stream index */ |
115 | int aStream; /* audio stream index */ |
107 | 116 | ||
108 | queue_t q_video; /* video packets queue */ |
117 | queue_t q_video; /* video packets queue */ |
109 | queue_t q_audio; /* audio packets queue */ |
118 | queue_t q_audio; /* audio packets queue */ |
110 | 119 | ||
111 | mutex_t gpu_lock; /* gpu access lock. libdrm not yet thread safe :( */ |
120 | mutex_t gpu_lock; /* gpu access lock. libdrm not yet thread safe :( */ |
112 | 121 | ||
- | 122 | vframe_t vframe[4]; /* decoder workset */ |
|
113 | int vfx; /* index of decoded frame */ |
123 | int vfx; /* index of decoded frame */ |
114 | int dfx; /* index of renderd frame */ |
124 | int dfx; /* index of renderd frame */ |
115 | - | ||
- | 125 | void *hwCtx; /* hardware context */ |
|
- | 126 | int hwdec; /* hardware decoder */ |
|
116 | }; |
127 | }; |
117 | 128 | ||
118 | 129 | ||
119 | - | ||
120 | #define DECODER_THREAD 1 |
130 | #define DECODER_THREAD 1 |
121 | #define AUDIO_THREAD 2 |
131 | #define AUDIO_THREAD 2 |
122 | #define VIDEO_THREAD 4 |
132 | #define VIDEO_THREAD 4 |
123 | 133 | ||
124 | extern int threads_running; |
134 | extern int threads_running; |
125 | extern astream_t astream; |
135 | extern astream_t astream; |
126 | extern AVRational video_time_base; |
136 | extern AVRational video_time_base; |
127 | 137 | ||
128 | render_t *create_render(vst_t *vst, window_t *win, uint32_t flags); |
138 | render_t *create_render(vst_t *vst, window_t *win, uint32_t flags); |
129 | void destroy_render(render_t *render); |
139 | void destroy_render(render_t *render); |
130 | int init_render(render_t *render, int width, int height); |
140 | int init_render(render_t *render, int width, int height); |
131 | void render_adjust_size(render_t *render, window_t *win); |
141 | void render_adjust_size(render_t *render, window_t *win); |
132 | void render_set_size(render_t *render, int width, int height); |
142 | void render_set_size(render_t *render, int width, int height); |
133 | void render_draw_client(render_t *render); |
143 | void render_draw_client(render_t *render); |
134 | 144 | ||
135 | int fplay_init_context(vst_t *vst); |
145 | int fplay_init_context(vst_t *vst); |
136 | 146 | ||
137 | int init_audio(int format); |
147 | int init_audio(int format); |
138 | int audio_thread(void *param); |
148 | int audio_thread(void *param); |
139 | void set_audio_volume(int left, int right); |
149 | void set_audio_volume(int left, int right); |
140 | 150 | ||
141 | int init_video(vst_t* vst); |
151 | int init_video(vst_t* vst); |
142 | int video_thread(void *param); |
152 | int video_thread(void *param); |
143 | 153 | ||
144 | void decoder(vst_t *vst); |
154 | void decoder(vst_t *vst); |
145 | int decode_video(vst_t* vst); |
155 | int decode_video(vst_t* vst); |
146 | int decode_audio(AVCodecContext *ctx, queue_t *qa); |
156 | int decode_audio(AVCodecContext *ctx, queue_t *qa); |
147 | 157 | ||
148 | double get_master_clock(void); |
158 | double get_master_clock(void); |
149 | 159 | ||
150 | static inline void GetNotify(void *event) |
160 | static inline void GetNotify(void *event) |
151 | { |
161 | { |
152 | __asm__ __volatile__ ( |
162 | __asm__ __volatile__ ( |
153 | "int $0x40" |
163 | "int $0x40" |
154 | ::"a"(68),"b"(14),"c"(event)); |
164 | ::"a"(68),"b"(14),"c"(event)); |
155 | } |
165 | } |
156 | 166 | ||
157 | int fplay_vaapi_init(void); |
- | |
158 | void va_convert_picture(vst_t *vst, int width, int height, AVPicture *pic); |
167 | void va_convert_picture(vst_t *vst, int width, int height, AVPicture *pic); |
159 | 168 | ||
160 | int init_fontlib(); |
169 | int init_fontlib(); |
161 | char *get_moviefile();3) |
170 | char *get_moviefile();3) |
162 | 171 | ||
163 | struct><3) |
172 | typedef><3) |
164 | 173 | ||
165 | struct>2) |
174 | typedef>2) |
166 | #define><2) |
175 | #define><2) |
167 | #define>1) |
176 | #define>1) |
168 | #define><1) |
177 | #define><1) |
169 | #define>0) |
178 | #define>0) |
170 | #define><0) |
179 | #define><0) |
171 | #define> |
180 | #define> |