1
mirror of https://github.com/mpv-player/mpv synced 2025-01-09 01:36:25 +01:00

Remove V4L2 decoder support (vo_v4l2 and ao_v4l2)

The removed VO and AO took MPEG data and decoded it with V4L2. I'm not
exactly sure what's the use of this today, but get rid of it.

As far as feeding video data to V4L2 is concerned, there are other
ways. For example, there is this script, that feeds yuv4mpeg formatted
raw video data to V4L2:

    https://raw.github.com/umlaeute/v4l2loopback/master/examples/yuv4mpeg_to_v4l2.c
This commit is contained in:
wm4 2012-08-07 00:17:24 +02:00
parent 229380d9bd
commit c113e6ed7d
9 changed files with 0 additions and 673 deletions

View File

@ -346,7 +346,6 @@ SRCS_COMMON = asxparser.c \
libmpdemux/mf.c \
libmpdemux/mp3_hdr.c \
libmpdemux/mp_taglists.c \
libmpdemux/mpeg_packetizer.c \
libmpdemux/video.c \
libvo/osd.c \
libvo/eosd_packer.c \
@ -399,8 +398,6 @@ SRCS_MPLAYER-$(OSS) += libao2/ao_oss.c
SRCS_MPLAYER-$(PULSE) += libao2/ao_pulse.c
SRCS_MPLAYER-$(PORTAUDIO) += libao2/ao_portaudio.c
SRCS_MPLAYER-$(RSOUND) += libao2/ao_rsound.c
SRCS_MPLAYER-$(V4L2) += libvo/vo_v4l2.c
SRCS_MPLAYER-$(V4L2) += libao2/ao_v4l2.c
SRCS_MPLAYER-$(VDPAU) += libvo/vo_vdpau.c
SRCS_MPLAYER-$(X11) += libvo/vo_x11.c libvo/x11_common.c

36
configure vendored
View File

@ -362,7 +362,6 @@ Video output:
--enable-caca enable CACA video output [autodetect]
--enable-direct3d enable Direct3D video output [autodetect]
--enable-directx enable DirectX video output [autodetect]
--enable-v4l2 enable V4L2 Decoder audio/video output [autodetect]
--enable-xv enable Xv video output [autodetect]
--enable-vdpau enable VDPAU acceleration [autodetect]
--enable-vm enable XF86VidMode support [autodetect]
@ -463,7 +462,6 @@ _gl=auto
_aa=auto
_caca=auto
_dvb=auto
_v4l2=auto
_iconv=auto
_ossaudio=auto
_rsound=auto
@ -687,8 +685,6 @@ for ac_option do
--disable-caca) _caca=no ;;
--enable-dvb) _dvb=yes ;;
--disable-dvb) _dvb=no ;;
--enable-v4l2) _v4l2=yes ;;
--disable-v4l2) _v4l2=no ;;
--enable-iconv) _iconv=yes ;;
--disable-iconv) _iconv=no ;;
--enable-libdv) _libdv=yes ;;
@ -2664,37 +2660,6 @@ echores "$_directx"
fi #if win32; then
echocheck "V4L2 MPEG Decoder"
if test "$_v4l2" = auto ; then
cat > $TMPC << EOF
#include <sys/time.h>
#include <linux/videodev2.h>
#include <linux/version.h>
int main(void) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
#error kernel headers too old, need 2.6.22
#endif
struct v4l2_ext_controls ctrls;
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
return 0;
}
EOF
_v4l2=no
cc_check && _v4l2=yes
fi
if test "$_v4l2" = yes ; then
def_v4l2='#define CONFIG_V4L2_DECODER 1'
vomodules="v4l2 $vomodules"
aomodules="v4l2 $aomodules"
else
def_v4l2='#undef CONFIG_V4L2_DECODER'
novomodules="v4l2 $novomodules"
noaomodules="v4l2 $noaomodules"
fi
echores "$_v4l2"
#########
# AUDIO #
#########
@ -3968,7 +3933,6 @@ TV = $_tv
TV_BSDBT848 = $_tv_bsdbt848
TV_DSHOW = $_tv_dshow
TV_V4L2 = $_tv_v4l2
V4L2 = $_v4l2
VCD = $_vcd
VDPAU = $_vdpau
VSTREAM = $_vstream

View File

@ -1,158 +0,0 @@
/*
* audio output for V4L2 hardware MPEG decoders
*
* WARNING: You need to force -ac hwmpa for audio output to work.
*
* Copyright (C) 2007 Benjamin Zores
*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <inttypes.h>
#include "config.h"
#include "mp_msg.h"
#include "audio_out.h"
#include "audio_out_internal.h"
#include "libaf/af_format.h"
#include "libmpdemux/mpeg_packetizer.h"
#include "libvo/vo_v4l2.h"
#define MPEG_AUDIO_ID 0x1C0
static int freq = 0;
static const ao_info_t info =
{
"V4L2 MPEG Audio Decoder output",
"v4l2",
"Benjamin Zores",
""
};
LIBAO_EXTERN (v4l2)
/* to set/get/query special features/parameters */
static int
control (int cmd,void *arg)
{
return CONTROL_UNKNOWN;
}
/* open & setup audio device */
static int
init (int rate, int channels, int format, int flags)
{
if (v4l2_fd < 0)
return 0;
if (format != AF_FORMAT_MPEG2)
{
mp_msg (MSGT_AO, MSGL_FATAL,
"AO: [v4l2] can only handle MPEG audio streams.\n");
return 0;
}
ao_data.outburst = 2048;
ao_data.samplerate = rate;
ao_data.channels = channels;
ao_data.format = AF_FORMAT_MPEG2;
ao_data.buffersize = 2048;
ao_data.bps = rate * 2 * 2;
ao_data.brokenpts = 0;
freq = rate;
/* check for supported audio rate */
if (rate != 32000 || rate != 41000 || rate != 48000)
{
mp_tmsg (MSGT_AO, MSGL_ERR, "[AO MPEGPES] %d Hz not supported, try to resample.\n", rate);
rate = 48000;
}
return 1;
}
/* close audio device */
static void
uninit (int immed)
{
/* nothing to do */
}
/* stop playing and empty buffers (for seeking/pause) */
static void
reset (void)
{
/* nothing to do */
}
/* stop playing, keep buffers (for pause) */
static void
audio_pause (void)
{
reset ();
}
/* resume playing, after audio_pause() */
static void
audio_resume (void)
{
/* nothing to do */
}
/* how many bytes can be played without blocking */
static int
get_space (void)
{
extern int vo_pts;
float x;
int y;
x = (float) (vo_pts - ao_data.brokenpts) / 90000.0;
if (x <= 0)
return 0;
y = freq * 4 * x;
y /= ao_data.outburst;
y *= ao_data.outburst;
if (y > 32000)
y = 32000;
return y;
}
/* number of bytes played */
static int
play (void *data, int len, int flags)
{
if (ao_data.format != AF_FORMAT_MPEG2)
return 0;
send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.brokenpts, 2, v4l2_write);
return len;
}
/* delay in seconds between first and last sample in buffer */
static float
get_delay (void)
{
return 0.0;
}

View File

