Index: libvo/video_out.c =================================================================== --- libvo/video_out.c (révision 18944) +++ libvo/video_out.c (copie de travail) @@ -100,6 +100,9 @@ extern vo_functions_t video_out_dxr2; #endif extern vo_functions_t video_out_dxr3; +#ifdef HAVE_IVTV +extern vo_functions_t video_out_ivtv; +#endif #ifdef HAVE_JPEG extern vo_functions_t video_out_jpeg; #endif @@ -211,6 +214,9 @@ #ifdef HAVE_DXR3 &video_out_dxr3, #endif +#ifdef HAVE_IVTV + &video_out_ivtv, +#endif #ifdef HAVE_ZR &video_out_zr, &video_out_zr2, Index: libvo/vo_ivtv.c =================================================================== --- libvo/vo_ivtv.c (révision 0) +++ libvo/vo_ivtv.c (révision 0) @@ -0,0 +1,353 @@ +/* + * Copyright (C) 2006 Benjamin Zores + * Video output for WinTV PVR-150/250/350 (a.k.a IVTV) cards. + * TV-Out through hardware MPEG decoder. + * Based on some old code from ivtv driver authors. + * See http://ivtvdriver.org/index.php/Main_Page for more details on the + * cards supported by the ivtv driver. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mp_msg.h" +#include "video_out.h" +#include "video_out_internal.h" + +#define DEFAULT_MPEG_DECODER "/dev/video16" + +#define VO_IVTV_SUBOPTION_HELP "help" +#define VO_IVTV_SUBOPTION_DEVICE "device" +#define VO_IVTV_SUBOPTION_OUTPUT "output" + +static int ivtv_fd = -1; +static char ivtvbuf[262144]; /* 256 kB */ +static int ivtvlen = 0; + +static vo_info_t info = +{ + "IVTV MPEG Decoder TV-Out", + "ivtv", + "Benjamin Zores", + "" +}; +LIBVO_EXTERN (ivtv) + +/* ivtv internals */ + +static int +ivtv_write (void) +{ + int wrote, curlen; + + if (ivtv_fd < 0) + return -1; + + if (ivtvlen > 0) + { + char * ivtvbuf_ptr = &ivtvbuf[0]; + curlen = ivtvlen; + + while (curlen > 0) + { + wrote = write (ivtv_fd, ivtvbuf_ptr, curlen); + ivtvbuf_ptr = ivtvbuf_ptr + wrote; + curlen -= wrote; + } + } + + return 0; +} + +static uint32_t +ivtv_reset (int blank_screen) +{ + struct ivtv_cfg_stop_decode sd; + struct ivtv_cfg_start_decode sd1; + + sd.hide_last = blank_screen; + sd.pts_stop = 0; + + while (ioctl (ivtv_fd, IVTV_IOC_S_STOP_DECODE, &sd) < 0) + { + if (errno != EBUSY) + { + mp_msg (MSGT_VO, MSGL_ERR, + "IVTV_IOC_STOP_DECODE: %s\n", strerror (errno)); + return 1; + } + } + + sd1.gop_offset = 0; + sd1.muted_audio_frames = 0; + + while (ioctl (ivtv_fd, IVTV_IOC_S_START_DECODE, &sd1) < 0) + { + if (errno != EBUSY) + { + mp_msg (MSGT_VO, MSGL_ERR, + "IVTV_IOC_START_DECODE: %s\n", strerror (errno)); + return 1; + } + } + + return 0; + +} + +/* video out functions */ + +static int +config (uint32_t width, uint32_t height, + uint32_t d_width, uint32_t d_height, + uint32_t fullscreen, char *title, uint32_t format) +{ + return 0; +} + +static int +preinit (const char *arg) +{ + struct v4l2_output vout; + char *dev_name = NULL; + int err, out = -1; + + dev_name = strdup (DEFAULT_MPEG_DECODER); + + if (arg) + { + if (!strncmp (arg, VO_IVTV_SUBOPTION_HELP, + strlen (VO_IVTV_SUBOPTION_HELP))) + { + mp_msg (MSGT_VO, MSGL_INFO, "Available suboptions: \n"); + mp_msg (MSGT_VO, MSGL_INFO, + " %s=/dev/videoX\n", VO_IVTV_SUBOPTION_DEVICE); + mp_msg (MSGT_VO, MSGL_INFO, " %s=id\n", VO_IVTV_SUBOPTION_OUTPUT); + + return -1; + } + else + { + char *opt = NULL; + int found = 0; + + opt = strstr (arg, VO_IVTV_SUBOPTION_DEVICE); + if (opt) + { + char *sep = NULL; + + free (dev_name); + sep = strchr (opt, ':'); + if (sep) + dev_name = strndup ((const char *) opt + + strlen (VO_IVTV_SUBOPTION_DEVICE) + 1, + strlen (opt) - strlen (VO_IVTV_SUBOPTION_DEVICE) + - 1 - strlen (sep)); + else + dev_name = strdup (opt + strlen (VO_IVTV_SUBOPTION_DEVICE) + 1); + + found = 1; + } + + opt = strstr (arg, VO_IVTV_SUBOPTION_OUTPUT); + if (opt) + { + char *sep = NULL; + char *o = NULL; + + sep = strchr (opt, ':'); + if (sep) + o = strndup ((const char *) opt + + strlen (VO_IVTV_SUBOPTION_OUTPUT) + 1, + strlen (opt) - strlen (VO_IVTV_SUBOPTION_OUTPUT) + - 1 - strlen (sep)); + else + o = strdup (opt + strlen (VO_IVTV_SUBOPTION_OUTPUT) + 1); + + out = atoi (o); + free (o); + found = 1; + } + + if (!found) + { + mp_msg (MSGT_VO, MSGL_INFO, "Unknown suboption.\n"); + return -1; + } + } + } + + ivtv_fd = open (dev_name, O_RDWR); + if (ivtv_fd < 0) + { + free (dev_name); + mp_msg (MSGT_VO, MSGL_ERR, "vo_ivtv: %s\n", strerror (errno)); + return -1; + } + + /* list available outputs */ + vout.index = 0; + err = 1; + mp_msg (MSGT_VO, MSGL_INFO, "VO: [ivtv] Available video outputs: "); + while (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) >= 0) + { + err = 0; + mp_msg (MSGT_VO, MSGL_INFO, "'#%d, %s' ", vout.index, vout.name); + vout.index++; + } + if (err) + { + mp_msg (MSGT_VO, MSGL_INFO, "none\n"); + free (dev_name); + return -1; + } + else + mp_msg (MSGT_VO, MSGL_INFO, "\n"); + + /* set user specified output */ + printf ("Out: %d\n", out); + if (out != -1) + { + if (ioctl (ivtv_fd, VIDIOC_S_OUTPUT, &out) < 0) + { + mp_msg (MSGT_VO, MSGL_ERR, + "VO: [ivtv] can't set output (%s)\n", strerror (errno)); + free (dev_name); + return -1; + } + } + + /* display device name */ + mp_msg (MSGT_VO, MSGL_INFO, "VO: [ivtv] using %s\n", dev_name); + free (dev_name); + + /* display current video output */ + if (ioctl (ivtv_fd, VIDIOC_G_OUTPUT, &out) == 0) + { + vout.index = out; + if (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) < 0) + { + mp_msg (MSGT_VO, MSGL_ERR, + "VO: [ivtv] can't get output (%s).\n", strerror (errno)); + return -1; + } + else + mp_msg (MSGT_VO, MSGL_INFO, + "VO: [ivtv] video output: %s\n", vout.name); + } + else + { + mp_msg (MSGT_VO, MSGL_ERR, + "VO: [ivtv] can't get output (%s).\n", strerror (errno)); + return -1; + } + + /* clear output */ + ivtv_reset (1); + + return 0; +} + +static void +draw_osd (void) +{ + /* do nothing */ +} + +static int +draw_frame (uint8_t * src[]) +{ + vo_mpegpes_t *p = (vo_mpegpes_t *) src[0]; + + memcpy (&ivtvbuf[0], p->data, p->size); + ivtvlen = p->size; + + return 0; +} + +static void +flip_page (void) +{ + ivtv_write (); +} + +static int +draw_slice (uint8_t *image[], int stride[], int w, int h, int x, int y) +{ + return 0; +} + +static void +uninit (void) +{ + if (ivtv_fd < 0) + return; + + /* clear output */ + ivtv_reset (1); + + /* close device */ + close (ivtv_fd); + ivtv_fd = -1; +} + +static void +check_events (void) +{ + /* do nothing */ +} + +static int +control (uint32_t request, void *data, ...) +{ + switch (request) + { + case VOCTRL_PAUSE: + case VOCTRL_RESUME: + { + ivtv_reset (0); + return 0; + } + + case VOCTRL_RESET: + return ivtv_reset (1); + + case VOCTRL_QUERY_FORMAT: + { + if (*((uint32_t*)data) != IMGFMT_MPEGPES) + return 0; + + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; + } + } + + return VO_NOTIMPL; +} Index: configure =================================================================== --- configure (révision 19005) +++ configure (copie de travail) @@ -315,6 +315,7 @@ --enable-directx build with DirectX support [autodetect] --enable-dxr2 build with DXR2 render support [autodetect] --enable-dxr3 build with DXR3/H+ render support [autodetect] + --enable-ivtv build with IVTV TV-Out render support [autodetect] --enable-dvb build with support for output via DVB-Card [autodetect] --enable-dvbhead build with DVB support (HEAD version) [autodetect] --enable-mga build with mga_vid (for Matrox G200/G4x0/G550) support @@ -1590,6 +1591,7 @@ _dvbhead=auto _dxr2=auto _dxr3=auto +_ivtv=auto _iconv=auto _langinfo=auto _rtc=auto @@ -1777,6 +1779,8 @@ --disable-dxr2) _dxr2=no ;; --enable-dxr3) _dxr3=yes ;; --disable-dxr3) _dxr3=no ;; + --enable-ivtv) _ivtv=yes ;; + --disable-ivtv) _ivtv=no ;; --enable-iconv) _iconv=yes ;; --disable-iconv) _iconv=no ;; --enable-langinfo) _langinfo=yes ;; @@ -4693,6 +4697,33 @@ fi echores "$_dxr3" +echocheck "IVTV TV-Out" +if test "$_ivtv" = auto ; then + cat > $TMPC << EOF +#include +#include +#include +#include +#include +int main(void) { return 0; } +EOF + _ivtv=no + cc_check && _ivtv=yes +fi +if test "$_ivtv" = yes ; then + _def_ivtv='#define HAVE_IVTV 1' + _vosrc="$_vosrc vo_ivtv.c" + _vomodules="ivtv $_vomodules" +else + _def_ivtv='#undef HAVE_IVTV' + _novomodules="ivtv $_novomodules" + if test "$_mp1e" = auto ; then + # we don't need mp1e + _mp1e=no + fi +fi +echores "$_ivtv" + echocheck "libmp1e" if test "$_mmx" = no ; then # mp1e REQUIRES mmx! @@ -8340,6 +8371,7 @@ $_def_fbdev $_def_dxr2 $_def_dxr3 +$_def_ivtv $_def_dvb $_def_dvb_in $_def_svga Index: etc/codecs.conf =================================================================== --- etc/codecs.conf (révision 18944) +++ etc/codecs.conf (copie de travail) @@ -35,7 +35,7 @@ ; Note: mpegpes is preferred for hw decoders: videocodec mpegpes - info "MPEG-PES output (.mpg or DXR3/DVB card)" + info "MPEG-PES output (.mpg or DXR3/IVTV/DVB card)" comment "for hardware decoding" status working format 0x10000001 ; mpeg 1