~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/i386/dsputil_mmx_avg.h

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * Copyright (c) 2000, 2001 Fabrice Bellard.
4
4
 * Copyright (c) 2002-2004 Michael Niedermayer
5
5
 *
 
6
 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
 
7
 * mostly rewritten by Michael Niedermayer <michaelni@gmx.at>
 
8
 * and improved by Zdenek Kabelac <kabi@users.sf.net>
 
9
 *
6
10
 * This file is part of FFmpeg.
7
11
 *
8
12
 * FFmpeg is free software; you can redistribute it and/or
18
22
 * You should have received a copy of the GNU Lesser General Public
19
23
 * License along with FFmpeg; if not, write to the Free Software
20
24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 
 *
22
 
 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
23
 
 * mostly rewritten by Michael Niedermayer <michaelni@gmx.at>
24
 
 * and improved by Zdenek Kabelac <kabi@users.sf.net>
25
25
 */
26
26
 
 
27
/* This header intentionally has no multiple inclusion guards. It is meant to
 
28
 * be included multiple times and generates different code depending on the
 
29
 * value of certain #defines. */
 
30
 
27
31
/* XXX: we use explicit registers to avoid a gcc 2.95.2 register asm
28
32
   clobber bug - now it will work with 2.95.2 and also with -fPIC
29
33
 */
