Revision 3d9fccbf

View differences:

libavcodec/i386/mpegvideo_mmx.c
24 24
#include "../mpegvideo.h"
25 25

  
26 26
extern UINT8 zigzag_end[64];
27
extern void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w);
27 28

  
28 29
#if 0
29 30

  
......
322 323
    }
323 324
}
324 325

  
326
/* draw the edges of width 'w' of an image of size width, height 
327
   this mmx version can only handle w==8 || w==16 */
328
static void draw_edges_mmx(UINT8 *buf, int wrap, int width, int height, int w)
329
{
330
    UINT8 *ptr, *last_line;
331
    int i;
332

  
333
    last_line = buf + (height - 1) * wrap;
334
    /* left and right */
335
    ptr = buf;
336
    if(w==8)
337
    {
338
	asm volatile(
339
		"1:				\n\t"
340
		"movd (%0), %%mm0		\n\t"
341
		"punpcklbw %%mm0, %%mm0		\n\t" 
342
		"punpcklwd %%mm0, %%mm0		\n\t"
343
		"punpckldq %%mm0, %%mm0		\n\t"
344
		"movq %%mm0, -8(%0)		\n\t"
345
		"movq -8(%0, %2), %%mm1		\n\t"
346
		"punpckhbw %%mm1, %%mm1		\n\t"
347
		"punpckhwd %%mm1, %%mm1		\n\t"
348
		"punpckhdq %%mm1, %%mm1		\n\t"
349
		"movq %%mm1, (%0, %2)		\n\t"
350
		"addl %1, %0			\n\t"
351
		"cmpl %3, %0			\n\t"
352
		" jb 1b				\n\t"
353
		: "+r" (ptr)
354
		: "r" (wrap), "r" (width), "r" (ptr + wrap*height)
355
	);
356
    }
357
    else
358
    {
359
	asm volatile(
360
		"1:				\n\t"
361
		"movd (%0), %%mm0		\n\t"
362
		"punpcklbw %%mm0, %%mm0		\n\t" 
363
		"punpcklwd %%mm0, %%mm0		\n\t"
364
		"punpckldq %%mm0, %%mm0		\n\t"
365
		"movq %%mm0, -8(%0)		\n\t"
366
		"movq %%mm0, -16(%0)		\n\t"
367
		"movq -8(%0, %2), %%mm1		\n\t"
368
		"punpckhbw %%mm1, %%mm1		\n\t"
369
		"punpckhwd %%mm1, %%mm1		\n\t"
370
		"punpckhdq %%mm1, %%mm1		\n\t"
371
		"movq %%mm1, (%0, %2)		\n\t"
372
		"movq %%mm1, 8(%0, %2)		\n\t"
373
		"addl %1, %0			\n\t"
374
		"cmpl %3, %0			\n\t"
375
		" jb 1b				\n\t"		
376
		: "+r" (ptr)
377
		: "r" (wrap), "r" (width), "r" (ptr + wrap*height)
378
	);
379
    }
380
    
381
    for(i=0;i<w;i+=4) {
382
        /* top and bottom (and hopefully also the corners) */
383
	ptr= buf - (i + 1) * wrap - w;
384
	asm volatile(
385
		"1:				\n\t"
386
		"movq (%1, %0), %%mm0		\n\t"
387
		"movq %%mm0, (%0)		\n\t"
388
		"movq %%mm0, (%0, %2)		\n\t"
389
		"movq %%mm0, (%0, %2, 2)	\n\t"
390
		"movq %%mm0, (%0, %3)		\n\t"
391
		"addl $8, %0			\n\t"
392
		"cmpl %4, %0			\n\t"
393
		" jb 1b				\n\t"
394
		: "+r" (ptr)
395
		: "r" ((int)buf - (int)ptr - w), "r" (-wrap), "r" (-wrap*3), "r" (ptr+width+2*w)
396
	);
397
	ptr= last_line + (i + 1) * wrap - w;
398
	asm volatile(
399
		"1:				\n\t"
400
		"movq (%1, %0), %%mm0		\n\t"
401
		"movq %%mm0, (%0)		\n\t"
402
		"movq %%mm0, (%0, %2)		\n\t"
403
		"movq %%mm0, (%0, %2, 2)	\n\t"
404
		"movq %%mm0, (%0, %3)		\n\t"
405
		"addl $8, %0			\n\t"
406
		"cmpl %4, %0			\n\t"
407
		" jb 1b				\n\t"
408
		: "+r" (ptr)
409
		: "r" ((int)last_line - (int)ptr - w), "r" (wrap), "r" (wrap*3), "r" (ptr+width+2*w)
410
	);
411
    }
412
}
413

  
414

  
325 415
void MPV_common_init_mmx(MpegEncContext *s)
326 416
{
327 417
    if (mm_flags & MM_MMX) {
......
329 419
        	s->dct_unquantize = dct_unquantize_h263_mmx;
330 420
	else
331 421
        	s->dct_unquantize = dct_unquantize_mpeg1_mmx;
422
	
423
	draw_edges = draw_edges_mmx;
332 424
    }
333 425
}
libavcodec/mpegvideo.c
39 39
static int dct_quantize_mmx(MpegEncContext *s, 
40 40
                            DCTELEM *block, int n,
41 41
                            int qscale);
42
static void draw_edges_c(UINT8 *buf, int wrap, int width, int height, int w);
43

  
44
void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w)= draw_edges_c;
45

  
42 46
#define EDGE_WIDTH 16
43 47

  
44 48
/* enable all paranoid tests for rounding, overflows, etc... */
......
361 365
}
362 366

  
363 367
/* draw the edges of width 'w' of an image of size width, height */
364
static void draw_edges(UINT8 *buf, int wrap, int width, int height, int w)
368
static void draw_edges_c(UINT8 *buf, int wrap, int width, int height, int w)
365 369
{
366 370
    UINT8 *ptr, *last_line;
367 371
    int i;
......
676 680
{
677 681
    if (s->block_last_index[i] >= 0) {
678 682
        if (!s->mpeg2)
679
            if(s->encoding || s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MSMPEG4)
683
            if(s->encoding || (!s->h263_msmpeg4))
680 684
                s->dct_unquantize(s, block, i, s->qscale);
681 685
        ff_idct (block);
682 686
        add_pixels_clamped(block, dest, line_size);

Also available in: Unified diff