flacdsp_template.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Mans Rullgard <mans@mansr.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stdint.h>
22 #include "libavutil/avutil.h"
23 
24 #undef FUNC
25 #undef FSUF
26 #undef sample
27 #undef sample_type
28 #undef OUT
29 #undef S
30 
31 #if SAMPLE_SIZE == 32
32 # define sample_type int32_t
33 #else
34 # define sample_type int16_t
35 #endif
36 
37 #if PLANAR
38 # define FSUF AV_JOIN(SAMPLE_SIZE, p)
39 # define sample sample_type *
40 # define OUT(n) n
41 # define S(s, c, i) (s[c][i])
42 #else
43 # define FSUF SAMPLE_SIZE
44 # define sample sample_type
45 # define OUT(n) n[0]
46 # define S(s, c, i) (*s++)
47 #endif
48 
49 #define FUNC(n) AV_JOIN(n ## _, FSUF)
50 
52  int channels, int len, int shift)
53 {
54  sample *samples = (sample *) OUT(out);
55  int i, j;
56 
57  for (j = 0; j < len; j++)
58  for (i = 0; i < channels; i++)
59  S(samples, i, j) = in[i][j] << shift;
60 }
61 
63  int channels, int len, int shift)
64 {
65  sample *samples = (sample *) OUT(out);
66  int i;
67 
68  for (i = 0; i < len; i++) {
69  int a = in[0][i];
70  int b = in[1][i];
71  S(samples, 0, i) = a << shift;
72  S(samples, 1, i) = (a - b) << shift;
73  }
74 }
75 
77  int channels, int len, int shift)
78 {
79  sample *samples = (sample *) OUT(out);
80  int i;
81 
82  for (i = 0; i < len; i++) {
83  int a = in[0][i];
84  int b = in[1][i];
85  S(samples, 0, i) = (a + b) << shift;
86  S(samples, 1, i) = b << shift;
87  }
88 }
89 
91  int channels, int len, int shift)
92 {
93  sample *samples = (sample *) OUT(out);
94  int i;
95 
96  for (i = 0; i < len; i++) {
97  int a = in[0][i];
98  int b = in[1][i];
99  a -= b >> 1;
100  S(samples, 0, i) = (a + b) << shift;
101  S(samples, 1, i) = a << shift;
102  }
103 }
static int shift(int a, int b)
Definition: sonic.c:86
static void FUNC() flac_decorrelate_indep_c(uint8_t **out, int32_t **in, int channels, int len, int shift)
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
Definition: git-howto.txt:5
external API header
static void FUNC() flac_decorrelate_ls_c(uint8_t **out, int32_t **in, int channels, int len, int shift)
#define sample
uint8_t
#define b
Definition: input.c:42
#define S(s, c, i)
static void FUNC() flac_decorrelate_rs_c(uint8_t **out, int32_t **in, int channels, int len, int shift)
int32_t
static void FUNC() flac_decorrelate_ms_c(uint8_t **out, int32_t **in, int channels, int len, int shift)
#define OUT(n)
synthesis window for stochastic i
#define FUNC(n)
int len
Filter the word “frame” indicates either a video frame or a group of audio samples
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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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_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_dlog(ac->avr,"%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-> out