summaryrefslogtreecommitdiff
path: root/src/libmpeg2
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-02-09 07:13:22 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-02-09 07:13:22 +0000
commit8700c75544d88f1479d5455b5b2788921d4dd5ee (patch)
tree7a80e2b00e4e7294c7d7ca1440c4d136ccf12998 /src/libmpeg2
parent2f8fed75fc94e7afe89f7b60586f7cb55737efe1 (diff)
downloadxine-lib-8700c75544d88f1479d5455b5b2788921d4dd5ee.tar.gz
xine-lib-8700c75544d88f1479d5455b5b2788921d4dd5ee.tar.bz2
the long-awaited video_out changes, not completely debuged (races)
- pts are 64 bit now - scr and video_out-loop run all the time - video_out cleanups - metronom cleanups - buffer type BUF_CONTROL_DISCONTINUITY is used internally now, input plugins should no longer send this one - support for individual frame durations - using nano-/usleep instead of itimer (simpler code, maybe this will help freebsd) CVS patchset: 1487 CVS date: 2002/02/09 07:13:22
Diffstat (limited to 'src/libmpeg2')
-rw-r--r--src/libmpeg2/decode.c169
-rw-r--r--src/libmpeg2/header.c43
-rw-r--r--src/libmpeg2/mpeg2_internal.h10
-rw-r--r--src/libmpeg2/slice.c17
-rw-r--r--src/libmpeg2/xine_decoder.c41
5 files changed, 137 insertions, 143 deletions
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c
index 2c2a25de2..999ef3079 100644
--- a/src/libmpeg2/decode.c
+++ b/src/libmpeg2/decode.c
@@ -22,10 +22,6 @@
*
*/
-/*
-#define LOG_PAN_SCAN
-*/
-
#include "config.h"
#include <stdio.h>
@@ -40,6 +36,12 @@
#include "xine_internal.h"
#include "events.h"
+/*
+#define LOG_PAN_SCAN
+*/
+
+#define LOG
+
#define BUFFER_SIZE (224 * 1024)
mpeg2_config_t config;
@@ -49,7 +51,7 @@ static void process_userdata(mpeg2dec_t *mpeg2dec, uint8_t *buffer);
void mpeg2_init (mpeg2dec_t * mpeg2dec,
vo_instance_t * output)
{
- static int do_init = 1;
+ static int do_init = 1;
if (do_init) {
do_init = 0;
@@ -79,50 +81,54 @@ void mpeg2_init (mpeg2dec_t * mpeg2dec,
header_state_init (mpeg2dec->picture);
}
-static int get_frame_duration(mpeg2dec_t * mpeg2dec, vo_frame_t * frame)
+static inline void get_frame_duration (mpeg2dec_t * mpeg2dec, vo_frame_t *frame)
{
- int duration;
- switch (frame->frame_rate_code) {
+ switch (mpeg2dec->picture->frame_rate_code) {
case 1: /* 23.976 fps */
- frame->duration = 3913;
+ frame->duration = 3913;
+ frame->pts_corrector = 0;
break;
case 2: /* 24 fps */
- frame->duration = 3750;
+ frame->duration = 3750;
+ frame->pts_corrector = 0;
break;
case 3: /* 25 fps */
- frame->duration = frame->repeat_first_field ? 5400 : 3600;
+ frame->duration = mpeg2dec->picture->repeat_first_field ? 5400 : 3600;
+ frame->pts_corrector = 0;
break;
case 4: /* 29.97 fps */
- if ((frame->repeat_first_field) || (mpeg2dec->last_repeat_first_field)) {
- frame->duration = 3754;
+ if ((mpeg2dec->picture->repeat_first_field) || (mpeg2dec->last_repeat_first_field)) {
+ frame->duration = 3754;
frame->pts_corrector = frame->repeat_first_field ? 375 : -375;
} else {
- frame->duration = 3003;
+ frame->duration = 3003;
frame->pts_corrector = 0;
}
-// duration = 3754;
-// duration = frame->repeat_first_field ? 4504 : 3003;
break;
case 5: /* 30 fps */
- frame->duration = 3000;
+ frame->duration = 3000;
+ frame->pts_corrector = 0;
break;
case 6: /* 50 fps */
- frame->duration = 1800;
+ frame->duration = 1800;
+ frame->pts_corrector = 0;
break;
case 7: /* 59.94 fps */
- frame->duration = 1525;
+ frame->duration = 1525;
+ frame->pts_corrector = 0;
break;
case 8: /* 60 fps */
- frame->duration = 1509;
+ frame->duration = 1509;
+ frame->pts_corrector = 0;
break;
default:
/* printf ("invalid/unknown frame rate code : %d \n",
frame->frame_rate_code); */
- duration = 3000;
+ frame->duration = 3000;
+ frame->pts_corrector = 0;
}
/* printf("mpeg2dec: rff=%u\n",frame->repeat_first_field); */
mpeg2dec->last_repeat_first_field = frame->repeat_first_field;
- return 1;
}
static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
@@ -159,8 +165,6 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
if ( picture->current_frame && ((picture->picture_structure == FRAME_PICTURE) ||
(picture->second_field)) ) {
- picture->current_frame->bad_frame |= mpeg2dec->drop_frame;
-
#if 0
printf ("type %s: %s\n",
picture->picture_coding_type == I_TYPE ? "I" :
@@ -168,10 +172,11 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
picture->current_frame->bad_frame ? "BAD" : "good");
#endif
if (picture->picture_coding_type == B_TYPE) {
- if (picture->mpeg1) {
- picture->current_frame->PTS = 0;
- }
- get_frame_duration(mpeg2dec, picture->current_frame);
+
+ /* hack against wrong mpeg1 pts */
+ if (picture->mpeg1)
+ picture->current_frame->pts = 0;
+
mpeg2dec->frames_to_drop = picture->current_frame->draw (picture->current_frame);
picture->current_frame->free (picture->current_frame);
picture->current_frame = NULL;
@@ -225,7 +230,7 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
break;
case I_TYPE:
- /*
+ /* for the sake of dvd menus, never drop i-frames
if (mpeg2dec->frames_to_drop>4) {
mpeg2dec->drop_frame = 1;
}
@@ -249,7 +254,7 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
|| (picture->frame_height != picture->coded_picture_height)) {
xine_frame_change_event_t notify_event;
- printf ("mpeg2dec: frame size has changed to from %d x %d to %d x %d\n",
+ printf ("libmpeg2: frame size has changed to from %d x %d to %d x %d\n",
picture->frame_width, picture->frame_height,
picture->coded_picture_width, picture->coded_picture_height);
@@ -264,7 +269,7 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
if (picture->backward_reference_frame)
picture->backward_reference_frame->free (picture->backward_reference_frame);
- printf ("mpeg2dec: old frames freed.\n");
+ printf ("libmpeg2: old frames freed.\n");
mpeg2dec->is_sequence_needed = 0;
picture->forward_reference_frame = NULL;
@@ -277,23 +282,23 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
case 0xb5: /* extension_start_code */
if (header_process_extension (picture, buffer)) {
- fprintf (stderr, "bad extension\n");
- exit (1);
+ printf ("libmpeg2: bad extension\n");
+ exit (1);
}
break;
case 0xb7: /* sequence end code */
#ifdef LOG_PAN_SCAN
- printf ("libmpeg2:SEQUENCE END CODE NOT HANDLED!\n");
+ printf ("libmpeg2: sequence end code not handled\n");
#endif
case 0xb8: /* group of pictures start code */
if (header_process_group_of_pictures (picture, buffer)) {
- fprintf (stderr, "bad group of pictures\n");
- exit (1);
+ printf ("libmpeg2: bad group of pictures\n");
+ exit (1);
}
default:
if (code >= 0xb9)
- fprintf (stderr, "stream not demultiplexed ?\n");
+ printf ("libmpeg2: stream not demultiplexed ?\n");
if (code >= 0xb0)
break;
@@ -315,7 +320,6 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
picture->coded_picture_height,
picture->aspect_ratio_information,
IMGFMT_YV12,
- picture->frame_duration,
picture->picture_structure);
else {
picture->current_frame =
@@ -324,7 +328,6 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
picture->coded_picture_height,
picture->aspect_ratio_information,
IMGFMT_YV12,
- picture->frame_duration,
(VO_PREDICTION_FLAG | picture->picture_structure));
if (picture->forward_reference_frame)
picture->forward_reference_frame->free (picture->forward_reference_frame);
@@ -333,19 +336,15 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
picture->backward_reference_frame;
picture->backward_reference_frame = picture->current_frame;
}
- picture->current_frame->bad_frame = 0;
- picture->current_frame->drawn = 0;
- picture->current_frame->PTS = mpeg2dec->pts;
- picture->current_frame->SCR = mpeg2dec->scr;
- picture->current_frame->aspect_ratio = picture->aspect_ratio_information;
- picture->current_frame->frame_rate_code = picture->frame_rate_code;
- picture->current_frame->top_field_first = picture->top_field_first;
- picture->current_frame->progressive_sequence = picture->progressive_sequence;
+ picture->current_frame->bad_frame = 1;
+ picture->current_frame->drawn = 0;
+ picture->current_frame->pts = mpeg2dec->pts;
+ picture->current_frame->scr = mpeg2dec->scr;
+ picture->current_frame->top_field_first = picture->top_field_first;
picture->current_frame->repeat_first_field = picture->repeat_first_field;
- picture->current_frame->progressive_frame = picture->progressive_frame;
- picture->current_frame->picture_coding_type = picture->picture_coding_type;
- picture->current_frame->bitrate = picture->bitrate;
- picture->current_frame->repeat_first_field = picture->repeat_first_field;
+
+ get_frame_duration(mpeg2dec, picture->current_frame);
+
mpeg2dec->pts = 0;
}
}
@@ -353,7 +352,8 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
if (!(mpeg2dec->drop_frame)) {
/* printf ("slice_process\n"); */
- slice_process (picture, code, buffer);
+ if (slice_process (picture, code, buffer) == 1)
+ picture->current_frame->bad_frame = 0;
#ifdef ARCH_X86
if (config.flags & MM_ACCEL_X86_MMX)
@@ -362,7 +362,7 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
}
}
- /* printf ("parse_chunk %d completed\n", code); */
+ /* printf ("libmpeg2: parse_chunk %d completed\n", code); */
return is_frame_done;
}
@@ -381,8 +381,8 @@ static inline uint8_t * copy_chunk (mpeg2dec_t * mpeg2dec,
limit = end;
/*
- printf ("copy chunk current %08x\n", current );
- printf ("copy chunk end %08x\n", end); fflush(stdout);
+ printf ("libmpeg2: copy chunk current %08x\n", current );
+ printf ("libmpeg2: copy chunk end %08x\n", end); fflush(stdout);
*/
while (1) {
@@ -444,31 +444,32 @@ int mpeg2_decode_data (mpeg2dec_t * mpeg2dec, uint8_t * current, uint8_t * end,
void mpeg2_flush (mpeg2dec_t * mpeg2dec) {
- picture_t *picture = mpeg2dec->picture;
+ picture_t *picture = mpeg2dec->picture;
- if (picture->backward_reference_frame && !picture->backward_reference_frame->drawn) {
- vo_frame_t *img;
-
- printf ("libmpeg2: blasting out backward reference frame on flush\n");
- picture->backward_reference_frame->PTS = 0;
- picture->backward_reference_frame->SCR = mpeg2dec->scr;
- get_frame_duration(mpeg2dec, picture->backward_reference_frame);
- picture->backward_reference_frame->bad_frame = 0;
- picture->backward_reference_frame->drawn = 1;
- picture->backward_reference_frame->displayed (picture->backward_reference_frame);
-
- /* output a copy instead of the frame used by decoder */
- img = picture->backward_reference_frame->instance->duplicate_frame(
- picture->backward_reference_frame->instance,
- picture->backward_reference_frame);
- img->PTS = 0;
- img->SCR = mpeg2dec->scr;
- img->bad_frame = 0;
- img->drawn = 2;
- img->draw(img);
-
- img->free(img);
- }
+ if (picture->backward_reference_frame && !picture->backward_reference_frame->drawn
+ && !picture->backward_reference_frame->bad_frame) {
+
+ vo_frame_t *img;
+
+ printf ("libmpeg2: blasting out backward reference frame on flush\n");
+
+ picture->backward_reference_frame->drawn = 1;
+
+ /* output a copy instead of the frame used by decoder */
+ img = picture->backward_reference_frame->instance->duplicate_frame(picture->backward_reference_frame->instance,
+ picture->backward_reference_frame);
+ img->pts = 0;
+ img->scr = 0;
+ img->bad_frame = 0;
+ img->drawn = 1;
+
+ img->draw(img);
+ img->free(img);
+
+ } else {
+ printf ("libmpeg2: flush called, but I have no frame to flush\n");
+
+ }
}
@@ -501,9 +502,8 @@ void mpeg2_close (mpeg2dec_t * mpeg2dec)
if (picture->throwaway_frame) {
printf ("libmpeg2: blasting out throwaway frame on close\n");
- picture->throwaway_frame->PTS = 0;
- picture->throwaway_frame->SCR = mpeg2dec->scr;
- picture->throwaway_frame->bad_frame = 0;
+ picture->throwaway_frame->pts = 0;
+ picture->throwaway_frame->scr = 0;
get_frame_duration(mpeg2dec, picture->throwaway_frame);
picture->throwaway_frame->draw (picture->throwaway_frame);
picture->throwaway_frame->free (picture->throwaway_frame);
@@ -511,10 +511,9 @@ void mpeg2_close (mpeg2dec_t * mpeg2dec)
if (picture->backward_reference_frame) {
printf ("libmpeg2: blasting out backward reference frame on close\n");
- picture->backward_reference_frame->PTS = 0;
- picture->backward_reference_frame->SCR = mpeg2dec->scr;
+ picture->backward_reference_frame->pts = 0;
+ picture->backward_reference_frame->scr = mpeg2dec->scr;
get_frame_duration(mpeg2dec, picture->backward_reference_frame);
- picture->backward_reference_frame->bad_frame = 0;
if( !picture->backward_reference_frame->drawn)
picture->backward_reference_frame->draw (picture->backward_reference_frame);
picture->backward_reference_frame->free (picture->backward_reference_frame);
diff --git a/src/libmpeg2/header.c b/src/libmpeg2/header.c
index e075f51e1..0a486f0f9 100644
--- a/src/libmpeg2/header.c
+++ b/src/libmpeg2/header.c
@@ -131,39 +131,7 @@ int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
/* this is not used by the decoder */
picture->aspect_ratio_information = buffer[3] >> 4;
picture->frame_rate_code = buffer[3] & 15;
-
- switch (picture->frame_rate_code) {
- case 1: /* 23.976 fps */
- picture->frame_duration = 3913;
- break;
- case 2: /* 24 fps */
- picture->frame_duration = 3750;
- break;
- case 3: /* 25 fps */
- picture->frame_duration = 3600;
- break;
- case 4: /* 29.97 fps */
- picture->frame_duration = 3003;
- break;
- case 5: /* 30 fps */
- picture->frame_duration = 3000;
- break;
- case 6: /* 50 fps */
- picture->frame_duration = 1800;
- break;
- case 7: /* 59.94 fps */
- picture->frame_duration = 1525;
- break;
- case 8: /* 60 fps */
- picture->frame_duration = 1509;
- break;
- default:
- /* printf ("invalid/unknown frame rate code : %d \n",
- picture->frame_rate_code); */
- picture->frame_duration = 3000;
- }
-
- picture->bitrate = (buffer[4]<<10)|(buffer[5]<<2)|(buffer[6]>>6);
+ /* picture->bitrate = (buffer[4]<<10)|(buffer[5]<<2)|(buffer[6]>>6); */
if (buffer[7] & 2) {
for (i = 0; i < 64; i++)
@@ -194,6 +162,7 @@ int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
/* picture->alternate_scan = 0; */
picture->picture_structure = FRAME_PICTURE;
/* picture->second_field = 0; */
+ picture->last_mba = ((width * height) >> 8) - 1;
return 0;
}
@@ -209,10 +178,14 @@ static int header_process_sequence_extension (picture_t * picture,
/* this is not used by the decoder */
picture->progressive_sequence = (buffer[1] >> 3) & 1;
+ picture->low_delay = buffer[5] & 0x80;
+
if (picture->progressive_sequence)
picture->coded_picture_height =
(picture->coded_picture_height + 31) & ~31;
+ printf ("libmpeg2: low_delay : %d\n", picture->low_delay);
+
/*
printf ("libmpeg2: sequence extension+5 : %08x (%d)\n",
buffer[5], buffer[5] % 0x80);
@@ -422,6 +395,8 @@ int header_process_group_of_pictures (picture_t * picture, uint8_t * buffer) {
int header_process_picture_header (picture_t *picture, uint8_t * buffer)
{
picture->picture_coding_type = (buffer [1] >> 3) & 7;
+ picture->vbv_delay = ((buffer[1] << 13) | (buffer[2] << 5) |
+ (buffer[3] >> 3)) & 0xffff;
/* forward_f_code and backward_f_code - used in mpeg1 only */
picture->f_motion.f_code[1] = (buffer[3] >> 2) & 1;
@@ -437,3 +412,5 @@ int header_process_picture_header (picture_t *picture, uint8_t * buffer)
return 0;
}
+
+
diff --git a/src/libmpeg2/mpeg2_internal.h b/src/libmpeg2/mpeg2_internal.h
index fcb70368b..767be0093 100644
--- a/src/libmpeg2/mpeg2_internal.h
+++ b/src/libmpeg2/mpeg2_internal.h
@@ -91,6 +91,9 @@ typedef struct picture_s {
/* what type of picture this is (I, P, B, D) */
int picture_coding_type;
+
+ int vbv_delay;
+ int low_delay;
/* picture coding extension stuff */
@@ -107,6 +110,8 @@ typedef struct picture_s {
int q_scale_type;
/* bool to use different vlc tables */
int intra_vlc_format;
+ /* last macroblock in the picture */
+ int last_mba;
/* used for DMV MC */
int top_field_first;
@@ -132,11 +137,10 @@ typedef struct picture_s {
/* this is a temporary interface, we will build a better one later. */
int aspect_ratio_information;
int frame_rate_code;
- int frame_duration;
int progressive_sequence;
int repeat_first_field;
int progressive_frame;
- int bitrate;
+ /*int bitrate; */
uint32_t frame_centre_horizontal_offset;
uint32_t frame_centre_vertical_offset;
uint32_t video_format;
@@ -222,7 +226,7 @@ extern mc_functions_t mc_functions_altivec;
extern mc_functions_t mc_functions_mlib;
/* slice.c */
-void slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
+int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
/* stats.c */
void stats_header (uint8_t code, uint8_t * buffer);
diff --git a/src/libmpeg2/slice.c b/src/libmpeg2/slice.c
index 4abdf8a4a..3cd547f24 100644
--- a/src/libmpeg2/slice.c
+++ b/src/libmpeg2/slice.c
@@ -968,7 +968,7 @@ do { \
NEEDBITS (bit_buf, bits, bit_ptr); \
continue; \
default: /* end of slice, or error */ \
- return; \
+ return (mba >= picture->last_mba); \
} \
} \
DUMPBITS (bit_buf, bits, tab->len); \
@@ -1497,15 +1497,15 @@ do { \
dest[2] += 4 * stride; \
} while (0); \
if (! (picture->mpeg1)) \
- return; \
+ return (mba >= picture->last_mba); \
picture->v_offset += 16; \
if (picture->v_offset >= picture->coded_picture_height) \
- return; \
+ return 1; \
offset = 0; \
} \
} while (0)
-void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
+int slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
{
#define bit_buf (picture->bitstream_buf)
#define bits (picture->bitstream_bits)
@@ -1515,8 +1515,10 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
uint8_t * dest[3];
int offset;
uint8_t ** forward_ref[2];
+ int mba;
stride = picture->coded_picture_width;
+ mba = (code-1) * (stride >> 4);
offset = (code - 1) * stride * 4;
picture->v_offset = (code - 1) * 16;
@@ -1592,6 +1594,7 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
NEEDBITS (bit_buf, bits, bit_ptr);
GET_MACROBLOCK_ADDRESS_INCREMENT (offset);
+ mba += offset;
offset <<= 4;
while (1) {
@@ -1744,6 +1747,7 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
picture->dc_dct_pred[2] = 1 << (picture->intra_dc_precision+7);
}
+ mba++;
offset += 16;
CHECK_DISPLAY;
@@ -1764,6 +1768,7 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
else
MOTION (motion_fi_zero, MACROBLOCK_MOTION_FORWARD);
+ mba++;
offset += 16;
CHECK_DISPLAY;
} while (--mba_inc);
@@ -1776,6 +1781,7 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
else
MOTION (motion_fi_reuse, macroblock_modes);
+ mba++;
offset += 16;
CHECK_DISPLAY;
} while (--mba_inc);
@@ -1785,4 +1791,7 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer)
#undef bit_buf
#undef bits
#undef bit_ptr
+
+ return (mba >= picture->last_mba);
+
}
diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c
index 2f6a338bb..da5415253 100644
--- a/src/libmpeg2/xine_decoder.c
+++ b/src/libmpeg2/xine_decoder.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2001 the xine project
+ * Copyright (C) 2000-2002 the xine project
*
* This file is part of xine, a unix video player.
*
@@ -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.20 2002/01/05 21:54:17 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.21 2002/02/09 07:13:23 guenter Exp $
*
* stuff needed to turn libmpeg2 into a xine decoder plugin
*/
@@ -36,69 +36,74 @@
#include "buffer.h"
#include "xine_internal.h"
+#define LOG
+
typedef struct mpeg2dec_decoder_s {
video_decoder_t video_decoder;
mpeg2dec_t mpeg2;
vo_instance_t *video_out;
- /*int mpeg_file;*/ /* debugging purposes only */
+ pthread_mutex_t lock; /* mutex for async flush */
} mpeg2dec_decoder_t;
static int mpeg2dec_can_handle (video_decoder_t *this_gen, int buf_type) {
return ((buf_type & 0xFFFF0000) == BUF_VIDEO_MPEG) ;
}
-
static void mpeg2dec_init (video_decoder_t *this_gen, vo_instance_t *video_out) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+ printf ("libmpeg2: init \n");
mpeg2_init (&this->mpeg2, video_out);
video_out->open(video_out);
this->video_out = video_out;
-
- /* debugging purposes */
- /*this->mpeg_file = open ("/tmp/video.mpv",O_CREAT | O_WRONLY | O_TRUNC, 0644);*/
+ pthread_mutex_init (&this->lock, NULL);
}
static void mpeg2dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+ printf ("libmpeg2: decode_data...\n");
+
+ pthread_mutex_lock (&this->lock);
+
if (buf->decoder_info[0] == 0) {
mpeg2_find_sequence_header (&this->mpeg2, buf->content, buf->content + buf->size);
} else {
- /* debugging purposes */
- /* write (this->mpeg_file, buf->content, buf->size); */
-
mpeg2_decode_data (&this->mpeg2, buf->content, buf->content + buf->size,
- buf->PTS, buf->SCR);
-
- this->video_out->decoder_started(this->video_out);
+ buf->pts, buf->scr);
}
+ pthread_mutex_unlock (&this->lock);
+
+ printf ("libmpeg2: decode_data...done\n");
}
static void mpeg2dec_flush (video_decoder_t *this_gen) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+ pthread_mutex_lock (&this->lock);
+ printf ("libmpeg2: flush\n");
+
mpeg2_flush (&this->mpeg2);
+ pthread_mutex_unlock (&this->lock);
}
static void mpeg2dec_close (video_decoder_t *this_gen) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+ printf ("libmpeg2: close\n");
+
mpeg2_close (&this->mpeg2);
this->video_out->close(this->video_out);
- /* debugging purposes */
- /*
- close (this->mpeg_file);
- this->mpeg_file = -1;
- */
+ pthread_mutex_destroy (&this->lock);
+
}
static char *mpeg2dec_get_id(void) {