diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-07-06 13:07:37 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-07-06 13:07:37 +0300 |
commit | 2670ceeb81e009f88812f4014e08b88317a2cf42 (patch) | |
tree | b6f2a6367fcc8998a531d209745770789ae03fcd /libmpcodecs | |
parent | b7f574405350f93083fb423c34a21788684e10d4 (diff) | |
parent | a7b99687a7c8b59abb67f725c1cbc648ab439c74 (diff) | |
download | mpv-2670ceeb81e009f88812f4014e08b88317a2cf42.tar.bz2 mpv-2670ceeb81e009f88812f4014e08b88317a2cf42.tar.xz |
Merge branch 'mplayer1_changes'
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/img_format.h | 22 | ||||
-rw-r--r-- | libmpcodecs/vf_delogo.c | 251 | ||||
-rw-r--r-- | libmpcodecs/vf_dint.c | 12 | ||||
-rw-r--r-- | libmpcodecs/vf_divtc.c | 6 | ||||
-rw-r--r-- | libmpcodecs/vf_ilpack.c | 685 | ||||
-rw-r--r-- | libmpcodecs/vf_stereo3d.c | 36 |
6 files changed, 576 insertions, 436 deletions
diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h index 2fc9775ee1..60adc5c038 100644 --- a/libmpcodecs/img_format.h +++ b/libmpcodecs/img_format.h @@ -164,26 +164,26 @@ /* Packed YUV Formats */ -#define IMGFMT_IUYV 0x56595549 -#define IMGFMT_IY41 0x31435949 +#define IMGFMT_IUYV 0x56595549 // Interlaced UYVY +#define IMGFMT_IY41 0x31435949 // Interlaced Y41P #define IMGFMT_IYU1 0x31555949 #define IMGFMT_IYU2 0x32555949 #define IMGFMT_UYVY 0x59565955 -#define IMGFMT_UYNV 0x564E5955 -#define IMGFMT_cyuv 0x76757963 -#define IMGFMT_Y422 0x32323459 +#define IMGFMT_UYNV 0x564E5955 // Exactly same as UYVY +#define IMGFMT_cyuv 0x76757963 // upside-down UYVY +#define IMGFMT_Y422 0x32323459 // Exactly same as UYVY #define IMGFMT_YUY2 0x32595559 -#define IMGFMT_YUNV 0x564E5559 +#define IMGFMT_YUNV 0x564E5559 // Exactly same as YUY2 #define IMGFMT_YVYU 0x55595659 #define IMGFMT_Y41P 0x50313459 #define IMGFMT_Y211 0x31313259 -#define IMGFMT_Y41T 0x54313459 -#define IMGFMT_Y42T 0x54323459 -#define IMGFMT_V422 0x32323456 +#define IMGFMT_Y41T 0x54313459 // Y41P, Y lsb = transparency +#define IMGFMT_Y42T 0x54323459 // UYVY, Y lsb = transparency +#define IMGFMT_V422 0x32323456 // upside-down UYVY? #define IMGFMT_V655 0x35353656 #define IMGFMT_CLJR 0x524A4C43 -#define IMGFMT_YUVP 0x50565559 -#define IMGFMT_UYVP 0x50565955 +#define IMGFMT_YUVP 0x50565559 // 10-bit YUYV +#define IMGFMT_UYVP 0x50565955 // 10-bit UYVY /* Compressed Formats */ #define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S')) diff --git a/libmpcodecs/vf_delogo.c b/libmpcodecs/vf_delogo.c index 342c88ee59..8fcc869c91 100644 --- a/libmpcodecs/vf_delogo.c +++ b/libmpcodecs/vf_delogo.c @@ -24,6 +24,8 @@ #include <stdlib.h> #include <string.h> #include <inttypes.h> +#include <limits.h> +#include <errno.h> #include <math.h> #include "mp_msg.h" @@ -41,16 +43,65 @@ static struct vf_priv_s { unsigned int outfmt; int xoff, yoff, lw, lh, band, show; + const char *file; + struct timed_rectangle { + int ts, x, y, w, h, b; + } *timed_rect; + int n_timed_rect; + int cur_timed_rect; } const vf_priv_dflt = { 0, - 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, + NULL, NULL, 0, 0, }; #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) +/** + * Adjust the coordinates to suit the band width + * Also print a notice in verbose mode + */ +static void fix_band(struct vf_priv_s *p) +{ + p->show = 0; + if (p->band < 0) { + p->band = 4; + p->show = 1; + } + p->lw += p->band*2; + p->lh += p->band*2; + p->xoff -= p->band; + p->yoff -= p->band; + mp_msg(MSGT_VFILTER, MSGL_V, "delogo: %d x %d, %d x %d, band = %d\n", + p->xoff, p->yoff, p->lw, p->lh, p->band); +} + +static void update_sub(struct vf_priv_s *p, double pts) +{ + int ipts = pts * 1000; + int tr = p->cur_timed_rect; + while (tr < p->n_timed_rect - 1 && ipts >= p->timed_rect[tr + 1].ts) + tr++; + while (tr >= 0 && ipts < p->timed_rect[tr].ts) + tr--; + if (tr == p->cur_timed_rect) + return; + p->cur_timed_rect = tr; + if (tr >= 0) { + p->xoff = p->timed_rect[tr].x; + p->yoff = p->timed_rect[tr].y; + p->lw = p->timed_rect[tr].w; + p->lh = p->timed_rect[tr].h; + p->band = p->timed_rect[tr].b; + } else { + p->xoff = p->yoff = p->lw = p->lh = p->band = 0; + } + fix_band(p); +} + 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 direct) { + 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; @@ -80,46 +131,46 @@ static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int for(y = logo_y1+1; y < logo_y2-1; y++) { - 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) { - *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-1)) *xdst = 0; - } - } - - dst+= dstStride; - src+= srcStride; + 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) { + *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-1)) *xdst = 0; + } + } + + dst+= dstStride; + src+= srcStride; } } static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt){ return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } @@ -130,15 +181,15 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi){ if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, - mpi->type, mpi->flags, mpi->w, mpi->h); + mpi->type, mpi->flags, mpi->w, mpi->h); mpi->planes[0]=vf->dmpi->planes[0]; mpi->stride[0]=vf->dmpi->stride[0]; mpi->width=vf->dmpi->width; if(mpi->flags&MP_IMGFLAG_PLANAR){ mpi->planes[1]=vf->dmpi->planes[1]; mpi->planes[2]=vf->dmpi->planes[2]; - mpi->stride[1]=vf->dmpi->stride[1]; - mpi->stride[2]=vf->dmpi->stride[2]; + mpi->stride[1]=vf->dmpi->stride[1]; + mpi->stride[2]=vf->dmpi->stride[2]; } mpi->flags|=MP_IMGFLAG_DIRECT; } @@ -147,22 +198,24 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ - // no DR, so get a new image! hope we'll get DR buffer: - vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt, - MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, - mpi->w,mpi->h); + // no DR, so get a new image! hope we'll get DR buffer: + vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt, + MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, + mpi->w,mpi->h); } dmpi= vf->dmpi; + if (vf->priv->timed_rect) + update_sub(vf->priv, pts); 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, - mpi->flags&MP_IMGFLAG_DIRECT); + 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, - mpi->flags&MP_IMGFLAG_DIRECT); + 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, - mpi->flags&MP_IMGFLAG_DIRECT); + 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); @@ -184,7 +237,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){ case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: - return vf_next_query_format(vf,vf->priv->outfmt); + return vf_next_query_format(vf,vf->priv->outfmt); } return 0; } @@ -196,6 +249,74 @@ static const unsigned int fmt_list[]={ 0 }; +static int load_timed_rectangles(struct vf_priv_s *delogo) +{ + FILE *f; + char line[2048]; + int lineno = 0, p; + double ts, last_ts = 0; + struct timed_rectangle *rect = NULL, *nr; + int n_rect = 0, alloc_rect = 0; + + f = fopen(delogo->file, "r"); + if (!f) { + mp_msg(MSGT_VFILTER, MSGL_ERR, "delogo: unable to load %s: %s\n", + delogo->file, strerror(errno)); + return -1; + } + while (fgets(line, sizeof(line), f)) { + lineno++; + if (*line == '#' || *line == '\n') + continue; + if (n_rect == alloc_rect) { + if (alloc_rect > INT_MAX / 2 / (int)sizeof(*rect)) { + mp_msg(MSGT_VFILTER, MSGL_WARN, + "delogo: too many rectangles\n"); + goto load_error; + } + alloc_rect = alloc_rect ? 2 * alloc_rect : 256; + nr = realloc(rect, alloc_rect * sizeof(*rect)); + if (!nr) { + mp_msg(MSGT_VFILTER, MSGL_WARN, "delogo: out of memory\n"); + goto load_error; + } + rect = nr; + } + nr = rect + n_rect; + memset(nr, 0, sizeof(*nr)); + p = sscanf(line, "%lf %d:%d:%d:%d:%d", + &ts, &nr->x, &nr->y, &nr->w, &nr->h, &nr->b); + if ((p == 2 && !nr->x) || p == 5 || p == 6) { + if (ts <= last_ts) + mp_msg(MSGT_VFILTER, MSGL_WARN, "delogo: %s:%d: wrong time\n", + delogo->file, lineno); + nr->ts = 1000 * ts + 0.5; + n_rect++; + } else { + mp_msg(MSGT_VFILTER, MSGL_WARN, "delogo: %s:%d: syntax error\n", + delogo->file, lineno); + } + } + fclose(f); + if (!n_rect) { + mp_msg(MSGT_VFILTER, MSGL_ERR, "delogo: %s: no rectangles found\n", + delogo->file); + free(rect); + return -1; + } + nr = realloc(rect, n_rect * sizeof(*rect)); + if (nr) + rect = nr; + delogo->timed_rect = rect; + delogo->n_timed_rect = n_rect; + return 0; + +load_error: + free(rect); + fclose(f); + return -1; +} + static int vf_open(vf_instance_t *vf, char *args){ vf->config=config; vf->put_image=put_image; @@ -203,29 +324,20 @@ static int vf_open(vf_instance_t *vf, char *args){ vf->query_format=query_format; vf->uninit=uninit; - mp_msg(MSGT_VFILTER, MSGL_V, "delogo: %d x %d, %d x %d, band = %d\n", - vf->priv->xoff, vf->priv->yoff, - vf->priv->lw, vf->priv->lh, - vf->priv->band); - - vf->priv->show = 0; - - if (vf->priv->band < 0) { - vf->priv->band = 4; - vf->priv->show = 1; + if (vf->priv->file) { + if (load_timed_rectangles(vf->priv)) + return 0; + mp_msg(MSGT_VFILTER, MSGL_V, "delogo: %d from %s\n", + vf->priv->n_timed_rect, vf->priv->file); + vf->priv->cur_timed_rect = -1; } - - - vf->priv->lw += vf->priv->band*2; - vf->priv->lh += vf->priv->band*2; - vf->priv->xoff -= vf->priv->band; - vf->priv->yoff -= vf->priv->band; + fix_band(vf->priv); // check csp: vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12); if(!vf->priv->outfmt) { - uninit(vf); + uninit(vf); return 0; // no csp match :( } @@ -240,6 +352,7 @@ static const m_option_t vf_opts_fields[] = { { "h", ST_OFF(lh), CONF_TYPE_INT, 0, 0, 0, NULL }, { "t", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, { "band", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, // alias + { "file", ST_OFF(file), CONF_TYPE_STRING, 0, 0, 0, NULL }, { NULL, NULL, 0, 0, 0, 0, NULL } }; diff --git a/libmpcodecs/vf_dint.c b/libmpcodecs/vf_dint.c index f5fc88e328..b449f9292c 100644 --- a/libmpcodecs/vf_dint.c +++ b/libmpcodecs/vf_dint.c @@ -32,7 +32,7 @@ struct vf_priv_s { float sense; // first parameter float level; // second parameter unsigned int imgfmt; - char diff; + int diff; uint32_t max; // int dfr; // int rdfr; @@ -73,7 +73,7 @@ static int config (struct vf_instance *vf, 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->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); @@ -81,10 +81,10 @@ static int config (struct vf_instance *vf, static int put_image (struct vf_instance *vf, mp_image_t *mpi, double pts) { - char rrow0[MAXROWSIZE]; - char rrow1[MAXROWSIZE]; - char rrow2[MAXROWSIZE]; - char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/; + int8_t rrow0[MAXROWSIZE]; + int8_t rrow1[MAXROWSIZE]; + int8_t rrow2[MAXROWSIZE]; + int8_t *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; diff --git a/libmpcodecs/vf_divtc.c b/libmpcodecs/vf_divtc.c index 3a4f2169ab..e04e7c0b4e 100644 --- a/libmpcodecs/vf_divtc.c +++ b/libmpcodecs/vf_divtc.c @@ -42,7 +42,7 @@ struct vf_priv_s ocount, sum[5]; double threshold; FILE *file; - char *bdata; + int8_t *bdata; unsigned int *csdata; int *history; struct vf_detc_pts_buf ptsbuf; @@ -386,8 +386,8 @@ static int analyze(struct vf_priv_s *p) { int *buf=0, *bp, bufsize=0, n, b, f, i, j, m, s; unsigned int *cbuf=0, *cp; - char *pbuf; - char lbuf[256]; + int8_t *pbuf; + int8_t lbuf[256]; int sum[5]; double d; diff --git a/libmpcodecs/vf_ilpack.c b/libmpcodecs/vf_ilpack.c index 73e7c57fbf..db4a849e1f 100644 --- a/libmpcodecs/vf_ilpack.c +++ b/libmpcodecs/vf_ilpack.c @@ -28,303 +28,306 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" +#include "libavutil/attributes.h" typedef void (pack_func_t)(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w, int us, int vs); + unsigned char *u, unsigned char *v, int w, int us, int vs); struct vf_priv_s { - int mode; - pack_func_t *pack[2]; + int mode; + pack_func_t *pack[2]; }; static void pack_nn_C(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w) + unsigned char *u, unsigned char *v, int w, + int av_unused us, int av_unused vs) { - int j; - for (j = w/2; j; j--) { - *dst++ = *y++; - *dst++ = *u++; - *dst++ = *y++; - *dst++ = *v++; - } + int j; + for (j = w/2; j; j--) { + *dst++ = *y++; + *dst++ = *u++; + *dst++ = *y++; + *dst++ = *v++; + } } static void pack_li_0_C(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w, int us, int vs) + unsigned char *u, unsigned char *v, int w, int us, int vs) { - int j; - for (j = w/2; j; j--) { - *dst++ = *y++; - *dst++ = (u[us+us] + 7*u[0])>>3; - *dst++ = *y++; - *dst++ = (v[vs+vs] + 7*v[0])>>3; - u++; v++; - } + int j; + for (j = w/2; j; j--) { + *dst++ = *y++; + *dst++ = (u[us+us] + 7*u[0])>>3; + *dst++ = *y++; + *dst++ = (v[vs+vs] + 7*v[0])>>3; + u++; v++; + } } static void pack_li_1_C(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w, int us, int vs) + unsigned char *u, unsigned char *v, int w, int us, int vs) { - int j; - for (j = w/2; j; j--) { - *dst++ = *y++; - *dst++ = (3*u[us+us] + 5*u[0])>>3; - *dst++ = *y++; - *dst++ = (3*v[vs+vs] + 5*v[0])>>3; - u++; v++; - } + int j; + for (j = w/2; j; j--) { + *dst++ = *y++; + *dst++ = (3*u[us+us] + 5*u[0])>>3; + *dst++ = *y++; + *dst++ = (3*v[vs+vs] + 5*v[0])>>3; + u++; v++; + } } #if HAVE_MMX static void pack_nn_MMX(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w) + unsigned char *u, unsigned char *v, int w, + int av_unused us, int av_unused vs) { - __asm__ volatile ("" - ASMALIGN(4) - "1: \n\t" - "movq (%0), %%mm1 \n\t" - "movq (%0), %%mm2 \n\t" - "movq (%1), %%mm4 \n\t" - "movq (%2), %%mm6 \n\t" - "punpcklbw %%mm6, %%mm4 \n\t" - "punpcklbw %%mm4, %%mm1 \n\t" - "punpckhbw %%mm4, %%mm2 \n\t" - - "add $8, %0 \n\t" - "add $4, %1 \n\t" - "add $4, %2 \n\t" - "movq %%mm1, (%3) \n\t" - "movq %%mm2, 8(%3) \n\t" - "add $16, %3 \n\t" - "decl %4 \n\t" - "jnz 1b \n\t" - "emms \n\t" - : - : "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8) - : "memory" - ); - pack_nn_C(dst, y, u, v, (w&7)); + __asm__ volatile ("" + ASMALIGN(4) + "1: \n\t" + "movq (%0), %%mm1 \n\t" + "movq (%0), %%mm2 \n\t" + "movq (%1), %%mm4 \n\t" + "movq (%2), %%mm6 \n\t" + "punpcklbw %%mm6, %%mm4 \n\t" + "punpcklbw %%mm4, %%mm1 \n\t" + "punpckhbw %%mm4, %%mm2 \n\t" + + "add $8, %0 \n\t" + "add $4, %1 \n\t" + "add $4, %2 \n\t" + "movq %%mm1, (%3) \n\t" + "movq %%mm2, 8(%3) \n\t" + "add $16, %3 \n\t" + "decl %4 \n\t" + "jnz 1b \n\t" + "emms \n\t" + : + : "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8) + : "memory" + ); + pack_nn_C(dst, y, u, v, (w&7), 0, 0); } #if HAVE_EBX_AVAILABLE static void pack_li_0_MMX(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w, int us, int vs) + unsigned char *u, unsigned char *v, int w, int us, int vs) { - __asm__ volatile ("" - "push %%"REG_BP" \n\t" + __asm__ volatile ("" + "push %%"REG_BP" \n\t" #if ARCH_X86_64 - "mov %6, %%"REG_BP" \n\t" + "mov %6, %%"REG_BP" \n\t" #else - "movl 4(%%"REG_d"), %%"REG_BP" \n\t" - "movl (%%"REG_d"), %%"REG_d" \n\t" + "movl 4(%%"REG_d"), %%"REG_BP" \n\t" + "movl (%%"REG_d"), %%"REG_d" \n\t" #endif - "pxor %%mm0, %%mm0 \n\t" - - ASMALIGN(4) - ".Lli0: \n\t" - "movq (%%"REG_S"), %%mm1 \n\t" - "movq (%%"REG_S"), %%mm2 \n\t" - - "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" - "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" - "punpcklbw %%mm0, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm6 \n\t" - "movq (%%"REG_a"), %%mm3 \n\t" - "movq (%%"REG_b"), %%mm5 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" - "punpcklbw %%mm0, %%mm5 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "psrlw $3, %%mm4 \n\t" - "psrlw $3, %%mm6 \n\t" - "packuswb %%mm4, %%mm4 \n\t" - "packuswb %%mm6, %%mm6 \n\t" - "punpcklbw %%mm6, %%mm4 \n\t" - "punpcklbw %%mm4, %%mm1 \n\t" - "punpckhbw %%mm4, %%mm2 \n\t" - - "movq %%mm1, (%%"REG_D") \n\t" - "movq %%mm2, 8(%%"REG_D") \n\t" - - "movq 8(%%"REG_S"), %%mm1 \n\t" - "movq 8(%%"REG_S"), %%mm2 \n\t" - - "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" - "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" - "punpckhbw %%mm0, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm6 \n\t" - "movq (%%"REG_a"), %%mm3 \n\t" - "movq (%%"REG_b"), %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" - "punpckhbw %%mm0, %%mm5 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "psrlw $3, %%mm4 \n\t" - "psrlw $3, %%mm6 \n\t" - "packuswb %%mm4, %%mm4 \n\t" - "packuswb %%mm6, %%mm6 \n\t" - "punpcklbw %%mm6, %%mm4 \n\t" - "punpcklbw %%mm4, %%mm1 \n\t" - "punpckhbw %%mm4, %%mm2 \n\t" - - "add $16, %%"REG_S" \n\t" - "add $8, %%"REG_a" \n\t" - "add $8, %%"REG_b" \n\t" - - "movq %%mm1, 16(%%"REG_D") \n\t" - "movq %%mm2, 24(%%"REG_D") \n\t" - "add $32, %%"REG_D" \n\t" - - "decl %%ecx \n\t" - "jnz .Lli0 \n\t" - "emms \n\t" - "pop %%"REG_BP" \n\t" - : - : "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16), + "pxor %%mm0, %%mm0 \n\t" + + ASMALIGN(4) + ".Lli0: \n\t" + "movq (%%"REG_S"), %%mm1 \n\t" + "movq (%%"REG_S"), %%mm2 \n\t" + + "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" + "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + "movq (%%"REG_a"), %%mm3 \n\t" + "movq (%%"REG_b"), %%mm5 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "psrlw $3, %%mm4 \n\t" + "psrlw $3, %%mm6 \n\t" + "packuswb %%mm4, %%mm4 \n\t" + "packuswb %%mm6, %%mm6 \n\t" + "punpcklbw %%mm6, %%mm4 \n\t" + "punpcklbw %%mm4, %%mm1 \n\t" + "punpckhbw %%mm4, %%mm2 \n\t" + + "movq %%mm1, (%%"REG_D") \n\t" + "movq %%mm2, 8(%%"REG_D") \n\t" + + "movq 8(%%"REG_S"), %%mm1 \n\t" + "movq 8(%%"REG_S"), %%mm2 \n\t" + + "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" + "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" + "punpckhbw %%mm0, %%mm4 \n\t" + "punpckhbw %%mm0, %%mm6 \n\t" + "movq (%%"REG_a"), %%mm3 \n\t" + "movq (%%"REG_b"), %%mm5 \n\t" + "punpckhbw %%mm0, %%mm3 \n\t" + "punpckhbw %%mm0, %%mm5 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "psrlw $3, %%mm4 \n\t" + "psrlw $3, %%mm6 \n\t" + "packuswb %%mm4, %%mm4 \n\t" + "packuswb %%mm6, %%mm6 \n\t" + "punpcklbw %%mm6, %%mm4 \n\t" + "punpcklbw %%mm4, %%mm1 \n\t" + "punpckhbw %%mm4, %%mm2 \n\t" + + "add $16, %%"REG_S" \n\t" + "add $8, %%"REG_a" \n\t" + "add $8, %%"REG_b" \n\t" + + "movq %%mm1, 16(%%"REG_D") \n\t" + "movq %%mm2, 24(%%"REG_D") \n\t" + "add $32, %%"REG_D" \n\t" + + "decl %%ecx \n\t" + "jnz .Lli0 \n\t" + "emms \n\t" + "pop %%"REG_BP" \n\t" + : + : "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16), #if ARCH_X86_64 - "d" ((x86_reg)us), "r" ((x86_reg)vs) + "d" ((x86_reg)us), "r" ((x86_reg)vs) #else - "d" (&us) + "d" (&us) #endif - : "memory" - ); - pack_li_0_C(dst, y, u, v, (w&15), us, vs); + : "memory" + ); + pack_li_0_C(dst, y, u, v, (w&15), us, vs); } static void pack_li_1_MMX(unsigned char *dst, unsigned char *y, - unsigned char *u, unsigned char *v, int w, int us, int vs) + unsigned char *u, unsigned char *v, int w, int us, int vs) { - __asm__ volatile ("" - "push %%"REG_BP" \n\t" + __asm__ volatile ("" + "push %%"REG_BP" \n\t" #if ARCH_X86_64 - "mov %6, %%"REG_BP" \n\t" + "mov %6, %%"REG_BP" \n\t" #else - "movl 4(%%"REG_d"), %%"REG_BP" \n\t" - "movl (%%"REG_d"), %%"REG_d" \n\t" + "movl 4(%%"REG_d"), %%"REG_BP" \n\t" + "movl (%%"REG_d"), %%"REG_d" \n\t" #endif - "pxor %%mm0, %%mm0 \n\t" - - ASMALIGN(4) - ".Lli1: \n\t" - "movq (%%"REG_S"), %%mm1 \n\t" - "movq (%%"REG_S"), %%mm2 \n\t" - - "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" - "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" - "punpcklbw %%mm0, %%mm4 \n\t" - "punpcklbw %%mm0, %%mm6 \n\t" - "movq (%%"REG_a"), %%mm3 \n\t" - "movq (%%"REG_b"), %%mm5 \n\t" - "punpcklbw %%mm0, %%mm3 \n\t" - "punpcklbw %%mm0, %%mm5 \n\t" - "movq %%mm4, %%mm7 \n\t" - "paddw %%mm4, %%mm4 \n\t" - "paddw %%mm7, %%mm4 \n\t" - "movq %%mm6, %%mm7 \n\t" - "paddw %%mm6, %%mm6 \n\t" - "paddw %%mm7, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "psrlw $3, %%mm4 \n\t" - "psrlw $3, %%mm6 \n\t" - "packuswb %%mm4, %%mm4 \n\t" - "packuswb %%mm6, %%mm6 \n\t" - "punpcklbw %%mm6, %%mm4 \n\t" - "punpcklbw %%mm4, %%mm1 \n\t" - "punpckhbw %%mm4, %%mm2 \n\t" - - "movq %%mm1, (%%"REG_D") \n\t" - "movq %%mm2, 8(%%"REG_D") \n\t" - - "movq 8(%%"REG_S"), %%mm1 \n\t" - "movq 8(%%"REG_S"), %%mm2 \n\t" - - "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" - "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" - "punpckhbw %%mm0, %%mm4 \n\t" - "punpckhbw %%mm0, %%mm6 \n\t" - "movq (%%"REG_a"), %%mm3 \n\t" - "movq (%%"REG_b"), %%mm5 \n\t" - "punpckhbw %%mm0, %%mm3 \n\t" - "punpckhbw %%mm0, %%mm5 \n\t" - "movq %%mm4, %%mm7 \n\t" - "paddw %%mm4, %%mm4 \n\t" - "paddw %%mm7, %%mm4 \n\t" - "movq %%mm6, %%mm7 \n\t" - "paddw %%mm6, %%mm6 \n\t" - "paddw %%mm7, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "paddw %%mm3, %%mm4 \n\t" - "paddw %%mm5, %%mm6 \n\t" - "psrlw $3, %%mm4 \n\t" - "psrlw $3, %%mm6 \n\t" - "packuswb %%mm4, %%mm4 \n\t" - "packuswb %%mm6, %%mm6 \n\t" - "punpcklbw %%mm6, %%mm4 \n\t" - "punpcklbw %%mm4, %%mm1 \n\t" - "punpckhbw %%mm4, %%mm2 \n\t" - - "add $16, %%"REG_S" \n\t" - "add $8, %%"REG_a" \n\t" - "add $8, %%"REG_b" \n\t" - - "movq %%mm1, 16(%%"REG_D") \n\t" - "movq %%mm2, 24(%%"REG_D") \n\t" - "add $32, %%"REG_D" \n\t" - - "decl %%ecx \n\t" - "jnz .Lli1 \n\t" - "emms \n\t" - "pop %%"REG_BP" \n\t" - : - : "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16), + "pxor %%mm0, %%mm0 \n\t" + + ASMALIGN(4) + ".Lli1: \n\t" + "movq (%%"REG_S"), %%mm1 \n\t" + "movq (%%"REG_S"), %%mm2 \n\t" + + "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" + "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + "movq (%%"REG_a"), %%mm3 \n\t" + "movq (%%"REG_b"), %%mm5 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "movq %%mm4, %%mm7 \n\t" + "paddw %%mm4, %%mm4 \n\t" + "paddw %%mm7, %%mm4 \n\t" + "movq %%mm6, %%mm7 \n\t" + "paddw %%mm6, %%mm6 \n\t" + "paddw %%mm7, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "paddw %%mm3, %%mm4 \n\t" + "paddw %%mm5, %%mm6 \n\t" + "psrlw $3, %%mm4 \n\t" + "psrlw $3, %%mm6 \n\t" + "packuswb %%mm4, %%mm4 \n\t" + "packuswb %%mm6, %%mm6 \n\t" + "punpcklbw %%mm6, %%mm4 \n\t" + "punpcklbw %%mm4, %%mm1 \n\t" + "punpckhbw %%mm4, %%mm2 \n\t" + + "movq %%mm1, (%%"REG_D") \n\t" + "movq %%mm2, 8(%%"REG_D") \n\t" + + "movq 8(%%"REG_S"), %%mm1 \n\t" + "movq 8(%%"REG_S"), %%mm2 \n\t" + + "movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t" + "movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t" + "punpckhbw %%mm0, %%mm4 \n\t" + "punpckhbw %%mm0, %%mm6 \n\t" + "movq (%%"REG_a"), %%mm3 \n\t" |