diff options
Diffstat (limited to 'src/post/planar')
-rw-r--r-- | src/post/planar/.hgignore (renamed from src/post/planar/.cvsignore) | 0 | ||||
-rw-r--r-- | src/post/planar/Makefile.am | 2 | ||||
-rw-r--r-- | src/post/planar/eq.c | 4 | ||||
-rw-r--r-- | src/post/planar/eq2.c | 10 | ||||
-rw-r--r-- | src/post/planar/expand.c | 111 | ||||
-rw-r--r-- | src/post/planar/noise.c | 8 |
6 files changed, 111 insertions, 24 deletions
diff --git a/src/post/planar/.cvsignore b/src/post/planar/.hgignore index 7d926a554..7d926a554 100644 --- a/src/post/planar/.cvsignore +++ b/src/post/planar/.hgignore diff --git a/src/post/planar/Makefile.am b/src/post/planar/Makefile.am index 9f8ffed45..cc0647808 100644 --- a/src/post/planar/Makefile.am +++ b/src/post/planar/Makefile.am @@ -23,7 +23,7 @@ lib_LTLIBRARIES = xineplug_post_planar.la xineplug_post_planar_la_SOURCES = planar.c invert.c expand.c fill.c boxblur.c \ denoise3d.c eq.c eq2.c unsharp.c pp.c noise.c -xineplug_post_planar_la_LIBADD = $(XINE_LIB) $(postproc_lib) -lm $(THREAD_LIBS) +xineplug_post_planar_la_LIBADD = $(XINE_LIB) $(postproc_lib) -lm $(PTHREAD_LIBS) xineplug_post_planar_la_LDFLAGS = -avoid-version -module \ @IMPURE_TEXT_LDFLAGS@ xineplug_post_planar_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) diff --git a/src/post/planar/eq.c b/src/post/planar/eq.c index 50fd03b7f..8c7b00e4b 100644 --- a/src/post/planar/eq.c +++ b/src/post/planar/eq.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: eq.c,v 1.14 2006/02/04 14:06:52 miguelfreitas Exp $ + * $Id: eq.c,v 1.15 2007/03/22 23:32:05 dgp85 Exp $ * * mplayer's eq (soft video equalizer) * Copyright (C) Richard Felker @@ -52,7 +52,7 @@ static void process_MMX(unsigned char *dest, int dstride, unsigned char *src, in "movq (%6), %%mm4 \n\t" "pxor %%mm0, %%mm0 \n\t" "movl %4, %%eax\n\t" - ".balign 16 \n\t" + ASMALIGN(4) "1: \n\t" "movq (%0), %%mm1 \n\t" "movq (%0), %%mm2 \n\t" diff --git a/src/post/planar/eq2.c b/src/post/planar/eq2.c index 806a4ea6c..38f9117db 100644 --- a/src/post/planar/eq2.c +++ b/src/post/planar/eq2.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: eq2.c,v 1.16 2006/03/26 14:45:41 valtri Exp $ + * $Id: eq2.c,v 1.18 2007/03/22 23:32:05 dgp85 Exp $ * * mplayer's eq2 (soft video equalizer) * Software equalizer (brightness, contrast, gamma, saturation) @@ -128,7 +128,7 @@ void affine_1d_MMX (eq2_param_t *par, unsigned char *dst, unsigned char *src, "movq (%6), %%mm4 \n\t" "pxor %%mm0, %%mm0 \n\t" "movl %4, %%eax\n\t" - ".balign 16 \n\t" + ASMALIGN(4) "1: \n\t" "movq (%0), %%mm1 \n\t" "movq (%0), %%mm2 \n\t" @@ -599,12 +599,12 @@ static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream) pthread_mutex_lock (&this->lock); for (i = 0; i < 3; i++) { - int height; + int height, width; height = (i==0) ? frame->height : frame->height/2; - + width = (i==0) ? frame->width : frame->width/2; if (eq2->param[i].adjust != NULL) { eq2->param[i].adjust (&eq2->param[i], out_frame->base[i], yv12_frame->base[i], - frame->width, height, out_frame->pitches[i], yv12_frame->pitches[i]); + width, height, out_frame->pitches[i], yv12_frame->pitches[i]); } else { xine_fast_memcpy(out_frame->base[i],yv12_frame->base[i], diff --git a/src/post/planar/expand.c b/src/post/planar/expand.c index 51cc4eac2..cf288921f 100644 --- a/src/post/planar/expand.c +++ b/src/post/planar/expand.c @@ -21,7 +21,8 @@ * * expand video filter by James Stembridge 24/05/2003 * improved by Michael Roitzsch - * + * centre_crop_out_mode by Reinhard Nissl + * * based on invert.c * */ @@ -52,6 +53,11 @@ * This way, the decoder (or any other post plugin up the tree) will only * see the frame area between the black bars and by that modify the * enlarged version directly. No need for later copying. + * + * When centre_crop_out_mode is enabled, the plugin will detect the black + * bars to the left and right of the image and will then set up cropping + * to efficiently remove the black border around the 4:3 image, which the + * plugin would produce otherwise for this case. */ @@ -63,6 +69,7 @@ typedef struct expand_parameters_s { int enable_automatic_shift; int overlay_y_offset; double aspect; + int centre_cut_out_mode; } expand_parameters_t; START_PARAM_DESCR(expand_parameters_t) @@ -72,6 +79,8 @@ PARAM_ITEM(POST_PARAM_TYPE_INT, overlay_y_offset, NULL, -500, 500, 0, "manually shift the overlay vertically") PARAM_ITEM(POST_PARAM_TYPE_DOUBLE, aspect, NULL, 1.0, 3.5, 0, "target aspect ratio") +PARAM_ITEM(POST_PARAM_TYPE_BOOL, centre_cut_out_mode, NULL, 0, 1, 0, + "cut out centred 4:3 image contained in 16:9 frame") END_PARAM_DESCR(expand_param_descr) typedef struct post_expand_s { @@ -83,6 +92,8 @@ typedef struct post_expand_s { int overlay_y_offset; double aspect; int top_bar_height; + int centre_cut_out_mode; + int cropping_active; } post_expand_t; /* plugin class functions */ @@ -106,6 +117,8 @@ static char *expand_get_help (void); static vo_frame_t *expand_get_frame(xine_video_port_t *port_gen, uint32_t width, uint32_t height, double ratio, int format, int flags); + +/* replaced vo_frame functions */ static int expand_draw(vo_frame_t *frame, xine_stream_t *stream); /* overlay manager intercept check */ @@ -153,6 +166,8 @@ static post_plugin_t *expand_open_plugin(post_class_t *class_gen, int inputs, this->enable_automatic_shift = 0; this->overlay_y_offset = 0; this->aspect = 4.0 / 3.0; + this->centre_cut_out_mode = 0; + this->cropping_active = 0; port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output); port->new_port.get_frame = expand_get_frame; @@ -166,8 +181,8 @@ static post_plugin_t *expand_open_plugin(post_class_t *class_gen, int inputs, input_param->data = &post_api; xine_list_push_back(this->post.input, input_param); - input->xine_in.name = "video"; - output->xine_out.name = "expanded video"; + input->xine_in.name = "video"; + output->xine_out.name = "expanded video"; this->post.xine_post.video_input[0] = &port->new_port; @@ -214,6 +229,8 @@ static int expand_set_parameters(xine_post_t *this_gen, void *param_gen) this->enable_automatic_shift = param->enable_automatic_shift; this->overlay_y_offset = param->overlay_y_offset; this->aspect = param->aspect; + this->centre_cut_out_mode = param->centre_cut_out_mode; + return 1; } @@ -225,6 +242,8 @@ static int expand_get_parameters(xine_post_t *this_gen, void *param_gen) param->enable_automatic_shift = this->enable_automatic_shift; param->overlay_y_offset = this->overlay_y_offset; param->aspect = this->aspect; + param->centre_cut_out_mode = this->centre_cut_out_mode; + return 1; } @@ -238,22 +257,86 @@ static char *expand_get_help(void) { " Enable_automatic_shift: Enable automatic overlay shifting\n" " Overlay_y_offset: Manually shift the overlay vertically\n" " aspect: The target aspect ratio (default 4:3)\n" + " Centre_cut_out_mode: extracts 4:3 image contained in 16:9 frame\n" "\n" ); } +static int is_pixel_black(vo_frame_t *frame, int x, int y) +{ + int Y = 0x00, Cr = 0x00, Cb = 0x00; + + if (x < 0) x = 0; + if (x >= frame->width) x = frame->width - 1; + if (y < 0) y = 0; + if (y >= frame->height) y = frame->height - 1; + + switch (frame->format) + { + case XINE_IMGFMT_YV12: + Y = *(frame->base[ 0 ] + frame->pitches[ 0 ] * y + x); + Cr = *(frame->base[ 1 ] + frame->pitches[ 1 ] * y / 2 + x / 2); + Cb = *(frame->base[ 2 ] + frame->pitches[ 2 ] * y / 2 + x / 2); + break; + + case XINE_IMGFMT_YUY2: + Y = *(frame->base[ 0 ] + frame->pitches[ 0 ] * y + x * 2 + 0); + x &= ~1; + Cr = *(frame->base[ 0 ] + frame->pitches[ 0 ] * y + x * 2 + 1); + Cb = *(frame->base[ 0 ] + frame->pitches[ 0 ] * y + x * 2 + 3); + break; + } + + return (Y == 0x10 && Cr == 0x80 && Cb == 0x80); +} + + static int expand_draw(vo_frame_t *frame, xine_stream_t *stream) { - post_video_port_t *port = (post_video_port_t *)frame->port; - post_expand_t *this = (post_expand_t *)port->post; - int skip; - - frame->ratio = this->aspect; - _x_post_frame_copy_down(frame, frame->next); - skip = frame->next->draw(frame->next, stream); - _x_post_frame_copy_up(frame, frame->next); - return skip; + post_video_port_t *port = (post_video_port_t *)frame->port; + post_expand_t *this = (post_expand_t *)port->post; + int skip; + + if (this->centre_cut_out_mode && !frame->bad_frame) + { + /* expected area of inner 4:3 image */ + int centre_width = frame->width * (9 * 4) / (16 * 3); + int centre_left = (frame->width - centre_width ) / 2; + + /* centre point for detecting a black frame */ + int centre_x = frame->width / 2; + int centre_y = frame->height / 2; + + /* ignore a black frame as it could lead to wrong results */ + if (!is_pixel_black(frame, centre_x, centre_y)) + { + /* coordinates for testing black border near the centre area */ + int test_left = centre_left - 16; + int test_right = centre_left + 16 + centre_width; + + /* enable cropping when these pixels are black */ + this->cropping_active = is_pixel_black(frame, test_left, centre_y) + && is_pixel_black(frame, test_right, centre_y); + } + + /* crop frame */ + if (this->centre_cut_out_mode && this->cropping_active) { + frame->crop_left += centre_left; + frame->crop_right += centre_left; + + /* get_frame() allocated an extra high frame */ + frame->crop_top += (frame->next->height - frame->height) / 2; + frame->crop_bottom += (frame->next->height - frame->height) / 2; + } + } + + frame->ratio = this->aspect; + _x_post_frame_copy_down(frame, frame->next); + skip = frame->next->draw(frame->next, stream); + _x_post_frame_copy_up(frame, frame->next); + + return skip; } @@ -338,6 +421,10 @@ static vo_frame_t *expand_get_frame(xine_video_port_t *port_gen, uint32_t width, static int expand_intercept_ovl(post_video_port_t *port) { + post_expand_t *this = (post_expand_t *)port->post; + + if (this->centre_cut_out_mode && this->cropping_active) return 0; + /* we always intercept overlay manager */ return 1; } diff --git a/src/post/planar/noise.c b/src/post/planar/noise.c index 1b46825db..154d5f8cc 100644 --- a/src/post/planar/noise.c +++ b/src/post/planar/noise.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: noise.c,v 1.3 2006/03/26 14:45:41 valtri Exp $ + * $Id: noise.c,v 1.4 2007/03/22 23:32:05 dgp85 Exp $ * * mplayer's noise filter, ported by Jason Tackaberry. Original filter * is copyright 2002 Michael Niedermayer <michaelni@gmx.at> @@ -159,7 +159,7 @@ static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int "pcmpeqb %%mm7, %%mm7 \n\t" "psllw $15, %%mm7 \n\t" "packsswb %%mm7, %%mm7 \n\t" - ".balign 16 \n\t" + ASMALIGN(4) "1: \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t" @@ -186,7 +186,7 @@ static inline void lineNoise_MMX2(uint8_t *dst, uint8_t *src, int8_t *noise, int "pcmpeqb %%mm7, %%mm7 \n\t" "psllw $15, %%mm7 \n\t" "packsswb %%mm7, %%mm7 \n\t" - ".balign 16 \n\t" + ASMALIGN(4) "1: \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t" @@ -225,7 +225,7 @@ static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t asm volatile( "mov %5, %%"REG_a" \n\t" - ".balign 16 \n\t" + ASMALIGN(4) "1: \n\t" "movq (%1, %%"REG_a"), %%mm1 \n\t" "movq (%0, %%"REG_a"), %%mm0 \n\t" |