Skip to content

Commit

Permalink
Renamed the video and audio data to something more reasonable.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 15, 2011
1 parent 4cd0092 commit 2bc4705
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
14 changes: 7 additions & 7 deletions test/sdltheoraplay.c
Expand Up @@ -18,7 +18,7 @@ static Uint32 baseticks = 0;

typedef struct AudioQueue
{
const THEORAPLAY_PcmAudioItem *audio;
const THEORAPLAY_AudioPacket *audio;
int offset;
struct AudioQueue *next;
} AudioQueue;
Expand Down Expand Up @@ -67,7 +67,7 @@ static void SDLCALL audio_callback(void *userdata, Uint8 *stream, int len)
} // audio_callback


static void queue_audio(const THEORAPLAY_PcmAudioItem *audio)
static void queue_audio(const THEORAPLAY_AudioPacket *audio)
{
AudioQueue *item = (AudioQueue *) malloc(sizeof (AudioQueue));
if (!item)
Expand Down Expand Up @@ -98,8 +98,8 @@ static int need_overlay(const THEORAPLAY_VideoFormat vidfmt)

static void setcaption(const char *fname,
const THEORAPLAY_VideoFormat vidfmt,
const THEORAPLAY_YuvVideoItem *video,
const THEORAPLAY_PcmAudioItem *audio)
const THEORAPLAY_VideoFrame *video,
const THEORAPLAY_AudioPacket *audio)
{
char buf[1024];
const char *fmtstr = "???";
Expand Down Expand Up @@ -142,8 +142,8 @@ static void setcaption(const char *fname,
static void playfile(const char *fname, const THEORAPLAY_VideoFormat vidfmt)
{
THEORAPLAY_Decoder *decoder = NULL;
const THEORAPLAY_YuvVideoItem *video = NULL;
const THEORAPLAY_PcmAudioItem *audio = NULL;
const THEORAPLAY_VideoFrame *video = NULL;
const THEORAPLAY_AudioPacket *audio = NULL;
SDL_Surface *screen = NULL;
SDL_Surface *shadow = NULL;
SDL_Overlay *overlay = NULL;
Expand Down Expand Up @@ -255,7 +255,7 @@ static void playfile(const char *fname, const THEORAPLAY_VideoFormat vidfmt)
// in case we catch up to a series of dupe frames, which
// means we'd have to draw that final frame and then wait for
// more.
const THEORAPLAY_YuvVideoItem *last = video;
const THEORAPLAY_VideoFrame *last = video;
while ((video = THEORAPLAY_getVideo(decoder)) != NULL)
{
THEORAPLAY_freeVideo(last);
Expand Down
4 changes: 2 additions & 2 deletions test/testtheoraplay.c
Expand Up @@ -14,8 +14,8 @@
static void dofile(const char *fname, const THEORAPLAY_VideoFormat vidfmt)
{
THEORAPLAY_Decoder *decoder = NULL;
const THEORAPLAY_YuvVideoItem *video = NULL;
const THEORAPLAY_PcmAudioItem *audio = NULL;
const THEORAPLAY_VideoFrame *video = NULL;
const THEORAPLAY_AudioPacket *audio = NULL;

printf("Trying file '%s' ...\n", fname);
decoder = THEORAPLAY_startDecode(fname, 20, vidfmt);
Expand Down
40 changes: 20 additions & 20 deletions theoraplay.c
Expand Up @@ -26,8 +26,8 @@

#define THEORAPLAY_INTERNAL 1

typedef THEORAPLAY_YuvVideoItem YuvVideoItem;
typedef THEORAPLAY_PcmAudioItem PcmAudioItem;
typedef THEORAPLAY_VideoFrame VideoFrame;
typedef THEORAPLAY_AudioPacket AudioPacket;

// !!! FIXME: these all count on the pixel format being TH_PF_420 for now.

Expand Down Expand Up @@ -92,11 +92,11 @@ typedef struct TheoraDecoder
THEORAPLAY_VideoFormat vidfmt;
ConvertVideoFrameFn vidcvt;

YuvVideoItem *videolist;
YuvVideoItem *videolisttail;
VideoFrame *videolist;
VideoFrame *videolisttail;

PcmAudioItem *audiolist;
PcmAudioItem *audiolisttail;
AudioPacket *audiolist;
AudioPacket *audiolisttail;
} TheoraDecoder;


Expand Down Expand Up @@ -297,7 +297,7 @@ static void WorkerThread(TheoraDecoder *ctx)
const int channels = vinfo.channels;
int chanidx, frameidx;
float *samples;
PcmAudioItem *item = (PcmAudioItem *) malloc(sizeof (PcmAudioItem));
AudioPacket *item = (AudioPacket *) malloc(sizeof (AudioPacket));
if (item == NULL) goto cleanup;
item->playms = (unsigned long) ((((double) audioframes) / ((double) vinfo.rate)) * 1000.0);
item->channels = channels;
Expand Down Expand Up @@ -369,7 +369,7 @@ static void WorkerThread(TheoraDecoder *ctx)
th_ycbcr_buffer ycbcr;
if (th_decode_ycbcr_out(tdec, ycbcr) == 0)
{
YuvVideoItem *item = (YuvVideoItem *) malloc(sizeof (YuvVideoItem));
VideoFrame *item = (VideoFrame *) malloc(sizeof (VideoFrame));
if (item == NULL) goto cleanup;
item->playms = (fps == 0) ? 0 : (unsigned int) ((((double) videoframes) / fps) * 1000.0);
item->fps = fps;
Expand Down Expand Up @@ -533,19 +533,19 @@ void THEORAPLAY_stopDecode(THEORAPLAY_Decoder *decoder)
pthread_mutex_destroy(&ctx->lock);
} // if

YuvVideoItem *videolist = ctx->videolist;
VideoFrame *videolist = ctx->videolist;
while (videolist)
{
YuvVideoItem *next = videolist->next;
VideoFrame *next = videolist->next;
free(videolist->pixels);
free(videolist);
videolist = next;
} // while

PcmAudioItem *audiolist = ctx->audiolist;
AudioPacket *audiolist = ctx->audiolist;
while (audiolist)
{
PcmAudioItem *next = audiolist->next;
AudioPacket *next = audiolist->next;
free(audiolist->samples);
free(audiolist);
audiolist = next;
Expand All @@ -570,10 +570,10 @@ int THEORAPLAY_decodingError(THEORAPLAY_Decoder *decoder)
} // THEORAPLAY_decodingError


const PcmAudioItem *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder)
const THEORAPLAY_AudioPacket *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder)
{
TheoraDecoder *ctx = (TheoraDecoder *) decoder;
PcmAudioItem *retval;
AudioPacket *retval;

pthread_mutex_lock(&ctx->lock);
retval = ctx->audiolist;
Expand All @@ -590,9 +590,9 @@ const PcmAudioItem *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder)
} // THEORAPLAY_getAudio


void THEORAPLAY_freeAudio(const PcmAudioItem *_item)
void THEORAPLAY_freeAudio(const THEORAPLAY_AudioPacket *_item)
{
PcmAudioItem *item = (PcmAudioItem *) _item;
THEORAPLAY_AudioPacket *item = (THEORAPLAY_AudioPacket *) _item;
if (item != NULL)
{
assert(item->next == NULL);
Expand All @@ -602,10 +602,10 @@ void THEORAPLAY_freeAudio(const PcmAudioItem *_item)
} // THEORAPLAY_freeAudio


const YuvVideoItem *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder)
const THEORAPLAY_VideoFrame *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder)
{
TheoraDecoder *ctx = (TheoraDecoder *) decoder;
YuvVideoItem *retval;
VideoFrame *retval;

pthread_mutex_lock(&ctx->lock);
retval = ctx->videolist;
Expand All @@ -624,9 +624,9 @@ const YuvVideoItem *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder)
} // THEORAPLAY_getVideo


