static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    AVCodecContext *codec = s->streams[0]->codec;

    int ret, size = 1024;



    if (avio_feof(s->pb))

        return AVERROR_EOF;



    if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||

        codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {

        ret = av_get_packet(s->pb, pkt, codec->block_align);

    } else if (codec->codec_tag == MKTAG('W','A','D','P') &&

               codec->channels > 1) {

        int i, ch;



        av_new_packet(pkt, codec->block_align);

        for (i = 0; i < 4; i++) {

            for (ch = 0; ch < codec->channels; ch++) {

                pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);

                pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);

            }

        }

        ret = 0;

    } else {

        ret = av_get_packet(s->pb, pkt, size);

    }



    pkt->stream_index = 0;



    return ret;

}

static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    AVCodecContext *codec = s->streams[0]->codec;

    int ret, size = 1024;



    if (avio_feof(s->pb))

        return AVERROR_EOF;



    if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||

        codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {

        ret = av_get_packet(s->pb, pkt, codec->block_align);

    } else if (codec->codec_tag == MKTAG('W','A','D','P') &&

               codec->channels > 1) {

        int i, ch;



        av_new_packet(pkt, codec->block_align);

        for (i = 0; i < 4; i++) {

            for (ch = 0; ch < codec->channels; ch++) {

                pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);

                pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);

            }

        }

        ret = 0;

    } else {

        ret = av_get_packet(s->pb, pkt, size);

    }



    pkt->stream_index = 0;



    return ret;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    AVCodecContext *codec = VAR_0->streams[0]->codec;

    int VAR_2, VAR_3 = 1024;



    if (avio_feof(VAR_0->pb))

        return AVERROR_EOF;



    if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||

        codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {

        VAR_2 = av_get_packet(VAR_0->pb, VAR_1, codec->block_align);

    } else if (codec->codec_tag == MKTAG('W','A','D','P') &&

               codec->channels > 1) {

        int VAR_4, VAR_5;



        av_new_packet(VAR_1, codec->block_align);

        for (VAR_4 = 0; VAR_4 < 4; VAR_4++) {

            for (VAR_5 = 0; VAR_5 < codec->channels; VAR_5++) {

                VAR_1->data[VAR_5 * 8 + VAR_4 * 2 + 0] = avio_r8(VAR_0->pb);

                VAR_1->data[VAR_5 * 8 + VAR_4 * 2 + 1] = avio_r8(VAR_0->pb);

            }

        }

        VAR_2 = 0;

    } else {

        VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);

    }



    VAR_1->stream_index = 0;



    return VAR_2;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ AVCodecContext *codec = VAR_0->streams[0]->codec; int VAR_2, VAR_3 = 1024; if (avio_feof(VAR_0->pb))
return AVERROR_EOF; if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||
codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { VAR_2 = av_get_packet(VAR_0->pb, VAR_1, codec->block_align); } else if (codec->codec_tag == MKTAG('W','A','D','P') && codec->channels > 1) { int VAR_4, VAR_5; av_new_packet(VAR_1, codec->block_align); for (VAR_4 = 0; VAR_4 < 4; VAR_4++) { for (VAR_5 = 0; VAR_5 < codec->channels; VAR_5++) { VAR_1->data[VAR_5 * 8 + VAR_4 * 2 + 0] = avio_r8(VAR_0->pb); VAR_1->data[VAR_5 * 8 + VAR_4 * 2 + 1] = avio_r8(VAR_0->pb); } } VAR_2 = 0; } else { VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3); } VAR_1->stream_index = 0; return VAR_2; }