Unverified Commit e349f4dd authored by Wolle's avatar Wolle Committed by GitHub

Merge branch 'only_for_testing' into master

parents 46faf113 bc5ee013
This diff is collapsed.
...@@ -236,6 +236,7 @@ private: ...@@ -236,6 +236,7 @@ private:
void showCodecParams(); void showCodecParams();
int findNextSync(uint8_t* data, size_t len); int findNextSync(uint8_t* data, size_t len);
int sendBytes(uint8_t* data, size_t len); int sendBytes(uint8_t* data, size_t len);
void setDecoderItems();
void compute_audioCurrentTime(int bd); void compute_audioCurrentTime(int bd);
void printDecodeError(int r); void printDecodeError(int r);
void showID3Tag(const char* tag, const char* val); void showID3Tag(const char* tag, const char* val);
...@@ -253,7 +254,6 @@ private: ...@@ -253,7 +254,6 @@ private:
bool playChunk(); bool playChunk();
bool playSample(int16_t sample[2]) ; bool playSample(int16_t sample[2]) ;
int32_t Gain(int16_t s[2]); int32_t Gain(int16_t s[2]);
bool fill_InputBuf();
void showstreamtitle(const char* ml); void showstreamtitle(const char* ml);
bool parseContentType(char* ct); bool parseContentType(char* ct);
bool parseHttpResponseHeader(); bool parseHttpResponseHeader();
...@@ -280,6 +280,7 @@ private: ...@@ -280,6 +280,7 @@ private:
uint32_t m4a_correctResumeFilePos(uint32_t resumeFilePos); uint32_t m4a_correctResumeFilePos(uint32_t resumeFilePos);
uint32_t flac_correctResumeFilePos(uint32_t resumeFilePos); uint32_t flac_correctResumeFilePos(uint32_t resumeFilePos);
uint32_t mp3_correctResumeFilePos(uint32_t resumeFilePos); uint32_t mp3_correctResumeFilePos(uint32_t resumeFilePos);
uint8_t determineOggCodec(uint8_t* data, uint16_t len);
//++++ implement several function with respect to the index of string ++++ //++++ implement several function with respect to the index of string ++++
...@@ -442,7 +443,7 @@ private: ...@@ -442,7 +443,7 @@ private:
enum : int { M4A_BEGIN = 0, M4A_FTYP = 1, M4A_CHK = 2, M4A_MOOV = 3, M4A_FREE = 4, M4A_TRAK = 5, M4A_MDAT = 6, enum : int { M4A_BEGIN = 0, M4A_FTYP = 1, M4A_CHK = 2, M4A_MOOV = 3, M4A_FREE = 4, M4A_TRAK = 5, M4A_MDAT = 6,
M4A_ILST = 7, M4A_MP4A = 8, M4A_AMRDY = 99, M4A_OKAY = 100}; M4A_ILST = 7, M4A_MP4A = 8, M4A_AMRDY = 99, M4A_OKAY = 100};
enum : int { CODEC_NONE = 0, CODEC_WAV = 1, CODEC_MP3 = 2, CODEC_AAC = 3, CODEC_M4A = 4, CODEC_FLAC = 5, enum : int { CODEC_NONE = 0, CODEC_WAV = 1, CODEC_MP3 = 2, CODEC_AAC = 3, CODEC_M4A = 4, CODEC_FLAC = 5,
CODEC_AACP = 6}; CODEC_AACP = 6, CODEC_OPUS = 7, CODEC_OGG = 8};
enum : int { ST_NONE = 0, ST_WEBFILE = 1, ST_WEBSTREAM = 2}; enum : int { ST_NONE = 0, ST_WEBFILE = 1, ST_WEBSTREAM = 2};
typedef enum { LEFTCHANNEL=0, RIGHTCHANNEL=1 } SampleIndex; typedef enum { LEFTCHANNEL=0, RIGHTCHANNEL=1 } SampleIndex;
typedef enum { LOWSHELF = 0, PEAKEQ = 1, HIFGSHELF =2 } FilterType; typedef enum { LOWSHELF = 0, PEAKEQ = 1, HIFGSHELF =2 } FilterType;
...@@ -478,6 +479,7 @@ private: ...@@ -478,6 +479,7 @@ private:
const size_t m_frameSizeMP3 = 1600; const size_t m_frameSizeMP3 = 1600;
const size_t m_frameSizeAAC = 1600; const size_t m_frameSizeAAC = 1600;
const size_t m_frameSizeFLAC = 4096 * 4; const size_t m_frameSizeFLAC = 4096 * 4;
const size_t m_frameSizeOPUS = 1024;
static const uint8_t m_tsPacketSize = 188; static const uint8_t m_tsPacketSize = 188;
static const uint8_t m_tsHeaderSize = 4; static const uint8_t m_tsHeaderSize = 4;
......
This diff is collapsed.
...@@ -27,7 +27,8 @@ typedef struct FLACsubFramesBuff_t{ ...@@ -27,7 +27,8 @@ typedef struct FLACsubFramesBuff_t{
enum : uint8_t {FLACDECODER_INIT, FLACDECODER_READ_IN, FLACDECODER_WRITE_OUT}; enum : uint8_t {FLACDECODER_INIT, FLACDECODER_READ_IN, FLACDECODER_WRITE_OUT};
enum : uint8_t {DECODE_FRAME, DECODE_SUBFRAMES, OUT_SAMPLES}; enum : uint8_t {DECODE_FRAME, DECODE_SUBFRAMES, OUT_SAMPLES};
enum : int8_t {GIVE_NEXT_LOOP = +1, enum : int8_t {FLAC_PARSE_OGG_DONE = 100,
GIVE_NEXT_LOOP = +1,
ERR_FLAC_NONE = 0, ERR_FLAC_NONE = 0,
ERR_FLAC_BLOCKSIZE_TOO_BIG = -1, ERR_FLAC_BLOCKSIZE_TOO_BIG = -1,
ERR_FLAC_RESERVED_BLOCKSIZE_UNSUPPORTED = -2, ERR_FLAC_RESERVED_BLOCKSIZE_UNSUPPORTED = -2,
...@@ -39,7 +40,8 @@ enum : int8_t {GIVE_NEXT_LOOP = +1, ...@@ -39,7 +40,8 @@ enum : int8_t {GIVE_NEXT_LOOP = +1,
ERR_FLAC_RESERVED_RESIDUAL_CODING = -8, ERR_FLAC_RESERVED_RESIDUAL_CODING = -8,
ERR_FLAC_WRONG_RICE_PARTITION_NR = -9, ERR_FLAC_WRONG_RICE_PARTITION_NR = -9,
ERR_FLAC_BITS_PER_SAMPLE_TOO_BIG = -10, ERR_FLAC_BITS_PER_SAMPLE_TOO_BIG = -10,
ERR_FLAG_BITS_PER_SAMPLE_UNKNOWN = 11}; ERR_FLAG_BITS_PER_SAMPLE_UNKNOWN = -11,
ERR_FLAC_DECODER_ASYNC = -12};
typedef struct FLACMetadataBlock_t{ typedef struct FLACMetadataBlock_t{
// METADATA_BLOCK_STREAMINFO // METADATA_BLOCK_STREAMINFO
...@@ -144,15 +146,15 @@ typedef struct FLACFrameHeader_t { ...@@ -144,15 +146,15 @@ typedef struct FLACFrameHeader_t {
int FLACFindSyncWord(unsigned char *buf, int nBytes); int FLACFindSyncWord(unsigned char *buf, int nBytes);
boolean FLACFindMagicWord(unsigned char* buf, int nBytes); boolean FLACFindMagicWord(unsigned char* buf, int nBytes);
boolean FLACFindStreamTitle(unsigned char* buf, int nBytes);
char* FLACgetStreamTitle(); char* FLACgetStreamTitle();
int FLACparseOggHeader(unsigned char *buf); int FLACparseOGG(uint8_t *inbuf, int *bytesLeft);
bool FLACDecoder_AllocateBuffers(void); bool FLACDecoder_AllocateBuffers(void);
void FLACDecoder_ClearBuffer(); void FLACDecoder_ClearBuffer();
void FLACDecoder_FreeBuffers(); void FLACDecoder_FreeBuffers();
void FLACSetRawBlockParams(uint8_t Chans, uint32_t SampRate, uint8_t BPS, uint32_t tsis, uint32_t AuDaLength); void FLACSetRawBlockParams(uint8_t Chans, uint32_t SampRate, uint8_t BPS, uint32_t tsis, uint32_t AuDaLength);
void FLACDecoderReset(); void FLACDecoderReset();
int8_t FLACDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf); int8_t FLACDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf);
int8_t flacDecodeFrame(uint8_t *inbuf, int *bytesLeft);
uint16_t FLACGetOutputSamps(); uint16_t FLACGetOutputSamps();
uint64_t FLACGetTotoalSamplesInStream(); uint64_t FLACGetTotoalSamplesInStream();
uint8_t FLACGetBitsPerSample(); uint8_t FLACGetBitsPerSample();
...@@ -160,15 +162,15 @@ uint8_t FLACGetChannels(); ...@@ -160,15 +162,15 @@ uint8_t FLACGetChannels();
uint32_t FLACGetSampRate(); uint32_t FLACGetSampRate();
uint32_t FLACGetBitRate(); uint32_t FLACGetBitRate();
uint32_t FLACGetAudioFileDuration(); uint32_t FLACGetAudioFileDuration();
uint32_t readUint(uint8_t nBits); uint32_t readUint(uint8_t nBits, int *bytesLeft);
int32_t readSignedInt(int nBits); int32_t readSignedInt(int nBits, int* bytesLeft);
int64_t readRiceSignedInt(uint8_t param); int64_t readRiceSignedInt(uint8_t param, int* bytesLeft);
void alignToByte(); void alignToByte();
int8_t decodeSubframes(); int8_t decodeSubframes(int* bytesLeft);
int8_t decodeSubframe(uint8_t sampleDepth, uint8_t ch); int8_t decodeSubframe(uint8_t sampleDepth, uint8_t ch, int* bytesLeft);
int8_t decodeFixedPredictionSubframe(uint8_t predOrder, uint8_t sampleDepth, uint8_t ch); int8_t decodeFixedPredictionSubframe(uint8_t predOrder, uint8_t sampleDepth, uint8_t ch, int* bytesLeft);
int8_t decodeLinearPredictiveCodingSubframe(int lpcOrder, int sampleDepth, uint8_t ch); int8_t decodeLinearPredictiveCodingSubframe(int lpcOrder, int sampleDepth, uint8_t ch, int* bytesLeft);
int8_t decodeResiduals(uint8_t warmup, uint8_t ch); int8_t decodeResiduals(uint8_t warmup, uint8_t ch, int* bytesLeft);
void restoreLinearPrediction(uint8_t ch, uint8_t shift); void restoreLinearPrediction(uint8_t ch, uint8_t shift);
int specialIndexOf(uint8_t* base, const char* str, int baselen, bool exact = false); int FLAC_specialIndexOf(uint8_t* base, const char* str, int baselen, bool exact = false);
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
// based on Xiph.Org Foundation celt decoder
#pragma once
//#pragma GCC optimize ("O3")
//#pragma GCC diagnostic ignored "-Wnarrowing"
#include "Arduino.h"
enum : int8_t {OPUS_PARSE_OGG_DONE = 100,
ERR_OPUS_NONE = 0,
ERR_OPUS_CHANNELS_OUT_OF_RANGE = -1,
ERR_OPUS_INVALID_SAMPLERATE = -2,
ERR_OPUS_EXTRA_CHANNELS_UNSUPPORTED = -3,
ERR_OPUS_DECODER_ASYNC = -4,
ERR_OPUS_SILK_MODE_UNSUPPORTED = -5,
ERR_OPUS_HYBRID_MODE_UNSUPPORTED = -6,
ERR_OPUS_OGG_SYNC_NOT_FOUND = - 7,
ERR_OPUS_CELT_BAD_ARG = -18,
ERR_OPUS_CELT_INTERNAL_ERROR = -19,
ERR_OPUS_CELT_UNIMPLEMENTED = -20,
ERR_OPUS_CELT_ALLOC_FAIL = -21,
ERR_OPUS_CELT_UNKNOWN_REQUEST = -22,
ERR_OPUS_CELT_GET_MODE_REQUEST = - 23,
ERR_OPUS_CELT_CLEAR_REQUEST = -24,
ERR_OPUS_CELT_SET_CHANNELS = -25,
ERR_OPUS_CELT_END_BAND = -26,
ERR_CELT_OPUS_INTERNAL_ERROR = -27};
bool OPUSDecoder_AllocateBuffers();
void OPUSDecoder_FreeBuffers();
void OPUSDecoder_ClearBuffers();
void OPUSsetDefaults();
int OPUSDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf);
uint8_t OPUSGetChannels();
uint32_t OPUSGetSampRate();
uint8_t OPUSGetBitsPerSample();
uint32_t OPUSGetBitRate();
uint16_t OPUSGetOutputSamps();
char *OPUSgetStreamTitle();
int OPUSFindSyncWord(unsigned char *buf, int nBytes);
int OPUSparseOGG(uint8_t *inbuf, int *bytesLeft);
int parseOpusHead(uint8_t *inbuf, int nBytes);
int parseOpusComment(uint8_t *inbuf, int nBytes);
int parseOpusTOC(uint8_t TOC_Byte);
int32_t opus_packet_get_samples_per_frame(const uint8_t *data, int32_t Fs);
// some helper functions
int OPUS_specialIndexOf(uint8_t* base, const char* str, int baselen, bool exact = false);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment