mirror of
https://github.com/mpv-player/mpv
synced 2025-01-11 17:39:38 +00:00
DR, 10l fixes
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10812 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
0c5802cfa0
commit
6af7fe11bf
@ -47,59 +47,80 @@ struct vf_priv_s {
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
|
||||
{
|
||||
int i;
|
||||
void *retval = dst;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
memcpy(dst, src, bytesPerLine);
|
||||
src += srcStride;
|
||||
dst += dstStride;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height,
|
||||
int logo_x, int logo_y, int logo_w, int logo_h, int band, int show) {
|
||||
int logo_x, int logo_y, int logo_w, int logo_h, int band, int show, int direct) {
|
||||
int y, x;
|
||||
int interp, dist;
|
||||
uint8_t *xdst, *xsrc;
|
||||
|
||||
uint8_t *topleft, *botleft, *topright;
|
||||
int xclipl, xclipr, yclipt, yclipb;
|
||||
int logo_x1, logo_x2, logo_y1, logo_y2;
|
||||
|
||||
xclipl = MAX(-logo_x, 0);
|
||||
xclipr = MAX(logo_x+logo_w-width, 0);
|
||||
yclipt = MAX(-logo_y, 0);
|
||||
yclipb = MAX(logo_y+logo_h-height, 0);
|
||||
|
||||
topleft = src+MAX(logo_y,0)*srcStride+MAX(logo_x,0);
|
||||
topright = src+MAX(logo_y,0)*srcStride+MIN(logo_x+logo_w-1,width-1);
|
||||
botleft = src+MIN(logo_y+logo_h-1,height-1)*srcStride+MAX(logo_x,0);
|
||||
logo_x1 = logo_x + xclipl;
|
||||
logo_x2 = logo_x + logo_w - xclipr;
|
||||
logo_y1 = logo_y + yclipt;
|
||||
logo_y2 = logo_y + logo_h - yclipb;
|
||||
|
||||
for(y=0; y<height; y++)
|
||||
topleft = src+logo_y1*srcStride+logo_x1;
|
||||
topright = src+logo_x1*srcStride+logo_x2-1;
|
||||
botleft = src+(logo_y2-1)*srcStride+logo_x1;
|
||||
|
||||
if (!direct) my_memcpy_pic(dst, src, width, height, dstStride, srcStride);
|
||||
|
||||
dst += (logo_y1+1)*dstStride;
|
||||
src += (logo_y1+1)*srcStride;
|
||||
|
||||
for(y = logo_y1+1; y < logo_y2-1; y++)
|
||||
{
|
||||
for (x = 0, xdst = dst, xsrc = src; x < width; x++, xdst++, xsrc++) {
|
||||
if (y >= logo_y && y < logo_y+logo_h && x >= logo_x && x < logo_x+logo_w) {
|
||||
interp = ((topleft[srcStride*(y-logo_y-yclipt)]
|
||||
+ topleft[srcStride*(y-logo_y-1-yclipt)]
|
||||
+ topleft[srcStride*(y-logo_y+1-yclipt)])*(logo_w-(x-logo_x))/logo_w
|
||||
+ (topright[srcStride*(y-logo_y-yclipt)]
|
||||
+ topright[srcStride*(y-logo_y-1-yclipt)]
|
||||
+ topright[srcStride*(y-logo_y+1-yclipt)])*(x-logo_x)/logo_w
|
||||
+ (topleft[x-logo_x-xclipl]
|
||||
+ topleft[x-logo_x-1-xclipl]
|
||||
+ topleft[x-logo_x+1-xclipl])*(logo_h-(y-logo_y))/logo_h
|
||||
+ (botleft[x-logo_x-xclipl]
|
||||
+ botleft[x-logo_x-1-xclipl]
|
||||
+ botleft[x-logo_x+1-xclipl])*(y-logo_y)/logo_h
|
||||
)/6;
|
||||
for (x = logo_x1+1, xdst = dst+logo_x1+1, xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
|
||||
interp = ((topleft[srcStride*(y-logo_y-yclipt)]
|
||||
+ topleft[srcStride*(y-logo_y-1-yclipt)]
|
||||
+ topleft[srcStride*(y-logo_y+1-yclipt)])*(logo_w-(x-logo_x))/logo_w
|
||||
+ (topright[srcStride*(y-logo_y-yclipt)]
|
||||
+ topright[srcStride*(y-logo_y-1-yclipt)]
|
||||
+ topright[srcStride*(y-logo_y+1-yclipt)])*(x-logo_x)/logo_w
|
||||
+ (topleft[x-logo_x-xclipl]
|
||||
+ topleft[x-logo_x-1-xclipl]
|
||||
+ topleft[x-logo_x+1-xclipl])*(logo_h-(y-logo_y))/logo_h
|
||||
+ (botleft[x-logo_x-xclipl]
|
||||
+ botleft[x-logo_x-1-xclipl]
|
||||
+ botleft[x-logo_x+1-xclipl])*(y-logo_y)/logo_h
|
||||
)/6;
|
||||
/* interp = (topleft[srcStride*(y-logo_y)]*(logo_w-(x-logo_x))/logo_w
|
||||
+ topright[srcStride*(y-logo_y)]*(x-logo_x)/logo_w
|
||||
+ topleft[x-logo_x]*(logo_h-(y-logo_y))/logo_h
|
||||
+ botleft[x-logo_x]*(y-logo_y)/logo_h
|
||||
)/2;*/
|
||||
if (y >= logo_y+band && y < logo_y+logo_h-band && x >= logo_x+band && x < logo_x+logo_w-band) {
|
||||
if (y >= logo_y+band && y < logo_y+logo_h-band && x >= logo_x+band && x < logo_x+logo_w-band) {
|
||||
*xdst = interp;
|
||||
} else {
|
||||
dist = 0;
|
||||
if (x < logo_x+band) dist = MAX(dist, logo_x-x+band);
|
||||
else if (x >= logo_x+logo_w-band) dist = MAX(dist, x-(logo_x+logo_w-1-band));
|
||||
if (y < logo_y+band) dist = MAX(dist, logo_y-y+band);
|
||||
else if (y >= logo_y+logo_h-band) dist = MAX(dist, y-(logo_y+logo_h-1-band));
|
||||
*xdst = (*xsrc*dist + interp*(band-dist))/band;
|
||||
if (show && dist == band) *xdst = 0;
|
||||
}
|
||||
} else {
|
||||
*xdst = *xsrc;
|
||||
dist = 0;
|
||||
if (x < logo_x+band) dist = MAX(dist, logo_x-x+band);
|
||||
else if (x >= logo_x+logo_w-band) dist = MAX(dist, x-(logo_x+logo_w-1-band));
|
||||
if (y < logo_y+band) dist = MAX(dist, logo_y-y+band);
|
||||
else if (y >= logo_y+logo_h-band) dist = MAX(dist, y-(logo_y+logo_h-1-band));
|
||||
*xdst = (*xsrc*dist + interp*(band-dist))/band;
|
||||
if (show && (dist == band-1)) *xdst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,11 +167,14 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||
dmpi= vf->dmpi;
|
||||
|
||||
delogo(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h,
|
||||
vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show);
|
||||
vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show,
|
||||
mpi->flags&MP_IMGFLAG_DIRECT);
|
||||
delogo(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2,
|
||||
vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show);
|
||||
vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
|
||||
mpi->flags&MP_IMGFLAG_DIRECT);
|
||||
delogo(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2,
|
||||
vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show);
|
||||
vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
|
||||
mpi->flags&MP_IMGFLAG_DIRECT);
|
||||
|
||||
vf_clone_mpi_attributes(dmpi, mpi);
|
||||
|
||||
@ -214,7 +238,7 @@ static int open(vf_instance_t *vf, char* args){
|
||||
vf->priv->show = 0;
|
||||
|
||||
if (vf->priv->band < 0) {
|
||||
vf->priv->band = 2;
|
||||
vf->priv->band = 4;
|
||||
vf->priv->show = 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user