summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-04 18:16:36 +0100
committerwm4 <wm4@nowhere>2013-01-13 17:39:31 +0100
commit23ab098969f5182585578ee01c3a47d42dea031f (patch)
tree3f9003095a8f8bb92ab61e8df9c51e109f4d4ffb /video/out
parentcfa1f9e082f3da83adb5161be140e477b38bc5c7 (diff)
downloadmpv-23ab098969f5182585578ee01c3a47d42dea031f.tar.bz2
mpv-23ab098969f5182585578ee01c3a47d42dea031f.tar.xz
video: remove slice based filtering and video output
Slices allowed filtering or drawing video in horizontal bands or blocks. This allowed working on the video in smaller units. In theory, this could bring a performance win by lowering cache pressure, as you didn't have to keep the whole video frame in cache while filtering, only the slice. In practice, the slice code path was barely used for the following reasons: - Multithreaded decoding with ffmpeg didn't use slices. The ffmpeg slice callback was disabled, because it can be called from another thread, and the mplayer video chain is not thread-safe. - There was nothing that would turn "full" images into appropriate slices, so slices were rarely used. - Most filters didn't actually support slices. On the other hand, supporting slices lead to code duplication and more complex code in general. I made some experiments and didn't find any actual measurable performance improvements when using slices. Even ffmpeg removed slices based filtering from libavfilter in favor of simpler code. The most broken thing about the slices code path is that slices can't be queued, like it is done for images in vo.c.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/vo.c5
-rw-r--r--video/out/vo.h14
-rw-r--r--video/out/vo_caca.c7
-rw-r--r--video/out/vo_corevideo.m2
-rw-r--r--video/out/vo_direct3d.c8
-rw-r--r--video/out/vo_lavc.c4
-rw-r--r--video/out/vo_null.c7
-rw-r--r--video/out/vo_opengl.c26
-rw-r--r--video/out/vo_opengl_old.c28
-rw-r--r--video/out/vo_vdpau.c9
-rw-r--r--video/out/vo_x11.c16
-rw-r--r--video/out/vo_xv.c5
12 files changed, 12 insertions, 119 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index 629bba09a6..18e000e3ab 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -213,11 +213,6 @@ void vo_skip_frame(struct vo *vo)
vo->frame_loaded = false;
}
-int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y)
-{
- return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
-}
-
void vo_new_frame_imminent(struct vo *vo)
{
if (vo->driver->buffer_frames)
diff --git a/video/out/vo.h b/video/out/vo.h
index 9206883183..bcc751e5f2 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -52,8 +52,6 @@ enum mp_voctrl {
VOCTRL_GET_EQUALIZER, // struct voctrl_get_equalizer_args
VOCTRL_DUPLICATE_FRAME,
- VOCTRL_START_SLICE,
-
/* for vdpau hardware decoding */
VOCTRL_HWDEC_DECODER_RENDER, // pointer to hw state
@@ -194,17 +192,6 @@ struct vo_driver {
void (*get_buffered_frame)(struct vo *vo, bool eof);
/*
- * Draw a planar YUV slice to the buffer:
- * params:
- * src[3] = source image planes (Y,U,V)
- * stride[3] = source image planes line widths (in bytes)
- * w,h = width*height of area to be copied (in Y pixels)
- * x,y = position at the destination image (in Y pixels)
- */
- int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
- int h, int x, int y);
-
- /*
* Draws OSD to the screen buffer
*/
void (*draw_osd)(struct vo *vo, struct osd_state *osd);
@@ -302,7 +289,6 @@ int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts);
int vo_redraw_frame(struct vo *vo);
int vo_get_buffered_frame(struct vo *vo, bool eof);
void vo_skip_frame(struct vo *vo);
-int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
void vo_new_frame_imminent(struct vo *vo);
void vo_draw_osd(struct vo *vo, struct osd_state *osd);
void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration);
diff --git a/video/out/vo_caca.c b/video/out/vo_caca.c
index a8a312d01a..43d1de44cd 100644
--- a/video/out/vo_caca.c
+++ b/video/out/vo_caca.c
@@ -171,12 +171,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mpi->planes[0]);
}
-static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h,
- int x, int y)
-{
- return 0;
-}
-
static void flip_page(struct vo *vo)
{
if (showosdmessage) {
@@ -380,7 +374,6 @@ const struct vo_driver video_out_caca = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m
index 1ace48eb9b..bc8833f12f 100644
--- a/video/out/vo_corevideo.m
+++ b/video/out/vo_corevideo.m
@@ -246,7 +246,7 @@ static int query_format(struct vo *vo, uint32_t format)
{
struct priv *p = vo->priv;
const int flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |
- VFCAP_OSD | VOCAP_NOSLICES;
+ VFCAP_OSD;
switch (format) {
case IMGFMT_YUY2:
p->pixelFormat = kYUVSPixelFormat;
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index d71b902b54..27def5e294 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -871,8 +871,7 @@ static void uninit_d3d(d3d_priv *priv)
static void d3d_upload_and_render_frame_texture(d3d_priv *priv,
mp_image_t *mpi)
{
- if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK))
- draw_slice(priv->vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
+ draw_slice(priv->vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
d3d_unlock_video_objects(priv);
@@ -894,9 +893,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
return;
}
- if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
- goto skip_upload;
-
if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Copy a planar frame. */
draw_slice(priv->vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
goto skip_upload;
@@ -2069,7 +2065,6 @@ const struct vo_driver video_out_direct3d = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
@@ -2088,7 +2083,6 @@ const struct vo_driver video_out_direct3d_shaders = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c
index 8134021b3f..6ae06fffec 100644
--- a/video/out/vo_lavc.c
+++ b/video/out/vo_lavc.c
@@ -200,10 +200,8 @@ static int query_format(struct vo *vo, uint32_t format)
// we can do it
VFCAP_CSP_SUPPORTED_BY_HW |
// we don't convert colorspaces here
- VFCAP_OSD |
+ VFCAP_OSD;
// we have OSD
- VOCAP_NOSLICES;
- // we don't use slices
}
static void write_packet(struct vo *vo, int size, AVPacket *packet)
diff --git a/video/out/vo_null.c b/video/out/vo_null.c
index 67779284e0..c1e931f806 100644
--- a/video/out/vo_null.c
+++ b/video/out/vo_null.c
@@ -30,12 +30,6 @@
#include "video/vfcap.h"
#include "video/mp_image.h"
-static int draw_slice(struct vo *vo, uint8_t *image[], int stride[],
- int w, int h, int x, int y)
-{
- return 0;
-}
-
static void draw_image(struct vo *vo, mp_image_t *mpi)
{
}
@@ -96,7 +90,6 @@ const struct vo_driver video_out_null = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 9403d7472e..759cb96ba7 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -1237,26 +1237,6 @@ static void flip_page(struct vo *vo)
p->frames_rendered++;
}
-static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h,
- int x, int y)
-{
- struct gl_priv *p = vo->priv;
- GL *gl = p->gl;
-
- p->mpi_flipped = stride[0] < 0;
-
- for (int n = 0; n < p->plane_count; n++) {
- gl->ActiveTexture(GL_TEXTURE0 + n);
- gl->BindTexture(GL_TEXTURE_2D, p->planes[n].gl_texture);
- int xs = p->planes[n].shift_x, ys = p->planes[n].shift_y;
- glUploadTex(gl, GL_TEXTURE_2D, p->gl_format, p->gl_type, src[n],
- stride[n], x >> xs, y >> ys, w >> xs, h >> ys, 0);
- }
- gl->ActiveTexture(GL_TEXTURE0);
-
- return 0;
-}
-
static uint32_t get_image(struct vo *vo, mp_image_t *mpi)
{
struct gl_priv *p = vo->priv;
@@ -1308,8 +1288,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mp_image_t mpi2 = *mpi;
int w = mpi->w, h = mpi->h;
- if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
- goto skip_upload;
mpi2.flags = 0;
mpi2.type = MP_IMGTYPE_TEMP;
mpi2.width = mpi2.w;
@@ -1347,7 +1325,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
}
gl->ActiveTexture(GL_TEXTURE0);
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
-skip_upload:
+
do_render(p);
}
@@ -2259,7 +2237,6 @@ const struct vo_driver video_out_opengl = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
@@ -2278,7 +2255,6 @@ const struct vo_driver video_out_opengl_hq = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
index 0fbc038784..3f629ed43e 100644
--- a/video/out/vo_opengl_old.c
+++ b/video/out/vo_opengl_old.c
@@ -587,29 +587,6 @@ static void flip_page(struct vo *vo)
gl->Clear(GL_COLOR_BUFFER_BIT);
}
-static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h,
- int x, int y)
-{
- struct gl_priv *p = vo->priv;
- GL *gl = p->gl;
-
- p->mpi_flipped = stride[0] < 0;
- glUploadTex(gl, p->target, p->gl_format, p->gl_type, src[0], stride[0],
- x, y, w, h, p->slice_height);
- if (p->is_yuv) {
- int xs, ys;
- mp_get_chroma_shift(p->image_format, &xs, &ys, NULL);
- gl->ActiveTexture(GL_TEXTURE1);
- glUploadTex(gl, p->target, p->gl_format, p->gl_type, src[1], stride[1],
- x >> xs, y >> ys, w >> xs, h >> ys, p->slice_height);
- gl->ActiveTexture(GL_TEXTURE2);
- glUploadTex(gl, p->target, p->gl_format, p->gl_type, src[2], stride[2],
- x >> xs, y >> ys, w >> xs, h >> ys, p->slice_height);
- gl->ActiveTexture(GL_TEXTURE0);
- }
- return 0;
-}
-
static uint32_t get_image(struct vo *vo, mp_image_t *mpi)
{
struct gl_priv *p = vo->priv;
@@ -719,8 +696,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
unsigned char *planes[3];
mp_image_t mpi2 = *mpi;
int w = mpi->w, h = mpi->h;
- if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
- goto skip_upload;
mpi2.flags = 0;
mpi2.type = MP_IMGTYPE_TEMP;
mpi2.width = mpi2.w;
@@ -807,7 +782,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
if (mpi->flags & MP_IMGFLAG_DIRECT) {
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
-skip_upload:
+
do_render(vo);
}
@@ -1172,7 +1147,6 @@ const struct vo_driver video_out_opengl_old = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index 3d0305b799..13a352f790 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -1309,7 +1309,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, double pts)
if (IMGFMT_IS_VDPAU(vc->image_format)) {
rndr = mpi->priv;
reserved_mpi = mpi;
- } else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) {
+ } else {
rndr = get_surface(vo, vc->deint_counter);
vc->deint_counter = WRAP_ADD(vc->deint_counter, 1, NUM_BUFFERED_VIDEO);
if (handle_preemption(vo) >= 0) {
@@ -1323,11 +1323,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, double pts)
CHECK_ST_WARNING("Error when calling "
"vdp_video_surface_put_bits_y_cb_cr");
}
- } else
- // We don't support slice callbacks so this shouldn't occur -
- // I think the flags test above in pointless, but I'm adding
- // this instead of removing it just in case.
- abort();
+ }
if (mpi->fields & MP_IMGFIELD_ORDERED)
vc->top_field_first = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST);
else
@@ -1437,7 +1433,6 @@ static int query_format(struct vo *vo, uint32_t format)
case IMGFMT_NV12:
case IMGFMT_YUY2:
case IMGFMT_UYVY:
- return default_flags | VOCAP_NOSLICES;
case IMGFMT_VDPAU_MPEG1:
case IMGFMT_VDPAU_MPEG2:
case IMGFMT_VDPAU_H264:
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c
index d65326616c..98ebc7f6d1 100644
--- a/video/out/vo_x11.c
+++ b/video/out/vo_x11.c
@@ -300,7 +300,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
}
/* set image size (which is indeed neither the input nor output size),
- if zoom is on it will be changed during draw_slice anyway so we don't
+ if zoom is on it will be changed during draw_image anyway so we don't
duplicate the aspect code here
*/
p->image_width = (width + 7) & (~7);
@@ -474,8 +474,7 @@ static void flip_page(struct vo *vo)
XSync(vo->x11->display, False);
}
-static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h,
- int x, int y)
+static void draw_image(struct vo *vo, mp_image_t *mpi)
{
struct priv *p = vo->priv;
uint8_t *dst[MP_MAX_PLANES] = {NULL};
@@ -517,15 +516,9 @@ static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h,
dst[0] += dstStride[0] * (p->image_height - 1);
dstStride[0] = -dstStride[0];
}
- sws_scale(p->swsContext, (const uint8_t **)src, stride, y, h, dst,
- dstStride);
+ sws_scale(p->swsContext, (const uint8_t **)mpi->planes, mpi->stride,
+ 0, mpi->h, dst, dstStride);
mp_draw_sub_backup_reset(p->osd_backup);
- return 0;
-}
-
-static void draw_image(struct vo *vo, mp_image_t *mpi)
-{
- draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
}
static int query_format(struct vo *vo, uint32_t format)
@@ -651,7 +644,6 @@ const struct vo_driver video_out_x11 = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,
diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c
index a17fb2df13..985a528d76 100644
--- a/video/out/vo_xv.c
+++ b/video/out/vo_xv.c
@@ -445,9 +445,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
{
struct xvctx *ctx = vo->priv;
- if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)
- ; // done
- else if (mpi->flags & MP_IMGFLAG_PLANAR)
+ if (mpi->flags & MP_IMGFLAG_PLANAR)
draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0);
else if (mpi->flags & MP_IMGFLAG_YUV)
// packed YUV:
@@ -694,7 +692,6 @@ const struct vo_driver video_out_xv = {
.config = config,
.control = control,
.draw_image = draw_image,
- .draw_slice = draw_slice,
.draw_osd = draw_osd,
.flip_page = flip_page,
.check_events = check_events,