[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/movie avi.c movie.c
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src/movie avi.c movie.c |
Date: |
Mon, 13 Oct 2003 22:20:22 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/10/13 22:20:22
Modified files:
src/movie : avi.c movie.c
Log message:
Cleanup
Patches:
Index: stratagus/src/movie/avi.c
diff -u stratagus/src/movie/avi.c:1.11 stratagus/src/movie/avi.c:1.12
--- stratagus/src/movie/avi.c:1.11 Sun Aug 17 11:57:07 2003
+++ stratagus/src/movie/avi.c Mon Oct 13 22:20:22 2003
@@ -10,7 +10,7 @@
//
/address@hidden avi.c - avi support */
//
-// (c) Copyright 2002 by Lutz Sammer.
+// (c) Copyright 2002-2003 by Lutz Sammer.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: avi.c,v 1.11 2003/08/17 15:57:07 n0body Exp $
+// $Id: avi.c,v 1.12 2003/10/14 02:20:22 jsalmon3 Exp $
//@{
@@ -73,7 +73,7 @@
//
// Open and check if it is an avi file.
//
- if (!(f = CLopen(name,CL_OPEN_READ))) {
+ if (!(f = CLopen(name, CL_OPEN_READ))) {
fprintf(stderr, "Can't open `%s'\n", name);
return NULL;
}
@@ -88,14 +88,14 @@
// Check the header magics
//
if (AccessLE32(buf) != 0x46464952) { // RIFF
- DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf)
- _C_ 0x46464952);
+ DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf) _C_
+ 0x46464952);
CLclose(f);
return NULL;
}
if (AccessLE32(buf + 8) != 0x20495641) { // "AVI "
- DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf)
- _C_ 0x20495641);
+ DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf) _C_
+ 0x20495641);
CLclose(f);
return NULL;
}
@@ -124,8 +124,8 @@
DebugLevel0Fn("Bytes %ld\n" _C_ hdr_len);
if (magic != 0x5453494C) { // LIST
- DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf)
- _C_ 0x5453494C);
+ DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf) _C_
+ 0x5453494C);
CLclose(f);
free(avi);
return NULL;
@@ -138,8 +138,8 @@
}
magic = AccessLE32(buf);
if (magic != 0x6C726468) { // hdrl
- DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf)
- _C_ 0x6C726468);
+ DebugLevel0Fn("Wrong magic %x (not %x)\n" _C_ AccessLE32(buf) _C_
+ 0x6C726468);
CLclose(f);
free(avi);
return NULL;
@@ -168,16 +168,16 @@
}
if (magic != 0x5453494C) { // LIST
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x5453494C);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x5453494C);
CLclose(f);
free(avi);
return NULL;
}
magic = AccessLE32(hdr_buf + i + 8);
if (magic != 0x6C727473) { // strl
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x6C727473);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x6C727473);
i += length + 8;
continue; // Ignore unknown LIST
@@ -185,8 +185,8 @@
magic = AccessLE32(hdr_buf + i + 12);
if (magic != 0x68727473) { // strh
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x68727473);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x68727473);
CLclose(f);
free(avi);
return NULL;
@@ -198,7 +198,7 @@
int scale;
int rate;
- memcpy(avi->VideoCodec,hdr_buf + i + 24,4);
+ memcpy(avi->VideoCodec, hdr_buf + i + 24, 4);
scale = AccessLE32(hdr_buf + i + 40);
rate = AccessLE32(hdr_buf + i + 44);
@@ -217,8 +217,8 @@
j += i + 20;
magic = AccessLE32(hdr_buf + j);
if (magic != 0x66727473) { // strf
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x66727473);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x66727473);
CLclose(f);
free(avi);
return NULL;
@@ -230,7 +230,7 @@
DebugLevel0("%dx%d\n" _C_ avi->Width _C_ avi->Height);
avi->VideoTag =
- ((avi->VideoStream / 10 + '0') ) |
+ ((avi->VideoStream / 10 + '0')) |
((avi->VideoStream % 10 + '0') << 8) |
('d' << 16) /*| ('b' << 24)*/;
@@ -238,52 +238,52 @@
avi->AudioStream = stream;
- DebugLevel0Fn("Audio%d: %d\n" _C_ stream
- _C_ AccessLE32(hdr_buf + i + 32));
+ DebugLevel0Fn("Audio%d: %d\n" _C_ stream _C_
+ AccessLE32(hdr_buf + i + 32));
j = AccessLE32(hdr_buf + i + 16);
j = (j + 1) & ~1; // pad even
j += i + 20;
magic = AccessLE32(hdr_buf + j);
if (magic != 0x66727473) { // strf
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x66727473);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x66727473);
CLclose(f);
free(avi);
return NULL;
}
- DebugLevel0Fn("Audio%d: Format %x Channels %d Rate %d Bitrate %d
Bits %d\n"
- _C_ avi->AudioStream
- _C_ AccessLE16(hdr_buf + j + 8 + 0)
- _C_ AccessLE16(hdr_buf + j + 8 + 2)
- _C_ AccessLE32(hdr_buf + j + 8 + 4)
- _C_ AccessLE32(hdr_buf + j + 8 + 8)
- _C_ AccessLE16(hdr_buf + j + 8 + 14));
+ DebugLevel0Fn("Audio%d: Format %x Channels %d Rate %d Bitrate %d
Bits %d\n" _C_
+ avi->AudioStream _C_
+ AccessLE16(hdr_buf + j + 8 + 0) _C_
+ AccessLE16(hdr_buf + j + 8 + 2) _C_
+ AccessLE32(hdr_buf + j + 8 + 4) _C_
+ AccessLE32(hdr_buf + j + 8 + 8) _C_
+ AccessLE16(hdr_buf + j + 8 + 14));
- switch( AccessLE16(hdr_buf + j + 8 + 0) ) {
- case 'O'+('g'<<8):
+ switch (AccessLE16(hdr_buf + j + 8 + 0)) {
+ case 'O' + ('g' << 8):
DebugLevel0Fn("Original stream compatible\n");
break;
- case 'P'+('g'<<8):
+ case 'P' + ('g' << 8):
DebugLevel0Fn("Have independent header\n");
break;
- case 'Q'+('g'<<8):
+ case 'Q' + ('g' << 8):
DebugLevel0Fn("Have no codebook header\n");
break;
- case 'o'+('g'<<8):
+ case 'o' + ('g' << 8):
DebugLevel0Fn("Original stream compatible\n");
break;
- case 'p'+('g'<<8):
+ case 'p' + ('g' << 8):
DebugLevel0Fn("Have independent header\n");
break;
- case 'q'+('g'<<8):
+ case 'q' + ('g' << 8):
DebugLevel0Fn("Have no codebook header\n");
break;
}
avi->AudioTag =
- ((avi->AudioStream / 10 + '0') ) |
+ ((avi->AudioStream / 10 + '0')) |
((avi->AudioStream % 10 + '0') << 8) |
('w' << 16) | ('b' << 24);
@@ -301,7 +301,7 @@
//
// Find movi
//
- for( ;; ) {
+ for (;;) {
if (CLread(f, buf, 8) != 8) { // EOF
DebugLevel0Fn("Unexpected eof\n");
CLclose(f);
@@ -313,14 +313,14 @@
length = (length + 1) & ~1; // pad even
DebugLevel0Fn("Magic %lx %ld\n" _C_ magic _C_ length);
- if( magic == 0x4b4e554a ) { // JUNK
- CLseek(f,length,SEEK_CUR); // skip section
+ if (magic == 0x4b4e554a) { // JUNK
+ CLseek(f, length, SEEK_CUR); // skip section
continue;
}
if (magic != 0x5453494C) { // LIST
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x5453494C);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x5453494C);
CLclose(f);
free(avi);
return NULL;
@@ -336,8 +336,8 @@
length -= 4;
DebugLevel0Fn("Magic %lx %ld\n" _C_ magic _C_ length);
if (magic != 0x69766f6d) { // movi
- DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic
- _C_ 0x69766f6d);
+ DebugLevel0Fn("Wrong magic %lx (not %x)\n" _C_ magic _C_
+ 0x69766f6d);
CLclose(f);
free(avi);
return NULL;
@@ -360,7 +360,7 @@
** @param video Video frame wanted
** @param framep Frame pointer.
*/
-local int AviFrameHandler(AviFile* avi, int video, unsigned char **framep)
+local int AviFrameHandler(AviFile* avi, int video, unsigned char** framep)
{
CLFile* f;
unsigned long magic;
@@ -415,7 +415,7 @@
break;
}
- if ((magic&0x00FFFFFF) == avi->VideoTag) {
+ if ((magic & 0x00FFFFFF) == avi->VideoTag) {
DebugLevel3Fn("Video %lx\n" _C_ avi->VideoTag);
if (!length) {
@@ -449,7 +449,7 @@
continue;
}
- if( magic != 0x4b4e554a ) { // JUNK
+ if (magic != 0x4b4e554a) { // JUNK
DebugLevel0Fn("Tag %lx\n" _C_ magic);
}
CLseek(f, length, SEEK_CUR); // skip section
Index: stratagus/src/movie/movie.c
diff -u stratagus/src/movie/movie.c:1.14 stratagus/src/movie/movie.c:1.15
--- stratagus/src/movie/movie.c:1.14 Fri Jul 11 10:35:33 2003
+++ stratagus/src/movie/movie.c Mon Oct 13 22:20:22 2003
@@ -10,7 +10,7 @@
//
/address@hidden movie.c - Movie playback functions. */
//
-// (c) Copyright 2002 by Lutz Sammer
+// (c) Copyright 2002-2003 by Lutz Sammer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: movie.c,v 1.14 2003/07/11 14:35:33 n0body Exp $
+// $Id: movie.c,v 1.15 2003/10/14 02:20:22 jsalmon3 Exp $
//@{
@@ -57,7 +57,7 @@
#ifdef USE_SDL /// Only supported with SDL for now
-extern SDL_Surface *Screen; /// internal screen
+extern SDL_Surface* Screen; /// internal screen
/*----------------------------------------------------------------------------
-- Defines
@@ -116,7 +116,7 @@
global int MovieDisplayFrame(AviFile* avi, PB_INSTANCE* pbi,
SDL_Overlay* overlay, SDL_Rect rect)
{
- unsigned char *frame;
+ unsigned char* frame;
int length;
int i;
YUV_BUFFER_CONFIG yuv;
@@ -160,7 +160,7 @@
*/
local void MovieCallbackKey(unsigned dummy __attribute__((unused)))
{
- MovieKeyPressed=0;
+ MovieKeyPressed = 0;
}
/**
@@ -169,7 +169,7 @@
local void MovieCallbackKey2(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused)))
{
- MovieKeyPressed=0;
+ MovieKeyPressed = 0;
}
/**
@@ -178,7 +178,7 @@
local void MovieCallbackKey3(unsigned dummy1 __attribute__((unused)),
unsigned dummy2 __attribute__((unused)))
{
- MovieKeyPressed=0;
+ MovieKeyPressed = 0;
}
/**
@@ -206,11 +206,11 @@
**
** @todo Support full screen and resolution changes.
*/
-global int PlayMovie(const char *name, int flags)
+global int PlayMovie(const char* name, int flags)
{
- AviFile *avi;
- SDL_Overlay *overlay;
- PB_INSTANCE *pbi;
+ AviFile* avi;
+ SDL_Overlay* overlay;
+ PB_INSTANCE* pbi;
EventCallback callbacks;
SDL_Rect rect;
@@ -220,7 +220,7 @@
return 1;
}
- if( avi->AudioStream != -1 ) { // Only if audio available
+ if (avi->AudioStream != -1) { // Only if audio available
StopMusic();
}
@@ -230,9 +230,8 @@
if (flags & PlayMovieFullScreen) {
DebugLevel0Fn("FIXME: full screen switch not supported\n");
}
- overlay =
- SDL_CreateYUVOverlay(avi->Width, avi->Height, SDL_YV12_OVERLAY,
- Screen);
+ overlay = SDL_CreateYUVOverlay(avi->Width, avi->Height,
+ SDL_YV12_OVERLAY, Screen);
if (!overlay) {
fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError());
exit(1);
@@ -246,20 +245,20 @@
StartDecoder(&pbi, avi->Width, avi->Height);
#if defined(WITH_SOUND) && defined(USE_OGG)
- if( avi->AudioStream != -1 ) { // Only if audio available
+ if (avi->AudioStream != -1) { // Only if audio available
PlayAviOgg(avi);
}
#endif
- callbacks.ButtonPressed=MovieCallbackKey;
- callbacks.ButtonReleased=MovieCallbackKey;
- callbacks.MouseMoved=MovieCallbackMouse;
- callbacks.MouseExit=MovieCallbackExit;
- callbacks.KeyPressed=MovieCallbackKey2;
- callbacks.KeyReleased=MovieCallbackKey2;
- callbacks.KeyRepeated=MovieCallbackKey3;
- callbacks.NetworkEvent=NetworkEvent;
- callbacks.SoundReady=WriteSound;
+ callbacks.ButtonPressed = MovieCallbackKey;
+ callbacks.ButtonReleased = MovieCallbackKey;
+ callbacks.MouseMoved = MovieCallbackMouse;
+ callbacks.MouseExit = MovieCallbackExit;
+ callbacks.KeyPressed = MovieCallbackKey2;
+ callbacks.KeyReleased = MovieCallbackKey2;
+ callbacks.KeyRepeated = MovieCallbackKey3;
+ callbacks.NetworkEvent = NetworkEvent;
+ callbacks.SoundReady = WriteSound;
if (flags & PlayMovieZoomScreen) {
if (flags & PlayMovieKeepAspect) {
@@ -269,7 +268,7 @@
wa = VideoWidth * 100 / avi->Width;
ha = VideoHeight * 100 / avi->Height;
DebugLevel0Fn(" %d x %d\n" _C_ wa _C_ ha);
- if( wa < ha ) { // Keep the aspect ratio
+ if (wa < ha) { // Keep the aspect ratio
rect.w = VideoWidth;
rect.h = avi->Height * wa / 100;
} else {
@@ -287,7 +286,7 @@
rect.x = (VideoWidth - rect.w) / 2;
rect.y = (VideoHeight - rect.h) / 2;
- if( 1 ) {
+ if (1) {
int i;
GetPbParam(pbi, PBC_SET_POSTPROC, &i);
@@ -305,7 +304,7 @@
WaitEventsOneFrame(&callbacks);
}
- if( avi->AudioStream != -1 ) { // Only if audio available
+ if (avi->AudioStream != -1) { // Only if audio available
StopMusic();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/movie avi.c movie.c,
Jimmy Salmon <=