diff options
author | Michael Roitzsch <mroi@users.sourceforge.net> | 2002-07-17 14:58:11 +0000 |
---|---|---|
committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2002-07-17 14:58:11 +0000 |
commit | a679862dfcc9dcf14b51f738be73d9e26ac5efe0 (patch) | |
tree | 77c5e6865532f8dd78ea0fd9b5a42d04324423bc | |
parent | 7d3b1240c412845aa8e645dcf17da18a5a304ea7 (diff) | |
download | xine-lib-a679862dfcc9dcf14b51f738be73d9e26ac5efe0.tar.gz xine-lib-a679862dfcc9dcf14b51f738be73d9e26ac5efe0.tar.bz2 |
* better use of vo_frame_t; don't add members to our private frame struct,
when vo_frame_t already has the appropriate info
* also fix some ratio_code <-> aspect_code mixing
CVS patchset: 2300
CVS date: 2002/07/17 14:58:11
-rw-r--r-- | src/dxr3/dxr3_mpeg_encoders.c | 18 | ||||
-rw-r--r-- | src/dxr3/video_out_dxr3.c | 73 | ||||
-rw-r--r-- | src/dxr3/video_out_dxr3.h | 9 |
3 files changed, 50 insertions, 50 deletions
diff --git a/src/dxr3/dxr3_mpeg_encoders.c b/src/dxr3/dxr3_mpeg_encoders.c index 9c40c5ed8..c28e84ef2 100644 --- a/src/dxr3/dxr3_mpeg_encoders.c +++ b/src/dxr3/dxr3_mpeg_encoders.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_mpeg_encoders.c,v 1.7 2002/07/16 16:21:14 mroi Exp $ + * $Id: dxr3_mpeg_encoders.c,v 1.8 2002/07/17 14:58:12 mroi Exp $ */ /* mpeg encoders for the dxr3 video out plugin. @@ -191,7 +191,7 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) * and context->video_bytes (= width * height * bytes/pixel) */ rte_set_video_parameters(context, - (drv->format == IMGFMT_YV12 ? RTE_YUV420 : RTE_YUYV), + (frame->vo_frame.format == IMGFMT_YV12 ? RTE_YUV420 : RTE_YUYV), context->width, context->height, context->video_rate, context->output_video_bits, context->gop_sequence); @@ -345,7 +345,7 @@ static int fame_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) /* if YUY2 and dimensions changed, we need to re-allocate the * internal YV12 buffer */ - if (drv->format == IMGFMT_YUY2) { + if (frame->vo_frame.format == IMGFMT_YUY2) { int image_size = drv->video_width * drv->video_oheight; this->out[0] = xine_xmalloc_aligned(16, image_size * 3/2, @@ -466,7 +466,7 @@ static int fame_on_display_frame(dxr3_driver_t *drv, dxr3_frame_t *frame) ssize_t written; int size; - if ((frame->width != this->fp.width) || (frame->oheight != this->fp.height)) { + if ((frame->vo_frame.width != this->fp.width) || (frame->oheight != this->fp.height)) { /* probably an old frame for a previous context. ignore it */ frame->vo_frame.displayed(&frame->vo_frame); return 1; @@ -533,12 +533,12 @@ static int fame_prepare_frame(fame_data_t *this, dxr3_driver_t *drv, dxr3_frame_ printf("dxr3_mpeg_encoder: Internal YV12 buffer not created.\n"); return 0; } - y = this->out[0] + frame->width * drv->top_bar; - u = this->out[1] + frame->width/2 * (drv->top_bar / 2); - v = this->out[2] + frame->width/2 * (drv->top_bar / 2); + y = this->out[0] + frame->vo_frame.width * drv->top_bar; + u = this->out[1] + (frame->vo_frame.width / 2) * (drv->top_bar / 2); + v = this->out[2] + (frame->vo_frame.width / 2) * (drv->top_bar / 2); yuy2 = frame->vo_frame.base[0]; - w2 = frame->width / 2; - for (i = 0; i < frame->iheight; i += 2) { + w2 = frame->vo_frame.width / 2; + for (i = 0; i < frame->vo_frame.height; i += 2) { for (j = 0; j < w2; j++) { /* packed YUV 422 is: Y[i] U[i] Y[i+1] V[i] */ *(y++) = *(yuy2++); diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c index c67f9a301..93db59441 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.41 2002/07/17 11:00:09 mroi Exp $ + * $Id: video_out_dxr3.c,v 1.42 2002/07/17 14:58:11 mroi Exp $ */ /* mpeg1 encoding video out plugin for the dxr3. @@ -415,7 +415,6 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge { dxr3_driver_t *this = (dxr3_driver_t *)this_gen; dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; - int i; int oheight; /* update the overlay window co-ords if required */ @@ -437,11 +436,14 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge this->video_iheight = height; this->video_oheight = height; this->top_bar = 0; - this->video_aspect = ratio_code; + this->video_ratio = ratio_code; - frame->width = width; - frame->iheight = height; - frame->oheight = height; + frame->vo_frame.width = width; + frame->vo_frame.height = height; + frame->vo_frame.ratio = ratio_code; + frame->oheight = height; + frame->pan_scan = (ratio_code == XINE_ASPECT_RATIO_PAN_SCAN); + frame->aspect = 0; if (frame->mem) { free(frame->mem); @@ -450,23 +452,15 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge frame_gen->base[0] = frame_gen->base[1] = frame_gen->base[2] = NULL; } - frame->vo_frame.ratio = this->aspect; - frame->pan_scan = 0; - if (ratio_code == XINE_ASPECT_RATIO_SQUARE || ratio_code == XINE_ASPECT_RATIO_4_3) - frame->vo_frame.ratio = ASPECT_FULL; - if (ratio_code == XINE_ASPECT_RATIO_ANAMORPHIC || ratio_code == XINE_ASPECT_RATIO_211_1) - frame->vo_frame.ratio = ASPECT_ANAMORPHIC; - if (ratio_code == XINE_ASPECT_RATIO_PAN_SCAN) - frame->pan_scan = 1; - return; } /* the following is for the mpeg encoding part only */ - frame->vo_frame.ratio = this->aspect; - frame->pan_scan = 0; - oheight = this->video_oheight; + frame->vo_frame.ratio = ratio_code; + frame->pan_scan = 0; + frame->aspect = this->aspect; + oheight = this->video_oheight; if (this->fd_video == CLOSED_FOR_DECODER) { /* decoder should have released it */ this->fd_video = CLOSED_FOR_ENCODER; /* allow encoder to reopen it */ @@ -479,23 +473,23 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge } if ((this->video_width != width) || (this->video_iheight != height) || - (this->video_aspect != ratio_code)) { + (this->video_ratio != ratio_code)) { /* check aspect ratio, see if we need to add black borders */ switch (ratio_code) { case XINE_ASPECT_RATIO_4_3: - frame->vo_frame.ratio = ASPECT_FULL; + frame->aspect = ASPECT_FULL; oheight = height; break; case XINE_ASPECT_RATIO_ANAMORPHIC: case XINE_ASPECT_RATIO_PAN_SCAN: - frame->vo_frame.ratio = ASPECT_ANAMORPHIC; + frame->aspect = ASPECT_ANAMORPHIC; oheight = height; break; default: /* assume square pixel */ - frame->vo_frame.ratio = ASPECT_ANAMORPHIC; + frame->aspect = ASPECT_ANAMORPHIC; oheight = (int)(width * 9./16.); if (oheight < height) { /* frame too high, try 4:3 */ - frame->vo_frame.ratio = ASPECT_FULL; + frame->aspect = ASPECT_FULL; oheight = (int)(width * 3./4.); } } @@ -507,13 +501,12 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge /* Tell the viewers about the aspect ratio stuff. */ if (oheight - height > 0) printf("video_out_dxr3: adding %d black lines to get %s aspect ratio.\n", - oheight - height, frame->vo_frame.ratio == ASPECT_FULL ? "4:3" : "16:9"); + oheight - height, frame->aspect == ASPECT_FULL ? "4:3" : "16:9"); this->video_width = width; this->video_iheight = height; this->video_oheight = oheight; - this->video_aspect = ratio_code; - this->format = format; + this->video_ratio = ratio_code; this->need_redraw = 1; this->need_update = 1; @@ -525,8 +518,8 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge } /* if dimensions changed, we need to re-allocate frame memory */ - if ((frame->width != width) || (frame->iheight != height) || - (frame->oheight != oheight)) { + if ((frame->vo_frame.width != width) || (frame->vo_frame.height != height) || + (frame->oheight != oheight) || (frame->vo_frame.format != format)) { if (frame->mem) { free (frame->mem); frame->mem = NULL; @@ -536,7 +529,7 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge * so old and new macroblocks overlap */ this->top_bar = ((oheight - height) / 32) * 16; if (format == IMGFMT_YUY2) { - int image_size; + int i, image_size; /* calculate pitch and size including black bars */ frame->vo_frame.pitches[0] = 32*((width + 15) / 16); @@ -599,10 +592,10 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge frame->vo_frame.base[0] += frame->vo_frame.pitches[0]; } - frame->width = width; - frame->iheight = height; - frame->oheight = oheight; - frame->swap_fields = this->swap_fields; + frame->vo_frame.width = width; + frame->vo_frame.height = height; + frame->oheight = oheight; + frame->swap_fields = this->swap_fields; } static void dxr3_overlay_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen, @@ -615,9 +608,9 @@ static void dxr3_overlay_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen, if (overlay->rle) { if (frame_gen->format == IMGFMT_YV12) - blend_yuv(frame->vo_frame.base, overlay, frame->width, frame->iheight); + blend_yuv(frame->vo_frame.base, overlay, frame->vo_frame.width, frame->vo_frame.height); else - blend_yuy2(frame->vo_frame.base[0], overlay, frame->width, frame->iheight); + blend_yuy2(frame->vo_frame.base[0], overlay, frame->vo_frame.width, frame->vo_frame.height); } } } @@ -628,7 +621,15 @@ static void dxr3_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; /* use correct aspect and pan&scan setting */ - if (frame->vo_frame.ratio != this->aspect) + if (!frame->aspect) { + /* aspect not determined yet, set it now */ + frame->aspect = this->aspect; + if (frame_gen->ratio == XINE_ASPECT_RATIO_SQUARE || frame_gen->ratio == XINE_ASPECT_RATIO_4_3) + frame->aspect = ASPECT_FULL; + if (frame_gen->ratio == XINE_ASPECT_RATIO_ANAMORPHIC || frame_gen->ratio == XINE_ASPECT_RATIO_211_1) + frame->aspect = ASPECT_ANAMORPHIC; + } + if (frame->aspect != this->aspect) dxr3_set_property(this_gen, VO_PROP_ASPECT_RATIO, frame->vo_frame.ratio); if (frame->pan_scan && !this->pan_scan) { dxr3_set_property(this_gen, VO_PROP_ZOOM_FACTOR, 1); diff --git a/src/dxr3/video_out_dxr3.h b/src/dxr3/video_out_dxr3.h index 47a7fa755..6e7298a6b 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.6 2002/07/17 11:00:09 mroi Exp $ + * $Id: video_out_dxr3.h,v 1.7 2002/07/17 14:58:12 mroi Exp $ */ #ifdef HAVE_CONFIG_H @@ -87,11 +87,10 @@ typedef struct dxr3_driver_s { em8300_bcs_t bcs; encoder_data_t *enc; /* encoder data */ - int format; /* color format */ int video_iheight; /* input height (before adding black bars) */ int video_oheight; /* output height (after adding bars) */ int video_width; - int video_aspect; + int video_ratio; int top_bar; /* the height of the upper black bar */ int need_redraw; /* the image on screen needs redrawing */ int need_update; /* the mpeg encoder needs to be updated */ @@ -114,8 +113,8 @@ typedef struct dxr3_driver_s { typedef struct dxr3_frame_s { vo_frame_t vo_frame; - int width, iheight, oheight; - int pan_scan; + int oheight; + int aspect, pan_scan; uint8_t *mem; /* allocated for YV12 or YUY2 buffers */ uint8_t *real_base[3]; /* yuv/yuy2 buffers in mem aligned on 16 */ int swap_fields; /* shifts Y buffer one line to exchange odd/even lines */ |