Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 174779 Details for
Bug 250181
media-video/mplayer-1.0_rc2_p28058: audio resampling
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
experimental support for resampling of 24-bit sound by lavcresample
mplayer-float-resample.diff (text/plain), 6.40 KB, created by
wbrana
on 2008-12-09 20:20:07 UTC
(
hide
)
Description:
experimental support for resampling of 24-bit sound by lavcresample
Filename:
MIME Type:
Creator:
wbrana
Created:
2008-12-09 20:20:07 UTC
Size:
6.40 KB
patch
obsolete
>diff --git a/libaf/af_lavcresample.c b/libaf/af_lavcresample.c >index 2dbdf78..c06104b 100644 >--- a/libaf/af_lavcresample.c >+++ b/libaf/af_lavcresample.c >@@ -28,10 +28,12 @@ > #include "libavcodec/avcodec.h" > #include "libavutil/rational.h" > >+#define FORMAT float >+ > // Data for specific instances of this filter > typedef struct af_resample_s{ > struct AVResampleContext *avrctx; >- int16_t *in[AF_NCH]; >+ FORMAT *in[AF_NCH]; > int in_alloc; > int index; > >@@ -56,8 +58,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg) > > af->data->nch = data->nch; > if (af->data->nch > AF_NCH) af->data->nch = AF_NCH; >- af->data->format = AF_FORMAT_S16_NE; >- af->data->bps = 2; >+ af->data->format = AF_FORMAT_FLOAT_NE; >+ af->data->bps = sizeof(FORMAT); > af->mul = (double)af->data->rate / data->rate; > af->delay = af->data->nch * s->filter_length / min(af->mul, 1); // *bps*.5 > >@@ -104,29 +106,29 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) > { > af_resample_t *s = af->setup; > int i, j, consumed, ret; >- int16_t *in = (int16_t*)data->audio; >- int16_t *out; >+ FORMAT *in = (FORMAT*)data->audio; >+ FORMAT *out; > int chans = data->nch; >- int in_len = data->len/(2*chans); >+ int in_len = data->len/(sizeof(FORMAT)*chans); > int out_len = in_len * af->mul + 10; >- int16_t tmp[AF_NCH][out_len]; >+ FORMAT tmp[AF_NCH][out_len]; > > if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) > return NULL; > >- out= (int16_t*)af->data->audio; >+ out= (FORMAT*)af->data->audio; > >- out_len= min(out_len, af->data->len/(2*chans)); >+ out_len= min(out_len, af->data->len/(sizeof(FORMAT)*chans)); > > if(s->in_alloc < in_len + s->index){ > s->in_alloc= in_len + s->index; > for(i=0; i<chans; i++){ >- s->in[i]= realloc(s->in[i], s->in_alloc*sizeof(int16_t)); >+ s->in[i]= realloc(s->in[i], s->in_alloc*sizeof(FORMAT)); > } > } > > if(chans==1){ >- memcpy(&s->in[0][s->index], in, in_len * sizeof(int16_t)); >+ memcpy(&s->in[0][s->index], in, in_len * sizeof(FORMAT)); > }else if(chans==2){ > for(j=0; j<in_len; j++){ > s->in[0][j + s->index]= *(in++); >@@ -148,11 +150,11 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) > > s->index= in_len - consumed; > for(i=0; i<chans; i++){ >- memmove(s->in[i], s->in[i] + consumed, s->index*sizeof(int16_t)); >+ memmove(s->in[i], s->in[i] + consumed, s->index*sizeof(FORMAT)); > } > > if(chans==1){ >- memcpy(out, tmp[0], out_len*sizeof(int16_t)); >+ memcpy(out, tmp[0], out_len*sizeof(FORMAT)); > }else if(chans==2){ > for(j=0; j<out_len; j++){ > *(out++)= tmp[0][j]; >@@ -167,7 +169,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) > } > > data->audio = af->data->audio; >- data->len = out_len*chans*2; >+ data->len = out_len*chans*sizeof(FORMAT); > data->rate = af->data->rate; > return data; > } >diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h >index 53ded30..13bdc0e 100644 >--- a/libavcodec/avcodec.h >+++ b/libavcodec/avcodec.h >@@ -2407,7 +2407,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl > void audio_resample_close(ReSampleContext *s); > > struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); >-int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); >+int av_resample(struct AVResampleContext *c, float *dst, float *src, int *consumed, int src_size, int dst_size, int update_ctx); > void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); > void av_resample_close(struct AVResampleContext *c); > >diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c >index 4397d2a..710eb75 100644 >--- a/libavcodec/resample2.c >+++ b/libavcodec/resample2.c >@@ -28,33 +28,14 @@ > #include "avcodec.h" > #include "dsputil.h" > >-#ifndef CONFIG_RESAMPLE_HP >-#define FILTER_SHIFT 15 >- >-#define FELEM int16_t >-#define FELEM2 int32_t >-#define FELEML int64_t >-#define FELEM_MAX INT16_MAX >-#define FELEM_MIN INT16_MIN >-#define WINDOW_TYPE 9 >-#elif !defined(CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE) >-#define FILTER_SHIFT 30 >- >-#define FELEM int32_t >-#define FELEM2 int64_t >-#define FELEML int64_t >-#define FELEM_MAX INT32_MAX >-#define FELEM_MIN INT32_MIN >-#define WINDOW_TYPE 12 >-#else > #define FILTER_SHIFT 0 > > #define FELEM double > #define FELEM2 double > #define FELEML double > #define WINDOW_TYPE 24 >-#endif > >+#define FORMAT float > > typedef struct AVResampleContext{ > FELEM *filter_bank; >@@ -130,11 +111,13 @@ void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_coun > > /* normalize so that an uniform color remains the same */ > for(i=0;i<tap_count;i++) { >-#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE >+//#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE > filter[ph * tap_count + i] = tab[i] / norm; >+/* > #else > filter[ph * tap_count + i] = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); > #endif >+*/ > } > } > #if 0 >@@ -233,7 +216,7 @@ void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensa > * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. > * @return the number of samples written in dst or -1 if an error occurred > */ >-int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){ >+int av_resample(AVResampleContext *c, float *dst, float *src, int *consumed, int src_size, int dst_size, int update_ctx){ > int dst_index, i; > int index= c->index; > int frac= c->frac; >@@ -277,13 +260,21 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int > val += src[sample_index + i] * (FELEM2)filter[i]; > } > } >- >+ if (val>1){ >+ val=1; >+ } if (val<-1){ >+ val=-1; >+ }; >+ dst[dst_index] = val; >+/* > #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE >- dst[dst_index] = av_clip_int16(lrintf(val)); >+ dst[dst_index] = av_clip_int16(lrintf(val)); >+ > #else > val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; > dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; > #endif >+*/ > > frac += dst_incr_frac; > index += dst_incr;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 250181
: 174779