30
34
static void DEF(put_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
31
35
{
32
 
    __asm __volatile(
 
36
    asm volatile(
33
37
        "lea (%3, %3), %%"REG_a"        \n\t"
34
38
        "1:                             \n\t"
35
39
        "movq (%1), %%mm0               \n\t"
57
61
 
58
62
static void DEF(put_pixels4_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
59
63
{
60
 
    __asm __volatile(
 
64
    asm volatile(
61
65
        "testl $1, %0                   \n\t"
62
66
            " jz 1f                     \n\t"
63
67
        "movd   (%1), %%mm0             \n\t"
96
100
        "add    $16, %2                 \n\t"
97
101
        "subl   $4, %0                  \n\t"
98
102
        "jnz    1b                      \n\t"
99
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
103
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
100
104
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
101
105
#else
102
106
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
108
112
 
109
113
static void DEF(put_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
110
114
{
111
 
    __asm __volatile(
 
115
    asm volatile(
112
116
        "testl $1, %0                   \n\t"
113
117
            " jz 1f                     \n\t"
114
118
        "movq   (%1), %%mm0             \n\t"
143
147
        "add    $32, %2                 \n\t"
144
148
        "subl   $4, %0                  \n\t"
145
149
        "jnz    1b                      \n\t"
146
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
150
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
147
151
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
148
152
#else
149
153
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
158
162
 
159
163
static void DEF(put_no_rnd_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
160
164
{
161
 
    __asm __volatile(
 
165
    asm volatile(
162
166
        "pcmpeqb %%mm6, %%mm6           \n\t"
163
167
        "testl $1, %0                   \n\t"
164
168
            " jz 1f                     \n\t"
213
217
        "add    $32, %2                 \n\t"
214
218
        "subl   $4, %0                  \n\t"
215
219
        "jnz    1b                      \n\t"
216
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
220
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
217
221
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
218
222
#else
219
223
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
228
232
 
229
233
static void DEF(avg_pixels4_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
230
234
{
231
 
    __asm __volatile(
 
235
    asm volatile(
232
236
        "testl $1, %0                   \n\t"
233
237
            " jz 1f                     \n\t"
234
238
        "movd   (%1), %%mm0             \n\t"
268
272
        "add    $16, %2                 \n\t"
269
273
        "subl   $4, %0                  \n\t"
270
274
        "jnz    1b                      \n\t"
271
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
275
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
272
276
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
273
277
#else
274
278
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
280
284
 
281
285
static void DEF(avg_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
282
286
{
283
 
    __asm __volatile(
 
287
    asm volatile(
284
288
        "testl $1, %0                   \n\t"
285
289
            " jz 1f                     \n\t"
286
290
        "movq   (%1), %%mm0             \n\t"
320
324
        "add    $32, %2                 \n\t"
321
325
        "subl   $4, %0                  \n\t"
322
326
        "jnz    1b                      \n\t"
323
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
327
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
324
328
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
325
329
#else
326
330
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
335
339
 
336
340
static void DEF(put_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
337
341
{
338
 
    __asm __volatile(
 
342
    asm volatile(
339
343
        "lea (%3, %3), %%"REG_a"        \n\t"
340
344
        "1:                             \n\t"
341
345
        "movq (%1), %%mm0               \n\t"
375
379
 
376
380
static void DEF(put_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
377
381
{
378
 
    __asm __volatile(
 
382
    asm volatile(
379
383
        "testl $1, %0                   \n\t"
380
384
            " jz 1f                     \n\t"
381
385
        "movq   (%1), %%mm0             \n\t"
408
412
        "add    $32, %2                 \n\t"
409
413
        "subl   $2, %0                  \n\t"
410
414
        "jnz    1b                      \n\t"
411
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
415
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
412
416
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
413
417
#else
414
418
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
423
427
 
424
428
static void DEF(avg_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
425
429
{
426
 
    __asm __volatile(
 
430
    asm volatile(
427
431
        "testl $1, %0                   \n\t"
428
432
            " jz 1f                     \n\t"
429
433
        "movq   (%1), %%mm0             \n\t"
462
466
        "add    $32, %2                 \n\t"
463
467
        "subl   $2, %0                  \n\t"
464
468
        "jnz    1b                      \n\t"
465
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
469
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
466
470
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
467
471
#else
468
472
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
477
481
 
478
482
static void DEF(put_no_rnd_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
479
483
{
480
 
    __asm __volatile(
 
484
    asm volatile(
481
485
        "pcmpeqb %%mm6, %%mm6           \n\t"
482
486
        "testl $1, %0                   \n\t"
483
487
            " jz 1f                     \n\t"
535
539
        "add    $32, %2                 \n\t"
536
540
        "subl   $2, %0                  \n\t"
537
541
        "jnz    1b                      \n\t"
538
 
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
 
542
#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
539
543
        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
540
544
#else
541
545
        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
552
556
static void DEF(put_no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
553
557
{
554
558
    MOVQ_BONE(mm6);
555
 
    __asm __volatile(
 
559
    asm volatile(
556
560
        "lea (%3, %3), %%"REG_a"        \n\t"
557
561
        "1:                             \n\t"
558
562
        "movq (%1), %%mm0               \n\t"
588
592
 
589
593
static void DEF(put_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
590
594
{
591
 
    __asm __volatile(
 
595
    asm volatile(
592
596
        "lea (%3, %3), %%"REG_a"        \n\t"
593
597
        "movq (%1), %%mm0               \n\t"
594
598
        "sub %3, %2                     \n\t"
620
624
static void DEF(put_no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
621
625
{
622
626
    MOVQ_BONE(mm6);
623
 
    __asm __volatile(
 
627
    asm volatile(
624
628
        "lea (%3, %3), %%"REG_a"        \n\t"
625
629
        "movq (%1), %%mm0               \n\t"
626
630
        "sub %3, %2                     \n\t"
652
656
 
653
657
static void DEF(avg_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
654
658
{
655
 
    __asm __volatile(
 
659
    asm volatile(
656
660
        "lea (%3, %3), %%"REG_a"        \n\t"
657
661
        "1:                             \n\t"
658
662
        "movq (%2), %%mm0               \n\t"
680
684
 
681
685
static void DEF(avg_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
682
686
{
683
 
    __asm __volatile(
 
687
    asm volatile(
684
688
        "lea (%3, %3), %%"REG_a"        \n\t"
685
689
        "1:                             \n\t"
686
690
        "movq (%1), %%mm0               \n\t"
712
716
 
713
717
static void DEF(avg_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
714
718
{
715
 
    __asm __volatile(
 
719
    asm volatile(
716
720
        "lea (%3, %3), %%"REG_a"        \n\t"
717
721
        "movq (%1), %%mm0               \n\t"
718
722
        "sub %3, %2                     \n\t"
748
752
        :"%"REG_a, "memory");
749
753
}
750
754
 
751
 
// Note this is not correctly rounded, but this function is only used for b frames so it doesnt matter
 
755
/* Note this is not correctly rounded, but this function is only
 
756
 * used for B-frames so it does not matter. */
752
757
static void DEF(avg_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
753
758
{
754
759
    MOVQ_BONE(mm6);
755
 
    __asm __volatile(
 
760
    asm volatile(
756
761
        "lea (%3, %3), %%"REG_a"        \n\t"
757
762
        "movq (%1), %%mm0               \n\t"
758
763
        PAVGB" 1(%1), %%mm0             \n\t"
790
795
        :"%"REG_a,  "memory");
791
796
}
792
797
 
 
798
static void DEF(avg_pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
 
799
{
 
800
    do {
 
801
        asm volatile(
 
802
            "movd (%1), %%mm0               \n\t"
 
803
            "movd (%1, %2), %%mm1           \n\t"
 
804
            "movd (%1, %2, 2), %%mm2        \n\t"
 
805
            "movd (%1, %3), %%mm3           \n\t"
 
806
            PAVGB" (%0), %%mm0              \n\t"
 
807
            PAVGB" (%0, %2), %%mm1          \n\t"
 
808
            PAVGB" (%0, %2, 2), %%mm2       \n\t"
 
809
            PAVGB" (%0, %3), %%mm3          \n\t"
 
810
            "movd %%mm0, (%1)               \n\t"
 
811
            "movd %%mm1, (%1, %2)           \n\t"
 
812
            "movd %%mm2, (%1, %2, 2)        \n\t"
 
813
            "movd %%mm3, (%1, %3)           \n\t"
 
814
            ::"S"(pixels), "D"(block),
 
815
             "r" ((long)line_size), "r"(3L*line_size)
 
816
            :"memory");
 
817
        block += 4*line_size;
 
818
        pixels += 4*line_size;
 
819
        h -= 4;
 
820
    } while(h > 0);
 
821
}
 
822
 
793
823
//FIXME the following could be optimized too ...
794
824
static void DEF(put_no_rnd_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
795
825
    DEF(put_no_rnd_pixels8_x2)(block  , pixels  , line_size, h);