void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)

{

    int id;



    id = avio_rl16(pb);

    codec->codec_type = AVMEDIA_TYPE_AUDIO;

    codec->codec_tag = id;

    codec->channels = avio_rl16(pb);

    codec->sample_rate = avio_rl32(pb);

    codec->bit_rate = avio_rl32(pb) * 8;

    codec->block_align = avio_rl16(pb);

    if (size == 14) {  /* We're dealing with plain vanilla WAVEFORMAT */

        codec->bits_per_coded_sample = 8;

    }else

        codec->bits_per_coded_sample = avio_rl16(pb);

    if (size >= 18) {  /* We're obviously dealing with WAVEFORMATEX */

        int cbSize = avio_rl16(pb); /* cbSize */

        size -= 18;

        cbSize = FFMIN(size, cbSize);

        if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */

            codec->bits_per_coded_sample = avio_rl16(pb);

            codec->channel_layout = avio_rl32(pb); /* dwChannelMask */

            id = avio_rl32(pb); /* 4 first bytes of GUID */

            avio_skip(pb, 12); /* skip end of GUID */

            cbSize -= 22;

            size -= 22;

        }

        codec->extradata_size = cbSize;

        if (cbSize > 0) {

            codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);

            avio_read(pb, codec->extradata, codec->extradata_size);

            size -= cbSize;

        }



        /* It is possible for the chunk to contain garbage at the end */

        if (size > 0)

            avio_skip(pb, size);

    }

    codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);

    if (codec->codec_id == CODEC_ID_AAC_LATM) {

        /* channels and sample_rate values are those prior to applying SBR and/or PS */

        codec->channels    = 0;

        codec->sample_rate = 0;

    }

}

void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)

{

    int id;



    id = avio_rl16(pb);

    codec->codec_type = AVMEDIA_TYPE_AUDIO;

    codec->codec_tag = id;

    codec->channels = avio_rl16(pb);

    codec->sample_rate = avio_rl32(pb);

    codec->bit_rate = avio_rl32(pb) * 8;

    codec->block_align = avio_rl16(pb);

    if (size == 14) {  

        codec->bits_per_coded_sample = 8;

    }else

        codec->bits_per_coded_sample = avio_rl16(pb);

    if (size >= 18) {  

        int cbSize = avio_rl16(pb); 

        size -= 18;

        cbSize = FFMIN(size, cbSize);

        if (cbSize >= 22 && id == 0xfffe) { 

            codec->bits_per_coded_sample = avio_rl16(pb);

            codec->channel_layout = avio_rl32(pb); 

            id = avio_rl32(pb); 

            avio_skip(pb, 12); 

            cbSize -= 22;

            size -= 22;

        }

        codec->extradata_size = cbSize;

        if (cbSize > 0) {

            codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);

            avio_read(pb, codec->extradata, codec->extradata_size);

            size -= cbSize;

        }



        

        if (size > 0)

            avio_skip(pb, size);

    }

    codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);

    if (codec->codec_id == CODEC_ID_AAC_LATM) {

        

        codec->channels    = 0;

        codec->sample_rate = 0;

    }

}

void ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
void FUNC_0(AVIOContext *VAR_0, AVCodecContext *VAR_1, int VAR_2)

{

    int VAR_3;



    VAR_3 = avio_rl16(VAR_0);

    VAR_1->codec_type = AVMEDIA_TYPE_AUDIO;

    VAR_1->codec_tag = VAR_3;

    VAR_1->channels = avio_rl16(VAR_0);

    VAR_1->sample_rate = avio_rl32(VAR_0);

    VAR_1->bit_rate = avio_rl32(VAR_0) * 8;

    VAR_1->block_align = avio_rl16(VAR_0);

    if (VAR_2 == 14) {  

        VAR_1->bits_per_coded_sample = 8;

    }else

        VAR_1->bits_per_coded_sample = avio_rl16(VAR_0);

    if (VAR_2 >= 18) {  

        int VAR_4 = avio_rl16(VAR_0); 

        VAR_2 -= 18;

        VAR_4 = FFMIN(VAR_2, VAR_4);

        if (VAR_4 >= 22 && VAR_3 == 0xfffe) { 

            VAR_1->bits_per_coded_sample = avio_rl16(VAR_0);

            VAR_1->channel_layout = avio_rl32(VAR_0); 

            VAR_3 = avio_rl32(VAR_0); 

            avio_skip(VAR_0, 12); 

            VAR_4 -= 22;

            VAR_2 -= 22;

        }

        VAR_1->extradata_size = VAR_4;

        if (VAR_4 > 0) {

            VAR_1->extradata = av_mallocz(VAR_1->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);

            avio_read(VAR_0, VAR_1->extradata, VAR_1->extradata_size);

            VAR_2 -= VAR_4;

        }



        

        if (VAR_2 > 0)

            avio_skip(VAR_0, VAR_2);

    }

    VAR_1->codec_id = ff_wav_codec_get_id(VAR_3, VAR_1->bits_per_coded_sample);

    if (VAR_1->codec_id == CODEC_ID_AAC_LATM) {

        

        VAR_1->channels    = 0;

        VAR_1->sample_rate = 0;

    }

}

void FUNC_0(AVIOContext *VAR_0, AVCodecContext *VAR_1, int VAR_2)
{ int VAR_3; VAR_3 = avio_rl16(VAR_0); VAR_1->codec_type = AVMEDIA_TYPE_AUDIO; VAR_1->codec_tag = VAR_3; VAR_1->channels = avio_rl16(VAR_0); VAR_1->sample_rate = avio_rl32(VAR_0); VAR_1->bit_rate = avio_rl32(VAR_0) * 8; VAR_1->block_align = avio_rl16(VAR_0); if (VAR_2 == 14) { VAR_1->bits_per_coded_sample = 8; }else VAR_1->bits_per_coded_sample = avio_rl16(VAR_0); if (VAR_2 >= 18) { int VAR_4 = avio_rl16(VAR_0); VAR_2 -= 18; VAR_4 = FFMIN(VAR_2, VAR_4); if (VAR_4 >= 22 && VAR_3 == 0xfffe) { VAR_1->bits_per_coded_sample = avio_rl16(VAR_0); VAR_1->channel_layout = avio_rl32(VAR_0); VAR_3 = avio_rl32(VAR_0); avio_skip(VAR_0, 12); VAR_4 -= 22; VAR_2 -= 22; } VAR_1->extradata_size = VAR_4; if (VAR_4 > 0) { VAR_1->extradata = av_mallocz(VAR_1->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); avio_read(VAR_0, VAR_1->extradata, VAR_1->extradata_size); VAR_2 -= VAR_4; } if (VAR_2 > 0)
avio_skip(VAR_0, VAR_2); } VAR_1->codec_id = ff_wav_codec_get_id(VAR_3, VAR_1->bits_per_coded_sample); if (VAR_1->codec_id == CODEC_ID_AAC_LATM) { VAR_1->channels    = 0; VAR_1->sample_rate = 0; } }