Rev 1696 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1696 | Rev 2349 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
4 | #include |
4 | #include |
5 | - | ||
- | 5 | #include "sound.h" |
|
6 | #include "fplay.h" |
6 | #include "fplay.h" |
Line 7... | Line -... | ||
7 | - | ||
8 | void video_thread(void *param); |
- | |
9 | - | ||
10 | void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
- | |
11 | { |
- | |
12 | __asm__ __volatile__( |
- | |
13 | "int $0x40" |
- | |
14 | ::"a"(7), "b"(bitmap), |
- | |
15 | "c"((w << 16) | h), |
- | |
16 | "d"((x << 16) | y)); |
- | |
Line 17... | Line 7... | ||
17 | } |
7 | |
18 | 8 | ||
19 | typedef struct |
9 | typedef struct |
20 | { |
- | |
21 | AVFrame *frame; |
10 | { |
22 | uint8_t *buffer; |
11 | AVPicture picture; |
23 | double pts; |
12 | double pts; |
Line 24... | Line 13... | ||
24 | volatile int ready; |
13 | volatile int ready; |
Line 25... | Line 14... | ||
25 | }vframe_t; |
14 | }vframe_t; |
Line 26... | Line 15... | ||
26 | 15 | ||
27 | vframe_t frames[8]; |
16 | vframe_t frames[4]; |
Line -... | Line 17... | ||
- | 17 | ||
- | 18 | struct SwsContext *cvt_ctx = NULL; |
|
28 | 19 | ||
29 | struct SwsContext *cvt_ctx; |
20 | int vfx = 0; |
Line 30... | Line 21... | ||
30 | 21 | int dfx = 0; |
|
31 | int vfx = 0; |
22 | |
Line -... | Line 23... | ||
- | 23 | render_t *render; |
|
- | 24 | ||
- | 25 | int width; |
|
- | 26 | int height; |
|
- | 27 | ||
32 | int dfx = 0; |
28 | AVRational video_time_base; |
33 | 29 | AVFrame *Frame; |
|
34 | int width; |
- | |
35 | int height; |
30 | |
Line 36... | Line 31... | ||
36 | 31 | volatile uint32_t driver_lock; |
|
37 | AVRational video_time_base; |
32 | |
Line 38... | Line 33... | ||
38 | AVFrame *Frame; |
33 | void get_client_rect(rect_t *rc); |
Line 39... | Line 34... | ||
39 | 34 | ||
- | 35 | ||
- | 36 | int init_video(AVCodecContext *ctx) |
|
- | 37 | { |
|
40 | int init_video(AVCodecContext *ctx) |
38 | int i; |
41 | { |
39 | |
42 | uint32_t size; |
40 | width = ctx->width; |
43 | int i; |
41 | height = ctx->height; |
44 | 42 | ||
Line 45... | Line 43... | ||
45 | width = ctx->width; |
43 | printf("w = %d h = %d\n\r", width, height); |
46 | height = ctx->height; |
- | |
47 | - | ||
48 | printf("w = %d h = %d\n\r", width, height); |
- | |
49 | - | ||
50 | Frame = avcodec_alloc_frame(); |
- | |
51 | if ( Frame == NULL ) |
- | |
52 | { |
- | |
53 | printf("Cannot alloc video buffer\n\r"); |
- | |
54 | return 0; |
44 | |
55 | }; |
45 | // __asm__ __volatile__("int3"); |
56 | 46 | ||
57 | cvt_ctx = sws_getContext( |
47 | render = create_render(ctx->width, ctx->height, |
58 | ctx->width, |
48 | ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT); |
59 | ctx->height, |
- | |
60 | ctx->pix_fmt, |
- | |
Line 61... | Line 49... | ||
61 | ctx->width, |
49 | if( render == NULL) |
62 | ctx->height, |
50 | { |
63 | PIX_FMT_BGR24, |
51 | printf("Cannot create render\n\r"); |
64 | SWS_BILINEAR, |
- | |
65 | NULL, NULL, NULL); |
- | |
Line 66... | Line 52... | ||
66 | if(cvt_ctx == NULL) |
52 | return 0; |
67 | { |
- | |
68 | printf("Cannot initialize the conversion context!\n"); |
53 | }; |
Line 69... | Line -... | ||
69 | return 0; |
- | |
70 | } |
- | |
71 | 54 | ||
72 | size = avpicture_get_size(PIX_FMT_RGB24, ctx->width, ctx->height); |
55 | Frame = avcodec_alloc_frame(); |
- | 56 | if ( Frame == NULL ) |
|
- | 57 | { |
|
- | 58 | printf("Cannot alloc video frame\n\r"); |
|
- | 59 | return 0; |
|
- | 60 | }; |
|
Line 73... | Line -... | ||
73 | - | ||
74 | for( i=0; i < 8; i++) |
- | |
75 | { |
61 | |
76 | AVFrame *frame; |
62 | for( i=0; i < 4; i++) |
77 | - | ||
78 | frame = avcodec_alloc_frame(); |
- | |
79 | - | ||
80 | if( frame ) |
- | |
81 | { |
- | |
82 | uint8_t *buffer = (uint8_t*)av_malloc(size); |
63 | { |
Line 83... | Line 64... | ||
83 | 64 | int ret; |
|
Line -... | Line 65... | ||
- | 65 | ||
84 | if( buffer ) |
66 | // printf("alloc picture %d %d %x\n", |
85 | { |
67 | // ctx->width, ctx->height, ctx->pix_fmt ); |
Line 86... | Line 68... | ||
86 | avpicture_fill((AVPicture *)frame, buffer, PIX_FMT_BGR24, |
68 | |
- | 69 | ret = avpicture_alloc(&frames[i].picture, ctx->pix_fmt, |
|
Line 87... | Line 70... | ||
87 | ctx->width, ctx->height); |
70 | ctx->width, ctx->height); |
88 | 71 | if ( ret != 0 ) |
|
- | 72 | { |
|
89 | frames[i].frame = frame; |
73 | printf("Cannot alloc video buffer\n\r"); |
90 | frames[i].buffer = buffer; |
- | |
91 | frames[i].pts = 0; |
- | |
92 | frames[i].ready = 0; |
74 | return 0; |
Line -... | Line 75... | ||
- | 75 | }; |
|
- | 76 | ||
- | 77 | frames[i].pts = 0; |
|
- | 78 | frames[i].ready = 0; |
|
- | 79 | }; |
|
- | 80 | ||
- | 81 | create_thread(video_thread, ctx, 1024*1024); |
|
- | 82 | ||
- | 83 | delay(50); |
|
- | 84 | return 1; |
|
- | 85 | }; |
|
- | 86 | ||
- | 87 | int frameFinished=0; |
|
93 | continue; |
88 | static int frame_count; |
- | 89 | ||
- | 90 | int decode_video(AVCodecContext *ctx, queue_t *qv) |
|
Line 94... | Line -... | ||
94 | }; |
- | |
95 | }; |
- | |
96 | printf("Cannot alloc frame buffer\n\r"); |
- | |
Line 97... | Line 91... | ||
97 | return 0; |
91 | { |
98 | }; |
92 | AVPacket pkt; |
99 | 93 | double pts; |
|
100 | create_thread(video_thread, 0, 163840); |
94 | double av_time; |
101 | 95 | ||
102 | return 1; |
96 | if(frames[dfx].ready != 0 ) |
103 | }; |
97 | return 1; |
Line 104... | Line 98... | ||
104 | 98 | ||
- | 99 | if( get_packet(qv, &pkt) == 0 ) |
|
Line 105... | Line 100... | ||
105 | int frameFinished=0; |
100 | return 0; |
106 | - | ||
107 | int decode_video(AVCodecContext *ctx, AVPacket *pkt) |
101 | |
- | 102 | frameFinished = 0; |
|
108 | { |
103 | |
Line 109... | Line -... | ||
109 | double pts; |
- | |
110 | AVPicture pict; |
- | |
111 | const uint8_t *data[4]; |
104 | ctx->reordered_opaque = pkt.pts; |
112 | double av_time; |
- | |
113 | - | ||
114 | // __asm__("int3"); |
- | |
115 | - | ||
116 | if(avcodec_decode_video(ctx, Frame, &frameFinished, |
- | |
117 | pkt->data, pkt->size) <= 0) |
- | |
118 | printf("decode error\n"); |
- | |
119 | - | ||
120 | if( pkt->dts == AV_NOPTS_VALUE && |
- | |
121 | Frame->reordered_opaque != AV_NOPTS_VALUE) |
- | |
122 | pts= Frame->reordered_opaque; |
- | |
Line 123... | Line 105... | ||
123 | else if(pkt->dts != AV_NOPTS_VALUE) |
105 | |
124 | pts= pkt->dts; |
106 | if(avcodec_decode_video2(ctx, Frame, &frameFinished, &pkt) <= 0) |
Line 125... | Line 107... | ||
125 | else |
107 | printf("video decoder error\n"); |
126 | pts= 0; |
108 | |
Line 127... | Line 109... | ||
127 | 109 | if(frameFinished) |
|
128 | pts *= av_q2d(video_time_base); |
110 | { |
129 | 111 | AVPicture *dst_pic; |
|
- | 112 | ||
Line 130... | Line 113... | ||
130 | if(frameFinished) |
113 | |
131 | { |
114 | if( pkt.dts == AV_NOPTS_VALUE && |
Line 132... | Line 115... | ||
132 | while( frames[dfx].ready != 0 ) |
115 | Frame->reordered_opaque != AV_NOPTS_VALUE) |
- | 116 | pts = Frame->reordered_opaque; |
|
Line 133... | Line -... | ||
133 | yield(); |
- | |
134 | - | ||
135 | pict.data[0] = frames[dfx].frame->data[0]; |
- | |
136 | pict.data[1] = frames[dfx].frame->data[1]; |
- | |
137 | pict.data[2] = frames[dfx].frame->data[2]; |
- | |
138 | pict.data[3] = NULL; |
- | |
139 | - | ||
140 | pict.linesize[0] = frames[dfx].frame->linesize[0]; |
- | |
141 | pict.linesize[1] = frames[dfx].frame->linesize[1]; |
- | |
142 | pict.linesize[2] = frames[dfx].frame->linesize[2]; |
- | |
143 | pict.linesize[3] = 0; |
- | |
144 | - | ||
145 | data[0] = Frame->data[0]; |
- | |
146 | data[1] = Frame->data[1]; |
- | |
147 | data[2] = Frame->data[2]; |
- | |
148 | data[3] = NULL; |
- | |
149 | - | ||
150 | sws_scale(cvt_ctx, data, Frame->linesize, 0, ctx->height, |
- | |
151 | pict.data, pict.linesize); |
117 | else if(pkt.dts != AV_NOPTS_VALUE) |
152 | 118 | pts= pkt.dts; |
|
153 | frames[dfx].pts = pts*1000.0; |
119 | else |
Line 154... | Line 120... | ||
154 | frames[dfx].ready = 1; |
120 | pts= 0; |
Line 155... | Line 121... | ||
155 | 121 | ||
156 | dfx++; |
122 | // pts = *(int64_t*)av_opt_ptr(avcodec_get_frame_class(), |
157 | dfx&= 7; |
123 | // Frame, "best_effort_timestamp"); |
- | 124 | ||
- | 125 | // if (pts == AV_NOPTS_VALUE) |
|
158 | }; |
126 | // pts = 0; |
- | 127 | ||
159 | 128 | pts *= av_q2d(video_time_base); |
|
Line 160... | Line 129... | ||
160 | return 0; |
129 | |
161 | } |
130 | dst_pic = &frames[dfx].picture; |
162 | 131 | ||
Line 200... | Line 169... | ||
200 | return 1; |
169 | return 1; |
201 | } |
170 | } |
202 | 171 | ||
Line 203... | Line 172... | ||
203 | 172 | ||
Line 204... | Line 173... | ||
204 | extern char __cmdline[]; |
173 | extern char *movie_file; |
205 | 174 | ||
206 | void video_thread(void *param) |
175 | int video_thread(void *param) |
- | 176 | { |
|
Line 207... | Line 177... | ||
207 | { |
177 | rect_t rc; |
- | 178 | AVCodecContext *ctx = param; |
|
- | 179 | ||
Line 208... | Line 180... | ||
208 | char *path; |
180 | BeginDraw(); |
Line 209... | Line 181... | ||
209 | 181 | DrawWindow(10, 10, width+9, height+26, movie_file, 0x000000,0x73); |
|
210 | path = strrchr(__cmdline,'/')+1; |
182 | EndDraw(); |
211 | 183 | ||
212 | DrawWindow(10, 10, width+9, height+26, path, 0x000000,0x74); |
184 | render_adjust_size(render); |
Line 221... | Line 193... | ||
221 | if(frames[vfx].ready == 1 ) |
193 | if(frames[vfx].ready == 1 ) |
222 | { |
194 | { |
223 | ctime = get_master_clock(); |
195 | ctime = get_master_clock(); |
224 | fdelay = (frames[vfx].pts - ctime); |
196 | fdelay = (frames[vfx].pts - ctime); |
- | 197 | ||
225 | // printf("ctime %f pts %f delay %f\n", |
198 | // printf("pts %f time %f delay %f\n", |
226 | // ctime, frames[vfx].pts, fdelay); |
199 | // frames[vfx].pts, ctime, fdelay); |
Line 227... | Line 200... | ||
227 | 200 | ||
228 | if(fdelay < 0.0 ) |
201 | if(fdelay < 0.0 ) |
229 | { |
202 | { |
230 | int next_vfx; |
203 | int next_vfx; |
231 | fdelay = 0; |
204 | fdelay = 0; |
232 | next_vfx = (vfx+1) & 7; |
205 | next_vfx = (vfx+1) & 3; |
233 | if( frames[next_vfx].ready == 1 ) |
206 | if( frames[next_vfx].ready == 1 ) |
234 | { |
207 | { |
235 | if(frames[next_vfx].pts <= ctime) |
208 | if(frames[next_vfx].pts <= ctime) |
236 | { |
209 | { |
237 | frames[vfx].ready = 0; // skip this frame |
210 | frames[vfx].ready = 0; // skip this frame |
238 | vfx++; |
211 | vfx++; |
239 | vfx&= 7; |
212 | vfx&= 3; |
240 | } |
213 | } |
241 | else |
214 | else |
242 | { |
215 | { |
243 | if( (frames[next_vfx].pts - ctime) < |
216 | if( (frames[next_vfx].pts - ctime) < |
244 | ( ctime - frames[vfx].pts) ) |
217 | ( ctime - frames[vfx].pts) ) |
245 | { |
218 | { |
246 | frames[vfx].ready = 0; // skip this frame |
219 | frames[vfx].ready = 0; // skip this frame |
247 | vfx++; |
220 | vfx++; |
248 | vfx&= 7; |
221 | vfx&= 3; |
249 | fdelay = (frames[next_vfx].pts - ctime); |
222 | fdelay = (frames[next_vfx].pts - ctime); |
250 | } |
223 | } |
251 | } |
224 | } |
252 | }; |
225 | }; |
Line 256... | Line 229... | ||
256 | { |
229 | { |
257 | delay( (uint32_t)(fdelay/10.0)); |
230 | delay( (uint32_t)(fdelay/10.0)); |
258 | }; |
231 | }; |
259 | 232 | ||
Line 260... | Line 233... | ||
260 | draw_bitmap(frames[vfx].buffer, 0, 0, width, height); |
233 | // blit_bitmap(&frames[vfx].bitmap, 5, 22, width, height); |
- | 234 | // frames[vfx].frame->linesize[0]); |
|
- | 235 | render->draw(render, &frames[vfx].picture); |
|
261 | frames[vfx].ready = 0; |
236 | frames[vfx].ready = 0; |
262 | vfx++; |
237 | vfx++; |
263 | vfx&= 7; |
238 | vfx&= 3; |
264 | } |
239 | } |
265 | else |
240 | else |
266 | { |
241 | { |
267 | yield(); |
242 | yield(); |
268 | }; |
243 | }; |
269 | }; |
244 | }; |
- | 245 | return 0; |
|
270 | }; |
246 | }; |
Line -... | Line 247... | ||
- | 247 | ||
- | 248 | ||
- | 249 | void draw_hw_picture(render_t *render, AVPicture *picture); |
|
- | 250 | void draw_sw_picture(render_t *render, AVPicture *picture); |
|
- | 251 | ||
- | 252 | render_t *create_render(uint32_t width, uint32_t height, |
|
- | 253 | uint32_t ctx_format, uint32_t flags) |
|
- | 254 | { |
|
- | 255 | render_t *ren; |
|
- | 256 | ||
- | 257 | render = (render_t*)malloc(sizeof(*ren)); |
|
- | 258 | memset(ren, 0, sizeof(*ren)); |
|
- | 259 | ||
- | 260 | render->ctx_width = width; |
|
- | 261 | render->ctx_height = height; |
|
- | 262 | render->ctx_format = ctx_format; |
|
- | 263 | ||
- | 264 | mutex_lock(&driver_lock); |
|
- | 265 | render->caps = InitPixlib(flags); |
|
- | 266 | mutex_unlock(&driver_lock); |
|
- | 267 | ||
- | 268 | if(render->caps==0) |
|
- | 269 | { |
|
- | 270 | printf("FPlay render engine: Hardware acceleration disabled\n"); |
|
- | 271 | render->draw = draw_sw_picture; |
|
- | 272 | } |
|
- | 273 | else |
|
- | 274 | { |
|
- | 275 | render->target = 0; |
|
- | 276 | render->draw = draw_hw_picture; |
|
- | 277 | }; |
|
- | 278 | ||
- | 279 | render->state = EMPTY; |
|
- | 280 | return render; |
|
- | 281 | }; |
|
- | 282 | ||
- | 283 | int render_set_size(render_t *render, int width, int height) |
|
- | 284 | { |
|
- | 285 | int i; |
|
- | 286 | ||
- | 287 | render->win_width = width; |
|
- | 288 | render->win_height = height; |
|
- | 289 | render->win_state = NORMAL; |
|
- | 290 | ||
- | 291 | // printf("%s %dx%d\n",__FUNCTION__, width, height); |
|
- | 292 | ||
- | 293 | if(render->state == EMPTY) |
|
- | 294 | { |
|
- | 295 | if(render->caps & HW_TEX_BLIT) |
|
- | 296 | { |
|
- | 297 | for( i=0; i < 4; i++) |
|
- | 298 | { |
|
- | 299 | render->bitmap[i].width = render->ctx_width; |
|
- | 300 | render->bitmap[i].height = render->ctx_height; |
|
- | 301 | ||
- | 302 | if( create_bitmap(&render->bitmap[i]) != 0 ) |
|
- | 303 | { |
|
- | 304 | status = 0; |
|
- | 305 | /* |
|
- | 306 | * Epic fail. Need exit_thread() here |
|
- | 307 | * |
|
- | 308 | */ |
|
- | 309 | return 0; |
|
- | 310 | }; |
|
- | 311 | } |
|
- | 312 | } |
|
- | 313 | else |
|
- | 314 | { |
|
- | 315 | render->bitmap[0].width = width; |
|
- | 316 | render->bitmap[0].height = height; |
|
- | 317 | ||
- | 318 | if( create_bitmap(&render->bitmap[0]) != 0 ) |
|
- | 319 | return 0; |
|
- | 320 | }; |
|
- | 321 | render->state = INIT; |
|
- | 322 | return 0; |
|
- | 323 | }; |
|
- | 324 | ||
- | 325 | if(render->caps & HW_TEX_BLIT) /* hw scaler */ |
|
- | 326 | return 0; |
|
- | 327 | ||
- | 328 | render->bitmap[0].width = width; |
|
- | 329 | render->bitmap[0].height = height; |
|
- | 330 | resize_bitmap(&render->bitmap[0]); |
|
- | 331 | ||
- | 332 | return 0; |
|
- | 333 | }; |
|
- | 334 | ||
- | 335 | void render_adjust_size(render_t *render) |
|
- | 336 | { |
|
- | 337 | char proc_info[1024]; |
|
- | 338 | ||
- | 339 | uint32_t right, bottom, new_w, new_h; |
|
- | 340 | uint32_t s, sw, sh; |
|
- | 341 | uint8_t state; |
|
- | 342 | ||
- | 343 | get_proc_info(proc_info); |
|
- | 344 | ||
- | 345 | right = *(uint32_t*)(proc_info+62)+1; |
|
- | 346 | bottom = *(uint32_t*)(proc_info+66)+1; |
|
- | 347 | state = *(uint8_t*)(proc_info+70); |
|
- | 348 | ||
- | 349 | if(state & 2) |
|
- | 350 | { render->win_state = MINIMIZED; |
|
- | 351 | return; |
|
- | 352 | } |
|
- | 353 | if(state & 4) |
|
- | 354 | { |
|
- | 355 | render->win_state = ROLLED; |
|
- | 356 | return; |
|
- | 357 | }; |
|
- | 358 | ||
- | 359 | render->win_state = NORMAL; |
|
- | 360 | ||
- | 361 | if( right == render->win_width && |
|
- | 362 | bottom == render->win_height) |
|
- | 363 | return; |
|
- | 364 | ||
- | 365 | new_w = bottom*render->ctx_width/render->ctx_height; |
|
- | 366 | new_h = right*render->ctx_height/render->ctx_width; |
|
- | 367 | ||
- | 368 | // printf("right %d bottom %d\n", right, bottom); |
|
- | 369 | // printf("new_w %d new_h %d\n", new_w, new_h); |
|
- | 370 | ||
- | 371 | s = right * bottom; |
|
- | 372 | sw = right * new_h; |
|
- | 373 | sh = bottom * new_w; |
|
- | 374 | ||
- | 375 | if( abs(s-sw) > abs(s-sh)) |
|
- | 376 | new_h = bottom; |
|
- | 377 | else |
|
- | 378 | new_w = right; |
|
- | 379 | ||
- | 380 | if(new_w < 64) |
|
- | 381 | { |
|
- | 382 | new_w = 64; |
|
- | 383 | new_h = 64*render->ctx_height/render->ctx_width; |
|
- | 384 | }; |
|
- | 385 | __asm__ __volatile__( |
|
- | 386 | "int $0x40" |
|
- | 387 | ::"a"(67), "b"(-1), "c"(-1), |
|
- | 388 | "d"(new_w+9),"S"(new_h+26) |
|
- | 389 | :"memory" ); |
|
- | 390 | render_set_size(render, new_w, new_h); |
|
- | 391 | ||
- | 392 | }; |
|
- | 393 | ||
- | 394 | void draw_hw_picture(render_t *render, AVPicture *picture) |
|
- | 395 | { |
|
- | 396 | int dst_width, dst_height; |
|
- | 397 | uint8_t *data[4]; |
|
- | 398 | int linesize[4]; |
|
- | 399 | ||
- | 400 | if(render->win_state != NORMAL) |
|
- | 401 | return; |
|
- | 402 | ||
- | 403 | if(render->caps & HW_TEX_BLIT) |
|
- | 404 | { |
|
- | 405 | dst_width = render->ctx_width; |
|
- | 406 | dst_height = render->ctx_height; |
|
- | 407 | } |
|
- | 408 | else |
|
- | 409 | { |
|
- | 410 | dst_width = render->win_width; |
|
- | 411 | dst_height = render->win_height; |
|
- | 412 | }; |
|
- | 413 | ||
- | 414 | cvt_ctx = sws_getCachedContext(cvt_ctx, |
|
- | 415 | render->ctx_width, render->ctx_height, render->ctx_format, |
|
- | 416 | dst_width, dst_height, PIX_FMT_BGRA, |
|
- | 417 | SWS_FAST_BILINEAR, NULL, NULL, NULL); |
|
- | 418 | if(cvt_ctx == NULL) |
|
- | 419 | { |
|
- | 420 | printf("Cannot initialize the conversion context!\n"); |
|
- | 421 | return ; |
|
- | 422 | }; |
|
- | 423 | // printf("sws_getCachedContext\n"); |
|
- | 424 | data[0] = render->bitmap[render->target].data; |
|
- | 425 | data[1] = render->bitmap[render->target].data+1; |
|
- | 426 | data[2] = render->bitmap[render->target].data+2; |
|
- | 427 | data[3] = render->bitmap[render->target].data+3; |
|
- | 428 | ||
- | 429 | linesize[0] = render->bitmap[render->target].pitch; |
|
- | 430 | linesize[1] = render->bitmap[render->target].pitch; |
|
- | 431 | linesize[2] = render->bitmap[render->target].pitch; |
|
- | 432 | linesize[3] = render->bitmap[render->target].pitch; |
|
- | 433 | ||
- | 434 | sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, |
|
- | 435 | picture->linesize, 0, render->ctx_height, data, linesize); |
|
- | 436 | // printf("sws_scale\n"); |
|
- | 437 | ||
- | 438 | blit_bitmap(&render->bitmap[render->target], 5, 22, |
|
- | 439 | render->win_width, render->win_height); |
|
- | 440 | // printf("blit_bitmap\n"); |
|
- | 441 | ||
- | 442 | delay(2); |
|
- | 443 | render->target++; |
|
- | 444 | render->target&= 3; |
|
- | 445 | } |
|
- | 446 | ||
- | 447 | void draw_sw_picture(render_t *render, AVPicture *picture) |
|
- | 448 | { |
|
- | 449 | uint8_t *data[4]; |
|
- | 450 | int linesize[4]; |
|
- | 451 | ||
- | 452 | if(render->win_state != NORMAL) |
|
- | 453 | return; |
|
- | 454 | ||
- | 455 | cvt_ctx = sws_getCachedContext(cvt_ctx, |
|
- | 456 | render->ctx_width, render->ctx_height, |
|
- | 457 | render->ctx_format, |
|
- | 458 | render->win_width, render->win_height, |
|
- | 459 | PIX_FMT_BGRA, SWS_FAST_BILINEAR, NULL, NULL, NULL); |
|
- | 460 | if(cvt_ctx == NULL) |
|
- | 461 | { |
|
- | 462 | printf("Cannot initialize the conversion context!\n"); |
|
- | 463 | return ; |
|
- | 464 | } |
|
- | 465 | ||
- | 466 | data[0] = render->bitmap[0].data; |
|
- | 467 | data[1] = render->bitmap[0].data+1; |
|
- | 468 | data[2] = render->bitmap[0].data+2; |
|
- | 469 | data[3] = render->bitmap[0].data+3; |
|
- | 470 | ||
- | 471 | ||
- | 472 | linesize[0] = render->bitmap[0].pitch; |
|
- | 473 | linesize[1] = render->bitmap[0].pitch; |
|
- | 474 | linesize[2] = render->bitmap[0].pitch; |
|
- | 475 | linesize[3] = render->bitmap[0].pitch; |
|
- | 476 | ||
- | 477 | sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, |
|
- | 478 | picture->linesize, 0, render->ctx_height, data, linesize); |
|
- | 479 | ||
- | 480 | blit_bitmap(&render->bitmap[0], 5, 22, |
|
- | 481 | render->win_width, render->win_height); |
|
- | 482 | }>> |
|
- | 483 | >=>>=>> |
|
- | 484 | ||
- | 485 | ||
- | 486 | ||
- | 487 |