diff options
author | Mike Melanson <mike@multimedia.cx> | 2002-11-02 21:38:38 +0000 |
---|---|---|
committer | Mike Melanson <mike@multimedia.cx> | 2002-11-02 21:38:38 +0000 |
commit | 0250eacf7013b2b80ddd1268d7ba48696d97acb8 (patch) | |
tree | 5ac597a0cf2b32f778f5a77fa158c695f93d5e16 | |
parent | 06878214eb135f073ece5834cb273f85cb5aa615 (diff) | |
download | xine-lib-0250eacf7013b2b80ddd1268d7ba48696d97acb8.tar.gz xine-lib-0250eacf7013b2b80ddd1268d7ba48696d97acb8.tar.bz2 |
bring the foovideo reference video decoder in line with the latest API
revision
CVS patchset: 3155
CVS date: 2002/11/02 21:38:38
-rw-r--r-- | src/libxinevdec/foovideo.c | 147 |
1 files changed, 92 insertions, 55 deletions
diff --git a/src/libxinevdec/foovideo.c b/src/libxinevdec/foovideo.c index 0bea30f16..65cc235d2 100644 --- a/src/libxinevdec/foovideo.c +++ b/src/libxinevdec/foovideo.c @@ -17,10 +17,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * General description and author credits go here... - * - * Leave the following line intact for when the decoder is committed to CVS: - * $Id: foovideo.c,v 1.7 2002/10/03 03:09:35 tmmm Exp $ + * foovideo.c: This is a reference video decoder for the xine multimedia + * player. It really works too! It will output frames of packed YUY2 data + * where each byte in the map is the same value, which is 3 larger than the + * value from the last frame. This creates a slowly rotating solid color + * frame when the frames are played in succession. + * + * $Id: foovideo.c,v 1.8 2002/11/02 21:38:38 tmmm Exp $ */ #include <stdio.h> @@ -37,11 +40,17 @@ #define VIDEOBUFSIZE 128*1024 +typedef struct { + video_decoder_class_t decoder_class; +} foovideo_class_t; + typedef struct foovideo_decoder_s { video_decoder_t video_decoder; /* parent video decoder structure */ + foovideo_class_t *class; + xine_stream_t *stream; + /* these are traditional variables in a video decoder object */ - vo_instance_t *video_out; /* object that will receive frames */ uint64_t video_step; /* frame duration in pts units */ int decoder_ok; /* current decoder status */ int skipframes; @@ -67,22 +76,6 @@ typedef struct foovideo_decoder_s { *************************************************************************/ /* - * This function is responsible is called to initialize the video decoder - * for use. Initialization usually involves setting up the fields in your - * private video decoder object. - */ -static void foovideo_init (video_decoder_t *this_gen, - vo_instance_t *video_out) { - foovideo_decoder_t *this = (foovideo_decoder_t *) this_gen; - - /* set our own video_out object to the one that xine gives us */ - this->video_out = video_out; - - /* indicate that the decoder is not quite ready yet */ - this->decoder_ok = 0; -} - -/* * This function receives a buffer of data from the demuxer layer and * figures out how to handle it based on its header flags. */ @@ -99,7 +92,7 @@ static void foovideo_decode_data (video_decoder_t *this_gen, return; if (buf->decoder_flags & BUF_FLAG_HEADER) { /* need to initialize */ - this->video_out->open (this->video_out); + this->stream->video_out->open (this->stream->video_out); if(this->buf) free(this->buf); @@ -115,7 +108,7 @@ static void foovideo_decode_data (video_decoder_t *this_gen, this->buf = malloc(this->bufsize); this->size = 0; - this->video_out->open (this->video_out); + this->stream->video_out->open (this->stream->video_out); this->decoder_ok = 1; /* do anything else relating to initializing this decoder */ @@ -138,7 +131,7 @@ static void foovideo_decode_data (video_decoder_t *this_gen, if (buf->decoder_flags & BUF_FLAG_FRAME_END) { - img = this->video_out->get_frame (this->video_out, + img = this->stream->video_out->get_frame (this->stream->video_out, this->width, this->height, XINE_VO_ASPECT_DONT_TOUCH, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS); @@ -172,8 +165,7 @@ static void foovideo_decode_data (video_decoder_t *this_gen, } /* - * This function is called when xine needs to flush the system. Not - * sure when or if this is used or even if it needs to do anything. + * This function is called when xine needs to flush the system. */ static void foovideo_flush (video_decoder_t *this_gen) { } @@ -188,11 +180,10 @@ static void foovideo_reset (video_decoder_t *this_gen) { } /* - * This function is called when xine shuts down the decoder. It should - * free any memory and release any other resources allocated during the - * execution of the decoder. + * This function frees the video decoder instance allocated to the decoder. */ -static void foovideo_close (video_decoder_t *this_gen) { +static void foovideo_dispose (video_decoder_t *this_gen) { + foovideo_decoder_t *this = (foovideo_decoder_t *) this_gen; if (this->buf) { @@ -202,63 +193,109 @@ static void foovideo_close (video_decoder_t *this_gen) { if (this->decoder_ok) { this->decoder_ok = 0; - this->video_out->close(this->video_out); + this->stream->video_out->close(this->stream->video_out); } + + free (this_gen); +} + +/* + * This function allocates, initializes, and returns a private video + * decoder structure. + */ +static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) { + + foovideo_decoder_t *this ; + + this = (foovideo_decoder_t *) xine_xmalloc (sizeof (foovideo_decoder_t)); + + this->video_decoder.decode_data = foovideo_decode_data; + this->video_decoder.flush = foovideo_flush; + this->video_decoder.reset = foovideo_reset; + this->video_decoder.dispose = foovideo_dispose; + this->size = 0; + + this->stream = stream; + this->class = (foovideo_class_t *) class_gen; + + this->decoder_ok = 0; + this->buf = NULL; + + return &this->video_decoder; } /* - * This function returns the human-readable ID string to identify - * this decoder. + * This function returns a brief string that describes (usually with the + * decoder's most basic name) the video decoder plugin. */ -static char *foovideo_get_id(void) { +static char *get_identifier (video_decoder_class_t *this) { return "foovideo"; } /* - * This function frees the video decoder instance allocated to the decoder. + * This function returns a slightly longer string describing the video + * decoder plugin. */ -static void foovideo_dispose (video_decoder_t *this_gen) { - free (this_gen); +static char *get_description (video_decoder_class_t *this) { + return "foovideo: reference xine video decoder plugin"; +} + +/* + * This function frees the video decoder class and any other memory that was + * allocated. + */ +static void dispose_class (video_decoder_class_t *this) { + free (this); } /* - * This function should be the plugin's only advertised function to the - * outside world. It allows xine to query the plugin module for the addresses - * to the necessary functions in the video decoder object. + * This function allocates a private video decoder class and initializes + * the class's member functions. */ -static void *init_video_decoder_plugin (xine_t *xine, void *data) { +static void *init_plugin (xine_t *xine, void *data) { - foovideo_decoder_t *this ; + foovideo_class_t *this; - this = (foovideo_decoder_t *) malloc (sizeof (foovideo_decoder_t)); - memset(this, 0, sizeof (foovideo_decoder_t)); + this = (foovideo_class_t *) xine_xmalloc (sizeof (foovideo_class_t)); - this->video_decoder.init = foovideo_init; - this->video_decoder.decode_data = foovideo_decode_data; - this->video_decoder.flush = foovideo_flush; - this->video_decoder.reset = foovideo_reset; - this->video_decoder.close = foovideo_close; - this->video_decoder.get_identifier = foovideo_get_id; - this->video_decoder.dispose = foovideo_dispose; + this->decoder_class.open_plugin = open_plugin; + this->decoder_class.get_identifier = get_identifier; + this->decoder_class.get_description = get_description; + this->decoder_class.dispose = dispose_class; - return (video_decoder_t *) this; + return this; } /* - * exported plugin catalog entry + * This is a list of all of the internal xine video buffer types that + * this decoder is able to handle. Check src/xine-engine/buffer.h for a + * list of valid buffer types (and add a new one if the one you need does + * not exist). Terminate the list with a 0. */ static uint32_t video_types[] = { /* BUF_VIDEO_FOOVIDEO, */ + BUF_VIDEO_VQA, + BUF_VIDEO_SORENSON_V3, 0 }; +/* + * This data structure combines the list of supported xine buffer types and + * the priority that the plugin should be given with respect to other + * plugins that handle the same buffer type. A plugin with priority (n+1) + * will be used instead of a plugin with priority (n). + */ static decoder_info_t dec_info_video = { video_types, /* supported types */ 5 /* priority */ }; +/* + * The plugin catalog entry. This is the only information that this plugin + * will export to the public. + */ plugin_info_t xine_plugin_info[] = { - /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_DECODER, 10, "foovideo", XINE_VERSION_CODE, &dec_info_video, init_video_decoder_plugin }, + /* { type, API, "name", version, special_info, init_function } */ + { PLUGIN_VIDEO_DECODER, 11, "foovideo", XINE_VERSION_CODE, &dec_info_video, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |