summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_expand.c
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/filter/vf_expand.c
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/filter/vf_expand.c')
-rw-r--r--video/filter/vf_expand.c77
1 files changed, 1 insertions, 76 deletions
diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c
index 7c9feb4375..3d1e3467f4 100644
--- a/video/filter/vf_expand.c
+++ b/video/filter/vf_expand.c
@@ -48,7 +48,6 @@ static struct vf_priv_s {
int exp_x,exp_y;
double aspect;
int round;
- int first_slice;
} const vf_priv_dflt = {
-1,-1,
-1,-1,
@@ -56,7 +55,6 @@ static struct vf_priv_s {
-1,-1,
0.,
1,
- 0
};
//===========================================================================//
@@ -141,11 +139,6 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi){
mpi->type, mpi->flags,
FFMAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
- if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&
- !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){
- mp_tmsg(MSGT_VFILTER, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n");
- return;
- }
// set up mpi as a cropped-down image of dmpi:
if(mpi->flags&MP_IMGFLAG_PLANAR){
mpi->planes[0]=vf->dmpi->planes[0]+
@@ -164,73 +157,7 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi){
mpi->stride[0]=vf->dmpi->stride[0];
mpi->width=vf->dmpi->width;
mpi->flags|=MP_IMGFLAG_DIRECT;
- mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
-// vf->dmpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
- }
-}
-
-static void start_slice(struct vf_instance *vf, mp_image_t *mpi){
-// printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);
- // they want slices!!! allocate the buffer.
- if(!mpi->priv)
- mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
-// MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
- MP_IMGTYPE_TEMP, mpi->flags,
- FFMAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
- FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
- vf->priv->first_slice = 1;
-}
-
-static void draw_top_blackbar_slice(struct vf_instance *vf,
- unsigned char** src, int* stride, int w,int h, int x, int y){
- if(vf->priv->exp_y>0 && y == 0) {
- vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride,
- vf->dmpi->w,vf->priv->exp_y,0,0);
- }
-
-}
-
-static void draw_bottom_blackbar_slice(struct vf_instance *vf,
- unsigned char** src, int* stride, int w,int h, int x, int y){
- if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) {
- unsigned char *src2[MP_MAX_PLANES];
- src2[0] = vf->dmpi->planes[0]
- + (vf->priv->exp_y+vf->h)*vf->dmpi->stride[0];
- if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
- src2[1] = vf->dmpi->planes[1]
- + ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1];
- src2[2] = vf->dmpi->planes[2]
- + ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2];
- } else {
- src2[1] = vf->dmpi->planes[1]; // passthrough rgb8 palette
- }
- vf_next_draw_slice(vf, src2, vf->dmpi->stride,
- vf->dmpi->w,vf->dmpi->h-(vf->priv->exp_y+vf->h),
- 0,vf->priv->exp_y+vf->h);
- }
-}
-
-static void draw_slice(struct vf_instance *vf,
- unsigned char** src, int* stride, int w,int h, int x, int y){
-// printf("draw_slice() called %d at %d\n",h,y);
-
- if (y == 0 && y+h == vf->h) {
- // special case - only one slice
- draw_top_blackbar_slice(vf, src, stride, w, h, x, y);
- vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);
- draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);
- return;
- }
- if (vf->priv->first_slice) {
- draw_top_blackbar_slice(vf, src, stride, w, h, x, y);
- draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);
- }
- vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);
- if (!vf->priv->first_slice) {
- draw_top_blackbar_slice(vf, src, stride, w, h, x, y);
- draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);
}
- vf->priv->first_slice = 0;
}
// w, h = width and height of the actual video frame (located at exp_x/exp_y)
@@ -249,7 +176,7 @@ static void clear_borders(struct vf_instance *vf, int w, int h)
}
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
- if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
+ if(mpi->flags&MP_IMGFLAG_DIRECT){
vf->dmpi=mpi->priv;
if(!vf->dmpi) { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "Why do we get NULL??\n"); return 0; }
mpi->priv=NULL;
@@ -304,8 +231,6 @@ static int vf_open(vf_instance_t *vf, char *args){
vf->config=config;
vf->control=control;
vf->query_format=query_format;
- vf->start_slice=start_slice;
- vf->draw_slice=draw_slice;
vf->get_image=get_image;
vf->put_image=put_image;
mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, aspect: %f, round: %d\n",