summaryrefslogtreecommitdiff
path: root/libavresample/resample_template.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-04-11 20:38:59 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-04-11 20:39:04 +0200
commit662a8d882758ac90cf55968fc7ab3540e51f2d0b (patch)
treeaab4b2f82b340a4c449fa74d86e4e8fb4810dc0b /libavresample/resample_template.c
parent65088b925a0dc2defdeaffbbc24963ef34af7834 (diff)
parent254c95cdd1b669a722204a4a65974fc2523c8f83 (diff)
Merge commit '254c95cdd1b669a722204a4a65974fc2523c8f83'
* commit '254c95cdd1b669a722204a4a65974fc2523c8f83': resample: split linear into its own function Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavresample/resample_template.c')
-rw-r--r--libavresample/resample_template.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/libavresample/resample_template.c b/libavresample/resample_template.c
index a9bbdae3f2..863852a3fd 100644
--- a/libavresample/resample_template.c
+++ b/libavresample/resample_template.c
@@ -61,6 +61,27 @@ static void SET_TYPE(resample_nearest)(void *dst0, int dst_index, const void *sr
dst[dst_index] = src[index];
}
+static void SET_TYPE(resample_linear)(ResampleContext *c, void *dst0, int dst_index,
+ const void *src0, unsigned int index, int frac)
+{
+ FELEM *dst = dst0;
+ const FELEM *src = src0;
+ int i;
+ unsigned int sample_index = index >> c->phase_shift;
+ FELEM2 val = 0;
+ FELEM *filter = ((FELEM *)c->filter_bank) +
+ c->filter_length * (index & c->phase_mask);
+ FELEM2 v2 = 0;
+
+ for (i = 0; i < c->filter_length; i++) {
+ val += src[sample_index + i] * (FELEM2)filter[i];
+ v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
+ }
+ val += (v2 - val) * (FELEML)frac / c->src_incr;
+
+ OUT(dst[dst_index], val);
+}
+
static void SET_TYPE(resample_one)(ResampleContext *c,
void *dst0, int dst_index, const void *src0,
unsigned int index, int frac)
@@ -73,17 +94,8 @@ static void SET_TYPE(resample_one)(ResampleContext *c,
FELEM *filter = ((FELEM *)c->filter_bank) +
c->filter_length * (index & c->phase_mask);
- if (c->linear) {
- FELEM2 v2 = 0;
- for (i = 0; i < c->filter_length; i++) {
- val += src[sample_index + i] * (FELEM2)filter[i];
- v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
- }
- val += (v2 - val) * (FELEML)frac / c->src_incr;
- } else {
- for (i = 0; i < c->filter_length; i++)
- val += src[sample_index + i] * (FELEM2)filter[i];
- }
+ for (i = 0; i < c->filter_length; i++)
+ val += src[sample_index + i] * (FELEM2)filter[i];
OUT(dst[dst_index], val);
}