void audio_encode_example(const char *filename)

{

    AVCodec *codec;

    AVCodecContext *c= NULL;

    int frame_size, i, j, out_size, outbuf_size;

    FILE *f;

    short *samples;

    float t, tincr;

    uint8_t *outbuf;



    printf("Audio encoding\n");



    /* find the MP2 encoder */

    codec = avcodec_find_encoder(CODEC_ID_MP2);

    if (!codec) {

        fprintf(stderr, "codec not found\n");

        exit(1);

    }



    c= avcodec_alloc_context();

    

    /* put sample parameters */

    c->bit_rate = 64000;

    c->sample_rate = 44100;

    c->channels = 2;



    /* open it */

    if (avcodec_open(c, codec) < 0) {

        fprintf(stderr, "could not open codec\n");

        exit(1);

    }

    

    /* the codec gives us the frame size, in samples */

    frame_size = c->frame_size;

    samples = malloc(frame_size * 2 * c->channels);

    outbuf_size = 10000;

    outbuf = malloc(outbuf_size);



    f = fopen(filename, "w");

    if (!f) {

        fprintf(stderr, "could not open %s\n", filename);

        exit(1);

    }

        

    /* encode a single tone sound */

    t = 0;

    tincr = 2 * M_PI * 440.0 / c->sample_rate;

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

        for(j=0;j<frame_size;j++) {

            samples[2*j] = (int)(sin(t) * 10000);

            samples[2*j+1] = samples[2*j];

            t += tincr;

        }

        /* encode the samples */

        out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);

        fwrite(outbuf, 1, out_size, f);

    }

    fclose(f);

    free(outbuf);

    free(samples);



    avcodec_close(c);

    free(c);

}

void audio_encode_example(const char *filename)

{

    AVCodec *codec;

    AVCodecContext *c= NULL;

    int frame_size, i, j, out_size, outbuf_size;

    FILE *f;

    short *samples;

    float t, tincr;

    uint8_t *outbuf;



    printf("Audio encoding\n");



    

    codec = avcodec_find_encoder(CODEC_ID_MP2);

    if (!codec) {

        fprintf(stderr, "codec not found\n");

        exit(1);

    }



    c= avcodec_alloc_context();

    

    

    c->bit_rate = 64000;

    c->sample_rate = 44100;

    c->channels = 2;



    

    if (avcodec_open(c, codec) < 0) {

        fprintf(stderr, "could not open codec\n");

        exit(1);

    }

    

    

    frame_size = c->frame_size;

    samples = malloc(frame_size * 2 * c->channels);

    outbuf_size = 10000;

    outbuf = malloc(outbuf_size);



    f = fopen(filename, "w");

    if (!f) {

        fprintf(stderr, "could not open %s\n", filename);

        exit(1);

    }

        

    

    t = 0;

    tincr = 2 * M_PI * 440.0 / c->sample_rate;

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

        for(j=0;j<frame_size;j++) {

            samples[2*j] = (int)(sin(t) * 10000);

            samples[2*j+1] = samples[2*j];

            t += tincr;

        }

        

        out_size = avcodec_encode_audio(c, outbuf, outbuf_size, samples);

        fwrite(outbuf, 1, out_size, f);

    }

    fclose(f);

    free(outbuf);

    free(samples);



    avcodec_close(c);

    free(c);

}

    f = fopen(filename, "w");     f = fopen(filename, "w");
void FUNC_0(const char *VAR_0)

{

    AVCodec *codec;

    AVCodecContext *c= NULL;

    int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;

    FILE *f;

    short *VAR_6;

    float VAR_7, VAR_8;

    uint8_t *outbuf;



    printf("Audio encoding\n");



    

    codec = avcodec_find_encoder(CODEC_ID_MP2);

    if (!codec) {

        fprintf(stderr, "codec not found\n");

        exit(1);

    }



    c= avcodec_alloc_context();

    

    

    c->bit_rate = 64000;

    c->sample_rate = 44100;

    c->channels = 2;



    

    if (avcodec_open(c, codec) < 0) {

        fprintf(stderr, "could not open codec\n");

        exit(1);

    }

    

    

    VAR_1 = c->VAR_1;

    VAR_6 = malloc(VAR_1 * 2 * c->channels);

    VAR_5 = 10000;

    outbuf = malloc(VAR_5);



    f = fopen(VAR_0, "w");

    if (!f) {

        fprintf(stderr, "could not open %s\n", VAR_0);

        exit(1);

    }

        

    

    VAR_7 = 0;

    VAR_8 = 2 * M_PI * 440.0 / c->sample_rate;

    for(VAR_2=0;VAR_2<200;VAR_2++) {

        for(VAR_3=0;VAR_3<VAR_1;VAR_3++) {

            VAR_6[2*VAR_3] = (int)(sin(VAR_7) * 10000);

            VAR_6[2*VAR_3+1] = VAR_6[2*VAR_3];

            VAR_7 += VAR_8;

        }

        

        VAR_4 = avcodec_encode_audio(c, outbuf, VAR_5, VAR_6);

        fwrite(outbuf, 1, VAR_4, f);

    }

    fclose(f);

    free(outbuf);

    free(VAR_6);



    avcodec_close(c);

    free(c);

}

void FUNC_0(const char *VAR_0)
{ AVCodec *codec; AVCodecContext *c= NULL; int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5; FILE *f; short *VAR_6; float VAR_7, VAR_8; uint8_t *outbuf; printf("Audio encoding\n"); codec = avcodec_find_encoder(CODEC_ID_MP2); if (!codec) { fprintf(stderr, "codec not found\n"); exit(1); } c= avcodec_alloc_context(); c->bit_rate = 64000; c->sample_rate = 44100; c->channels = 2; if (avcodec_open(c, codec) < 0) { fprintf(stderr, "could not open codec\n"); exit(1); } VAR_1 = c->VAR_1; VAR_6 = malloc(VAR_1 * 2 * c->channels); VAR_5 = 10000; outbuf = malloc(VAR_5); f = fopen(VAR_0, "w"); if (!f) { fprintf(stderr, "could not open %s\n", VAR_0); exit(1); } VAR_7 = 0; VAR_8 = 2 * M_PI * 440.0 / c->sample_rate; for(VAR_2=0;VAR_2<200;VAR_2++) { for(VAR_3=0;VAR_3<VAR_1;VAR_3++) { VAR_6[2*VAR_3] = (int)(sin(VAR_7) * 10000); VAR_6[2*VAR_3+1] = VAR_6[2*VAR_3]; VAR_7 += VAR_8; } VAR_4 = avcodec_encode_audio(c, outbuf, VAR_5, VAR_6); fwrite(outbuf, 1, VAR_4, f); } fclose(f); free(outbuf); free(VAR_6); avcodec_close(c); free(c); }