Ticket #1073: trunk.diff

File trunk.diff, 45.1 KB (added by eternalsword@…, 18 years ago)

diff between mplayer libmpeg2 and svn://svn.videolan.org/libmpeg2/trunk

  • libmpeg2/alloc.c

    diff -u /build/mplayer/libmpeg2/alloc.c /build/libmpeg2/libmpeg2/alloc.c
    old new  
    6262        free (*(((void **)buf) - 1));
    6363}
    6464
    65 void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
    66                          int free (void *))
     65void mpeg2_malloc_hooks (void * alloc_func (unsigned, mpeg2_alloc_t),
     66                         int free_func (void *))
    6767{
    68     malloc_hook = malloc;
    69     free_hook = free;
     68    malloc_hook = alloc_func;
     69    free_hook = free_func;
    7070}
  • libmpeg2/cpu_accel.c

    Only in /build/mplayer/libmpeg2: alpha_asm.h
    Only in /build/mplayer/libmpeg2: attributes.h
    Only in /build/libmpeg2/libmpeg2: configure.incl
    Only in /build/libmpeg2/libmpeg2: convert
    diff -u /build/mplayer/libmpeg2/cpu_accel.c /build/libmpeg2/libmpeg2/cpu_accel.c
    old new  
    11/*
    22 * cpu_accel.c
    3  * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
     3 * Copyright (C) 2000-2004 Michel Lespinasse <walken@zoy.org>
    44 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
    55 *
    66 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
     
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: cpu_accel.c 26315 2008-04-01 17:41:18Z diego $
    2622 */
    2723
    2824#include "config.h"
    29 #include "cpudetect.h"
    3025
    3126#include <inttypes.h>
    3227
     
    3429#include "attributes.h"
    3530#include "mpeg2_internal.h"
    3631
    37 #ifdef ACCEL_DETECT
    3832#if defined(ARCH_X86) || defined(ARCH_X86_64)
    39 
    40 /* MPlayer imports libmpeg2 as decoder, which detects MMX / 3DNow!
    41  * instructions via assembly. However, it is regarded as duplicated work
    42  * in MPlayer, so that we enforce using MPlayer's implementation.
    43  */
    44 #define USE_MPLAYER_CPUDETECT
    45 
    46 static inline uint32_t arch_accel (void)
     33static inline uint32_t arch_accel (uint32_t accel)
    4734{
    48 #if !defined(USE_MPLAYER_CPUDETECT)
    49     uint32_t eax, ebx, ecx, edx;
    50     int AMD;
    51     uint32_t caps;
     35    if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
     36        accel |= MPEG2_ACCEL_X86_MMX;
     37       
     38    if (accel & (MPEG2_ACCEL_X86_SSE2 | MPEG2_ACCEL_X86_SSE3))
     39        accel |= MPEG2_ACCEL_X86_MMXEXT;
     40       
     41    if (accel & (MPEG2_ACCEL_X86_SSE3))
     42        accel |= MPEG2_ACCEL_X86_SSE2;
     43
     44#ifdef ACCEL_DETECT
     45    if (accel & MPEG2_ACCEL_DETECT) {
     46        uint32_t eax, ebx, ecx, edx;
     47        int AMD;
    5248
    5349#if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__))
    5450#define cpuid(op,eax,ebx,ecx,edx)       \
     
    5955               "=d" (edx)               \
    6056             : "a" (op)                 \
    6157             : "cc")
    62 #else  /* PIC version : save ebx (not needed on x86_64) */
     58#else   /* PIC version : save ebx (not needed on x86_64) */
    6359#define cpuid(op,eax,ebx,ecx,edx)       \
    6460    __asm__ ("pushl %%ebx\n\t"          \
    6561             "cpuid\n\t"                \
     
    7470#endif
    7571
    7672#ifndef __x86_64__ /* x86_64 supports the cpuid op */
    77     __asm__ ("pushf\n\t"
    78             "pushf\n\t"
    79             "pop %0\n\t"
    80             "movl %0,%1\n\t"
    81             "xorl $0x200000,%0\n\t"
    82             "push %0\n\t"
    83             "popf\n\t"
    84             "pushf\n\t"
    85             "pop %0\n\t"
    86             "popf"
    87             : "=r" (eax),
    88               "=r" (ebx)
    89             :
    90             : "cc");
     73        __asm__ ("pushf\n\t"
     74                "pushf\n\t"
     75                "pop %0\n\t"
     76                "movl %0,%1\n\t"
     77                "xorl $0x200000,%0\n\t"
     78                "push %0\n\t"
     79                "popf\n\t"
     80                "pushf\n\t"
     81                "pop %0\n\t"
     82                "popf"
     83                : "=r" (eax),
     84                "=r" (ebx)
     85                :
     86                : "cc");
    9187
    92     if (eax == ebx)             /* no cpuid */
    93         return 0;
     88        if (eax == ebx)                 /* no cpuid */
     89            return accel;
    9490#endif
    9591
    96     cpuid (0x00000000, eax, ebx, ecx, edx);
    97     if (!eax)                   /* vendor string only */
    98         return 0;
    99 
    100     AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
    101 
    102     cpuid (0x00000001, eax, ebx, ecx, edx);
    103     if (! (edx & 0x00800000))   /* no MMX */
    104         return 0;
    105 
    106     caps = MPEG2_ACCEL_X86_MMX;
    107     if (edx & 0x02000000)       /* SSE - identical to AMD MMX extensions */
    108         caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
    109 
    110     cpuid (0x80000000, eax, ebx, ecx, edx);
    111     if (eax < 0x80000001)       /* no extended capabilities */
    112         return caps;
    113 
    114     cpuid (0x80000001, eax, ebx, ecx, edx);
    115 
    116     if (edx & 0x80000000)
    117         caps |= MPEG2_ACCEL_X86_3DNOW;
    118 
    119     if (AMD && (edx & 0x00400000))      /* AMD MMX extensions */
    120         caps |= MPEG2_ACCEL_X86_MMXEXT;
    121 
    122     return caps;
    123 #else /* USE_MPLAYER_CPUDETECT: Use MPlayer's CPU capability property. */
    124     caps = 0;
    125     if (gCpuCaps.hasMMX)
    126         caps |= MPEG2_ACCEL_X86_MMX;
    127     if (gCpuCaps.hasSSE2)
    128         caps |= MPEG2_ACCEL_X86_SSE2;
    129     if (gCpuCaps.hasMMX2)
    130         caps |= MPEG2_ACCEL_X86_MMXEXT;
    131     if (gCpuCaps.has3DNow)
    132         caps |= MPEG2_ACCEL_X86_3DNOW;
     92        cpuid (0x00000000, eax, ebx, ecx, edx);
     93        if (!eax)                       /* vendor string only */
     94            return accel;
     95
     96        AMD = (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65);
     97
     98        cpuid (0x00000001, eax, ebx, ecx, edx);
     99        if (! (edx & 0x00800000))       /* no MMX */
     100            return accel;
     101
     102        accel |= MPEG2_ACCEL_X86_MMX;
     103        if (edx & 0x02000000)           /* SSE - identical to AMD MMX ext. */
     104            accel |= MPEG2_ACCEL_X86_MMXEXT;
     105
     106        if (edx & 0x04000000)           /* SSE2 */
     107            accel |= MPEG2_ACCEL_X86_SSE2;
     108
     109        if (ecx & 0x00000001)           /* SSE3 */
     110            accel |= MPEG2_ACCEL_X86_SSE3;
     111
     112        cpuid (0x80000000, eax, ebx, ecx, edx);
     113        if (eax < 0x80000001)           /* no extended capabilities */
     114            return accel;
    133115
    134     return caps;
     116        cpuid (0x80000001, eax, ebx, ecx, edx);
    135117
    136 #endif /* USE_MPLAYER_CPUDETECT */
     118        if (edx & 0x80000000)
     119            accel |= MPEG2_ACCEL_X86_3DNOW;
     120
     121        if (AMD && (edx & 0x00400000))  /* AMD MMX extensions */
     122            accel |= MPEG2_ACCEL_X86_MMXEXT;
     123    }
     124#endif /* ACCEL_DETECT */
     125
     126    return accel;
    137127}
    138128#endif /* ARCH_X86 || ARCH_X86_64 */
    139129
    140 #if defined(ARCH_PPC) || defined(ARCH_SPARC)
     130#if defined(ACCEL_DETECT) && (defined(ARCH_PPC) || defined(ARCH_SPARC))
    141131#include <signal.h>
    142132#include <setjmp.h>
    143133
     
    154144    canjump = 0;
    155145    siglongjmp (jmpbuf, 1);
    156146}
     147#endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */
    157148
    158149#ifdef ARCH_PPC
    159 static uint32_t arch_accel (void)
     150static uint32_t arch_accel (uint32_t accel)
    160151{
    161     static RETSIGTYPE (* oldsig) (int);
    162 
    163     oldsig = signal (SIGILL, sigill_handler);
    164     if (sigsetjmp (jmpbuf, 1)) {
    165         signal (SIGILL, oldsig);
    166         return 0;
    167     }
     152#ifdef ACCEL_DETECT
     153    if ((accel & (MPEG2_ACCEL_PPC_ALTIVEC | MPEG2_ACCEL_DETECT)) ==
     154        MPEG2_ACCEL_DETECT) {
     155        static RETSIGTYPE (* oldsig) (int);
     156
     157        oldsig = signal (SIGILL, sigill_handler);
     158        if (sigsetjmp (jmpbuf, 1)) {
     159            signal (SIGILL, oldsig);
     160            return accel;
     161        }
    168162
    169     canjump = 1;
     163        canjump = 1;
    170164
    171165#if defined(__APPLE_CC__)       /* apple */
    172166#define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
    173 #else                   /* gnu */
     167#else                           /* gnu */
    174168#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
    175169#endif
    176     asm volatile ("mtspr 256, %0\n\t"
    177                   VAND (0, 0, 0)
    178                   :
    179                   : "r" (-1));
     170        asm volatile ("mtspr 256, %0\n\t"
     171                      VAND (0, 0, 0)
     172                      :
     173                      : "r" (-1));
    180174
    181     canjump = 0;
     175        canjump = 0;
     176        accel |= MPEG2_ACCEL_PPC_ALTIVEC;
    182177
    183     signal (SIGILL, oldsig);
    184     return MPEG2_ACCEL_PPC_ALTIVEC;
     178        signal (SIGILL, oldsig);
     179    }
     180#endif /* ACCEL_DETECT */
     181
     182    return accel;
    185183}
    186184#endif /* ARCH_PPC */
    187185
    188186#ifdef ARCH_SPARC
    189 static uint32_t arch_accel (void)
     187static uint32_t arch_accel (uint32_t accel)
    190188{
    191     static RETSIGTYPE (* oldsig) (int);
     189    if (accel & MPEG2_ACCEL_SPARC_VIS2)
     190        accel |= MPEG2_ACCEL_SPARC_VIS;
    192191
    193     oldsig = signal (SIGILL, sigill_handler);
    194     if (sigsetjmp (jmpbuf, 1)) {
    195         signal (SIGILL, oldsig);
    196         return 0;
    197     }
     192#ifdef ACCEL_DETECT
     193    if ((accel & (MPEG2_ACCEL_SPARC_VIS2 | MPEG2_ACCEL_DETECT)) ==
     194        MPEG2_ACCEL_DETECT) {
     195        static RETSIGTYPE (* oldsig) (int);
    198196
    199     canjump = 1;
     197        oldsig = signal (SIGILL, sigill_handler);
     198        if (sigsetjmp (jmpbuf, 1)) {
     199            signal (SIGILL, oldsig);
     200            return accel;
     201        }
    200202
    201     /* pdist %f0, %f0, %f0 */
    202     __asm__ __volatile__(".word\t0x81b007c0");
     203        canjump = 1;
    203204
    204     canjump = 0;
     205        /* pdist %f0, %f0, %f0 */
     206        __asm__ __volatile__(".word\t0x81b007c0");
    205207
    206     if (sigsetjmp (jmpbuf, 1)) {
    207         signal (SIGILL, oldsig);
    208         return MPEG2_ACCEL_SPARC_VIS;
    209     }
     208        canjump = 0;
     209        accel |= MPEG2_ACCEL_SPARC_VIS;
    210210
    211     canjump = 1;
     211        if (sigsetjmp (jmpbuf, 1)) {
     212            signal (SIGILL, oldsig);
     213            return accel;
     214        }
    212215
    213     /* edge8n %g0, %g0, %g0 */
    214     __asm__ __volatile__(".word\t0x81b00020");
     216        canjump = 1;
    215217
    216     canjump = 0;
     218        /* edge8n %g0, %g0, %g0 */
     219        __asm__ __volatile__(".word\t0x81b00020");
     220
     221        canjump = 0;
     222        accel |= MPEG2_ACCEL_SPARC_VIS2;
    217223
    218     signal (SIGILL, oldsig);
    219     return MPEG2_ACCEL_SPARC_VIS | MPEG2_ACCEL_SPARC_VIS2;
     224        signal (SIGILL, oldsig);
     225    }
     226#endif /* ACCEL_DETECT */
     227
     228    return accel;
    220229}
    221230#endif /* ARCH_SPARC */
    222 #endif /* ARCH_PPC || ARCH_SPARC */
    223231
    224232#ifdef ARCH_ALPHA
    225 static uint32_t arch_accel (void)
     233static inline uint32_t arch_accel (uint32_t accel)
    226234{
    227     uint64_t no_mvi;
     235    if (accel & MPEG2_ACCEL_ALPHA_MVI)
     236        accel |= MPEG2_ACCEL_ALPHA;
     237
     238#ifdef ACCEL_DETECT
     239    if (accel & MPEG2_ACCEL_DETECT) {
     240        uint64_t no_mvi;
     241
     242        asm volatile ("amask %1, %0"
     243                      : "=r" (no_mvi)
     244                      : "rI" (256));    /* AMASK_MVI */
     245        accel |= no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
     246                                               MPEG2_ACCEL_ALPHA_MVI);
     247    }
     248#endif /* ACCEL_DETECT */
    228249
    229     asm volatile ("amask %1, %0"
    230                   : "=r" (no_mvi)
    231                   : "rI" (256));        /* AMASK_MVI */
    232     return no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
    233                                          MPEG2_ACCEL_ALPHA_MVI);
     250    return accel;
    234251}
    235252#endif /* ARCH_ALPHA */
    236 #endif /* ACCEL_DETECT */
    237253
    238 uint32_t mpeg2_detect_accel (void)
     254uint32_t mpeg2_detect_accel (uint32_t accel)
    239255{
    240     uint32_t accel;
    241 
    242     accel = 0;
    243 #ifdef ACCEL_DETECT
    244256#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
    245     accel = arch_accel ();
    246 #endif
     257    accel = arch_accel (accel);
    247258#endif
    248259    return accel;
    249260}
  • libmpeg2/cpu_state.c

    diff -u /build/mplayer/libmpeg2/cpu_state.c /build/libmpeg2/libmpeg2/cpu_state.c
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: cpu_state.c 26627 2008-05-01 12:45:59Z diego $
    2622 */
    2723
    2824#include "config.h"
     
    5450#define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t"
    5551#define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t"
    5652#define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t"
    57 #else                   /* gnu */
     53#else                           /* gnu */
    5854#define LI(a,b) "li " #a "," #b "\n\t"
    5955#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
    6056#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
  • libmpeg2/decode.c

    diff -u /build/mplayer/libmpeg2/decode.c /build/libmpeg2/libmpeg2/decode.c
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: decode.c 21542 2006-12-09 10:34:27Z henry $
    2622 */
    2723
    2824#include "config.h"
     
    135131    }
    136132    mpeg2dec->bytes_since_tag += skipped;
    137133    mpeg2dec->code = mpeg2dec->buf_start[-1];
    138     return (mpeg2_state_t)-1;
     134    return STATE_INTERNAL_NORETURN;
    139135}
    140136
    141137mpeg2_state_t mpeg2_seek_header (mpeg2dec_t * mpeg2dec)
    142138{
    143     while (mpeg2dec->code != 0xb3 &&
    144            ((mpeg2dec->code != 0xb7 && mpeg2dec->code != 0xb8 &&
    145              mpeg2dec->code) || mpeg2dec->sequence.width == (unsigned)-1))
     139    while (!(mpeg2dec->code == 0xb3 ||
     140             ((mpeg2dec->code == 0xb7 || mpeg2dec->code == 0xb8 ||
     141               !mpeg2dec->code) && mpeg2dec->sequence.width != (unsigned)-1)))
    146142        if (seek_chunk (mpeg2dec) == STATE_BUFFER)
    147143            return STATE_BUFFER;
    148144    mpeg2dec->chunk_start = mpeg2dec->chunk_ptr = mpeg2dec->chunk_buffer;
    149145    mpeg2dec->user_data_len = 0;
    150     return (mpeg2dec->code ? mpeg2_parse_header (mpeg2dec) :
    151             mpeg2_header_picture_start (mpeg2dec));
     146    return ((mpeg2dec->code == 0xb7) ?
     147            mpeg2_header_end (mpeg2dec) : mpeg2_parse_header (mpeg2dec));
    152148}
    153149
    154150#define RECEIVED(code,state) (((state) << 8) + (code))
     
    161157        mpeg2_state_t state;
    162158
    163159        state = mpeg2dec->action (mpeg2dec);
    164         if ((int)state >= 0)
     160        if ((int)state > (int)STATE_INTERNAL_NORETURN)
    165161            return state;
    166162    }
    167163
     
    200196            return STATE_BUFFER;
    201197    }
    202198
     199    mpeg2dec->action = mpeg2_seek_header;
    203200    switch (mpeg2dec->code) {
    204201    case 0x00:
    205         mpeg2dec->action = mpeg2_header_picture_start;
    206202        return mpeg2dec->state;
    207     case 0xb7:
    208         mpeg2dec->action = mpeg2_header_end;
    209         break;
    210203    case 0xb3:
     204    case 0xb7:
    211205    case 0xb8:
    212         mpeg2dec->action = mpeg2_parse_header;
    213         break;
     206        return (mpeg2dec->state == STATE_SLICE) ? STATE_SLICE : STATE_INVALID;
    214207    default:
    215208        mpeg2dec->action = seek_chunk;
    216209        return STATE_INVALID;
    217210    }
    218     return (mpeg2dec->state == STATE_SLICE) ? STATE_SLICE : STATE_INVALID;
    219211}
    220212
    221213mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec)
     
    262254
    263255        /* state transition after a sequence header */
    264256        case RECEIVED (0x00, STATE_SEQUENCE):
    265             mpeg2dec->action = mpeg2_header_picture_start;
    266257        case RECEIVED (0xb8, STATE_SEQUENCE):
    267258            mpeg2_header_sequence_finalize (mpeg2dec);
    268259            break;
     
    270261        /* other legal state transitions */
    271262        case RECEIVED (0x00, STATE_GOP):
    272263            mpeg2_header_gop_finalize (mpeg2dec);
    273             mpeg2dec->action = mpeg2_header_picture_start;
    274264            break;
    275265        case RECEIVED (0x01, STATE_PICTURE):
    276266        case RECEIVED (0x01, STATE_PICTURE_2ND):
     
    355345    fbuf->buf[1] = buf[1];
    356346    fbuf->buf[2] = buf[2];
    357347    fbuf->id = id;
    358     // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
    359     if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
    360         mpeg2dec->fbuf[1]->buf[0]=buf[0];
    361         mpeg2dec->fbuf[1]->buf[1]=buf[1];
    362         mpeg2dec->fbuf[1]->buf[2]=buf[2];
    363         mpeg2dec->fbuf[1]->id=NULL;
    364     }
    365 //        printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
    366 //          mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
    367348}
    368349
    369350void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
     
    398379uint32_t mpeg2_accel (uint32_t accel)
    399380{
    400381    if (!mpeg2_accels) {
    401         if (accel & MPEG2_ACCEL_DETECT)
    402             accel |= mpeg2_detect_accel ();
    403         mpeg2_accels = accel |= MPEG2_ACCEL_DETECT;
    404         mpeg2_cpu_state_init (accel);
    405         mpeg2_idct_init (accel);
    406         mpeg2_mc_init (accel);
     382        mpeg2_accels = mpeg2_detect_accel (accel) | MPEG2_ACCEL_DETECT;
     383        mpeg2_cpu_state_init (mpeg2_accels);
     384        mpeg2_idct_init (mpeg2_accels);
     385        mpeg2_mc_init (mpeg2_accels);
    407386    }
    408387    return mpeg2_accels & ~MPEG2_ACCEL_DETECT;
    409388}
  • libmpeg2/header.c

    diff -u /build/mplayer/libmpeg2/header.c /build/libmpeg2/libmpeg2/header.c
    old new  
    2020 * You should have received a copy of the GNU General Public License
    2121 * along with this program; if not, write to the Free Software
    2222 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23  *
    24  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    25  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    26  * $Id: header.c 21542 2006-12-09 10:34:27Z henry $
    2723 */
    2824
    2925#include "config.h"
     
    104100    mpeg2dec->decoder.convert = NULL;
    105101    mpeg2dec->decoder.convert_id = NULL;
    106102    mpeg2dec->picture = mpeg2dec->pictures;
    107     memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
    108     memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
    109     memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
    110103    mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
    111104    mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
    112105    mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
     
    257250{
    258251    uint8_t * buffer = mpeg2dec->chunk_start;
    259252    mpeg2_sequence_t * sequence = &(mpeg2dec->new_sequence);
    260     uint32_t flags;
    261253
    262     flags = ((sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) |
    263              ((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT));
     254    sequence->flags = ((sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) |
     255                       ((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT));
    264256    if (buffer[0] & 1) {
    265         flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
     257        sequence->flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
    266258        sequence->colour_primaries = buffer[1];
    267259        sequence->transfer_characteristics = buffer[2];
    268260        sequence->matrix_coefficients = buffer[3];
     
    281273    return 0;
    282274}
    283275
     276static inline void simplify (unsigned int * u, unsigned int * v)
     277{
     278    unsigned int a, b, tmp;
     279
     280    a = *u;     b = *v;
     281    while (a) { /* find greatest common divisor */
     282        tmp = a;        a = b % tmp;    b = tmp;
     283    }
     284    *u /= b;    *v /= b;
     285}
     286
    284287static inline void finalize_sequence (mpeg2_sequence_t * sequence)
    285288{
    286289    int width;
     
    317320            sequence->pixel_width = 64; sequence->pixel_height = 45;    return;
    318321        case 6: /* 720x480 16:9 */
    319322            sequence->pixel_width = 32; sequence->pixel_height = 27;    return;
    320         case 12:        /* 720*480 4:3 */
    321             sequence->pixel_width = 8;  sequence->pixel_height = 9;     return;
     323        case 8: /* BT.601 625 lines 4:3 */
     324            sequence->pixel_width = 59; sequence->pixel_height = 54;    return;
     325        case 12: /* BT.601 525 lines 4:3 */
     326            sequence->pixel_width = 10; sequence->pixel_height = 11;    return;
    322327        default:
    323328            height = 88 * sequence->pixel_width + 1171;
    324329            width = 2000;
     
    327332
    328333    sequence->pixel_width = width;
    329334    sequence->pixel_height = height;
    330     while (width) {     /* find greatest common divisor */
    331         int tmp = width;
    332         width = height % tmp;
    333         height = tmp;
    334     }
    335     sequence->pixel_width /= height;
    336     sequence->pixel_height /= height;
    337 }
    338 
    339 static void copy_matrix (mpeg2dec_t * mpeg2dec, int index)
    340 {
    341     if (memcmp (mpeg2dec->quantizer_matrix[index],
    342                 mpeg2dec->new_quantizer_matrix[index], 64)) {
    343         memcpy (mpeg2dec->quantizer_matrix[index],
    344                 mpeg2dec->new_quantizer_matrix[index], 64);
    345         mpeg2dec->scaled[index] = -1;
     335    simplify (&sequence->pixel_width, &sequence->pixel_height);
     336}
     337
     338int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence,
     339                        unsigned int * pixel_width,
     340                        unsigned int * pixel_height)
     341{
     342    static struct {
     343        unsigned int width, height;
     344    } video_modes[] = {
     345        {720, 576}, /* 625 lines, 13.5 MHz (D1, DV, DVB, DVD) */
     346        {704, 576}, /* 625 lines, 13.5 MHz (1/1 D1, DVB, DVD, 4CIF) */
     347        {544, 576}, /* 625 lines, 10.125 MHz (DVB, laserdisc) */
     348        {528, 576}, /* 625 lines, 10.125 MHz (3/4 D1, DVB, laserdisc) */
     349        {480, 576}, /* 625 lines, 9 MHz (2/3 D1, DVB, SVCD) */
     350        {352, 576}, /* 625 lines, 6.75 MHz (D2, 1/2 D1, CVD, DVB, DVD) */
     351        {352, 288}, /* 625 lines, 6.75 MHz, 1 field (D4, VCD, DVB, DVD, CIF) */
     352        {176, 144}, /* 625 lines, 3.375 MHz, half field (QCIF) */
     353        {720, 486}, /* 525 lines, 13.5 MHz (D1) */
     354        {704, 486}, /* 525 lines, 13.5 MHz */
     355        {720, 480}, /* 525 lines, 13.5 MHz (DV, DSS, DVD) */
     356        {704, 480}, /* 525 lines, 13.5 MHz (1/1 D1, ATSC, DVD) */
     357        {544, 480}, /* 525 lines. 10.125 MHz (DSS, laserdisc) */
     358        {528, 480}, /* 525 lines. 10.125 MHz (3/4 D1, laserdisc) */
     359        {480, 480}, /* 525 lines, 9 MHz (2/3 D1, SVCD) */
     360        {352, 480}, /* 525 lines, 6.75 MHz (D2, 1/2 D1, CVD, DVD) */
     361        {352, 240}  /* 525  lines. 6.75 MHz, 1 field (D4, VCD, DSS, DVD) */
     362    };
     363    unsigned int width, height, pix_width, pix_height, i, DAR_16_9;
     364
     365    *pixel_width = sequence->pixel_width;
     366    *pixel_height = sequence->pixel_height;
     367    width = sequence->picture_width;
     368    height = sequence->picture_height;
     369    for (i = 0; i < sizeof (video_modes) / sizeof (video_modes[0]); i++)
     370        if (width == video_modes[i].width && height == video_modes[i].height)
     371            break;
     372    if (i == sizeof (video_modes) / sizeof (video_modes[0]) ||
     373        (sequence->pixel_width == 1 && sequence->pixel_height == 1) ||
     374        width != sequence->display_width || height != sequence->display_height)
     375        return 0;
     376
     377    for (pix_height = 1; height * pix_height < 480; pix_height <<= 1);
     378    height *= pix_height;
     379    for (pix_width = 1; width * pix_width <= 352; pix_width <<= 1);
     380    width *= pix_width;
     381
     382    if (! (sequence->flags & SEQ_FLAG_MPEG2)) {
     383        static unsigned int mpeg1_check[2][2] = {{11, 54}, {27, 45}};
     384        DAR_16_9 = (sequence->pixel_height == 27 ||
     385                    sequence->pixel_height == 45);
     386        if (width < 704 ||
     387            sequence->pixel_height != mpeg1_check[DAR_16_9][height == 576])
     388            return 0;
     389    } else {
     390        DAR_16_9 = (3 * sequence->picture_width * sequence->pixel_width >
     391                    4 * sequence->picture_height * sequence->pixel_height);
     392        switch (width) {
     393        case 528: case 544:     pix_width *= 4; pix_height *= 3; break;
     394        case 480:               pix_width *= 3; pix_height *= 2; break;
     395        }
     396    }
     397    if (DAR_16_9) {
     398        pix_width *= 4; pix_height *= 3;
     399    }
     400    if (height == 576) {
     401        pix_width *= 59; pix_height *= 54;
     402    } else {
     403        pix_width *= 10; pix_height *= 11;
     404    }
     405    *pixel_width = pix_width;
     406    *pixel_height = pix_height;
     407    simplify (pixel_width, pixel_height);
     408    return (height == 576) ? 1 : 2;
     409}
     410
     411static void copy_matrix (mpeg2dec_t * mpeg2dec, int idx)
     412{
     413    if (memcmp (mpeg2dec->quantizer_matrix[idx],
     414                mpeg2dec->new_quantizer_matrix[idx], 64)) {
     415        memcpy (mpeg2dec->quantizer_matrix[idx],
     416                mpeg2dec->new_quantizer_matrix[idx], 64);
     417        mpeg2dec->scaled[idx] = -1;
    346418    }
    347419}
    348420
     
    392464                              (sequence->chroma_height == sequence->height));
    393465
    394466    if (mpeg2dec->sequence.width != (unsigned)-1) {
    395         unsigned int new_byte_rate;
    396 
    397467        /*
    398468         * According to 6.1.1.6, repeat sequence headers should be
    399          * identical to the original. However some DVDs dont respect
    400          * that and have different bitrates in the repeat sequence
    401          * headers. So we'll ignore that in the comparison and still
    402          * consider these as repeat sequence headers.
    403          *
    404          * However, be careful not to alter the current sequence when
    405          * returning STATE_INVALID_END.
     469         * identical to the original. However some encoders do not
     470         * respect that and change various fields (including bitrate
     471         * and aspect ratio) in the repeat sequence headers. So we
     472         * choose to be as conservative as possible and only restart
     473         * the decoder if the width, height, chroma_width,
     474         * chroma_height or low_delay flag are modified.
    406475         */
    407         new_byte_rate = sequence->byte_rate;
    408         sequence->byte_rate = mpeg2dec->sequence.byte_rate;
    409         if (memcmp (&(mpeg2dec->sequence), sequence,
    410                     sizeof (mpeg2_sequence_t))) {
     476        if (sequence->width != mpeg2dec->sequence.width ||
     477            sequence->height != mpeg2dec->sequence.height ||
     478            sequence->chroma_width != mpeg2dec->sequence.chroma_width ||
     479            sequence->chroma_height != mpeg2dec->sequence.chroma_height ||
     480            ((sequence->flags ^ mpeg2dec->sequence.flags) &
     481             SEQ_FLAG_LOW_DELAY)) {
    411482            decoder->stride_frame = sequence->width;
    412             sequence->byte_rate = new_byte_rate;
    413483            mpeg2_header_end (mpeg2dec);
    414484            mpeg2dec->action = invalid_end_action;
    415485            mpeg2dec->state = STATE_INVALID_END;
    416486            return;
    417487        }
    418         sequence->byte_rate = new_byte_rate;
    419         mpeg2dec->state = STATE_SEQUENCE_REPEATED;
     488        mpeg2dec->state = (memcmp (&(mpeg2dec->sequence), sequence,
     489                                   sizeof (mpeg2_sequence_t)) ?
     490                           STATE_SEQUENCE_MODIFIED : STATE_SEQUENCE_REPEATED);
    420491    } else
    421492        decoder->stride_frame = sequence->width;
    422493    mpeg2dec->sequence = *sequence;
     
    468539        }
    469540}
    470541
    471 mpeg2_state_t mpeg2_header_picture_start (mpeg2dec_t * mpeg2dec)
     542int mpeg2_header_picture (mpeg2dec_t * mpeg2dec)
    472543{
     544    uint8_t * buffer = mpeg2dec->chunk_start;
    473545    mpeg2_picture_t * picture = &(mpeg2dec->new_picture);
     546    mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
     547    int type;
    474548
    475549    mpeg2dec->state = ((mpeg2dec->state != STATE_SLICE_1ST) ?
    476550                       STATE_PICTURE : STATE_PICTURE_2ND);
    477     picture->flags = 0;
     551    mpeg2dec->ext_state = PIC_CODING_EXT;
     552
     553    picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6);
     554
     555    type = (buffer [1] >> 3) & 7;
     556    if (type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B) {
     557        /* forward_f_code and backward_f_code - used in mpeg1 only */
     558        decoder->f_motion.f_code[1] = (buffer[3] >> 2) & 1;
     559        decoder->f_motion.f_code[0] =
     560            (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
     561        decoder->b_motion.f_code[1] = (buffer[4] >> 6) & 1;
     562        decoder->b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
     563    }
     564
     565    picture->flags = PIC_FLAG_PROGRESSIVE_FRAME | type;
    478566    picture->tag = picture->tag2 = 0;
    479567    if (mpeg2dec->num_tags) {
    480         if (mpeg2dec->bytes_since_tag >= 4) {
     568        if (mpeg2dec->bytes_since_tag >= mpeg2dec->chunk_ptr - buffer + 4) {
    481569            mpeg2dec->num_tags = 0;
    482570            picture->tag = mpeg2dec->tag_current;
    483571            picture->tag2 = mpeg2dec->tag2_current;
    484             picture->flags = PIC_FLAG_TAGS;
     572            picture->flags |= PIC_FLAG_TAGS;
    485573        } else if (mpeg2dec->num_tags > 1) {
    486574            mpeg2dec->num_tags = 1;
    487575            picture->tag = mpeg2dec->tag_previous;
    488576            picture->tag2 = mpeg2dec->tag2_previous;
    489             picture->flags = PIC_FLAG_TAGS;
     577            picture->flags |= PIC_FLAG_TAGS;
    490578        }
    491579    }
     580    picture->nb_fields = 2;
    492581    picture->display_offset[0].x = picture->display_offset[1].x =
    493582        picture->display_offset[2].x = mpeg2dec->display_offset_x;
    494583    picture->display_offset[0].y = picture->display_offset[1].y =
    495584        picture->display_offset[2].y = mpeg2dec->display_offset_y;
    496     return mpeg2_parse_header (mpeg2dec);
    497 }
    498 
    499 int mpeg2_header_picture (mpeg2dec_t * mpeg2dec)
    500 {
    501     uint8_t * buffer = mpeg2dec->chunk_start;
    502     mpeg2_picture_t * picture = &(mpeg2dec->new_picture);
    503     mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
    504     int type;
    505 
    506     type = (buffer [1] >> 3) & 7;
    507     mpeg2dec->ext_state = PIC_CODING_EXT;
    508 
    509     picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6);
    510 
    511     picture->flags |= type;
    512 
    513     if (type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B) {
    514         /* forward_f_code and backward_f_code - used in mpeg1 only */
    515         decoder->f_motion.f_code[1] = (buffer[3] >> 2) & 1;
    516         decoder->f_motion.f_code[0] =
    517             (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
    518         decoder->b_motion.f_code[1] = (buffer[4] >> 6) & 1;
    519         decoder->b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
    520     }
    521585
    522586    /* XXXXXX decode extra_information_picture as well */
    523587
    524     picture->nb_fields = 2;
    525 
    526     mpeg2dec->q_scale_type = 0;
     588    decoder->q_scale_type = 0;
    527589    decoder->intra_dc_precision = 7;
    528590    decoder->frame_pred_frame_dct = 1;
    529591    decoder->concealment_motion_vectors = 0;
     
    570632    decoder->top_field_first = buffer[3] >> 7;
    571633    decoder->frame_pred_frame_dct = (buffer[3] >> 6) & 1;
    572634    decoder->concealment_motion_vectors = (buffer[3] >> 5) & 1;
    573     mpeg2dec->q_scale_type = buffer[3] & 16;
     635    decoder->q_scale_type = buffer[3] & 16;
    574636    decoder->intra_vlc_format = (buffer[3] >> 3) & 1;
    575637    decoder->scan = (buffer[3] & 4) ? mpeg2_scan_alt : mpeg2_scan_norm;
    576     flags |= (buffer[4] & 0x80) ? PIC_FLAG_PROGRESSIVE_FRAME : 0;
     638    if (!(buffer[4] & 0x80))
     639        flags &= ~PIC_FLAG_PROGRESSIVE_FRAME;
    577640    if (buffer[4] & 0x40)
    578641        flags |= (((buffer[4]<<26) | (buffer[5]<<18) | (buffer[6]<<10)) &
    579642                  PIC_MASK_COMPOSITE_DISPLAY) | PIC_FLAG_COMPOSITE_DISPLAY;
     
    794857    return 0;
    795858}
    796859
    797 static void prescale (mpeg2dec_t * mpeg2dec, int index)
     860static void prescale (mpeg2dec_t * mpeg2dec, int idx)
    798861{
    799862    static int non_linear_scale [] = {
    800863         0,  1,  2,  3,  4,  5,   6,   7,
     
    805868    int i, j, k;
    806869    mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
    807870
    808     if (mpeg2dec->scaled[index] != mpeg2dec->q_scale_type) {
    809         mpeg2dec->scaled[index] = mpeg2dec->q_scale_type;
     871    if (mpeg2dec->scaled[idx] != decoder->q_scale_type) {
     872        mpeg2dec->scaled[idx] = decoder->q_scale_type;
    810873        for (i = 0; i < 32; i++) {
    811             k = mpeg2dec->q_scale_type ? non_linear_scale[i] : (i << 1);
    812             decoder->quantizer_scales[i] = k;
     874            k = decoder->q_scale_type ? non_linear_scale[i] : (i << 1);
    813875            for (j = 0; j < 64; j++)
    814                 decoder->quantizer_prescale[index][i][j] =
    815                     k * mpeg2dec->quantizer_matrix[index][j];
     876                decoder->quantizer_prescale[idx][i][j] =
     877                    k * mpeg2dec->quantizer_matrix[idx][j];
    816878        }
    817879    }
    818880}
     
    864926                         mpeg2dec->fbuf[b_type]->buf);
    865927    }
    866928    mpeg2dec->action = NULL;
    867     return (mpeg2_state_t)-1;
     929    return STATE_INTERNAL_NORETURN;
    868930}
    869931
    870932static mpeg2_state_t seek_sequence (mpeg2dec_t * mpeg2dec)
  • libmpeg2/idct_alpha.c

    diff -u /build/mplayer/libmpeg2/idct_alpha.c /build/libmpeg2/libmpeg2/idct_alpha.c
    old new  
    2020 * You should have received a copy of the GNU General Public License
    2121 * along with this program; if not, write to the Free Software
    2222 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23  *
    24  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    25  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    26  * $Id: idct_alpha.c 26051 2008-02-21 16:47:05Z diego $
    2723 */
    2824
    2925#include "config.h"
  • libmpeg2/idct_altivec.c

    diff -u /build/mplayer/libmpeg2/idct_altivec.c /build/libmpeg2/libmpeg2/idct_altivec.c
    old new  
    5858
    5959#if defined(__APPLE_CC__)       /* apple */
    6060#define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) (a, b, c, d, e, f, g, h)
    61 #else                   /* gnu */
     61#else                           /* gnu */
    6262#define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
    6363#endif
    6464
  • libmpeg2/idct.c

    diff -u /build/mplayer/libmpeg2/idct.c /build/libmpeg2/libmpeg2/idct.c
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: idct.c 26425 2008-04-12 22:42:00Z diego $
    2622 */
    2723
    2824#include "config.h"
  • libmpeg2/idct_mmx.c

    diff -u /build/mplayer/libmpeg2/idct_mmx.c /build/libmpeg2/libmpeg2/idct_mmx.c
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: idct_mmx.c 26425 2008-04-12 22:42:00Z diego $
    2622 */
    2723
    2824#include "config.h"
  • libmpeg2/motion_comp_arm.c

    Only in /build/mplayer/libmpeg2: libmpeg-0.4.1.diff
    Only in /build/libmpeg2/libmpeg2: libmpeg2.pc.in
    Only in /build/libmpeg2/libmpeg2: Makefile.am
    Only in /build/libmpeg2/libmpeg2: Makefile.in
    Only in /build/mplayer/libmpeg2: mmx.h
    diff -u /build/mplayer/libmpeg2/motion_comp_arm.c /build/libmpeg2/libmpeg2/motion_comp_arm.c
    old new  
    1616 * GNU General Public License for more details.
    1717 *
    1818 * You should have received a copy of the GNU General Public License
    19  * along with this program; if not, write to the Free Software
     19 * along with mpeg2dec; if not, write to the Free Software
    2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2121 */
    2222
     
    3030#include "attributes.h"
    3131#include "mpeg2_internal.h"
    3232
    33 #define avg2(a,b) ((a+b+1)>>1)
     33#define avg2(a,b)     ((a+b+1)>>1)
    3434#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
    3535
    36 #define predict_o(i) (ref[i])
    37 #define predict_x(i) (avg2 (ref[i], ref[i+1]))
    38 #define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
     36#define predict_o(i)  (ref[i])
     37#define predict_x(i)  (avg2 (ref[i], ref[i+1]))
     38#define predict_y(i)  (avg2 (ref[i], (ref+stride)[i]))
    3939#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
    4040                             (ref+stride)[i], (ref+stride)[i+1]))
    4141
     
    6767        op (predict_##xy, 15);                                          \
    6868        ref += stride;                                                  \
    6969        dest += stride;                                                 \
    70     } while (--height);                                                 \
     70    } while (--height);                                         \
    7171}                                                                       \
    7272static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref,  \
    7373                                  const int stride, int height)         \
     
    8383        op (predict_##xy, 7);                                           \
    8484        ref += stride;                                                  \
    8585        dest += stride;                                                 \
    86     } while (--height);                                                 \
     86    } while (--height);                                         \
    8787}                                                                       \
    8888/* definitions of the actual mc functions */
    8989
    90 MC_FUNC (put,o)
    9190MC_FUNC (avg,o)
    92 MC_FUNC (put,x)
    9391MC_FUNC (avg,x)
    9492MC_FUNC (put,y)
    9593MC_FUNC (avg,y)
     
    117115}
    118116
    119117extern void MC_put_o_8_arm (uint8_t * dest, const uint8_t * ref,
    120                                 int stride, int height);
     118                             int stride, int height);
    121119
    122120extern void MC_put_x_8_arm (uint8_t * dest, const uint8_t * ref,
    123121                            int stride, int height);
  • libmpeg2/motion_comp_arm_s.S

    diff -u /build/mplayer/libmpeg2/motion_comp_arm_s.S /build/libmpeg2/libmpeg2/motion_comp_arm_s.S
    old new  
    1515@ GNU General Public License for more details.
    1616@
    1717@ You should have received a copy of the GNU General Public License
    18 @ along with this program; if not, write to the Free Software
     18@ along with mpeg2dec; if not, write to the Free Software
    1919@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2020
     21
    2122        .text
    2223
    2324@ ----------------------------------------------------------------
  • libmpeg2/motion_comp.c

    diff -u /build/mplayer/libmpeg2/motion_comp.c /build/libmpeg2/libmpeg2/motion_comp.c
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: motion_comp.c 26314 2008-04-01 17:31:37Z diego $
    2622 */
    2723
    2824#include "config.h"
     
    6258    else
    6359#endif
    6460#ifdef ARCH_ARM
    65     if (accel & MPEG2_ACCEL_ARM_IWMMXT)
    66         mpeg2_mc = mpeg2_mc_iwmmxt;
    67     else if (accel & MPEG2_ACCEL_ARM)
     61    if (accel & MPEG2_ACCEL_ARM) {
    6862        mpeg2_mc = mpeg2_mc_arm;
    69     else
     63    } else
    7064#endif
    7165        mpeg2_mc = mpeg2_mc_c;
    7266}
  • libmpeg2/motion_comp_mmx.c

    Only in /build/mplayer/libmpeg2: motion_comp_iwmmxt.c
    diff -u /build/mplayer/libmpeg2/motion_comp_mmx.c /build/libmpeg2/libmpeg2/motion_comp_mmx.c
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: motion_comp_mmx.c 21542 2006-12-09 10:34:27Z henry $
    2622 */
    2723
    2824#include "config.h"
  • libmpeg2/mpeg2_internal.h

    Only in /build/mplayer/libmpeg2: mpeg2.h
    diff -u /build/mplayer/libmpeg2/mpeg2_internal.h /build/libmpeg2/libmpeg2/mpeg2_internal.h
    old new  
    1919 * You should have received a copy of the GNU General Public License
    2020 * along with this program; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
    23  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    24  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    25  * $Id: mpeg2_internal.h 26425 2008-04-12 22:42:00Z diego $
    2622 */
    2723
     24#ifndef LIBMPEG2_MPEG2_INTERNAL_H
     25#define LIBMPEG2_MPEG2_INTERNAL_H
     26
     27#define STATE_INTERNAL_NORETURN ((mpeg2_state_t)-1)
     28
    2829/* macroblock modes */
    2930#define MACROBLOCK_INTRA 1
    3031#define MACROBLOCK_PATTERN 2
     
    149150
    150151    int mpeg1;
    151152
    152     int quantizer_scales[32];
    153     int quantizer_scale;
    154     char* quant_store;
    155     int quant_stride;
     153    /* XXX: stuff due to xine shit */
     154    int8_t q_scale_type;
    156155};
    157156
    158157typedef struct {
     
    220219    int16_t display_offset_x, display_offset_y;
    221220
    222221    int copy_matrix;
    223     int8_t q_scale_type, scaled[4];
     222    int8_t scaled[4]; /* XXX: MOVED */
     223    //int8_t q_scale_type, scaled[4];
    224224    uint8_t quantizer_matrix[4][64];
    225225    uint8_t new_quantizer_matrix[4][64];
    226 
    227     unsigned char *pending_buffer;
    228     int pending_length;
    229226};
    230227
    231228typedef struct {
     
    236233} cpu_state_t;
    237234
    238235/* cpu_accel.c */
    239 uint32_t mpeg2_detect_accel (void);
     236uint32_t mpeg2_detect_accel (uint32_t accel);
    240237
    241238/* cpu_state.c */
    242239void mpeg2_cpu_state_init (uint32_t accel);
     
    314311extern mpeg2_mc_t mpeg2_mc_alpha;
    315312extern mpeg2_mc_t mpeg2_mc_vis;
    316313extern mpeg2_mc_t mpeg2_mc_arm;
    317 extern mpeg2_mc_t mpeg2_mc_iwmmxt;
     314
     315#endif /* LIBMPEG2_MPEG2_INTERNAL_H */
  • libmpeg2/slice.c

    diff -u /build/mplayer/libmpeg2/slice.c /build/libmpeg2/libmpeg2/slice.c
    old new  
    2020 * You should have received a copy of the GNU General Public License
    2121 * along with this program; if not, write to the Free Software
    2222 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23  *
    24  * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
    25  * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
    26  * $Id: slice.c 21941 2007-01-16 09:49:28Z henry $
    2723 */
    2824
    2925#include "config.h"
     
    146142
    147143    quantizer_scale_code = UBITS (bit_buf, 5);
    148144    DUMPBITS (bit_buf, bits, 5);
    149     decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
    150145
    151146    decoder->quantizer_matrix[0] =
    152147        decoder->quantizer_prescale[0][quantizer_scale_code];
     
    450445        break;  /* illegal, check needed to avoid buffer overflow */
    451446    }
    452447    dest[63] ^= mismatch & 16;
    453     DUMPBITS (bit_buf, bits, 2);        /* dump end of block code */
     448    DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
    454449    decoder->bitstream_buf = bit_buf;
    455450    decoder->bitstream_bits = bits;
    456451    decoder->bitstream_ptr = bit_ptr;
     
    508503            } else {
    509504
    510505                /* end of block. I commented out this code because if we */
    511                 /* dont exit here we will still exit at the later test :) */
     506                /* do not exit here we will still exit at the later test :) */
    512507
    513508                /* if (i >= 128) break; */      /* end of block */
    514509
     
    560555        break;  /* illegal, check needed to avoid buffer overflow */
    561556    }
    562557    dest[63] ^= mismatch & 16;
    563     DUMPBITS (bit_buf, bits, 4);        /* dump end of block code */
     558    DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
    564559    decoder->bitstream_buf = bit_buf;
    565560    decoder->bitstream_bits = bits;
    566561    decoder->bitstream_ptr = bit_ptr;
     
    681676        break;  /* illegal, check needed to avoid buffer overflow */
    682677    }
    683678    dest[63] ^= mismatch & 16;
    684     DUMPBITS (bit_buf, bits, 2);        /* dump end of block code */
     679    DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
    685680    decoder->bitstream_buf = bit_buf;
    686681    decoder->bitstream_bits = bits;
    687682    decoder->bitstream_ptr = bit_ptr;
     
    799794        }
    800795        break;  /* illegal, check needed to avoid buffer overflow */
    801796    }
    802     DUMPBITS (bit_buf, bits, 2);        /* dump end of block code */
     797    DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
    803798    decoder->bitstream_buf = bit_buf;
    804799    decoder->bitstream_bits = bits;
    805800    decoder->bitstream_ptr = bit_ptr;
     
    926921        }
    927922        break;  /* illegal, check needed to avoid buffer overflow */
    928923    }
    929     DUMPBITS (bit_buf, bits, 2);        /* dump end of block code */
     924    DUMPBITS (bit_buf, bits, tab->len); /* dump end of block code */
    930925    decoder->bitstream_buf = bit_buf;
    931926    decoder->bitstream_bits = bits;
    932927    decoder->bitstream_ptr = bit_ptr;
     
    15691564
    15701565#define NEXT_MACROBLOCK                                                 \
    15711566do {                                                                    \
    1572     if(decoder->quant_store) {                                          \
    1573        if (decoder->picture_structure == TOP_FIELD)                     \
    1574         decoder->quant_store[2*decoder->quant_stride*(decoder->v_offset>>4) \
    1575                     +(decoder->offset>>4)] = decoder->quantizer_scale;  \
    1576        else if (decoder->picture_structure == BOTTOM_FIELD)             \
    1577         decoder->quant_store[2*decoder->quant_stride*(decoder->v_offset>>4) \
    1578                     + decoder->quant_stride                             \
    1579                     +(decoder->offset>>4)] = decoder->quantizer_scale;  \
    1580        else                                                             \
    1581         decoder->quant_store[decoder->quant_stride*(decoder->v_offset>>4) \
    1582                     +(decoder->offset>>4)] = decoder->quantizer_scale;  \
    1583     }                                                                   \
    15841567    decoder->offset += 16;                                              \
    15851568    if (decoder->offset == decoder->width) {                            \
    15861569        do { /* just so we can use the break statement */               \
     
    16041587    }                                                                   \
    16051588} while (0)
    16061589
     1590/**
     1591 * Dummy motion decoding function, to avoid calling NULL in
     1592 * case of malformed streams.
     1593 */
    16071594static void motion_dummy (mpeg2_decoder_t * const decoder,
    16081595                          motion_t * const motion,
    16091596                          mpeg2_mc_fct * const * const table)
     
    16681655    if (decoder->mpeg1) {
    16691656        decoder->motion_parser[0] = motion_zero_420;
    16701657        decoder->motion_parser[MC_FIELD] = motion_dummy;
    1671         decoder->motion_parser[MC_FRAME] = motion_mp1;
     1658        decoder->motion_parser[MC_FRAME] = motion_mp1;
    16721659        decoder->motion_parser[MC_DMV] = motion_dummy;
    16731660        decoder->motion_parser[4] = motion_reuse_420;
    16741661    } else if (decoder->picture_structure == FRAME_PICTURE) {
     
    18941881
    18951882            motion_parser_t * parser;
    18961883
     1884            if (   ((macroblock_modes >> MOTION_TYPE_SHIFT) < 0)
     1885                || ((macroblock_modes >> MOTION_TYPE_SHIFT) >=
     1886                    (int)(sizeof(decoder->motion_parser)
     1887                          / sizeof(decoder->motion_parser[0])))
     1888               ) {
     1889                break; // Illegal !
     1890            }
     1891
    18971892            parser =
    18981893                decoder->motion_parser[macroblock_modes >> MOTION_TYPE_SHIFT];
    18991894            MOTION_CALL (parser, macroblock_modes);
  • libmpeg2/vlc.h

    Common subdirectories: /build/mplayer/libmpeg2/.svn and /build/libmpeg2/libmpeg2/.svn
    Only in /build/mplayer/libmpeg2: vis.h
    diff -u /build/mplayer/libmpeg2/vlc.h /build/libmpeg2/libmpeg2/vlc.h
    old new  
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2222 */
    2323
     24#ifndef LIBMPEG2_VLC_H
     25#define LIBMPEG2_VLC_H
     26
    2427#define GETWORD(bit_buf,shift,bit_ptr)                          \
    2528do {                                                            \
    2629    bit_buf |= ((bit_ptr[0] << 8) | bit_ptr[1]) << (shift);     \
     
    121124#define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
    122125
    123126static const MBtab MB_B [] = {
    124     {0,                 0}, {INTRA|QUANT,       6},
     127    {0,                 6}, {INTRA|QUANT,       6},
    125128    {BWD|CODED|QUANT,   6}, {FWD|CODED|QUANT,   6},
    126129    {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
    127130                                        {INTRA,       5}, {INTRA,       5},
     
    201204};
    202205
    203206static const CBPtab CBP_9 [] = {
    204     {0,    0}, {0x00, 9}, {0x39, 9}, {0x36, 9},
     207    {0,    9}, {0x00, 9}, {0x39, 9}, {0x36, 9},
    205208    {0x37, 9}, {0x3b, 9}, {0x3d, 9}, {0x3e, 9},
    206209    {0x17, 8}, {0x17, 8}, {0x1b, 8}, {0x1b, 8},
    207210    {0x1d, 8}, {0x1d, 8}, {0x1e, 8}, {0x1e, 8},
     
    289292};
    290293
    291294static const DCTtab DCT_B14_8 [] = {
    292     { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
     295    { 65, 0,12}, { 65, 0,12}, { 65, 0,12}, { 65, 0,12},
    293296    {  3, 2, 7}, {  3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
    294297    {  1, 4, 7}, {  1, 4, 7}, {  9, 1, 7}, {  9, 1, 7},
    295298    {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6},
     
    326329};
    327330
    328331static const DCTtab DCT_B15_8 [] = {
    329     { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
     332    { 65, 0,12}, { 65, 0,12}, { 65, 0,12}, { 65, 0,12},
    330333    {  8, 1, 7}, {  8, 1, 7}, {  9, 1, 7}, {  9, 1, 7},
    331334    {  7, 1, 7}, {  7, 1, 7}, {  3, 2, 7}, {  3, 2, 7},
    332335    {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6},
     
    427430    { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
    428431    { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7}
    429432};
     433
     434#endif /* LIBMPEG2_VLC_H */