[Scummvm-cvs-logs] CVS: scummvm/graphics animation.cpp,1.4,1.5 animation.h,1.4,1.5
Max Horn
fingolfin at users.sourceforge.net
Mon Mar 22 16:21:10 CET 2004
Update of /cvsroot/scummvm/scummvm/graphics
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3834/graphics
Modified Files:
animation.cpp animation.h
Log Message:
Unify MPEG2 code even more
Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/animation.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- animation.cpp 22 Mar 2004 20:46:30 -0000 1.4
+++ animation.cpp 23 Mar 2004 00:10:17 -0000 1.5
@@ -151,6 +151,82 @@
#endif
}
+bool BaseAnimationState::decodeFrame() {
+#ifdef USE_MPEG2
+ mpeg2_state_t state;
+ const mpeg2_sequence_t *sequence_i;
+ size_t size = (size_t) -1;
+
+ do {
+ state = mpeg2_parse(decoder);
+ sequence_i = info->sequence;
+
+ switch (state) {
+ case STATE_BUFFER:
+ size = mpgfile->read(buffer, BUFFER_SIZE);
+ mpeg2_buffer(decoder, buffer, buffer + size);
+ break;
+
+ case STATE_SLICE:
+ case STATE_END:
+ if (info->display_fbuf) {
+ /* simple audio video sync code:
+ * we calculate the actual frame by taking the elapsed audio time and try
+ * to stay inside +- 1 frame of this calculated frame number by dropping
+ * frames if we run behind and delaying if we are too fast
+ */
+
+ /* Avoid deadlock is sound was too far ahead */
+ if (bgSoundStream && !bgSound.isActive())
+ return false;
+
+ if (checkPaletteSwitch() || (bgSoundStream == NULL) ||
+ ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum + 1) ||
+ frameskipped > 10) {
+ if (frameskipped > 10) {
+ warning("force frame %i redraw", framenum);
+ frameskipped = 0;
+ }
+ drawYUV(sequence_i->width, sequence_i->height, info->display_fbuf->buf);
+
+ if (bgSoundStream) {
+ while ((_snd->getChannelElapsedTime(bgSound) * 12) / 1000 < framenum)
+ _sys->delay_msecs(10);
+ } else {
+ ticks += 83;
+ while (_sys->get_msecs() < ticks)
+ _sys->delay_msecs(10);
+ // FIXME: This used to be used for the Sword2 version of this
+ // method. I do not see any compelling reason why it should be
+ // used, but maybe I am wrong; so if you know more, either
+ // remove this comment, or change the implementation of the
+ // method to use "sleepUntil" for BS2.
+ //_vm->sleepUntil(ticks);
+ }
+
+ } else {
+ warning("dropped frame %i", framenum);
+ frameskipped++;
+ }
+
+#ifdef BACKEND_8BIT
+ buildLookup(palnum + 1, lutcalcnum);
+#endif
+
+ framenum++;
+ return true;
+
+ }
+ break;
+
+ default:
+ break;
+ }
+ } while (size);
+#endif
+ return false;
+}
+
bool BaseAnimationState::checkPaletteSwitch() {
#ifdef BACKEND_8BIT
// if we have reached the last image with this palette, switch to new one
Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/animation.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- animation.h 22 Mar 2004 20:46:30 -0000 1.4
+++ animation.h 23 Mar 2004 00:10:17 -0000 1.5
@@ -123,8 +123,12 @@
virtual ~BaseAnimationState();
bool init(const char *name);
+ bool decodeFrame();
+
protected:
bool checkPaletteSwitch();
+ virtual void drawYUV(int width, int height, byte *const *dat) = 0;
+
#ifdef BACKEND_8BIT
void buildLookup(int p, int lines);
virtual void setPalette(byte *pal) = 0;
More information about the Scummvm-git-logs
mailing list