diff options
31 files changed, 811 insertions, 401 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]; }; diff --git a/src/libspudec/spu.c b/src/libspudec/spu.c index c8356bc78..6dfe956dd 100644 --- a/src/libspudec/spu.c +++ b/src/libspudec/spu.c @@ -36,7 +36,7 @@ * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: spu.c,v 1.80 2004/09/03 12:28:24 mroi Exp $ + * $Id: spu.c,v 1.81 2005/09/24 19:08:26 miguelfreitas Exp $ * */ @@ -478,8 +478,8 @@ void spudec_process (spudec_decoder_t *this, int stream_id) { /* Subtitle and not a menu button */ int i; for (i = 0;i < 4; i++) { - this->overlay.clip_color[i] = this->overlay.color[i]; - this->overlay.clip_trans[i] = this->overlay.trans[i]; + this->overlay.hili_color[i] = this->overlay.color[i]; + this->overlay.hili_trans[i] = this->overlay.trans[i]; } } pthread_mutex_unlock(&this->nav_pci_lock); @@ -667,10 +667,10 @@ static void spudec_do_commands(xine_t *xine, spudec_state_t *state, spudec_seq_t ovl->y = (buf[4] << 4) | (buf[5] >> 4); ovl->width = (((buf[2] & 0x0f) << 8) | buf[3]) - ovl->x + 1; ovl->height = (((buf[5] & 0x0f) << 8) | buf[6]) - ovl->y + 1; - ovl->clip_top = -1; - ovl->clip_bottom = -1; - ovl->clip_left = -1; - ovl->clip_right = -1; + ovl->hili_top = -1; + ovl->hili_bottom = -1; + ovl->hili_left = -1; + ovl->hili_right = -1; #ifdef LOG_DEBUG printf ("spu: \tx = %d y = %d width = %d height = %d\n", @@ -791,10 +791,10 @@ static void spudec_draw_picture (xine_t *xine, spudec_state_t *state, spudec_seq * ovl->width = state->o_right - state->o_left + 1; * ovl->height = state->o_bottom - state->o_top + 1; - * ovl->clip_top = 0; - * ovl->clip_bottom = ovl->height - 1; - * ovl->clip_left = 0; - * ovl->clip_right = ovl->width - 1; + * ovl->hili_top = 0; + * ovl->hili_bottom = ovl->height - 1; + * ovl->hili_left = 0; + * ovl->hili_right = ovl->width - 1; */ /* allocate for the worst case: @@ -959,11 +959,11 @@ static void spudec_print_overlay( vo_overlay_t *ovl ) { printf ("spu: \ttrans [%d %d %d %d]\n", ovl->trans[0], ovl->trans[1], ovl->trans[2], ovl->trans[3]); printf ("spu: \tclip top=%d bottom=%d left=%d right=%d\n", - ovl->clip_top, ovl->clip_bottom, ovl->clip_left, ovl->clip_right); + ovl->hili_top, ovl->hili_bottom, ovl->hili_left, ovl->hili_right); printf ("spu: \tclip_clut [%x %x %x %x]\n", - ovl->clip_color[0], ovl->clip_color[1], ovl->clip_color[2], ovl->clip_color[3]); - printf ("spu: \tclip_trans [%d %d %d %d]\n", - ovl->clip_trans[0], ovl->clip_trans[1], ovl->clip_trans[2], ovl->clip_trans[3]); + ovl->hili_color[0], ovl->hili_color[1], ovl->hili_color[2], ovl->hili_color[3]); + printf ("spu: \thili_trans [%d %d %d %d]\n", + ovl->hili_trans[0], ovl->hili_trans[1], ovl->hili_trans[2], ovl->hili_trans[3]); return; } #endif @@ -996,17 +996,17 @@ int spudec_copy_nav_to_overlay(xine_t *xine, pci_t* nav_pci, uint32_t* clut, /* button areas in the nav packet are in screen coordinates, * overlay clipping areas are in overlay coordinates; * therefore we must subtract the display coordinates of the underlying overlay */ - overlay->clip_left = (button_ptr->x_start > base->x) ? (button_ptr->x_start - base->x) : 0; - overlay->clip_top = (button_ptr->y_start > base->y) ? (button_ptr->y_start - base->y) : 0; - overlay->clip_right = (button_ptr->x_end > base->x) ? (button_ptr->x_end - base->x) : 0; - overlay->clip_bottom = (button_ptr->y_end > base->y) ? (button_ptr->y_end - base->y) : 0; + overlay->hili_left = (button_ptr->x_start > base->x) ? (button_ptr->x_start - base->x) : 0; + overlay->hili_top = (button_ptr->y_start > base->y) ? (button_ptr->y_start - base->y) : 0; + overlay->hili_right = (button_ptr->x_end > base->x) ? (button_ptr->x_end - base->x) : 0; + overlay->hili_bottom = (button_ptr->y_end > base->y) ? (button_ptr->y_end - base->y) : 0; if(button_ptr->btn_coln != 0) { #ifdef LOG_BUTTON fprintf(stderr, "libspudec: normal button clut\n"); #endif for (i = 0;i < 4; i++) { - overlay->clip_color[i] = clut[0xf & (nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> (16 + 4*i))]; - overlay->clip_trans[i] = 0xf & (nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> (4*i)); + overlay->hili_color[i] = clut[0xf & (nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> (16 + 4*i))]; + overlay->hili_trans[i] = 0xf & (nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> (4*i)); } } else { #ifdef LOG_BUTTON @@ -1014,10 +1014,10 @@ int spudec_copy_nav_to_overlay(xine_t *xine, pci_t* nav_pci, uint32_t* clut, #endif for (i = 0;i < 4; i++) { #ifdef LOG_BUTTON - printf("libspudec:btn_coln = 0, clip_color = color\n"); + printf("libspudec:btn_coln = 0, hili_color = color\n"); #endif - overlay->clip_color[i] = overlay->color[i]; - overlay->clip_trans[i] = overlay->trans[i]; + overlay->hili_color[i] = overlay->color[i]; + overlay->hili_trans[i] = overlay->trans[i]; } } diff --git a/src/video_out/alphablend.c b/src/video_out/alphablend.c index 2f840a31e..b0942b066 100644 --- a/src/video_out/alphablend.c +++ b/src/video_out/alphablend.c @@ -19,8 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * The author may be reached as <dent@linuxvideo.org> - * *------------------------------------------------------------ * */ @@ -110,6 +108,15 @@ rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w) return rle; } +/* + * heck, this function is overly complicated and currently buggy. + * if James would like to revive it (implementing proper clipping - + * not to confuse with button highlight) i would have no objections, + * but for now i will be using an alternate version based on rgb24. [MF] + * + * obs: this function has about 420 lines. other blend_rgb16 has 165. + */ +#if JAMES_BLEND_RGB16_FUNCTION void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, int img_width, int img_height, int dst_width, int dst_height, @@ -123,9 +130,12 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, rle_elem_t *rle = img_overl->rle; rle_elem_t *rle_start = img_overl->rle; rle_elem_t *rle_limit = rle + img_overl->num_rle; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; int x, y, x1_scaled, x2_scaled; int dy, dy_step, x_scale; /* scaled 2**SCALE_SHIFT */ - int clip_right; + int clip_right, clip_left, clip_top; + int hili_right, hili_left; uint16_t *img_pix; int rlelen; int rle_this_bite; @@ -167,8 +177,8 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, printf("blend_rgb16: dy_step=%i, x_scale=%i\n", dy_step, x_scale); #endif if (img_width & 1) img_width++; - img_offset = ( ( (img_overl->y * img_height) / dst_height) * img_width) - + ( (img_overl->x * img_width) / dst_width); + img_offset = ( ( (y_off * img_height) / dst_height) * img_width) + + ( (x_off * img_width) / dst_width); #ifdef LOG_BLEND_RGB16 printf("blend_rgb16: x=%i, y=%i, w=%i, h=%i, img_offset=%lf\n", img_overl->x, img_overl->y, img_overl->width, @@ -177,19 +187,39 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, #endif img_pix = (uint16_t *) img + (int)img_offset; /* - + (img_overl->y * img_height / dst_height) * img_width - + (img_overl->x * img_width / dst_width); + + (y_off * img_height / dst_height) * img_width + + (x_off * img_width / dst_width); */ - /* avoid wraping overlay if drawing to small image */ - if( (img_overl->x + img_overl->clip_right) < dst_width ) - clip_right = img_overl->clip_right; + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; else - clip_right = dst_width - img_overl->x; - - /* avoid buffer overflow */ - if( (src_height + img_overl->y) >= dst_height ) - src_height = dst_height - img_overl->y; + clip_right = dst_width - x_off; + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + + if( (src_height + y_off) > dst_height ) + src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; + else + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; rlelen = rle_remainder = rle_this_bite = 0; rle_remainder = rlelen = rle->len; @@ -206,32 +236,32 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, clr = clr_next; switch (zone_state) { case 0: /* Starting */ - /* FIXME: Get libspudec to set clip_top to -1 if no button */ - if (img_overl->clip_top < 0) { + /* FIXME: Get libspudec to set hili_top to -1 if no button */ + if (img_overl->hili_top < 0) { #ifdef LOG_BLEND_RGB16 - printf("blend_rgb16: No button clip area\n"); + printf("blend_rgb16: No button highlight area\n"); #endif zone_state = 7; break; } #ifdef LOG_BLEND_RGB16 - printf("blend_rgb16: Button clip area found. (%d,%d) .. (%d,%d)\n", - img_overl->clip_left, - img_overl->clip_top, - img_overl->clip_right, - img_overl->clip_bottom); + printf("blend_rgb16: Button highlight area found. (%d,%d) .. (%d,%d)\n", + img_overl->hili_left, + img_overl->hili_top, + img_overl->hili_right, + img_overl->hili_bottom); #endif - if (y < img_overl->clip_top) { + if (y < img_overl->hili_top) { zone_state = 1; break; - } else if (y >= img_overl->clip_bottom) { + } else if (y >= img_overl->hili_bottom) { zone_state = 5; break; - } else if (x < img_overl->clip_left) { + } else if (x < hili_left) { zone_state = 2; break; - } else if (x >= img_overl->clip_right) { + } else if (x >= hili_right) { zone_state = 4; break; } else { @@ -239,7 +269,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, break; } break; - case 1: /* Above clip area */ + case 1: /* Above highlight area */ clut = (clut_t*) img_overl->color; trans = img_overl->trans; o = trans[clr]; @@ -277,15 +307,15 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, if (rle >= rle_limit) { zone_state = 6; } - if (y >= img_overl->clip_top) { + if (y >= img_overl->hili_top) { zone_state = 2; #ifdef LOG_BLEND_RGB16 - printf("blend_rgb16: Button clip top reached. y=%i, top=%i\n", - y, img_overl->clip_top); + printf("blend_rgb16: Button highlight top reached. y=%i, top=%i\n", + y, img_overl->hili_top); #endif - if (x >= img_overl->clip_left) { + if (x >= hili_left) { zone_state = 3; - if (x >= img_overl->clip_right) { + if (x >= hili_right) { zone_state = 4; } } @@ -295,13 +325,13 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, clut = (clut_t*) img_overl->color; trans = img_overl->trans; o = trans[clr]; - if (x + rle_remainder <= img_overl->clip_left) { + if (x + rle_remainder <= hili_left) { rle_this_bite = rle_remainder; rle_remainder = rlelen = rle->len; clr_next = rle->color; rle++; } else { - rle_this_bite = img_overl->clip_left - x; + rle_this_bite = hili_left - x; rle_remainder -= rle_this_bite; zone_state = 3; } @@ -327,7 +357,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } else { rle = rle_start; /* y-scaling, reuse the last rle encoded line */ } - if (y >= img_overl->clip_bottom) { + if (y >= img_overl->hili_bottom) { zone_state = 5; break; } @@ -337,16 +367,16 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } break; case 3: /* In button */ - clut = (clut_t*) img_overl->clip_color; - trans = img_overl->clip_trans; + clut = (clut_t*) img_overl->hili_color; + trans = img_overl->hili_trans; o = trans[clr]; - if (x + rle_remainder <= img_overl->clip_right) { + if (x + rle_remainder <= hili_right) { rle_this_bite = rle_remainder; rle_remainder = rlelen = rle->len; clr_next = rle->color; rle++; } else { - rle_this_bite = img_overl->clip_right - x; + rle_this_bite = hili_right - x; rle_remainder -= rle_this_bite; zone_state = 4; } @@ -372,7 +402,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } else { rle = rle_start; /* y-scaling, reuse the last rle encoded line */ } - if (y >= img_overl->clip_bottom) { + if (y >= img_overl->hili_bottom) { zone_state = 5; break; } @@ -417,7 +447,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } else { rle = rle_start; /* y-scaling, reuse the last rle encoded line */ } - if (y >= img_overl->clip_bottom) { + if (y >= img_overl->hili_bottom) { zone_state = 5; break; } @@ -512,8 +542,9 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, #endif } +#endif -void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, +void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, int img_width, int img_height, int dst_width, int dst_height, alphablend_t *extra_data) @@ -522,29 +553,219 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, int src_height = img_overl->height; rle_elem_t *rle = img_overl->rle; rle_elem_t *rle_limit = rle + img_overl->num_rle; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; int x, y, x1_scaled, x2_scaled; int dy, dy_step, x_scale; /* scaled 2**SCALE_SHIFT */ - int clip_right; + int hili_right, hili_left; + int clip_right, clip_left, clip_top; uint8_t *img_pix; dy_step = INT_TO_SCALED(dst_height) / img_height; x_scale = INT_TO_SCALED(img_width) / dst_width; - img_pix = img + 3 * ( (img_overl->y * img_height / dst_height) * img_width - + (img_overl->x * img_width / dst_width)); + img_pix = img + 2 * ( (y_off * img_height / dst_height) * img_width + + (x_off * img_width / dst_width)); - /* avoid wraping overlay if drawing to small image */ - if( (img_overl->x + img_overl->clip_right) <= dst_width ) - clip_right = img_overl->clip_right; + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; + else + clip_right = dst_width - x_off; + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + + if( (src_height + y_off) > dst_height ) + src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; else - clip_right = dst_width - img_overl->x; + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; + + for (dy = y = 0; y < src_height && rle < rle_limit; ) { + int mask = !(y < img_overl->hili_top || y >= img_overl->hili_bottom); + rle_elem_t *rle_start = rle; + + int rlelen = 0; + uint8_t clr = 0; + + for (x = x1_scaled = 0; x < src_width;) { + int rle_bite; + clut_t *colors; + uint8_t *trans; + uint16_t o; + int clipped = (y < clip_top); + + /* take next element from rle list everytime an element is finished */ + if (rlelen <= 0) { + if (rle >= rle_limit) + break; + + rlelen = rle->len; + clr = rle->color; + rle++; + } + + if (!mask) { + /* above or below highlight area */ + + rle_bite = rlelen; + /* choose palette for surrounding area */ + colors = (clut_t*)img_overl->color; + trans = img_overl->trans; + } else { + /* treat cases where highlight border is inside rle->len pixels */ + if ( x < hili_left ) { + /* starts left */ + if( x + rlelen > hili_left ) { + /* ends not left */ + + /* choose the largest "bite" up to palette change */ + rle_bite = hili_left - x; + /* choose palette for surrounding area */ + colors = (clut_t*)img_overl->color; + trans = img_overl->trans; + } else { + /* ends left */ + + rle_bite = rlelen; + /* choose palette for surrounding area */ + colors = (clut_t*)img_overl->color; + trans = img_overl->trans; + } + if( x < clip_left ) + clipped = 1; + } else if( x + rlelen > hili_right ) { + /* ends right */ + if( x < hili_right ) { + /* starts not right */ + + /* choose the largest "bite" up to palette change */ + rle_bite = hili_right - x; + /* we're in the center area so choose highlight palette */ + colors = (clut_t*)img_overl->hili_color; + trans = img_overl->hili_trans; + } else { + /* starts right */ + + rle_bite = rlelen; + /* choose palette for surrounding area */ + colors = (clut_t*)img_overl->color; + trans = img_overl->trans; + + if( x + rle_bite >= clip_right ) + clipped = 1; + } + } else { + /* starts not left and ends not right */ + + rle_bite = rlelen; + /* we're in the center area so choose highlight palette */ + colors = (clut_t*)img_overl->hili_color; + trans = img_overl->hili_trans; + } + } + + x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); + + o = trans[clr]; + if (o && !clipped) { + mem_blend16((uint16_t *) (img_pix + x1_scaled*2), + *((uint16_t *)&colors[clr]), + o, x2_scaled-x1_scaled); + } + + x1_scaled = x2_scaled; + x += rle_bite; + rlelen -= rle_bite; + } + + img_pix += img_width * 2; + dy += dy_step; + if (dy >= INT_TO_SCALED(1)) { + dy -= INT_TO_SCALED(1); + ++y; + while (dy >= INT_TO_SCALED(1)) { + rle = rle_img_advance_line(rle, rle_limit, src_width); + dy -= INT_TO_SCALED(1); + ++y; + } + } else { + rle = rle_start; /* y-scaling, reuse the last rle encoded line */ + } + } +} + +void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, + int img_width, int img_height, + int dst_width, int dst_height, + alphablend_t *extra_data) +{ + int src_width = img_overl->width; + int src_height = img_overl->height; + rle_elem_t *rle = img_overl->rle; + rle_elem_t *rle_limit = rle + img_overl->num_rle; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; + int x, y, x1_scaled, x2_scaled; + int dy, dy_step, x_scale; /* scaled 2**SCALE_SHIFT */ + int hili_right, hili_left; + int clip_right, clip_left, clip_top; + uint8_t *img_pix; - /* avoid buffer overflow */ - if( (src_height + img_overl->y) > dst_height ) - src_height = dst_height - img_overl->y; + dy_step = INT_TO_SCALED(dst_height) / img_height; + x_scale = INT_TO_SCALED(img_width) / dst_width; + + img_pix = img + 3 * ( (y_off * img_height / dst_height) * img_width + + (x_off * img_width / dst_width)); + + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; + else + clip_right = dst_width - x_off; + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + + if( (src_height + y_off) > dst_height ) + src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; + else + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; for (dy = y = 0; y < src_height && rle < rle_limit; ) { - int mask = !(y < img_overl->clip_top || y >= img_overl->clip_bottom); + int mask = !(y < img_overl->hili_top || y >= img_overl->hili_bottom); rle_elem_t *rle_start = rle; int rlelen = 0; @@ -555,6 +776,7 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, clut_t *colors; uint8_t *trans; uint16_t o; + int clipped = (y < clip_top); /* take next element from rle list everytime an element is finished */ if (rlelen <= 0) { @@ -567,21 +789,21 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, } if (!mask) { - /* above or below clipping area */ + /* above or below highlight area */ rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; } else { - /* treat cases where clipping border is inside rle->len pixels */ - if ( x < img_overl->clip_left ) { + /* treat cases where highlight border is inside rle->len pixels */ + if ( x < hili_left ) { /* starts left */ - if( x + rlelen > img_overl->clip_left ) { + if( x + rlelen > hili_left ) { /* ends not left */ /* choose the largest "bite" up to palette change */ - rle_bite = img_overl->clip_left - x; + rle_bite = hili_left - x; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; @@ -593,16 +815,18 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, colors = (clut_t*)img_overl->color; trans = img_overl->trans; } - } else if( x + rlelen > clip_right ) { + if( x < clip_left ) + clipped = 1; + } else if( x + rlelen > hili_right ) { /* ends right */ - if( x < clip_right ) { + if( x < hili_right ) { /* starts not right */ /* choose the largest "bite" up to palette change */ - rle_bite = clip_right - x; - /* we're in the center area so choose clip palette */ - colors = (clut_t*)img_overl->clip_color; - trans = img_overl->clip_trans; + rle_bite = hili_right - x; + /* we're in the center area so choose highlight palette */ + colors = (clut_t*)img_overl->hili_color; + trans = img_overl->hili_trans; } else { /* starts right */ @@ -610,21 +834,24 @@ void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; + + if( x + rle_bite >= clip_right ) + clipped = 1; } } else { /* starts not left and ends not right */ rle_bite = rlelen; - /* we're in the center area so choose clip palette */ - colors = (clut_t*)img_overl->clip_color; - trans = img_overl->clip_trans; + /* we're in the center area so choose highlight palette */ + colors = (clut_t*)img_overl->hili_color; + trans = img_overl->hili_trans; } } x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); o = trans[clr]; - if (o) { + if (o && !clipped) { mem_blend24(img_pix + x1_scaled*3, colors[clr].cb, colors[clr].cr, colors[clr].y, o, x2_scaled-x1_scaled); @@ -660,29 +887,52 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, int src_height = img_overl->height; rle_elem_t *rle = img_overl->rle; rle_elem_t *rle_limit = rle + img_overl->num_rle; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; int x, y, x1_scaled, x2_scaled; int dy, dy_step, x_scale; /* scaled 2**SCALE_SHIFT */ - int clip_right; + int hili_right, hili_left; + int clip_right, clip_left, clip_top; uint8_t *img_pix; dy_step = INT_TO_SCALED(dst_height) / img_height; x_scale = INT_TO_SCALED(img_width) / dst_width; - img_pix = img + 4 * ( (img_overl->y * img_height / dst_height) * img_width - + (img_overl->x * img_width / dst_width)); + img_pix = img + 4 * ( (y_off * img_height / dst_height) * img_width + + (x_off * img_width / dst_width)); - /* avoid wraping overlay if drawing to small image */ - if( (img_overl->x + img_overl->clip_right) <= dst_width ) - clip_right = img_overl->clip_right; + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; else - clip_right = dst_width - img_overl->x; - - /* avoid buffer overflow */ - if( (src_height + img_overl->y) > dst_height ) - src_height = dst_height - img_overl->y; - + clip_right = dst_width - x_off; + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + + if( (src_height + y_off) > dst_height ) + src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; + else + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; + for (y = dy = 0; y < src_height && rle < rle_limit; ) { - int mask = !(y < img_overl->clip_top || y >= img_overl->clip_bottom); + int mask = !(y < img_overl->hili_top || y >= img_overl->hili_bottom); rle_elem_t *rle_start = rle; int rlelen = 0; @@ -693,6 +943,7 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, clut_t *colors; uint8_t *trans; uint16_t o; + int clipped = (y < clip_top); /* take next element from rle list everytime an element is finished */ if (rlelen <= 0) { @@ -705,21 +956,21 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, } if (!mask) { - /* above or below clipping area */ + /* above or below highlight area */ rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; } else { - /* treat cases where clipping border is inside rle->len pixels */ - if ( x < img_overl->clip_left ) { + /* treat cases where highlight border is inside rle->len pixels */ + if ( x < hili_left ) { /* starts left */ - if( x + rlelen > img_overl->clip_left ) { + if( x + rlelen > hili_left ) { /* ends not left */ /* choose the largest "bite" up to palette change */ - rle_bite = img_overl->clip_left - x; + rle_bite = hili_left - x; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; @@ -731,16 +982,18 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, colors = (clut_t*)img_overl->color; trans = img_overl->trans; } - } else if( x + rlelen > clip_right ) { + if( x < clip_left ) + clipped = 1; + } else if( x + rlelen > hili_right ) { /* ends right */ - if( x < clip_right ) { + if( x < hili_right ) { /* starts not right */ /* choose the largest "bite" up to palette change */ - rle_bite = clip_right - x; - /* we're in the center area so choose clip palette */ - colors = (clut_t*)img_overl->clip_color; - trans = img_overl->clip_trans; + rle_bite = hili_right - x; + /* we're in the center area so choose highlight palette */ + colors = (clut_t*)img_overl->hili_color; + trans = img_overl->hili_trans; } else { /* starts right */ @@ -748,21 +1001,24 @@ void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; + + if( x + rle_bite >= clip_right ) + clipped = 1; } } else { /* starts not left and ends not right */ rle_bite = rlelen; - /* we're in the center area so choose clip palette */ - colors = (clut_t*)img_overl->clip_color; - trans = img_overl->clip_trans; + /* we're in the center area so choose highlight palette */ + colors = (clut_t*)img_overl->hili_color; + trans = img_overl->hili_trans; } } x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); o = trans[clr]; - if (o) { + if (o && !clipped) { mem_blend32(img_pix + x1_scaled*4, (uint8_t *)&colors[clr], o, x2_scaled-x1_scaled); } @@ -906,8 +1162,8 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, int src_height = img_overl->height; rle_elem_t *rle = img_overl->rle; rle_elem_t *rle_limit = rle + img_overl->num_rle; - int x_off = img_overl->x; - int y_off = img_overl->y; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; int x_odd = x_off & 1; int y_odd = y_off & 1; int ymask,xmask; @@ -915,7 +1171,8 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, int rle_remainder; int rlelen; int x, y; - int clip_right; + int hili_right, hili_left; + int clip_right, clip_left, clip_top; uint8_t clr=0; int any_line_buffered = 0; @@ -929,18 +1186,38 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, #ifdef LOG_BLEND_YUV printf("overlay_blend started x=%d, y=%d, w=%d h=%d\n",img_overl->x,img_overl->y,img_overl->width,img_overl->height); #endif - my_clut = (clut_t*) img_overl->clip_color; - my_trans = img_overl->clip_trans; + my_clut = (clut_t*) img_overl->hili_color; + my_trans = img_overl->hili_trans; - /* avoid wraping overlay if drawing to small image */ - if( (x_off + img_overl->clip_right) <= dst_width ) - clip_right = img_overl->clip_right; + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; else clip_right = dst_width - x_off; - - /* avoid buffer overflow */ + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; + else + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; if (src_height <= 0) return; @@ -967,7 +1244,7 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, break; } - ymask = ((y < img_overl->clip_top) || (y >= img_overl->clip_bottom)); + ymask = ((y < img_overl->hili_top) || (y >= img_overl->hili_bottom)); xmask = 0; #ifdef LOG_BLEND_YUV printf("X started ymask=%d y=%d src_height=%d\n",ymask, y, src_height); @@ -975,6 +1252,7 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, for (x = 0; x < src_width;) { uint16_t o; + int clipped = (y < clip_top); if (rle >= rle_limit) { #ifdef LOG_BLEND_YUV @@ -1009,14 +1287,14 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, #endif if (ymask == 0) { - if (x < img_overl->clip_left) { - /* Starts outside clip area */ - if ((x + rle_remainder) > img_overl->clip_left ) { + if (x < hili_left) { + /* Starts outside highlight area */ + if ((x + rle_remainder) > hili_left ) { #ifdef LOG_BLEND_YUV - printf("Outside clip left %d, ending inside\n", img_overl->clip_left); + printf("Outside highlight left %d, ending inside\n", hili_left); #endif /* Cutting needed, starts outside, ends inside */ - rle_this_bite = (img_overl->clip_left - x); + rle_this_bite = (hili_left - x); rle_remainder -= rle_this_bite; rlelen -= rle_this_bite; my_clut = (clut_t*) img_overl->color; @@ -1024,7 +1302,7 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, xmask = 0; } else { #ifdef LOG_BLEND_YUV - printf("Outside clip left %d, ending outside\n", img_overl->clip_left); + printf("Outside highlight left %d, ending outside\n", hili_left); #endif /* no cutting needed, starts outside, ends outside */ rle_this_bite = rle_remainder; @@ -1034,36 +1312,38 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, my_trans = img_overl->trans; xmask = 0; } - } else if (x < clip_right) { - /* Starts inside clip area */ - if ((x + rle_remainder) > clip_right ) { + if( x < clip_left ) + clipped = 1; + } else if (x < hili_right) { + /* Starts inside highlight area */ + if ((x + rle_remainder) > hili_right ) { #ifdef LOG_BLEND_YUV - printf("Inside clip right %d, ending outside\n", clip_right); + printf("Inside highlight right %d, ending outside\n", hili_right); #endif /* Cutting needed, starts inside, ends outside */ - rle_this_bite = (clip_right - x); + rle_this_bite = (hili_right - x); rle_remainder -= rle_this_bite; rlelen -= rle_this_bite; - my_clut = (clut_t*) img_overl->clip_color; - my_trans = img_overl->clip_trans; + my_clut = (clut_t*) img_overl->hili_color; + my_trans = img_overl->hili_trans; xmask++; } else { #ifdef LOG_BLEND_YUV - printf("Inside clip right %d, ending inside\n", clip_right); + printf("Inside highlight right %d, ending inside\n", hili_right); #endif /* no cutting needed, starts inside, ends inside */ rle_this_bite = rle_remainder; rle_remainder = 0; rlelen -= rle_this_bite; - my_clut = (clut_t*) img_overl->clip_color; - my_trans = img_overl->clip_trans; + my_clut = (clut_t*) img_overl->hili_color; + my_trans = img_overl->hili_trans; xmask++; } - } else if (x >= clip_right) { - /* Starts outside clip area, ends outside clip area */ + } else if (x >= hili_right) { + /* Starts outside highlight area, ends outside highlight area */ if ((x + rle_remainder ) > src_width ) { #ifdef LOG_BLEND_YUV - printf("Outside clip right %d, ending eol\n", clip_right); + printf("Outside highlight right %d, ending eol\n", hili_right); #endif /* Cutting needed, starts outside, ends at right edge */ /* It should never reach here due to the earlier test of src_width */ @@ -1076,7 +1356,7 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, } else { /* no cutting needed, starts outside, ends outside */ #ifdef LOG_BLEND_YUV - printf("Outside clip right %d, ending outside\n", clip_right); + printf("Outside highlight right %d, ending outside\n", hili_right); #endif rle_this_bite = rle_remainder; rle_remainder = 0; @@ -1085,9 +1365,11 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, my_trans = img_overl->trans; xmask = 0; } + if( x + rle_this_bite >= clip_right ) + clipped = 1; } } else { - /* Outside clip are due to y */ + /* Outside highlight are due to y */ /* no cutting needed, starts outside, ends outside */ rle_this_bite = rle_remainder; rle_remainder = 0; @@ -1117,7 +1399,7 @@ void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, any_line_buffered |= ((y + y_odd) & 1) ? 2 : 1; } - if (o) { + if (o && !clipped) { if(o >= 15) { memset(dst_y + x, my_clut[clr].y, rle_this_bite); if (!enable_exact_blending) { @@ -1288,8 +1570,8 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, int src_height = img_overl->height; rle_elem_t *rle = img_overl->rle; rle_elem_t *rle_limit = rle + img_overl->num_rle; - int x_off = img_overl->x; - int y_off = img_overl->y; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; int x_odd = x_off & 1; int ymask; int rle_this_bite; @@ -1297,7 +1579,8 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, int rlelen; int x, y; int l = 0; - int clip_right; + int hili_right, hili_left; + int clip_right, clip_left, clip_top; union { uint32_t value; @@ -1315,18 +1598,38 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, uint8_t *dst_y = dst_img + dst_pitch * y_off + 2 * x_off; uint8_t *dst; - my_clut = (clut_t*) img_overl->clip_color; - my_trans = img_overl->clip_trans; + my_clut = (clut_t*) img_overl->hili_color; + my_trans = img_overl->hili_trans; - /* avoid wraping overlay if drawing to small image */ - if( (x_off + img_overl->clip_right) <= dst_width ) - clip_right = img_overl->clip_right; + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; else clip_right = dst_width - x_off; - - /* avoid buffer overflow */ + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; + else + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; if (src_height <= 0) return; @@ -1348,11 +1651,12 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, if (rle >= rle_limit) break; - ymask = ((y < img_overl->clip_top) || (y >= img_overl->clip_bottom)); + ymask = ((y < img_overl->hili_top) || (y >= img_overl->hili_bottom)); dst = dst_y; for (x = 0; x < src_width;) { uint16_t o; + int clipped = (y < clip_top); if (rle >= rle_limit) break; @@ -1379,21 +1683,21 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, #endif if (ymask == 0) { - if (x < img_overl->clip_left) { - /* Starts outside clip area */ - if ((x + rle_remainder) > img_overl->clip_left ) { + if (x < hili_left) { + /* Starts outside highlight area */ + if ((x + rle_remainder) > hili_left ) { #ifdef LOG_BLEND_YUV - printf("Outside clip left %d, ending inside\n", img_overl->clip_left); + printf("Outside highlight left %d, ending inside\n", hili_left); #endif /* Cutting needed, starts outside, ends inside */ - rle_this_bite = (img_overl->clip_left - x); + rle_this_bite = (hili_left - x); rle_remainder -= rle_this_bite; rlelen -= rle_this_bite; my_clut = (clut_t*) img_overl->color; my_trans = img_overl->trans; } else { #ifdef LOG_BLEND_YUV - printf("Outside clip left %d, ending outside\n", img_overl->clip_left); + printf("Outside highlight left %d, ending outside\n", hili_left); #endif /* no cutting needed, starts outside, ends outside */ rle_this_bite = rle_remainder; @@ -1402,34 +1706,36 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, my_clut = (clut_t*) img_overl->color; my_trans = img_overl->trans; } - } else if (x < clip_right) { - /* Starts inside clip area */ - if ((x + rle_remainder) > clip_right ) { + if( x < clip_left ) + clipped = 1; + } else if (x < hili_right) { + /* Starts inside highlight area */ + if ((x + rle_remainder) > hili_right ) { #ifdef LOG_BLEND_YUV - printf("Inside clip right %d, ending outside\n", clip_right); + printf("Inside highlight right %d, ending outside\n", hili_right); #endif /* Cutting needed, starts inside, ends outside */ - rle_this_bite = (clip_right - x); + rle_this_bite = (hili_right - x); rle_remainder -= rle_this_bite; rlelen -= rle_this_bite; - my_clut = (clut_t*) img_overl->clip_color; - my_trans = img_overl->clip_trans; + my_clut = (clut_t*) img_overl->hili_color; + my_trans = img_overl->hili_trans; } else { #ifdef LOG_BLEND_YUV - printf("Inside clip right %d, ending inside\n", clip_right); + printf("Inside highlight right %d, ending inside\n", hili_right); #endif /* no cutting needed, starts inside, ends inside */ rle_this_bite = rle_remainder; rle_remainder = 0; rlelen -= rle_this_bite; - my_clut = (clut_t*) img_overl->clip_color; - my_trans = img_overl->clip_trans; + my_clut = (clut_t*) img_overl->hili_color; + my_trans = img_overl->hili_trans; } - } else if (x >= clip_right) { - /* Starts outside clip area, ends outsite clip area */ + } else if (x >= hili_right) { + /* Starts outside highlight area, ends outsite highlight area */ if ((x + rle_remainder ) > src_width ) { #ifdef LOG_BLEND_YUV - printf("Outside clip right %d, ending eol\n", clip_right); + printf("Outside highlight right %d, ending eol\n", hili_right); #endif /* Cutting needed, starts outside, ends at right edge */ /* It should never reach here due to the earlier test of src_width */ @@ -1441,7 +1747,7 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, } else { /* no cutting needed, starts outside, ends outside */ #ifdef LOG_BLEND_YUV - printf("Outside clip right %d, ending outside\n", clip_right); + printf("Outside highlight right %d, ending outside\n", hili_right); #endif rle_this_bite = rle_remainder; rle_remainder = 0; @@ -1449,9 +1755,11 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, my_clut = (clut_t*) img_overl->color; my_trans = img_overl->trans; } + if( x + rle_this_bite >= clip_right ) + clipped = 1; } } else { - /* Outside clip are due to y */ + /* Outside highlight are due to y */ /* no cutting needed, starts outside, ends outside */ rle_this_bite = rle_remainder; rle_remainder = 0; @@ -1477,7 +1785,7 @@ void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, any_line_buffered = 1; } - if (o) { + if (o && !clipped) { if (!enable_exact_blending) { l = rle_this_bite>>1; if( !((x_odd+x) & 1) ) { @@ -1660,85 +1968,126 @@ void blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, rle_elem_t *rle = img_overl->rle; rle_elem_t *rle_limit = rle + img_overl->num_rle; int mask; - int x_off = img_overl->x; - int y_off = img_overl->y; + int x_off = img_overl->x + extra_data->offset_x; + int y_off = img_overl->y + extra_data->offset_y; int x, y; - uint8_t norm_pixel,clip_pixel; + uint8_t norm_pixel,hili_pixel; uint8_t *dst_y; uint8_t *dst; uint8_t alphamask = (ia44) ? 0x0F : 0xF0; - int clip_right; + int hili_right, hili_left; + int clip_right, clip_left, clip_top; if (!img_overl) return; dst_y = dst_img + dst_pitch*y_off + x_off; - if( (x_off + img_overl->width) <= dst_width ) - clip_right = img_overl->width; + /* checks to avoid drawing overlay outside the destination buffer */ + if( (x_off + src_width) <= dst_width ) + clip_right = src_width; else clip_right = dst_width - x_off; - - if ((src_height + y_off) > dst_height) + + if( x_off >= 0 ) + clip_left = 0; + else + clip_left = -x_off; + + if( y_off >= 0 ) + clip_top = 0; + else + clip_top = -y_off; + + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; + + /* make highlight area fit into clip area */ + if( img_overl->hili_right <= clip_right ) + hili_right = img_overl->hili_right; + else + hili_right = clip_right; + + if( img_overl->hili_left >= clip_left ) + hili_left = img_overl->hili_left; + else + hili_left = clip_left; for (y = 0; y < src_height; y++) { - mask = !(y < img_overl->clip_top || y >= img_overl->clip_bottom); + mask = !(y < img_overl->hili_top || y >= img_overl->hili_bottom); dst = dst_y; for (x = 0; x < src_width;) { - int len = (x + rle->len > clip_right) ? clip_right - x : rle->len; + int len = (x + rle->len > hili_right) ? hili_right - x : rle->len; + int clipped = (y < clip_top); if (len > 0) { norm_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color, img_overl->color[rle->color]) << 4) | (img_overl->trans[rle->color] & 0x0F)); - clip_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color+OVL_PALETTE_SIZE, - img_overl->clip_color[rle->color]) << 4) | - (img_overl->clip_trans[rle->color] & 0x0F)); + hili_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color+OVL_PALETTE_SIZE, + img_overl->hili_color[rle->color]) << 4) | + (img_overl->hili_trans[rle->color] & 0x0F)); if (!ia44) { norm_pixel = ((norm_pixel & 0x0F) << 4) | ((norm_pixel & 0xF0) >> 4); - clip_pixel = ((clip_pixel & 0x0F) << 4) | ((clip_pixel & 0xF0) >> 4); + hili_pixel = ((hili_pixel & 0x0F) << 4) | ((hili_pixel & 0xF0) >> 4); } if (mask) { - if (x < img_overl->clip_left) { - if (x + len <= img_overl->clip_left) { - memblend_xx44(dst,norm_pixel,len, alphamask); + if (x < hili_left) { + if (x < clip_left) + clipped = 1; + + if (x + len <= hili_left) { + if(!clipped) + memblend_xx44(dst,norm_pixel,len, alphamask); dst += len; } else { - memblend_xx44(dst,norm_pixel,img_overl->clip_left -x, alphamask); - dst += img_overl->clip_left - x; - len -= img_overl->clip_left - x; - if (len <= img_overl->clip_right - img_overl->clip_left) { - memblend_xx44(dst,clip_pixel,len, alphamask); + if(!clipped) + memblend_xx44(dst,norm_pixel,hili_left -x, alphamask); + dst += hili_left - x; + len -= hili_left - x; + if (len <= hili_right - hili_left) { + if(!clipped) + memblend_xx44(dst,hili_pixel,len, alphamask); dst += len; } else { - memblend_xx44(dst,clip_pixel,img_overl->clip_right - img_overl->clip_left, - alphamask); - dst += img_overl->clip_right - img_overl->clip_left; - len -= img_overl->clip_right - img_overl->clip_left; - memblend_xx44(dst,norm_pixel,len, alphamask); + if(!clipped) + memblend_xx44(dst,hili_pixel, hili_right - hili_left, + alphamask); + dst += hili_right - hili_left; + len -= hili_right - hili_left; + if(!clipped) + memblend_xx44(dst,norm_pixel,len, alphamask); dst += len; } } - } else if (x < img_overl->clip_right) { - if (len <= img_overl->clip_right - x) { - memblend_xx44(dst,clip_pixel,len, alphamask); + } else if (x < hili_right) { + if (len <= hili_right - x) { + if(!clipped) + memblend_xx44(dst,hili_pixel,len, alphamask); dst += len; } else { - memblend_xx44(dst,clip_pixel,img_overl->clip_right - x,alphamask); - dst += img_overl->clip_right - x; - len -= img_overl->clip_right - x; - memblend_xx44(dst,norm_pixel,len, alphamask); + if(!clipped) + memblend_xx44(dst,hili_pixel,hili_right - x,alphamask); + if (len > clip_right - x) + clipped = 1; + dst += hili_right - x; + len -= hili_right - x; + if(!clipped) + memblend_xx44(dst,norm_pixel,len, alphamask); dst += len; } } else { - memblend_xx44(dst,norm_pixel,len, alphamask); + if (x > clip_right) + clipped = 1; + if(!clipped) + memblend_xx44(dst,norm_pixel,len, alphamask); dst += len; } } else { - memblend_xx44(dst,norm_pixel,len, alphamask); + if(!clipped) + memblend_xx44(dst,norm_pixel,len, alphamask); dst += len; } } @@ -1764,6 +2113,8 @@ void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine) extra_data->buffer = 0; extra_data->buffer_size = 0; + extra_data->offset_x = 0; + extra_data->offset_y = 0; extra_data->disable_exact_blending = config->register_bool(config, "video.output.disable_exact_alphablend", 0, diff --git a/src/video_out/alphablend.h b/src/video_out/alphablend.h index b49a902c3..e29ddf11d 100644 --- a/src/video_out/alphablend.h +++ b/src/video_out/alphablend.h @@ -32,6 +32,8 @@ typedef struct { int buffer_size; int disable_exact_blending; + + int offset_x, offset_y; } alphablend_t; void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine); @@ -74,7 +76,7 @@ typedef struct { unsigned size; unsigned max_used; uint32_t cluts[XX44_PALETTE_SIZE]; - /* cache palette entries for both colors and clip_colors */ + /* cache palette entries for both colors and hili_colors */ int lookup_cache[OVL_PALETTE_SIZE*2]; } xx44_palette_t; diff --git a/src/video_out/video_out_aa.c b/src/video_out/video_out_aa.c index f3e02de1a..55c74d7e1 100644 --- a/src/video_out/video_out_aa.c +++ b/src/video_out/video_out_aa.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_aa.c,v 1.44 2004/09/22 20:29:15 miguelfreitas Exp $ + * $Id: video_out_aa.c,v 1.45 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_aa.c, ascii-art output plugin for xine * @@ -337,6 +337,6 @@ static vo_info_t vo_info_aa = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "aa", XINE_VERSION_CODE, &vo_info_aa, init_class }, + { PLUGIN_VIDEO_OUT, 21, "aa", XINE_VERSION_CODE, &vo_info_aa, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_caca.c b/src/video_out/video_out_caca.c index 225177fc6..f9eb74b50 100644 --- a/src/video_out/video_out_caca.c +++ b/src/video_out/video_out_caca.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_caca.c,v 1.3 2004/09/22 20:29:15 miguelfreitas Exp $ + * $Id: video_out_caca.c,v 1.4 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_caca.c, Color AsCii Art output plugin for xine * @@ -338,6 +338,6 @@ static vo_info_t vo_info_caca = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "caca", XINE_VERSION_CODE, &vo_info_caca, init_class }, + { PLUGIN_VIDEO_OUT, 21, "caca", XINE_VERSION_CODE, &vo_info_caca, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_directfb.c b/src/video_out/video_out_directfb.c index 79646e885..53ba33c0f 100644 --- a/src/video_out/video_out_directfb.c +++ b/src/video_out/video_out_directfb.c @@ -324,6 +324,9 @@ static void directfb_overlay_blend (vo_driver_t *this_gen, directfb_driver_t *this = (directfb_driver_t *) this_gen;
directfb_frame_t *frame = (directfb_frame_t *) frame_gen;
+ this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x;
+ this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y;
+
if (frame->format == DSPF_YUY2) {
blend_yuy2 (frame->vo_frame.base[0], overlay,
frame->width, frame->height,
diff --git a/src/video_out/video_out_directx.c b/src/video_out/video_out_directx.c index 349fff0f7..d0daa25da 100755 --- a/src/video_out/video_out_directx.c +++ b/src/video_out/video_out_directx.c @@ -20,7 +20,7 @@ * video_out_directx.c, direct draw video output plugin for xine * by Matthew Grooms <elon@altavista.com> * - * $Id: video_out_directx.c,v 1.24 2005/09/19 16:14:02 valtri Exp $ + * $Id: video_out_directx.c,v 1.25 2005/09/24 19:08:26 miguelfreitas Exp $ */ typedef unsigned char boolean; @@ -1107,6 +1107,8 @@ static void win32_overlay_blend( vo_driver_t * vo_driver, vo_frame_t * vo_frame, win32_frame_t * win32_frame = ( win32_frame_t * ) vo_frame; win32_driver_t * win32_driver = ( win32_driver_t * ) vo_driver; + win32_driver->alphablend_extra_data.offset_x = vo_frame->overlay_offset_x; + win32_driver->alphablend_extra_data.offset_y = vo_frame->overlay_offset_y; /* temporary overlay support, somthing more appropriate * for win32 will be devised at a later date */ @@ -1274,6 +1276,6 @@ static vo_info_t vo_info_win32 = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "vo_directx", XINE_VERSION_CODE, &vo_info_win32, init_class }, + { PLUGIN_VIDEO_OUT, 21, "vo_directx", XINE_VERSION_CODE, &vo_info_win32, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c index d81649dbb..90ebfe107 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.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_fb.c,v 1.43 2005/09/05 15:13:13 mshopf Exp $ + * $Id: video_out_fb.c,v 1.44 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_fb.c, frame buffer xine driver by Miguel Freitas * @@ -494,9 +494,9 @@ static void fb_overlay_clut_yuv2rgb(fb_driver_t *this, overlay->rgb_clut++; } - if(!overlay->clip_rgb_clut) + if(!overlay->hili_rgb_clut) { - clut = (clut_t*) overlay->clip_color; + clut = (clut_t*) overlay->hili_color; for(i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); @@ -509,7 +509,7 @@ static void fb_overlay_clut_yuv2rgb(fb_driver_t *this, clut[i].cb, clut[i].cr); } - overlay->clip_rgb_clut++; + overlay->hili_rgb_clut++; } } @@ -519,10 +519,13 @@ static void fb_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, fb_driver_t *this = (fb_driver_t *)this_gen; fb_frame_t *frame = (fb_frame_t *)frame_gen; + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; + /* Alpha Blend here */ if(overlay->rle) { - if(!overlay->rgb_clut || !overlay->clip_rgb_clut) + if(!overlay->rgb_clut || !overlay->hili_rgb_clut) fb_overlay_clut_yuv2rgb(this,overlay,frame); switch(this->bpp) @@ -1133,6 +1136,6 @@ static vo_info_t vo_info_fb = /* exported plugin catalog entry */ plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "fb", XINE_VERSION_CODE, &vo_info_fb, fb_init_class }, + { PLUGIN_VIDEO_OUT, 21, "fb", XINE_VERSION_CODE, &vo_info_fb, fb_init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_macosx.m b/src/video_out/video_out_macosx.m index 7a7bad769..93e71e8b3 100644 --- a/src/video_out/video_out_macosx.m +++ b/src/video_out/video_out_macosx.m @@ -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_macosx.m,v 1.11 2004/11/26 06:09:51 athp Exp $ + * $Id: video_out_macosx.m,v 1.12 2005/09/24 19:08:26 miguelfreitas Exp $ * * This output driver makes use of xine's objective-c video_output * classes located in the macosx folder. @@ -218,6 +218,9 @@ static void macosx_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, macosx_driver_t *this = (macosx_driver_t *) this_gen; macosx_frame_t *frame = (macosx_frame_t *) frame_gen; + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; + /* TODO: should check here whether the overlay has changed or not: use a * ovl_changed boolean variable similarly to video_out_xv */ if (overlay->rle) { @@ -378,7 +381,7 @@ plugin_info_t xine_plugin_info[] = { /* work around the problem that dlclose() is not allowed to * get rid of an image module which contains objective C code and simply * crashes with a Trace/BPT trap when we try to do so */ - { PLUGIN_VIDEO_OUT | PLUGIN_NO_UNLOAD, 20, "macosx", XINE_VERSION_CODE, &vo_info_macosx, init_class }, + { PLUGIN_VIDEO_OUT | PLUGIN_NO_UNLOAD, 21, "macosx", XINE_VERSION_CODE, &vo_info_macosx, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_none.c b/src/video_out/video_out_none.c index aae86fc01..1d55ee208 100644 --- a/src/video_out/video_out_none.c +++ b/src/video_out/video_out_none.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_none.c,v 1.22 2004/09/22 20:29:15 miguelfreitas Exp $ + * $Id: video_out_none.c,v 1.23 2005/09/24 19:08:26 miguelfreitas Exp $ * * Was originally part of toxine frontend. * ...but has now been adapted to xine coding style standards ;) @@ -306,6 +306,6 @@ static vo_info_t vo_info_none = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "none", XINE_VERSION_CODE, &vo_info_none, init_class }, + { PLUGIN_VIDEO_OUT, 21, "none", XINE_VERSION_CODE, &vo_info_none, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c index d1f78633b..414629566 100644 --- a/src/video_out/video_out_opengl.c +++ b/src/video_out/video_out_opengl.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_opengl.c,v 1.52 2005/09/05 14:56:31 mshopf Exp $ + * $Id: video_out_opengl.c,v 1.53 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_opengl.c, OpenGL based interface for xine * @@ -1424,14 +1424,14 @@ static void opengl_overlay_clut_yuv2rgb(opengl_driver_t *this, vo_overlay_t *ov } overlay->rgb_clut++; } - if (!overlay->clip_rgb_clut) { - clut = (clut_t*) overlay->clip_color; + if (!overlay->hili_rgb_clut) { + clut = (clut_t*) overlay->hili_color; for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { *((uint32_t *)&clut[i]) = frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, clut[i].y, clut[i].cb, clut[i].cr); } - overlay->clip_rgb_clut++; + overlay->hili_rgb_clut++; } } @@ -1446,6 +1446,9 @@ static void opengl_overlay_begin (vo_driver_t *this_gen, x11osd_clear(this->xoverlay); XUnlockDisplay (this->display); } + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } static void opengl_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) { @@ -1474,7 +1477,7 @@ static void opengl_overlay_blend (vo_driver_t *this_gen, XUnlockDisplay (this->display); } } else { - if (!overlay->rgb_clut || !overlay->clip_rgb_clut) + if (!overlay->rgb_clut || !overlay->hili_rgb_clut) opengl_overlay_clut_yuv2rgb (this, overlay, frame); # if BYTES_PER_PIXEL == 3 @@ -1992,6 +1995,6 @@ static vo_info_t vo_info_opengl = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "opengl", XINE_VERSION_CODE, &vo_info_opengl, opengl_init_class }, + { PLUGIN_VIDEO_OUT, 21, "opengl", XINE_VERSION_CODE, &vo_info_opengl, opengl_init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_pgx32.c b/src/video_out/video_out_pgx32.c index b0a7fb894..b2f108db8 100644 --- a/src/video_out/video_out_pgx32.c +++ b/src/video_out/video_out_pgx32.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_pgx32.c,v 1.12 2004/11/24 16:11:05 mroi Exp $ + * $Id: video_out_pgx32.c,v 1.13 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_pgx32.c, Sun PGX32 output plugin for xine * @@ -593,7 +593,7 @@ static void pgx32_overlay_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen, vo { /*pgx32_driver_t *this = (pgx32_driver_t *)(void *)this_gen;*/ pgx32_frame_t *frame = (pgx32_frame_t *)frame_gen; - + if (overlay->rle) { int i, j, x, y, len, width; int use_clip_palette; @@ -617,23 +617,23 @@ static void pgx32_overlay_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen, vo len = 0; } - if ((y >= overlay->clip_top) && (y <= overlay->clip_bottom) && (x <= overlay->clip_right)) { - if ((x < overlay->clip_left) && (x + width - 1 >= overlay->clip_left)) { - width -= overlay->clip_left - x; - len += overlay->clip_left - x; + if ((y >= overlay->hili_top) && (y <= overlay->hili_bottom) && (x <= overlay->hili_right)) { + if ((x < overlay->hili_left) && (x + width - 1 >= overlay->hili_left)) { + width -= overlay->hili_left - x; + len += overlay->hili_left - x; } - else if (x > overlay->clip_left) { + else if (x > overlay->hili_left) { use_clip_palette = 1; - if (x + width - 1 > overlay->clip_right) { - width -= overlay->clip_right - x; - len += overlay->clip_right - x; + if (x + width - 1 > overlay->hili_right) { + width -= overlay->hili_right - x; + len += overlay->hili_right - x; } } } if (use_clip_palette) { - clut = *(clut_t *)&overlay->clip_color[overlay->rle[i].color]; - trans = overlay->clip_trans[overlay->rle[i].color]; + clut = *(clut_t *)&overlay->hili_color[overlay->rle[i].color]; + trans = overlay->hili_trans[overlay->rle[i].color]; } else { clut = *(clut_t *)&overlay->color[overlay->rle[i].color]; @@ -892,6 +892,6 @@ static void *pgx32_init_class(xine_t *xine, void *visual_gen) } plugin_info_t xine_plugin_info[] = { - {PLUGIN_VIDEO_OUT, 20, "pgx32", XINE_VERSION_CODE, &vo_info_pgx32, pgx32_init_class}, + {PLUGIN_VIDEO_OUT, 21, "pgx32", XINE_VERSION_CODE, &vo_info_pgx32, pgx32_init_class}, {PLUGIN_NONE, 0, "", 0, NULL, NULL} }; diff --git a/src/video_out/video_out_pgx64.c b/src/video_out/video_out_pgx64.c index b1f590c84..18046ea7b 100644 --- a/src/video_out/video_out_pgx64.c +++ b/src/video_out/video_out_pgx64.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_pgx64.c,v 1.73 2005/09/05 14:56:31 mshopf Exp $ + * $Id: video_out_pgx64.c,v 1.74 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_pgx64.c, Sun XVR100/PGX64/PGX24 output plugin for xine * @@ -912,6 +912,9 @@ static void pgx64_overlay_begin(vo_driver_t *this_gen, vo_frame_t *frame_gen, in pgx64_driver_t *this = (pgx64_driver_t *)(void *)this_gen; /*pgx64_frame_t *frame = (pgx64_frame_t *)frame_gen;*/ + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; + if ((this->chromakey_en) && (changed || this->chromakey_regen_needed)) { pgx64_overlay_t *ovl, *next_ovl; @@ -982,16 +985,16 @@ static void pgx64_overlay_key_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen len = 0; } - if ((y >= overlay->clip_top) && (y <= overlay->clip_bottom) && (x <= overlay->clip_right)) { - if ((x < overlay->clip_left) && (x + width - 1 >= overlay->clip_left)) { - width -= overlay->clip_left - x; - len += overlay->clip_left - x; + if ((y >= overlay->hili_top) && (y <= overlay->hili_bottom) && (x <= overlay->hili_right)) { + if ((x < overlay->hili_left) && (x + width - 1 >= overlay->hili_left)) { + width -= overlay->hili_left - x; + len += overlay->hili_left - x; } - else if (x > overlay->clip_left) { + else if (x > overlay->hili_left) { use_clip_palette = 1; - if (x + width - 1 > overlay->clip_right) { - width -= overlay->clip_right - x; - len += overlay->clip_right - x; + if (x + width - 1 > overlay->hili_right) { + width -= overlay->hili_right - x; + len += overlay->hili_right - x; } } } @@ -1002,8 +1005,8 @@ static void pgx64_overlay_key_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen uint8_t *src_trans; if (use_clip_palette) { - src_clut = (clut_t *)&overlay->clip_color; - src_trans = (uint8_t *)&overlay->clip_trans; + src_clut = (clut_t *)&overlay->hili_color; + src_trans = (uint8_t *)&overlay->hili_trans; } else { src_clut = (clut_t *)&overlay->color; @@ -1513,6 +1516,6 @@ static void *pgx64_init_class(xine_t *xine, void *visual_gen) } plugin_info_t xine_plugin_info[] = { - {PLUGIN_VIDEO_OUT, 20, "pgx64", XINE_VERSION_CODE, &vo_info_pgx64, pgx64_init_class}, + {PLUGIN_VIDEO_OUT, 21, "pgx64", XINE_VERSION_CODE, &vo_info_pgx64, pgx64_init_class}, {PLUGIN_NONE, 0, "", 0, NULL, NULL} }; diff --git a/src/video_out/video_out_sdl.c b/src/video_out/video_out_sdl.c index d422ed76d..87cb1b11a 100644 --- a/src/video_out/video_out_sdl.c +++ b/src/video_out/video_out_sdl.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_sdl.c,v 1.42 2004/12/12 22:01:28 mroi Exp $ + * $Id: video_out_sdl.c,v 1.43 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_sdl.c, Simple DirectMedia Layer * @@ -242,6 +242,9 @@ static void sdl_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_ sdl_driver_t *this = (sdl_driver_t *) this_gen; sdl_frame_t *frame = (sdl_frame_t *) frame_gen; + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; + if (overlay->rle) { if( frame->format == XINE_IMGFMT_YV12 ) blend_yuv( frame->vo_frame.base, overlay, frame->width, frame->height, frame->vo_frame.pitches, &this->alphablend_extra_data); @@ -607,6 +610,6 @@ static vo_info_t vo_info_sdl = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "sdl", XINE_VERSION_CODE, &vo_info_sdl, init_class }, + { PLUGIN_VIDEO_OUT, 21, "sdl", XINE_VERSION_CODE, &vo_info_sdl, init_class }, { PLUGIN_NONE, 0, "" , 0 , NULL, NULL} }; diff --git a/src/video_out/video_out_stk.c b/src/video_out/video_out_stk.c index 5f3025071..f0b6429dd 100644 --- a/src/video_out/video_out_stk.c +++ b/src/video_out/video_out_stk.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_stk.c,v 1.14 2004/11/24 16:11:06 mroi Exp $ + * $Id: video_out_stk.c,v 1.15 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_stk.c, Libstk Surface Video Driver * more info on Libstk at http://www.libstk.org @@ -227,6 +227,9 @@ static void stk_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_ stk_driver_t* this = (stk_driver_t*)this_gen; stk_frame_t* frame = (stk_frame_t*)frame_gen; //printf("video_out_stk: overlay_blend()\n"); + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; if (overlay->rle) { if (frame->format == XINE_IMGFMT_YV12) @@ -484,7 +487,7 @@ static vo_info_t vo_info_stk = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "stk", XINE_VERSION_CODE, &vo_info_stk, init_class }, + { PLUGIN_VIDEO_OUT, 21, "stk", XINE_VERSION_CODE, &vo_info_stk, init_class }, { PLUGIN_NONE, 0, "" , 0 , NULL, NULL} }; diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c index e5661af20..19bd29fe1 100644 --- a/src/video_out/video_out_syncfb.c +++ b/src/video_out/video_out_syncfb.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_syncfb.c,v 1.100 2004/12/12 22:01:28 mroi Exp $ + * $Id: video_out_syncfb.c,v 1.101 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_syncfb.c, SyncFB (for Matrox G200/G400 cards) interface for xine * @@ -568,6 +568,9 @@ static void syncfb_overlay_blend(vo_driver_t* this_gen, vo_frame_t* frame_gen, v { syncfb_frame_t* frame = (syncfb_frame_t *) frame_gen; + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; + /* alpha blend here */ if (overlay->rle) { if (frame->format == XINE_IMGFMT_YV12) @@ -1115,7 +1118,7 @@ static vo_info_t vo_info_syncfb = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "SyncFB", XINE_VERSION_CODE, &vo_info_syncfb, init_class }, + { PLUGIN_VIDEO_OUT, 21, "SyncFB", XINE_VERSION_CODE, &vo_info_syncfb, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_vidix.c b/src/video_out/video_out_vidix.c index 227438748..bd2b85e94 100644 --- a/src/video_out/video_out_vidix.c +++ b/src/video_out/video_out_vidix.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_vidix.c,v 1.68 2005/01/23 23:01:12 jstembridge Exp $ + * $Id: video_out_vidix.c,v 1.69 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_vidix.c * @@ -568,9 +568,9 @@ static void vidix_update_frame_format (vo_driver_t *this_gen, static void vidix_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed) { -#ifdef HAVE_X11 vidix_driver_t *this = (vidix_driver_t *) this_gen; +#ifdef HAVE_X11 this->ovl_changed += changed; if( this->ovl_changed && this->xoverlay ) { @@ -579,6 +579,9 @@ static void vidix_overlay_begin (vo_driver_t *this_gen, XUnlockDisplay (this->display); } #endif + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } static void vidix_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) { @@ -1309,10 +1312,10 @@ static vo_info_t vo_info_vidixfb = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ #ifdef HAVE_X11 - { PLUGIN_VIDEO_OUT, 20, "vidix", XINE_VERSION_CODE, &vo_info_vidix, vidix_init_class }, + { PLUGIN_VIDEO_OUT, 21, "vidix", XINE_VERSION_CODE, &vo_info_vidix, vidix_init_class }, #endif #ifdef HAVE_FB - { PLUGIN_VIDEO_OUT, 20, "vidixfb", XINE_VERSION_CODE, &vo_info_vidixfb, vidixfb_init_class }, + { PLUGIN_VIDEO_OUT, 21, "vidixfb", XINE_VERSION_CODE, &vo_info_vidixfb, vidixfb_init_class }, #endif { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index ae381f61d..f66ca3d2d 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.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_xshm.c,v 1.140 2005/09/05 15:13:13 mshopf Exp $ + * $Id: video_out_xshm.c,v 1.141 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_xshm.c, X11 shared memory extension interface for xine * @@ -607,14 +607,14 @@ static void xshm_overlay_clut_yuv2rgb(xshm_driver_t *this, vo_overlay_t *overla } overlay->rgb_clut++; } - if (!overlay->clip_rgb_clut) { - clut = (clut_t*) overlay->clip_color; + if (!overlay->hili_rgb_clut) { + clut = (clut_t*) overlay->hili_color; for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { *((uint32_t *)&clut[i]) = frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, clut[i].y, clut[i].cb, clut[i].cr); } - overlay->clip_rgb_clut++; + overlay->hili_rgb_clut++; } } @@ -629,6 +629,9 @@ static void xshm_overlay_begin (vo_driver_t *this_gen, x11osd_clear(this->xoverlay); XUnlockDisplay (this->display); } + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } static void xshm_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) { @@ -657,7 +660,7 @@ static void xshm_overlay_blend (vo_driver_t *this_gen, XUnlockDisplay (this->display); } } else { - if (!overlay->rgb_clut || !overlay->clip_rgb_clut) + if (!overlay->rgb_clut || !overlay->hili_rgb_clut) xshm_overlay_clut_yuv2rgb (this, overlay, frame); switch (this->bpp) { @@ -1299,6 +1302,6 @@ static vo_info_t vo_info_xshm = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "xshm", XINE_VERSION_CODE, &vo_info_xshm, xshm_init_class }, + { PLUGIN_VIDEO_OUT, 21, "xshm", XINE_VERSION_CODE, &vo_info_xshm, xshm_init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index ddc40d8b7..cf7605239 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.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_xv.c,v 1.212 2005/07/30 11:26:09 valtri Exp $ + * $Id: video_out_xv.c,v 1.213 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -634,6 +634,9 @@ static void xv_overlay_begin (vo_driver_t *this_gen, x11osd_clear(this->xoverlay); XUnlockDisplay (this->display); } + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } static void xv_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) { @@ -1605,7 +1608,7 @@ static vo_info_t vo_info_xv = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "xv", XINE_VERSION_CODE, &vo_info_xv, init_class }, + { PLUGIN_VIDEO_OUT, 21, "xv", XINE_VERSION_CODE, &vo_info_xv, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index 4400f83f2..0288ed0df 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.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_xvmc.c,v 1.23 2005/05/03 19:25:11 totte67 Exp $ + * $Id: video_out_xvmc.c,v 1.24 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_xvmc.c, X11 video motion compensation extension interface for xine * @@ -837,6 +837,9 @@ static void xvmc_overlay_blend (vo_driver_t *this_gen, xvmc_frame_t *frame = (xvmc_frame_t *) frame_gen; lprintf ("xvmc_overlay_blend\n"); + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; /* Alpha Blend here * As XV drivers improve to support Hardware overlay, we will change this function. @@ -1796,7 +1799,7 @@ static vo_info_t vo_info_xvmc = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "xvmc", XINE_VERSION_CODE, &vo_info_xvmc, init_class }, + { PLUGIN_VIDEO_OUT, 21, "xvmc", XINE_VERSION_CODE, &vo_info_xvmc, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index fd2ba9911..86f8ff7f4 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -18,7 +18,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_xxmc.c,v 1.17 2005/06/09 21:06:02 totte67 Exp $ + * $Id: video_out_xxmc.c,v 1.18 2005/09/24 19:08:26 miguelfreitas Exp $ * * video_out_xxmc.c, X11 decoding accelerated video extension interface for xine * @@ -1408,7 +1408,10 @@ static void xxmc_overlay_begin (vo_driver_t *this_gen, clear_xx44_palette(&this->palette); } } - xvmc_context_reader_unlock( &this->xvmc_lock ); + xvmc_context_reader_unlock( &this->xvmc_lock ); + + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; + this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } static void xxmc_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) @@ -2644,7 +2647,7 @@ static vo_info_t vo_info_xxmc = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_OUT, 20, "xxmc", XINE_VERSION_CODE, &vo_info_xxmc, init_class }, + { PLUGIN_VIDEO_OUT, 21, "xxmc", XINE_VERSION_CODE, &vo_info_xxmc, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/video_out/x11osd.c b/src/video_out/x11osd.c index 24eba0f36..ec9a663f1 100644 --- a/src/video_out/x11osd.c +++ b/src/video_out/x11osd.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: x11osd.c,v 1.13 2004/11/13 17:13:41 miguelfreitas Exp $ + * $Id: x11osd.c,v 1.14 2005/09/24 19:08:26 miguelfreitas Exp $ * * x11osd.c, use X11 Nonrectangular Window Shape Extension to draw xine OSD * @@ -467,16 +467,16 @@ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay) width = len; len = 0; } - if ((y >= overlay->clip_top) && (y <= overlay->clip_bottom) && (x <= overlay->clip_right)) { - if ((x < overlay->clip_left) && (x + width - 1 >= overlay->clip_left)) { - width -= overlay->clip_left - x; - len += overlay->clip_left - x; + if ((y >= overlay->hili_top) && (y <= overlay->hili_bottom) && (x <= overlay->hili_right)) { + if ((x < overlay->hili_left) && (x + width - 1 >= overlay->hili_left)) { + width -= overlay->hili_left - x; + len += overlay->hili_left - x; } - else if (x > overlay->clip_left) { + else if (x > overlay->hili_left) { use_clip_palette = 1; - if (x + width - 1 > overlay->clip_right) { - width -= overlay->clip_right - x; - len += overlay->clip_right - x; + if (x + width - 1 > overlay->hili_right) { + width -= overlay->hili_right - x; + len += overlay->hili_right - x; } } } @@ -487,8 +487,8 @@ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay) uint8_t *src_trans; if (use_clip_palette) { - src_clut = (clut_t *)&overlay->clip_color; - src_trans = (uint8_t *)&overlay->clip_trans; + src_clut = (clut_t *)&overlay->hili_color; + src_trans = (uint8_t *)&overlay->hili_trans; } else { src_clut = (clut_t *)&overlay->color; diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index e76f22167..2f40d73b1 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -238,10 +238,10 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { this->event.object.overlay->width = osd->x2 - osd->x1; this->event.object.overlay->height = osd->y2 - osd->y1; - this->event.object.overlay->clip_top = 0; - this->event.object.overlay->clip_bottom = this->event.object.overlay->height; - this->event.object.overlay->clip_left = 0; - this->event.object.overlay->clip_right = this->event.object.overlay->width; + this->event.object.overlay->hili_top = 0; + this->event.object.overlay->hili_bottom = this->event.object.overlay->height; + this->event.object.overlay->hili_left = 0; + this->event.object.overlay->hili_right = this->event.object.overlay->width; /* there will be at least that many rle objects (one for each row) */ required = osd->y2 - osd->y1; @@ -298,8 +298,8 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { #endif lprintf("num_rle = %d\n", this->event.object.overlay->num_rle); - memcpy(this->event.object.overlay->clip_color, osd->color, sizeof(osd->color)); - memcpy(this->event.object.overlay->clip_trans, osd->trans, sizeof(osd->trans)); + memcpy(this->event.object.overlay->hili_color, osd->color, sizeof(osd->color)); + memcpy(this->event.object.overlay->hili_trans, osd->trans, sizeof(osd->trans)); memcpy(this->event.object.overlay->color, osd->color, sizeof(osd->color)); memcpy(this->event.object.overlay->trans, osd->trans, sizeof(osd->trans)); diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 7e3ce577c..4928cc0c6 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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.c,v 1.218 2005/02/14 14:04:55 holstsn Exp $ + * $Id: video_out.c,v 1.219 2005/09/24 19:08:26 miguelfreitas Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -338,6 +338,8 @@ static vo_frame_t *vo_get_frame (xine_video_port_t *this_gen, img->crop_right = 0; img->crop_top = 0; img->crop_bottom = 0; + img->overlay_offset_x = 0; + img->overlay_offset_y = 0; img->stream = NULL; _x_extra_info_reset ( img->extra_info ); @@ -451,6 +453,8 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { (this->grab_only || !(this->driver->get_capabilities (this->driver) & VO_CAP_CROP)) ) { if (img->format == XINE_IMGFMT_YV12 || img->format == XINE_IMGFMT_YUY2) { + img->overlay_offset_x -= img->crop_left; + img->overlay_offset_y -= img->crop_top; img = crop_frame( img->port, img ); img_already_locked = 1; } else { @@ -626,6 +630,8 @@ static vo_frame_t * duplicate_frame( vos_t *this, vo_frame_t *img ) { dupl->crop_right = img->crop_right; dupl->crop_top = img->crop_top; dupl->crop_bottom = img->crop_bottom; + dupl->overlay_offset_x = img->overlay_offset_x; + dupl->overlay_offset_y = img->overlay_offset_y; this->driver->update_frame_format (this->driver, dupl, dupl->width, dupl->height, dupl->ratio, dupl->format, dupl->flags); @@ -1604,6 +1610,8 @@ static vo_frame_t * crop_frame( xine_video_port_t *this_gen, vo_frame_t *img ) { dupl->progressive_frame = img->progressive_frame; dupl->repeat_first_field = img->repeat_first_field; dupl->top_field_first = img->top_field_first; + dupl->overlay_offset_x = img->overlay_offset_x; + dupl->overlay_offset_y = img->overlay_offset_y; switch (img->format) { case XINE_IMGFMT_YV12: diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h index 31680992d..12d6b6f02 100644 --- a/src/xine-engine/video_out.h +++ b/src/xine-engine/video_out.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.h,v 1.112 2004/10/08 21:08:26 mroi Exp $ + * $Id: video_out.h,v 1.113 2005/09/24 19:08:26 miguelfreitas Exp $ * * * xine version of video_out.h @@ -150,6 +150,9 @@ struct vo_frame_s { vo_driver_t *driver; xine_stream_t *stream; + /* displacement for overlays */ + int overlay_offset_x, overlay_offset_y; + /* * that part is used only by video_out.c for frame management * obs: changing anything here will require recompiling vo drivers @@ -285,7 +288,7 @@ struct xine_video_port_s { * from generic vo functions. */ -#define VIDEO_OUT_DRIVER_IFACE_VERSION 20 +#define VIDEO_OUT_DRIVER_IFACE_VERSION 21 struct vo_driver_s { @@ -400,13 +403,15 @@ struct vo_overlay_s { uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */ int rgb_clut; /* true if clut was converted to rgb */ - int clip_top; - int clip_bottom; - int clip_left; - int clip_right; - uint32_t clip_color[OVL_PALETTE_SIZE]; - uint8_t clip_trans[OVL_PALETTE_SIZE]; - int clip_rgb_clut; /* true if clut was converted to rgb */ + /* define a highlight area with different colors */ + int hili_top; + int hili_bottom; + int hili_left; + int hili_right; + uint32_t hili_color[OVL_PALETTE_SIZE]; + uint8_t hili_trans[OVL_PALETTE_SIZE]; + int hili_rgb_clut; /* true if clut was converted to rgb */ + int unscaled; /* true if it should be blended unscaled */ }; diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c index 36584b78a..346c3c9a6 100644 --- a/src/xine-engine/video_overlay.c +++ b/src/xine-engine/video_overlay.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_overlay.c,v 1.37 2004/12/08 18:18:23 miguelfreitas Exp $ + * $Id: video_overlay.c,v 1.38 2005/09/24 19:08:26 miguelfreitas Exp $ * */ @@ -320,11 +320,11 @@ static void video_overlay_print_overlay( vo_overlay_t *ovl ) { printf ("video_overlay: \ttrans [%d %d %d %d]\n", ovl->trans[0], ovl->trans[1], ovl->trans[2], ovl->trans[3]); printf ("video_overlay: \tclip top=%d bottom=%d left=%d right=%d\n", - ovl->clip_top, ovl->clip_bottom, ovl->clip_left, ovl->clip_right); + ovl->hili_top, ovl->hili_bottom, ovl->hili_left, ovl->hili_right); printf ("video_overlay: \tclip_clut [%x %x %x %x]\n", - ovl->clip_color[0], ovl->clip_color[1], ovl->clip_color[2], ovl->clip_color[3]); - printf ("video_overlay: \tclip_trans [%d %d %d %d]\n", - ovl->clip_trans[0], ovl->clip_trans[1], ovl->clip_trans[2], ovl->clip_trans[3]); + ovl->hili_color[0], ovl->hili_color[1], ovl->hili_color[2], ovl->hili_color[3]); + printf ("video_overlay: \thili_trans [%d %d %d %d]\n", + ovl->hili_trans[0], ovl->hili_trans[1], ovl->hili_trans[2], ovl->hili_trans[3]); return; } #endif @@ -436,19 +436,19 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { printf ("video_overlay:overlay present\n"); #endif this->objects[handle].handle = handle; - overlay->clip_top = event_overlay->clip_top; - overlay->clip_bottom = event_overlay->clip_bottom; - overlay->clip_left = event_overlay->clip_left; - overlay->clip_right = event_overlay->clip_right; - overlay->clip_color[0] = event_overlay->clip_color[0]; - overlay->clip_color[1] = event_overlay->clip_color[1]; - overlay->clip_color[2] = event_overlay->clip_color[2]; - overlay->clip_color[3] = event_overlay->clip_color[3]; - overlay->clip_trans[0] = event_overlay->clip_trans[0]; - overlay->clip_trans[1] = event_overlay->clip_trans[1]; - overlay->clip_trans[2] = event_overlay->clip_trans[2]; - overlay->clip_trans[3] = event_overlay->clip_trans[3]; - overlay->clip_rgb_clut = event_overlay->clip_rgb_clut; + overlay->hili_top = event_overlay->hili_top; + overlay->hili_bottom = event_overlay->hili_bottom; + overlay->hili_left = event_overlay->hili_left; + overlay->hili_right = event_overlay->hili_right; + overlay->hili_color[0] = event_overlay->hili_color[0]; + overlay->hili_color[1] = event_overlay->hili_color[1]; + overlay->hili_color[2] = event_overlay->hili_color[2]; + overlay->hili_color[3] = event_overlay->hili_color[3]; + overlay->hili_trans[0] = event_overlay->hili_trans[0]; + overlay->hili_trans[1] = event_overlay->hili_trans[1]; + overlay->hili_trans[2] = event_overlay->hili_trans[2]; + overlay->hili_trans[3] = event_overlay->hili_trans[3]; + overlay->hili_rgb_clut = event_overlay->hili_rgb_clut; #ifdef LOG_DEBUG video_overlay_print_overlay( this->events[this_event].event->object.overlay ) ; #endif diff --git a/src/xine-engine/video_overlay.h b/src/xine-engine/video_overlay.h index f236c29c6..67562759f 100644 --- a/src/xine-engine/video_overlay.h +++ b/src/xine-engine/video_overlay.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_overlay.h,v 1.19 2004/12/08 18:18:24 miguelfreitas Exp $ + * $Id: video_overlay.h,v 1.20 2005/09/24 19:08:26 miguelfreitas Exp $ * */ @@ -60,10 +60,10 @@ typedef struct vo_buttons_s { /* The following clipping coordinates are relative to the left upper corner * of the OVERLAY, not of the target FRAME. Please do not mix them up! */ - int32_t clip_top; - int32_t clip_bottom; - int32_t clip_left; - int32_t clip_right; + int32_t hili_top; + int32_t hili_bottom; + int32_t hili_left; + int32_t hili_right; int32_t up; int32_t down; int32_t left; @@ -74,7 +74,7 @@ typedef struct vo_buttons_s { uint32_t active_color[OVL_PALETTE_SIZE]; uint8_t active_trans[OVL_PALETTE_SIZE]; xine_event_t active_event; - int32_t clip_rgb_clut; /* true if clut was converted to rgb*/ + int32_t hili_rgb_clut; /* true if clut was converted to rgb*/ /* FIXME: Probably not needed ^^^ */ } vo_buttons_t; diff --git a/src/xine-engine/xine_plugin.h b/src/xine-engine/xine_plugin.h index d85364521..e9a50ff14 100644 --- a/src/xine-engine/xine_plugin.h +++ b/src/xine-engine/xine_plugin.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: xine_plugin.h,v 1.18 2005/04/10 09:31:16 tmattern Exp $ + * $Id: xine_plugin.h,v 1.19 2005/09/24 19:08:26 miguelfreitas Exp $ * * generic plugin definitions * @@ -97,7 +97,7 @@ typedef struct { * info is a list of plugin_info_t terminated by PLUGIN_NONE * example: * plugin_info_t acme_plugin_info[] = { - * { PLUGIN_VIDEO_OUT, 20, "acme", XINE_VERSION_CODE, &vo_info_acme, + * { PLUGIN_VIDEO_OUT, 21, "acme", XINE_VERSION_CODE, &vo_info_acme, * init_class_acme }, * { PLUGIN_NONE, 0, "", 0, NULL, NULL } * }; |