From 97c50cb77949856573d7f5f5a3c28cb73e61e011 Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Tue, 19 Apr 2005 05:16:45 +0000 Subject: sync to FFmpeg build 4752 CVS patchset: 7463 CVS date: 2005/04/19 05:16:45 --- src/libffmpeg/libavcodec/imgresample.c | 79 ++++++++-------------------------- 1 file changed, 18 insertions(+), 61 deletions(-) (limited to 'src/libffmpeg/libavcodec/imgresample.c') diff --git a/src/libffmpeg/libavcodec/imgresample.c b/src/libffmpeg/libavcodec/imgresample.c index 14fdb1059..2c7e1120a 100644 --- a/src/libffmpeg/libavcodec/imgresample.c +++ b/src/libffmpeg/libavcodec/imgresample.c @@ -55,6 +55,8 @@ struct ImgReSampleContext { uint8_t *line_buf; }; +void av_build_filter(int16_t *filter, double factor, int tap_count, int phase_count, int scale, int type); + static inline int get_phase(int pos) { return ((pos) >> (POS_FRAC_BITS - PHASE_BITS)) & ((1 << PHASE_BITS) - 1); @@ -540,39 +542,6 @@ static void component_resample(ImgReSampleContext *s, } } -/* XXX: the following filter is quite naive, but it seems to suffice - for 4 taps */ -static void build_filter(int16_t *filter, float factor) -{ - int ph, i, v; - float x, y, tab[NB_TAPS], norm, mult; - - /* if upsampling, only need to interpolate, no filter */ - if (factor > 1.0) - factor = 1.0; - - for(ph=0;ph= UINT_MAX / (LINE_BUF_HEIGHT + NB_TAPS)) + return NULL; s->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS)); if (!s->line_buf) goto fail; @@ -617,10 +588,10 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight, s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth; s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight; - build_filter(&s->h_filters[0][0], (float) s->pad_owidth / - (float) (iwidth - leftBand - rightBand)); - build_filter(&s->v_filters[0][0], (float) s->pad_oheight / - (float) (iheight - topBand - bottomBand)); + av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth / + (float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<v_filters[0][0], (float) s->pad_oheight / + (float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1< /* input */ #define XSIZE 256 @@ -698,11 +655,11 @@ static void dump_filter(int16_t *filter) int i, ph; for(ph=0;phh_filters[0][0]); component_resample(s, img1, xsize, xsize, ysize, img + 50 * XSIZE, XSIZE, XSIZE, YSIZE - 100); img_resample_close(s); - sprintf(buf, "/tmp/out%d.pgm", i); + snprintf(buf, sizeof(buf), "/tmp/out%d.pgm", i); save_pgm(buf, img1, xsize, ysize); } /* mmx test */ #ifdef HAVE_MMX - printf("MMX test\n"); + av_log(NULL, AV_LOG_INFO, "MMX test\n"); fact = 0.72; xsize = (int)(XSIZE * fact); ysize = (int)(YSIZE * fact); @@ -793,10 +750,10 @@ int main(int argc, char **argv) component_resample(s, img2, xsize, xsize, ysize, img, XSIZE, XSIZE, YSIZE); if (memcmp(img1, img2, xsize * ysize) != 0) { - fprintf(stderr, "mmx error\n"); + av_log(NULL, AV_LOG_ERROR, "mmx error\n"); exit(1); } - printf("MMX OK\n"); + av_log(NULL, AV_LOG_INFO, "MMX OK\n"); #endif return 0; } -- cgit v1.2.3