annotate libvo/vosub_vidix.c @ 4207:1427d0f1f2d6

-lavcopts vme= option to set motion estimation method - patch by Rich Felker <dalias@aerifal.cx>
author arpi
date Thu, 17 Jan 2002 01:02:41 +0000
parents 7e2bf04c9a7c
children 9a33ad2f3547
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
938d37ad4f85 preliminary version
nick
parents:
diff changeset
149 next_frame = 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
150 vidix_mem =vidix_play.dga_addr;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
151
938d37ad4f85 preliminary version
nick
parents:
diff changeset
152 /*clear the buffer*/
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
153 memset(vidix_mem + vidix_play.offsets[0],0x80,vidix_play.frame_size*vidix_play.num_frames);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
154 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
155 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
156
4198
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
157 void vidix_start(void)
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
158 {
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
159 int err;
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
160
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
161 if((err=vdlPlaybackOn(vidix_handler))!=0)
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
162 {
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
163 printf("vosub_vidix: Can't start playback: %s\n",strerror(err));
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
164 return -1;
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
165 }
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
166 return 0;
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
167 }
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
168
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
169 void vidix_stop(void)
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
170 {
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
171 int err;
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
172
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
173 if((err=vdlPlaybackOff(vidix_handler))!=0)
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
174 {
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
175 printf("vosub_vidix: Can't stop playback: %s\n",strerror(err));
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
176 return -1;
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
177 }
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
178 return 0;
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
179 }
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
180
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
181 void vidix_term( void )
938d37ad4f85 preliminary version
nick
parents:
diff changeset
182 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
183 if(verbose > 1) printf("vosub_vidix: vidix_term() was called\n");
4198
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
184 // vdlPlaybackOff(vidix_handler);
7e2bf04c9a7c added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents: 4138
diff changeset
185 vidix_stop();
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
186 vdlClose(vidix_handler);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
187 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
188
938d37ad4f85 preliminary version
nick
parents:
diff changeset
189 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
190 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
191 uint8_t *src;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
192 uint8_t *dest;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
193 unsigned bespitch,apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
194 int i;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
195 apitch = vidix_play.dest.pitch.y-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
196 bespitch = (w + apitch) & ~apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
197
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
198 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
199 dest += bespitch*y + x;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
200 src = image[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
201 for(i=0;i<h;i++){
938d37ad4f85 preliminary version
nick
parents:
diff changeset
202 memcpy(dest,src,w);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
203 src+=stride[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
204 dest += bespitch;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
205 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
206
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
207 apitch = vidix_play.dest.pitch.v-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
208 bespitch = (w + apitch) & ~apitch;
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
209 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.v;
4031
8b8569b255d0 YV12 sliced output fixed
nick
parents: 4014
diff changeset
210 dest += bespitch*y/4 + x;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
211 src = image[1];
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
212 for(i=0;i<h/2;i++){
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
213 memcpy(dest,src,w/2);
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
214 src+=stride[1];
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
215 dest+=bespitch/2;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
216 }
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
217 apitch = vidix_play.dest.pitch.u-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
218 bespitch = (w + apitch) & ~apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
219
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
220 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.u;
4031
8b8569b255d0 YV12 sliced output fixed
nick
parents: 4014
diff changeset
221 dest += bespitch*y/4 + x;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
222 src = image[2];
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
223 for(i=0;i<h/2;i++){
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
224 memcpy(dest,src,w/2);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
225 src+=stride[2];
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
226 dest += bespitch/2;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
227 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
228 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
229 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
230
938d37ad4f85 preliminary version
nick
parents:
diff changeset
231 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
232 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
233 uint8_t *src;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
234 uint8_t *dest;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
235 unsigned bespitch,apitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
236 int i;
4014
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
237 apitch = vidix_play.dest.pitch.y-1;
cb7c183816f8 Looks working ;)
nick
parents: 4013
diff changeset
238 bespitch = (w*2 + apitch) & ~apitch;
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
239 dest = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
240 dest += bespitch*y + x;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
241 src = image[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
242 for(i=0;i<h;i++){
938d37ad4f85 preliminary version
nick
parents:
diff changeset
243 memcpy(dest,src,w*2);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
244 src+=stride[0];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
245 dest += bespitch;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
246 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
247 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
248
938d37ad4f85 preliminary version
nick
parents:
diff changeset
249
938d37ad4f85 preliminary version
nick
parents:
diff changeset
250 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
251 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
252 if(verbose > 1) printf("vosub_vidix: vidix_draw_slice() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
253 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
254 vidix_draw_slice_420(image,stride,w,h,x,y);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
255 else
938d37ad4f85 preliminary version
nick
parents:
diff changeset
256 vidix_draw_slice_422(image,stride,w,h,x,y);
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 uint32_t vidix_draw_frame(uint8_t *image[])
938d37ad4f85 preliminary version
nick
parents:
diff changeset
261 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
262 if(verbose > 1) printf("vosub_vidix: vidix_draw_frame() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
263 /* Note it's very strange but sometime for YUY2 draw_frame is called */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
264 if(src_format == IMGFMT_YV12 || src_format == IMGFMT_I420 || src_format == IMGFMT_IYUV)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
265 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
266 printf("vosub_vidix: draw_frame for i420 is called\nExiting...\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
267 vidix_term();
938d37ad4f85 preliminary version
nick
parents:
diff changeset
268 exit( EXIT_FAILURE );
938d37ad4f85 preliminary version
nick
parents:
diff changeset
269 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
270 else
938d37ad4f85 preliminary version
nick
parents:
diff changeset
271 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
272 int stride[1];
938d37ad4f85 preliminary version
nick
parents:
diff changeset
273 stride[0] = vidix_play.src.w*2;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
274 vidix_draw_slice_422(image,stride,vidix_play.src.w,vidix_play.src.h,
938d37ad4f85 preliminary version
nick
parents:
diff changeset
275 vidix_play.src.x,vidix_play.src.y);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
276 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
277 return 0;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
278 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
279
938d37ad4f85 preliminary version
nick
parents:
diff changeset
280 void vidix_flip_page(void)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
281 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
282 if(verbose > 1) printf("vosub_vidix: vidix_flip_page() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
283 if(vo_doublebuffering)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
284 {
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
285 vdlPlaybackFrameSelect(vidix_handler,next_frame);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
286 next_frame=(next_frame+1)%vidix_play.num_frames;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
287 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
288 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
289
938d37ad4f85 preliminary version
nick
parents:
diff changeset
290 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
291 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
292 UNUSED(x0);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
293 UNUSED(y0);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
294 UNUSED(w);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
295 UNUSED(h);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
296 UNUSED(src);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
297 UNUSED(srca);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
298 UNUSED(stride);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
299 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
300
938d37ad4f85 preliminary version
nick
parents:
diff changeset
301 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
302 {
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
303 uint32_t apitch,bespitch;
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
304 void *lvo_mem;
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
305 lvo_mem = vidix_mem + vidix_play.offsets[next_frame] + vidix_play.offset.y;
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
306 apitch = vidix_play.dest.pitch.y-1;
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
307 bespitch = (vidix_play.src.w + apitch) & (~apitch);
4010
938d37ad4f85 preliminary version
nick
parents:
diff changeset
308 switch(vidix_play.fourcc){
938d37ad4f85 preliminary version
nick
parents:
diff changeset
309 case IMGFMT_YV12:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
310 case IMGFMT_IYUV:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
311 case IMGFMT_I420:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
312 vo_draw_alpha_yv12(w,h,src,srca,stride,lvo_mem+bespitch*y0+x0,bespitch);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
313 break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
314 case IMGFMT_YUY2:
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
315 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
316 break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
317 case IMGFMT_UYVY:
4032
076c6c29e693 OSD support
nick
parents: 4031
diff changeset
318 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
319 break;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
320 default:
938d37ad4f85 preliminary version
nick
parents:
diff changeset
321 draw_alpha_null(x0,y0,w,h,src,srca,stride);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
322 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
323 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
324
938d37ad4f85 preliminary version
nick
parents:
diff changeset
325 void vidix_draw_osd(void)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
326 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
327 if(verbose > 1) printf("vosub_vidix: vidix_draw_osd() was called\n");
938d37ad4f85 preliminary version
nick
parents:
diff changeset
328 /* TODO: hw support */
938d37ad4f85 preliminary version
nick
parents:
diff changeset
329 vo_draw_text(vidix_play.src.w,vidix_play.src.h,draw_alpha);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
330 }
938d37ad4f85 preliminary version
nick
parents:
diff changeset
331
938d37ad4f85 preliminary version
nick
parents:
diff changeset
332 uint32_t vidix_query_fourcc(uint32_t format)
938d37ad4f85 preliminary version
nick
parents:
diff changeset
333 {
938d37ad4f85 preliminary version
nick
parents:
diff changeset
334 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
335 vidix_fourcc.fourcc = format;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
336 vdlQueryFourcc(vidix_handler,&vidix_fourcc);
938d37ad4f85 preliminary version
nick
parents:
diff changeset
337 return vidix_fourcc.depth != VID_DEPTH_NONE;
938d37ad4f85 preliminary version
nick
parents:
diff changeset
338 }