Move libgsm_encode_close before its first use and call it with the correct number of arguments.
Unified · Split
| @@ -32,6 +32,13 @@ · 31 unmodified lines | |||
| 32 | #include "avcodec.h" | 32 | #include "avcodec.h" |
| 33 | #include "gsm.h" | 33 | #include "gsm.h" |
| 34 | 34 | ||
| 35 | static av_cold int libgsm_encode_close(AVCodecContext *avctx) { | ||
| 36 | av_freep(&avctx->coded_frame); | ||
| 37 | gsm_destroy(avctx->priv_data); | ||
| 38 | avctx->priv_data = NULL; | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | |||
| 35 | static av_cold int libgsm_encode_init(AVCodecContext *avctx) { | 42 | static av_cold int libgsm_encode_init(AVCodecContext *avctx) { |
| 36 | if (avctx->channels > 1) { | 43 | if (avctx->channels > 1) { |
| 37 | av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", | 44 | av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", |
| @@ -77,17 +84,10 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) { · 39 unmodified lines | |||
| 77 | 84 | ||
| 78 | return 0; | 85 | return 0; |
| 79 | error: | 86 | error: |
| 80 | libgsm_encode_close(); | 87 | libgsm_encode_close(avctx); |
| 81 | return -1; | 88 | return -1; |
| 82 | } | 89 | } |
| 83 | 90 | ||
| 84 | static av_cold int libgsm_encode_close(AVCodecContext *avctx) { | ||
| 85 | av_freep(&avctx->coded_frame); | ||
| 86 | gsm_destroy(avctx->priv_data); | ||
| 87 | avctx->priv_data = NULL; | ||
| 88 | return 0; | ||
| 89 | } | ||
| 90 | |||
| 91 | static int libgsm_encode_frame(AVCodecContext *avctx, | 91 | static int libgsm_encode_frame(AVCodecContext *avctx, |
| 92 | unsigned char *frame, int buf_size, void *data) { | 92 | unsigned char *frame, int buf_size, void *data) { |
| 93 | // we need a full block | 93 | // we need a full block |