summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Courtier-Dutton <jcdutton@users.sourceforge.net>2002-10-18 16:46:23 +0000
committerJames Courtier-Dutton <jcdutton@users.sourceforge.net>2002-10-18 16:46:23 +0000
commit8bb89fd2610320780a1db6763451492ded6bdccb (patch)
tree2e05cf021a9f4aa3748a7605a9327865d4af95e2 /src
parenta6f73d008c8ba9f07f4c3cff3603ed99c517e04d (diff)
downloadxine-lib-8bb89fd2610320780a1db6763451492ded6bdccb.tar.gz
xine-lib-8bb89fd2610320780a1db6763451492ded6bdccb.tar.bz2
Enable libmpeg2 for new api.
EVENTS and metainfo might not be sent yet. CVS patchset: 2852 CVS date: 2002/10/18 16:46:23
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/libmpeg2/decode.c50
-rw-r--r--src/libmpeg2/mpeg2.h2
-rw-r--r--src/libmpeg2/xine_decoder.c93
4 files changed, 81 insertions, 65 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e6ad9031a..1a2273a1b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,6 +32,7 @@ SUBDIRS = \
input \
demuxers \
libffmpeg \
+ libmpeg2 \
liba52 \
libmad
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c
index 00b866ecc..2afe03992 100644
--- a/src/libmpeg2/decode.c
+++ b/src/libmpeg2/decode.c
@@ -154,54 +154,54 @@ static void remember_metainfo (mpeg2dec_t *mpeg2dec) {
picture_t * picture = mpeg2dec->picture;
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = picture->frame_width;
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = picture->frame_height;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = picture->frame_width;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = picture->frame_height;
switch (picture->aspect_ratio_information) {
case XINE_VO_ASPECT_PAN_SCAN:
case XINE_VO_ASPECT_ANAMORPHIC:
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 16.0 /9.0;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 16.0 /9.0;
break;
case XINE_VO_ASPECT_DVB: /* 2.11:1 */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 2.11/1.0;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 2.11/1.0;
break;
case XINE_VO_ASPECT_SQUARE: /* square pels */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000;
break;
default:
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 4.0 / 3.0;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_VIDEO_RATIO] = 10000 * 4.0 / 3.0;
break;
}
switch (mpeg2dec->picture->frame_rate_code) {
case 1: /* 23.976 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3913;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3913;
break;
case 2: /* 24 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3750;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3750;
break;
case 3: /* 25 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3600;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3600;
break;
case 4: /* 29.97 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3003;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3003;
break;
case 5: /* 30 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3000;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3000;
break;
case 6: /* 50 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1800;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1800;
break;
case 7: /* 59.94 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1525;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1525;
break;
case 8: /* 60 fps */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1509;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 1509;
break;
default:
/* printf ("invalid/unknown frame rate code : %d \n",
frame->frame_rate_code); */
- mpeg2dec->xine->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3000;
+ mpeg2dec->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] = 3000;
}
}
@@ -349,15 +349,16 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
if (mpeg2dec->is_sequence_needed
|| (picture->frame_width != picture->coded_picture_width)
|| (picture->frame_height != picture->coded_picture_height)) {
- xine_frame_change_event_t notify_event;
-
remember_metainfo (mpeg2dec);
+#if 0
+ xine_frame_change_event_t notify_event;
notify_event.event.type = XINE_EVENT_FRAME_CHANGE;
notify_event.width = picture->coded_picture_width;
notify_event.height = picture->coded_picture_height;
notify_event.aspect = picture->aspect_ratio_information;
xine_send_event(mpeg2dec->xine, &notify_event.event);
+#endif
if (picture->forward_reference_frame)
picture->forward_reference_frame->free (picture->forward_reference_frame);
@@ -680,7 +681,7 @@ void mpeg2_find_sequence_header (mpeg2dec_t * mpeg2dec,
if (mpeg2dec->force_aspect) picture->aspect_ratio_information = mpeg2dec->force_aspect;
if (mpeg2dec->is_sequence_needed) {
- xine_frame_change_event_t notify_event;
+ //xine_frame_change_event_t notify_event;
mpeg2dec->is_sequence_needed = 0;
picture->frame_width = picture->coded_picture_width;
@@ -688,11 +689,11 @@ void mpeg2_find_sequence_header (mpeg2dec_t * mpeg2dec,
remember_metainfo (mpeg2dec);
- notify_event.event.type = XINE_EVENT_FRAME_CHANGE;
- notify_event.width = picture->coded_picture_width;
- notify_event.height = picture->coded_picture_height;
- notify_event.aspect = picture->aspect_ratio_information;
- xine_send_event(mpeg2dec->xine, &notify_event.event);
+ //notify_event.event.type = XINE_EVENT_FRAME_CHANGE;
+ //notify_event.width = picture->coded_picture_width;
+ //notify_event.height = picture->coded_picture_height;
+ //notify_event.aspect = picture->aspect_ratio_information;
+ //xine_send_event(mpeg2dec->xine, &notify_event.event);
}
} else if (code == 0xb5) { /* extension_start_code */
if (mpeg2_header_extension (picture, mpeg2dec->chunk_buffer)) {
@@ -719,6 +720,7 @@ static void process_userdata(mpeg2dec_t *mpeg2dec, uint8_t *buffer)
{
/* check if user data denotes closed captions */
if (buffer[0] == 'C' && buffer[1] == 'C') {
+#if 0
xine_closed_caption_event_t event;
uint8_t *end = find_end(buffer);
@@ -727,5 +729,7 @@ static void process_userdata(mpeg2dec_t *mpeg2dec, uint8_t *buffer)
event.buf_len = end - &buffer[2];
event.pts = mpeg2dec->pts;
xine_send_event(mpeg2dec->xine, &event.event);
+#endif
+
}
}
diff --git a/src/libmpeg2/mpeg2.h b/src/libmpeg2/mpeg2.h
index 723066891..2c3bd4799 100644
--- a/src/libmpeg2/mpeg2.h
+++ b/src/libmpeg2/mpeg2.h
@@ -46,7 +46,7 @@ typedef struct mpeg2dec_s {
int64_t pts;
uint32_t rff_pattern;
int force_aspect;
- xine_t *xine;
+ xine_stream_t *stream;
} mpeg2dec_t ;
diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c
index f3a548c1e..65d6276a1 100644
--- a/src/libmpeg2/xine_decoder.c
+++ b/src/libmpeg2/xine_decoder.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_decoder.c,v 1.40 2002/09/05 22:18:57 mroi Exp $
+ * $Id: xine_decoder.c,v 1.41 2002/10/18 16:46:24 jcdutton Exp $
*
* stuff needed to turn libmpeg2 into a xine decoder plugin
*/
@@ -39,36 +39,20 @@
/*
#define LOG
*/
+typedef struct {
+ video_decoder_class_t decoder_class;
+} mpeg2_class_t;
+
typedef struct mpeg2dec_decoder_s {
video_decoder_t video_decoder;
mpeg2dec_t mpeg2;
+ mpeg2_class_t *class;
+ xine_stream_t *stream;
vo_instance_t *video_out;
pthread_mutex_t lock; /* mutex for async flush */
} mpeg2dec_decoder_t;
-static void mpeg2dec_init (video_decoder_t *this_gen, vo_instance_t *video_out) {
-
- mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
-
-#ifdef LOG
- printf ("libmpeg2: init... \n");
-#endif
-
- pthread_mutex_lock (&this->lock);
-
- mpeg2_init (&this->mpeg2, video_out);
- video_out->open(video_out);
- this->video_out = video_out;
- this->mpeg2.force_aspect = 0;
-
- pthread_mutex_unlock (&this->lock);
-
-#ifdef LOG
- printf ("libmpeg2: init...done\n");
-#endif
-}
-
static void mpeg2dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
@@ -129,7 +113,7 @@ static void mpeg2dec_reset (video_decoder_t *this_gen) {
}
-static void mpeg2dec_close (video_decoder_t *this_gen) {
+static void mpeg2dec_dispose (video_decoder_t *this_gen) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
@@ -144,41 +128,68 @@ static void mpeg2dec_close (video_decoder_t *this_gen) {
this->video_out->close(this->video_out);
pthread_mutex_unlock (&this->lock);
-}
-
-static char *mpeg2dec_get_id(void) {
- return "mpeg2dec";
-}
-
-static void mpeg2dec_dispose (video_decoder_t *this_gen) {
- mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
pthread_mutex_destroy (&this->lock);
free (this);
}
-static void *init_video_decoder_plugin (xine_t *xine, void *data) {
-
+static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
mpeg2dec_decoder_t *this ;
this = (mpeg2dec_decoder_t *) malloc (sizeof (mpeg2dec_decoder_t));
memset(this, 0, sizeof (mpeg2dec_decoder_t));
- this->video_decoder.init = mpeg2dec_init;
this->video_decoder.decode_data = mpeg2dec_decode_data;
this->video_decoder.flush = mpeg2dec_flush;
this->video_decoder.reset = mpeg2dec_reset;
- this->video_decoder.close = mpeg2dec_close;
- this->video_decoder.get_identifier = mpeg2dec_get_id;
this->video_decoder.dispose = mpeg2dec_dispose;
-
- this->mpeg2.xine = xine;
+ this->stream = stream;
+ this->class = (mpeg2_class_t *) class_gen;
+ this->mpeg2.stream = stream;
pthread_mutex_init (&this->lock, NULL);
- return this;
+ pthread_mutex_lock (&this->lock);
+
+ mpeg2_init (&this->mpeg2, stream->video_out);
+ stream->video_out->open(stream->video_out);
+ this->video_out = stream->video_out;
+ this->mpeg2.force_aspect = 0;
+
+ pthread_mutex_unlock (&this->lock);
+
+ return &this->video_decoder;
}
/*
+ * mpeg2 plugin class
+ */
+
+static char *get_identifier (video_decoder_class_t *this) {
+ return "mpeg2dec";
+}
+
+static char *get_description (video_decoder_class_t *this) {
+ return "mpeg2 based video decoder plugin";
+}
+
+static void dispose_class (video_decoder_class_t *this) {
+ free (this);
+}
+
+static void *init_plugin (xine_t *xine, void *data) {
+
+ mpeg2_class_t *this;
+
+ this = (mpeg2_class_t *) malloc (sizeof (mpeg2_class_t));
+
+ 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 this;
+}
+/*
* exported plugin catalog entry
*/
@@ -191,6 +202,6 @@ static decoder_info_t dec_info_mpeg2 = {
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 10, "mpeg2", XINE_VERSION_CODE, &dec_info_mpeg2, init_video_decoder_plugin },
+ { PLUGIN_VIDEO_DECODER, 11, "mpeg2", XINE_VERSION_CODE, &dec_info_mpeg2, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};