| 1 | /******************************************************************** |
| 2 | * * |
| 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
| 4 | * * |
| 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
| 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
| 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
| 8 | * * |
| 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
| 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
| 11 | * * |
| 12 | ******************************************************************** |
| 13 | |
| 14 | function: simple example decoder using vorbisidec |
| 15 | |
| 16 | ********************************************************************/ |
| 17 | |
| 18 | /* Takes a vorbis bitstream from stdin and writes raw stereo PCM to |
| 19 | stdout using vorbisfile. Using vorbisfile is much simpler than |
| 20 | dealing with libvorbis. */ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | #include "ivorbiscodec.h"cxx . . $ `<file>/mednafen/tremor/ivorbiscodec.h`/ |
| 25 | #include "ivorbisfile.h"cxx . . $ `<file>/mednafen/tremor/ivorbisfile.h`/ |
| 26 | |
| 27 | #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ |
| 28 | #include <io.h> |
| 29 | #include <fcntl.h> |
| 30 | #endif |
| 31 | |
| 32 | char pcmoutcxx . . $ pcmout.[4096]; /* take 4k out of the data segment, not the stack */ |
| 33 | |
| 34 | int maincxx . . $ main(d1b40a211a1a4e4c).(){ |
| 35 | OggVorbis_Filecxx . . $ OggVorbis_File# vf; |
| 36 | int eof=0; |
| 37 | int current_section; |
| 38 | |
| 39 | #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ |
| 40 | /* Beware the evil ifdef. We avoid these where we can, but this one we |
| 41 | cannot. Don't add any more, you'll probably go to hell if you do. */ |
| 42 | _setmode( _fileno( stdin ), _O_BINARY ); |
| 43 | _setmode( _fileno( stdout ), _O_BINARY ); |
| 44 | #endif |
| 45 | |
| 46 | if(ov_opencxx . . $ ov_open(14abe1420fd41867).(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!, &vf, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0) < 0) { |
| 47 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"Input does not appear to be an Ogg bitstream.\n"); |
| 48 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 49 | } |
| 50 | |
| 51 | /* Throw the comments plus a few lines about the bitstream we're |
| 52 | decoding */ |
| 53 | { |
| 54 | char **ptr=ov_commentcxx . . $ ov_comment(5c593f69dba24d40).(&vf,-1)->user_commentscxx . . $ vorbis_comment#user_comments.; |
| 55 | vorbis_infocxx . . $ vorbis_info# *vi=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(&vf,-1); |
| 56 | while(*ptr){ |
| 57 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"%s\n",*ptr); |
| 58 | ++ptr; |
| 59 | } |
| 60 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"\nBitstream is %d channel, %ldHz\n",vi->channelscxx . . $ vorbis_info#channels.,vi->ratecxx . . $ vorbis_info#rate.); |
| 61 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"\nDecoded length: %ld samples\n", |
| 62 | (long)ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(&vf,-1)); |
| 63 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"Encoded by: %s\n\n",ov_commentcxx . . $ ov_comment(5c593f69dba24d40).(&vf,-1)->vendorcxx . . $ vorbis_comment#vendor.); |
| 64 | } |
| 65 | |
| 66 | while(!eof){ |
| 67 | long ret=ov_readcxx . . $ ov_read(fecdd0574488f6f9).(&vf,pcmoutcxx . . $ pcmout.,sizeof(pcmoutcxx . . $ pcmout.),¤t_section); |
| 68 | if (ret == 0) { |
| 69 | /* EOF */ |
| 70 | eof=1; |
| 71 | } else if (ret < 0) { |
| 72 | if(ret==OV_EBADLINKcxx . . $ `mednafen/tremor/ivorbiscodec.h:196:9`!){ |
| 73 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"Corrupt bitstream section! Exiting.\n"); |
| 74 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 75 | } |
| 76 | |
| 77 | /* some other error in the stream. Not a problem, just reporting it in |
| 78 | case we (the app) cares. In this case, we don't. */ |
| 79 | } else { |
| 80 | /* we don't bother dealing with sample rate changes, etc, but |
| 81 | you'll have to*/ |
| 82 | fwritecxx . . $ fwrite(ab0609fa07c47d6e).(pcmoutcxx . . $ pcmout.,1,ret,stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /* cleanup */ |
| 87 | ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(&vf); |
| 88 | |
| 89 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"Done.\n"); |
| 90 | return(0); |
| 91 | } |