diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-06-02 19:12:01 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-06-02 19:12:01 +0300 |
commit | 80be936a56199f7affddef546514604dcefcb763 (patch) | |
tree | ead37c819dad115446817aea7b78c53cee584735 | |
parent | ed1a1e28d89e9ab63e886adda18f0b8ccfec9356 (diff) | |
parent | 1cbf1ec46835300d1226068487b90476aff73ce8 (diff) | |
download | mpv-80be936a56199f7affddef546514604dcefcb763.tar.bz2 mpv-80be936a56199f7affddef546514604dcefcb763.tar.xz |
Merge svn changes up to r31303
-rw-r--r-- | libmpcodecs/vf_geq.c | 6 | ||||
-rw-r--r-- | libmpcodecs/vf_palette.c | 46 | ||||
-rw-r--r-- | libmpcodecs/vf_qp.c | 5 | ||||
-rw-r--r-- | libvo/geometry.c | 21 | ||||
-rw-r--r-- | libvo/vo_xv.c | 20 | ||||
-rw-r--r-- | spudec.c | 14 |
6 files changed, 68 insertions, 44 deletions
diff --git a/libmpcodecs/vf_geq.c b/libmpcodecs/vf_geq.c index 46f449b811..55645492e4 100644 --- a/libmpcodecs/vf_geq.c +++ b/libmpcodecs/vf_geq.c @@ -137,7 +137,7 @@ static void uninit(struct vf_instance *vf){ //===========================================================================// static int vf_open(vf_instance_t *vf, char *args){ char eq[3][2000] = { { 0 }, { 0 }, { 0 } }; - int plane; + int plane, res; vf->config=config; vf->put_image=put_image; @@ -178,9 +178,9 @@ static int vf_open(vf_instance_t *vf, char *args){ plane==0 ? lum : (plane==1 ? cb : cr), NULL }; - vf->priv->e[plane] = ff_parse_expr(eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL); + res = ff_parse_expr(&vf->priv->e[plane], eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL); - if (!vf->priv->e[plane]) { + if (res < 0) { mp_msg(MSGT_VFILTER, MSGL_ERR, "geq: error loading equation `%s'\n", eq[plane]); return 0; } diff --git a/libmpcodecs/vf_palette.c b/libmpcodecs/vf_palette.c index b62773d81a..17670f3eb0 100644 --- a/libmpcodecs/vf_palette.c +++ b/libmpcodecs/vf_palette.c @@ -27,8 +27,9 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" +#include "mpbswap.h" -#include "libswscale/rgb2rgb.h" +#include "libswscale/swscale.h" //===========================================================================// @@ -51,6 +52,23 @@ static const unsigned int rgb_list[]={ 0 }; +/** + * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette. + */ +static void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) +{ + long i; + for (i=0; i<num_pixels; i++) + ((uint16_t *)dst)[i] = ((const uint16_t *)palette)[src[i]]; +} + +static void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) +{ + long i; + for (i=0; i<num_pixels; i++) + ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]); +} + static unsigned int gray_pal[256]; static unsigned int find_best(struct vf_instance *vf, unsigned int fmt){ @@ -113,11 +131,6 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ // no stride conversion needed switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ case 15: - if (IMGFMT_IS_BGR(dmpi->imgfmt)) - palette8tobgr15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); - else - palette8torgb15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); - break; case 16: if (IMGFMT_IS_BGR(dmpi->imgfmt)) palette8tobgr16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); @@ -126,15 +139,15 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ break; case 24: if (IMGFMT_IS_BGR(dmpi->imgfmt)) - palette8topacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); else - palette8topacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); break; case 32: if (IMGFMT_IS_BGR(dmpi->imgfmt)) - palette8topacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); else - palette8topacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); break; } } else { @@ -144,11 +157,6 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ unsigned char* dst=dmpi->planes[0]+y*dmpi->stride[0]; switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ case 15: - if (IMGFMT_IS_BGR(dmpi->imgfmt)) - palette8tobgr15(src,dst,mpi->w,mpi->planes[1]); - else - palette8torgb15(src,dst,mpi->w,mpi->planes[1]); - break; case 16: if (IMGFMT_IS_BGR(dmpi->imgfmt)) palette8tobgr16(src,dst,mpi->w,mpi->planes[1]); @@ -157,15 +165,15 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ break; case 24: if (IMGFMT_IS_BGR(dmpi->imgfmt)) - palette8topacked24(src,dst,mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); else - palette8topacked24(src,dst,mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); break; case 32: if (IMGFMT_IS_BGR(dmpi->imgfmt)) - palette8topacked32(src,dst,mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); else - palette8topacked32(src,dst,mpi->w,mpi->planes[1]); + sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); break; } } diff --git a/libmpcodecs/vf_qp.c b/libmpcodecs/vf_qp.c index fa25a4508f..d3ae638f8c 100644 --- a/libmpcodecs/vf_qp.c +++ b/libmpcodecs/vf_qp.c @@ -67,10 +67,11 @@ static int config(struct vf_instance *vf, NULL }; double temp_val; + int res; - temp_val= ff_parse_and_eval_expr(vf->priv->eq, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); + res= ff_parse_and_eval_expr(&temp_val, vf->priv->eq, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); - if (isnan(temp_val)){ + if (res < 0){ mp_msg(MSGT_VFILTER, MSGL_ERR, "qp: Error evaluating \"%s\" \n", vf->priv->eq); return 0; } diff --git a/libvo/geometry.c b/libvo/geometry.c index 39ff209b7b..9d60ada29f 100644 --- a/libvo/geometry.c +++ b/libvo/geometry.c @@ -36,7 +36,7 @@ int geometry_xy_changed; int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) { if(vo_geometry != NULL) { - char xsign[2], ysign[2]; + char xsign[2], ysign[2], dummy[2]; int width, height, xoff, yoff, xper, yper; int i; int ok = 0; @@ -46,28 +46,31 @@ int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) strcpy(ysign, "+"); switch (i) { case 0: - ok = sscanf(vo_geometry, "%ix%i%1[+-]%i%1[+-]%i", &width, &height, xsign, &xoff, ysign, &yoff) == 6; + ok = sscanf(vo_geometry, "%ix%i%1[+-]%i%1[+-]%i%c", + &width, &height, xsign, &xoff, ysign, + &yoff, dummy) == 6; break; case 1: - ok = sscanf(vo_geometry, "%ix%i", &width, &height) == 2; + ok = sscanf(vo_geometry, "%ix%i%c", &width, &height, dummy) == 2; break; case 2: - ok = sscanf(vo_geometry, "%1[+-]%i%1[+-]%i", xsign, &xoff, ysign, &yoff) == 4; + ok = sscanf(vo_geometry, "%1[+-]%i%1[+-]%i%c", + xsign, &xoff, ysign, &yoff, dummy) == 4; break; case 3: - ok = sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) == 2; + ok = sscanf(vo_geometry, "%i%%:%i%1[%]%c", &xper, &yper, dummy, dummy) == 3; break; case 4: - ok = sscanf(vo_geometry, "%i:%i%%", &xoff, &yper) == 2; + ok = sscanf(vo_geometry, "%i:%i%1[%]%c", &xoff, &yper, dummy, dummy) == 3; break; case 5: - ok = sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) == 2; + ok = sscanf(vo_geometry, "%i%%:%i%c", &xper, &yoff, dummy) == 2; break; case 6: - ok = sscanf(vo_geometry, "%i:%i", &xoff, &yoff) == 2; + ok = sscanf(vo_geometry, "%i:%i%c", &xoff, &yoff, dummy) == 2; break; case 7: - ok = sscanf(vo_geometry, "%i%%", &xper) == 1; + ok = sscanf(vo_geometry, "%i%1[%]%c", &xper, dummy, dummy) == 2; break; } } diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 49ff146ba0..0dbc600847 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -119,14 +119,24 @@ struct xvctx { static void allocate_xvimage(struct vo *, int); +static void fixup_osd_position(struct vo *vo, int *x0, int *y0, int *w, int *h) +{ + struct xvctx *ctx = vo->priv; + *x0 += ctx->image_width * (vo->panscan_x >> 1) + / (vo->dwidth + vo->panscan_x); + *w = av_clip(*w, 0, ctx->image_width); + *h = av_clip(*h, 0, ctx->image_height); + *x0 = FFMIN(*x0, ctx->image_width - *w); + *y0 = FFMIN(*y0, ctx->image_height - *h); +} + static void draw_alpha_yv12(void *p, int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) { struct vo *vo = p; struct xvctx *ctx = vo->priv; - x0 += ctx->image_width * (vo->panscan_x >> 1) - / (vo->dwidth + vo->panscan_x); + fixup_osd_position(vo, &x0, &y0, &w, &h); vo_draw_alpha_yv12(w, h, src, srca, stride, ctx->xvimage[ctx->current_buf]->data + ctx->xvimage[ctx->current_buf]->offsets[0] + @@ -141,8 +151,7 @@ static void draw_alpha_yuy2(void *p, int x0, int y0, int w, int h, { struct vo *vo = p; struct xvctx *ctx = vo->priv; - x0 += ctx->image_width * (vo->panscan_x >> 1) - / (vo->dwidth + vo->panscan_x); + fixup_osd_position(vo, &x0, &y0, &w, &h); vo_draw_alpha_yuy2(w, h, src, srca, stride, ctx->xvimage[ctx->current_buf]->data + ctx->xvimage[ctx->current_buf]->offsets[0] + @@ -157,8 +166,7 @@ static void draw_alpha_uyvy(void *p, int x0, int y0, int w, int h, { struct vo *vo = p; struct xvctx *ctx = vo->priv; - x0 += ctx->image_width * (vo->panscan_x >> 1) - / (vo->dwidth + vo->panscan_x); + fixup_osd_position(vo, &x0, &y0, &w, &h); vo_draw_alpha_yuy2(w, h, src, srca, stride, ctx->xvimage[ctx->current_buf]->data + ctx->xvimage[ctx->current_buf]->offsets[0] + @@ -1202,11 +1202,15 @@ void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigne spudec_parse_extradata(this, extradata, extradata_len); /* XXX Although the video frame is some size, the SPU frame is always maximum size i.e. 720 wide and 576 or 480 high */ - this->orig_frame_width = 720; - if (this->orig_frame_height == 480 || this->orig_frame_height == 240) - this->orig_frame_height = 480; - else - this->orig_frame_height = 576; + // For HD files in MKV the VobSub resolution can be higher though, + // see largeres_vobsub.mkv + if (this->orig_frame_width <= 720 && this->orig_frame_height <= 576) { + this->orig_frame_width = 720; + if (this->orig_frame_height == 480 || this->orig_frame_height == 240) + this->orig_frame_height = 480; + else + this->orig_frame_height = 576; + } } else mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc"); |