diff options
author | Nathan Caldwell <saintdev@gmail.com> | 2012-09-28 23:16:09 -0600 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2012-10-01 14:42:40 +0200 |
commit | 6cb8c8540978ce6fe5355ec282693d6e6a3466d7 (patch) | |
tree | 9384a1cb299e2a208158bc53488562d3cd83159e /libavcodec/libopusdec.c | |
parent | 15d35bee83f7ace32725ea85044105867657d663 (diff) | |
download | ffmpeg-6cb8c8540978ce6fe5355ec282693d6e6a3466d7.tar.gz |
Opus encoder using libopus
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavcodec/libopusdec.c')
-rw-r--r-- | libavcodec/libopusdec.c | 28 |
1 files changed, 3 insertions, 25 deletions
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 <opus.h> #include <opus_multistream.h> -#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; |