[MPlayer-dev-eng] [PATCH][FILTER] Drop interlaced frames.
Andriy N. Gritsenko
andrej at lucky.net
Tue Sep 10 12:49:05 CEST 2002
Hi all!
I've already done it myself. :) It works good, it's just another
deinterlace method. I'm using it as 'mencoder -vop pp,dint ...' (since
filters work in reverse order (from -vop) then I place this filter at
end of list and it have to be first). Please, test it thoroughly, any
comments/improvements are welcome.
With best wishes.
Andriy.
-------------- next part --------------
diff -udprP MPlayer-20020910.orig/libmpcodecs/dec_video.c MPlayer-20020910/libmpcodecs/dec_video.c
--- MPlayer-20020910.orig/libmpcodecs/dec_video.c Sun Sep 1 00:03:03 2002
+++ MPlayer-20020910/libmpcodecs/dec_video.c Tue Sep 10 13:17:52 2002
@@ -237,8 +237,10 @@ if(!mpi || drop_frame) return 0; // erro
//vo_draw_image(video_out,mpi);
vf=sh_video->vfilter;
-vf->put_image(vf,mpi);
-vf->control(vf,VFCTRL_DRAW_OSD,NULL);
+if(vf->put_image(vf,mpi))
+ vf->control(vf,VFCTRL_DRAW_OSD,NULL);
+else
+ return 0;
t2=GetTimer()-t2;
tt=t2*0.000001f;
diff -udprP MPlayer-20020910.orig/libmpcodecs/ve_divx4.c MPlayer-20020910/libmpcodecs/ve_divx4.c
--- MPlayer-20020910.orig/libmpcodecs/ve_divx4.c Mon Sep 9 15:12:30 2002
+++ MPlayer-20020910/libmpcodecs/ve_divx4.c Tue Sep 10 13:15:59 2002
@@ -223,7 +223,7 @@ static int query_format(struct vf_instan
return 0;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
ENC_RESULT enc_result;
vf->priv->enc_frame.image=mpi->planes[0];
vf->priv->enc_frame.bitstream=mux_v->buffer;
@@ -273,6 +273,7 @@ static void put_image(struct vf_instance
}
}
mencoder_write_chunk(mux_v,vf->priv->enc_frame.length,enc_result.is_key_frame?0x10:0);
+ return 1;
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/ve_lavc.c MPlayer-20020910/libmpcodecs/ve_lavc.c
--- MPlayer-20020910.orig/libmpcodecs/ve_lavc.c Fri Aug 30 03:38:42 2002
+++ MPlayer-20020910/libmpcodecs/ve_lavc.c Tue Sep 10 13:19:09 2002
@@ -387,7 +387,7 @@ static int query_format(struct vf_instan
return 0;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
int out_size;
AVPicture lavc_venc_picture;
@@ -431,6 +431,7 @@ static void put_image(struct vf_instance
if(lavc_venc_context.stats_out && stats_file)
fprintf(stats_file, "%s", lavc_venc_context.stats_out);
#endif
+ return 1;
}
static void uninit(struct vf_instance_s* vf){
diff -udprP MPlayer-20020910.orig/libmpcodecs/ve_libdv.c MPlayer-20020910/libmpcodecs/ve_libdv.c
--- MPlayer-20020910.orig/libmpcodecs/ve_libdv.c Thu Aug 29 01:45:44 2002
+++ MPlayer-20020910/libmpcodecs/ve_libdv.c Tue Sep 10 13:15:59 2002
@@ -72,13 +72,14 @@ static int query_format(struct vf_instan
return 0;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
dv_encode_full_frame(vf->priv->enc, mpi->planes,
(mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb,
mux_v->buffer);
mencoder_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10);
+ return 1;
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/ve_rawrgb.c MPlayer-20020910/libmpcodecs/ve_rawrgb.c
--- MPlayer-20020910.orig/libmpcodecs/ve_rawrgb.c Thu Aug 29 01:45:44 2002
+++ MPlayer-20020910/libmpcodecs/ve_rawrgb.c Tue Sep 10 13:15:59 2002
@@ -46,9 +46,10 @@ static int query_format(struct vf_instan
return 0;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mux_v->buffer=mpi->planes[0];
mencoder_write_chunk(mux_v, mpi->width*mpi->height*3, 0x10);
+ return 1;
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/ve_vfw.c MPlayer-20020910/libmpcodecs/ve_vfw.c
--- MPlayer-20020910.orig/libmpcodecs/ve_vfw.c Mon Sep 2 02:06:15 2002
+++ MPlayer-20020910/libmpcodecs/ve_vfw.c Tue Sep 10 13:15:59 2002
@@ -238,12 +238,13 @@ static int query_format(struct vf_instan
return 0;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
long flags=0;
int ret;
// flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
mencoder_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
+ return 1;
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf.c MPlayer-20020910/libmpcodecs/vf.c
--- MPlayer-20020910.orig/libmpcodecs/vf.c Fri Aug 30 09:16:40 2002
+++ MPlayer-20020910/libmpcodecs/vf.c Tue Sep 10 13:15:59 2002
@@ -347,8 +347,8 @@ int vf_next_query_format(struct vf_insta
return flags;
}
-void vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi){
- vf->next->put_image(vf->next,mpi);
+int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi){
+ return vf->next->put_image(vf->next,mpi);
}
//============================================================================
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf.h MPlayer-20020910/libmpcodecs/vf.h
--- MPlayer-20020910.orig/libmpcodecs/vf.h Sun Sep 1 17:30:54 2002
+++ MPlayer-20020910/libmpcodecs/vf.h Tue Sep 10 13:15:59 2002
@@ -29,7 +29,7 @@ typedef struct vf_instance_s {
unsigned int fmt);
void (*get_image)(struct vf_instance_s* vf,
mp_image_t *mpi);
- void (*put_image)(struct vf_instance_s* vf,
+ int (*put_image)(struct vf_instance_s* vf,
mp_image_t *mpi);
void (*draw_slice)(struct vf_instance_s* vf,
unsigned char** src, int* stride, int w,int h, int x, int y);
@@ -77,7 +77,7 @@ int vf_next_config(struct vf_instance_s*
unsigned int flags, unsigned int outfmt);
int vf_next_control(struct vf_instance_s* vf, int request, void* data);
int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt);
-void vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi);
+int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi);
vf_instance_t* append_filters(vf_instance_t* last);
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_crop.c MPlayer-20020910/libmpcodecs/vf_crop.c
--- MPlayer-20020910.orig/libmpcodecs/vf_crop.c Sun May 12 22:06:15 2002
+++ MPlayer-20020910/libmpcodecs/vf_crop.c Tue Sep 10 13:15:59 2002
@@ -39,7 +39,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
MP_IMGTYPE_EXPORT, 0,
vf->priv->crop_w, vf->priv->crop_h);
@@ -59,7 +59,7 @@ static void put_image(struct vf_instance
}
dmpi->stride[0]=mpi->stride[0];
dmpi->width=mpi->width;
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_cropdetect.c MPlayer-20020910/libmpcodecs/vf_cropdetect.c
--- MPlayer-20020910.orig/libmpcodecs/vf_cropdetect.c Sun Jun 30 01:12:07 2002
+++ MPlayer-20020910/libmpcodecs/vf_cropdetect.c Tue Sep 10 13:15:59 2002
@@ -55,7 +55,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
int bpp=mpi->bpp/8;
int x,y;
@@ -115,7 +115,7 @@ if(++vf->priv->fno>2){ // ignore first 2
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_dint.c MPlayer-20020910/libmpcodecs/vf_dint.c
--- MPlayer-20020910.orig/libmpcodecs/vf_dint.c Thu Jan 1 03:00:00 1970
+++ MPlayer-20020910/libmpcodecs/vf_dint.c Tue Sep 10 13:27:58 2002
@@ -0,0 +1,195 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "../config.h"
+#include "../mp_msg.h"
+#include "../libvo/fastmemcpy.h"
+
+#include "mp_image.h"
+#include "img_format.h"
+#include "vf.h"
+
+struct vf_priv_s {
+ float sense; // first parameter
+ float level; // second parameter
+ unsigned int imgfmt;
+ char diff;
+ uint32_t max;
+// int dfr;
+// int rdfr;
+ int was_dint;
+ mp_image_t *pmpi; // previous mpi
+};
+
+#define MAXROWSIZE 1200
+
+static int config (struct vf_instance_s* vf,
+ int width, int height, int d_width, int d_height,
+ unsigned int flags, unsigned int outfmt)
+{
+ int rowsize;
+
+ vf->priv->pmpi = vf_get_image (vf->next, outfmt, MP_IMGTYPE_TEMP,
+ 0, width, height);
+ if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) &&
+ outfmt != IMGFMT_RGB32 && outfmt != IMGFMT_BGR32 &&
+ outfmt != IMGFMT_RGB24 && outfmt != IMGFMT_BGR24 &&
+ outfmt != IMGFMT_RGB16 && outfmt != IMGFMT_BGR16)
+ {
+ mp_msg (MSGT_VFILTER, MSGL_WARN, "Drop-interlaced filter doesn't support this outfmt :(\n");
+ return 0;
+ }
+ vf->priv->imgfmt = outfmt;
+ // recalculate internal values
+ rowsize = vf->priv->pmpi->width;
+ if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE;
+ vf->priv->max = vf->priv->level * vf->priv->pmpi->height * rowsize / 2;
+ if (vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) // planar YUV
+ vf->priv->diff = vf->priv->sense * 256;
+ else
+ vf->priv->diff = vf->priv->sense * (1 << (vf->priv->pmpi->bpp/3));
+ if (vf->priv->diff < 0) vf->priv->diff = 0;
+ if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) &&
+ vf->priv->pmpi->bpp < 24 && vf->priv->diff > 31)
+ vf->priv->diff = 31;
+ mp_msg (MSGT_VFILTER, MSGL_INFO, "Drop-interlaced: %dx%d diff %d / level %u\n",
+ vf->priv->pmpi->width, vf->priv->pmpi->height,
+ (int)vf->priv->diff, (unsigned int)vf->priv->max);
+// vf->priv->rdfr = vf->priv->dfr = 0;
+ vf->priv->was_dint = 0;
+ return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
+}
+
+static int put_image (struct vf_instance_s* vf, mp_image_t *mpi)
+{
+ char rrow0[MAXROWSIZE];
+ char rrow1[MAXROWSIZE];
+ char rrow2[MAXROWSIZE];
+ char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/;
+ int rowsize = mpi->width;
+ uint32_t nok = 0, max = vf->priv->max;
+ int diff = vf->priv->diff;
+ int i, j;
+ register int n1, n2;
+ unsigned char *cur0, *prv0;
+ register unsigned char *cur, *prv;
+
+ // check if nothing to do
+ if (mpi->imgfmt == vf->priv->imgfmt)
+ {
+ cur0 = mpi->planes[0] + mpi->stride[0];
+ prv0 = mpi->planes[0];
+ for (j = 1; j < mpi->height && nok <= max; j++)
+ {
+ cur = cur0;
+ prv = prv0;
+ // analyse row (row0)
+ if (mpi->flags & MP_IMGFLAG_PLANAR) // planar YUV - check luminance
+ for (i = 0; i < rowsize; i++)
+ {
+ if (cur[0] - prv[0] > diff)
+ row0[i] = 1;
+ else if (cur[0] - prv[0] < -diff)
+ row0[i] = -1;
+ else
+ row0[i] = 0;
+ cur++;
+ prv++;
+ // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0
+ // but row3 is 1 so it's interlaced ptr (nok++)
+ if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) &&
+ (++nok) > max)
+ break;
+ }
+ else if (mpi->bpp < 24) // RGB/BGR 16 - check all colors
+ for (i = 0; i < rowsize; i++)
+ {
+ n1 = cur[0] + (cur[1]<<8);
+ n2 = prv[0] + (prv[1]<<8);
+ if ((n1&0x1f) - (n2&0x1f) > diff ||
+ ((n1>>5)&0x3f) - ((n2>>5)&0x3f) > diff ||
+ ((n1>>11)&0x1f) - ((n2>>11)&0x1f) > diff)
+ row0[i] = 1;
+ else if ((n1&0x1f) - (n2&0x1f) < -diff ||
+ ((n1>>5)&0x3f) - ((n2>>5)&0x3f) < -diff ||
+ ((n1>>11)&0x1f) - ((n2>>11)&0x1f) < -diff)
+ row0[i] = -1;
+ else
+ row0[i] = 0;
+ cur += 2;
+ prv += 2;
+ // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0
+ // but row3 is 1 so it's interlaced ptr (nok++)
+ if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) &&
+ (++nok) > max)
+ break;
+ }
+ else // RGB/BGR 24/32
+ for (i = 0; i < rowsize; i++)
+ {
+ if (cur[0] - prv[0] > diff ||
+ cur[1] - prv[1] > diff ||
+ cur[2] - prv[2] > diff)
+ row0[i] = 1;
+ else if (prv[0] - cur[0] > diff ||
+ prv[1] - cur[1] > diff ||
+ prv[2] - cur[2] > diff)
+ row0[i] = -1;
+ else
+ row0[i] = 0;
+ cur += mpi->bpp/8;
+ prv += mpi->bpp/8;
+ // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0
+ // but row3 is 1 so it's interlaced ptr (nok++)
+ if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) &&
+ (++nok) > max)
+ break;
+ }
+ cur0 += mpi->stride[0];
+ prv0 += mpi->stride[0];
+ // rotate rows
+ cur = row2;
+ row2 = row1;
+ row1 = row0;
+ row0 = cur;
+ }
+ }
+ // check if number of interlaced is above of max
+ if (nok > max)
+ {
+// vf->priv->dfr++;
+ if (vf->priv->was_dint < 1) // can skip at most one frame!
+ {
+ vf->priv->was_dint++;
+// vf->priv->rdfr++;
+// mp_msg (MSGT_VFILTER, MSGL_INFO, "DI:%d/%d ", vf->priv->rdfr, vf->priv->dfr);
+ return 0;
+ }
+ }
+ vf->priv->was_dint = 0;
+// mp_msg (MSGT_VFILTER, MSGL_INFO, "DI:%d/%d ", vf->priv->rdfr, vf->priv->dfr);
+ return vf_next_put_image (vf, mpi);
+}
+
+static int open (vf_instance_t *vf, char* args){
+ vf->config = config;
+ vf->put_image = put_image;
+// vf->default_reqs=VFCAP_ACCEPT_STRIDE;
+ vf->priv = malloc (sizeof(struct vf_priv_s));
+ vf->priv->sense = 0.01;
+ vf->priv->level = 0.15;
+ vf->priv->pmpi = NULL;
+ if (args)
+ sscanf (args, "%f:%f", &vf->priv->sense, &vf->priv->level);
+ return 1;
+}
+
+vf_info_t vf_info_dint = {
+ "drop interlaced frames",
+ "dint",
+ "A.G.",
+ "",
+ open
+};
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_eq.c MPlayer-20020910/libmpcodecs/vf_eq.c
--- MPlayer-20020910.orig/libmpcodecs/vf_eq.c Wed Aug 28 03:24:27 2002
+++ MPlayer-20020910/libmpcodecs/vf_eq.c Tue Sep 10 13:34:03 2002
@@ -109,7 +109,7 @@ static void (*process)(unsigned char *de
/* FIXME: add packed yuv version of process */
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi)
{
mp_image_t *dmpi;
@@ -135,7 +135,7 @@ static void put_image(struct vf_instance
vf->priv->contrast);
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
static int control(struct vf_instance_s* vf, int request, void* data)
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_expand.c MPlayer-20020910/libmpcodecs/vf_expand.c
--- MPlayer-20020910.orig/libmpcodecs/vf_expand.c Wed Aug 21 22:12:13 2002
+++ MPlayer-20020910/libmpcodecs/vf_expand.c Tue Sep 10 13:16:33 2002
@@ -221,14 +221,14 @@ static void get_image(struct vf_instance
}
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_DIRECT){
vf->priv->dmpi=mpi->priv;
#ifdef OSD_SUPPORT
if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
#endif
- vf_next_put_image(vf,vf->priv->dmpi);
- return; // we've used DR, so we're ready...
+ return vf_next_put_image(vf,vf->priv->dmpi);
+ // we've used DR, so we're ready...
}
// hope we'll get DR buffer:
@@ -259,7 +259,7 @@ static void put_image(struct vf_instance
#ifdef OSD_SUPPORT
if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
#endif
- vf_next_put_image(vf,vf->priv->dmpi);
+ return vf_next_put_image(vf,vf->priv->dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_fame.c MPlayer-20020910/libmpcodecs/vf_fame.c
--- MPlayer-20020910.orig/libmpcodecs/vf_fame.c Sat Jun 1 23:57:26 2002
+++ MPlayer-20020910/libmpcodecs/vf_fame.c Tue Sep 10 13:16:33 2002
@@ -45,7 +45,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
fame_yuv_t yuv;
mp_image_t *dmpi;
int out_size;
@@ -62,7 +62,7 @@ static void put_image(struct vf_instance
out_size = fame_encode_slice(vf->priv->ctx);
fame_end_frame(vf->priv->ctx, NULL);
- if(out_size<=0) return;
+ if(out_size<=0) return 0;
dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES,
MP_IMGTYPE_EXPORT, 0,
@@ -75,7 +75,7 @@ static void put_image(struct vf_instance
dmpi->planes[0]=&vf->priv->pes;
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_flip.c MPlayer-20020910/libmpcodecs/vf_flip.c
--- MPlayer-20020910.orig/libmpcodecs/vf_flip.c Tue Sep 3 23:26:32 2002
+++ MPlayer-20020910/libmpcodecs/vf_flip.c Tue Sep 10 13:16:33 2002
@@ -44,10 +44,10 @@ static void get_image(struct vf_instance
}
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
if(mpi->flags&MP_IMGFLAG_DIRECT){
- vf_next_put_image(vf,vf->priv->dmpi);
- return; // we've used DR, so we're ready...
+ return vf_next_put_image(vf,vf->priv->dmpi);
+ // we've used DR, so we're ready...
}
vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
@@ -68,7 +68,7 @@ static void put_image(struct vf_instance
} else
vf->priv->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
- vf_next_put_image(vf,vf->priv->dmpi);
+ return vf_next_put_image(vf,vf->priv->dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_halfpack.c MPlayer-20020910/libmpcodecs/vf_halfpack.c
--- MPlayer-20020910.orig/libmpcodecs/vf_halfpack.c Fri Aug 30 17:32:47 2002
+++ MPlayer-20020910/libmpcodecs/vf_halfpack.c Tue Sep 10 13:34:24 2002
@@ -140,7 +140,7 @@ static void (*halfpack)(unsigned char *d
unsigned int dststride, unsigned int srcstride[3], int w, int h);
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi)
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi)
{
mp_image_t *dmpi;
@@ -153,7 +153,7 @@ static void put_image(struct vf_instance
dmpi->stride[0], mpi->stride,
mpi->w, mpi->h);
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
static int config(struct vf_instance_s* vf,
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_lavc.c MPlayer-20020910/libmpcodecs/vf_lavc.c
--- MPlayer-20020910.orig/libmpcodecs/vf_lavc.c Thu Aug 29 01:45:44 2002
+++ MPlayer-20020910/libmpcodecs/vf_lavc.c Tue Sep 10 13:16:33 2002
@@ -78,7 +78,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t* dmpi;
int out_size;
AVPicture lavc_venc_picture;
@@ -93,7 +93,7 @@ static void put_image(struct vf_instance
out_size = avcodec_encode_video(&lavc_venc_context,
vf->priv->outbuf, vf->priv->outbuf_size, &lavc_venc_picture);
- if(out_size<=0) return;
+ if(out_size<=0) return 0;
dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES,
MP_IMGTYPE_EXPORT, 0,
@@ -106,7 +106,7 @@ static void put_image(struct vf_instance
dmpi->planes[0]=(unsigned char*)&vf->priv->pes;
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_lavcdeint.c MPlayer-20020910/libmpcodecs/vf_lavcdeint.c
--- MPlayer-20020910.orig/libmpcodecs/vf_lavcdeint.c Thu Aug 15 00:43:49 2002
+++ MPlayer-20020910/libmpcodecs/vf_lavcdeint.c Tue Sep 10 13:16:33 2002
@@ -107,7 +107,7 @@ config (struct vf_instance_s* vf,
flags, outfmt);
}
-static void
+static int
put_image (struct vf_instance_s* vf, mp_image_t *mpi)
{
struct vf_priv_s *priv = vf->priv;
@@ -137,10 +137,10 @@ put_image (struct vf_instance_s* vf, mp_
priv->pix_fmt, priv->width, priv->height) < 0)
{
/* This should not happen -- see config() */
- return;
+ return 0;
}
- vf_next_put_image(vf, dmpi);
+ return vf_next_put_image(vf, dmpi);
}
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_mirror.c MPlayer-20020910/libmpcodecs/vf_mirror.c
--- MPlayer-20020910.orig/libmpcodecs/vf_mirror.c Mon Jun 24 00:08:31 2002
+++ MPlayer-20020910/libmpcodecs/vf_mirror.c Tue Sep 10 13:16:33 2002
@@ -42,7 +42,7 @@ static void mirror(unsigned char* dst,un
//===========================================================================//
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -66,7 +66,7 @@ static void put_image(struct vf_instance
dmpi->w,dmpi->h,dmpi->bpp>>3);
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_noise.c MPlayer-20020910/libmpcodecs/vf_noise.c
--- MPlayer-20020910.orig/libmpcodecs/vf_noise.c Tue Aug 13 20:53:32 2002
+++ MPlayer-20020910/libmpcodecs/vf_noise.c Tue Sep 10 13:16:33 2002
@@ -334,7 +334,7 @@ static void get_image(struct vf_instance
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
@@ -361,7 +361,7 @@ static void put_image(struct vf_instance
if(gCpuCaps.hasMMX2) asm volatile ("sfence\n\t");
#endif
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
static void uninit(struct vf_instance_s* vf){
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_palette.c MPlayer-20020910/libmpcodecs/vf_palette.c
--- MPlayer-20020910.orig/libmpcodecs/vf_palette.c Mon Sep 9 19:13:51 2002
+++ MPlayer-20020910/libmpcodecs/vf_palette.c Tue Sep 10 13:20:21 2002
@@ -68,7 +68,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -144,7 +144,7 @@ static void put_image(struct vf_instance
}
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_pp.c MPlayer-20020910/libmpcodecs/vf_pp.c
--- MPlayer-20020910.orig/libmpcodecs/vf_pp.c Thu Aug 29 01:45:44 2002
+++ MPlayer-20020910/libmpcodecs/vf_pp.c Tue Sep 10 13:16:33 2002
@@ -67,7 +67,7 @@ static void get_image(struct vf_instance
mpi->flags|=MP_IMGFLAG_DIRECT;
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
// no DR, so get a new image! hope we'll get DR buffer:
vf->priv->dmpi=vf_get_image(vf->next,vf->priv->outfmt,
@@ -87,7 +87,7 @@ static void put_image(struct vf_instance
vf->priv->pp);
}
- vf_next_put_image(vf,vf->priv->dmpi);
+ return vf_next_put_image(vf,vf->priv->dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_rectangle.c MPlayer-20020910/libmpcodecs/vf_rectangle.c
--- MPlayer-20020910.orig/libmpcodecs/vf_rectangle.c Thu Aug 29 01:45:44 2002
+++ MPlayer-20020910/libmpcodecs/vf_rectangle.c Tue Sep 10 13:16:33 2002
@@ -62,7 +62,7 @@ control(struct vf_instance_s* vf, int re
return vf_next_control(vf, request, data);
return 0;
}
-static void
+static int
put_image(struct vf_instance_s* vf, mp_image_t* mpi){
mp_image_t* dmpi;
unsigned int bpp;
@@ -136,7 +136,7 @@ put_image(struct vf_instance_s* vf, mp_i
p += dmpi->stride[0];
}
}
- vf_next_put_image(vf, dmpi);
+ return vf_next_put_image(vf, dmpi);
}
static int
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_rgb2bgr.c MPlayer-20020910/libmpcodecs/vf_rgb2bgr.c
--- MPlayer-20020910.orig/libmpcodecs/vf_rgb2bgr.c Sat Apr 13 22:14:31 2002
+++ MPlayer-20020910/libmpcodecs/vf_rgb2bgr.c Tue Sep 10 13:16:33 2002
@@ -44,7 +44,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -72,7 +72,7 @@ static void put_image(struct vf_instance
rgb24tobgr24(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*3);
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_rotate.c MPlayer-20020910/libmpcodecs/vf_rotate.c
--- MPlayer-20020910.orig/libmpcodecs/vf_rotate.c Mon Jun 24 00:08:31 2002
+++ MPlayer-20020910/libmpcodecs/vf_rotate.c Tue Sep 10 13:16:33 2002
@@ -60,7 +60,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,height,width,d_height,d_width,flags,outfmt);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -84,7 +84,7 @@ static void put_image(struct vf_instance
dmpi->w,dmpi->h,dmpi->bpp>>3,vf->priv->direction);
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_scale.c MPlayer-20020910/libmpcodecs/vf_scale.c
--- MPlayer-20020910.orig/libmpcodecs/vf_scale.c Mon Aug 19 01:46:03 2002
+++ MPlayer-20020910/libmpcodecs/vf_scale.c Tue Sep 10 13:16:33 2002
@@ -166,7 +166,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -182,7 +182,7 @@ static void put_image(struct vf_instance
dmpi->qstride=mpi->qstride;
}
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_test.c MPlayer-20020910/libmpcodecs/vf_test.c
--- MPlayer-20020910.orig/libmpcodecs/vf_test.c Mon Jun 24 00:08:31 2002
+++ MPlayer-20020910/libmpcodecs/vf_test.c Tue Sep 10 13:16:33 2002
@@ -268,9 +268,10 @@ static void ring2Test(uint8_t *dst, int
}
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
int frame= vf->priv->frame_num;
+ int ret;
// hope we'll get DR buffer:
dmpi=vf_get_image(vf->next,IMGFMT_YV12,
@@ -299,9 +300,10 @@ static void put_image(struct vf_instance
}
}
- vf_next_put_image(vf,dmpi);
+ ret = vf_next_put_image(vf,dmpi);
frame++;
vf->priv->frame_num= frame;
+ return ret;
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_vo.c MPlayer-20020910/libmpcodecs/vf_vo.c
--- MPlayer-20020910.orig/libmpcodecs/vf_vo.c Sun Sep 1 17:30:54 2002
+++ MPlayer-20020910/libmpcodecs/vf_vo.c Tue Sep 10 13:16:33 2002
@@ -87,11 +87,11 @@ static void get_image(struct vf_instance
video_out->control(VOCTRL_GET_IMAGE,mpi);
}
-static void put_image(struct vf_instance_s* vf,
+static int put_image(struct vf_instance_s* vf,
mp_image_t *mpi){
- if(!vo_config_count) return; // vo not configured?
+ if(!vo_config_count) return 0; // vo not configured?
// first check, maybe the vo/vf plugin implements draw_image using mpi:
- if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return; // done.
+ if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done.
// nope, fallback to old draw_frame/draw_slice:
if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){
// blit frame:
@@ -100,6 +100,7 @@ static void put_image(struct vf_instance
else
video_out->draw_frame(mpi->planes);
}
+ return 1;
}
static void draw_slice(struct vf_instance_s* vf,
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_yuy2.c MPlayer-20020910/libmpcodecs/vf_yuy2.c
--- MPlayer-20020910.orig/libmpcodecs/vf_yuy2.c Mon Sep 9 23:55:57 2002
+++ MPlayer-20020910/libmpcodecs/vf_yuy2.c Tue Sep 10 13:16:33 2002
@@ -27,7 +27,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YUY2);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
@@ -45,7 +45,7 @@ static void put_image(struct vf_instance
dmpi->qscale=mpi->qscale;
dmpi->qstride=mpi->qstride;
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/libmpcodecs/vf_yvu9.c MPlayer-20020910/libmpcodecs/vf_yvu9.c
--- MPlayer-20020910.orig/libmpcodecs/vf_yvu9.c Sun Jun 23 18:03:54 2002
+++ MPlayer-20020910/libmpcodecs/vf_yvu9.c Tue Sep 10 13:16:33 2002
@@ -27,7 +27,7 @@ static int config(struct vf_instance_s*
return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YV12);
}
-static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
int y,w,h;
@@ -58,7 +58,7 @@ static void put_image(struct vf_instance
dmpi->qscale=mpi->qscale;
dmpi->qstride=mpi->qstride;
- vf_next_put_image(vf,dmpi);
+ return vf_next_put_image(vf,dmpi);
}
//===========================================================================//
diff -udprP MPlayer-20020910.orig/mencoder.c MPlayer-20020910/mencoder.c
--- MPlayer-20020910.orig/mencoder.c Mon Sep 9 14:47:54 2002
+++ MPlayer-20020910/mencoder.c Tue Sep 10 13:16:33 2002
@@ -317,6 +317,7 @@ uint32_t audiosamples=1;
uint32_t videosamples=1;
uint32_t skippedframes=0;
uint32_t duplicatedframes=0;
+uint32_t badframes=0;
aviwrite_stream_t* mux_a=NULL;
aviwrite_stream_t* mux_v=NULL;
@@ -1039,7 +1040,9 @@ case VCODEC_FRAMENO:
default:
// decode_video will callback down to ve_*.c encoders, through the video filters
blit_frame=decode_video(sh_video,start,in_size,(skip_flag>0)?1:0);
- if(!blit_frame && skip_flag<=0){
+ if(!blit_frame){
+ badframes++;
+ if(skip_flag<=0){
// unwanted skipping of a frame, what to do?
if(skip_limit==0){
// skipping not allowed -> write empty frame:
@@ -1048,6 +1051,7 @@ default:
// skipping allowed -> skip it and distriubute timer error:
v_timer_corr-=(float)mux_v->h.dwScale/mux_v->h.dwRate;
}
+ }
}
}
@@ -1134,7 +1138,7 @@ if(sh_audio && !demuxer2){
(int)demuxer->movi_end);
#else
if(verbose) {
- mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb A-V:%5.3f [%d:%d] A/Vms %d/%d D/S %d/%d \r",
+ mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb A-V:%5.3f [%d:%d] A/Vms %d/%d D/B/S %d/%d/%d \r",
mux_v->timer, decoded_frameno, (int)(p*100),
(t>1) ? (int)(decoded_frameno/t+0.5) : 0,
(p>0.001) ? (int)((t/p-t)/60) : 0,
@@ -1143,7 +1147,7 @@ if(sh_audio && !demuxer2){
(mux_v->timer>1) ? (int)(mux_v->size/mux_v->timer/125) : 0,
(mux_a && mux_a->timer>1) ? (int)(mux_a->size/mux_a->timer/125) : 0,
audiorate/audiosamples, videorate/videosamples,
- duplicatedframes, skippedframes
+ duplicatedframes, badframes, skippedframes
);
} else
mp_msg(MSGT_AVSYNC,MSGL_STATUS,"Pos:%6.1fs %6df (%2d%%) %3dfps Trem:%4dmin %3dmb A-V:%5.3f [%d:%d]\r",
More information about the MPlayer-dev-eng
mailing list