summaryrefslogtreecommitdiff
path: root/src/post/planar
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2004-01-07 19:52:42 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2004-01-07 19:52:42 +0000
commit5e25dd8a73f15e8116da5ce8fda14f8f671473ce (patch)
treed47d0a7c256fe25905f4fcd66302dbee68c5faa9 /src/post/planar
parent6f75f546fd6e928245911e8ebcea680a7c9046b6 (diff)
downloadxine-lib-5e25dd8a73f15e8116da5ce8fda14f8f671473ce.tar.gz
xine-lib-5e25dd8a73f15e8116da5ce8fda14f8f671473ce.tar.bz2
the new, refined post plugin architecture
* post plugins are now much safer (fewer races/inconsistencies) and easier to write * all post plugins are ported to the new architecture (and should work) * ports can now be opened and closed with a NULL stream CVS patchset: 6007 CVS date: 2004/01/07 19:52:42
Diffstat (limited to 'src/post/planar')
-rw-r--r--src/post/planar/boxblur.c181
-rw-r--r--src/post/planar/denoise3d.c188
-rw-r--r--src/post/planar/eq.c174
-rw-r--r--src/post/planar/eq2.c177
-rw-r--r--src/post/planar/expand.c333
-rw-r--r--src/post/planar/invert.c156
-rw-r--r--src/post/planar/planar.c18
-rwxr-xr-xsrc/post/planar/pp.c188
-rw-r--r--src/post/planar/unsharp.c171
9 files changed, 344 insertions, 1242 deletions
diff --git a/src/post/planar/boxblur.c b/src/post/planar/boxblur.c
index 1504773c1..f85b6ad31 100644
--- a/src/post/planar/boxblur.c
+++ b/src/post/planar/boxblur.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: boxblur.c,v 1.11 2003/12/07 15:33:26 miguelfreitas Exp $
+ * $Id: boxblur.c,v 1.12 2004/01/07 19:52:42 mroi Exp $
*
* mplayer's boxblur
* Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
@@ -65,12 +65,10 @@ struct post_plugin_boxblur_s {
post_plugin_t post;
/* private data */
- xine_video_port_t *vo_port;
- xine_stream_t *stream;
-
boxblur_parameters_t params;
+ xine_post_in_t params_input;
- pthread_mutex_t lock;
+ pthread_mutex_t lock;
};
@@ -119,12 +117,6 @@ static xine_post_api_t post_api = {
get_help,
};
-typedef struct post_boxblur_out_s post_boxblur_out_t;
-struct post_boxblur_out_s {
- xine_post_out_t xine_out;
-
- post_plugin_boxblur_t *plugin;
-};
/* plugin class functions */
static post_plugin_t *boxblur_open_plugin(post_class_t *class_gen, int inputs,
@@ -137,15 +129,8 @@ static void boxblur_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void boxblur_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int boxblur_rewire(xine_post_out_t *output, void *data);
-
-/* replaced video_port functions */
-static void boxblur_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *boxblur_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
-static void boxblur_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+/* frame intercept check */
+static int boxblur_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
/* replaced vo_frame functions */
static int boxblur_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -171,61 +156,40 @@ static post_plugin_t *boxblur_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_boxblur_t *this = (post_plugin_boxblur_t *)malloc(sizeof(post_plugin_boxblur_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_api = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_boxblur_out_t *output = (post_boxblur_out_t *)malloc(sizeof(post_boxblur_out_t));
- post_video_port_t *port;
+ post_plugin_boxblur_t *this = (post_plugin_boxblur_t *)xine_xmalloc(sizeof(post_plugin_boxblur_t));
+ post_in_t *input;
+ xine_post_in_t *input_api;
+ post_out_t *output;
+ post_video_port_t *port;
- if (!this || !input || !input_api || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_api);
- free(output);
return NULL;
}
-
- this->stream = NULL;
-
+
+ _x_post_init(&this->post, 0, 1);
+
this->params.luma_radius = 2;
this->params.luma_power = 1;
this->params.chroma_radius = -1;
this->params.chroma_power = -1;
- pthread_mutex_init (&this->lock, NULL);
-
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = boxblur_open;
- port->port.get_frame = boxblur_get_frame;
- port->port.close = boxblur_close;
-
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
+ pthread_mutex_init(&this->lock, NULL);
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->intercept_frame = boxblur_intercept_frame;
+ port->new_frame->draw = boxblur_draw;
+
+ input_api = &this->params_input;
input_api->name = "parameters";
input_api->type = XINE_POST_DATA_PARAMETERS;
input_api->data = &post_api;
+ xine_list_append_content(this->post.input, input_api);
+ input->xine_in.name = "video";
output->xine_out.name = "boxblured video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = boxblur_rewire;
- output->plugin = this;
-
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
-
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_api);
- xine_list_append_content(this->post.output, output);
+ this->post.xine_post.video_input[0] = &port->new_port;
this->post.dispose = boxblur_dispose;
@@ -251,81 +215,17 @@ static void boxblur_class_dispose(post_class_t *class_gen)
static void boxblur_dispose(post_plugin_t *this_gen)
{
post_plugin_boxblur_t *this = (post_plugin_boxblur_t *)this_gen;
- post_boxblur_out_t *output = (post_boxblur_out_t *)xine_list_first_content(this->post.output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (this->stream)
- port->close(port, this->stream);
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-
-static int boxblur_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_boxblur_out_t *output = (post_boxblur_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
- if (!data)
- return 0;
-
- if (output->plugin->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->plugin->stream);
- new_port->open(new_port, output->plugin->stream);
+ if (_x_post_dispose(this_gen)) {
+ pthread_mutex_destroy(&this->lock);
+ free(this);
}
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
-
- return 1;
}
-static void boxblur_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_boxblur_t *this = (post_plugin_boxblur_t *)port->post;
- this->stream = stream;
- port->original_port->open(port->original_port, stream);
-}
-static vo_frame_t *boxblur_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
+static int boxblur_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = boxblur_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
-
- return frame;
-}
-
-static void boxblur_close(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_boxblur_t *this = (post_plugin_boxblur_t *)port->post;
-
- this->stream = NULL;
-
- port->original_port->close(port->original_port, stream);
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
@@ -413,8 +313,6 @@ static int boxblur_draw(vo_frame_t *frame, xine_stream_t *stream)
int cw, ch;
int skip;
- _x_post_restore_video_frame(frame, port);
-
if( !frame->bad_frame ) {
@@ -423,11 +321,9 @@ static int boxblur_draw(vo_frame_t *frame, xine_stream_t *stream)
yv12_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
-
- yv12_frame->pts = frame->pts;
- yv12_frame->duration = frame->duration;
- _x_extra_info_merge(yv12_frame->extra_info, frame->extra_info);
-
+
+ _x_post_frame_copy_up(frame, yv12_frame);
+
yuy2_to_yv12(frame->base[0], frame->pitches[0],
yv12_frame->base[0], yv12_frame->pitches[0],
yv12_frame->base[1], yv12_frame->pitches[1],
@@ -443,11 +339,7 @@ static int boxblur_draw(vo_frame_t *frame, xine_stream_t *stream)
out_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
-
- _x_extra_info_merge(out_frame->extra_info, frame->extra_info);
-
- out_frame->pts = frame->pts;
- out_frame->duration = frame->duration;
+ _x_post_frame_copy_up(frame, out_frame);
pthread_mutex_lock (&this->lock);
@@ -475,16 +367,17 @@ static int boxblur_draw(vo_frame_t *frame, xine_stream_t *stream)
pthread_mutex_unlock (&this->lock);
skip = out_frame->draw(out_frame, stream);
-
- frame->vpts = out_frame->vpts;
+
+ _x_post_frame_copy_down(frame, out_frame);
out_frame->free(out_frame);
yv12_frame->free(yv12_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
-
return skip;
}
diff --git a/src/post/planar/denoise3d.c b/src/post/planar/denoise3d.c
index 36ba6490c..e4d8d65b2 100644
--- a/src/post/planar/denoise3d.c
+++ b/src/post/planar/denoise3d.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: denoise3d.c,v 1.11 2003/12/07 15:33:26 miguelfreitas Exp $
+ * $Id: denoise3d.c,v 1.12 2004/01/07 19:52:42 mroi Exp $
*
* mplayer's denoise3d
* Copyright (C) 2003 Daniel Moreno <comac@comac.darktech.org>
@@ -70,16 +70,14 @@ struct post_plugin_denoise3d_s {
post_plugin_t post;
/* private data */
- xine_video_port_t *vo_port;
- xine_stream_t *stream;
-
denoise3d_parameters_t params;
+ xine_post_in_t params_input;
- int Coefs[4][512];
- unsigned char Line[MAX_LINE_WIDTH];
- vo_frame_t *prev_frame;
+ int Coefs[4][512];
+ unsigned char Line[MAX_LINE_WIDTH];
+ vo_frame_t *prev_frame;
- pthread_mutex_t lock;
+ pthread_mutex_t lock;
};
#define ABS(A) ( (A) > 0 ? (A) : -(A) )
@@ -156,12 +154,6 @@ static xine_post_api_t post_api = {
get_help,
};
-typedef struct post_denoise3d_out_s post_denoise3d_out_t;
-struct post_denoise3d_out_s {
- xine_post_out_t xine_out;
-
- post_plugin_denoise3d_t *plugin;
-};
/* plugin class functions */
static post_plugin_t *denoise3d_open_plugin(post_class_t *class_gen, int inputs,
@@ -174,16 +166,12 @@ static void denoise3d_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void denoise3d_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int denoise3d_rewire(xine_post_out_t *output, void *data);
-
-/* replaced video_port functions */
-static void denoise3d_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *denoise3d_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
+/* replaced video_port functios */
static void denoise3d_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+/* frame intercept check */
+static int denoise3d_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
+
/* replaced vo_frame functions */
static int denoise3d_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -208,61 +196,41 @@ static post_plugin_t *denoise3d_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_denoise3d_t *this = (post_plugin_denoise3d_t *)malloc(sizeof(post_plugin_denoise3d_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_api = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_denoise3d_out_t *output = (post_denoise3d_out_t *)malloc(sizeof(post_denoise3d_out_t));
- post_video_port_t *port;
+ post_plugin_denoise3d_t *this = (post_plugin_denoise3d_t *)xine_xmalloc(sizeof(post_plugin_denoise3d_t));
+ post_in_t *input;
+ xine_post_in_t *input_api;
+ post_out_t *output;
+ post_video_port_t *port;
- if (!this || !input || !input_api || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_api);
- free(output);
return NULL;
}
- this->stream = NULL;
-
+ _x_post_init(&this->post, 0, 1);
+
this->params.luma = PARAM1_DEFAULT;
this->params.chroma = PARAM2_DEFAULT;
this->params.time = PARAM3_DEFAULT;
this->prev_frame = NULL;
- pthread_mutex_init (&this->lock, NULL);
+ pthread_mutex_init(&this->lock, NULL);
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = denoise3d_open;
- port->port.get_frame = denoise3d_get_frame;
- port->port.close = denoise3d_close;
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->new_port.close = denoise3d_close;
+ port->intercept_frame = denoise3d_intercept_frame;
+ port->new_frame->draw = denoise3d_draw;
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
-
+ input_api = &this->params_input;
input_api->name = "parameters";
input_api->type = XINE_POST_DATA_PARAMETERS;
input_api->data = &post_api;
+ xine_list_append_content(this->post.input, input_api);
+ input->xine_in.name = "video";
output->xine_out.name = "denoise3d video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = denoise3d_rewire;
- output->plugin = this;
-
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
-
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_api);
- xine_list_append_content(this->post.output, output);
+ this->post.xine_post.video_input[0] = &port->new_port;
this->post.dispose = denoise3d_dispose;
@@ -290,72 +258,13 @@ static void denoise3d_class_dispose(post_class_t *class_gen)
static void denoise3d_dispose(post_plugin_t *this_gen)
{
post_plugin_denoise3d_t *this = (post_plugin_denoise3d_t *)this_gen;
- post_denoise3d_out_t *output = (post_denoise3d_out_t *)xine_list_first_content(this->post.output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (this->stream)
- port->close(port, this->stream);
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-
-static int denoise3d_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_denoise3d_out_t *output = (post_denoise3d_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
- if (!data)
- return 0;
-
- if (output->plugin->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->plugin->stream);
- new_port->open(new_port, output->plugin->stream);
+ if (_x_post_dispose(this_gen)) {
+ pthread_mutex_destroy(&this->lock);
+ free(this);
}
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
-
- return 1;
}
-static void denoise3d_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_denoise3d_t *this = (post_plugin_denoise3d_t *)port->post;
- this->stream = stream;
- port->original_port->open(port->original_port, stream);
-}
-
-static vo_frame_t *denoise3d_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = denoise3d_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
-
- return frame;
-}
static void denoise3d_close(xine_video_port_t *port_gen, xine_stream_t *stream)
{
@@ -367,11 +276,18 @@ static void denoise3d_close(xine_video_port_t *port_gen, xine_stream_t *stream)
this->prev_frame = NULL;
}
- this->stream = NULL;
-
port->original_port->close(port->original_port, stream);
+ port->stream = NULL;
+ _x_post_dec_usage(port);
+}
+
+
+static int denoise3d_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
+{
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
+
#define LowPass(Prev, Curr, Coef) (((Prev)*Coef[Prev - Curr] + (Curr)*(65536-(Coef[Prev - Curr]))) / 65536)
static void deNoise(unsigned char *Frame,
@@ -427,8 +343,6 @@ static int denoise3d_draw(vo_frame_t *frame, xine_stream_t *stream)
int cw, ch;
int skip;
- _x_post_restore_video_frame(frame, port);
-
if( !frame->bad_frame ) {
@@ -438,9 +352,7 @@ static int denoise3d_draw(vo_frame_t *frame, xine_stream_t *stream)
yv12_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
- yv12_frame->pts = frame->pts;
- yv12_frame->duration = frame->duration;
- _x_extra_info_merge(yv12_frame->extra_info, frame->extra_info);
+ _x_post_frame_copy_up(frame, yv12_frame);
yuy2_to_yv12(frame->base[0], frame->pitches[0],
yv12_frame->base[0], yv12_frame->pitches[0],
@@ -457,11 +369,7 @@ static int denoise3d_draw(vo_frame_t *frame, xine_stream_t *stream)
out_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
-
- _x_extra_info_merge(out_frame->extra_info, frame->extra_info);
-
- out_frame->pts = frame->pts;
- out_frame->duration = frame->duration;
+ _x_post_frame_copy_up(frame, out_frame);
pthread_mutex_lock (&this->lock);
@@ -492,18 +400,24 @@ static int denoise3d_draw(vo_frame_t *frame, xine_stream_t *stream)
skip = out_frame->draw(out_frame, stream);
- frame->vpts = out_frame->vpts;
+ _x_post_frame_copy_down(frame, out_frame);
out_frame->free(out_frame);
if(this->prev_frame)
this->prev_frame->free(this->prev_frame);
- this->prev_frame = yv12_frame;
+ if(port->stream)
+ this->prev_frame = yv12_frame;
+ else
+ /* do not keep this frame when no stream is connected to us,
+ * otherwise, this frame might never get freed */
+ yv12_frame->free(yv12_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
-
return skip;
}
diff --git a/src/post/planar/eq.c b/src/post/planar/eq.c
index e9c413af0..7925d3e31 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.10 2003/12/07 15:33:26 miguelfreitas Exp $
+ * $Id: eq.c,v 1.11 2004/01/07 19:52:42 mroi Exp $
*
* mplayer's eq (soft video equalizer)
* Copyright (C) Richard Felker
@@ -148,10 +148,8 @@ struct post_plugin_eq_s {
post_plugin_t post;
/* private data */
- xine_video_port_t *vo_port;
- xine_stream_t *stream;
-
- eq_parameters_t params;
+ eq_parameters_t params;
+ xine_post_in_t params_input;
pthread_mutex_t lock;
};
@@ -207,12 +205,6 @@ static xine_post_api_t post_api = {
get_help,
};
-typedef struct post_eq_out_s post_eq_out_t;
-struct post_eq_out_s {
- xine_post_out_t xine_out;
-
- post_plugin_eq_t *plugin;
-};
/* plugin class functions */
static post_plugin_t *eq_open_plugin(post_class_t *class_gen, int inputs,
@@ -225,17 +217,12 @@ static void eq_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void eq_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int eq_rewire(xine_post_out_t *output, void *data);
-
/* replaced video_port functions */
static int eq_get_property(xine_video_port_t *port_gen, int property);
static int eq_set_property(xine_video_port_t *port_gen, int property, int value);
-static void eq_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *eq_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
-static void eq_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+
+/* frame intercept check */
+static int eq_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
/* replaced vo_frame functions */
static int eq_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -261,67 +248,46 @@ static post_plugin_t *eq_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_eq_t *this = (post_plugin_eq_t *)malloc(sizeof(post_plugin_eq_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_api = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_eq_out_t *output = (post_eq_out_t *)malloc(sizeof(post_eq_out_t));
+ post_plugin_eq_t *this = (post_plugin_eq_t *)xine_xmalloc(sizeof(post_plugin_eq_t));
+ post_in_t *input;
+ xine_post_in_t *input_api;
+ post_out_t *output;
post_video_port_t *port;
- if (!this || !input || !input_api || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_api);
- free(output);
return NULL;
}
- this->stream = NULL;
-
process = process_C;
#ifdef ARCH_X86
if( xine_mm_accel() & MM_ACCEL_X86_MMX )
process = process_MMX;
#endif
+ _x_post_init(&this->post, 0, 1);
+
this->params.brightness = 0;
this->params.contrast = 0;
pthread_mutex_init (&this->lock, NULL);
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = eq_open;
- port->port.get_frame = eq_get_frame;
- port->port.close = eq_close;
- port->port.get_property = eq_get_property;
- port->port.set_property = eq_set_property;
-
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->new_port.get_property = eq_get_property;
+ port->new_port.set_property = eq_set_property;
+ port->intercept_frame = eq_intercept_frame;
+ port->new_frame->draw = eq_draw;
+ input_api = &this->params_input;
input_api->name = "parameters";
input_api->type = XINE_POST_DATA_PARAMETERS;
input_api->data = &post_api;
+ xine_list_append_content(this->post.input, input_api);
+ input->xine_in.name = "video";
output->xine_out.name = "eqd video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = eq_rewire;
- output->plugin = this;
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
-
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
-
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_api);
- xine_list_append_content(this->post.output, output);
+ this->post.xine_post.video_input[0] = &port->new_port;
this->post.dispose = eq_dispose;
@@ -347,43 +313,14 @@ static void eq_class_dispose(post_class_t *class_gen)
static void eq_dispose(post_plugin_t *this_gen)
{
post_plugin_eq_t *this = (post_plugin_eq_t *)this_gen;
- post_eq_out_t *output = (post_eq_out_t *)xine_list_first_content(this->post.output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (this->stream)
- port->close(port, this->stream);
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-
-static int eq_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_eq_out_t *output = (post_eq_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
-
- if (!data)
- return 0;
- if (output->plugin->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->plugin->stream);
- new_port->open(new_port, output->plugin->stream);
+ if (_x_post_dispose(this_gen)) {
+ pthread_mutex_destroy(&this->lock);
+ free(this);
}
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
-
- return 1;
}
+
static int eq_get_property(xine_video_port_t *port_gen, int property) {
post_video_port_t *port = (post_video_port_t *)port_gen;
post_plugin_eq_t *this = (post_plugin_eq_t *)port->post;
@@ -412,49 +349,13 @@ static int eq_set_property(xine_video_port_t *port_gen, int property, int value)
return port->original_port->set_property(port->original_port, property, value);
}
-static void eq_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_eq_t *this = (post_plugin_eq_t *)port->post;
- this->stream = stream;
- port->original_port->open(port->original_port, stream);
-}
-
-static vo_frame_t *eq_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = eq_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
-
- return frame;
-}
-static void eq_close(xine_video_port_t *port_gen, xine_stream_t *stream)
+static int eq_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_eq_t *this = (post_plugin_eq_t *)port->post;
-
- this->stream = NULL;
-
- port->original_port->close(port->original_port, stream);
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
-
-
static int eq_draw(vo_frame_t *frame, xine_stream_t *stream)
{
post_video_port_t *port = (post_video_port_t *)frame->port;
@@ -463,8 +364,6 @@ static int eq_draw(vo_frame_t *frame, xine_stream_t *stream)
vo_frame_t *yv12_frame;
int skip;
- _x_post_restore_video_frame(frame, port);
-
if( !frame->bad_frame &&
((this->params.brightness != 0) || (this->params.contrast != 0)) ) {
@@ -474,9 +373,7 @@ static int eq_draw(vo_frame_t *frame, xine_stream_t *stream)
yv12_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
- yv12_frame->pts = frame->pts;
- yv12_frame->duration = frame->duration;
- _x_extra_info_merge(yv12_frame->extra_info, frame->extra_info);
+ _x_post_frame_copy_up(frame, yv12_frame);
yuy2_to_yv12(frame->base[0], frame->pitches[0],
yv12_frame->base[0], yv12_frame->pitches[0],
@@ -493,11 +390,7 @@ static int eq_draw(vo_frame_t *frame, xine_stream_t *stream)
out_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
-
- _x_extra_info_merge(out_frame->extra_info, frame->extra_info);
-
- out_frame->pts = frame->pts;
- out_frame->duration = frame->duration;
+ _x_post_frame_copy_up(frame, out_frame);
pthread_mutex_lock (&this->lock);
@@ -514,15 +407,16 @@ static int eq_draw(vo_frame_t *frame, xine_stream_t *stream)
skip = out_frame->draw(out_frame, stream);
- frame->vpts = out_frame->vpts;
+ _x_post_frame_copy_down(frame, out_frame);
out_frame->free(out_frame);
yv12_frame->free(yv12_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
-
return skip;
}
diff --git a/src/post/planar/eq2.c b/src/post/planar/eq2.c
index e4db57b24..005fc07db 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.12 2003/12/07 15:33:26 miguelfreitas Exp $
+ * $Id: eq2.c,v 1.13 2004/01/07 19:52:42 mroi Exp $
*
* mplayer's eq2 (soft video equalizer)
* Software equalizer (brightness, contrast, gamma, saturation)
@@ -308,10 +308,9 @@ struct post_plugin_eq2_s {
post_plugin_t post;
/* private data */
- xine_video_port_t *vo_port;
- xine_stream_t *stream;
-
eq2_parameters_t params;
+ xine_post_in_t params_input;
+
vf_eq2_t eq2;
pthread_mutex_t lock;
@@ -387,12 +386,6 @@ static xine_post_api_t post_api = {
get_help,
};
-typedef struct post_eq2_out_s post_eq2_out_t;
-struct post_eq2_out_s {
- xine_post_out_t xine_out;
-
- post_plugin_eq2_t *plugin;
-};
/* plugin class functions */
static post_plugin_t *eq2_open_plugin(post_class_t *class_gen, int inputs,
@@ -405,17 +398,12 @@ static void eq2_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void eq2_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int eq2_rewire(xine_post_out_t *output, void *data);
-
/* replaced video_port functions */
static int eq2_get_property(xine_video_port_t *port_gen, int property);
static int eq2_set_property(xine_video_port_t *port_gen, int property, int value);
-static void eq2_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *eq2_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
-static void eq2_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+
+/* frame intercept check */
+static int eq2_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
/* replaced vo_frame functions */
static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -441,23 +429,20 @@ static post_plugin_t *eq2_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_eq2_t *this = (post_plugin_eq2_t *)malloc(sizeof(post_plugin_eq2_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_api = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_eq2_out_t *output = (post_eq2_out_t *)malloc(sizeof(post_eq2_out_t));
+ post_plugin_eq2_t *this = (post_plugin_eq2_t *)xine_xmalloc(sizeof(post_plugin_eq2_t));
+ post_in_t *input;
+ xine_post_in_t *input_api;
+ post_out_t *output;
post_video_port_t *port;
- vf_eq2_t *eq2;
+ vf_eq2_t *eq2;
int i;
- if (!this || !input || !input_api || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_api);
- free(output);
return NULL;
}
-
- this->stream = NULL;
+
+ _x_post_init(&this->post, 0, 1);
eq2 = &this->eq2;
for (i = 0; i < 3; i++) {
@@ -480,42 +465,24 @@ static post_plugin_t *eq2_open_plugin(post_class_t *class_gen, int inputs,
eq2->ggamma = this->params.ggamma = 1.0;
eq2->bgamma = this->params.bgamma = 1.0;
- pthread_mutex_init (&this->lock, NULL);
+ pthread_mutex_init(&this->lock, NULL);
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = eq2_open;
- port->port.get_frame = eq2_get_frame;
- port->port.close = eq2_close;
- port->port.get_property = eq2_get_property;
- port->port.set_property = eq2_set_property;
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->new_port.get_property = eq2_get_property;
+ port->new_port.set_property = eq2_set_property;
+ port->intercept_frame = eq2_intercept_frame;
+ port->new_frame->draw = eq2_draw;
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
-
+ input_api = &this->params_input;
input_api->name = "parameters";
input_api->type = XINE_POST_DATA_PARAMETERS;
input_api->data = &post_api;
+ xine_list_append_content(this->post.input, input_api);
+ input->xine_in.name = "video";
output->xine_out.name = "eqd video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = eq2_rewire;
- output->plugin = this;
-
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
-
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_api);
- xine_list_append_content(this->post.output, output);
+ this->post.xine_post.video_input[0] = &port->new_port;
this->post.dispose = eq2_dispose;
@@ -543,43 +510,14 @@ static void eq2_class_dispose(post_class_t *class_gen)
static void eq2_dispose(post_plugin_t *this_gen)
{
post_plugin_eq2_t *this = (post_plugin_eq2_t *)this_gen;
- post_eq2_out_t *output = (post_eq2_out_t *)xine_list_first_content(this->post.output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (this->stream)
- port->close(port, this->stream);
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-
-static int eq2_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_eq2_out_t *output = (post_eq2_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
-
- if (!data)
- return 0;
- if (output->plugin->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->plugin->stream);
- new_port->open(new_port, output->plugin->stream);
+ if (_x_post_dispose(this_gen)) {
+ pthread_mutex_destroy(&this->lock);
+ free(this);
}
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
-
- return 1;
}
+
static int eq2_get_property(xine_video_port_t *port_gen, int property) {
post_video_port_t *port = (post_video_port_t *)port_gen;
post_plugin_eq2_t *this = (post_plugin_eq2_t *)port->post;
@@ -614,48 +552,12 @@ static int eq2_set_property(xine_video_port_t *port_gen, int property, int value
return port->original_port->set_property(port->original_port, property, value);
}
-static void eq2_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_eq2_t *this = (post_plugin_eq2_t *)port->post;
- this->stream = stream;
- port->original_port->open(port->original_port, stream);
-}
-static vo_frame_t *eq2_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
+static int eq2_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = eq2_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
-
- return frame;
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
-static void eq2_close(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_eq2_t *this = (post_plugin_eq2_t *)port->post;
-
- this->stream = NULL;
-
- port->original_port->close(port->original_port, stream);
-}
-
-
-
static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream)
{
@@ -667,8 +569,6 @@ static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream)
int skip;
int i;
- _x_post_restore_video_frame(frame, port);
-
if( !frame->bad_frame &&
(eq2->param[0].adjust || eq2->param[1].adjust || eq2->param[2].adjust) ) {
@@ -678,9 +578,7 @@ static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream)
yv12_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
- yv12_frame->pts = frame->pts;
- yv12_frame->duration = frame->duration;
- _x_extra_info_merge(yv12_frame->extra_info, frame->extra_info);
+ _x_post_frame_copy_up(frame, yv12_frame);
yuy2_to_yv12(frame->base[0], frame->pitches[0],
yv12_frame->base[0], yv12_frame->pitches[0],
@@ -696,11 +594,7 @@ static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream)
out_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
-
- _x_extra_info_merge(out_frame->extra_info, frame->extra_info);
-
- out_frame->pts = frame->pts;
- out_frame->duration = frame->duration;
+ _x_post_frame_copy_up(frame, out_frame);
pthread_mutex_lock (&this->lock);
@@ -722,15 +616,16 @@ static int eq2_draw(vo_frame_t *frame, xine_stream_t *stream)
skip = out_frame->draw(out_frame, stream);
- frame->vpts = out_frame->vpts;
+ _x_post_frame_copy_down(frame, out_frame);
out_frame->free(out_frame);
yv12_frame->free(yv12_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
-
return skip;
}
diff --git a/src/post/planar/expand.c b/src/post/planar/expand.c
index 9f3cda2cf..5848775fb 100644
--- a/src/post/planar/expand.c
+++ b/src/post/planar/expand.c
@@ -27,7 +27,6 @@
*/
#include "xine_internal.h"
-#include "xineutils.h"
#include "post.h"
/* The expand trick explained:
@@ -45,13 +44,11 @@
* image into a frame with pre-attached black borders. This is the way:
* - when the decoder asks for a new frame, we allocate an enlarged
* frame from the original port and prepare it with black borders
- * - we clone the frame by copying its vo_frame_t structure
- * - we modify this structure so that the decoder will only see
+ * - we modify this frame's base pointers so that the decoder will only see
* the area between the black bars
* - this frame is given to the decoder, which paints its image inside
- * - when the decoder draws the frame, we intercept that and draw
- * the enlarged version instead
- * - same with freeing the frame
+ * - when the decoder draws the frame, the post plugin architecture
+ * will automatically restore the old pointers
* This way, the decoder (or any other post plugin down 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.
@@ -74,22 +71,14 @@ PARAM_ITEM(POST_PARAM_TYPE_INT, overlay_y_offset, NULL, -500, 500, 0,
"manually shift the overlay vertically")
END_PARAM_DESCR(expand_param_descr)
-typedef struct post_expand_out_s {
- xine_post_out_t xine_out;
- /* keep the stream for open/close when rewiring */
- xine_stream_t *stream;
-} post_expand_out_t;
-
typedef struct post_expand_s {
post_plugin_t post;
- post_overlay_manager_t *overlay_manager;
+ xine_post_in_t parameter_input;
+
int enable_automatic_shift;
int overlay_y_offset;
int top_bar_height;
-
- vo_frame_t **frames_prealloc;
- int num_frames;
} post_expand_t;
/* plugin class functions */
@@ -103,27 +92,19 @@ static void expand_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void expand_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int expand_rewire(xine_post_out_t *output, void *data);
-
/* parameter functions */
static xine_post_api_descr_t *expand_get_param_descr(void);
static int expand_set_parameters(xine_post_t *this_gen, void *param_gen);
static int expand_get_parameters(xine_post_t *this_gen, void *param_gen);
+static char *expand_get_help (void);
-/* replaced video_port functions */
-static void expand_open(xine_video_port_t *port_gen, xine_stream_t *stream);
+/* replaced video port functions */
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);
-static video_overlay_manager_t *expand_get_overlay_manager(xine_video_port_t *port_gen);
-static void expand_close(xine_video_port_t *port_gen, xine_stream_t *stream);
-/* replaced vo_frame functions */
-static int expand_draw(vo_frame_t *frame, xine_stream_t *stream);
-static void expand_free(vo_frame_t *frame);
-static void expand_field(vo_frame_t *frame, int which_field);
-static void expand_lock(vo_frame_t *frame);
+/* overlay manager intercept check */
+static int expand_intercept_ovl(post_video_port_t *port);
/* replaced overlay manager functions */
static int32_t expand_overlay_add_event(video_overlay_manager_t *this_gen, void *event);
@@ -144,78 +125,44 @@ void *expand_init_plugin(xine_t *xine, void *data)
return class;
}
-static char * get_help (void) {
- return _("The expand plugin is meant to take frames of arbitrary aspect ratio and "
- "converts them to 4:3 aspect by adding black bars on the top and bottom "
- "of the frame. This allows us to shift overlays down into the black area "
- "so they don't cover the image.\n"
- "\n"
- "Parameters (FIXME: better help)\n"
- " Enable_automatic_shift: Enable automatic overlay shifting\n"
- " Overlay_y_offset: Manually shift the overlay vertically\n"
- "\n"
- );
-}
static post_plugin_t *expand_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_expand_t *this = (post_expand_t *)malloc(sizeof(post_expand_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_param = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_expand_out_t *output = (post_expand_out_t *)malloc(sizeof(post_expand_out_t));
+ post_expand_t *this = (post_expand_t *)xine_xmalloc(sizeof(post_expand_t));
+ post_in_t *input;
+ xine_post_in_t *input_param;
+ post_out_t *output;
post_video_port_t *port;
static xine_post_api_t post_api =
- { expand_set_parameters, expand_get_parameters, expand_get_param_descr, get_help };
+ { expand_set_parameters, expand_get_parameters, expand_get_param_descr, expand_get_help };
- if (!this || !input || !input_param || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_param);
- free(output);
return NULL;
}
- this->overlay_manager = NULL;
+ _x_post_init(&this->post, 0, 1);
+
this->enable_automatic_shift = 0;
this->overlay_y_offset = 0;
- this->frames_prealloc = NULL;
- this->num_frames = 0;
-
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = expand_open;
- port->port.get_frame = expand_get_frame;
- port->port.get_overlay_manager = expand_get_overlay_manager;
- port->port.close = expand_close;
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->new_port.get_frame = expand_get_frame;
+ port->intercept_ovl = expand_intercept_ovl;
+ port->new_manager->add_event = expand_overlay_add_event;
+ input_param = &this->parameter_input;
input_param->name = "parameters";
input_param->type = XINE_POST_DATA_PARAMETERS;
input_param->data = &post_api;
-
- output->xine_out.name = "expanded video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = expand_rewire;
- output->stream = NULL;
+ xine_list_append_content(this->post.input, input_param);
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
+ input->xine_in.name = "video";
+ output->xine_out.name = "expanded video";
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
-
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_param);
- xine_list_append_content(this->post.output, output);
+ this->post.xine_post.video_input[0] = &port->new_port;
this->post.dispose = expand_dispose;
@@ -240,47 +187,10 @@ static void expand_class_dispose(post_class_t *class_gen)
static void expand_dispose(post_plugin_t *this_gen)
{
- post_expand_out_t *output = (post_expand_out_t *)xine_list_first_content(this_gen->output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
post_expand_t *this = (post_expand_t *)this_gen;
- int i;
-
- if (output->stream)
- port->close(port, output->stream);
- free(this->overlay_manager);
-
- for (i = 0; i < this->num_frames; i++)
- free(this->frames_prealloc[i]);
- free(this->frames_prealloc);
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-
-static int expand_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_expand_out_t *output = (post_expand_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
-
- if (!data)
- return 0;
- if (output->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->stream);
- new_port->open(new_port, output->stream);
- }
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
- return 1;
+ if (_x_post_dispose(this_gen))
+ free(this);
}
@@ -309,25 +219,32 @@ static int expand_get_parameters(xine_post_t *this_gen, void *param_gen)
return 1;
}
-
-static void expand_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_expand_out_t *output = (post_expand_out_t *)xine_list_first_content(port->post->output);
- output->stream = stream;
- port->original_port->open(port->original_port, stream);
+static char *expand_get_help(void) {
+ return _("The expand plugin is meant to take frames of arbitrary aspect ratio and "
+ "converts them to 4:3 aspect by adding black bars on the top and bottom "
+ "of the frame. This allows us to shift overlays down into the black area "
+ "so they don't cover the image.\n"
+ "\n"
+ "Parameters (FIXME: better help)\n"
+ " Enable_automatic_shift: Enable automatic overlay shifting\n"
+ " Overlay_y_offset: Manually shift the overlay vertically\n"
+ "\n"
+ );
}
+
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)
{
post_video_port_t *port = (post_video_port_t *)port_gen;
post_expand_t *this = (post_expand_t *)port->post;
- vo_frame_t *original_frame, *cloned_frame = NULL;
+ vo_frame_t *frame;
uint32_t new_height, top_bar_height;
int i, end;
+ _x_post_rewire_video(port);
+
if (ratio <= 0.0) ratio = (double)width / (double)height;
/* Calculate height of expanded frame */
@@ -336,171 +253,77 @@ static vo_frame_t *expand_get_frame(xine_video_port_t *port_gen, uint32_t width,
top_bar_height = (new_height - height) / 2;
top_bar_height = (top_bar_height + 1) & ~1;
- ((post_expand_t *)port->post)->top_bar_height = top_bar_height;
+ this->top_bar_height = top_bar_height;
if (new_height > height &&
(format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2)) {
- original_frame = port->original_port->get_frame(port->original_port,
+ frame = port->original_port->get_frame(port->original_port,
width, new_height, 4.0 / 3.0, format, flags);
- /* search for a free frame among the preallocated */
- while (!cloned_frame) {
- for (i = 0; i < this->num_frames; i++)
- /* misusing is_first as a free flag */
- if (this->frames_prealloc[i]->is_first) break;
- if (i >= this->num_frames) {
- /* no free frame found -> we need to allocate some more */
- this->frames_prealloc =
- realloc(this->frames_prealloc, sizeof(vo_frame_t *) * (this->num_frames + 15));
- for (i = this->num_frames; i < this->num_frames + 15; i++) {
- this->frames_prealloc[i] = (vo_frame_t *)malloc(sizeof(vo_frame_t));
- this->frames_prealloc[i]->is_first = 1;
- }
- this->num_frames += 15;
- } else
- cloned_frame = this->frames_prealloc[i];
- }
- /* misusing is_first as a free flag */
- cloned_frame->is_first = 0;
-
- xine_fast_memcpy(cloned_frame, original_frame, sizeof(vo_frame_t));
- /* replace with our own functions */
- cloned_frame->draw = expand_draw;
- cloned_frame->free = expand_free;
- /* decoders should not copy the frames, since they won't be displayed as is */
- /* FIXME: We might get speed improvements with copy-capable outputs by:
- * - copying the top black bar here
- * - letting the decoder copy the image
- * - copying the bottom black bar in expand_draw()
- */
- cloned_frame->proc_slice = NULL;
- cloned_frame->proc_frame = NULL;
- cloned_frame->field = expand_field;
- cloned_frame->lock = expand_lock;
-
- cloned_frame->port = port_gen;
- /* misuse the next pointer to remember the original */
- cloned_frame->next = original_frame;
+ _x_post_inc_usage(port);
+ frame = _x_post_intercept_video_frame(frame, port);
/* paint black bars in the top and bottom of the frame and hide these
* from the decoders by modifying the pointers to and
* the size of the drawing area */
- cloned_frame->height = height;
- cloned_frame->ratio = ratio;
+ frame->height = height;
+ frame->ratio = ratio;
switch (format) {
case XINE_IMGFMT_YV12:
/* paint top bar */
- memset(cloned_frame->base[0], 0, cloned_frame->pitches[0] * top_bar_height );
- memset(cloned_frame->base[1], 128, cloned_frame->pitches[1] * top_bar_height / 2);
- memset(cloned_frame->base[2], 128, cloned_frame->pitches[2] * top_bar_height / 2);
+ memset(frame->base[0], 0, frame->pitches[0] * top_bar_height );
+ memset(frame->base[1], 128, frame->pitches[1] * top_bar_height / 2);
+ memset(frame->base[2], 128, frame->pitches[2] * top_bar_height / 2);
/* paint bottom bar */
- memset(cloned_frame->base[0] + cloned_frame->pitches[0] * (top_bar_height + height) , 0,
- cloned_frame->pitches[0] * (new_height - top_bar_height - height) );
- memset(cloned_frame->base[1] + cloned_frame->pitches[1] * (top_bar_height + height) / 2, 128,
- cloned_frame->pitches[1] * (new_height - top_bar_height - height) / 2);
- memset(cloned_frame->base[2] + cloned_frame->pitches[2] * (top_bar_height + height) / 2, 128,
- cloned_frame->pitches[2] * (new_height - top_bar_height - height) / 2);
+ memset(frame->base[0] + frame->pitches[0] * (top_bar_height + height) , 0,
+ frame->pitches[0] * (new_height - top_bar_height - height) );
+ memset(frame->base[1] + frame->pitches[1] * (top_bar_height + height) / 2, 128,
+ frame->pitches[1] * (new_height - top_bar_height - height) / 2);
+ memset(frame->base[2] + frame->pitches[2] * (top_bar_height + height) / 2, 128,
+ frame->pitches[2] * (new_height - top_bar_height - height) / 2);
/* modify drawing area */
- cloned_frame->base[0] += cloned_frame->pitches[0] * top_bar_height;
- cloned_frame->base[1] += cloned_frame->pitches[1] * top_bar_height / 2;
- cloned_frame->base[2] += cloned_frame->pitches[2] * top_bar_height / 2;
+ frame->base[0] += frame->pitches[0] * top_bar_height;
+ frame->base[1] += frame->pitches[1] * top_bar_height / 2;
+ frame->base[2] += frame->pitches[2] * top_bar_height / 2;
break;
case XINE_IMGFMT_YUY2:
/* paint top bar */
- end = cloned_frame->pitches[0] * top_bar_height;
+ end = frame->pitches[0] * top_bar_height;
for (i = 0; i < end; i += 2) {
- cloned_frame->base[0][i] = 0;
- cloned_frame->base[0][i+1] = 128;
+ frame->base[0][i] = 0;
+ frame->base[0][i+1] = 128;
}
/* paint bottom bar */
- end = cloned_frame->pitches[0] * new_height;
- for (i = cloned_frame->pitches[0] * (top_bar_height + height); i < end; i += 2) {
- cloned_frame->base[0][i] = 0;
- cloned_frame->base[0][i+1] = 128;
+ end = frame->pitches[0] * new_height;
+ for (i = frame->pitches[0] * (top_bar_height + height); i < end; i += 2) {
+ frame->base[0][i] = 0;
+ frame->base[0][i+1] = 128;
}
/* modify drawing area */
- cloned_frame->base[0] += cloned_frame->pitches[0] * top_bar_height;
+ frame->base[0] += frame->pitches[0] * top_bar_height;
}
} else {
- cloned_frame = port->original_port->get_frame(port->original_port,
+ frame = port->original_port->get_frame(port->original_port,
width, height, ratio, format, flags);
/* no need to intercept this one, we are not going to do anything with it */
}
- return cloned_frame;
-}
-
-static video_overlay_manager_t *expand_get_overlay_manager(xine_video_port_t *port_gen)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_expand_t *this = (post_expand_t *)port->post;
-
- if (!this->overlay_manager) {
- /* create a new overlay manager to intercept */
- this->overlay_manager = _x_post_intercept_overlay_manager(&this->post,
- port->original_port->get_overlay_manager(port->original_port));
- /* replace with our own add_event function */
- this->overlay_manager->manager.add_event = expand_overlay_add_event;
- } else {
- /* the original port might have changed */
- this->overlay_manager->original_manager =
- port->original_port->get_overlay_manager(port->original_port);
- }
-
- return &this->overlay_manager->manager;
-}
-
-static void expand_close(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_expand_out_t *output = (post_expand_out_t *)xine_list_first_content(port->post->output);
- output->stream = NULL;
- port->original_port->close(port->original_port, stream);
+ return frame;
}
-static int expand_draw(vo_frame_t *frame, xine_stream_t *stream)
-{
- vo_frame_t *original_frame = frame->next;
- int skip;
-
- original_frame->pts = frame->pts;
- original_frame->duration = frame->duration;
- original_frame->bad_frame = frame->bad_frame;
- _x_extra_info_merge(original_frame->extra_info, frame->extra_info);
- skip = original_frame->draw(original_frame, stream);
- frame->vpts = original_frame->vpts;
- return skip;
-}
-
-static void expand_free(vo_frame_t *frame)
+static int expand_intercept_ovl(post_video_port_t *port)
{
- vo_frame_t *original_frame = frame->next;
-
- original_frame->free(original_frame);
- if (--frame->lock_counter == 0)
- /* misusing is_first as a free flag */
- frame->is_first = 1;
-}
-
-static void expand_field(vo_frame_t *frame, int which_field)
-{
-}
-
-static void expand_lock(vo_frame_t *frame)
-{
- vo_frame_t *original_frame = frame->next;
-
- original_frame->lock(original_frame);
- frame->lock_counter++;
+ /* we always intercept overlay manager */
+ return 1;
}
static int32_t expand_overlay_add_event(video_overlay_manager_t *this_gen, void *event_gen)
{
- post_overlay_manager_t *ovl_manager = (post_overlay_manager_t *)this_gen;
- video_overlay_event_t *event = (video_overlay_event_t *)event_gen;
- post_expand_t *this = (post_expand_t *)ovl_manager->post;
+ video_overlay_event_t *event = (video_overlay_event_t *)event_gen;
+ post_video_port_t *port = _x_post_ovl_manager_to_port(this_gen);
+ post_expand_t *this = (post_expand_t *)port->post;
if (event->event_type == OVERLAY_EVENT_SHOW) {
switch (event->object.object_type) {
@@ -517,5 +340,5 @@ static int32_t expand_overlay_add_event(video_overlay_manager_t *this_gen, void
}
}
- return ovl_manager->original_manager->add_event(ovl_manager->original_manager, event_gen);
+ return port->original_manager->add_event(port->original_manager, event_gen);
}
diff --git a/src/post/planar/invert.c b/src/post/planar/invert.c
index 9d76fc73b..613565aa8 100644
--- a/src/post/planar/invert.c
+++ b/src/post/planar/invert.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: invert.c,v 1.18 2003/12/09 00:02:35 f1rmb Exp $
+ * $Id: invert.c,v 1.19 2004/01/07 19:52:42 mroi Exp $
*/
/*
@@ -31,14 +31,6 @@
/* plugin class initialization function */
void *invert_init_plugin(xine_t *xine, void *);
-/* plugin structure */
-typedef struct post_invert_out_s post_invert_out_t;
-struct post_invert_out_s {
- xine_post_out_t xine_out;
- /* keep the stream for open/close when rewiring */
- xine_stream_t *stream;
-};
-
/* plugin class functions */
static post_plugin_t *invert_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
@@ -50,15 +42,8 @@ static void invert_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void invert_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int invert_rewire(xine_post_out_t *output, void *data);
-
-/* replaced video_port functions */
-static void invert_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *invert_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
-static void invert_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+/* frame intercept check */
+static int invert_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
/* replaced vo_frame functions */
static int invert_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -84,45 +69,24 @@ static post_plugin_t *invert_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_t *this = (post_plugin_t *)malloc(sizeof(post_plugin_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_invert_out_t *output = (post_invert_out_t *)malloc(sizeof(post_invert_out_t));
+ post_plugin_t *this = (post_plugin_t *)xine_xmalloc(sizeof(post_plugin_t));
+ post_in_t *input;
+ post_out_t *output;
post_video_port_t *port;
- if (!this || !input || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(output);
return NULL;
}
- port = _x_post_intercept_video_port(this, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = invert_open;
- port->port.get_frame = invert_get_frame;
- port->port.close = invert_close;
-
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
-
- output->xine_out.name = "inverted video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = invert_rewire;
- output->stream = NULL;
+ _x_post_init(this, 0, 1);
- this->xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->xine_post.audio_input[0] = NULL;
- this->xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->xine_post.video_input[0] = &port->port;
- this->xine_post.video_input[1] = NULL;
-
- this->input = xine_list_new();
- this->output = xine_list_new();
-
- xine_list_append_content(this->input, input);
- xine_list_append_content(this->output, output);
+ port = _x_post_intercept_video_port(this, video_target[0], &input, &output);
+ port->intercept_frame = invert_intercept_frame;
+ port->new_frame->draw = invert_draw;
+ input->xine_in.name = "video";
+ output->xine_out.name = "inverted video";
+ this->xine_post.video_input[0] = &port->new_port;
this->dispose = invert_dispose;
@@ -147,77 +111,14 @@ static void invert_class_dispose(post_class_t *class_gen)
static void invert_dispose(post_plugin_t *this)
{
- post_invert_out_t *output = (post_invert_out_t *)xine_list_first_content(this->output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (output->stream)
- port->close(port, output->stream);
-
- free(this->xine_post.audio_input);
- free(this->xine_post.video_input);
- free(xine_list_first_content(this->input));
- free(xine_list_first_content(this->output));
- xine_list_free(this->input);
- xine_list_free(this->output);
- free(this);
-}
-
-
-static int invert_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_invert_out_t *output = (post_invert_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
-
- if (!data)
- return 0;
- if (output->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->stream);
- new_port->open(new_port, output->stream);
- }
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
- return 1;
+ if (_x_post_dispose(this))
+ free(this);
}
-static void invert_open(xine_video_port_t *port_gen, xine_stream_t *stream)
+static int invert_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_invert_out_t *output = (post_invert_out_t *)xine_list_first_content(port->post->output);
- output->stream = stream;
- port->original_port->open(port->original_port, stream);
-}
-
-static vo_frame_t *invert_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = invert_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
-
- return frame;
-}
-
-static void invert_close(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_invert_out_t *output = (post_invert_out_t *)xine_list_first_content(port->post->output);
- output->stream = NULL;
- port->original_port->close(port->original_port, stream);
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
@@ -227,12 +128,16 @@ static int invert_draw(vo_frame_t *frame, xine_stream_t *stream)
vo_frame_t *inverted_frame;
int size, i, skip;
+ if (frame->bad_frame) {
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
+ return skip;
+ }
+
inverted_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, frame->format, frame->flags | VO_BOTH_FIELDS);
- inverted_frame->pts = frame->pts;
- inverted_frame->duration = frame->duration;
- inverted_frame->bad_frame = frame->bad_frame;
- _x_extra_info_merge(inverted_frame->extra_info, frame->extra_info);
+ _x_post_frame_copy_up(frame, inverted_frame);
switch (inverted_frame->format) {
case XINE_IMGFMT_YUY2:
@@ -254,17 +159,10 @@ static int invert_draw(vo_frame_t *frame, xine_stream_t *stream)
for (i = 0; i < size; i++)
inverted_frame->base[2][i] = 0xff - frame->base[2][i];
break;
- default:
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "invert: cannot handle image format %d\n", frame->format);
- inverted_frame->free(inverted_frame);
- _x_post_restore_video_frame(frame, port);
- return frame->draw(frame, stream);
}
skip = inverted_frame->draw(inverted_frame, stream);
+ _x_post_frame_copy_down(frame, inverted_frame);
inverted_frame->free(inverted_frame);
- frame->vpts = inverted_frame->vpts;
- _x_post_restore_video_frame(frame, port);
return skip;
}
diff --git a/src/post/planar/planar.c b/src/post/planar/planar.c
index 0c869eff3..2abcb5ea0 100644
--- a/src/post/planar/planar.c
+++ b/src/post/planar/planar.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: planar.c,v 1.6 2003/12/14 22:13:25 siggi Exp $
+ * $Id: planar.c,v 1.7 2004/01/07 19:52:42 mroi Exp $
*
* catalog for planar post plugins
*/
@@ -52,13 +52,13 @@ post_info_t pp_special_info = { XINE_POST_TYPE_VIDEO_FILTER };
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_POST, 7, "expand", XINE_VERSION_CODE+1, &expand_special_info, &expand_init_plugin },
- { PLUGIN_POST, 7, "invert", XINE_VERSION_CODE+1, &invert_special_info, &invert_init_plugin },
- { PLUGIN_POST, 7, "eq", XINE_VERSION_CODE, &eq_special_info, &eq_init_plugin },
- { PLUGIN_POST, 7, "denoise3d", XINE_VERSION_CODE, &denoise3d_special_info, &denoise3d_init_plugin },
- { PLUGIN_POST, 7, "boxblur", XINE_VERSION_CODE, &boxblur_special_info, &boxblur_init_plugin },
- { PLUGIN_POST, 7, "eq2", XINE_VERSION_CODE, &eq2_special_info, &eq2_init_plugin },
- { PLUGIN_POST, 7, "unsharp", XINE_VERSION_CODE, &unsharp_special_info, &unsharp_init_plugin },
- { PLUGIN_POST, 7, "pp", XINE_VERSION_CODE, &pp_special_info, &pp_init_plugin },
+ { PLUGIN_POST, 8, "expand", XINE_VERSION_CODE, &expand_special_info, &expand_init_plugin },
+ { PLUGIN_POST, 8, "invert", XINE_VERSION_CODE, &invert_special_info, &invert_init_plugin },
+ { PLUGIN_POST, 8, "eq", XINE_VERSION_CODE, &eq_special_info, &eq_init_plugin },
+ { PLUGIN_POST, 8, "denoise3d", XINE_VERSION_CODE, &denoise3d_special_info, &denoise3d_init_plugin },
+ { PLUGIN_POST, 8, "boxblur", XINE_VERSION_CODE, &boxblur_special_info, &boxblur_init_plugin },
+ { PLUGIN_POST, 8, "eq2", XINE_VERSION_CODE, &eq2_special_info, &eq2_init_plugin },
+ { PLUGIN_POST, 8, "unsharp", XINE_VERSION_CODE, &unsharp_special_info, &unsharp_init_plugin },
+ { PLUGIN_POST, 8, "pp", XINE_VERSION_CODE, &pp_special_info, &pp_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/post/planar/pp.c b/src/post/planar/pp.c
index b2c81f173..95fcfb4f1 100755
--- a/src/post/planar/pp.c
+++ b/src/post/planar/pp.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: pp.c,v 1.4 2003/12/07 15:33:26 miguelfreitas Exp $
+ * $Id: pp.c,v 1.5 2004/01/07 19:52:42 mroi Exp $
*
* plugin for ffmpeg libpostprocess
*/
@@ -61,12 +61,11 @@ struct post_plugin_pp_s {
post_plugin_t post;
/* private data */
- xine_video_port_t *vo_port;
- xine_stream_t *stream;
int frame_width;
int frame_height;
- pp_parameters_t params;
+ pp_parameters_t params;
+ xine_post_in_t params_input;
/* libpostproc specific stuff */
int pp_flags;
@@ -140,12 +139,6 @@ static xine_post_api_t post_api = {
get_help,
};
-typedef struct post_pp_out_s post_pp_out_t;
-struct post_pp_out_s {
- xine_post_out_t xine_out;
-
- post_plugin_pp_t *plugin;
-};
/* plugin class functions */
static post_plugin_t *pp_open_plugin(post_class_t *class_gen, int inputs,
@@ -158,15 +151,8 @@ static void pp_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void pp_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int pp_rewire(xine_post_out_t *output, void *data);
-
-/* replaced video_port functions */
-static void pp_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *pp_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
-static void pp_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+/* frame intercept check */
+static int pp_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
/* replaced vo_frame functions */
static int pp_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -192,23 +178,20 @@ static post_plugin_t *pp_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_pp_t *this = (post_plugin_pp_t *)malloc(sizeof(post_plugin_pp_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_api = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_pp_out_t *output = (post_pp_out_t *)malloc(sizeof(post_pp_out_t));
+ post_plugin_pp_t *this = (post_plugin_pp_t *)xine_xmalloc(sizeof(post_plugin_pp_t));
+ post_in_t *input;
+ xine_post_in_t *input_api;
+ post_out_t *output;
post_video_port_t *port;
- uint32_t cpu_caps;
+ uint32_t cpu_caps;
- if (!this || !input || !input_api || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_api);
- free(output);
return NULL;
}
- this->stream = NULL;
-
+ _x_post_init(&this->post, 0, 1);
+
this->params.quality = 3;
strcpy(this->params.mode, "de");
@@ -227,38 +210,20 @@ static post_plugin_t *pp_open_plugin(post_class_t *class_gen, int inputs,
pthread_mutex_init (&this->lock, NULL);
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = pp_open;
- port->port.get_frame = pp_get_frame;
- port->port.close = pp_close;
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->intercept_frame = pp_intercept_frame;
+ port->new_frame->draw = pp_draw;
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
-
+ input_api = &this->params_input;
input_api->name = "parameters";
input_api->type = XINE_POST_DATA_PARAMETERS;
input_api->data = &post_api;
+ xine_list_append_content(this->post.input, input_api);
+ input->xine_in.name = "video";
output->xine_out.name = "pped video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = pp_rewire;
- output->plugin = this;
-
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
-
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_api);
- xine_list_append_content(this->post.output, output);
+ this->post.xine_post.video_input[0] = &port->new_port;
this->post.dispose = pp_dispose;
@@ -284,91 +249,24 @@ static void pp_class_dispose(post_class_t *class_gen)
static void pp_dispose(post_plugin_t *this_gen)
{
post_plugin_pp_t *this = (post_plugin_pp_t *)this_gen;
- post_pp_out_t *output = (post_pp_out_t *)xine_list_first_content(this->post.output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (this->stream)
- port->close(port, this->stream);
-
- if(this->pp_mode) {
- pp_free_mode(this->pp_mode);
- this->pp_mode = NULL;
- }
-
- if(this->pp_context) {
- pp_free_context(this->pp_context);
- this->pp_context = NULL;
- }
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-
-static int pp_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_pp_out_t *output = (post_pp_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
-
- if (!data)
- return 0;
- if (output->plugin->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->plugin->stream);
- new_port->open(new_port, output->plugin->stream);
+ if (_x_post_dispose(this_gen)) {
+ if(this->pp_mode) {
+ pp_free_mode(this->pp_mode);
+ this->pp_mode = NULL;
+ }
+ if(this->pp_context) {
+ pp_free_context(this->pp_context);
+ this->pp_context = NULL;
+ }
+ free(this);
}
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
-
- return 1;
-}
-
-static void pp_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_pp_t *this = (post_plugin_pp_t *)port->post;
- this->stream = stream;
- port->original_port->open(port->original_port, stream);
}
-static vo_frame_t *pp_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = pp_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
- return frame;
-}
-
-static void pp_close(xine_video_port_t *port_gen, xine_stream_t *stream)
+static int pp_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_pp_t *this = (post_plugin_pp_t *)port->post;
-
- this->stream = NULL;
-
- port->original_port->close(port->original_port, stream);
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
@@ -381,8 +279,6 @@ static int pp_draw(vo_frame_t *frame, xine_stream_t *stream)
int skip;
int pp_flags;
- _x_post_restore_video_frame(frame, port);
-
if( !frame->bad_frame ) {
/* convert to YV12 if needed */
@@ -391,9 +287,7 @@ static int pp_draw(vo_frame_t *frame, xine_stream_t *stream)
yv12_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
- yv12_frame->pts = frame->pts;
- yv12_frame->duration = frame->duration;
- _x_extra_info_merge(yv12_frame->extra_info, frame->extra_info);
+ _x_post_frame_copy_up(frame, yv12_frame);
yuy2_to_yv12(frame->base[0], frame->pitches[0],
yv12_frame->base[0], yv12_frame->pitches[0],
@@ -409,10 +303,7 @@ static int pp_draw(vo_frame_t *frame, xine_stream_t *stream)
out_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
- _x_extra_info_merge(out_frame->extra_info, frame->extra_info);
-
- out_frame->pts = frame->pts;
- out_frame->duration = frame->duration;
+ _x_post_frame_copy_up(frame, out_frame);
pthread_mutex_lock (&this->lock);
@@ -451,18 +342,21 @@ static int pp_draw(vo_frame_t *frame, xine_stream_t *stream)
if(this->pp_mode) {
skip = out_frame->draw(out_frame, stream);
- frame->vpts = out_frame->vpts;
+ _x_post_frame_copy_down(frame, out_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
out_frame->free(out_frame);
yv12_frame->free(yv12_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
-
return skip;
}
diff --git a/src/post/planar/unsharp.c b/src/post/planar/unsharp.c
index f60530fb9..31359f500 100644
--- a/src/post/planar/unsharp.c
+++ b/src/post/planar/unsharp.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: unsharp.c,v 1.12 2003/12/07 15:33:26 miguelfreitas Exp $
+ * $Id: unsharp.c,v 1.13 2004/01/07 19:52:42 mroi Exp $
*
* mplayer's unsharp
* Copyright (C) 2002 Rémi Guyomarch <rguyom@pobox.com>
@@ -166,13 +166,11 @@ struct post_plugin_unsharp_s {
post_plugin_t post;
/* private data */
- xine_video_port_t *vo_port;
- xine_stream_t *stream;
-
unsharp_parameters_t params;
+ xine_post_in_t params_input;
struct vf_priv_s priv;
- pthread_mutex_t lock;
+ pthread_mutex_t lock;
};
@@ -251,12 +249,6 @@ static xine_post_api_t post_api = {
get_help,
};
-typedef struct post_unsharp_out_s post_unsharp_out_t;
-struct post_unsharp_out_s {
- xine_post_out_t xine_out;
-
- post_plugin_unsharp_t *plugin;
-};
/* plugin class functions */
static post_plugin_t *unsharp_open_plugin(post_class_t *class_gen, int inputs,
@@ -269,15 +261,8 @@ static void unsharp_class_dispose(post_class_t *class_gen);
/* plugin instance functions */
static void unsharp_dispose(post_plugin_t *this_gen);
-/* rewire function */
-static int unsharp_rewire(xine_post_out_t *output, void *data);
-
-/* replaced video_port functions */
-static void unsharp_open(xine_video_port_t *port_gen, xine_stream_t *stream);
-static vo_frame_t *unsharp_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags);
-static void unsharp_close(xine_video_port_t *port_gen, xine_stream_t *stream);
+/* frame intercept check */
+static int unsharp_intercept_frame(post_video_port_t *port, vo_frame_t *frame);
/* replaced vo_frame functions */
static int unsharp_draw(vo_frame_t *frame, xine_stream_t *stream);
@@ -304,21 +289,18 @@ static post_plugin_t *unsharp_open_plugin(post_class_t *class_gen, int inputs,
xine_video_port_t **video_target)
{
post_plugin_unsharp_t *this = (post_plugin_unsharp_t *)xine_xmalloc(sizeof(post_plugin_unsharp_t));
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- xine_post_in_t *input_api = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_unsharp_out_t *output = (post_unsharp_out_t *)malloc(sizeof(post_unsharp_out_t));
- post_video_port_t *port;
+ post_in_t *input;
+ xine_post_in_t *input_api;
+ post_out_t *output;
+ post_video_port_t *port;
- if (!this || !input || !input_api || !output || !video_target || !video_target[0]) {
+ if (!this || !video_target || !video_target[0]) {
free(this);
- free(input);
- free(input_api);
- free(output);
return NULL;
}
- this->stream = NULL;
-
+ _x_post_init(&this->post, 0, 1);
+
this->params.luma_matrix_width = 5;
this->params.luma_matrix_height = 5;
this->params.luma_amount = 0.0;
@@ -329,39 +311,21 @@ static post_plugin_t *unsharp_open_plugin(post_class_t *class_gen, int inputs,
pthread_mutex_init (&this->lock, NULL);
- port = _x_post_intercept_video_port(&this->post, video_target[0]);
- /* replace with our own get_frame function */
- port->port.open = unsharp_open;
- port->port.get_frame = unsharp_get_frame;
- port->port.close = unsharp_close;
+ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output);
+ port->intercept_frame = unsharp_intercept_frame;
+ port->new_frame->draw = unsharp_draw;
- input->name = "video";
- input->type = XINE_POST_DATA_VIDEO;
- input->data = (xine_video_port_t *)&port->port;
-
+ input_api = &this->params_input;
input_api->name = "parameters";
input_api->type = XINE_POST_DATA_PARAMETERS;
input_api->data = &post_api;
+ xine_list_append_content(this->post.input, input_api);
+ input->xine_in.name = "video";
output->xine_out.name = "unsharped video";
- output->xine_out.type = XINE_POST_DATA_VIDEO;
- output->xine_out.data = (xine_video_port_t **)&port->original_port;
- output->xine_out.rewire = unsharp_rewire;
- output->plugin = this;
-
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *));
- this->post.xine_post.audio_input[0] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 2);
- this->post.xine_post.video_input[0] = &port->port;
- this->post.xine_post.video_input[1] = NULL;
- this->post.input = xine_list_new();
- this->post.output = xine_list_new();
+ this->post.xine_post.video_input[0] = &port->new_port;
- xine_list_append_content(this->post.input, input);
- xine_list_append_content(this->post.input, input_api);
- xine_list_append_content(this->post.output, output);
-
set_parameters ((xine_post_t *)this, &this->params);
this->post.dispose = unsharp_dispose;
@@ -407,86 +371,20 @@ static void unsharp_free_SC(post_plugin_unsharp_t *this)
static void unsharp_dispose(post_plugin_t *this_gen)
{
post_plugin_unsharp_t *this = (post_plugin_unsharp_t *)this_gen;
- post_unsharp_out_t *output = (post_unsharp_out_t *)xine_list_first_content(this->post.output);
- xine_video_port_t *port = *(xine_video_port_t **)output->xine_out.data;
-
- if (this->stream)
- port->close(port, this->stream);
-
- unsharp_free_SC(this);
-
- free(this->post.xine_post.audio_input);
- free(this->post.xine_post.video_input);
- free(xine_list_first_content(this->post.input));
- free(xine_list_next_content(this->post.input));
- free(xine_list_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- free(this);
-}
-
-static int unsharp_rewire(xine_post_out_t *output_gen, void *data)
-{
- post_unsharp_out_t *output = (post_unsharp_out_t *)output_gen;
- xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data;
- xine_video_port_t *new_port = (xine_video_port_t *)data;
-
- if (!data)
- return 0;
-
- if (output->plugin->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, output->plugin->stream);
- new_port->open(new_port, output->plugin->stream);
+ if (_x_post_dispose(this_gen)) {
+ unsharp_free_SC(this);
+ pthread_mutex_destroy(&this->lock);
+ free(this);
}
- /* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
-
- return 1;
}
-static void unsharp_open(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_unsharp_t *this = (post_plugin_unsharp_t *)port->post;
- this->stream = stream;
- port->original_port->open(port->original_port, stream);
-}
-static vo_frame_t *unsharp_get_frame(xine_video_port_t *port_gen, uint32_t width,
- uint32_t height, double ratio,
- int format, int flags)
+static int unsharp_intercept_frame(post_video_port_t *port, vo_frame_t *frame)
{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- vo_frame_t *frame;
-
- frame = port->original_port->get_frame(port->original_port,
- width, height, ratio, format, flags);
-
- _x_post_intercept_video_frame(frame, port);
- if( format == XINE_IMGFMT_YV12 || format == XINE_IMGFMT_YUY2 ) {
- /* replace with our own draw function */
- frame->draw = unsharp_draw;
- /* decoders should not copy the frames, since they won't be displayed */
- frame->proc_slice = NULL;
- frame->proc_frame = NULL;
- }
-
- return frame;
+ return (frame->format == XINE_IMGFMT_YV12 || frame->format == XINE_IMGFMT_YUY2);
}
-static void unsharp_close(xine_video_port_t *port_gen, xine_stream_t *stream)
-{
- post_video_port_t *port = (post_video_port_t *)port_gen;
- post_plugin_unsharp_t *this = (post_plugin_unsharp_t *)port->post;
-
- this->stream = NULL;
-
- port->original_port->close(port->original_port, stream);
-}
-
-
static int unsharp_draw(vo_frame_t *frame, xine_stream_t *stream)
{
@@ -496,8 +394,6 @@ static int unsharp_draw(vo_frame_t *frame, xine_stream_t *stream)
vo_frame_t *yv12_frame;
int skip;
- _x_post_restore_video_frame(frame, port);
-
if( !frame->bad_frame &&
(this->priv.lumaParam.amount || this->priv.chromaParam.amount) ) {
@@ -508,9 +404,7 @@ static int unsharp_draw(vo_frame_t *frame, xine_stream_t *stream)
yv12_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
- yv12_frame->pts = frame->pts;
- yv12_frame->duration = frame->duration;
- _x_extra_info_merge(yv12_frame->extra_info, frame->extra_info);
+ _x_post_frame_copy_up(frame, yv12_frame);
yuy2_to_yv12(frame->base[0], frame->pitches[0],
yv12_frame->base[0], yv12_frame->pitches[0],
@@ -527,11 +421,7 @@ static int unsharp_draw(vo_frame_t *frame, xine_stream_t *stream)
out_frame = port->original_port->get_frame(port->original_port,
frame->width, frame->height, frame->ratio, XINE_IMGFMT_YV12, frame->flags | VO_BOTH_FIELDS);
-
- _x_extra_info_merge(out_frame->extra_info, frame->extra_info);
-
- out_frame->pts = frame->pts;
- out_frame->duration = frame->duration;
+ _x_post_frame_copy_up(frame, out_frame);
pthread_mutex_lock (&this->lock);
@@ -565,15 +455,16 @@ static int unsharp_draw(vo_frame_t *frame, xine_stream_t *stream)
skip = out_frame->draw(out_frame, stream);
- frame->vpts = out_frame->vpts;
+ _x_post_frame_copy_down(frame, out_frame);
out_frame->free(out_frame);
yv12_frame->free(yv12_frame);
} else {
- skip = frame->draw(frame, stream);
+ _x_post_frame_copy_up(frame, frame->next);
+ skip = frame->next->draw(frame->next, stream);
+ _x_post_frame_copy_down(frame, frame->next);
}
-
return skip;
}