Rev 6106 | Rev 6118 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6106 | Rev 6117 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | 45 | ||
Line 46... | Line 46... | ||
46 | AVRational video_time_base; |
46 | AVRational video_time_base; |
47 | AVFrame *Frame; |
47 | AVFrame *Frame; |
Line 48... | Line -... | ||
48 | - | ||
49 | extern mutex_t driver_lock; |
- | |
50 | 48 | ||
Line 51... | Line 49... | ||
51 | void get_client_rect(rect_t *rc); |
49 | void get_client_rect(rect_t *rc); |
52 | 50 | ||
53 | void flush_video() |
51 | void flush_video() |
Line 63... | Line 61... | ||
63 | vfx = 0; |
61 | vfx = 0; |
64 | dfx = 0; |
62 | dfx = 0; |
65 | }; |
63 | }; |
66 | 64 | ||
Line 67... | Line 65... | ||
67 | int init_video(AVCodecContext *ctx) |
65 | int init_video(vst_t *vst) |
68 | { |
66 | { |
69 | int i; |
67 | int i; |
Line 70... | Line 68... | ||
70 | 68 | ||
71 | width = ctx->width; |
69 | width = vst->vCtx->width; |
Line 72... | Line 70... | ||
72 | height = ctx->height; |
70 | height = vst->vCtx->height; |
73 | 71 | ||
74 | Frame = avcodec_alloc_frame(); |
72 | Frame = av_frame_alloc(); |
75 | if ( Frame == NULL ) |
73 | if ( Frame == NULL ) |
76 | { |
74 | { |
77 | printf("Cannot alloc video frame\n\r"); |
75 | printf("Cannot alloc video frame\n\r"); |
Line 78... | Line 76... | ||
78 | return 0; |
76 | return 0; |
79 | }; |
77 | }; |
80 | 78 | ||
Line 81... | Line 79... | ||
81 | for( i=0; i < 4; i++) |
79 | for( i=0; i < 4; i++) |
82 | { |
80 | { |
83 | int ret; |
81 | int ret; |
84 | 82 | ||
85 | ret = avpicture_alloc(&frames[i].picture, ctx->pix_fmt, |
83 | ret = avpicture_alloc(&frames[i].picture, vst->vCtx->pix_fmt, |
86 | ctx->width, ctx->height); |
84 | vst->vCtx->width, vst->vCtx->height); |
87 | if ( ret != 0 ) |
85 | if ( ret != 0 ) |
Line 88... | Line 86... | ||
88 | { |
86 | { |
89 | printf("Cannot alloc video buffer\n\r"); |
87 | printf("Cannot alloc video buffer\n\r"); |
90 | return 0; |
88 | return 0; |
Line 91... | Line 89... | ||
91 | }; |
89 | }; |
Line 92... | Line 90... | ||
92 | 90 | ||
93 | frames[i].pts = 0; |
91 | frames[i].pts = 0; |
94 | frames[i].ready = 0; |
92 | frames[i].ready = 0; |
Line 95... | Line 93... | ||
95 | }; |
93 | }; |
96 | 94 | ||
97 | create_thread(video_thread, ctx, 1024*1024); |
95 | create_thread(video_thread, vst, 1024*1024); |
98 | 96 | ||
99 | delay(50); |
97 | delay(50); |
100 | return 1; |
98 | return 1; |
Line 101... | Line 99... | ||
101 | }; |
99 | }; |
102 | 100 | ||
Line 103... | Line 101... | ||
103 | int decode_video(AVCodecContext *ctx, queue_t *qv) |
101 | int decode_video(vst_t* vst) |
104 | { |
102 | { |
Line 105... | Line 103... | ||
105 | AVPacket pkt; |
103 | AVPacket pkt; |
106 | double pts; |
104 | double pts; |
Line 130... | Line 128... | ||
130 | if( 1 /*pts > current_clock*/) |
128 | if( 1 /*pts > current_clock*/) |
131 | { |
129 | { |
132 | frameFinished = 0; |
130 | frameFinished = 0; |
133 | 131 | ||
Line 134... | Line 132... | ||
134 | ctx->reordered_opaque = pkt.pts; |
132 | vst->vCtx->reordered_opaque = pkt.pts; |
- | 133 | ||
- | 134 | mutex_lock(&vst->gpu_lock); |
|
Line 135... | Line 135... | ||
135 | 135 | ||
136 | if(avcodec_decode_video2(ctx, Frame, &frameFinished, &pkt) <= 0) |
136 | if(avcodec_decode_video2(vst->vCtx, Frame, &frameFinished, &pkt) <= 0) |
Line 137... | Line 137... | ||
137 | printf("video decoder error\n"); |
137 | printf("video decoder error\n"); |
138 | 138 | ||
139 | if(frameFinished) |
139 | if(frameFinished) |
Line 153... | Line 153... | ||
153 | dst_pic = &frames[dfx].picture; |
153 | dst_pic = &frames[dfx].picture; |
Line 154... | Line 154... | ||
154 | 154 | ||
155 | av_image_copy(dst_pic->data, dst_pic->linesize, |
155 | av_image_copy(dst_pic->data, dst_pic->linesize, |
156 | (const uint8_t**)Frame->data, |
156 | (const uint8_t**)Frame->data, |
Line 157... | Line 157... | ||
157 | Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height); |
157 | Frame->linesize, vst->vCtx->pix_fmt, vst->vCtx->width, vst->vCtx->height); |
Line 158... | Line 158... | ||
158 | 158 | ||
Line 159... | Line 159... | ||
159 | frames[dfx].pts = pts*1000.0; |
159 | frames[dfx].pts = pts*1000.0; |
160 | 160 | ||
161 | frames[dfx].ready = 1; |
161 | frames[dfx].ready = 1; |
162 | 162 | ||
- | 163 | dfx++; |
|
- | 164 | dfx&= 3; |
|
163 | dfx++; |
165 | frames_count++; |
164 | dfx&= 3; |
166 | }; |
Line 165... | Line 167... | ||
165 | frames_count++; |
167 | mutex_unlock(&vst->gpu_lock); |
166 | }; |
168 | |
Line 384... | Line 386... | ||
384 | }; |
386 | }; |
385 | 387 | ||
Line 386... | Line 388... | ||
386 | #define VERSION_A 1 |
388 | #define VERSION_A 1 |
Line 387... | Line -... | ||
387 | - | ||
388 | extern queue_t q_video; |
- | |
389 | extern queue_t q_audio; |
- | |
390 | 389 | ||
391 | void render_time(render_t *render) |
390 | void render_time(render_t *render) |
392 | { |
391 | { |
393 | progress_t *prg = main_render->win->panel.prg; |
392 | progress_t *prg = main_render->win->panel.prg; |
Line 545... | Line 544... | ||
545 | extern char *movie_file; |
544 | extern char *movie_file; |
Line 546... | Line 545... | ||
546 | 545 | ||
547 | int video_thread(void *param) |
546 | int video_thread(void *param) |
548 | { |
547 | { |
549 | AVCodecContext *ctx = param; |
548 | vst_t *vst = param; |
Line 550... | Line 549... | ||
550 | window_t *MainWindow; |
549 | window_t *MainWindow; |
Line 551... | Line 550... | ||
551 | 550 | ||
Line 557... | Line 556... | ||
557 | MainWindow->panel.prg->max = stream_duration; |
556 | MainWindow->panel.prg->max = stream_duration; |
Line 558... | Line 557... | ||
558 | 557 | ||
Line 559... | Line -... | ||
559 | show_window(MainWindow, NORMAL); |
- | |
560 | - | ||
561 | // __asm__ __volatile__("int3"); |
558 | show_window(MainWindow, NORMAL); |
562 | 559 | ||
563 | main_render = create_render(MainWindow, ctx, HW_TEX_BLIT|HW_BIT_BLIT); |
560 | main_render = create_render(vst, MainWindow, HW_TEX_BLIT|HW_BIT_BLIT); |
564 | if( main_render == NULL) |
561 | if( main_render == NULL) |
565 | { |
562 | { |
566 | printf("Cannot create render\n\r"); |
563 | printf("Cannot create render\n\r"); |
Line 585... | Line 582... | ||
585 | 582 | ||
586 | void draw_hw_picture(render_t *render, AVPicture *picture); |
583 | void draw_hw_picture(render_t *render, AVPicture *picture); |
Line 587... | Line 584... | ||
587 | void draw_sw_picture(render_t *render, AVPicture *picture); |
584 | void draw_sw_picture(render_t *render, AVPicture *picture); |
588 | 585 | ||
589 | render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags) |
586 | render_t *create_render(vst_t *vst, window_t *win, uint32_t flags) |
Line 590... | Line 587... | ||
590 | { |
587 | { |
591 | render_t *render; |
588 | render_t *render; |
Line 598... | Line 595... | ||
598 | 595 | ||
Line 599... | Line 596... | ||
599 | render = (render_t*)malloc(sizeof(render_t)); |
596 | render = (render_t*)malloc(sizeof(render_t)); |
600 | memset(render, 0, sizeof(render_t)); |
597 | memset(render, 0, sizeof(render_t)); |
Line -... | Line 598... | ||
- | 598 | ||
601 | 599 | render->vst = vst; |
|
Line 602... | Line 600... | ||
602 | render->win = win; |
600 | render->win = win; |
603 | 601 | ||
604 | render->ctx_width = ctx->width; |
602 | render->ctx_width = vst->vCtx->width; |
Line 605... | Line 603... | ||
605 | render->ctx_height = ctx->height; |
603 | render->ctx_height = vst->vCtx->height; |
Line 606... | Line 604... | ||
606 | render->ctx_format = ctx->pix_fmt; |
604 | render->ctx_format = vst->vCtx->pix_fmt; |
607 | 605 | ||
Line 843... | Line 841... | ||
843 | }; |
841 | }; |
844 | 842 | ||
Line 845... | Line 843... | ||
845 | cvt_ctx = sws_getCachedContext(cvt_ctx, |
843 | cvt_ctx = sws_getCachedContext(cvt_ctx, |
846 | render->ctx_width, render->ctx_height, render->ctx_format, |
844 | render->ctx_width, render->ctx_height, render->ctx_format, |
847 | dst_width, dst_height, PIX_FMT_BGRA, |
845 | dst_width, dst_height, AV_PIX_FMT_BGRA, |
848 | SWS_FAST_BILINEAR, NULL, NULL, NULL); |
846 | SWS_FAST_BILINEAR, NULL, NULL, NULL); |
849 | if(cvt_ctx == NULL) |
847 | if(cvt_ctx == NULL) |
850 | { |
848 | { |
851 | printf("Cannot initialize the conversion context!\n"); |
849 | printf("Cannot initialize the conversion context!\n"); |
852 | return ; |
850 | return ; |
Line 875... | Line 873... | ||
875 | sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, |
873 | sws_scale(cvt_ctx, (const uint8_t* const *)picture->data, |
876 | picture->linesize, 0, render->ctx_height, data, linesize); |
874 | picture->linesize, 0, render->ctx_height, data, linesize); |
877 | // printf("sws_scale\n"); |
875 | // printf("sws_scale\n"); |
Line -... | Line 876... | ||
- | 876 | ||
Line 878... | Line 877... | ||
878 | 877 | mutex_lock(&render->vst->gpu_lock); |
|
879 | 878 | ||
Line 880... | Line 879... | ||
880 | if(render->caps & HW_TEX_BLIT) |
879 | if(render->caps & HW_TEX_BLIT) |
Line 897... | Line 896... | ||
897 | pxBlitBitmap(bitmap, render->rcvideo.l, |
896 | pxBlitBitmap(bitmap, render->rcvideo.l, |
898 | CAPTION_HEIGHT+render->rcvideo.t, |
897 | CAPTION_HEIGHT+render->rcvideo.t, |
899 | render->rcvideo.r, render->rcvideo.b, 0, 0); |
898 | render->rcvideo.r, render->rcvideo.b, 0, 0); |
900 | }; |
899 | }; |
901 | 900 | mutex_unlock(&render->vst->gpu_lock); |
|
- | 901 | ||
Line 902... | Line 902... | ||
902 | render->last_bitmap = bitmap; |
902 | render->last_bitmap = bitmap; |
903 | render->target++; |
903 | render->target++; |
904 | render->target&= 1; |
904 | render->target&= 1; |
905 | } |
905 | } |
Line 918... | Line 918... | ||
918 | cvt_ctx = sws_getCachedContext(cvt_ctx, |
918 | cvt_ctx = sws_getCachedContext(cvt_ctx, |
919 | render->ctx_width, render->ctx_height, |
919 | render->ctx_width, render->ctx_height, |
920 | render->ctx_format, |
920 | render->ctx_format, |
921 | render->rcvideo.r, render->rcvideo.b, |
921 | render->rcvideo.r, render->rcvideo.b, |
922 | PIX_FMT_BGRA, SWS_FAST_BILINEAR, NULL, NULL, NULL); |
922 | AV_PIX_FMT_BGRA, SWS_FAST_BILINEAR, NULL, NULL, NULL); |
923 | if(cvt_ctx == NULL) |
923 | if(cvt_ctx == NULL) |
924 | { |
924 | { |
925 | printf("Cannot initialize the conversion context!\n"); |
925 | printf("Cannot initialize the conversion context!\n"); |
926 | return ; |
926 | return ; |
927 | } |
927 | } |