Bink: clean up headers and formatting
This commit is contained in:
parent
3c3b436cc1
commit
e6a01e2379
2 changed files with 123 additions and 207 deletions
226
src/bink.c
226
src/bink.c
|
@ -1,40 +1,27 @@
|
|||
#include "bink.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fixer.h"
|
||||
|
||||
#include "bink.h"
|
||||
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#include <SDL.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libswscale/swscale.h>
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libswscale/swscale.h"
|
||||
|
||||
|
||||
//#define DISABLE_MOVIES
|
||||
//#define DISABLE_MUSIC
|
||||
//#define DISABLE_FMVS
|
||||
|
||||
extern void SDL_Delay();
|
||||
extern uint SDL_GetTicks();
|
||||
extern int SoundSys_IsOn();
|
||||
extern void DrawAvpMenuBink(char* buf, int width, int height, int pitch);
|
||||
extern float PlatVolumeToGain(int volume);
|
||||
|
||||
|
||||
//#define AL_CHECK() { int err = alGetError(); if(err!=AL_NO_ERROR) printf("%s:%d ALError %04x\n", __FILE__, __LINE__, err); }
|
||||
#define AL_CHECK() {}
|
||||
|
||||
#define FRAMEQUEUESIZE 4
|
||||
|
||||
struct binkMovie
|
||||
{
|
||||
struct binkMovie {
|
||||
AVFormatContext* avContext;
|
||||
AVPacket packet;
|
||||
|
||||
|
@ -64,18 +51,12 @@ struct binkMovie
|
|||
ALuint alSampleRate;
|
||||
|
||||
uint timeStart;
|
||||
|
||||
BOOL looping;
|
||||
BOOL isfmv;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
||||
static void BinkRenderMovie(struct binkMovie* aMovie)
|
||||
{
|
||||
if(aMovie && aMovie->videoFrame && aMovie->videoScalePicture[0])
|
||||
{
|
||||
if (aMovie && aMovie->videoFrame && aMovie->videoScalePicture[0]) {
|
||||
DrawAvpMenuBink(
|
||||
aMovie->videoScalePicture[0],
|
||||
aMovie->videoFrame->width,
|
||||
|
@ -84,7 +65,6 @@ static void BinkRenderMovie(struct binkMovie* aMovie)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void BinkInitMovieStruct(struct binkMovie* aMovie)
|
||||
{
|
||||
*aMovie = (struct binkMovie){
|
||||
|
@ -96,8 +76,7 @@ static void BinkInitMovieStruct(struct binkMovie* aMovie)
|
|||
|
||||
static void BinkReleaseMovie(struct binkMovie* aMovie)
|
||||
{
|
||||
if(aMovie->alInited)
|
||||
{
|
||||
if (aMovie->alInited) {
|
||||
alSourceStop(aMovie->alSource);
|
||||
alDeleteSources(1, &aMovie->alSource);
|
||||
alDeleteBuffers(FRAMEQUEUESIZE, aMovie->alBuffers);
|
||||
|
@ -105,9 +84,6 @@ static void BinkReleaseMovie(struct binkMovie* aMovie)
|
|||
free(aMovie->audioTempBuffer);
|
||||
}
|
||||
|
||||
if(aMovie->videoScaleContext)
|
||||
av_freep(&aMovie->videoScalePicture[0]);
|
||||
|
||||
if (aMovie->avContext)
|
||||
avformat_close_input(&aMovie->avContext);
|
||||
if (aMovie->audioCodecContext)
|
||||
|
@ -118,6 +94,8 @@ static void BinkReleaseMovie(struct binkMovie* aMovie)
|
|||
avcodec_free_context(&aMovie->videoCodecContext);
|
||||
if (aMovie->videoFrame)
|
||||
av_frame_free(&aMovie->videoFrame);
|
||||
if (aMovie->videoScaleContext)
|
||||
av_freep(&aMovie->videoScalePicture[0]);
|
||||
|
||||
BinkInitMovieStruct(aMovie);
|
||||
}
|
||||
|
@ -125,15 +103,16 @@ static void BinkReleaseMovie(struct binkMovie* aMovie)
|
|||
|
||||
static int DecodeVideoFrame(struct binkMovie* aMovie)
|
||||
{
|
||||
int ret = avcodec_receive_frame(aMovie->videoCodecContext, aMovie->videoFrame);
|
||||
if (ret < 0)
|
||||
if (avcodec_receive_frame(aMovie->videoCodecContext, aMovie->videoFrame) != 0)
|
||||
return 0;
|
||||
|
||||
if(aMovie->videoScaleContext==NULL)
|
||||
{
|
||||
if(aMovie->videoScaleWidth==0) aMovie->videoScaleWidth = aMovie->videoFrame->width;
|
||||
if(aMovie->videoScaleHeight==0) aMovie->videoScaleHeight = aMovie->videoFrame->height;
|
||||
if(aMovie->videoScaleFormat==AV_PIX_FMT_NONE) aMovie->videoScaleFormat = AV_PIX_FMT_RGB565;
|
||||
if (aMovie->videoScaleContext == NULL) {
|
||||
if (aMovie->videoScaleWidth == 0)
|
||||
aMovie->videoScaleWidth = aMovie->videoFrame->width;
|
||||
if (aMovie->videoScaleHeight == 0)
|
||||
aMovie->videoScaleHeight = aMovie->videoFrame->height;
|
||||
if (aMovie->videoScaleFormat == AV_PIX_FMT_NONE)
|
||||
aMovie->videoScaleFormat = AV_PIX_FMT_RGB565;
|
||||
|
||||
aMovie->videoScaleContext = sws_getContext(
|
||||
aMovie->videoFrame->width, aMovie->videoFrame->height,
|
||||
|
@ -159,19 +138,13 @@ static int DecodeVideoFrame(struct binkMovie* aMovie)
|
|||
|
||||
static int DecodeAudioFrame(struct binkMovie* aMovie)
|
||||
{
|
||||
int decoded_frame_ready = 0;
|
||||
av_frame_unref(aMovie->audioFrame);
|
||||
//avcodec_get_frame_defaults(aMovie->audioFrame);
|
||||
|
||||
int ret = avcodec_receive_frame(aMovie->audioCodecContext, aMovie->audioFrame);
|
||||
if (ret < 0)
|
||||
if (avcodec_receive_frame(aMovie->audioCodecContext, aMovie->audioFrame) != 0)
|
||||
return 0;
|
||||
|
||||
if (!SoundSys_IsOn())
|
||||
return 0;
|
||||
|
||||
if(!aMovie->alInited)
|
||||
{
|
||||
if (!aMovie->alInited) {
|
||||
alGenSources(1, &aMovie->alSource);
|
||||
AL_CHECK();
|
||||
|
||||
|
@ -192,24 +165,27 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
|
|||
for (int i=0; i < aMovie->alNumFreeBuffers; i++)
|
||||
aMovie->alFreeBuffers[i] = aMovie->alBuffers[i];
|
||||
|
||||
switch(aMovie->audioFrame->channel_layout)
|
||||
{
|
||||
switch (aMovie->audioFrame->channel_layout) {
|
||||
case AV_CH_LAYOUT_MONO:
|
||||
aMovie->alFormat = (aMovie->audioFrame->format == AV_SAMPLE_FMT_U8) ? AL_FORMAT_MONO8 : AL_FORMAT_MONO16;
|
||||
aMovie->alFormat = (aMovie->audioFrame->format == AV_SAMPLE_FMT_U8) ?
|
||||
AL_FORMAT_MONO8 : AL_FORMAT_MONO16;
|
||||
aMovie->alNumChannels = 1;
|
||||
break;
|
||||
case AV_CH_LAYOUT_STEREO:
|
||||
aMovie->alFormat = (aMovie->audioFrame->format == AV_SAMPLE_FMT_U8) ? AL_FORMAT_STEREO8 : AL_FORMAT_STEREO16;
|
||||
aMovie->alFormat = (aMovie->audioFrame->format == AV_SAMPLE_FMT_U8) ?
|
||||
AL_FORMAT_STEREO8 : AL_FORMAT_STEREO16;
|
||||
aMovie->alNumChannels = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
aMovie->alSampleRate = aMovie->audioFrame->sample_rate;
|
||||
aMovie->audioTempBuffer = malloc(aMovie->alNumChannels * aMovie->audioFrame->nb_samples * 2 * 2);
|
||||
aMovie->audioTempBuffer =
|
||||
malloc(aMovie->alNumChannels * aMovie->audioFrame->nb_samples * 2 * 2);
|
||||
aMovie->alInited = TRUE;
|
||||
}
|
||||
|
||||
memset(aMovie->audioTempBuffer, 0, aMovie->alNumChannels * aMovie->audioFrame->nb_samples * 2 * 2);
|
||||
memset(aMovie->audioTempBuffer, 0,
|
||||
aMovie->alNumChannels * aMovie->audioFrame->nb_samples * 2 * 2);
|
||||
|
||||
if (aMovie->alNumChannels == 0)
|
||||
return 0;
|
||||
|
@ -217,17 +193,14 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
|
|||
// reclaim completed frames
|
||||
int processedBuffers = 0;
|
||||
alGetSourcei(aMovie->alSource, AL_BUFFERS_PROCESSED, &processedBuffers);
|
||||
if(processedBuffers>0)
|
||||
{
|
||||
if (processedBuffers > 0) {
|
||||
alSourceStop(aMovie->alSource);
|
||||
while(processedBuffers>0)
|
||||
{
|
||||
while (processedBuffers > 0) {
|
||||
ALuint buffer = 0;
|
||||
alSourceUnqueueBuffers(aMovie->alSource, 1, &buffer);
|
||||
AL_CHECK();
|
||||
|
||||
if(buffer>0)
|
||||
{
|
||||
if (buffer > 0) {
|
||||
aMovie->alFreeBuffers[aMovie->alNumFreeBuffers] = buffer;
|
||||
aMovie->alNumFreeBuffers++;
|
||||
}
|
||||
|
@ -237,27 +210,20 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
|
|||
}
|
||||
|
||||
// queue this frame
|
||||
if(aMovie->alNumFreeBuffers>0)
|
||||
{
|
||||
if (aMovie->alNumFreeBuffers > 0) {
|
||||
ALuint alBuffer = aMovie->alFreeBuffers[aMovie->alNumFreeBuffers-1];
|
||||
|
||||
int sampleCount = aMovie->audioFrame->nb_samples * aMovie->alNumChannels;
|
||||
|
||||
|
||||
// 16bit is deafult
|
||||
uint dataSize = sampleCount*2;
|
||||
uint dataSize = sampleCount * 2; // 16bit is deafult
|
||||
void* data = (void*)aMovie->audioFrame->extended_data[0];
|
||||
|
||||
switch(aMovie->audioFrame->format)
|
||||
{
|
||||
case AV_SAMPLE_FMT_U8:
|
||||
{
|
||||
switch (aMovie->audioFrame->format) {
|
||||
case AV_SAMPLE_FMT_U8: {
|
||||
dataSize = sampleCount;
|
||||
} break;
|
||||
|
||||
default:
|
||||
case AV_SAMPLE_FMT_S16:
|
||||
{
|
||||
case AV_SAMPLE_FMT_S16: {
|
||||
/*
|
||||
unsigned short* p = (unsigned short*) data;
|
||||
for(int i=0; i<sampleCount; i++)
|
||||
|
@ -265,23 +231,21 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
|
|||
*/
|
||||
} break;
|
||||
|
||||
case AV_SAMPLE_FMT_FLT:
|
||||
{
|
||||
case AV_SAMPLE_FMT_FLT: {
|
||||
data = (void*)aMovie->audioTempBuffer;
|
||||
short* tempBuf = (short*)aMovie->audioTempBuffer;
|
||||
float* srcBuf = (float*)aMovie->audioFrame->extended_data[0];
|
||||
for(int i=0; i<sampleCount; i++)
|
||||
{
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
float val = srcBuf[i] * 32768;
|
||||
if(val > 32767) val = 32767;
|
||||
if(val < -32768) val = 32768;
|
||||
if (val > 32767)
|
||||
val = 32767;
|
||||
if (val < -32768)
|
||||
val = 32768;
|
||||
tempBuf[i] = (short)val;
|
||||
|
||||
}
|
||||
} break;
|
||||
|
||||
case AV_SAMPLE_FMT_S32:
|
||||
{
|
||||
case AV_SAMPLE_FMT_S32: {
|
||||
data = (void*)aMovie->audioTempBuffer;
|
||||
short* tempBuf = (short*)aMovie->audioTempBuffer;
|
||||
unsigned int* srcBuf = (unsigned int*)aMovie->audioFrame->extended_data[0];
|
||||
|
@ -289,19 +253,17 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
|
|||
tempBuf[i] = (short)(((*srcBuf - *srcBuf>>2) >> 16) & 0x0000FFFF);
|
||||
} break;
|
||||
|
||||
case AV_SAMPLE_FMT_FLTP:
|
||||
{
|
||||
case AV_SAMPLE_FMT_FLTP: {
|
||||
data = (void*)aMovie->audioTempBuffer;
|
||||
short* tempBuf = (short*)aMovie->audioTempBuffer;
|
||||
|
||||
for(int i=0; i<aMovie->audioFrame->nb_samples; i++)
|
||||
{
|
||||
for(int j=0; j<aMovie->alNumChannels; j++)
|
||||
{
|
||||
for (int i = 0; i < aMovie->audioFrame->nb_samples; i++) {
|
||||
for (int j = 0; j < aMovie->alNumChannels; j++) {
|
||||
float* srcBuf = (float*)aMovie->audioFrame->extended_data[j];
|
||||
float val = srcBuf[i] * 32768;
|
||||
if(val > 32767) val = 32767;
|
||||
if(val < -32768) val = 32768;
|
||||
if (val > 32767)
|
||||
val = 32767;
|
||||
if (val < -32768)
|
||||
val = 32768;
|
||||
tempBuf[(i*aMovie->alNumChannels)+j] = (short)val;
|
||||
}
|
||||
}
|
||||
|
@ -310,8 +272,6 @@ static int DecodeAudioFrame(struct binkMovie* aMovie)
|
|||
|
||||
alSourceStop(aMovie->alSource);
|
||||
|
||||
//printf("fmt=%d, buffer size=%d, rdy=%d, len=%d, s1=%d, samples=%d\n", aMovie->audioFrame->format, dataSize, decoded_frame_ready, len, aPacket->size, sampleCount);
|
||||
|
||||
alBufferData(alBuffer, aMovie->alFormat, data, dataSize - 16, aMovie->alSampleRate);
|
||||
AL_CHECK();
|
||||
|
||||
|
@ -334,6 +294,7 @@ static int ReadFrame(struct binkMovie* aMovie)
|
|||
{
|
||||
// Read from file if no packet is buffered.
|
||||
if (!aMovie->packet.buf && av_read_frame(aMovie->avContext, &aMovie->packet) < 0) {
|
||||
// No more packets in file.
|
||||
if (aMovie->looping) {
|
||||
av_seek_frame(aMovie->avContext, -1, 0, 0);
|
||||
return ReadFrame(aMovie);
|
||||
|
@ -363,33 +324,28 @@ static int ReadFrame(struct binkMovie* aMovie)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static int BinkStartMovie(struct binkMovie* aMovie, const char* aFilename, BOOL aLoopFlag, BOOL aFmvFlag, BOOL aMusicFlag)
|
||||
static int BinkStartMovie(struct binkMovie* aMovie, const char* aFilename,
|
||||
BOOL aLoopFlag, BOOL aFmvFlag, BOOL aMusicFlag)
|
||||
{
|
||||
BinkInitMovieStruct(aMovie);
|
||||
aMovie->looping = aLoopFlag;
|
||||
|
||||
if(aFmvFlag)
|
||||
{
|
||||
if (aFmvFlag) {
|
||||
aMovie->videoScaleWidth = 128;
|
||||
aMovie->videoScaleHeight = 96;
|
||||
aMovie->videoScaleFormat = AV_PIX_FMT_RGB24;
|
||||
}
|
||||
|
||||
if(avformat_open_input(&aMovie->avContext, aFilename, NULL, NULL) < 0)
|
||||
{
|
||||
if (avformat_open_input(&aMovie->avContext, aFilename, NULL, NULL) != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!avformat_find_stream_info(aMovie->avContext, NULL) < 0)
|
||||
{
|
||||
if (avformat_find_stream_info(aMovie->avContext, NULL) < 0) {
|
||||
BinkReleaseMovie(aMovie);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int numStreams = 0;
|
||||
for(int i=0; i<aMovie->avContext->nb_streams; i++)
|
||||
{
|
||||
for (int i = 0; i < aMovie->avContext->nb_streams; i++) {
|
||||
const AVStream* stream = aMovie->avContext->streams[i];
|
||||
const AVCodec* codec = avcodec_find_decoder(stream->codecpar->codec_id);
|
||||
if (!codec)
|
||||
|
@ -398,41 +354,34 @@ static int BinkStartMovie(struct binkMovie* aMovie, const char* aFilename, BOOL
|
|||
if (!context)
|
||||
continue;
|
||||
if (avcodec_parameters_to_context(context, stream->codecpar) < 0 ||
|
||||
avcodec_open2(context, codec, NULL) < 0) {
|
||||
avcodec_open2(context, codec, NULL) != 0) {
|
||||
avcodec_free_context(&context);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aMovie->videoStreamIndex < 0 && context->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
{
|
||||
if (aMovie->videoStreamIndex < 0 && context->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
aMovie->videoCodecContext = context;
|
||||
aMovie->videoStreamIndex = i;
|
||||
aMovie->videoFrame = av_frame_alloc();
|
||||
aMovie->videoFrameDuration =
|
||||
1000.0f * (float)stream->time_base.num / (float)stream->time_base.den;
|
||||
numStreams++;
|
||||
}
|
||||
else if (aMovie->audioStreamIndex < 0 && context->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
{
|
||||
} else if (aMovie->audioStreamIndex < 0 && context->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
aMovie->audioCodecContext = context;
|
||||
aMovie->audioStreamIndex = i;
|
||||
aMovie->audioFrame = av_frame_alloc();
|
||||
numStreams++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
avcodec_free_context(&context);
|
||||
}
|
||||
}
|
||||
|
||||
if(aMovie->videoStreamIndex < 0 && aMovie->audioStreamIndex < 0)
|
||||
{
|
||||
if (aMovie->videoStreamIndex < 0 && aMovie->audioStreamIndex < 0) {
|
||||
BinkReleaseMovie(aMovie);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!aFmvFlag)
|
||||
{
|
||||
if (!aFmvFlag) {
|
||||
for (int i = 0; i < (FRAMEQUEUESIZE-1) * numStreams; i++)
|
||||
ReadFrame(aMovie);
|
||||
}
|
||||
|
@ -440,7 +389,6 @@ static int BinkStartMovie(struct binkMovie* aMovie, const char* aFilename, BOOL
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int BinkUpdateMovie(struct binkMovie* aMovie)
|
||||
{
|
||||
if(!aMovie->avContext)
|
||||
|
@ -467,21 +415,15 @@ static int BinkUpdateMovie(struct binkMovie* aMovie)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return !eof || playing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void PlayBinkedFMV(char* filenamePtr, int volume)
|
||||
{
|
||||
struct binkMovie movie;
|
||||
|
||||
if (BinkStartMovie(&movie, filenamePtr, FALSE, FALSE, FALSE)) {
|
||||
alSourcef(movie.alSource, AL_GAIN, PlatVolumeToGain(volume));
|
||||
|
||||
while (BinkUpdateMovie(&movie)) {
|
||||
BinkRenderMovie(&movie);
|
||||
FlipBuffers();
|
||||
|
@ -501,25 +443,21 @@ void StartMenuBackgroundBink()
|
|||
BinkStartMovie(&menuBackgroundMovie, "FMVs/Menubackground.bik", TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
int PlayMenuBackgroundBink()
|
||||
{
|
||||
ClearScreenToBlack();
|
||||
if(BinkUpdateMovie(&menuBackgroundMovie))
|
||||
{
|
||||
if (BinkUpdateMovie(&menuBackgroundMovie)) {
|
||||
BinkRenderMovie(&menuBackgroundMovie);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void EndMenuBackgroundBink()
|
||||
{
|
||||
BinkReleaseMovie(&menuBackgroundMovie);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
||||
struct binkMovie musicMovie;
|
||||
|
@ -528,9 +466,7 @@ int StartMusicBink(char* filenamePtr, BOOL looping)
|
|||
{
|
||||
if (!SoundSys_IsOn())
|
||||
return 0;
|
||||
|
||||
int ret = BinkStartMovie(&musicMovie, filenamePtr, looping, FALSE, TRUE);
|
||||
return ret;
|
||||
return BinkStartMovie(&musicMovie, filenamePtr, looping, FALSE, TRUE);
|
||||
}
|
||||
|
||||
int PlayMusicBink(int volume)
|
||||
|
@ -541,51 +477,41 @@ int PlayMusicBink(int volume)
|
|||
if (!musicMovie.avContext)
|
||||
return 1;
|
||||
|
||||
if(!(musicMovie.audioStreamIndex>=0 && musicMovie.alInited))
|
||||
if (musicMovie.audioStreamIndex < 0 || !musicMovie.alInited)
|
||||
return 1;
|
||||
|
||||
alSourcef(musicMovie.alSource, AL_GAIN, PlatVolumeToGain(volume));
|
||||
for(int i=0; i<musicMovie.avContext->nb_streams * FRAMEQUEUESIZE; i++)
|
||||
{
|
||||
for (int i = 0; i < musicMovie.avContext->nb_streams * FRAMEQUEUESIZE; i++) {
|
||||
int processedBuffers = 0;
|
||||
alGetSourcei(musicMovie.alSource, AL_BUFFERS_PROCESSED, &processedBuffers);
|
||||
if (processedBuffers + musicMovie.alNumFreeBuffers > 0)
|
||||
{
|
||||
if (!ReadFrame(&musicMovie))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void EndMusicBink()
|
||||
{
|
||||
if(!SoundSys_IsOn())
|
||||
if (SoundSys_IsOn())
|
||||
return;
|
||||
|
||||
BinkReleaseMovie(&musicMovie);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
FMVHandle CreateBinkFMV(char* filenamePtr)
|
||||
{
|
||||
struct binkMovie* movie = malloc(sizeof(struct binkMovie));
|
||||
BinkInitMovieStruct(movie);
|
||||
|
||||
if(!BinkStartMovie(movie, filenamePtr, FALSE, TRUE, FALSE))
|
||||
{
|
||||
if (!BinkStartMovie(movie, filenamePtr, FALSE, TRUE, FALSE)) {
|
||||
free(movie);
|
||||
return 0;
|
||||
}
|
||||
return (FMVHandle)movie;
|
||||
}
|
||||
|
||||
|
||||
int UpdateBinkFMV(FMVHandle aFmvHandle, int volume)
|
||||
{
|
||||
if (aFmvHandle == 0)
|
||||
|
@ -600,7 +526,6 @@ int UpdateBinkFMV(FMVHandle aFmvHandle, int volume)
|
|||
return BinkUpdateMovie(movie);
|
||||
}
|
||||
|
||||
|
||||
void CloseBinkFMV(FMVHandle aFmvHandle)
|
||||
{
|
||||
if (aFmvHandle == 0)
|
||||
|
@ -611,18 +536,13 @@ void CloseBinkFMV(FMVHandle aFmvHandle)
|
|||
free(movie);
|
||||
}
|
||||
|
||||
|
||||
char* GetBinkFMVImage(FMVHandle aFmvHandle)
|
||||
{
|
||||
if (aFmvHandle == 0)
|
||||
return 0;
|
||||
|
||||
struct binkMovie* movie = (struct binkMovie*)aFmvHandle;
|
||||
|
||||
if(!movie->videoScaleContext)
|
||||
return 0;
|
||||
|
||||
return movie->videoScalePicture[0];
|
||||
}
|
||||
|
||||
|
||||
|
|
12
src/bink.h
12
src/bink.h
|
@ -1,8 +1,7 @@
|
|||
#ifndef _BINK_H_
|
||||
#define _BINK_H_
|
||||
#ifndef BINK_H
|
||||
#define BINK_H
|
||||
|
||||
extern BOOL BinkSys_Init();
|
||||
extern void BinkSys_Release();
|
||||
#include "fixer.h"
|
||||
|
||||
//--- intro/outro
|
||||
extern void PlayBinkedFMV(char* filenamePtr, int volume);
|
||||
|
@ -17,7 +16,6 @@ extern int StartMusicBink(char* filenamePtr, BOOL looping);
|
|||
extern int PlayMusicBink(int volume);
|
||||
extern void EndMusicBink();
|
||||
|
||||
|
||||
//---- ingame fmv
|
||||
typedef unsigned int FMVHandle;
|
||||
|
||||
|
@ -26,6 +24,4 @@ extern int UpdateBinkFMV(FMVHandle aFmvHandle, int volume);
|
|||
extern void CloseBinkFMV(FMVHandle aFmvHandle);
|
||||
extern char* GetBinkFMVImage(FMVHandle aFmvHandle);
|
||||
|
||||
|
||||
|
||||
#endif //_BINK_H_
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue