summaryrefslogtreecommitdiff
path: root/src/dxr3
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2005-09-24 19:08:26 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2005-09-24 19:08:26 +0000
commit37cc903c609ca656a71852e5f50731f0b43bdda0 (patch)
tree50d8c59540de4b6ef20b24acd784903764b99522 /src/dxr3
parent097426600056a112752e92eb1c13f0d6900f3907 (diff)
downloadxine-lib-37cc903c609ca656a71852e5f50731f0b43bdda0.tar.gz
xine-lib-37cc903c609ca656a71852e5f50731f0b43bdda0.tar.bz2
- rename all clip_top, clip_left, clip_color... to hili_xxxx. that
"clip" thing has caused too much confusion already since these variables define a highlight area. - add overlay offset support to video_out.c/alphablend/vo drivers - use overlay offset to implement proper croping of frames when vo driver doesn't support it - add clipping checks to alphablend to avoid buffer overflow, buffer "underflow" and wrapping. - increase vo api number - note: dxr3 support is incomplete about overlay offset CVS patchset: 7739 CVS date: 2005/09/24 19:08:26
Diffstat (limited to 'src/dxr3')
-rw-r--r--src/dxr3/dxr3_spu_encoder.c72
-rw-r--r--src/dxr3/video_out_dxr3.c33
-rw-r--r--src/dxr3/video_out_dxr3.h6
3 files changed, 57 insertions, 54 deletions
diff --git a/src/dxr3/dxr3_spu_encoder.c b/src/dxr3/dxr3_spu_encoder.c
index b8ca223f6..75ad12495 100644
--- a/src/dxr3/dxr3_spu_encoder.c
+++ b/src/dxr3/dxr3_spu_encoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: dxr3_spu_encoder.c,v 1.8 2004/07/20 16:37:44 mroi Exp $
+ * $Id: dxr3_spu_encoder.c,v 1.9 2005/09/24 19:08:26 miguelfreitas Exp $
*/
#include <stdio.h>
@@ -115,11 +115,11 @@ static void convert_palette(spu_encoder_t *this)
}
this->overlay->rgb_clut = 1;
}
- if (!this->overlay->clip_rgb_clut) {
+ if (!this->overlay->hili_rgb_clut) {
for (i = 0; i < OVL_PALETTE_SIZE; i++) {
- y = (this->overlay->clip_color[i] >> 16) & 0xff;
- cr = (this->overlay->clip_color[i] >> 8) & 0xff;
- cb = (this->overlay->clip_color[i] ) & 0xff;
+ y = (this->overlay->hili_color[i] >> 16) & 0xff;
+ cr = (this->overlay->hili_color[i] >> 8) & 0xff;
+ cb = (this->overlay->hili_color[i] ) & 0xff;
r = 1.164 * y + 1.596 * (cr - 128);
g = 1.164 * y - 0.813 * (cr - 128) - 0.392 * (cb - 128);
b = 1.164 * y + 2.017 * (cb - 128);
@@ -129,9 +129,9 @@ static void convert_palette(spu_encoder_t *this)
if (r > 0xff) r = 0xff;
if (g > 0xff) g = 0xff;
if (b > 0xff) b = 0xff;
- this->overlay->clip_color[i] = (r << 16) | (g << 8) | b;
+ this->overlay->hili_color[i] = (r << 16) | (g << 8) | b;
}
- this->overlay->clip_rgb_clut = 1;
+ this->overlay->hili_rgb_clut = 1;
}
}
@@ -145,15 +145,15 @@ static void create_histogram(spu_encoder_t *this)
x = y = 0;
for (i = 0, rle = this->overlay->rle; i < this->overlay->num_rle; i++, rle++) {
len = rle->len;
- if (y >= this->overlay->clip_top && y < this->overlay->clip_bottom) {
- if (x < this->overlay->clip_left) {
- part = (this->overlay->clip_left - x < len) ? (this->overlay->clip_left - x) : len;
+ if (y >= this->overlay->hili_top && y < this->overlay->hili_bottom) {
+ if (x < this->overlay->hili_left) {
+ part = (this->overlay->hili_left - x < len) ? (this->overlay->hili_left - x) : len;
this->map[rle->color] += part;
len -= part;
x += part;
}
- if (x >= this->overlay->clip_left && x < this->overlay->clip_right) {
- part = (this->overlay->clip_right - x < len) ? (this->overlay->clip_right - x) : len;
+ if (x >= this->overlay->hili_left && x < this->overlay->hili_right) {
+ part = (this->overlay->hili_right - x < len) ? (this->overlay->hili_right - x) : len;
this->clip_map[rle->color] += part;
len -= part;
x += part;
@@ -174,7 +174,7 @@ static void create_histogram(spu_encoder_t *this)
for (i = 0; i < OVL_PALETTE_SIZE; i++)
if (this->clip_map[i])
lprintf("histogram: clip color #%d 0x%.8x appears %d times\n",
- i, this->overlay->clip_color[i], this->clip_map[i]);
+ i, this->overlay->hili_color[i], this->clip_map[i]);
#endif
}
@@ -221,32 +221,32 @@ static void generate_clut(spu_encoder_t *this)
max = 0;
for (i = 1; i < OVL_PALETTE_SIZE; i++)
if (this->clip_map[i] > this->clip_map[max]) max = i;
- this->clip_color[0] = this->overlay->clip_color[max];
- this->clip_trans[0] = this->overlay->clip_trans[max];
+ this->hili_color[0] = this->overlay->hili_color[max];
+ this->hili_trans[0] = this->overlay->hili_trans[max];
for (spu_color = 1; spu_color < 4; spu_color++) {
/* modify histogram and find next maximum -> next spu color */
max = 0;
for (i = 0; i < OVL_PALETTE_SIZE; i++) {
/* subtract a correction based on the distance to the last spu color */
- diff = ((this->overlay->clip_color[i] ) & 0xff) - ((this->clip_color[spu_color - 1] ) & 0xff);
+ diff = ((this->overlay->hili_color[i] ) & 0xff) - ((this->hili_color[spu_color - 1] ) & 0xff);
dist = diff * diff;
- diff = ((this->overlay->clip_color[i] >> 8) & 0xff) - ((this->clip_color[spu_color - 1] >> 8) & 0xff);
+ diff = ((this->overlay->hili_color[i] >> 8) & 0xff) - ((this->hili_color[spu_color - 1] >> 8) & 0xff);
dist += diff * diff;
- diff = ((this->overlay->clip_color[i] >> 16) & 0xff) - ((this->clip_color[spu_color - 1] >> 16) & 0xff);
+ diff = ((this->overlay->hili_color[i] >> 16) & 0xff) - ((this->hili_color[spu_color - 1] >> 16) & 0xff);
dist += diff * diff;
- diff = ((this->overlay->clip_trans[i] ) ) - ((this->clip_trans[spu_color - 1] ) );
+ diff = ((this->overlay->hili_trans[i] ) ) - ((this->hili_trans[spu_color - 1] ) );
dist += diff * diff;
this->clip_map[i] *= 1 - 1.0 / (dist / DIST_COEFF + 1.0);
if (this->clip_map[i] > this->clip_map[max]) max = i;
}
- this->clip_color[spu_color] = this->overlay->clip_color[max];
- this->clip_trans[spu_color] = this->overlay->clip_trans[max];
+ this->hili_color[spu_color] = this->overlay->hili_color[max];
+ this->hili_trans[spu_color] = this->overlay->hili_trans[max];
}
#ifdef LOG
for (spu_color = 0; spu_color < 4; spu_color++)
lprintf("spu clip color %d: 0x%.8x, trans: %d\n", spu_color,
- this->clip_color[spu_color], this->clip_trans[spu_color]);
+ this->hili_color[spu_color], this->hili_trans[spu_color]);
#endif
}
@@ -281,13 +281,13 @@ static void map_colors(spu_encoder_t *this)
min = 0;
min_dist = DBL_MAX;
for (spu_color = 0; spu_color < 4; spu_color++) {
- diff = ((this->overlay->clip_color[i] ) & 0xff) - ((this->clip_color[spu_color] ) & 0xff);
+ diff = ((this->overlay->hili_color[i] ) & 0xff) - ((this->hili_color[spu_color] ) & 0xff);
dist = diff * diff;
- diff = ((this->overlay->clip_color[i] >> 8) & 0xff) - ((this->clip_color[spu_color] >> 8) & 0xff);
+ diff = ((this->overlay->hili_color[i] >> 8) & 0xff) - ((this->hili_color[spu_color] >> 8) & 0xff);
dist += diff * diff;
- diff = ((this->overlay->clip_color[i] >> 16) & 0xff) - ((this->clip_color[spu_color] >> 16) & 0xff);
+ diff = ((this->overlay->hili_color[i] >> 16) & 0xff) - ((this->hili_color[spu_color] >> 16) & 0xff);
dist += diff * diff;
- diff = ((this->overlay->clip_trans[i] ) ) - ((this->clip_trans[spu_color] ) );
+ diff = ((this->overlay->hili_trans[i] ) ) - ((this->hili_trans[spu_color] ) );
dist += diff * diff;
if (dist < min_dist) {
min_dist = dist;
@@ -315,16 +315,16 @@ static void convert_clut(spu_encoder_t *this)
this->color[i] = 0x00008080;
for (i = 0; i < 4; i++) {
- r = (this->clip_color[i] >> 16) & 0xff;
- g = (this->clip_color[i] >> 8) & 0xff;
- b = (this->clip_color[i] ) & 0xff;
+ r = (this->hili_color[i] >> 16) & 0xff;
+ g = (this->hili_color[i] >> 8) & 0xff;
+ b = (this->hili_color[i] ) & 0xff;
y = 0.257 * r + 0.504 * g + 0.098 * b;
cr = 0.439 * r - 0.368 * g - 0.071 * b + 128;
cb = -0.148 * r - 0.291 * g + 0.439 * b + 128;
- this->clip_color[i] = (y << 16) | (cr << 8) | cb;
+ this->hili_color[i] = (y << 16) | (cr << 8) | cb;
}
for (i = 4; i < 16; i++)
- this->clip_color[i] = 0x00008080;
+ this->hili_color[i] = 0x00008080;
}
static void convert_overlay(spu_encoder_t *this)
@@ -350,15 +350,15 @@ static void convert_overlay(spu_encoder_t *this)
for (i = 0, rle = this->overlay->rle; i < this->overlay->num_rle; i++, rle++) {
len = rle->len;
if ((y & 1) == field) {
- if (y >= this->overlay->clip_top && y < this->overlay->clip_bottom) {
- if (x < this->overlay->clip_left) {
- part = (this->overlay->clip_left - x < len) ? (this->overlay->clip_left - x) : len;
+ if (y >= this->overlay->hili_top && y < this->overlay->hili_bottom) {
+ if (x < this->overlay->hili_left) {
+ part = (this->overlay->hili_left - x < len) ? (this->overlay->hili_left - x) : len;
write_rle(this, &offset, &higher_nibble, part, this->map[rle->color]);
len -= part;
x += part;
}
- if (x >= this->overlay->clip_left && x < this->overlay->clip_right) {
- part = (this->overlay->clip_right - x < len) ? (this->overlay->clip_right - x) : len;
+ if (x >= this->overlay->hili_left && x < this->overlay->hili_right) {
+ part = (this->overlay->hili_right - x < len) ? (this->overlay->hili_right - x) : len;
write_rle(this, &offset, &higher_nibble, part, this->clip_map[rle->color]);
len -= part;
x += part;
diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c
index fdf97240a..3d2cf960a 100644
--- a/src/dxr3/video_out_dxr3.c
+++ b/src/dxr3/video_out_dxr3.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out_dxr3.c,v 1.109 2005/04/10 09:41:13 tmattern Exp $
+ * $Id: video_out_dxr3.c,v 1.110 2005/09/24 19:08:26 miguelfreitas Exp $
*/
/* mpeg1 encoding video out plugin for the dxr3.
@@ -95,9 +95,9 @@ static vo_info_t vo_info_dxr3_aa = {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
#ifdef HAVE_X11
- { PLUGIN_VIDEO_OUT, 20, "dxr3", XINE_VERSION_CODE, &vo_info_dxr3_x11, &dxr3_x11_init_plugin },
+ { PLUGIN_VIDEO_OUT, 21, "dxr3", XINE_VERSION_CODE, &vo_info_dxr3_x11, &dxr3_x11_init_plugin },
#endif
- { PLUGIN_VIDEO_OUT, 20, "aadxr3", XINE_VERSION_CODE, &vo_info_dxr3_aa, &dxr3_aa_init_plugin },
+ { PLUGIN_VIDEO_OUT, 21, "aadxr3", XINE_VERSION_CODE, &vo_info_dxr3_aa, &dxr3_aa_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
@@ -804,6 +804,9 @@ static void dxr3_overlay_begin(vo_driver_t *this_gen, vo_frame_t *frame_gen, int
this->spu_enc->need_reencode = 1;
this->spu_enc->overlay = NULL;
+
+ this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x;
+ this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y;
}
static void dxr3_overlay_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen,
@@ -872,10 +875,10 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen)
}
/* copy clip palette */
- this->spu_enc->color[4] = this->spu_enc->clip_color[0];
- this->spu_enc->color[5] = this->spu_enc->clip_color[1];
- this->spu_enc->color[6] = this->spu_enc->clip_color[2];
- this->spu_enc->color[7] = this->spu_enc->clip_color[3];
+ this->spu_enc->color[4] = this->spu_enc->hili_color[0];
+ this->spu_enc->color[5] = this->spu_enc->hili_color[1];
+ this->spu_enc->color[6] = this->spu_enc->hili_color[2];
+ this->spu_enc->color[7] = this->spu_enc->hili_color[3];
/* set palette */
if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, this->spu_enc->color))
xprintf(this->class->xine, XINE_VERBOSITY_DEBUG,
@@ -892,14 +895,14 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen)
/* set clipping */
btn.color = 0x7654;
btn.contrast =
- ((this->spu_enc->clip_trans[3] << 12) & 0xf000) |
- ((this->spu_enc->clip_trans[2] << 8) & 0x0f00) |
- ((this->spu_enc->clip_trans[1] << 4) & 0x00f0) |
- ((this->spu_enc->clip_trans[0] ) & 0x000f);
- btn.left = this->spu_enc->overlay->x + this->spu_enc->overlay->clip_left;
- btn.right = this->spu_enc->overlay->x + this->spu_enc->overlay->clip_right - 1;
- btn.top = this->spu_enc->overlay->y + this->spu_enc->overlay->clip_top;
- btn.bottom = this->spu_enc->overlay->y + this->spu_enc->overlay->clip_bottom - 2;
+ ((this->spu_enc->hili_trans[3] << 12) & 0xf000) |
+ ((this->spu_enc->hili_trans[2] << 8) & 0x0f00) |
+ ((this->spu_enc->hili_trans[1] << 4) & 0x00f0) |
+ ((this->spu_enc->hili_trans[0] ) & 0x000f);
+ btn.left = this->spu_enc->overlay->x + this->spu_enc->overlay->hili_left;
+ btn.right = this->spu_enc->overlay->x + this->spu_enc->overlay->hili_right - 1;
+ btn.top = this->spu_enc->overlay->y + this->spu_enc->overlay->hili_top;
+ btn.bottom = this->spu_enc->overlay->y + this->spu_enc->overlay->hili_bottom - 2;
if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn))
xprintf(this->class->xine, XINE_VERBOSITY_DEBUG,
"dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno));
diff --git a/src/dxr3/video_out_dxr3.h b/src/dxr3/video_out_dxr3.h
index 2157e8f3a..00494445d 100644
--- a/src/dxr3/video_out_dxr3.h
+++ b/src/dxr3/video_out_dxr3.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out_dxr3.h,v 1.23 2004/11/24 16:11:03 mroi Exp $
+ * $Id: video_out_dxr3.h,v 1.24 2005/09/24 19:08:26 miguelfreitas Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -160,8 +160,8 @@ struct spu_encoder_s {
uint32_t color[16];
uint8_t trans[4];
int map[OVL_PALETTE_SIZE];
- uint32_t clip_color[16];
- uint8_t clip_trans[4];
+ uint32_t hili_color[16];
+ uint8_t hili_trans[4];
int clip_map[OVL_PALETTE_SIZE];
};