00001 #ifndef AUDIOOUTPUTREENCODER 00002 #define AUDIOOUTPUTREENCODER 00003 00004 extern "C" { 00005 #include "libavcodec/avcodec.h" 00006 }; 00007 00008 #include "spdifencoder.h" 00009 #include "audiooutputsettings.h" 00010 00011 #define INBUFSIZE 131072 00012 #define OUTBUFSIZE INBUFSIZE 00013 00014 class AudioOutputDigitalEncoder 00015 { 00016 typedef int16_t inbuf_t; 00017 typedef int16_t outbuf_t; 00018 00019 public: 00020 AudioOutputDigitalEncoder(void); 00021 ~AudioOutputDigitalEncoder(); 00022 00023 bool Init(CodecID codec_id, int bitrate, int samplerate, int channels); 00024 void Dispose(void); 00025 size_t Encode(void *buf, int len, AudioFormat format); 00026 size_t GetFrames(void *ptr, int maxlen); 00027 int Buffered(void) const 00028 { return inlen / sizeof(inbuf_t) / av_context->channels; } 00029 void clear(); 00030 00031 private: 00032 void *realloc(void *ptr, size_t old_size, size_t new_size); 00033 00034 AVCodecContext *av_context; 00035 outbuf_t *out; 00036 size_t out_size; 00037 inbuf_t *in; 00038 size_t in_size; 00039 int outlen; 00040 int inlen; 00041 size_t samples_per_frame; 00042 int16_t m_encodebuffer[FF_MIN_BUFFER_SIZE]; 00043 SPDIFEncoder *m_spdifenc; 00044 }; 00045 00046 #endif
1.6.3