Commit 6cb8c854 authored by Nathan Caldwell's avatar Nathan Caldwell Committed by Diego Biurrun

Opus encoder using libopus

Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
parent 15d35bee
......@@ -49,7 +49,7 @@ version <next>:
- RTP depacketization of JPEG
- Smooth Streaming live segmenter muxer
- RTP packetization of JPEG
- Opus decoder using libopus
- Opus decoder and encoder using libopus
version 0.8:
......
......@@ -1583,6 +1583,7 @@ libopencore_amrwb_decoder_deps="libopencore_amrwb"
libopenjpeg_decoder_deps="libopenjpeg"
libopenjpeg_encoder_deps="libopenjpeg"
libopus_decoder_deps="libopus"
libopus_encoder_deps="libopus"
libschroedinger_decoder_deps="libschroedinger"
libschroedinger_encoder_deps="libschroedinger"
libspeex_decoder_deps="libspeex"
......
......@@ -756,7 +756,7 @@ following image formats are supported:
@item Musepack SV7 @tab @tab X
@item Musepack SV8 @tab @tab X
@item Nellymoser Asao @tab X @tab X
@item Opus @tab @tab E
@item Opus @tab E @tab E
@tab supported through external library libopus
@item PCM A-law @tab X @tab X
@item PCM mu-law @tab X @tab X
......
......@@ -581,7 +581,10 @@ OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENJPEG_DECODER) += libopenjpegdec.o
OBJS-$(CONFIG_LIBOPENJPEG_ENCODER) += libopenjpegenc.o
OBJS-$(CONFIG_LIBOPUS_DECODER) += libopusdec.o vorbis_data.o
OBJS-$(CONFIG_LIBOPUS_DECODER) += libopusdec.o libopus.o \
vorbis_data.o
OBJS-$(CONFIG_LIBOPUS_ENCODER) += libopusenc.o libopus.o \
vorbis_data.o audio_frame_queue.o
OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o \
libschroedinger.o
OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \
......
......@@ -393,7 +393,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (LIBOPENCORE_AMRNB, libopencore_amrnb);
REGISTER_DECODER (LIBOPENCORE_AMRWB, libopencore_amrwb);
REGISTER_ENCDEC (LIBOPENJPEG, libopenjpeg);
REGISTER_DECODER (LIBOPUS, libopus);
REGISTER_ENCDEC (LIBOPUS, libopus);
REGISTER_ENCDEC (LIBSCHROEDINGER, libschroedinger);
REGISTER_ENCDEC (LIBSPEEX, libspeex);
REGISTER_ENCODER (LIBTHEORA, libtheora);
......
/*
* libopus encoder/decoder common code
* Copyright (c) 2012 Nicolas George
*
* This file is part of libav.
*
* libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <opus_defines.h>
#include "libavutil/common.h"
#include "libavutil/error.h"
#include "libopus.h"
int ff_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);
}
}
/*
* libopus encoder/decoder common code
* Copyright (c) 2012 Nicolas George
*
* This file is part of libav.
*
* libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_LIBOPUS_H
#define AVCODEC_LIBOPUS_H
int ff_opus_error_to_averror(int err);
#endif /* AVCODEC_LIBOPUS_H */
......@@ -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;
......
This diff is collapsed.
......@@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 30
#define LIBAVCODEC_VERSION_MINOR 31
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment