static void do_audio_out(AVFormatContext *s, 

                         AVOutputStream *ost, 

                         AVInputStream *ist,

                         unsigned char *buf, int size)

{

    uint8_t *buftmp;

    uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it */

    uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it - yep really WMA */

    int size_out, frame_bytes, ret;

    AVCodecContext *enc;



    enc = &ost->st->codec;



    if (ost->audio_resample) {

        buftmp = audio_buf;

        size_out = audio_resample(ost->resample, 

                                  (short *)buftmp, (short *)buf,

                                  size / (ist->st->codec.channels * 2));

        size_out = size_out * enc->channels * 2;

    } else {

        buftmp = buf;

        size_out = size;

    }



    /* now encode as many frames as possible */

    if (enc->frame_size > 1) {

        /* output resampled raw samples */

        fifo_write(&ost->fifo, buftmp, size_out, 

                   &ost->fifo.wptr);



        frame_bytes = enc->frame_size * 2 * enc->channels;

        

        while (fifo_read(&ost->fifo, audio_buf, frame_bytes, 

                     &ost->fifo.rptr) == 0) {

            ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out), 

                                       (short *)audio_buf);

            av_write_frame(s, ost->index, audio_out, ret);

        }

    } else {

        /* output a pcm frame */

        /* XXX: change encoding codec API to avoid this ? */

        switch(enc->codec->id) {

        case CODEC_ID_PCM_S16LE:

        case CODEC_ID_PCM_S16BE:

        case CODEC_ID_PCM_U16LE:

        case CODEC_ID_PCM_U16BE:

            break;

        default:

            size_out = size_out >> 1;

            break;

        }

        ret = avcodec_encode_audio(enc, audio_out, size_out, 

				   (short *)buftmp);

        av_write_frame(s, ost->index, audio_out, ret);

    }

}

static void do_audio_out(AVFormatContext *s, 

                         AVOutputStream *ost, 

                         AVInputStream *ist,

                         unsigned char *buf, int size)

{

    uint8_t *buftmp;

    uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; 

    uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; 

    int size_out, frame_bytes, ret;

    AVCodecContext *enc;



    enc = &ost->st->codec;



    if (ost->audio_resample) {

        buftmp = audio_buf;

        size_out = audio_resample(ost->resample, 

                                  (short *)buftmp, (short *)buf,

                                  size / (ist->st->codec.channels * 2));

        size_out = size_out * enc->channels * 2;

    } else {

        buftmp = buf;

        size_out = size;

    }



    

    if (enc->frame_size > 1) {

        

        fifo_write(&ost->fifo, buftmp, size_out, 

                   &ost->fifo.wptr);



        frame_bytes = enc->frame_size * 2 * enc->channels;

        

        while (fifo_read(&ost->fifo, audio_buf, frame_bytes, 

                     &ost->fifo.rptr) == 0) {

            ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out), 

                                       (short *)audio_buf);

            av_write_frame(s, ost->index, audio_out, ret);

        }

    } else {

        

        

        switch(enc->codec->id) {

        case CODEC_ID_PCM_S16LE:

        case CODEC_ID_PCM_S16BE:

        case CODEC_ID_PCM_U16LE:

        case CODEC_ID_PCM_U16BE:

            break;

        default:

            size_out = size_out >> 1;

            break;

        }

        ret = avcodec_encode_audio(enc, audio_out, size_out, 

				   (short *)buftmp);

        av_write_frame(s, ost->index, audio_out, ret);

    }

}

static void FUNC_0(AVFormatContext *VAR_0, 

                         AVOutputStream *VAR_1, 

                         AVInputStream *VAR_2,

                         unsigned char *VAR_3, int VAR_4)

{

    uint8_t *buftmp;

    uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; 

    uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; 

    int VAR_5, VAR_6, VAR_7;

    AVCodecContext *enc;



    enc = &VAR_1->st->codec;



    if (VAR_1->audio_resample) {

        buftmp = audio_buf;

        VAR_5 = audio_resample(VAR_1->resample, 

                                  (short *)buftmp, (short *)VAR_3,

                                  VAR_4 / (VAR_2->st->codec.channels * 2));

        VAR_5 = VAR_5 * enc->channels * 2;

    } else {

        buftmp = VAR_3;

        VAR_5 = VAR_4;

    }



    

    if (enc->frame_size > 1) {

        

        fifo_write(&VAR_1->fifo, buftmp, VAR_5, 

                   &VAR_1->fifo.wptr);



        VAR_6 = enc->frame_size * 2 * enc->channels;

        

        while (fifo_read(&VAR_1->fifo, audio_buf, VAR_6, 

                     &VAR_1->fifo.rptr) == 0) {

            VAR_7 = avcodec_encode_audio(enc, audio_out, sizeof(audio_out), 

                                       (short *)audio_buf);

            av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7);

        }

    } else {

        

        

        switch(enc->codec->id) {

        case CODEC_ID_PCM_S16LE:

        case CODEC_ID_PCM_S16BE:

        case CODEC_ID_PCM_U16LE:

        case CODEC_ID_PCM_U16BE:

            break;

        default:

            VAR_5 = VAR_5 >> 1;

            break;

        }

        VAR_7 = avcodec_encode_audio(enc, audio_out, VAR_5, 

				   (short *)buftmp);

        av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7);

    }

}

static void FUNC_0(AVFormatContext *VAR_0,
AVOutputStream *VAR_1,
AVInputStream *VAR_2,
unsigned char *VAR_3, int VAR_4)
{ uint8_t *buftmp; uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; int VAR_5, VAR_6, VAR_7; AVCodecContext *enc; enc = &VAR_1->st->codec; if (VAR_1->audio_resample) { buftmp = audio_buf; VAR_5 = audio_resample(VAR_1->resample,
(short *)buftmp, (short *)VAR_3,
VAR_4 / (VAR_2->st->codec.channels * 2)); VAR_5 = VAR_5 * enc->channels * 2; } else { buftmp = VAR_3; VAR_5 = VAR_4; } if (enc->frame_size > 1) { fifo_write(&VAR_1->fifo, buftmp, VAR_5,
&VAR_1->fifo.wptr); VAR_6 = enc->frame_size * 2 * enc->channels; while (fifo_read(&VAR_1->fifo, audio_buf, VAR_6,
&VAR_1->fifo.rptr) == 0) { VAR_7 = avcodec_encode_audio(enc, audio_out, sizeof(audio_out),
(short *)audio_buf); av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7); } } else { switch(enc->codec->id) { case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
break; default:
VAR_5 = VAR_5 >> 1; break; } VAR_7 = avcodec_encode_audio(enc, audio_out, VAR_5,
(short *)buftmp); av_write_frame(VAR_0, VAR_1->index, audio_out, VAR_7); } }