From ebdf7c59eee588633416888dabb0164f671797ef Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 26 Oct 2004 20:10:20 +0000 Subject: add frontend cropping support CVS patchset: 7076 CVS date: 2004/10/26 20:10:20 --- include/xine.h.in | 7 ++++++- src/xine-engine/video_out.c | 43 +++++++++++++++++++++++++++++++++++++++- src/xine-engine/vo_scale.c | 6 +++++- src/xine-engine/xine_interface.c | 10 +++++++++- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/include/xine.h.in b/include/xine.h.in index a4633c78e..021d34327 100644 --- a/include/xine.h.in +++ b/include/xine.h.in @@ -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.h.in,v 1.131 2004/09/28 18:49:39 miguelfreitas Exp $ + * $Id: xine.h.in,v 1.132 2004/10/26 20:10:26 miguelfreitas Exp $ * * public xine-lib (libxine) interface and documentation * @@ -366,6 +366,11 @@ int xine_get_param (xine_stream_t *stream, int param); #define XINE_PARAM_VO_ZOOM_Y 0x0100000d /* percent */ #define XINE_PARAM_VO_PAN_SCAN 0x01000009 /* bool */ #define XINE_PARAM_VO_TVMODE 0x0100000a /* ??? */ +#define XINE_PARAM_VO_CROP_LEFT 0x01000020 /* crop frame pixels */ +#define XINE_PARAM_VO_CROP_RIGHT 0x01000021 /* crop frame pixels */ +#define XINE_PARAM_VO_CROP_TOP 0x01000022 /* crop frame pixels */ +#define XINE_PARAM_VO_CROP_BOTTOM 0x01000023 /* crop frame pixels */ + #define XINE_VO_ZOOM_STEP 100 #define XINE_VO_ZOOM_MAX 400 diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index f5bcf312a..38c420da3 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.212 2004/10/18 21:07:38 f1rmb Exp $ + * $Id: video_out.c,v 1.213 2004/10/26 20:10:20 miguelfreitas Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -120,6 +120,7 @@ typedef struct { int64_t current_duration; int frame_drop_limit; int frame_drop_cpt; + int crop_left, crop_right, crop_top, crop_bottom; } vos_t; @@ -438,6 +439,12 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { int img_already_locked = 0; + /* add cropping requested by frontend */ + img->crop_left += this->crop_left; + img->crop_right += this->crop_right; + img->crop_top += this->crop_top; + img->crop_bottom += this->crop_bottom; + /* perform cropping when vo driver does not support it */ if( (img->crop_left || img->crop_top || img->crop_right || img->crop_bottom) && @@ -1305,6 +1312,19 @@ static int vo_get_property (xine_video_port_t *this_gen, int property) { /* * handle XINE_PARAM_xxx properties (convert from driver's range) */ + case XINE_PARAM_VO_CROP_LEFT: + ret = this->crop_left; + break; + case XINE_PARAM_VO_CROP_RIGHT: + ret = this->crop_right; + break; + case XINE_PARAM_VO_CROP_TOP: + ret = this->crop_top; + break; + case XINE_PARAM_VO_CROP_BOTTOM: + ret = this->crop_bottom; + break; + case XINE_PARAM_VO_HUE: case XINE_PARAM_VO_SATURATION: case XINE_PARAM_VO_CONTRAST: @@ -1373,6 +1393,27 @@ static int vo_set_property (xine_video_port_t *this_gen, int property, int value /* * handle XINE_PARAM_xxx properties (convert to driver's range) */ + case XINE_PARAM_VO_CROP_LEFT: + if( value < 0 ) + value = 0; + ret = this->crop_left = value; + break; + case XINE_PARAM_VO_CROP_RIGHT: + if( value < 0 ) + value = 0; + ret = this->crop_right = value; + break; + case XINE_PARAM_VO_CROP_TOP: + if( value < 0 ) + value = 0; + ret = this->crop_top = value; + break; + case XINE_PARAM_VO_CROP_BOTTOM: + if( value < 0 ) + value = 0; + ret = this->crop_bottom = value; + break; + case XINE_PARAM_VO_HUE: case XINE_PARAM_VO_SATURATION: case XINE_PARAM_VO_CONTRAST: diff --git a/src/xine-engine/vo_scale.c b/src/xine-engine/vo_scale.c index 0f522ea1d..a93c0c08e 100644 --- a/src/xine-engine/vo_scale.c +++ b/src/xine-engine/vo_scale.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: vo_scale.c,v 1.34 2004/10/09 06:44:52 mroi Exp $ + * $Id: vo_scale.c,v 1.35 2004/10/26 20:10:25 miguelfreitas Exp $ * * Contains common code to calculate video scaling parameters. * In short, it will map frame dimensions to screen/window size. @@ -56,8 +56,12 @@ void _x_vo_scale_compute_ideal_size (vo_scale_t *this) { * aspect ratio */ + /* image_ratio = (double) (this->delivered_width - (this->crop_left + this->crop_right)) / (double) (this->delivered_height - (this->crop_top + this->crop_bottom)); + */ + image_ratio = (double) (this->delivered_width) / + (double) (this->delivered_height); switch (this->user_ratio) { case XINE_VO_ASPECT_AUTO: diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 3567d9d4d..5c11c065a 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.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: xine_interface.c,v 1.83 2004/08/02 12:51:21 miguelfreitas Exp $ + * $Id: xine_interface.c,v 1.84 2004/10/26 20:10:24 miguelfreitas Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -441,6 +441,10 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { case XINE_PARAM_VO_ZOOM_Y: case XINE_PARAM_VO_PAN_SCAN: case XINE_PARAM_VO_TVMODE: + case XINE_PARAM_VO_CROP_LEFT: + case XINE_PARAM_VO_CROP_RIGHT: + case XINE_PARAM_VO_CROP_TOP: + case XINE_PARAM_VO_CROP_BOTTOM: stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); stream->video_out->set_property(stream->video_out, param, value); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); @@ -586,6 +590,10 @@ int xine_get_param (xine_stream_t *stream, int param) { case XINE_PARAM_VO_ZOOM_Y: case XINE_PARAM_VO_PAN_SCAN: case XINE_PARAM_VO_TVMODE: + case XINE_PARAM_VO_CROP_LEFT: + case XINE_PARAM_VO_CROP_RIGHT: + case XINE_PARAM_VO_CROP_TOP: + case XINE_PARAM_VO_CROP_BOTTOM: stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); ret = stream->video_out->get_property(stream->video_out, param); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); -- cgit v1.2.3