diff options
-rw-r--r-- | libavcodec/dsputil.c | 31 | ||||
-rw-r--r-- | libavcodec/dsputil.h | 2 | ||||
-rw-r--r-- | libavcodec/i386/dsputil_mmx.c | 90 | ||||
-rw-r--r-- | libavcodec/i386/mpegvideo_mmx.c | 90 | ||||
-rw-r--r-- | libavcodec/mpegvideo.c | 38 | ||||
-rw-r--r-- | libavcodec/snow.c | 6 |
6 files changed, 129 insertions, 128 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 055486d493..af6341a729 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -404,6 +404,35 @@ int w97_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ } #endif +/* draw the edges of width 'w' of an image of size width, height */ +//FIXME check that this is ok for mpeg4 interlaced +static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w) +{ + uint8_t *ptr, *last_line; + int i; + + last_line = buf + (height - 1) * wrap; + for(i=0;i<w;i++) { + /* top and bottom */ + memcpy(buf - (i + 1) * wrap, buf, width); + memcpy(last_line + (i + 1) * wrap, last_line, width); + } + /* left and right */ + ptr = buf; + for(i=0;i<height;i++) { + memset(ptr - w, ptr[0], w); + memset(ptr + width, ptr[width-1], w); + ptr += wrap; + } + /* corners */ + for(i=0;i<w;i++) { + memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */ + memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */ + memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ + memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ + } +} + static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) { int i; @@ -4203,6 +4232,8 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c; c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c; + c->draw_edges = draw_edges_c; + #ifdef CONFIG_CAVS_DECODER ff_cavsdsp_init(c,avctx); #endif diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 5fe169eccd..dc930431d8 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -392,6 +392,8 @@ typedef struct DSPContext { #define BASIS_SHIFT 16 #define RECON_SHIFT 6 + void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w); + /* h264 functions */ void (*h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride); void (*h264_idct8_add)(uint8_t *dst, DCTELEM *block, int stride); diff --git a/libavcodec/i386/dsputil_mmx.c b/libavcodec/i386/dsputil_mmx.c index 30e938312d..c0d5bfcaca 100644 --- a/libavcodec/i386/dsputil_mmx.c +++ b/libavcodec/i386/dsputil_mmx.c @@ -696,6 +696,94 @@ static void h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale){ } } +/* draw the edges of width 'w' of an image of size width, height + this mmx version can only handle w==8 || w==16 */ +static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w) +{ + uint8_t *ptr, *last_line; + int i; + + last_line = buf + (height - 1) * wrap; + /* left and right */ + ptr = buf; + if(w==8) + { + asm volatile( + "1: \n\t" + "movd (%0), %%mm0 \n\t" + "punpcklbw %%mm0, %%mm0 \n\t" + "punpcklwd %%mm0, %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "movq %%mm0, -8(%0) \n\t" + "movq -8(%0, %2), %%mm1 \n\t" + "punpckhbw %%mm1, %%mm1 \n\t" + "punpckhwd %%mm1, %%mm1 \n\t" + "punpckhdq %%mm1, %%mm1 \n\t" + "movq %%mm1, (%0, %2) \n\t" + "add %1, %0 \n\t" + "cmp %3, %0 \n\t" + " jb 1b \n\t" + : "+r" (ptr) + : "r" ((long)wrap), "r" ((long)width), "r" (ptr + wrap*height) + ); + } + else + { + asm volatile( + "1: \n\t" + "movd (%0), %%mm0 \n\t" + "punpcklbw %%mm0, %%mm0 \n\t" + "punpcklwd %%mm0, %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "movq %%mm0, -8(%0) \n\t" + "movq %%mm0, -16(%0) \n\t" + "movq -8(%0, %2), %%mm1 \n\t" + "punpckhbw %%mm1, %%mm1 \n\t" + "punpckhwd %%mm1, %%mm1 \n\t" + "punpckhdq %%mm1, %%mm1 \n\t" + "movq %%mm1, (%0, %2) \n\t" + "movq %%mm1, 8(%0, %2) \n\t" + "add %1, %0 \n\t" + "cmp %3, %0 \n\t" + " jb 1b \n\t" + : "+r" (ptr) + : "r" ((long)wrap), "r" ((long)width), "r" (ptr + wrap*height) + ); + } + + for(i=0;i<w;i+=4) { + /* top and bottom (and hopefully also the corners) */ + ptr= buf - (i + 1) * wrap - w; + asm volatile( + "1: \n\t" + "movq (%1, %0), %%mm0 \n\t" + "movq %%mm0, (%0) \n\t" + "movq %%mm0, (%0, %2) \n\t" + "movq %%mm0, (%0, %2, 2) \n\t" + "movq %%mm0, (%0, %3) \n\t" + "add $8, %0 \n\t" + "cmp %4, %0 \n\t" + " jb 1b \n\t" + : "+r" (ptr) + : "r" ((long)buf - (long)ptr - w), "r" ((long)-wrap), "r" ((long)-wrap*3), "r" (ptr+width+2*w) + ); + ptr= last_line + (i + 1) * wrap - w; + asm volatile( + "1: \n\t" + "movq (%1, %0), %%mm0 \n\t" + "movq %%mm0, (%0) \n\t" + "movq %%mm0, (%0, %2) \n\t" + "movq %%mm0, (%0, %2, 2) \n\t" + "movq %%mm0, (%0, %3) \n\t" + "add $8, %0 \n\t" + "cmp %4, %0 \n\t" + " jb 1b \n\t" + : "+r" (ptr) + : "r" ((long)last_line - (long)ptr - w), "r" ((long)wrap), "r" ((long)wrap*3), "r" (ptr+width+2*w) + ); + } +} + #define PAETH(cpu, abs3)\ void add_png_paeth_prediction_##cpu(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)\ {\ @@ -2075,6 +2163,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) c->add_bytes= add_bytes_mmx; c->add_bytes_l2= add_bytes_l2_mmx; + c->draw_edges = draw_edges_mmx; + if (ENABLE_ANY_H263) { c->h263_v_loop_filter= h263_v_loop_filter_mmx; c->h263_h_loop_filter= h263_h_loop_filter_mmx; diff --git a/libavcodec/i386/mpegvideo_mmx.c b/libavcodec/i386/mpegvideo_mmx.c index 90b553aa2b..0823fddebc 100644 --- a/libavcodec/i386/mpegvideo_mmx.c +++ b/libavcodec/i386/mpegvideo_mmx.c @@ -475,94 +475,6 @@ asm volatile( ); } -/* draw the edges of width 'w' of an image of size width, height - this mmx version can only handle w==8 || w==16 */ -static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w) -{ - uint8_t *ptr, *last_line; - int i; - - last_line = buf + (height - 1) * wrap; - /* left and right */ - ptr = buf; - if(w==8) - { - asm volatile( - "1: \n\t" - "movd (%0), %%mm0 \n\t" - "punpcklbw %%mm0, %%mm0 \n\t" - "punpcklwd %%mm0, %%mm0 \n\t" - "punpckldq %%mm0, %%mm0 \n\t" - "movq %%mm0, -8(%0) \n\t" - "movq -8(%0, %2), %%mm1 \n\t" - "punpckhbw %%mm1, %%mm1 \n\t" - "punpckhwd %%mm1, %%mm1 \n\t" - "punpckhdq %%mm1, %%mm1 \n\t" - "movq %%mm1, (%0, %2) \n\t" - "add %1, %0 \n\t" - "cmp %3, %0 \n\t" - " jb 1b \n\t" - : "+r" (ptr) - : "r" ((long)wrap), "r" ((long)width), "r" (ptr + wrap*height) - ); - } - else - { - asm volatile( - "1: \n\t" - "movd (%0), %%mm0 \n\t" - "punpcklbw %%mm0, %%mm0 \n\t" - "punpcklwd %%mm0, %%mm0 \n\t" - "punpckldq %%mm0, %%mm0 \n\t" - "movq %%mm0, -8(%0) \n\t" - "movq %%mm0, -16(%0) \n\t" - "movq -8(%0, %2), %%mm1 \n\t" - "punpckhbw %%mm1, %%mm1 \n\t" - "punpckhwd %%mm1, %%mm1 \n\t" - "punpckhdq %%mm1, %%mm1 \n\t" - "movq %%mm1, (%0, %2) \n\t" - "movq %%mm1, 8(%0, %2) \n\t" - "add %1, %0 \n\t" - "cmp %3, %0 \n\t" - " jb 1b \n\t" - : "+r" (ptr) - : "r" ((long)wrap), "r" ((long)width), "r" (ptr + wrap*height) - ); - } - - for(i=0;i<w;i+=4) { - /* top and bottom (and hopefully also the corners) */ - ptr= buf - (i + 1) * wrap - w; - asm volatile( - "1: \n\t" - "movq (%1, %0), %%mm0 \n\t" - "movq %%mm0, (%0) \n\t" - "movq %%mm0, (%0, %2) \n\t" - "movq %%mm0, (%0, %2, 2) \n\t" - "movq %%mm0, (%0, %3) \n\t" - "add $8, %0 \n\t" - "cmp %4, %0 \n\t" - " jb 1b \n\t" - : "+r" (ptr) - : "r" ((long)buf - (long)ptr - w), "r" ((long)-wrap), "r" ((long)-wrap*3), "r" (ptr+width+2*w) - ); - ptr= last_line + (i + 1) * wrap - w; - asm volatile( - "1: \n\t" - "movq (%1, %0), %%mm0 \n\t" - "movq %%mm0, (%0) \n\t" - "movq %%mm0, (%0, %2) \n\t" - "movq %%mm0, (%0, %2, 2) \n\t" - "movq %%mm0, (%0, %3) \n\t" - "add $8, %0 \n\t" - "cmp %4, %0 \n\t" - " jb 1b \n\t" - : "+r" (ptr) - : "r" ((long)last_line - (long)ptr - w), "r" ((long)wrap), "r" ((long)wrap*3), "r" (ptr+width+2*w) - ); - } -} - static void denoise_dct_mmx(MpegEncContext *s, DCTELEM *block){ const int intra= s->mb_intra; int *sum= s->dct_error_sum[intra]; @@ -718,8 +630,6 @@ void MPV_common_init_mmx(MpegEncContext *s) s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx; - draw_edges = draw_edges_mmx; - if (mm_flags & MM_SSE2) { s->denoise_dct= denoise_dct_sse2; } else { diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 76a17d56d5..18b4a57dc2 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -53,14 +53,11 @@ static void dct_unquantize_h263_intra_c(MpegEncContext *s, DCTELEM *block, int n, int qscale); static void dct_unquantize_h263_inter_c(MpegEncContext *s, DCTELEM *block, int n, int qscale); -static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w); extern int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx); extern void XVMC_field_end(MpegEncContext *s); extern void XVMC_decode_mb(MpegEncContext *s); -void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w)= draw_edges_c; - /* enable all paranoid tests for rounding, overflows, etc... */ //#define PARANOID @@ -793,35 +790,6 @@ void init_vlc_rl(RLTable *rl, int use_static) } } -/* draw the edges of width 'w' of an image of size width, height */ -//FIXME check that this is ok for mpeg4 interlaced -static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w) -{ - uint8_t *ptr, *last_line; - int i; - - last_line = buf + (height - 1) * wrap; - for(i=0;i<w;i++) { - /* top and bottom */ - memcpy(buf - (i + 1) * wrap, buf, width); - memcpy(last_line + (i + 1) * wrap, last_line, width); - } - /* left and right */ - ptr = buf; - for(i=0;i<height;i++) { - memset(ptr - w, ptr[0], w); - memset(ptr + width, ptr[width-1], w); - ptr += wrap; - } - /* corners */ - for(i=0;i<w;i++) { - memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */ - memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */ - memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ - memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ - } -} - int ff_find_unused_picture(MpegEncContext *s, int shared){ int i; @@ -1015,9 +983,9 @@ void MPV_frame_end(MpegEncContext *s) }else #endif if(s->unrestricted_mv && s->current_picture.reference && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { - draw_edges(s->current_picture.data[0], s->linesize , s->h_edge_pos , s->v_edge_pos , EDGE_WIDTH ); - draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); - draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); + s->dsp.draw_edges(s->current_picture.data[0], s->linesize , s->h_edge_pos , s->v_edge_pos , EDGE_WIDTH ); + s->dsp.draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); + s->dsp.draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2); } emms_c(); diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 9fcb2d0eaf..81b61ac885 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -4120,9 +4120,9 @@ static int frame_start(SnowContext *s){ int h= s->avctx->height; if(s->current_picture.data[0]){ - draw_edges(s->current_picture.data[0], s->current_picture.linesize[0], w , h , EDGE_WIDTH ); - draw_edges(s->current_picture.data[1], s->current_picture.linesize[1], w>>1, h>>1, EDGE_WIDTH/2); - draw_edges(s->current_picture.data[2], s->current_picture.linesize[2], w>>1, h>>1, EDGE_WIDTH/2); + s->dsp.draw_edges(s->current_picture.data[0], s->current_picture.linesize[0], w , h , EDGE_WIDTH ); + s->dsp.draw_edges(s->current_picture.data[1], s->current_picture.linesize[1], w>>1, h>>1, EDGE_WIDTH/2); + s->dsp.draw_edges(s->current_picture.data[2], s->current_picture.linesize[2], w>>1, h>>1, EDGE_WIDTH/2); } tmp= s->last_picture[s->max_ref_frames-1]; |