X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=tests%2Fapi%2Fapi-flac-test.c;h=3fea3258f319bff6756beec9e9e24071f6aca62e;hb=09a39042db1b34672ba92a29c2b2f8f18a588a40;hp=2e9081266f829646aeece42c0288fcdcdb55f204;hpb=b4ca32414ea28ad29b4bd387c298f5a676dace2a;p=ffmpeg diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c index 2e9081266f8..3fea3258f31 100644 --- a/tests/api/api-flac-test.c +++ b/tests/api/api-flac-test.c @@ -31,7 +31,7 @@ #include "libavutil/common.h" #include "libavutil/samplefmt.h" -#define NUMBER_OF_FRAMES 200 +#define NUMBER_OF_AUDIO_FRAMES 200 #define NAME_BUFF_SIZE 100 /* generate i-th frame of test audio */ @@ -126,7 +126,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, in_frame->nb_samples = enc_ctx->frame_size; in_frame->format = enc_ctx->sample_fmt; in_frame->channel_layout = enc_ctx->channel_layout; - if (av_frame_get_buffer(in_frame, 32) != 0) { + if (av_frame_get_buffer(in_frame, 0) != 0) { av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input frame\n"); return AVERROR(ENOMEM); } @@ -137,19 +137,19 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, return AVERROR(ENOMEM); } - raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); + raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_AUDIO_FRAMES); if (!raw_in) { av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n"); return AVERROR(ENOMEM); } - raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES); + raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_AUDIO_FRAMES); if (!raw_out) { av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n"); return AVERROR(ENOMEM); } - for (i = 0; i < NUMBER_OF_FRAMES; i++) { + for (i = 0; i < NUMBER_OF_AUDIO_FRAMES; i++) { av_init_packet(&enc_pkt); enc_pkt.data = NULL; enc_pkt.size = 0; @@ -209,7 +209,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, av_packet_unref(&enc_pkt); } - if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) { + if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_AUDIO_FRAMES) != 0) { av_log(NULL, AV_LOG_ERROR, "Output differs\n"); return 1; } @@ -223,20 +223,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, return 0; } -static int close_encoder(AVCodecContext **enc_ctx) -{ - avcodec_close(*enc_ctx); - av_freep(enc_ctx); - return 0; -} - -static int close_decoder(AVCodecContext **dec_ctx) -{ - avcodec_close(*dec_ctx); - av_freep(dec_ctx); - return 0; -} - int main(void) { AVCodec *enc = NULL, *dec = NULL; @@ -265,8 +251,8 @@ int main(void) return 1; if (run_test(enc, dec, enc_ctx, dec_ctx) != 0) return 1; - close_encoder(&enc_ctx); - close_decoder(&dec_ctx); + avcodec_free_context(&enc_ctx); + avcodec_free_context(&dec_ctx); } }