Commit ff4600d9 authored by Aurelien Jacobs's avatar Aurelien Jacobs

sbc: implement SBC encoder (low-complexity subband codec)

This was originally based on libsbc, and was fully integrated into ffmpeg.
parent 2e08de08
...@@ -1142,7 +1142,7 @@ following image formats are supported: ...@@ -1142,7 +1142,7 @@ following image formats are supported:
@tab Real low bitrate AC-3 codec @tab Real low bitrate AC-3 codec
@item RealAudio Lossless @tab @tab X @item RealAudio Lossless @tab @tab X
@item RealAudio SIPR / ACELP.NET @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X
@item SBC (low-complexity subband codec) @tab @tab X @item SBC (low-complexity subband codec) @tab X @tab X
@tab Used in Bluetooth A2DP @tab Used in Bluetooth A2DP
@item Shorten @tab @tab X @item Shorten @tab @tab X
@item Sierra VMD audio @tab @tab X @item Sierra VMD audio @tab @tab X
......
...@@ -588,6 +588,7 @@ OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o ...@@ -588,6 +588,7 @@ OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o
OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o
OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o
OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o
OBJS-$(CONFIG_SBC_ENCODER) += sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263data.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o h263data.o \ OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o h263data.o \
h263.o ituh263enc.o h263.o ituh263enc.o
......
...@@ -453,6 +453,7 @@ extern AVCodec ff_ra_144_encoder; ...@@ -453,6 +453,7 @@ extern AVCodec ff_ra_144_encoder;
extern AVCodec ff_ra_144_decoder; extern AVCodec ff_ra_144_decoder;
extern AVCodec ff_ra_288_decoder; extern AVCodec ff_ra_288_decoder;
extern AVCodec ff_ralf_decoder; extern AVCodec ff_ralf_decoder;
extern AVCodec ff_sbc_encoder;
extern AVCodec ff_sbc_decoder; extern AVCodec ff_sbc_decoder;
extern AVCodec ff_shorten_decoder; extern AVCodec ff_shorten_decoder;
extern AVCodec ff_sipr_decoder; extern AVCodec ff_sipr_decoder;
......
...@@ -2926,6 +2926,8 @@ typedef struct AVCodecContext { ...@@ -2926,6 +2926,8 @@ typedef struct AVCodecContext {
#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3 #define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3
#define FF_PROFILE_MJPEG_JPEG_LS 0xf7 #define FF_PROFILE_MJPEG_JPEG_LS 0xf7
#define FF_PROFILE_SBC_MSBC 1
/** /**
* level * level
* - encoding: Set by user. * - encoding: Set by user.
......
...@@ -300,6 +300,7 @@ static const AVOption avcodec_options[] = { ...@@ -300,6 +300,7 @@ static const AVOption avcodec_options[] = {
{"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, INT_MIN, INT_MAX, V|E, "profile"}, {"mpeg4_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_MAIN }, INT_MIN, INT_MAX, V|E, "profile"},
{"mpeg4_asp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "profile"}, {"mpeg4_asp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "profile"},
{"main10", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, V|E, "profile"}, {"main10", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, V|E, "profile"},
{"msbc", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_SBC_MSBC }, INT_MIN, INT_MAX, A|E, "profile"},
{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D}, {"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
......
...@@ -140,4 +140,9 @@ const AVProfile ff_vp9_profiles[] = { ...@@ -140,4 +140,9 @@ const AVProfile ff_vp9_profiles[] = {
{ FF_PROFILE_UNKNOWN }, { FF_PROFILE_UNKNOWN },
}; };
const AVProfile ff_sbc_profiles[] = {
{ FF_PROFILE_SBC_MSBC, "mSBC" },
{ FF_PROFILE_UNKNOWN },
};
#endif /* !CONFIG_SMALL */ #endif /* !CONFIG_SMALL */
...@@ -31,5 +31,6 @@ extern const AVProfile ff_mpeg2_video_profiles[]; ...@@ -31,5 +31,6 @@ extern const AVProfile ff_mpeg2_video_profiles[];
extern const AVProfile ff_mpeg4_video_profiles[]; extern const AVProfile ff_mpeg4_video_profiles[];
extern const AVProfile ff_vc1_profiles[]; extern const AVProfile ff_vc1_profiles[];
extern const AVProfile ff_vp9_profiles[]; extern const AVProfile ff_vp9_profiles[];
extern const AVProfile ff_sbc_profiles[];
#endif /* AVCODEC_PROFILES_H */ #endif /* AVCODEC_PROFILES_H */
This diff is collapsed.
/*
* Bluetooth low-complexity, subband codec (SBC)
*
* Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
* Copyright (C) 2008-2010 Nokia Corporation
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
* Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* SBC basic "building bricks"
*/
#ifndef AVCODEC_SBCDSP_H
#define AVCODEC_SBCDSP_H
#include "sbc.h"
#include "sbcdsp_data.h"
#define SCALE_OUT_BITS 15
#define SBC_X_BUFFER_SIZE 328
typedef struct sbc_dsp_context SBCDSPContext;
struct sbc_dsp_context {
int position;
/* Number of consecutive blocks handled by the encoder */
uint8_t increment;
DECLARE_ALIGNED(SBC_ALIGN, int16_t, X)[2][SBC_X_BUFFER_SIZE];
void (*sbc_analyze_4)(const int16_t *in, int32_t *out, const int16_t *consts);
void (*sbc_analyze_8)(const int16_t *in, int32_t *out, const int16_t *consts);
/* Polyphase analysis filter for 4 subbands configuration,
* it handles "increment" blocks at once */
void (*sbc_analyze_4s)(SBCDSPContext *s,
int16_t *x, int32_t *out, int out_stride);
/* Polyphase analysis filter for 8 subbands configuration,
* it handles "increment" blocks at once */
void (*sbc_analyze_8s)(SBCDSPContext *s,
int16_t *x, int32_t *out, int out_stride);
/* Process input data (deinterleave, endian conversion, reordering),
* depending on the number of subbands and input data byte order */
int (*sbc_enc_process_input_4s)(int position, const uint8_t *pcm,
int16_t X[2][SBC_X_BUFFER_SIZE],
int nsamples, int nchannels);
int (*sbc_enc_process_input_8s)(int position, const uint8_t *pcm,
int16_t X[2][SBC_X_BUFFER_SIZE],
int nsamples, int nchannels);
/* Scale factors calculation */
void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8],
uint32_t scale_factor[2][8],
int blocks, int channels, int subbands);
/* Scale factors calculation with joint stereo support */
int (*sbc_calc_scalefactors_j)(int32_t sb_sample_f[16][2][8],
uint32_t scale_factor[2][8],
int blocks, int subbands);
};
/*
* Initialize pointers to the functions which are the basic "building bricks"
* of SBC codec. Best implementation is selected based on target CPU
* capabilities.
*/
void ff_sbcdsp_init(SBCDSPContext *s);
#endif /* AVCODEC_SBCDSP_H */
This diff is collapsed.
/*
* Bluetooth low-complexity, subband codec (SBC)
*
* Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
* Copyright (C) 2008-2010 Nokia Corporation
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
* Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* miscellaneous SBC tables
*/
#ifndef AVCODEC_SBCDSP_DATA_H
#define AVCODEC_SBCDSP_DATA_H
#include "sbc.h"
#define SBC_PROTO_FIXED_SCALE 16
#define SBC_COS_TABLE_FIXED_SCALE 15
/*
* Constant tables for the use in SIMD optimized analysis filters
* Each table consists of two parts:
* 1. reordered "proto" table
* 2. reordered "cos" table
*
* Due to non-symmetrical reordering, separate tables for "even"
* and "odd" cases are needed
*/
extern const int16_t ff_sbcdsp_analysis_consts_fixed4_simd_even[];
extern const int16_t ff_sbcdsp_analysis_consts_fixed4_simd_odd[];
extern const int16_t ff_sbcdsp_analysis_consts_fixed8_simd_even[];
extern const int16_t ff_sbcdsp_analysis_consts_fixed8_simd_odd[];
#endif /* AVCODEC_SBCDSP_DATA_H */
This diff is collapsed.
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