annotate libvo/vosub_vidix.c @ 4142:5e8231233418

S->C
author nick
date Sun, 13 Jan 2002 18:26:58 +0000
parents 458831ca939a
children 7e2bf04c9a7c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
1
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
2 /*
938d37ad4f85 preliminary version
nick
parents:
diff changeset
3 * vosub_vidix.c
938d37ad4f85 preliminary version
nick
parents:
diff changeset
4 *
938d37ad4f85 preliminary version
nick
parents:
diff changeset
5 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - 2002
938d37ad4f85 preliminary version
nick
parents:
diff changeset
6 *
938d37ad4f85 preliminary version
nick
parents:
diff changeset
7 * You can redistribute this file under terms and conditions
938d37ad4f85 preliminary version
nick
parents:
diff changeset
8 * of GNU General Public licence v2.
938d37ad4f85 preliminary version
nick
parents:
diff changeset
9 *
938d37ad4f85 preliminary version
nick
parents:
diff changeset
10 * This file contains vidix interface to any mplayer's VO plugin.
938d37ad4f85 preliminary version
nick
parents:
diff changeset
11 * (Partly based on vesa_lvo.c from mplayer's package)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
12 */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
13
938d37ad4f85 preliminary version
nick
parents:
diff changeset
14 #include <inttypes.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
15 #include <sys/ioctl.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
16 #include <unistd.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
17 #include <fcntl.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
18 #include <sys/mman.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
19 #include <stdio.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
20 #include <stdlib.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
21 #include <string.h>
938d37ad4f85 preliminary version
nick
parents:
diff changeset
22
938d37ad4f85 preliminary version
nick
parents:
diff changeset
23 #include "config.h"
938d37ad4f85 preliminary version
nick
parents:
diff changeset
24
938d37ad4f85 preliminary version
nick
parents:
diff changeset
25 #include "vosub_vidix.h"
938d37ad4f85 preliminary version
nick
parents:
diff changeset
26 #include "../vidix/vidixlib.h"
938d37ad4f85 preliminary version
nick
parents:
diff changeset
27 #include "fastmemcpy.h"
938d37ad4f85 preliminary version
nick
parents:
diff changeset
28 #include "osd.h"
938d37ad4f85 preliminary version
nick
parents:
diff changeset
29 #include "video_out.h"
938d37ad4f85 preliminary version
nick
parents:
diff changeset
30
938d37ad4f85 preliminary version
nick
parents:
diff changeset
31 #define NUM_FRAMES 10 /* Temporary: driver will overwrite it */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
32 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
33
938d37ad4f85 preliminary version
nick
parents:
diff changeset
34 static VDL_HANDLE vidix_handler = NULL;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
35 static uint8_t *vidix_mem = NULL;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
36 static uint8_t next_frame;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
37 static unsigned image_bpp,image_height,image_width,src_format;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
38 extern int verbose;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
39
938d37ad4f85 preliminary version
nick
parents:
diff changeset
40 static vidix_capability_t vidix_cap;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
41 static vidix_playback_t vidix_play;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
42 static vidix_fourcc_t vidix_fourcc;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
43
938d37ad4f85 preliminary version
nick
parents:
diff changeset
44 #define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
45 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
938d37ad4f85 preliminary version
nick
parents:
diff changeset
46 #define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size))
938d37ad4f85 preliminary version
nick
parents:
diff changeset
47
938d37ad4f85 preliminary version
nick
parents:
diff changeset
48 extern vo_functions_t video_out_vesa;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
49
4082
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
50 int vidix_preinit(const char *drvname,void *server)
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
51 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
52 int err;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
53 if(verbose > 1) printf("vosub_vidix: vidix_preinit(%s) was called\n",drvname);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
54 if(vdlGetVersion() != VIDIX_VERSION)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
55 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
56 printf("vosub_vidix: You have wrong version of VIDIX library\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
57 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
58 }
4138
458831ca939a using LIBDIR@config.h
alex
parents: 4132
diff changeset
59 vidix_handler = vdlOpen(LIBDIR"/vidix/",
4132
84ecfd03c86a test for preinit errors and correct handling subdevice
nick
parents: 4082
diff changeset
60 drvname ? drvname[0] == ':' ? &drvname[1] : drvname[0] ? drvname : NULL : NULL,
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
61 TYPE_OUTPUT,
938d37ad4f85 preliminary version
nick
parents:
diff changeset
62 verbose);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
63 if(vidix_handler == NULL)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
64 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
65 printf("vosub_vidix: Couldn't find working VIDIX driver\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
66 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
67 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
68 if((err=vdlGetCapability(vidix_handler,&vidix_cap)) != 0)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
69 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
70 printf("vosub_vidix: Couldn't get capability: %s\n",strerror(err));
938d37ad4f85 preliminary version
nick
parents:
diff changeset
71 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
72 }
4013
625b61fd11fb Printing driver name
nick
parents: 4010
diff changeset
73 printf("vosub_vidix: Using: %s\n",vidix_cap.name);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
74 /* we are able to tune up this stuff depend on fourcc format */
4082
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
75 ((vo_functions_t *)server)->draw_slice=vidix_draw_slice;
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
76 ((vo_functions_t *)server)->draw_frame=vidix_draw_frame;
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
77 ((vo_functions_t *)server)->flip_page=vidix_flip_page;
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
78 ((vo_functions_t *)server)->draw_osd=vidix_draw_osd;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
79 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
80 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
81
938d37ad4f85 preliminary version
nick
parents:
diff changeset
82 int vidix_init(unsigned src_width,unsigned src_height,
938d37ad4f85 preliminary version
nick
parents:
diff changeset
83 unsigned x_org,unsigned y_org,unsigned dst_width,
938d37ad4f85 preliminary version
nick
parents:
diff changeset
84 unsigned dst_height,unsigned format,unsigned dest_bpp,
938d37ad4f85 preliminary version
nick
parents:
diff changeset
85 unsigned vid_w,unsigned vid_h)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
86 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
87 size_t i,awidth;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
88 int err;
4082
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
89 if(verbose > 1)
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
90 printf("vosub_vidix: vidix_init() was called\n"
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
91 "src_w=%u src_h=%u dest_x_y_w_h = %u %u %u %u\n"
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
92 "format=%s dest_bpp=%u vid_w=%u vid_h=%u\n"
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
93 ,src_width,src_height,x_org,y_org,dst_width,dst_height
802a745a52b0 Using any graphics server
nick
parents: 4032
diff changeset
94 ,vo_format_name(format),dest_bpp,vid_w,vid_h);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
95 if(vid_w > vidix_cap.maxwidth || vid_w < vidix_cap.minwidth ||
938d37ad4f85 preliminary version
nick
parents:
diff changeset
96 vid_h > vidix_cap.maxheight || vid_h < vidix_cap.minheight)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
97 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
98 printf("vosub_vidix: video server has unsupported resolution by vidix\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
99 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
100 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
101 err = 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
102 switch(dest_bpp)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
103 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
104 case 1: err = ((vidix_fourcc.depth & VID_DEPTH_1BPP) != VID_DEPTH_1BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
105 case 2: err = ((vidix_fourcc.depth & VID_DEPTH_2BPP) != VID_DEPTH_2BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
106 case 4: err = ((vidix_fourcc.depth & VID_DEPTH_4BPP) != VID_DEPTH_4BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
107 case 8: err = ((vidix_fourcc.depth & VID_DEPTH_8BPP) != VID_DEPTH_8BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
108 case 12:err = ((vidix_fourcc.depth & VID_DEPTH_12BPP) != VID_DEPTH_12BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
109 case 16:err = ((vidix_fourcc.depth & VID_DEPTH_16BPP) != VID_DEPTH_16BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
110 case 24:err = ((vidix_fourcc.depth & VID_DEPTH_24BPP) != VID_DEPTH_24BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
111 case 32:err = ((vidix_fourcc.depth & VID_DEPTH_32BPP) != VID_DEPTH_32BPP); break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
112 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
113 if(err)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
114 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
115 printf("vosub_vidix: video server has unsupported color depth by vidix\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
116 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
117 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
118 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_UPSCALER) != FLAG_UPSCALER)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
119 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
120 printf("vosub_vidix: vidix driver can't upscale image\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
121 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
122 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
123 if((dst_width > src_width || dst_height > src_height) && (vidix_cap.flags & FLAG_DOWNSCALER) != FLAG_DOWNSCALER)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
124 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
125 printf("vosub_vidix: vidix driver can't downscale image\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
126 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
127 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
128 image_width = src_width;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
129 image_height = src_height;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
130 src_format = format;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
131 memset(&vidix_play,0,sizeof(vidix_playback_t));
938d37ad4f85 preliminary version
nick
parents:
diff changeset
132 vidix_play.fourcc = format;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
133 vidix_play.capability = vidix_cap.flags; /* every ;) */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
134 vidix_play.blend_factor = 0; /* for now */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
135 vidix_play.src.x = vidix_play.src.y = 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
136 vidix_play.src.w = src_width;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
137 vidix_play.src.h = src_height;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
138 vidix_play.dest.x = x_org;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
139 vidix_play.dest.y = y_org;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
140 vidix_play.dest.w = dst_width;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
141 vidix_play.dest.h = dst_height;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
142 vidix_play.num_frames=NUM_FRAMES;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
143 if((err=vdlConfigPlayback(vidix_handler,&vidix_play))!=0)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
144 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
145 printf("vosub_vidix: Can't configure playback: %s\n",strerror(err));
938d37ad4f85 preliminary version
nick
parents:
diff changeset
146 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
147 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
148 if((err=vdlPlaybackOn(vidix_handler))!=0)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
149 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
150 printf("vosub_vidix: Can't start playback: %s\n",strerror(err));
938d37ad4f85 preliminary version
nick
parents:
diff changeset
151 return -1;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
152 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
153
938d37ad4f85 preliminary version
nick
parents:
diff changeset
154 next_frame = 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
155 vidix_mem =vidix_play.dga_addr;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
156
938d37ad4f85 preliminary version
nick
parents:
diff changeset
157 /*clear the buffer*/
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
158 memset(vidix_mem + vidix_play.offsets[0],0x80,vidix_play.frame_size*vidix_play.num_frames);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
159 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
160 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
161
938d37ad4f85 preliminary version
nick
parents:
diff changeset
162 void vidix_term( void )
938d37ad4f85 preliminary version
nick
parents:
diff changeset
163 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
164 if(verbose > 1) printf("vosub_vidix: vidix_term() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
165 vdlPlaybackOff(vidix_handler);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
166 vdlClose(vidix_handler);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
167 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
168
938d37ad4f85 preliminary version
nick
parents:
diff changeset
169 uint32_t vidix_draw_slice_420(uint8_t *image[], int stride[], int w,int h,int x,int y)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
170 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
171 uint8_t *src;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
172 uint8_t *dest;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
173 unsigned bespitch,apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
174 int i;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
175 apitch = vidix_play.dest.pitch.y-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
176 bespitch = (w + apitch) & ~apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
177
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
178 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
179 dest += bespitch*y + x;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
180 src = image[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
181 for(i=0;i<h;i++){
938d37ad4f85 preliminary version
nick
parents:
diff changeset
182 memcpy(dest,src,w);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
183 src+=stride[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
184 dest += bespitch;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
185 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
186
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
187 apitch = vidix_play.dest.pitch.v-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
188 bespitch = (w + apitch) & ~apitch;
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
189 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
4031
8b8569b255d0 YV12 sliced output fixed
nick
parents: 4014
diff changeset
190 dest += bespitch*y/4 + x;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
191 src = image[1];
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
192 for(i=0;i<h/2;i++){
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
193 memcpy(dest,src,w/2);
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
194 src+=stride[1];
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
195 dest+=bespitch/2;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
196 }
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
197 apitch = vidix_play.dest.pitch.u-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
198 bespitch = (w + apitch) & ~apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
199
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
200 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
4031
8b8569b255d0 YV12 sliced output fixed
nick
parents: 4014
diff changeset
201 dest += bespitch*y/4 + x;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
202 src = image[2];
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
203 for(i=0;i<h/2;i++){
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
204 memcpy(dest,src,w/2);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
205 src+=stride[2];
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
206 dest += bespitch/2;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
207 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
208 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
209 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
210
938d37ad4f85 preliminary version
nick
parents:
diff changeset
211 uint32_t vidix_draw_slice_422(uint8_t *image[], int stride[], int w,int h,int x,int y)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
212 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
213 uint8_t *src;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
214 uint8_t *dest;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
215 unsigned bespitch,apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
216 int i;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
217 apitch = vidix_play.dest.pitch.y-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
218 bespitch = (w*2 + apitch) & ~apitch;
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
219 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
220 dest += bespitch*y + x;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
221 src = image[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
222 for(i=0;i<h;i++){
938d37ad4f85 preliminary version
nick
parents:
diff changeset
223 memcpy(dest,src,w*2);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
224 src+=stride[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
225 dest += bespitch;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
226 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
227 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
228
938d37ad4f85 preliminary version
nick
parents:
diff changeset
229
938d37ad4f85 preliminary version
nick
parents:
diff changeset
230 uint32_t vidix_draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
231 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
232 if(verbose > 1) printf("vosub_vidix: vidix_draw_slice() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
233 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
234 vidix_draw_slice_420(image,stride,w,h,x,y);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
235 else
938d37ad4f85 preliminary version
nick
parents:
diff changeset
236 vidix_draw_slice_422(image,stride,w,h,x,y);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
237 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
238 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
239
938d37ad4f85 preliminary version
nick
parents:
diff changeset
240 uint32_t vidix_draw_frame(uint8_t *image[])
938d37ad4f85 preliminary version
nick
parents:
diff changeset
241 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
242 if(verbose > 1) printf("vosub_vidix: vidix_draw_frame() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
243 /* Note it's very strange but sometime for YUY2 draw_frame is called */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
244 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
245 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
246 printf("vosub_vidix: draw_frame for i420 is called\nExiting...\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
247 vidix_term();
938d37ad4f85 preliminary version
nick
parents:
diff changeset
248 exit( EXIT_FAILURE );
938d37ad4f85 preliminary version
nick
parents:
diff changeset
249 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
250 else
938d37ad4f85 preliminary version
nick
parents:
diff changeset
251 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
252 int stride[1];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
253 stride[0] = vidix_play.src.w*2;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
254 vidix_draw_slice_422(image,stride,vidix_play.src.w,vidix_play.src.h,
938d37ad4f85 preliminary version
nick
parents:
diff changeset
255 vidix_play.src.x,vidix_play.src.y);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
256 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
257 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
258 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
259
938d37ad4f85 preliminary version
nick
parents:
diff changeset
260 void vidix_flip_page(void)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
261 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
262 if(verbose > 1) printf("vosub_vidix: vidix_flip_page() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
263 if(vo_doublebuffering)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
264 {
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
265 vdlPlaybackFrameSelect(vidix_handler,next_frame);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
266 next_frame=(next_frame+1)%vidix_play.num_frames;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
267 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
268 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
269
938d37ad4f85 preliminary version
nick
parents:
diff changeset
270 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
271 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
272 UNUSED(x0);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
273 UNUSED(y0);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
274 UNUSED(w);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
275 UNUSED(h);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
276 UNUSED(src);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
277 UNUSED(srca);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
278 UNUSED(stride);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
279 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
280
938d37ad4f85 preliminary version
nick
parents:
diff changeset
281 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
282 {
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
283 uint32_t apitch,bespitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
284 void *lvo_mem;
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
285 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
286 apitch = vidix_play.dest.pitch.y-1;
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
287 bespitch = (vidix_play.src.w + apitch) & (~apitch);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
288 switch(vidix_play.fourcc){
938d37ad4f85 preliminary version
nick
parents:
diff changeset
289 case IMGFMT_YV12:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
290 case IMGFMT_IYUV:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
291 case IMGFMT_I420:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
292 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
293 break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
294 case IMGFMT_YUY2:
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
295 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0),2*bespitch);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
296 break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
297 case IMGFMT_UYVY:
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
298 vo_draw_alpha_yuy2(w,h,src,srca,stride,lvo_mem+2*(bespitch*y0+x0)+1,2*bespitch);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
299 break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
300 default:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
301 draw_alpha_null(x0,y0,w,h,src,srca,stride);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
302 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
303 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
304
938d37ad4f85 preliminary version
nick
parents:
diff changeset
305 void vidix_draw_osd(void)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
306 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
307 if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
308 /* TODO: hw support */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
309 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
310 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
311
938d37ad4f85 preliminary version
nick
parents:
diff changeset
312 uint32_t vidix_query_fourcc(uint32_t format)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
313 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
314 if(verbose > 1) printf("vosub_vidix: query_format was called: %x (%s)\n",format,vo_format_name(format));
938d37ad4f85 preliminary version
nick
parents:
diff changeset
315 vidix_fourcc.fourcc = format;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
316 vdlQueryFourcc(vidix_handler,&vidix_fourcc);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
317 return vidix_fourcc.depth != VID_DEPTH_NONE;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
318 }