Index: libvo/video_out.c =================================================================== --- libvo/video_out.c (révision 19017) +++ 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,301 @@ +/* + * 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 "subopt-helper.h" +#include "video_out.h" +#include "video_out_internal.h" + +#define DEFAULT_MPEG_DECODER "/dev/video16" + +/* ivtv private */ +static int ivtv_fd = -1; +static vo_mpegpes_t *pes; + +/* suboptions */ +static int output; +static char *device; + +static opt_t subopts[] = { + {"output", OPT_ARG_INT, &output, (opt_test_f)int_non_neg}, + {"device", OPT_ARG_MSTRZ, &device, NULL}, + {NULL} +}; + +static vo_info_t info = +{ + "IVTV MPEG Decoder TV-Out", + "ivtv", + "Benjamin Zores", + "" +}; +LIBVO_EXTERN (ivtv) + +/* ivtv internals */ + +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; + + output = -1; + device = NULL; + + if (subopt_parse (arg, subopts) != 0) + { + mp_msg (MSGT_VO, MSGL_FATAL, + "\n-vo ivtv command line help:\n" + "Example: mplayer -vo ivtv:device=/dev/video16:output=2\n" + "\nOptions:\n" + " device=/dev/videoX\n" + " Name of the MPEG decoder device file.\n" + " output=<0-...>\n" + " V4L2 id of the TV output.\n" + "\n" ); + return -1; + } + + dev_name = device ? strdup (device) : strdup (DEFAULT_MPEG_DECODER); + + 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 */ + if (output != -1) + { + if (ioctl (ivtv_fd, VIDIOC_S_OUTPUT, &output) < 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, &output) == 0) + { + vout.index = output; + 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[]) +{ + pes = (vo_mpegpes_t *) src[0]; + return 0; +} + +static void +flip_page (void) +{ + if (ivtv_fd < 0) + return; + + if (pes->size > 0) + { + int wrote, curlen; + char *buf_ptr; + + buf_ptr = pes->data; + curlen = pes->size; + + while (curlen > 0) + { + wrote = write (ivtv_fd, buf_ptr, curlen); + buf_ptr = buf_ptr + wrote; + curlen -= wrote; + } + } +} + +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 19017) +++ configure (copie de travail) @@ -321,6 +321,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 @@ -1599,6 +1600,7 @@ _dvbhead=auto _dxr2=auto _dxr3=auto +_ivtv=auto _iconv=auto _langinfo=auto _rtc=auto @@ -1786,6 +1788,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 ;; @@ -4708,6 +4712,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! @@ -8363,6 +8394,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 19017) +++ 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