static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,

                             const AVFrame *frame, int *got_packet_ptr)

{

    WMACodecContext *s = avctx->priv_data;

    int i, total_gain, ret, error;



    s->block_len_bits= s->frame_len_bits; //required by non variable block len

    s->block_len = 1 << s->block_len_bits;



    apply_window_and_mdct(avctx, frame);



    if (s->ms_stereo) {

        float a, b;

        int i;



        for(i = 0; i < s->block_len; i++) {

            a = s->coefs[0][i]*0.5;

            b = s->coefs[1][i]*0.5;

            s->coefs[0][i] = a + b;

            s->coefs[1][i] = a - b;

        }

    }



    if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE)))

        return ret;



    total_gain= 128;

    for(i=64; i; i>>=1){

        error = encode_frame(s, s->coefs, avpkt->data, avpkt->size,

                                 total_gain - i);

        if(error<=0)

            total_gain-= i;

    }



    while(total_gain <= 128 && error > 0)

        error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, total_gain++);

    av_assert0((put_bits_count(&s->pb) & 7) == 0);

    i= avctx->block_align - (put_bits_count(&s->pb)+7)/8;

    av_assert0(i>=0);

    while(i--)

        put_bits(&s->pb, 8, 'N');



    flush_put_bits(&s->pb);

    av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align);



    if (frame->pts != AV_NOPTS_VALUE)

        avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);



    avpkt->size = avctx->block_align;

    *got_packet_ptr = 1;

    return 0;

}

static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,

                             const AVFrame *frame, int *got_packet_ptr)

{

    WMACodecContext *s = avctx->priv_data;

    int i, total_gain, ret, error;



    s->block_len_bits= s->frame_len_bits; 

    s->block_len = 1 << s->block_len_bits;



    apply_window_and_mdct(avctx, frame);



    if (s->ms_stereo) {

        float a, b;

        int i;



        for(i = 0; i < s->block_len; i++) {

            a = s->coefs[0][i]*0.5;

            b = s->coefs[1][i]*0.5;

            s->coefs[0][i] = a + b;

            s->coefs[1][i] = a - b;

        }

    }



    if ((ret = ff_alloc_packet2(avctx, avpkt, 2 * MAX_CODED_SUPERFRAME_SIZE)))

        return ret;



    total_gain= 128;

    for(i=64; i; i>>=1){

        error = encode_frame(s, s->coefs, avpkt->data, avpkt->size,

                                 total_gain - i);

        if(error<=0)

            total_gain-= i;

    }



    while(total_gain <= 128 && error > 0)

        error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, total_gain++);

    av_assert0((put_bits_count(&s->pb) & 7) == 0);

    i= avctx->block_align - (put_bits_count(&s->pb)+7)/8;

    av_assert0(i>=0);

    while(i--)

        put_bits(&s->pb, 8, 'N');



    flush_put_bits(&s->pb);

    av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align);



    if (frame->pts != AV_NOPTS_VALUE)

        avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);



    avpkt->size = avctx->block_align;

    *got_packet_ptr = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,

                             const AVFrame *VAR_2, int *VAR_3)

{

    WMACodecContext *s = VAR_0->priv_data;

    int VAR_10, VAR_5, VAR_6, VAR_7;



    s->block_len_bits= s->frame_len_bits; 

    s->block_len = 1 << s->block_len_bits;



    apply_window_and_mdct(VAR_0, VAR_2);



    if (s->ms_stereo) {

        float VAR_8, VAR_9;

        int VAR_10;



        for(VAR_10 = 0; VAR_10 < s->block_len; VAR_10++) {

            VAR_8 = s->coefs[0][VAR_10]*0.5;

            VAR_9 = s->coefs[1][VAR_10]*0.5;

            s->coefs[0][VAR_10] = VAR_8 + VAR_9;

            s->coefs[1][VAR_10] = VAR_8 - VAR_9;

        }

    }



    if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, 2 * MAX_CODED_SUPERFRAME_SIZE)))

        return VAR_6;



    VAR_5= 128;

    for(VAR_10=64; VAR_10; VAR_10>>=1){

        VAR_7 = encode_frame(s, s->coefs, VAR_1->data, VAR_1->size,

                                 VAR_5 - VAR_10);

        if(VAR_7<=0)

            VAR_5-= VAR_10;

    }



    while(VAR_5 <= 128 && VAR_7 > 0)

        VAR_7 = encode_frame(s, s->coefs, VAR_1->data, VAR_1->size, VAR_5++);

    av_assert0((put_bits_count(&s->pb) & 7) == 0);

    VAR_10= VAR_0->block_align - (put_bits_count(&s->pb)+7)/8;

    av_assert0(VAR_10>=0);

    while(VAR_10--)

        put_bits(&s->pb, 8, 'N');



    flush_put_bits(&s->pb);

    av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == VAR_0->block_align);



    if (VAR_2->pts != AV_NOPTS_VALUE)

        VAR_1->pts = VAR_2->pts - ff_samples_to_time_base(VAR_0, VAR_0->delay);



    VAR_1->size = VAR_0->block_align;

    *VAR_3 = 1;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ WMACodecContext *s = VAR_0->priv_data; int VAR_10, VAR_5, VAR_6, VAR_7; s->block_len_bits= s->frame_len_bits; s->block_len = 1 << s->block_len_bits; apply_window_and_mdct(VAR_0, VAR_2); if (s->ms_stereo) { float VAR_8, VAR_9; int VAR_10; for(VAR_10 = 0; VAR_10 < s->block_len; VAR_10++) { VAR_8 = s->coefs[0][VAR_10]*0.5; VAR_9 = s->coefs[1][VAR_10]*0.5; s->coefs[0][VAR_10] = VAR_8 + VAR_9; s->coefs[1][VAR_10] = VAR_8 - VAR_9; } } if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, 2 * MAX_CODED_SUPERFRAME_SIZE)))
return VAR_6; VAR_5= 128; for(VAR_10=64; VAR_10; VAR_10>>=1){ VAR_7 = encode_frame(s, s->coefs, VAR_1->data, VAR_1->size,
VAR_5 - VAR_10); if(VAR_7<=0)
VAR_5-= VAR_10; } while(VAR_5 <= 128 && VAR_7 > 0)
VAR_7 = encode_frame(s, s->coefs, VAR_1->data, VAR_1->size, VAR_5++); av_assert0((put_bits_count(&s->pb) & 7) == 0); VAR_10= VAR_0->block_align - (put_bits_count(&s->pb)+7)/8; av_assert0(VAR_10>=0); while(VAR_10--)
put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == VAR_0->block_align); if (VAR_2->pts != AV_NOPTS_VALUE)
VAR_1->pts = VAR_2->pts - ff_samples_to_time_base(VAR_0, VAR_0->delay); VAR_1->size = VAR_0->block_align; *VAR_3 = 1; return 0; }