Mercurial > mplayer.hg
comparison libvo/vo_dxr3.c @ 6647:c66284733f3d
removed fame and lavc encoder, enabled spu encoder, added equaliuzer support
author | alex |
---|---|
date | Fri, 05 Jul 2002 14:26:37 +0000 |
parents | d6c07ebda746 |
children | c0e8034d47e4 |
comparison
equal
deleted
inserted
replaced
6646:6cfc8fd31299 | 6647:c66284733f3d |
---|---|
4 * Copyright (C) 2002 David Holm <dholm@iname.com> | 4 * Copyright (C) 2002 David Holm <dholm@iname.com> |
5 * | 5 * |
6 */ | 6 */ |
7 | 7 |
8 /* ChangeLog added 2002-01-10 | 8 /* ChangeLog added 2002-01-10 |
9 * 2002-07-05: | |
10 * Removed lavc and fame encoder to be compatible with new libvo style. | |
11 * Added graphic equalizer support. | |
12 * | |
9 * 2002-04-15: | 13 * 2002-04-15: |
10 * The spuenc code isn't 100% stable yet, therefore I'm disabling | 14 * The spuenc code isn't 100% stable yet, therefore I'm disabling |
11 * it due to the upcoming stable release. | 15 * it due to the upcoming stable release. |
12 * | 16 * |
13 * 2002-04-03: | 17 * 2002-04-03: |
88 #include "fastmemcpy.h" | 92 #include "fastmemcpy.h" |
89 | 93 |
90 #include "video_out.h" | 94 #include "video_out.h" |
91 #include "video_out_internal.h" | 95 #include "video_out_internal.h" |
92 #include "aspect.h" | 96 #include "aspect.h" |
93 #include "postproc/rgb2rgb.h" | |
94 #include "postproc/swscale.h" | |
95 #include "cpudetect.h" | 97 #include "cpudetect.h" |
96 #include "spuenc.h" | 98 #include "spuenc.h" |
97 | 99 #include "../vidix/vidixlib.h" |
98 //#define USE_LIBFAME // this is done in configure now | 100 |
99 | 101 #define SPU_SUPPORT |
100 /* Libfame codec initialisation */ | 102 |
101 #ifdef USE_LIBFAME | 103 static vo_info_t vo_info = |
102 #include "../libfame/fame.h" | 104 { |
103 static unsigned char *outbuf = NULL; | 105 "DXR3/H+ video out", |
104 static fame_parameters_t fame_params; | 106 "dxr3", |
105 static fame_yuv_t fame_yuv; | 107 "David Holm <dholm@iname.com>", |
106 static fame_context_t *fame_ctx = NULL; | 108 "" |
107 static fame_object_t *fame_obj; | 109 }; |
108 #endif | |
109 | |
110 /* libavcodec codec initialisation */ | |
111 #ifdef USE_LIBAVCODEC | |
112 #ifdef USE_LIBAVCODEC_SO | |
113 #include <libffmpeg/avcodec.h> | |
114 #include <libffmpeg/dsputil.h> | |
115 #else | |
116 #include "libavcodec/avcodec.h" | |
117 #include "libavcodec/dsputil.h" | |
118 #endif | |
119 /* for video encoder */ | |
120 static AVCodec *avc_codec = NULL; | |
121 static AVCodecContext *avc_context = NULL; | |
122 static AVPicture avc_picture; | |
123 int avc_outbuf_size = 100000; | |
124 extern int avcodec_inited; | |
125 extern int motion_estimation_method; | |
126 #endif | |
127 | |
128 char *picture_data[] = { NULL, NULL, NULL }; | |
129 int picture_linesize[] = { 0, 0, 0 }; | |
130 | |
131 #ifdef HAVE_MMX | |
132 #include "mmx.h" | |
133 #endif | |
134 | |
135 LIBVO_EXTERN (dxr3) | 110 LIBVO_EXTERN (dxr3) |
136 | |
137 /* codec control */ | |
138 enum MpegCodec { | |
139 MPG_CODEC_NON, | |
140 MPG_CODEC_AVCODEC, | |
141 MPG_CODEC_FAME | |
142 }; | |
143 | |
144 #if defined(USE_LIBAVCODEC) | |
145 static int mpeg_codec = MPG_CODEC_AVCODEC; | |
146 #elif defined(USE_LIBFAME) | |
147 static int mpeg_codec = MPG_CODEC_FAME; | |
148 #else | |
149 static int mpeg_codec = MPG_CODEC_NONE; | |
150 #endif | |
151 | 111 |
152 /* Resolutions and positions */ | 112 /* Resolutions and positions */ |
153 static int v_width, v_height; | 113 static int v_width, v_height; |
154 static int s_width, s_height; | 114 static int s_width, s_height; |
155 static int osd_w, osd_h; | 115 static int osd_w, osd_h; |
156 static int noprebuf = 0; | 116 static int noprebuf = 0; |
157 static int img_format = 0; | 117 static int img_format = 0; |
158 static SwsContext * sws = NULL; | |
159 | 118 |
160 /* File descriptors */ | 119 /* File descriptors */ |
161 static int fd_control = -1; | 120 static int fd_control = -1; |
162 static int fd_video = -1; | 121 static int fd_video = -1; |
163 static int fd_spu = -1; | 122 static int fd_spu = -1; |
164 static char fdv_name[80]; | 123 static char fdv_name[80]; |
165 static char fds_name[80]; | 124 static char fds_name[80]; |
166 | 125 |
126 #ifdef SPU_SUPPORT | |
167 /* on screen display/subpics */ | 127 /* on screen display/subpics */ |
168 static char *osdpicbuf = NULL; | 128 static char *osdpicbuf = NULL; |
169 static int osdpicbuf_w; | 129 static int osdpicbuf_w; |
170 static int osdpicbuf_h; | 130 static int osdpicbuf_h; |
171 static int disposd = 0; | 131 static int disposd = 0; |
172 static encodedata *spued; | 132 static encodedata *spued; |
133 #endif | |
173 | 134 |
174 /* Static variable used in ioctl's */ | 135 /* Static variable used in ioctl's */ |
175 static int ioval = 0; | 136 static int ioval = 0; |
176 | 137 |
177 static vo_info_t vo_info = | 138 static int get_video_eq(vidix_video_eq_t *info); |
178 { | 139 static int set_video_eq(vidix_video_eq_t *info); |
179 "DXR3/H+ video out", | |
180 "dxr3", | |
181 "David Holm <dholm@iname.com>", | |
182 "" | |
183 }; | |
184 | 140 |
185 uint32_t control(uint32_t request, void *data, ...) | 141 uint32_t control(uint32_t request, void *data, ...) |
186 { | 142 { |
187 uint32_t flag = 0; | |
188 switch (request) { | 143 switch (request) { |
189 case VOCTRL_RESUME: | 144 case VOCTRL_RESUME: |
190 if (!noprebuf) { | 145 if (!noprebuf) { |
191 ioval = EM8300_PLAYMODE_PLAY; | 146 ioval = EM8300_PLAYMODE_PLAY; |
192 if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) { | 147 if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) { |
211 fsync(fd_video); | 166 fsync(fd_video); |
212 fsync(fd_spu); | 167 fsync(fd_spu); |
213 } | 168 } |
214 return VO_TRUE; | 169 return VO_TRUE; |
215 case VOCTRL_QUERY_FORMAT: | 170 case VOCTRL_QUERY_FORMAT: |
216 switch (*((uint32_t*)data)) { | 171 { |
217 case IMGFMT_MPEGPES: | 172 uint32_t flag = 0; |
218 /* Hardware accelerated | Hardware supports subpics */ | 173 |
219 flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_SPU; | 174 if (*((uint32_t*)data) != IMGFMT_MPEGPES) |
220 break; | 175 return 0; |
221 #if defined(USE_LIBFAME) || defined(USE_LIBAVCODEC) | 176 |
222 case IMGFMT_YV12: | 177 flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_SPU; |
223 case IMGFMT_YUY2: | 178 if (!noprebuf) |
224 case IMGFMT_RGB24: | 179 flag |= VFCAP_TIMER; |
225 case IMGFMT_BGR24: | 180 return flag; |
226 /* Conversion needed | OSD Supported */ | 181 } |
227 flag = VFCAP_CSP_SUPPORTED | VFCAP_OSD; | 182 case VOCTRL_QUERY_VAA: |
228 break; | 183 { |
229 #else | 184 vo_vaa_t *vaa = data; |
230 default: | 185 |
231 printf("VO: [dxr3] You have disabled libavcodec/libfame support (Read DOCS/codecs.html)!\n"); | 186 memset(vaa,0,sizeof(vo_vaa_t)); |
232 #endif | 187 vaa->get_video_eq=get_video_eq; |
233 } | 188 vaa->set_video_eq=set_video_eq; |
234 if (noprebuf) { | 189 return VO_TRUE; |
235 return flag; | 190 } |
236 } else { | |
237 return (flag | VFCAP_TIMER); | |
238 } | |
239 } | 191 } |
240 return VO_NOTIMPL; | 192 return VO_NOTIMPL; |
241 } | 193 } |
242 | 194 |
243 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format, const vo_tune_info_t *info) | 195 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format, const vo_tune_info_t *info) |
322 } else { | 274 } else { |
323 ioval = EM8300_ASPECTRATIO_16_9; | 275 ioval = EM8300_ASPECTRATIO_16_9; |
324 printf("VO: [dxr3] Setting aspect ratio to 16:9\n"); | 276 printf("VO: [dxr3] Setting aspect ratio to 16:9\n"); |
325 } | 277 } |
326 ioctl(fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval); | 278 ioctl(fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval); |
327 | 279 |
328 if (format != IMGFMT_MPEGPES) { | 280 #ifdef SPU_SUPPORT |
329 size = s_width * s_height; | 281 osdpicbuf = malloc(s_width * s_height); |
330 picture_data[0] = malloc((size * 3) / 2); | 282 if (osdpicbuf == NULL) { |
331 picture_data[1] = picture_data[0] + size; | 283 printf("vo_dxr3: out of mem\n"); |
332 picture_data[2] = picture_data[1] + size / 4; | 284 return -1; |
333 | 285 } |
334 picture_linesize[0] = s_width; | 286 spued = (encodedata *) malloc(sizeof(encodedata)); |
335 picture_linesize[1] = s_width / 2; | 287 if (spued == NULL) { |
336 picture_linesize[2] = s_width / 2; | 288 printf("vo_dxr3:out of mem\n"); |
337 switch (mpeg_codec) { | 289 return -1; |
338 #ifdef USE_LIBFAME | 290 } |
339 case MPG_CODEC_FAME: | 291 osd_w = s_width; |
340 printf("VO: [dxr3] Using FAME\n"); | 292 osd_h = s_height; |
341 fame_ctx = fame_open(); | 293 osdpicbuf_w = s_width; |
342 if (!fame_ctx) { | 294 osdpicbuf_h = s_height; |
343 printf("VO: [dxr3] Cannot open libFAME!\n"); | 295 #endif |
344 return -1; | 296 |
345 } | 297 return 0; |
346 | |
347 fame_obj = fame_get_object(fame_ctx, "motion/pmvfast"); | |
348 fame_register(fame_ctx, "motion", fame_obj); | |
349 | |
350 memset(&fame_params, 0, sizeof(fame_parameters_t)); | |
351 fame_params.width = s_width; | |
352 fame_params.height = s_height; | |
353 fame_params.coding = "IPPPPPPP"; | |
354 fame_params.quality = 90; | |
355 fame_params.bitrate = 0; | |
356 fame_params.slices_per_frame = 1; | |
357 fame_params.frames_per_sequence = (int) (vo_fps + 0.5); | |
358 fame_params.shape_quality = 100; | |
359 fame_params.search_range = (int) (vo_fps + 0.5); | |
360 fame_params.verbose = 0; | |
361 fame_params.profile = NULL; | |
362 | |
363 if (vo_fps < 24.0) { | |
364 fame_params.frame_rate_num = 24000; | |
365 fame_params.frame_rate_den = 1001; | |
366 } else if (vo_fps < 25.0) { | |
367 fame_params.frame_rate_num = 24; | |
368 fame_params.frame_rate_den = 1; | |
369 } else if (vo_fps < 29.0) { | |
370 fame_params.frame_rate_num = 25; | |
371 fame_params.frame_rate_den = 1; | |
372 } else if (vo_fps < 30.0) { | |
373 fame_params.frame_rate_num = 30000; | |
374 fame_params.frame_rate_den = 1001; | |
375 } else if (vo_fps < 50.0) { | |
376 fame_params.frame_rate_num = 30; | |
377 fame_params.frame_rate_den = 1; | |
378 } else if (vo_fps < 55.0) { | |
379 fame_params.frame_rate_num = 50; | |
380 fame_params.frame_rate_den = 1; | |
381 } else if (vo_fps < 60.0) { | |
382 fame_params.frame_rate_num = 60000; | |
383 fame_params.frame_rate_den = 1001; | |
384 } else { | |
385 fame_params.frame_rate_num = 60; | |
386 fame_params.frame_rate_den = 1; | |
387 } | |
388 | |
389 outbuf = malloc(100000); | |
390 fame_init(fame_ctx, &fame_params, outbuf, 100000); | |
391 | |
392 fame_yuv.w = s_width; | |
393 fame_yuv.h = s_height; | |
394 fame_yuv.y = picture_data[0]; | |
395 fame_yuv.u = picture_data[1]; | |
396 fame_yuv.v = picture_data[2]; | |
397 break; | |
398 #endif | |
399 #ifdef USE_LIBAVCODEC | |
400 case MPG_CODEC_AVCODEC: | |
401 printf("VO: [dxr3] Using AVCODEC\n"); | |
402 avc_codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); | |
403 if (!avc_codec) { | |
404 printf("VO: [dxr3] Unable to find mpeg1video codec\n"); | |
405 uninit(); | |
406 return -1; | |
407 } | |
408 if (avc_context) { | |
409 free(avc_context); | |
410 } | |
411 avc_context = malloc(sizeof(AVCodecContext)); | |
412 memset(avc_context, 0, sizeof(AVCodecContext)); | |
413 avc_context->width = s_width; | |
414 avc_context->height = s_height; | |
415 // realy need this line ? -- Pontscho | |
416 // ioctl(fd_control, EM8300_IOCTL_GET_VIDEOMODE, &ioval); | |
417 avc_context->gop_size = 7; | |
418 avc_context->frame_rate = (int) (vo_fps * FRAME_RATE_BASE); | |
419 avc_context->bit_rate = 0; | |
420 avc_context->flags = CODEC_FLAG_QSCALE; | |
421 avc_context->quality = 2; | |
422 avc_context->pix_fmt = PIX_FMT_YUV420P; | |
423 motion_estimation_method = ME_EPZS; | |
424 if (avcodec_open(avc_context, avc_codec) < 0) { | |
425 printf("VO: [dxr3] Unable to open codec\n"); | |
426 uninit(); | |
427 return -1; | |
428 } | |
429 /* Create a pixel buffer and set up pointers for color components */ | |
430 memset(&avc_picture, 0, sizeof(avc_picture)); | |
431 avc_picture.linesize[0] = picture_linesize[0]; | |
432 avc_picture.linesize[1] = picture_linesize[1]; | |
433 avc_picture.linesize[2] = picture_linesize[2]; | |
434 | |
435 avc_picture.data[0] = picture_data[0]; | |
436 avc_picture.data[1] = picture_data[1]; | |
437 avc_picture.data[2] = picture_data[2]; | |
438 break; | |
439 #endif | |
440 } | |
441 | |
442 sws = getSwsContextFromCmdLine(v_width, v_height, img_format, s_width, s_height, IMGFMT_YV12); | |
443 if (!sws) { | |
444 printf("vo_vesa: Can't initialize SwScaler\n"); | |
445 return -1; | |
446 } | |
447 | |
448 /* This stuff calculations the relative position of the osd */ | |
449 osd_w = s_width; | |
450 osd_h = s_height; | |
451 | |
452 if (format == IMGFMT_BGR24) { | |
453 yuv2rgb_init(24, MODE_BGR); | |
454 } else { | |
455 yuv2rgb_init(24, MODE_RGB); | |
456 } | |
457 return 0; | |
458 } else if (format == IMGFMT_MPEGPES) { | |
459 printf("VO: [dxr3] Format: MPEG-PES (no conversion needed)\n"); | |
460 osdpicbuf = malloc(s_width * s_height); | |
461 if (osdpicbuf == NULL) { | |
462 printf("vo_dxr3: out of mem\n"); | |
463 return -1; | |
464 } | |
465 spued = (encodedata *) malloc(sizeof(encodedata)); | |
466 if (spued == NULL) { | |
467 printf("vo_dxr3:out of mem\n"); | |
468 return -1; | |
469 } | |
470 osd_w = s_width; | |
471 osd_h = s_height; | |
472 osdpicbuf_w = s_width; | |
473 osdpicbuf_h = s_height; | |
474 | |
475 return 0; | |
476 } | |
477 | |
478 printf("VO: [dxr3] Format: Unsupported\n"); | |
479 uninit(); | |
480 return -1; | |
481 } | 298 } |
482 | 299 |
483 static const vo_info_t* get_info(void) | 300 static const vo_info_t* get_info(void) |
484 { | 301 { |
485 return &vo_info; | 302 return &vo_info; |
486 } | 303 } |
487 | 304 |
488 static void draw_alpha(int x, int y, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) | 305 static void draw_alpha(int x, int y, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) |
489 { | 306 { |
490 /*int lx, ly, bx; | 307 #ifdef SPU_SUPPORT |
491 unsigned char *buf; | 308 int lx, ly, bx; |
492 buf = &osdpicbuf[(y * osdpicbuf_w) + x]; | 309 unsigned char *buf = &osdpicbuf[(y * osdpicbuf_w) + x]; |
493 if (img_format == IMGFMT_MPEGPES) { | 310 for (ly = 0; ly < h - 1; ly++) { |
494 for (ly = 0; ly < h - 1; ly++) { | 311 for(lx = 0; lx < w; lx++) { |
495 for(lx = 0; lx < w; lx++) { | 312 if ((srca[(ly * srcstride) + lx] != 0) && (src[(ly * srcstride) + lx] != 0)) { |
496 if ((srca[(ly * srcstride) + lx] != 0) && (src[(ly * srcstride) + lx] != 0)) { | 313 if(src[(ly * srcstride) + lx] >= 128) { |
497 if(src[(ly * srcstride) + lx] >= 128) { | 314 buf[ly * osdpicbuf_w + lx] = 3; |
498 buf[ly * osdpicbuf_w + lx] = 3; | |
499 } | |
500 } | 315 } |
501 } | 316 } |
502 } | 317 } |
503 pixbuf_encode_rle(x, y, osdpicbuf_w, osdpicbuf_h - 1, osdpicbuf, osdpicbuf_w, spued); | 318 } |
504 } else*/ { | 319 pixbuf_encode_rle(x, y, osdpicbuf_w, osdpicbuf_h - 1, osdpicbuf, osdpicbuf_w, spued); |
505 #if defined(USE_LIBAVCODEC) || defined(USE_LIBFAME) | 320 #endif |
506 vo_draw_alpha_yv12(w, h, src, srca, srcstride, | |
507 picture_data[0] + x + y * picture_linesize[0], picture_linesize[0]); | |
508 #endif | |
509 } | |
510 } | 321 } |
511 | 322 |
512 static void draw_osd(void) | 323 static void draw_osd(void) |
513 { | 324 { |
514 if (img_format != IMGFMT_MPEGPES) { | 325 #ifdef SPU_SUPPORT |
515 vo_draw_text(osd_w, osd_h, draw_alpha); | 326 if ((disposd % 15) == 0) { |
516 } /*else if ((disposd % 15) == 0) { | |
517 vo_draw_text(osd_w, osd_h, draw_alpha); | 327 vo_draw_text(osd_w, osd_h, draw_alpha); |
518 memset(osdpicbuf, 0, s_width * s_height); | 328 memset(osdpicbuf, 0, s_width * s_height); |
519 */ | 329 |
520 /* could stand some check here to see if the subpic hasn't changed | 330 /* could stand some check here to see if the subpic hasn't changed |
521 * as if it hasn't and we re-send it it will "blink" as the last one | 331 * as if it hasn't and we re-send it it will "blink" as the last one |
522 * is turned off, and the new one (same one) is turned on | 332 * is turned off, and the new one (same one) is turned on |
523 */ | 333 */ |
524 /*if (!noprebuf) { | 334 if (!noprebuf) { |
525 ioctl(fd_spu, EM8300_IOCTL_SPU_SETPTS, &vo_pts); | 335 ioctl(fd_spu, EM8300_IOCTL_SPU_SETPTS, &vo_pts); |
526 } | 336 } |
527 write(fd_spu, spued->data, spued->count); | 337 write(fd_spu, spued->data, spued->count); |
528 } | 338 } |
529 disposd++;*/ | 339 disposd++; |
340 #endif | |
530 } | 341 } |
531 | 342 |
532 | 343 |
533 static uint32_t draw_frame(uint8_t * src[]) | 344 static uint32_t draw_frame(uint8_t * src[]) |
534 { | 345 { |
535 char *pData; | 346 char *pData; |
536 int pSize; | 347 int pSize; |
537 if (img_format == IMGFMT_MPEGPES) { | 348 vo_mpegpes_t *p = (vo_mpegpes_t *) src[0]; |
538 vo_mpegpes_t *p = (vo_mpegpes_t *) src[0]; | |
539 | 349 |
540 if (p->id == 0x20) { | 350 #ifdef SPU_SUPPORT |
541 if (!noprebuf) { | 351 if (p->id == 0x20) { |
542 ioctl(fd_spu, EM8300_IOCTL_SPU_SETPTS, &vo_pts); | 352 if (!noprebuf) { |
543 } | 353 ioctl(fd_spu, EM8300_IOCTL_SPU_SETPTS, &vo_pts); |
544 write(fd_spu, p->data, p->size); | 354 } |
545 } else { | 355 write(fd_spu, p->data, p->size); |
546 write(fd_video, p->data, p->size); | 356 } else |
547 } | 357 #endif |
548 return 0; | 358 write(fd_video, p->data, p->size); |
549 } else { | 359 return 0; |
550 int size, srcStride = (img_format == IMGFMT_YUY2) ? (v_width * 2) : (v_width * 3); | |
551 sws->swScale(sws, src, &srcStride, 0, v_height, picture_data, picture_linesize); | |
552 draw_osd(); | |
553 switch (mpeg_codec) { | |
554 #ifdef USE_LIBFAME | |
555 case MPG_CODEC_FAME: | |
556 size = fame_encode_frame(fame_ctx, &fame_yuv, NULL); | |
557 write(fd_video, outbuf, size); | |
558 break; | |
559 #endif | |
560 #ifdef USE_LIBAVCODEC | |
561 case MPG_CODEC_AVCODEC: | |
562 size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture); | |
563 write(fd_video, picture_data[0], size); | |
564 break; | |
565 #endif | |
566 } | |
567 return 0; | |
568 } | |
569 return -1; | |
570 } | 360 } |
571 | 361 |
572 static void flip_page(void) | 362 static void flip_page(void) |
573 { | 363 { |
574 int size; | 364 int size; |
575 if (!noprebuf) { | 365 if (!noprebuf) { |
576 ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts); | 366 ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts); |
577 } | 367 } |
578 if (img_format == IMGFMT_YV12) { | |
579 switch (mpeg_codec) { | |
580 #ifdef USE_LIBFAME | |
581 case MPG_CODEC_FAME: | |
582 size = fame_encode_frame(fame_ctx, &fame_yuv, NULL); | |
583 write(fd_video, outbuf, size); | |
584 break; | |
585 #endif | |
586 #ifdef USE_LIBAVCODEC | |
587 case MPG_CODEC_AVCODEC: | |
588 size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture); | |
589 if (!noprebuf) { | |
590 ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts); | |
591 } | |
592 write(fd_video, picture_data[0], size); | |
593 break; | |
594 #endif | |
595 } | |
596 } | |
597 } | 368 } |
598 | 369 |
599 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0) | 370 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0) |
600 { | 371 { |
601 if (img_format == IMGFMT_YV12) { | |
602 sws->swScale(sws, srcimg, stride, y0, h, picture_data, picture_linesize); | |
603 return 0; | |
604 } | |
605 return -1; | 372 return -1; |
606 } | 373 } |
607 | 374 |
608 static void uninit(void) | 375 static void uninit(void) |
609 { | 376 { |
610 printf("VO: [dxr3] Uninitializing\n"); | 377 printf("VO: [dxr3] Uninitializing\n"); |
611 if (sws) { | |
612 freeSwsContext(sws); | |
613 } | |
614 | |
615 switch (mpeg_codec) { | |
616 #ifdef USE_LIBFAME | |
617 case MPG_CODEC_FAME: | |
618 if (fame_ctx) { | |
619 fame_close(fame_ctx); | |
620 } | |
621 break; | |
622 #endif | |
623 #ifdef USE_LIBAVCODEC | |
624 case MPG_CODEC_AVCODEC: | |
625 if (avc_context) { | |
626 avcodec_close(avc_context); | |
627 } | |
628 break; | |
629 #endif | |
630 } | |
631 if (picture_data[0]) { | |
632 free(picture_data[0]); | |
633 } | |
634 if (fd_video) { | 378 if (fd_video) { |
635 close(fd_video); | 379 close(fd_video); |
636 } | 380 } |
637 if (fd_spu) { | 381 if (fd_spu) { |
638 close(fd_spu); | 382 close(fd_spu); |
639 } | 383 } |
640 if (fd_control) { | 384 if (fd_control) { |
641 close(fd_control); | 385 close(fd_control); |
642 } | 386 } |
387 #ifdef SPU_SUPPORT | |
643 if(osdpicbuf) { | 388 if(osdpicbuf) { |
644 free(osdpicbuf); | 389 free(osdpicbuf); |
645 } | 390 } |
646 if(spued) { | 391 if(spued) { |
647 free(spued); | 392 free(spued); |
648 } | 393 } |
394 #endif | |
649 } | 395 } |
650 | 396 |
651 static void check_events(void) | 397 static void check_events(void) |
652 { | 398 { |
653 } | 399 } |
673 if (cpucaps.has3DNowExt) { | 419 if (cpucaps.has3DNowExt) { |
674 printf("VO: [dxr3] Fast AMD special disabling prebuffering.\n"); | 420 printf("VO: [dxr3] Fast AMD special disabling prebuffering.\n"); |
675 noprebuf = 1; | 421 noprebuf = 1; |
676 fdflags |= O_NONBLOCK; | 422 fdflags |= O_NONBLOCK; |
677 } | 423 } |
678 | |
679 #if defined(USE_LIBFAME) | |
680 printf("VO: [dxr3] FAME supported\n"); | |
681 if (arg && !strncmp("fame", arg, 4)) { | |
682 mpeg_codec = MPG_CODEC_FAME; | |
683 arg = strchr(arg, ':'); | |
684 if (arg) { | |
685 arg++; | |
686 } | |
687 } | |
688 #endif | |
689 #if defined(USE_LIBAVCODEC) | |
690 printf("VO: [dxr3] AVCODEC supported\n"); | |
691 if (arg && !strncmp("avcodec", arg, 7)) { | |
692 mpeg_codec = MPG_CODEC_AVCODEC; | |
693 arg = strchr(arg, ':'); | |
694 if (arg) { | |
695 arg++; | |
696 } | |
697 } | |
698 #endif | |
699 | 424 |
700 if (arg && arg[0]) { | 425 if (arg && arg[0]) { |
701 printf("VO: [dxr3] Forcing use of device %s\n", arg); | 426 printf("VO: [dxr3] Forcing use of device %s\n", arg); |
702 sprintf(devname, "/dev/em8300-%s", arg); | 427 sprintf(devname, "/dev/em8300-%s", arg); |
703 } else { | 428 } else { |
758 uninit(); | 483 uninit(); |
759 return -1; | 484 return -1; |
760 } | 485 } |
761 } | 486 } |
762 strcpy(fds_name, devname); | 487 strcpy(fds_name, devname); |
763 | |
764 #if defined(USE_LIBAVCODEC) | |
765 if (mpeg_codec == MPG_CODEC_AVCODEC && !avcodec_inited) { | |
766 avcodec_init(); | |
767 avcodec_register_all(); | |
768 avcodec_inited = 1; | |
769 } | |
770 | |
771 #endif | |
772 | 488 |
773 return 0; | 489 return 0; |
774 } | 490 } |
491 | |
492 static int get_video_eq(vidix_video_eq_t *info) | |
493 { | |
494 em8300_bcs_t bcs; | |
495 | |
496 if (ioctl(fd_control, EM8300_IOCTL_GETBCS, &bcs) < 0) | |
497 return 1; | |
498 info->brightness = bcs.brightness; | |
499 info->contrast = bcs.contrast; | |
500 info->saturation = bcs.saturation; | |
501 info->cap = VEQ_CAP_BRIGHTNESS|VEQ_CAP_CONTRAST|VEQ_CAP_SATURATION; | |
502 return 0; | |
503 } | |
504 | |
505 static int set_video_eq(vidix_video_eq_t *info) | |
506 { | |
507 em8300_bcs_t bcs; | |
508 | |
509 if (info->cap & VEQ_CAP_BRIGHTNESS) | |
510 bcs.brightness = info->brightness; | |
511 if (info->cap & VEQ_CAP_CONTRAST) | |
512 bcs.contrast = info->contrast; | |
513 if (info->cap & VEQ_CAP_SATURATION) | |
514 bcs.saturation = info->saturation; | |
515 | |
516 if (ioctl(fd_control, EM8300_IOCTL_SETBCS, &bcs) < 0) | |
517 return 1; | |
518 return 0; | |
519 } |