Cast a malloc() call to a specific pointer type.
2 * TheoraPlay; multithreaded Ogg Theora/Ogg Vorbis decoding.
4 * Please see the file LICENSE.txt in the source's root directory.
6 * This file written by Ryan C. Gordon.
12 #include "theoraplay.h"
14 static void dofile(const char *fname, const THEORAPLAY_VideoFormat vidfmt)
16 THEORAPLAY_Decoder *decoder = NULL;
17 const THEORAPLAY_VideoFrame *video = NULL;
18 const THEORAPLAY_AudioPacket *audio = NULL;
20 printf("Trying file '%s' ...\n", fname);
21 decoder = THEORAPLAY_startDecodeFile(fname, 20, vidfmt);
22 while (THEORAPLAY_isDecoding(decoder))
24 video = THEORAPLAY_getVideo(decoder);
27 printf("Got video frame (%u ms)!\n", video->playms);
28 THEORAPLAY_freeVideo(video);
31 audio = THEORAPLAY_getAudio(decoder);
34 printf("Got %d frames of audio (%u ms)!\n", audio->frames, audio->playms);
35 THEORAPLAY_freeAudio(audio);
42 if (THEORAPLAY_decodingError(decoder))
43 printf("There was an error decoding this file!\n");
45 printf("done with this file!\n");
47 THEORAPLAY_stopDecode(decoder);
50 int main(int argc, char **argv)
52 THEORAPLAY_VideoFormat vidfmt = THEORAPLAY_VIDFMT_YV12;
55 for (i = 1; i < argc; i++)
57 if (strcmp(argv[i], "--rgb") == 0)
58 vidfmt = THEORAPLAY_VIDFMT_RGB;
59 else if (strcmp(argv[i], "--rgba") == 0)
60 vidfmt = THEORAPLAY_VIDFMT_RGBA;
61 else if (strcmp(argv[i], "--yv12") == 0)
62 vidfmt = THEORAPLAY_VIDFMT_YV12;
64 dofile(argv[i], vidfmt);
67 printf("done all files!\n");
71 // end of testtheoraplay.c ...