FFmpeg  4.3
sbcdsp.h
Go to the documentation of this file.
1 /*
2  * Bluetooth low-complexity, subband codec (SBC)
3  *
4  * Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
5  * Copyright (C) 2008-2010 Nokia Corporation
6  * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
7  * Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
8  * Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
9  *
10  * This file is part of FFmpeg.
11  *
12  * FFmpeg is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * FFmpeg is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with FFmpeg; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 
27 /**
28  * @file
29  * SBC basic "building bricks"
30  */
31 
32 #ifndef AVCODEC_SBCDSP_H
33 #define AVCODEC_SBCDSP_H
34 
35 #include "sbc.h"
36 #include "sbcdsp_data.h"
37 
38 #define SCALE_OUT_BITS 15
39 #define SBC_X_BUFFER_SIZE 328
40 
41 typedef struct sbc_dsp_context SBCDSPContext;
42 
44  int position;
45  /* Number of consecutive blocks handled by the encoder */
48  void (*sbc_analyze_4)(const int16_t *in, int32_t *out, const int16_t *consts);
49  void (*sbc_analyze_8)(const int16_t *in, int32_t *out, const int16_t *consts);
50  /* Polyphase analysis filter for 4 subbands configuration,
51  * it handles "increment" blocks at once */
52  void (*sbc_analyze_4s)(SBCDSPContext *s,
53  int16_t *x, int32_t *out, int out_stride);
54  /* Polyphase analysis filter for 8 subbands configuration,
55  * it handles "increment" blocks at once */
56  void (*sbc_analyze_8s)(SBCDSPContext *s,
57  int16_t *x, int32_t *out, int out_stride);
58  /* Process input data (deinterleave, endian conversion, reordering),
59  * depending on the number of subbands and input data byte order */
61  int16_t X[2][SBC_X_BUFFER_SIZE],
62  int nsamples, int nchannels);
64  int16_t X[2][SBC_X_BUFFER_SIZE],
65  int nsamples, int nchannels);
66  /* Scale factors calculation */
67  void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8],
68  uint32_t scale_factor[2][8],
69  int blocks, int channels, int subbands);
70  /* Scale factors calculation with joint stereo support */
71  int (*sbc_calc_scalefactors_j)(int32_t sb_sample_f[16][2][8],
72  uint32_t scale_factor[2][8],
73  int blocks, int subbands);
74 };
75 
76 /*
77  * Initialize pointers to the functions which are the basic "building bricks"
78  * of SBC codec. Best implementation is selected based on target CPU
79  * capabilities.
80  */
81 void ff_sbcdsp_init(SBCDSPContext *s);
82 
83 void ff_sbcdsp_init_arm(SBCDSPContext *s);
84 void ff_sbcdsp_init_x86(SBCDSPContext *s);
85 
86 #endif /* AVCODEC_SBCDSP_H */
sbc_dsp_context
Definition: sbcdsp.h:43
out
FILE * out
Definition: movenc.c:54
subbands
subbands
Definition: aptx.h:39
ff_sbcdsp_init
void ff_sbcdsp_init(SBCDSPContext *s)
Definition: sbcdsp.c:364
ff_sbcdsp_init_x86
void ff_sbcdsp_init_x86(SBCDSPContext *s)
Definition: sbcdsp_init.c:42
x
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
Definition: fate.txt:150
sbc_dsp_context::sbc_analyze_4
void(* sbc_analyze_4)(const int16_t *in, int32_t *out, const int16_t *consts)
Definition: sbcdsp.h:48
s
#define s(width, name)
Definition: cbs_vp9.c:257
channels
channels
Definition: aptx.h:33
int32_t
int32_t
Definition: audio_convert.c:194
sbcdsp_data.h
SBC_ALIGN
#define SBC_ALIGN
Definition: sbc.h:78
sbc_dsp_context::X
int16_t X[2][SBC_X_BUFFER_SIZE]
Definition: sbcdsp.h:47
sbc_dsp_context::increment
uint8_t increment
Definition: sbcdsp.h:46
sbc.h
sbc_dsp_context::sbc_analyze_4s
void(* sbc_analyze_4s)(SBCDSPContext *s, int16_t *x, int32_t *out, int out_stride)
Definition: sbcdsp.h:52
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:112
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
SBC_X_BUFFER_SIZE
#define SBC_X_BUFFER_SIZE
Definition: sbcdsp.h:39
sbc_dsp_context::sbc_analyze_8
void(* sbc_analyze_8)(const int16_t *in, int32_t *out, const int16_t *consts)
Definition: sbcdsp.h:49
uint8_t
uint8_t
Definition: audio_convert.c:194
sbc_dsp_context::sbc_calc_scalefactors
void(* sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8], uint32_t scale_factor[2][8], int blocks, int channels, int subbands)
Definition: sbcdsp.h:67
sbc_dsp_context::sbc_enc_process_input_4s
int(* sbc_enc_process_input_4s)(int position, const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE], int nsamples, int nchannels)
Definition: sbcdsp.h:60
void
typedef void(RENAME(mix_any_func_type))
Definition: rematrix_template.c:52
sbc_dsp_context::sbc_enc_process_input_8s
int(* sbc_enc_process_input_8s)(int position, const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE], int nsamples, int nchannels)
Definition: sbcdsp.h:63
sbc_dsp_context::sbc_calc_scalefactors_j
int(* sbc_calc_scalefactors_j)(int32_t sb_sample_f[16][2][8], uint32_t scale_factor[2][8], int blocks, int subbands)
Definition: sbcdsp.h:71
sbc_dsp_context::sbc_analyze_8s
void(* sbc_analyze_8s)(SBCDSPContext *s, int16_t *x, int32_t *out, int out_stride)
Definition: sbcdsp.h:56
int
int
Definition: ffmpeg_filter.c:192
ff_sbcdsp_init_arm
void ff_sbcdsp_init_arm(SBCDSPContext *s)
Definition: sbcdsp_init_arm.c:86
sbc_dsp_context::position
int position
Definition: sbcdsp.h:44