Make spudec_assemble more resistent in the face of incomplete packets.

Put the global spu_changed into spudec_handle_t.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6779 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
kmkaplan 2002-07-24 16:47:29 +00:00
parent a793730000
commit 54edd9eaef
2 changed files with 17 additions and 5 deletions

View File

@ -49,6 +49,7 @@ typedef struct {
size_t packet_reserve; /* size of the memory pointed to by packet */
unsigned int packet_offset; /* end of the currently assembled fragment */
unsigned int packet_size; /* size of the packet once all fragments are assembled */
unsigned int packet_pts; /* PTS for this packet */
unsigned int control_start; /* index of start of control data */
unsigned int palette[4];
unsigned int alpha[4];
@ -75,10 +76,9 @@ typedef struct {
int auto_palette; /* 1 if we lack a palette and must use an heuristic. */
int font_start_level; /* Darkest value used for the computed font */
vo_functions_t *hw_spu;
int spu_changed;
} spudec_handle_t;
static int spu_changed = 0;
static inline unsigned int get_be16(const unsigned char *p)
{
return (p[0] << 8) + p[1];
@ -402,13 +402,13 @@ static void spudec_decode(spudec_handle_t *this, unsigned int pts100)
spudec_process_control(this, pts100);
spudec_process_data(this);
}
spu_changed = 1;
this->spu_changed = 1;
}
int spudec_changed(void * this)
{
spudec_handle_t * spu = (spudec_handle_t*)this;
return (spu_changed|(spu->now_pts > spu->end_pts));
return (spu->spu_changed || spu->now_pts > spu->end_pts);
}
void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsigned int pts100)
@ -419,6 +419,10 @@ void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsign
mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: packet too short\n");
return;
}
if (spu->packet_pts < pts100) {
spu->packet_pts = pts100;
spu->packet_offset = 0;
}
if (spu->packet_offset == 0) {
unsigned int len2 = get_be16(packet);
// Start new fragment
@ -437,6 +441,7 @@ void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsign
}
memcpy(spu->packet, packet, len);
spu->packet_offset = len;
spu->packet_pts = pts100;
}
} else {
// Continue current fragment
@ -502,8 +507,11 @@ void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsi
{
spudec_handle_t *spu = (spudec_handle_t *)this;
if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image)
{
draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height,
spu->image, spu->aimage, spu->stride);
spu->spu_changed = 0;
}
}
/* calc the bbox for spudec subs */
@ -603,8 +611,11 @@ void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*dra
if (spu->orig_frame_width == 0 || spu->orig_frame_height == 0
|| (spu->orig_frame_width == dxs && spu->orig_frame_height == dys)) {
if (spu->image)
{
draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height,
spu->image, spu->aimage, spu->stride);
spu->spu_changed = 0;
}
}
else {
if (spu->scaled_frame_width != dxs || spu->scaled_frame_height != dys) { /* Resizing is needed */
@ -887,7 +898,7 @@ nothing_to_do:
#endif
draw_alpha(spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height,
spu->scaled_image, spu->scaled_aimage, spu->scaled_stride);
spu_changed = 0;
spu->spu_changed = 0;
}
}
}

View File

@ -14,5 +14,6 @@ void spudec_reset(void *this); // called after seek
int spudec_visible(void *this); // check if spu is visible
void spudec_set_font_factor(void * this, double factor); // sets the equivalent to ffactor
void spudec_set_hw_spu(void *this, vo_functions_t *hw_spu);
int spudec_changed(void *this);
#endif