[Mplayer-cvslog] CVS: main spudec.c,1.33,1.34 spudec.h,1.12,1.13
Kim Minh Kaplan CVS
kmkaplan at mplayerhq.hu
Wed Jul 24 18:47:44 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv4312
Modified Files:
spudec.c spudec.h
Log Message:
Make spudec_assemble more resistent in the face of incomplete packets.
Put the global spu_changed into spudec_handle_t.
Index: spudec.c
===================================================================
RCS file: /cvsroot/mplayer/main/spudec.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- spudec.c 17 Jun 2002 19:11:22 -0000 1.33
+++ spudec.c 24 Jul 2002 16:47:29 -0000 1.34
@@ -49,6 +49,7 @@
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 @@
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 @@
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 @@
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 @@
}
memcpy(spu->packet, packet, len);
spu->packet_offset = len;
+ spu->packet_pts = pts100;
}
} else {
// Continue current fragment
@@ -502,8 +507,11 @@
{
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 @@
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 @@
#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;
}
}
}
Index: spudec.h
===================================================================
RCS file: /cvsroot/mplayer/main/spudec.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- spudec.h 17 May 2002 23:47:21 -0000 1.12
+++ spudec.h 24 Jul 2002 16:47:29 -0000 1.13
@@ -14,5 +14,6 @@
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
More information about the MPlayer-cvslog
mailing list