@ -41,7 +41,6 @@ extern const struct ao_driver audio_out_openal;
extern const struct ao_driver audio_out_null;
extern const struct ao_driver audio_out_alsa;
extern const struct ao_driver audio_out_dsound;
extern const struct ao_driver audio_out_v4l2;
extern const struct ao_driver audio_out_pcm;
extern const struct ao_driver audio_out_pss;
extern const struct ao_driver audio_out_portaudio;
@ -72,9 +71,6 @@ static const struct ao_driver * const audio_out_drivers[] = {
#endif
#ifdef CONFIG_OPENAL
&audio_out_openal,
#endif
#ifdef CONFIG_V4L2_DECODER
&audio_out_v4l2,
#endif
&audio_out_null,
// should not be auto-selected:

View File

@ -1,147 +0,0 @@
/*
* set of helper routines for building MPEG 1/2 PS/PES packets
*
* Copyright (C) 2006 Benjamin Zores
*
* Based on code borrowed from vo_mpegpes/vo_dxr2:
* (C) 2000 Ralph Metzler <ralph@convergence.de>
* Marcus Metzler <marcus@convergence.de>
* Gerard Lantau
*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <unistd.h>
#include <string.h>
#include <inttypes.h>
#include "mp_msg.h"
#include "mpeg_packetizer.h"
#define PES_MAX_SIZE 2048
static const unsigned char ps2_header[] = {
0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x04, 0x00,
0x04, 0x01, 0x01, 0x86, 0xa3, 0xf8
};
static const unsigned char ps1_header[] = {
0x00, 0x00, 0x01, 0xba, 0x21, 0x00,
0xb9, 0x37, 0x83, 0x80, 0xc3, 0x51,
};
/* Send MPEG <type> PES packet */
static int
send_mpeg_pes_packet_ll(unsigned char *data, int len, int id, uint64_t pts,
int type, unsigned char *header, int header_len,
int align4, int my_write (const unsigned char *data, int len))
{
int ptslen = (pts ? 5 : 0);
int n = 0;
int idx, plen;
int hdr;
unsigned char pes_header[PES_MAX_SIZE];
mp_msg (MSGT_HEADER, MSGL_DBG2,
"MPEG%d PES packet: 0x%x => %"PRIu64" \n", type, id, pts);
memset (pes_header, '\0', PES_MAX_SIZE);
/* startcode */
pes_header[0] = 0;
pes_header[1] = 0;
pes_header[2] = 0x01;
pes_header[3] = id; /* stream id */
while (len > 0)
{
int payload_size = len; /* data + PTS */
if(type == 2)
hdr = 3;
else
hdr = (ptslen ? 0 : 1);
if (6 + hdr + ptslen + payload_size + header_len > PES_MAX_SIZE)
payload_size = PES_MAX_SIZE - 6 - hdr - ptslen - header_len;
if(align4)
payload_size &= ~3;
/* construct PES header: packetize */
plen = payload_size + hdr + ptslen + header_len;
pes_header[4] = plen >> 8;
pes_header[5] = plen & 255;
idx = 6;
if (ptslen)
{
int x;
if(type == 2)
{
pes_header[idx++] = 0x81;
pes_header[idx++] = 0x80;
pes_header[idx++] = ptslen;
}
/* presentation time stamp */
x = (0x02 << 4) | (((pts >> 30) & 0x07) << 1) | 1;
pes_header[idx++] = x;
x = ((((pts >> 15) & 0x7fff) << 1) | 1);
pes_header[idx++] = x >>8;
pes_header[idx++] = x & 255;
x = (((pts & 0x7fff) << 1) | 1);
pes_header[idx++] = x >> 8;
pes_header[idx++] = x & 255;
}
else
{
if(type == 2)
{
pes_header[idx++] = 0x81;
pes_header[idx++] = 0x00;
pes_header[idx++] = 0x00;
}
else
pes_header[idx++] = 0x0f;
}
if(header_len)
{
memcpy(&pes_header[idx], header, header_len);
idx += header_len;
}
my_write (pes_header, idx);
n = my_write (data, payload_size);
len -= n;
data += n;
ptslen = 0; /* store PTS only once, at first packet! */
if(align4 && len < 4)
break;
}
return n;
}
int
send_mpeg_pes_packet (unsigned char *data, int len, int id, uint64_t pts,
int type, int my_write (const unsigned char *data, int len))
{
return send_mpeg_pes_packet_ll(data, len, id, pts, type, NULL, 0, 0, my_write);
}

View File

@ -1,37 +0,0 @@
/*
* helper routines for building MPEG 1/2 PS/PES packets
*
* Copyright (C) 2006 Benjamin Zores
*
* based on code borrowed from vo_mpegpes/vo_dxr2:
* (C) 2000 Ralph Metzler <ralph@convergence.de>
* Marcus Metzler <marcus@convergence.de>
* Gerard Lantau
*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPLAYER_MPEG_PACKETIZER_H
#define MPLAYER_MPEG_PACKETIZER_H
#include <stdint.h>
/* Send MPEG <type> PES packet */
int send_mpeg_pes_packet (unsigned char *data, int len, int id, uint64_t pts,
int type, int my_write (const unsigned char *data, int len));
#endif /* MPLAYER_MPEG_PACKETIZER_H */

View File

@ -86,7 +86,6 @@ extern struct vo_driver video_out_caca;
extern struct vo_driver video_out_direct3d;
extern struct vo_driver video_out_direct3d_shaders;
extern struct vo_driver video_out_directx;
extern struct vo_driver video_out_v4l2;
extern struct vo_driver video_out_directfb;
extern struct vo_driver video_out_corevideo;
extern struct vo_driver video_out_sharedbuffer;
@ -123,9 +122,6 @@ const struct vo_driver *video_out_drivers[] =
#endif
#ifdef CONFIG_CACA
&video_out_caca,
#endif
#ifdef CONFIG_V4L2_DECODER
&video_out_v4l2,
#endif
&video_out_null,
// should not be auto-selected

View File

@ -1,254 +0,0 @@
/*
* video output for V4L2 hardware MPEG decoders
*
* Copyright (C) 2007 Benjamin Zores
*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <inttypes.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <linux/ioctl.h>
#include "mp_msg.h"
#include "subopt-helper.h"
#include "video_out.h"
#include "libmpcodecs/vfcap.h"
#include "libmpcodecs/mp_image.h"
#include "libmpdemux/mpeg_packetizer.h"
#include "vo_v4l2.h"
#define DEFAULT_MPEG_DECODER "/dev/video16"
#define V4L2_VO_HDR "VO: [v4l2]"
int v4l2_fd = -1;
static vo_mpegpes_t *pes;
/* suboptions */
static int output = -1;
static char *device = NULL;
static const opt_t subopts[] = {
{"output", OPT_ARG_INT, &output, int_non_neg},
{"device", OPT_ARG_MSTRZ, &device, NULL},
{NULL}
};
int v4l2_write(const unsigned char *data, int len)
{
if (v4l2_fd < 0)
return 0;
return write(v4l2_fd, data, len);
}
/* video out functions */
static int config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height,
uint32_t fullscreen, uint32_t format)
{
return 0;
}
static int preinit(struct vo *vo, const char *arg)
{
struct v4l2_output vout;
struct v4l2_ext_controls ctrls;
int err;
if (subopt_parse(arg, subopts) != 0) {
mp_msg(MSGT_VO, MSGL_FATAL,
"\n-vo v4l2 command line help:\n"
"Example: mplayer -vo v4l2: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;
}
if (!device)
device = strdup(DEFAULT_MPEG_DECODER);
v4l2_fd = open(device, O_RDWR);
if (v4l2_fd < 0) {
free(device);
mp_msg(MSGT_VO, MSGL_FATAL, "%s %s\n", V4L2_VO_HDR, strerror(errno));
return -1;
}
/* check for device hardware MPEG decoding capability */
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
ctrls.count = 0;
ctrls.controls = NULL;
if (ioctl(v4l2_fd, VIDIOC_G_EXT_CTRLS, &ctrls) < 0) {
free(device);
mp_msg(MSGT_OPEN, MSGL_FATAL, "%s %s\n", V4L2_VO_HDR, strerror(errno));
return -1;
}
/* list available outputs */
vout.index = 0;
err = 1;
mp_msg(MSGT_VO, MSGL_INFO, "%s Available video outputs: ", V4L2_VO_HDR);
while (ioctl(v4l2_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(device);
return -1;
} else
mp_msg(MSGT_VO, MSGL_INFO, "\n");
/* set user specified output */
if (output != -1) {
if (ioctl(v4l2_fd, VIDIOC_S_OUTPUT, &output) < 0) {
mp_msg(MSGT_VO, MSGL_ERR,
"%s can't set output (%s)\n", V4L2_VO_HDR, strerror(errno));
free(device);
return -1;
}
}
/* display device name */
mp_msg(MSGT_VO, MSGL_INFO, "%s using %s\n", V4L2_VO_HDR, device);
free(device);
/* display current video output */
if (ioctl(v4l2_fd, VIDIOC_G_OUTPUT, &output) == 0) {
vout.index = output;
if (ioctl(v4l2_fd, VIDIOC_ENUMOUTPUT, &vout) < 0) {
mp_msg(MSGT_VO, MSGL_ERR,
"%s can't get output (%s).\n", V4L2_VO_HDR, strerror(errno));
return -1;
} else
mp_msg(MSGT_VO, MSGL_INFO,
"%s video output: %s\n", V4L2_VO_HDR, vout.name);
} else {
mp_msg(MSGT_VO, MSGL_ERR,
"%s can't get output (%s).\n", V4L2_VO_HDR, strerror(errno));
return -1;
}
return 0;
}
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
/* do nothing */
}
static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
{
pes = (vo_mpegpes_t *) (mpi->planes[0]);
return 0;
}
static void flip_page(struct vo *vo)
{
if (v4l2_fd < 0)
return;
if (!pes)
return;
send_mpeg_pes_packet(pes->data, pes->size, pes->id,
pes->timestamp ? pes->timestamp : vo_pts, 2,
v4l2_write);
/* ensure flip_page() won't be called twice */
pes = NULL;
}
static int draw_slice(struct vo *vo, uint8_t *image[], int stride[],
int w, int h, int x, int y)
{
return 0;
}
static void uninit(struct vo *vo)
{
if (v4l2_fd < 0)
return;
/* close device */
close(v4l2_fd);
v4l2_fd = -1;
}
static void check_events(struct vo *vo)
{
/* do nothing */
}
static int query_format(struct vo *vo, uint32_t format)
{
if (format != IMGFMT_MPEGPES)
return 0;
return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_TIMER;
}
static int control(struct vo *vo, uint32_t request, void *data)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(vo, *((uint32_t *) data));
case VOCTRL_DRAW_IMAGE:
return draw_image(vo, data);
}
return VO_NOTIMPL;
}
const struct vo_driver video_out_v4l2 = {
.is_new = false,
.info = &(const vo_info_t) {
"V4L2 MPEG Video Decoder Output",
"v4l2",
"Benjamin Zores",
""
},
.preinit = preinit,
.config = config,
.control = control,
.draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
.uninit = uninit,
};

View File

@ -1,30 +0,0 @@
/*
* video output for V4L2 hardware MPEG decoders
*
* Copyright (C) 2007 Benjamin Zores
*
* This file is part of MPlayer.
*
* MPlayer 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.
*
* MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPLAYER_VO_V4L2_H
#define MPLAYER_VO_V4L2_H
extern int v4l2_fd;
int v4l2_write(const unsigned char *data, int len);
#endif /* MPLAYER_VO_V4L2_H */