void THEORAPLAY_freeVideo(const YuvVideoItem *_item)
void THEORAPLAY_freeVideo(const THEORAPLAY_VideoFrame *_item)
{
YuvVideoItem *item = (YuvVideoItem *) _item;
THEORAPLAY_VideoFrame *item = (THEORAPLAY_VideoFrame *) _item;
if (item != NULL)
{
assert(item->next == NULL);
Expand Down
20 changes: 10 additions & 10 deletions theoraplay.h
Expand Up @@ -23,26 +23,26 @@ typedef enum THEORAPLAY_VideoFormat
THEORAPLAY_VIDFMT_RGBA /* 32 bits packed pixel RGBA (full alpha). */
} THEORAPLAY_VideoFormat;

typedef struct THEORAPLAY_YuvVideoItem
typedef struct THEORAPLAY_VideoFrame
{
unsigned int playms;
double fps;
unsigned int width;
unsigned int height;
THEORAPLAY_VideoFormat format;
unsigned char *pixels;
struct THEORAPLAY_YuvVideoItem *next;
} THEORAPLAY_YuvVideoItem;
struct THEORAPLAY_VideoFrame *next;
} THEORAPLAY_VideoFrame;

typedef struct THEORAPLAY_PcmAudioItem
typedef struct THEORAPLAY_AudioPacket
{
unsigned int playms; // playback start time in milliseconds.
int channels;
int freq;
int frames;
float *samples; // frames * channels float32 samples.
struct THEORAPLAY_PcmAudioItem *next;
} THEORAPLAY_PcmAudioItem;
struct THEORAPLAY_AudioPacket *next;
} THEORAPLAY_AudioPacket;

THEORAPLAY_Decoder *THEORAPLAY_startDecode(const char *fname,
const unsigned int maxframes,
Expand All @@ -51,11 +51,11 @@ void THEORAPLAY_stopDecode(THEORAPLAY_Decoder *decoder);
int THEORAPLAY_isDecoding(THEORAPLAY_Decoder *decoder);
int THEORAPLAY_decodingError(THEORAPLAY_Decoder *decoder);

const THEORAPLAY_PcmAudioItem *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder);
void THEORAPLAY_freeAudio(const THEORAPLAY_PcmAudioItem *item);
const THEORAPLAY_AudioPacket *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder);
void THEORAPLAY_freeAudio(const THEORAPLAY_AudioPacket *item);

const THEORAPLAY_YuvVideoItem *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder);
void THEORAPLAY_freeVideo(const THEORAPLAY_YuvVideoItem *item);
const THEORAPLAY_VideoFrame *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder);
void THEORAPLAY_freeVideo(const THEORAPLAY_VideoFrame *item);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 2bc4705

Please sign in to comment.