diff options
author | mswitch <mswitch@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-03-26 18:47:42 +0000 |
---|---|---|
committer | mswitch <mswitch@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-03-26 18:47:42 +0000 |
commit | 95a5682456a2107575a77053c93a74408a6e5270 (patch) | |
tree | b4f20f539ee8f0df2ea52a586805f0e46640c1a0 /libvo/vo_dxr3.c | |
parent | c1205011cc7e5a82e87a4c50cf8e7dc9e733bade (diff) | |
download | mpv-95a5682456a2107575a77053c93a74408a6e5270.tar.bz2 mpv-95a5682456a2107575a77053c93a74408a6e5270.tar.xz |
XorA added the option of switching between fame/avcodec without
recompiling. Docs updated accordingly
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5362 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_dxr3.c')
-rw-r--r-- | libvo/vo_dxr3.c | 120 |
1 files changed, 102 insertions, 18 deletions
diff --git a/libvo/vo_dxr3.c b/libvo/vo_dxr3.c index 709e27a0eb..d31b7c5bf2 100644 --- a/libvo/vo_dxr3.c +++ b/libvo/vo_dxr3.c @@ -6,6 +6,10 @@ */ /* ChangeLog added 2002-01-10 + * 2002-03-26: + * XorA added an option parser and support for selecting encoder + * codec. We thank him again. + * * 2002-03-25: * A couple of bugfixes by XorA * @@ -83,11 +87,9 @@ #include "../postproc/swscale.h" #include "../cpudetect.h" -#ifndef USE_LIBAVCODEC -# define USE_LIBFAME -#else -# undef USE_LIBFAME -#endif +#define USE_LIBFAME + +/* Libfame codec initialisation */ #ifdef USE_LIBFAME #include "../libfame/fame.h" static unsigned char *outbuf = NULL; @@ -95,7 +97,10 @@ static fame_parameters_t fame_params; static fame_yuv_t fame_yuv; static fame_context_t *fame_ctx = NULL; static fame_object_t *fame_obj; -#elif USE_LIBAVCODEC +#endif + +/* libavcodec codec initialisation */ +#ifdef USE_LIBAVCODEC #ifdef USE_LIBAVCODEC_SO #include <libffmpeg/avcodec.h> #else @@ -116,6 +121,21 @@ int picture_linesize[] = { 0, 0, 0 }; #endif LIBVO_EXTERN (dxr3) +/* codec control */ +enum MpegCodec +{ + MPG_CODEC_NON, + MPG_CODEC_AVCODEC, + MPG_CODEC_FAME +}; + +#if defined(USE_LIBFAME) +static int mpeg_codec = MPG_CODEC_FAME; +#elif defined(USE_LIBAVCODEC) +static int mpeg_codec = MPG_CODEC_AVCODEC; +#else +statuc int mpeg_codec = MPG_CODEC_NONE; +#endif /* Resolutions and positions */ static int v_width, v_height; @@ -284,7 +304,11 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 picture_linesize[0] = s_width; picture_linesize[1] = s_width / 2; picture_linesize[2] = s_width / 2; + switch(mpeg_codec) + { #ifdef USE_LIBFAME + case MPG_CODEC_FAME: + printf("VO: [dxr3] Using FAME\n"); fame_ctx = fame_open(); if (!fame_ctx) { printf("VO: [dxr3] Cannot open libFAME!\n"); @@ -340,7 +364,11 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 fame_yuv.y = picture_data[0]; fame_yuv.u = picture_data[1]; fame_yuv.v = picture_data[2]; -#elif USE_LIBAVCODEC + break; +#endif +#ifdef USE_LIBAVCODEC + case MPG_CODEC_AVCODEC: + printf("VO: [dxr3] Using AVCODEC\n"); avc_codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); if (!avc_codec) { printf("VO: [dxr3] Unable to find mpeg1video codec\n"); @@ -376,7 +404,10 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32 avc_picture.data[0] = picture_data[0]; avc_picture.data[1] = picture_data[1]; avc_picture.data[2] = picture_data[2]; + break; #endif + } + sws = getSwsContextFromCmdLine(v_width, v_height, img_format, s_width, s_height, IMGFMT_YV12); if (!sws) { printf("vo_vesa: Can't initialize SwScaler\n"); @@ -441,13 +472,21 @@ static uint32_t draw_frame(uint8_t * src[]) int size, srcStride = (img_format == IMGFMT_YUY2) ? (v_width * 2) : (v_width * 3); sws->swScale(sws, src, &srcStride, 0, v_height, picture_data, picture_linesize); draw_osd(); + switch(mpeg_codec) + { #ifdef USE_LIBFAME + case MPG_CODEC_FAME: size = fame_encode_frame(fame_ctx, &fame_yuv, NULL); write(fd_video, outbuf, size); -#elif USE_LIBAVCODEC + break; +#endif +#ifdef USE_LIBAVCODEC + case MPG_CODEC_AVCODEC: size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture); write(fd_video, picture_data[0], size); + break; #endif + } return 0; } return -1; @@ -455,20 +494,29 @@ static uint32_t draw_frame(uint8_t * src[]) static void flip_page(void) { + int size; if (!noprebuf) { ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts); } if (img_format == IMGFMT_YV12) { + switch(mpeg_codec) + { #ifdef USE_LIBFAME - int size = fame_encode_frame(fame_ctx, &fame_yuv, NULL); + case MPG_CODEC_FAME: + size = fame_encode_frame(fame_ctx, &fame_yuv, NULL); write(fd_video, outbuf, size); -#elif USE_LIBAVCODEC - int size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture); + break; +#endif +#ifdef USE_LIBAVCODEC + case MPG_CODEC_AVCODEC: + size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture); if (!noprebuf) { ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts); } write(fd_video, picture_data[0], size); + break; #endif + } } } @@ -487,15 +535,24 @@ static void uninit(void) if (sws) { freeSwsContext(sws); } + + switch(mpeg_codec) + { #ifdef USE_LIBFAME + case MPG_CODEC_FAME: if (fame_ctx) { fame_close(fame_ctx); } -#elif USE_LIBAVCODEC + break; +#endif +#ifdef USE_LIBAVCODEC + case MPG_CODEC_AVCODEC: if (avc_context) { avcodec_close(avc_context); } + break; #endif + } if (picture_data[0]) { free(picture_data[0]); } @@ -522,13 +579,39 @@ static uint32_t preinit(const char *arg) GetCpuCaps(&cpucaps); /* Open the control interface */ - if ((arg && !strcmp("noprebuf", arg)) || cpucaps.has3DNowExt) { + if (arg && !strncmp("noprebuf", arg,8)) { printf("VO: [dxr3] Disabling prebuffering.\n"); noprebuf = 1; fdflags |= O_NONBLOCK; + arg=strchr(arg,':'); + if(arg) arg++; } - if (arg && !noprebuf) { + if(cpucaps.has3DNowExt) + { + printf("VO: [dxr3] fast AMD special disabling prebuffering.\n"); + noprebuf = 1; + fdflags |= O_NONBLOCK; + } + +#if defined(USE_LIBFAME) + printf("VO: [dxr3] FAME supported\n"); + if (arg && !strncmp("fame",arg,4)) { + mpeg_codec=MPG_CODEC_FAME; + arg=strchr(arg,':'); + if(arg) arg++; + } +#endif +#if defined(USE_LIBAVCODEC) + printf("VO: [dxr3] AVCODEC supported\n"); + if (arg && !strncmp("avcodec",arg,7)) { + mpeg_codec=MPG_CODEC_AVCODEC; + arg=strchr(arg,':'); + if(arg) arg++; + } +#endif + + if (arg && arg[0]) { printf("VO: [dxr3] Forcing use of device %s\n", arg); sprintf(devname, "/dev/em8300-%s", arg); } else { @@ -590,10 +673,11 @@ static uint32_t preinit(const char *arg) } } -#if !defined(USE_LIBFAME) && defined(USE_LIBAVCODEC) - avcodec_init(); - avcodec_register_all(); -#endif + if(mpeg_codec==MPG_CODEC_AVCODEC) + { + avcodec_init(); + avcodec_register_all(); + } return 0; } |