Mercurial > mplayer.hg
annotate libvo/vo_dxr3.c @ 2908:220e6c728747
gcc version messages updated. let's flame us again...
author | arpi |
---|---|
date | Wed, 14 Nov 2001 22:18:16 +0000 |
parents | 4f6190ab52e7 |
children | ee37c7fc3022 |
rev | line source |
---|---|
2645 | 1 #define PES_MAX_SIZE 2048 |
2 /* | |
3 * vo_dxr3.c - DXR3/H+ video out | |
4 * | |
5 * Copyright (C) 2001 David Holm <dholm@iname.com> | |
6 * | |
7 * libav - MPEG-PS multiplexer, part of ffmpeg | |
8 * Copyright Gerard Lantau (see http://ffmpeg.sf.net) | |
9 * | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
10 * |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
11 * |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
12 * |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
13 * |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
14 * *** NOTICE *** |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
15 * Further development of this device will be carried out using |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
16 * the new libvo2 system, meanwhile I hope someone can find where |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
17 * the lockup problem is located (caused by using subpics or audio |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
18 * (video gets blocked)) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
19 * |
2645 | 20 */ |
21 | |
22 #include "fastmemcpy.h" | |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <string.h> | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
26 #include <linux/kernel.h> |
2645 | 27 |
28 #include <stdio.h> | |
29 #include <time.h> | |
30 #include <unistd.h> | |
31 | |
32 #include <libdxr3/api.h> | |
33 | |
34 #include "config.h" | |
35 #include "video_out.h" | |
36 #include "video_out_internal.h" | |
37 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
38 #include "../postproc/rgb2rgb.h" |
2645 | 39 #ifdef HAVE_MMX |
40 #include "mmx.h" | |
41 #endif | |
42 | |
43 LIBVO_EXTERN (dxr3) | |
44 | |
45 #ifdef USE_LIBAVCODEC | |
46 | |
47 #ifdef USE_LIBAVCODEC_SO | |
48 #include <libffmpeg/avcodec.h> | |
49 #else | |
50 #include "../libavcodec/avcodec.h" | |
51 #endif | |
52 static AVPicture picture; | |
53 static AVCodec *codec=NULL; | |
54 static AVCodecContext codec_context; | |
55 extern int avcodec_inited; | |
56 #endif | |
57 | |
58 static unsigned char *picture_buf=NULL; | |
59 static unsigned char *outbuf=NULL; | |
2770 | 60 static unsigned char *spubuf=NULL; |
61 static int outbuf_size = 0; | |
62 static int v_width,v_height; | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
63 static int s_width,s_height; |
2645 | 64 static int s_pos_x,s_pos_y; |
65 static int d_pos_x,d_pos_y; | |
66 static int osd_w,osd_h; | |
2770 | 67 static int img_format = 0; |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
68 static int palette[] = { 0x000000, 0x494949, 0xb5b5b5, 0xffffff }; |
2645 | 69 |
70 static vo_info_t vo_info = | |
71 { | |
72 "DXR3/H+ video out", | |
73 "dxr3", | |
74 "David Holm <dholm@iname.com>", | |
75 "" | |
76 }; | |
77 | |
78 static uint32_t | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
79 init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, uint32_t fullscreen, char *title, uint32_t format) |
2645 | 80 { |
81 if( dxr3_get_status() == DXR3_STATUS_CLOSED ) | |
82 { | |
2770 | 83 if( dxr3_open( "/dev/em8300" ) != 0 ) { printf( "Error opening /dev/em8300\n" ); return -1; } |
2645 | 84 printf( "DXR3 status: %s\n", dxr3_get_status() ? "opened":"closed" ); |
85 } | |
86 | |
2770 | 87 /* Subpic code isn't working yet, don't set to ON |
88 unless you are really sure what you are doing */ | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
89 dxr3_subpic_set_mode( DXR3_SPU_MODE_ON ); |
2770 | 90 dxr3_subpic_set_palette( (char*)palette ); |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
91 spubuf = malloc(53220); //53220bytes is the standardized max size of a subpic |
2770 | 92 |
2645 | 93 if( dxr3_set_playmode( DXR3_PLAYMODE_PLAY ) !=0 ) printf( "Error setting playmode of DXR3\n" ); |
94 | |
95 img_format = format; | |
2770 | 96 v_width = width; |
97 v_height = height; | |
2645 | 98 picture_buf=NULL; |
2770 | 99 |
2645 | 100 if( format == IMGFMT_YV12 ) |
101 { | |
102 #ifdef USE_LIBAVCODEC | |
103 | |
104 int size; | |
105 | |
106 printf("Format: YV12\n"); | |
107 | |
108 if(!avcodec_inited){ | |
109 avcodec_init(); | |
110 avcodec_register_all(); | |
111 avcodec_inited=1; | |
112 } | |
113 | |
114 /* find the mpeg1 video encoder */ | |
115 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); | |
116 if (!codec) { | |
117 fprintf(stderr, "mpeg1 codec not found\n"); | |
118 return -1; | |
119 } | |
120 | |
121 memset(&codec_context,0,sizeof(codec_context)); | |
122 codec_context.bit_rate=100000; // not used | |
2770 | 123 codec_context.frame_rate=25*FRAME_RATE_BASE; |
124 codec_context.gop_size=0; | |
2645 | 125 codec_context.flags=CODEC_FLAG_QSCALE; |
2770 | 126 codec_context.quality=1; |
127 codec_context.pix_fmt = PIX_FMT_YUV420P; | |
2645 | 128 if(width<=352 && height<=288){ |
129 codec_context.width=352; | |
130 codec_context.height=288; | |
131 } else | |
132 if(width<=352 && height<=576){ | |
133 codec_context.width=352; | |
134 codec_context.height=576; | |
135 } else | |
136 if(width<=480 && height<=576){ | |
137 codec_context.width=480; | |
138 codec_context.height=576; | |
139 } else | |
140 if(width<=544 && height<=576){ | |
141 codec_context.width=544; | |
142 codec_context.height=576; | |
143 } else { | |
144 codec_context.width=704; | |
145 codec_context.height=576; | |
146 } | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
147 s_width = codec_context.width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
148 s_height = codec_context.height;; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
149 |
2645 | 150 |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
151 osd_w=scr_width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
152 d_pos_x=(codec_context.width-(int)scr_width)/2; |
2645 | 153 if(d_pos_x<0){ |
154 s_pos_x=-d_pos_x;d_pos_x=0; | |
155 osd_w=codec_context.width; | |
156 } else s_pos_x=0; | |
157 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
158 osd_h=scr_height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
159 d_pos_y=(codec_context.height-(int)scr_height)/2; |
2645 | 160 if(d_pos_y<0){ |
161 s_pos_y=-d_pos_y;d_pos_y=0; | |
162 osd_h=codec_context.height; | |
163 } else s_pos_y=0; | |
164 | |
165 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); | |
166 | |
167 /* open it */ | |
168 if (avcodec_open(&codec_context, codec) < 0) { | |
169 fprintf(stderr, "could not open codec\n"); | |
170 return -1; | |
171 } | |
172 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
173 outbuf_size=10000+width*height; |
2645 | 174 outbuf = malloc(outbuf_size); |
175 | |
176 size = codec_context.width*codec_context.height; | |
2770 | 177 picture_buf = malloc((size * 3)/2); /* size for YUV 420 */ |
178 | |
179 picture.data[0] = picture_buf; | |
180 picture.data[1] = picture.data[0] + size; | |
181 picture.data[2] = picture.data[1] + size / 4; | |
182 picture.linesize[0] = codec_context.width; | |
183 picture.linesize[1] = codec_context.width / 2; | |
184 picture.linesize[2] = codec_context.width / 2; | |
185 | |
186 return 0; | |
187 #endif | |
188 return -1; | |
189 } | |
190 else if(format==IMGFMT_BGR24) | |
191 { | |
192 #ifdef USE_LIBAVCODEC | |
193 int size = 0; | |
194 printf("Format: BGR24\n"); | |
195 | |
196 if(!avcodec_inited) | |
197 { | |
198 avcodec_init(); | |
199 avcodec_register_all(); | |
200 avcodec_inited=1; | |
201 } | |
202 | |
203 /* find the mpeg1 video encoder */ | |
204 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); | |
205 if (!codec) | |
206 { | |
207 fprintf(stderr, "mpeg1 codec not found\n"); | |
208 return -1; | |
209 } | |
210 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
211 outbuf_size=10000+width*height; |
2770 | 212 outbuf = malloc(outbuf_size); |
213 | |
214 memset(&codec_context,0,sizeof(codec_context)); | |
215 codec_context.bit_rate=100000; | |
216 codec_context.frame_rate=25*FRAME_RATE_BASE; | |
217 codec_context.gop_size=0; | |
218 codec_context.flags=CODEC_FLAG_QSCALE; | |
219 codec_context.quality=1; | |
220 codec_context.pix_fmt = PIX_FMT_YUV420P; | |
221 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
222 /*if(width<=352 && height<=288){ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
223 codec_context.width=352; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
224 codec_context.height=288; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
225 } else |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
226 if(width<=352 && height<=576){ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
227 codec_context.width=352; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
228 codec_context.height=576; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
229 } else |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
230 if(width<=480 && height<=576){ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
231 codec_context.width=480; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
232 codec_context.height=576; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
233 } else |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
234 if(width<=544 && height<=576){ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
235 codec_context.width=544; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
236 codec_context.height=576; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
237 } else { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
238 codec_context.width=704; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
239 codec_context.height=576; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
240 }*/ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
241 s_width = codec_context.width = width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
242 s_height = codec_context.height = height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
243 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
244 osd_w=scr_width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
245 d_pos_x=(codec_context.width-(int)scr_width)/2; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
246 if(d_pos_x<0){ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
247 s_pos_x=-d_pos_x;d_pos_x=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
248 osd_w=codec_context.width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
249 } else s_pos_x=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
250 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
251 osd_h=scr_height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
252 d_pos_y=(codec_context.height-(int)scr_height)/2; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
253 if(d_pos_y<0){ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
254 s_pos_y=-d_pos_y;d_pos_y=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
255 osd_h=codec_context.height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
256 } else s_pos_y=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
257 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
258 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
259 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
260 /* open it */ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
261 if (avcodec_open(&codec_context, codec) < 0) { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
262 fprintf(stderr, "could not open codec\n"); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
263 return -1; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
264 } |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
265 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
266 size = 10000+codec_context.width*codec_context.height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
267 picture_buf = malloc((size * 3)/2); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
268 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
269 picture.data[0] = picture_buf; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
270 picture.data[1] = picture.data[0] + size; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
271 picture.data[2] = picture.data[1] + size / 4; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
272 picture.linesize[0] = codec_context.width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
273 picture.linesize[1] = codec_context.width / 2; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
274 picture.linesize[2] = codec_context.width / 2; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
275 return 0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
276 #endif |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
277 return -1; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
278 } |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
279 else if(format==IMGFMT_YUY2) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
280 { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
281 #ifdef USE_LIBAVCODEC |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
282 int size = 0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
283 printf("Format: YUY2\n"); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
284 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
285 if(!avcodec_inited) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
286 { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
287 avcodec_init(); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
288 avcodec_register_all(); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
289 avcodec_inited=1; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
290 } |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
291 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
292 /* find the mpeg1 video encoder */ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
293 codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
294 if (!codec) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
295 { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
296 fprintf(stderr, "mpeg1 codec not found\n"); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
297 return -1; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
298 } |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
299 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
300 outbuf_size=10000+width*height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
301 outbuf = malloc(outbuf_size); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
302 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
303 memset(&codec_context,0,sizeof(codec_context)); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
304 codec_context.bit_rate=100000; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
305 codec_context.frame_rate=25*FRAME_RATE_BASE; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
306 codec_context.gop_size=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
307 codec_context.flags=CODEC_FLAG_QSCALE; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
308 codec_context.quality=1; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
309 codec_context.pix_fmt = PIX_FMT_YUV420P; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
310 |
2770 | 311 if(width<=352 && height<=288){ |
312 codec_context.width=352; | |
313 codec_context.height=288; | |
314 } else | |
315 if(width<=352 && height<=576){ | |
316 codec_context.width=352; | |
317 codec_context.height=576; | |
318 } else | |
319 if(width<=480 && height<=576){ | |
320 codec_context.width=480; | |
321 codec_context.height=576; | |
322 } else | |
323 if(width<=544 && height<=576){ | |
324 codec_context.width=544; | |
325 codec_context.height=576; | |
326 } else { | |
327 codec_context.width=704; | |
328 codec_context.height=576; | |
329 } | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
330 s_width = codec_context.width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
331 s_height = codec_context.height;; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
332 /* FOR DEBUGGING ONLY!! */ |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
333 codec_context.width = width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
334 codec_context.height = height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
335 |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
336 osd_w=scr_width; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
337 d_pos_x=(codec_context.width-(int)scr_width)/2; |
2770 | 338 if(d_pos_x<0){ |
339 s_pos_x=-d_pos_x;d_pos_x=0; | |
340 osd_w=codec_context.width; | |
341 } else s_pos_x=0; | |
342 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
343 osd_h=scr_height; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
344 d_pos_y=(codec_context.height-(int)scr_height)/2; |
2770 | 345 if(d_pos_y<0){ |
346 s_pos_y=-d_pos_y;d_pos_y=0; | |
347 osd_h=codec_context.height; | |
348 } else s_pos_y=0; | |
349 | |
350 printf("[vo] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); | |
351 | |
352 /* open it */ | |
353 if (avcodec_open(&codec_context, codec) < 0) { | |
354 fprintf(stderr, "could not open codec\n"); | |
355 return -1; | |
356 } | |
357 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
358 size = 10000+codec_context.width*codec_context.height; |
2770 | 359 picture_buf = malloc((size * 3)/2); |
2645 | 360 |
361 picture.data[0] = picture_buf; | |
362 picture.data[1] = picture.data[0] + size; | |
363 picture.data[2] = picture.data[1] + size / 4; | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
364 picture.linesize[0] = codec_context.width; |
2645 | 365 picture.linesize[1] = codec_context.width / 2; |
366 picture.linesize[2] = codec_context.width / 2; | |
367 return 0; | |
368 #endif | |
2770 | 369 return -1; |
2645 | 370 } |
371 else if(format==IMGFMT_MPEGPES) | |
372 { | |
373 printf( "Format: MPEG-PES\n" ); | |
374 return 0; | |
375 } | |
376 | |
377 printf( "Format: Unsupported\n" ); | |
378 return -1; | |
379 } | |
380 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
381 static const vo_info_t* get_info(void) |
2645 | 382 { |
383 return &vo_info; | |
384 } | |
385 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
386 static void draw_alpha(int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
2645 | 387 { |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
388 int x,y,index=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
389 int n_rles=0, prev_nibbled=0, nibbled=0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
390 char prevcolor=0; |
2770 | 391 unsigned char *dst = spubuf; |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
392 unsigned short *subpic_size, *cs_table; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
393 subpic_size = dst+=2; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
394 cs_table = dst+=2; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
395 prevcolor = src[0]; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
396 for( y = 0; y <= (h-1); y+=2 ) |
2770 | 397 { |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
398 for( x = 0; x < w; x++ ) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
399 { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
400 if( prevcolor == src[x+(y*w)] ) index++; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
401 else |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
402 { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
403 if( prevcolor < 64 ) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
404 prevcolor = 0x00; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
405 else if( prevcolor < 128 ) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
406 prevcolor = 0x01; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
407 else if( prevcolor < 192 ) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
408 prevcolor = 0x02; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
409 else |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
410 prevcolor = 0x03; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
411 } |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
412 } |
2770 | 413 } |
414 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
415 dxr3_subpic_write(spubuf,(dst-spubuf)); |
2645 | 416 } |
417 | |
418 static void draw_osd(void) | |
419 { | |
420 vo_draw_text(osd_w,osd_h,draw_alpha); | |
421 } | |
422 | |
423 static uint32_t draw_frame(uint8_t * src[]) | |
424 { | |
425 if( img_format == IMGFMT_MPEGPES ) | |
426 { | |
2770 | 427 int data_left; |
2645 | 428 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0]; |
429 | |
430 data_left = p->size; | |
431 while( data_left ) | |
432 data_left -= dxr3_video_write( &((unsigned char*)p->data)[p->size-data_left], data_left ); | |
433 | |
434 return 0; | |
435 } | |
436 #ifdef USE_LIBAVCODEC | |
437 else if( img_format == IMGFMT_YV12 ) | |
438 { | |
439 printf("ERROR: Uninplemented\n"); | |
440 } | |
2770 | 441 else if( img_format == IMGFMT_BGR24 ) |
442 { | |
443 int tmp_size, out_size; | |
444 int wrap, wrap3, x, y; | |
445 int r, g, b, R, G, B, h = v_height, w = v_width; | |
446 unsigned char *s, *Y, *U, *V; | |
447 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
448 printf( "dS: %dx%d dD: %dx%d S: %dx%d V: %dx%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y,s_width,s_height,v_width,v_height); |
2770 | 449 if(d_pos_x+w>picture.linesize[0]) w=picture.linesize[0]-d_pos_x; |
450 if(d_pos_y+h>codec_context.height) h=codec_context.height-d_pos_y; | |
451 | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
452 Y = picture.data[0]+d_pos_x+(d_pos_y*picture.linesize[0]); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
453 U = picture.data[1]+(d_pos_x/2)+((d_pos_y/2)*picture.linesize[1]); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
454 V = picture.data[2]+(d_pos_x/2)+((d_pos_y/2)*picture.linesize[2]); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
455 |
2770 | 456 //BGR24->YUV420P from ffmpeg, see ffmpeg.sourceforge.net for terms of license |
457 #define SCALEBITS 8 | |
458 #define ONE_HALF (1 << (SCALEBITS - 1)) | |
459 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
460 wrap = s_width; |
2770 | 461 wrap3 = w * 3; |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
462 s = src[0]+s_pos_x+(s_pos_y*wrap3); |
2770 | 463 for( y = 0; y < h; y+=2 ) |
464 { | |
465 for( x = 0; x < w; x+=2 ) | |
466 { | |
467 b = s[0]; | |
468 g = s[1]; | |
469 r = s[2]; | |
470 R = r; | |
471 G = g; | |
472 B = b; | |
473 Y[0] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
474 b = s[3]; | |
475 g = s[4]; | |
476 r = s[5]; | |
477 R += r; | |
478 G += g; | |
479 B += b; | |
480 Y[1] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
481 s += wrap3; | |
482 Y += wrap; | |
483 | |
484 b = s[0]; | |
485 g = s[1]; | |
486 r = s[2]; | |
487 R += r; | |
488 G += g; | |
489 B += b; | |
490 Y[0] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
491 b = s[3]; | |
492 g = s[4]; | |
493 r = s[5]; | |
494 R += r; | |
495 G += g; | |
496 B += b; | |
497 Y[1] = (FIX(0.29900) * r + FIX(0.58700) * g + FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; | |
498 U[0] = ((- FIX(0.16874) * R - FIX(0.33126) * G - FIX(0.50000) * B + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
499 V[0] = ((FIX(0.50000) * R - FIX(0.41869) * G - FIX(0.08131) * B + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128; | |
500 | |
501 U++; | |
502 V++; | |
503 s -= (wrap3-6); | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
504 Y -= (wrap-(3/2)); |
2770 | 505 } |
506 s += wrap3; | |
507 Y += wrap; | |
508 } | |
509 #undef SCALEBITS | |
510 #undef ONE_HALF | |
511 #undef FIX(x) | |
512 //End of ffmpeg code, see ffmpeg.sourceforge.net for terms of license | |
513 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture); | |
514 while( out_size ) | |
515 out_size -= dxr3_video_write( &outbuf[tmp_size-out_size], out_size ); | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
516 return 0; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
517 } |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
518 else if( img_format == IMGFMT_YUY2 ) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
519 { |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
520 int tmp_size, out_size; |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
521 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
522 while( out_size ) |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
523 out_size -= dxr3_video_write( &outbuf[tmp_size-out_size], out_size ); |
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
524 |
2770 | 525 return 0; |
526 } | |
2645 | 527 #endif |
528 | |
2770 | 529 printf( "Error in draw_frame(...)\n" ); |
2645 | 530 return -1; |
531 } | |
532 | |
533 static void flip_page (void) | |
534 { | |
535 } | |
536 | |
537 static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) | |
538 { | |
539 int y; | |
540 unsigned char* s; | |
541 unsigned char* d; | |
542 int data_left; | |
543 vo_mpegpes_t *p = (vo_mpegpes_t *)srcimg[0]; | |
544 | |
545 if( img_format == IMGFMT_YV12 ) | |
546 { | |
547 #ifdef USE_LIBAVCODEC | |
2770 | 548 int out_size, tmp_size; |
2645 | 549 x0+=d_pos_x; |
550 y0+=d_pos_y; | |
551 if(x0+w>picture.linesize[0]) w=picture.linesize[0]-x0; // !! | |
552 if(y0+h>codec_context.height) h=codec_context.height-y0; | |
553 | |
554 // Y | |
555 s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; | |
556 d=picture.data[0]+x0+y0*picture.linesize[0]; | |
557 for( y = 0; y < h; y++) | |
558 { | |
559 memcpy(d,s,w); | |
560 s+=stride[0]; | |
561 d+=picture.linesize[0]; | |
562 } | |
563 | |
564 w/=2;h/=2;x0/=2;y0/=2; | |
565 | |
566 // U | |
567 s=srcimg[1]+(s_pos_x/2)+(s_pos_y/2)*stride[1]; | |
568 d=picture.data[1]+x0+y0*picture.linesize[1]; | |
569 for( y = 0; y < h; y++) | |
570 { | |
571 memcpy(d,s,w); | |
572 s+=stride[1]; | |
573 d+=picture.linesize[1]; | |
574 } | |
575 | |
576 // V | |
577 s=srcimg[2]+(s_pos_x/2)+(s_pos_y/2)*stride[2]; | |
578 d=picture.data[2]+x0+y0*picture.linesize[2]; | |
579 for(y=0;y<h;y++) | |
580 { | |
581 memcpy(d,s,w); | |
582 s+=stride[2]; | |
583 d+=picture.linesize[2]; | |
584 } | |
2770 | 585 |
586 tmp_size = out_size = avcodec_encode_video(&codec_context, outbuf, outbuf_size, &picture); | |
587 while( out_size ) | |
588 out_size -= dxr3_video_write( &outbuf[tmp_size-out_size], out_size ); | |
2645 | 589 |
590 return 0; | |
591 #endif | |
2770 | 592 return -1; |
593 } | |
594 else if( img_format == IMGFMT_BGR24 ) | |
595 { | |
2645 | 596 return -1; |
597 } | |
598 else if( img_format == IMGFMT_MPEGPES ) | |
599 { | |
600 data_left = p->size; | |
601 while( data_left ) | |
602 data_left -= dxr3_video_write( &((unsigned char*)p->data)[p->size-data_left], data_left ); | |
603 return 0; | |
604 } | |
605 | |
606 return -1; | |
607 } | |
608 | |
609 | |
610 static uint32_t | |
611 query_format(uint32_t format) | |
612 { | |
2770 | 613 if(format==IMGFMT_MPEGPES) return 0x2|0x4; |
2645 | 614 #ifdef USE_LIBAVCODEC |
2770 | 615 if(format==IMGFMT_YV12) return 0x1|0x4; |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
616 if(format==IMGFMT_YUY2) return 0x1|0x4; |
2770 | 617 if(format==IMGFMT_BGR24) return 0x1|0x4; |
618 #else | |
619 if(format==IMGFMT_YV12) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;} | |
2866
4f6190ab52e7
Added a temporary fix to the DXR3 win32 codec playback, win32 codecs might prove to play back an unscaled image!
mswitch
parents:
2770
diff
changeset
|
620 if(format==IMGFMT_YUY2) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;} |
2770 | 621 if(format==IMGFMT_BGR24) {printf("You need to compile with libavcodec or ffmpeg.so to play this file!\n" ); return 0;} |
622 #endif | |
2645 | 623 return 0; |
624 } | |
625 | |
626 static void | |
627 uninit(void) | |
628 { | |
2770 | 629 free(outbuf); |
630 free(picture_buf); | |
631 free(spubuf); | |
2645 | 632 dxr3_close( ); |
633 } | |
634 | |
635 | |
636 static void check_events(void) | |
637 { | |
638 } | |
639 |