summaryrefslogtreecommitdiff
path: root/src/post/goom/xine_goom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/post/goom/xine_goom.c')
-rw-r--r--src/post/goom/xine_goom.c181
1 files changed, 58 insertions, 123 deletions
diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c
index 71851fb9f..e7d0f1eea 100644
--- a/src/post/goom/xine_goom.c
+++ b/src/post/goom/xine_goom.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_goom.c,v 1.47 2003/12/14 22:13:25 siggi Exp $
+ * $Id: xine_goom.c,v 1.48 2004/01/07 19:52:42 mroi Exp $
*
* GOOM post plugin.
*
@@ -71,7 +71,7 @@ struct post_plugin_goom_s {
/* private data */
xine_video_port_t *vo_port;
- xine_stream_t *stream;
+ post_out_t video_output;
post_class_goom_t *class;
@@ -82,8 +82,6 @@ struct post_plugin_goom_s {
gint16 data [2][512];
audio_buffer_t buf; /* dummy buffer just to hold a copy of audio data */
- int bits;
- int mode;
int channels;
int sample_rate;
int sample_counter;
@@ -92,25 +90,14 @@ struct post_plugin_goom_s {
int width_back, height_back;
double ratio;
int fps;
- int use_asm;
int csc_method;
yuv_planes_t yuv;
/* frame skipping */
int skip_frame;
- int title_flag;
- char *msg;
- int msg_index;
- int msg_flag;
- char msg_buf[1024];
};
-typedef struct post_goom_out_s post_goom_out_t;
-struct post_goom_out_s {
- xine_post_out_t out;
- post_plugin_goom_t *post;
-};
/* plugin class initialization function */
static void *goom_init_plugin(xine_t *xine, void *);
@@ -123,7 +110,7 @@ post_info_t goom_special_info = {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_POST | PLUGIN_MUST_PRELOAD, 7, "goom", XINE_VERSION_CODE, &goom_special_info, &goom_init_plugin },
+ { PLUGIN_POST | PLUGIN_MUST_PRELOAD, 8, "goom", XINE_VERSION_CODE, &goom_special_info, &goom_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
@@ -140,7 +127,6 @@ static void goom_class_dispose(post_class_t *class_gen);
static void goom_dispose(post_plugin_t *this_gen);
/* rewire function */
-static int goom_rewire_audio(xine_post_out_t *output, void *data);
static int goom_rewire_video(xine_post_out_t *output, void *data);
static int goom_port_open(xine_audio_port_t *this, xine_stream_t *stream,
@@ -232,33 +218,27 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_goom_t *this = (post_plugin_goom_t *)xine_xmalloc(sizeof(post_plugin_goom_t));
- post_class_goom_t *class = (post_class_goom_t*) class_gen;
- xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
- post_goom_out_t *output = (post_goom_out_t *)malloc(sizeof(post_goom_out_t));
- post_goom_out_t *outputv = (post_goom_out_t *)malloc(sizeof(post_goom_out_t));
+ post_plugin_goom_t *this = (post_plugin_goom_t *)xine_xmalloc(sizeof(post_plugin_goom_t));
+ post_class_goom_t *class = (post_class_goom_t*) class_gen;
+ post_in_t *input;
+ post_out_t *output;
+ post_out_t *outputv;
post_audio_port_t *port;
xine_cfg_entry_t fps_entry, width_entry, height_entry, csc_method_entry;
- if (!this || !input || !output || !outputv || !video_target || !video_target[0] ||
- !audio_target || !audio_target[0] ) {
+ if (!this || !video_target || !video_target[0] || !audio_target || !audio_target[0]) {
free(this);
- free(input);
- free(output);
- free(outputv);
return NULL;
}
- memset(this, 0, sizeof(post_plugin_goom_t));
- memset(input, 0, sizeof(xine_post_in_t));
- memset(output, 0, sizeof(post_goom_out_t));
- memset(outputv, 0, sizeof(post_goom_out_t));
-
+ _x_post_init(&this->post, 1, 0);
+
/*
* Lookup config entries.
*/
this->class = class;
class->ip = this;
+ this->vo_port = video_target[0];
this->metronom = _x_metronom_init(1, 0, class->xine);
@@ -283,54 +263,28 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs,
this->width_back = this->width;
this->height_back = this->height;
- this->title_flag = 0;
- this->msg_flag = 0;
- this->msg_index = 0;
- this->msg = NULL;
-
goom_init (this->width_back, this->height_back, 0);
this->ratio = (double)this->width_back/(double)this->height_back;
this->sample_counter = 0;
- this->stream = NULL;
- this->vo_port = video_target[0];
this->buf.mem = NULL;
this->buf.mem_size = 0;
- port = _x_post_intercept_audio_port(&this->post, audio_target[0]);
- port->port.open = goom_port_open;
- port->port.close = goom_port_close;
- port->port.put_buffer = goom_port_put_buffer;
-
- input->name = "audio in";
- input->type = XINE_POST_DATA_AUDIO;
- input->data = (xine_audio_port_t *)&port->port;
-
- output->out.name = "audio out";
- output->out.type = XINE_POST_DATA_AUDIO;
- output->out.data = (xine_audio_port_t **)&port->original_port;
- output->out.rewire = goom_rewire_audio;
- output->post = this;
-
- outputv->out.name = "generated video";
- outputv->out.type = XINE_POST_DATA_VIDEO;
- outputv->out.data = (xine_video_port_t **)&this->vo_port;
- outputv->out.rewire = goom_rewire_video;
- outputv->post = this;
-
- this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *) * 2);
- this->post.xine_post.audio_input[0] = &port->port;
- this->post.xine_post.audio_input[1] = NULL;
- this->post.xine_post.video_input = (xine_video_port_t **)malloc(sizeof(xine_video_port_t *) * 1);
- this->post.xine_post.video_input[0] = 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.output, output);
+ port = _x_post_intercept_audio_port(&this->post, audio_target[0], &input, &output);
+ port->new_port.open = goom_port_open;
+ port->new_port.close = goom_port_close;
+ port->new_port.put_buffer = goom_port_put_buffer;
+
+ outputv = &this->video_output;
+ outputv->xine_out.name = "generated video";
+ outputv->xine_out.type = XINE_POST_DATA_VIDEO;
+ outputv->xine_out.data = (xine_video_port_t **)&this->vo_port;
+ outputv->xine_out.rewire = goom_rewire_video;
+ outputv->post = &this->post;
xine_list_append_content(this->post.output, outputv);
+
+ this->post.xine_post.audio_input[0] = &port->new_port;
this->post.dispose = goom_dispose;
@@ -356,65 +310,35 @@ static void goom_class_dispose(post_class_t *class_gen)
static void goom_dispose(post_plugin_t *this_gen)
{
post_plugin_goom_t *this = (post_plugin_goom_t *)this_gen;
- xine_post_out_t *output = (xine_post_out_t *)xine_list_last_content(this_gen->output);
- xine_video_port_t *port = *(xine_video_port_t **)output->data;
-
- this->class->ip = NULL;
-
- goom_close();
- this->metronom->exit(this->metronom);
+ if (_x_post_dispose(this_gen)) {
+ this->class->ip = NULL;
- 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_first_content(this->post.output));
- xine_list_free(this->post.input);
- xine_list_free(this->post.output);
- if(this->buf.mem)
- free(this->buf.mem);
- free(this);
-}
+ goom_close();
+ this->metronom->exit(this->metronom);
-static int goom_rewire_audio(xine_post_out_t *output_gen, void *data)
-{
- post_goom_out_t *output = (post_goom_out_t *)output_gen;
- xine_audio_port_t *old_port = *(xine_audio_port_t **)output_gen->data;
- xine_audio_port_t *new_port = (xine_audio_port_t *)data;
- post_plugin_goom_t *this = (post_plugin_goom_t *)output->post;
-
- if (!data)
- return 0;
- if (this->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, this->stream);
- new_port->open(new_port, this->stream, this->bits, this->sample_rate, this->mode);
+ if(this->buf.mem)
+ free(this->buf.mem);
+ free(this);
}
- /* reconnect ourselves */
- *(xine_audio_port_t **)output_gen->data = new_port;
- return 1;
}
+
static int goom_rewire_video(xine_post_out_t *output_gen, void *data)
{
- post_goom_out_t *output = (post_goom_out_t *)output_gen;
+ post_out_t *output = (post_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;
post_plugin_goom_t *this = (post_plugin_goom_t *)output->post;
if (!data)
return 0;
- if (this->stream) {
- /* register our stream at the new output port */
- old_port->close(old_port, this->stream);
- new_port->open(new_port, this->stream);
- }
+ /* register our stream at the new output port */
+ old_port->close(old_port, NULL);
+ new_port->open(new_port, NULL);
/* reconnect ourselves */
- *(xine_video_port_t **)output_gen->data = new_port;
+ this->vo_port = new_port;
return 1;
}
@@ -424,16 +348,25 @@ static int goom_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream,
post_audio_port_t *port = (post_audio_port_t *)port_gen;
post_plugin_goom_t *this = (post_plugin_goom_t *)port->post;
- this->bits = bits;
- this->mode = mode;
+ _x_post_rewire_audio(port);
+ _x_post_inc_usage(port);
+
+ if (stream)
+ port->stream = stream;
+ else
+ port->stream = POST_NULL_STREAM;
+ port->bits = bits;
+ port->rate = rate;
+ port->mode = mode;
+
this->channels = _x_ao_mode2channels(mode);
+ this->sample_rate = rate;
this->samples_per_frame = rate / this->fps;
- this->sample_rate = rate;
- this->stream = stream;
this->data_idx = 0;
init_yuv_planes(&this->yuv, this->width, this->height);
this->skip_frame = 0;
+ this->vo_port->open(this->vo_port, NULL);
this->metronom->set_master(this->metronom, stream->metronom);
return port->original_port->open(port->original_port, stream, bits, rate, mode );
@@ -446,11 +379,14 @@ static void goom_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream )
free_yuv_planes(&this->yuv);
- this->stream = NULL;
+ port->stream = NULL;
+ this->vo_port->close(this->vo_port, NULL);
this->metronom->set_master(this->metronom, NULL);
port->original_port->close(port->original_port, stream );
+
+ _x_post_dec_usage(port);
}
static void goom_port_put_buffer (xine_audio_port_t *port_gen,
@@ -459,7 +395,6 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen,
post_audio_port_t *port = (post_audio_port_t *)port_gen;
post_plugin_goom_t *this = (post_plugin_goom_t *)port->post;
vo_frame_t *frame;
- /* uint32_t *goom_frame; */
uint8_t *goom_frame, *goom_frame_end;
int16_t *data;
int8_t *data8;
@@ -475,11 +410,11 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen,
this->buf.mem_size = buf->mem_size;
}
memcpy(this->buf.mem, buf->mem,
- buf->num_frames*this->channels*((this->bits == 8)?1:2));
+ buf->num_frames*this->channels*((port->bits == 8)?1:2));
this->buf.num_frames = buf->num_frames;
/* pass data to original port */
- port->original_port->put_buffer(port->original_port, buf, stream );
+ port->original_port->put_buffer(port->original_port, buf, stream);
/* we must not use original data anymore, it should have already being moved
* to the fifo of free audio buffers. just use our private copy instead.
@@ -492,7 +427,7 @@ static void goom_port_put_buffer (xine_audio_port_t *port_gen,
do {
- if( this->bits == 8 ) {
+ if( port->bits == 8 ) {
data8 = (int8_t *)buf->mem;
data8 += samples_used * this->channels;