From 6cb8c8540978ce6fe5355ec282693d6e6a3466d7 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Fri, 28 Sep 2012 23:16:09 -0600 Subject: Opus encoder using libopus Signed-off-by: Diego Biurrun --- libavcodec/libopusdec.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'libavcodec/libopusdec.c') diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index 4335bd6eca..1b5b746496 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -22,40 +22,18 @@ #include #include -#include "libavutil/common.h" #include "libavutil/avassert.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "vorbis.h" #include "mathops.h" +#include "libopus.h" struct libopus_context { OpusMSDecoder *dec; AVFrame frame; }; -static int opus_error_to_averror(int err) -{ - switch (err) { - case OPUS_BAD_ARG: - return AVERROR(EINVAL); - case OPUS_BUFFER_TOO_SMALL: - return AVERROR_UNKNOWN; - case OPUS_INTERNAL_ERROR: - return AVERROR(EFAULT); - case OPUS_INVALID_PACKET: - return AVERROR_INVALIDDATA; - case OPUS_UNIMPLEMENTED: - return AVERROR(ENOSYS); - case OPUS_INVALID_STATE: - return AVERROR_UNKNOWN; - case OPUS_ALLOC_FAIL: - return AVERROR(ENOMEM); - default: - return AVERROR(EINVAL); - } -} - #define OPUS_HEAD_SIZE 19 static av_cold int libopus_decode_init(AVCodecContext *avc) @@ -107,7 +85,7 @@ static av_cold int libopus_decode_init(AVCodecContext *avc) if (!opus->dec) { av_log(avc, AV_LOG_ERROR, "Unable to create decoder: %s\n", opus_strerror(ret)); - return opus_error_to_averror(ret); + return ff_opus_error_to_averror(ret); } ret = opus_multistream_decoder_ctl(opus->dec, OPUS_SET_GAIN(gain_db)); @@ -156,7 +134,7 @@ static int libopus_decode(AVCodecContext *avc, void *frame, if (nb_samples < 0) { av_log(avc, AV_LOG_ERROR, "Decoding error: %s\n", opus_strerror(nb_samples)); - return opus_error_to_averror(nb_samples); + return ff_opus_error_to_averror(nb_samples); } opus->frame.nb_samples = nb_samples; -- cgit v1.2.3