// The idiosyncrasies of GSM-in-WAV are explained at http://kbs.cs.tu-berlin.de/~jutta/toast.html
+#include "config.h"
+#if HAVE_GSM_H
+#include <gsm.h>
+#else
#include <gsm/gsm.h>
+#endif
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
}
}
-#if FF_API_OLD_ENCODE_AUDIO
- avctx->coded_frame= avcodec_alloc_frame();
- if (!avctx->coded_frame) {
- gsm_destroy(avctx->priv_data);
- return AVERROR(ENOMEM);
- }
-#endif
-
return 0;
}
static av_cold int libgsm_encode_close(AVCodecContext *avctx) {
-#if FF_API_OLD_ENCODE_AUDIO
- av_freep(&avctx->coded_frame);
-#endif
gsm_destroy(avctx->priv_data);
avctx->priv_data = NULL;
return 0;
AVCodec ff_libgsm_encoder = {
.name = "libgsm",
+ .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_GSM,
.init = libgsm_encode_init,
.close = libgsm_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
AVCodec ff_libgsm_ms_encoder = {
.name = "libgsm_ms",
+ .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_GSM_MS,
.init = libgsm_encode_init,
.close = libgsm_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
};
typedef struct LibGSMDecodeContext {
- AVFrame frame;
struct gsm_state *state;
} LibGSMDecodeContext;
}
}
- avcodec_get_frame_defaults(&s->frame);
- avctx->coded_frame = &s->frame;
-
return 0;
}
{
int i, ret;
LibGSMDecodeContext *s = avctx->priv_data;
+ AVFrame *frame = data;
uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int16_t *samples;
}
/* get output buffer */
- s->frame.nb_samples = avctx->frame_size;
- if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
+ frame->nb_samples = avctx->frame_size;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- samples = (int16_t *)s->frame.data[0];
+ samples = (int16_t *)frame->data[0];
for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
if ((ret = gsm_decode(s->state, buf, samples)) < 0)
samples += GSM_FRAME_SIZE;
}
- *got_frame_ptr = 1;
- *(AVFrame *)data = s->frame;
+ *got_frame_ptr = 1;
return avctx->block_align;
}
AVCodec ff_libgsm_decoder = {
.name = "libgsm",
+ .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_GSM,
.priv_data_size = sizeof(LibGSMDecodeContext),
.decode = libgsm_decode_frame,
.flush = libgsm_flush,
.capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
AVCodec ff_libgsm_ms_decoder = {
.name = "libgsm_ms",
+ .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_GSM_MS,
.priv_data_size = sizeof(LibGSMDecodeContext),
.decode = libgsm_decode_frame,
.flush = libgsm_flush,
.capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
};