Rev 6106 | Rev 6118 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6106 | Rev 6117 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | #include "pixlib3.h" |
- | |
2 | #include |
1 | #include |
- | 2 | #include "pixlib3.h" |
|
Line 3... | Line 3... | ||
3 | 3 | ||
4 | #define BLACK_MAGIC_SOUND |
4 | #define BLACK_MAGIC_SOUND |
Line 5... | Line 5... | ||
5 | #define BLACK_MAGIC_VIDEO |
5 | #define BLACK_MAGIC_VIDEO |
6 | 6 | ||
Line 7... | Line 7... | ||
7 | typedef unsigned int color_t; |
7 | typedef unsigned int color_t; |
- | 8 | typedef unsigned int count_t; |
|
Line 8... | Line 9... | ||
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 | 12 | ||
Line 12... | Line 13... | ||
12 | #define HAS_LEFT (1<<0) |
13 | #define HAS_LEFT (1<<0) |
13 | #define HAS_TOP (1<<1) |
14 | #define HAS_TOP (1<<1) |
- | 15 | #define HAS_RIGHT (1<<2) |
|
14 | #define HAS_RIGHT (1<<2) |
16 | #define HAS_BOTTOM (1<<3) |
15 | #define HAS_BOTTOM (1<<3) |
17 | |
16 | 18 | struct render |
|
17 | struct render |
19 | { |
18 | { |
20 | vst_t *vst; |
Line 63... | Line 65... | ||
63 | #define ID_PROGRESS 102 |
65 | #define ID_PROGRESS 102 |
64 | #define ID_VOL_LEVEL 103 |
66 | #define ID_VOL_LEVEL 103 |
65 | #define ID_VOL_CTRL 104 |
67 | #define ID_VOL_CTRL 104 |
66 | 68 | ||
Line 67... | Line -... | ||
67 | - | ||
68 | typedef struct |
69 | typedef struct |
69 | { |
70 | { |
70 | mutex_t lock; |
71 | mutex_t lock; |
71 | char *buffer; |
72 | char *buffer; |
72 | int count; |
73 | int count; |
Line 87... | Line 88... | ||
87 | AVPacketList *first_pkt; |
88 | AVPacketList *first_pkt; |
88 | AVPacketList *last_pkt; |
89 | AVPacketList *last_pkt; |
89 | int size; |
90 | int size; |
90 | int count; |
91 | int count; |
91 | mutex_t lock; |
92 | mutex_t lock; |
92 | } queue_t; |
93 | } queue_t; |
93 | 94 | ||
Line 94... | Line 95... | ||
94 | int put_packet(queue_t *q, AVPacket *pkt); |
95 | int put_packet(queue_t *q, AVPacket *pkt); |
95 | int get_packet(queue_t *q, AVPacket *pkt); |
96 | int get_packet(queue_t *q, AVPacket *pkt); |
Line -... | Line 97... | ||
- | 97 | ||
- | 98 | struct vstate |
|
- | 99 | { |
|
- | 100 | AVFormatContext *fCtx; /* format context */ |
|
- | 101 | AVCodecContext *vCtx; /* video decoder context */ |
|
- | 102 | AVCodecContext *aCtx; /* audio decoder context */ |
|
- | 103 | AVCodec *vCodec; /* video codec */ |
|
- | 104 | AVCodec *aCodec; /* audio codec */ |
|
- | 105 | int vStream; /* video stream index */ |
|
- | 106 | int aStream; /* audio stream index */ |
|
- | 107 | ||
- | 108 | queue_t q_video; /* video packets queue */ |
|
- | 109 | queue_t q_audio; /* audio packets queue */ |
|
- | 110 | ||
- | 111 | mutex_t gpu_lock; /* gpu access lock. libdrm not yet thread safe :( */ |
|
- | 112 | ||
- | 113 | }; |
|
- | 114 | ||
Line 96... | Line 115... | ||
96 | 115 | ||
97 | 116 | ||
98 | #define DECODER_THREAD 1 |
117 | #define DECODER_THREAD 1 |
Line 99... | Line 118... | ||
99 | #define AUDIO_THREAD 2 |
118 | #define AUDIO_THREAD 2 |
100 | #define VIDEO_THREAD 4 |
119 | #define VIDEO_THREAD 4 |
101 | 120 | ||
Line 102... | Line 121... | ||
102 | extern int threads_running; |
121 | extern int threads_running; |
103 | extern astream_t astream; |
122 | extern astream_t astream; |
104 | extern AVRational video_time_base; |
123 | extern AVRational video_time_base; |
105 | 124 | ||
106 | render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags); |
125 | render_t *create_render(vst_t *vst, window_t *win, uint32_t flags); |
107 | void destroy_render(render_t *render); |
126 | void destroy_render(render_t *render); |
Line 114... | Line 133... | ||
114 | int init_audio(int format); |
133 | int init_audio(int format); |
115 | int audio_thread(void *param); |
134 | int audio_thread(void *param); |
116 | void set_audio_volume(int left, int right); |
135 | void set_audio_volume(int left, int right); |
Line 117... | Line 136... | ||
117 | 136 | ||
118 | int init_video(AVCodecContext *ctx); |
137 | int init_video(vst_t* vst); |
Line -... | Line 138... | ||
- | 138 | int video_thread(void *param); |
|
119 | int video_thread(void *param); |
139 | |
120 | 140 | void decoder(vst_t *vst); |
|
Line 121... | Line 141... | ||
121 | int decode_video(AVCodecContext *ctx, queue_t *qv); |
141 | int decode_video(vst_t* vst); |
Line 122... | Line 142... | ||
122 | int decode_audio(AVCodecContext *ctx, queue_t *qa); |
142 | int decode_audio(AVCodecContext *ctx, queue_t *qa); |