Skip to content

Commit 2357c6a

Browse files
author
Jeremian Morris
committed
Adding mpeg2dec for optional MPEG2 video decoding.
git-svn-id: http://svn.mythtv.org/svn/trunk@5118 7dbf422c-18fa-0310-86e9-fd20926502f2
1 parent 2202b77 commit 2357c6a

29 files changed

+11996
-7
lines changed

mythtv/libs/libmythmpeg2/alloc.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* alloc.c
3+
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4+
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5+
*
6+
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7+
* See http://libmpeg2.sourceforge.net/ for updates.
8+
*
9+
* mpeg2dec is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 2 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* mpeg2dec is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22+
*/
23+
24+
#include <stdlib.h>
25+
#include <inttypes.h>
26+
27+
#include "mpeg2.h"
28+
29+
static void * (* malloc_hook) (unsigned size, mpeg2_alloc_t reason) = NULL;
30+
static int (* free_hook) (void * buf) = NULL;
31+
32+
void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason)
33+
{
34+
char * buf;
35+
36+
if (malloc_hook) {
37+
buf = (char *) malloc_hook (size, reason);
38+
if (buf)
39+
return buf;
40+
}
41+
42+
if (size) {
43+
buf = (char *) malloc (size + 63 + sizeof (void **));
44+
if (buf) {
45+
char * align_buf;
46+
47+
align_buf = buf + 63 + sizeof (void **);
48+
align_buf -= (long)align_buf & 63;
49+
*(((void **)align_buf) - 1) = buf;
50+
return align_buf;
51+
}
52+
}
53+
return NULL;
54+
}
55+
56+
void mpeg2_free (void * buf)
57+
{
58+
if (free_hook && free_hook (buf))
59+
return;
60+
61+
if (buf)
62+
free (*(((void **)buf) - 1));
63+
}
64+
65+
void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
66+
int free (void *))
67+
{
68+
malloc_hook = malloc;
69+
free_hook = free;
70+
}
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
* Alpha assembly macros
3+
* Copyright (c) 2002-2003 Falk Hueffner <falk@debian.org>
4+
*
5+
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
6+
* See http://libmpeg2.sourceforge.net/ for updates.
7+
*
8+
* mpeg2dec is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* mpeg2dec is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*/
22+
23+
#ifndef ALPHA_ASM_H
24+
#define ALPHA_ASM_H
25+
26+
#include <inttypes.h>
27+
28+
#if defined __GNUC__
29+
# define GNUC_PREREQ(maj, min) \
30+
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
31+
#else
32+
# define GNUC_PREREQ(maj, min) 0
33+
#endif
34+
35+
#define AMASK_BWX (1 << 0)
36+
#define AMASK_FIX (1 << 1)
37+
#define AMASK_CIX (1 << 2)
38+
#define AMASK_MVI (1 << 8)
39+
40+
#ifdef __alpha_bwx__
41+
# define HAVE_BWX() 1
42+
#else
43+
# define HAVE_BWX() (amask(AMASK_BWX) == 0)
44+
#endif
45+
#ifdef __alpha_fix__
46+
# define HAVE_FIX() 1
47+
#else
48+
# define HAVE_FIX() (amask(AMASK_FIX) == 0)
49+
#endif
50+
#ifdef __alpha_max__
51+
# define HAVE_MVI() 1
52+
#else
53+
# define HAVE_MVI() (amask(AMASK_MVI) == 0)
54+
#endif
55+
#ifdef __alpha_cix__
56+
# define HAVE_CIX() 1
57+
#else
58+
# define HAVE_CIX() (amask(AMASK_CIX) == 0)
59+
#endif
60+
61+
inline static uint64_t BYTE_VEC(uint64_t x)
62+
{
63+
x |= x << 8;
64+
x |= x << 16;
65+
x |= x << 32;
66+
return x;
67+
}
68+
inline static uint64_t WORD_VEC(uint64_t x)
69+
{
70+
x |= x << 16;
71+
x |= x << 32;
72+
return x;
73+
}
74+
75+
#define ldq(p) (*(const uint64_t *) (p))
76+
#define ldl(p) (*(const int32_t *) (p))
77+
#define stl(l, p) do { *(uint32_t *) (p) = (l); } while (0)
78+
#define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0)
79+
#define sextw(x) ((int16_t) (x))
80+
81+
#ifdef __GNUC__
82+
struct unaligned_long { uint64_t l; } __attribute__((packed));
83+
#define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul))
84+
#define uldq(a) (((const struct unaligned_long *) (a))->l)
85+
86+
#if GNUC_PREREQ(3,3)
87+
#define prefetch(p) __builtin_prefetch((p), 0, 1)
88+
#define prefetch_en(p) __builtin_prefetch((p), 0, 0)
89+
#define prefetch_m(p) __builtin_prefetch((p), 1, 1)
90+
#define prefetch_men(p) __builtin_prefetch((p), 1, 0)
91+
#define cmpbge __builtin_alpha_cmpbge
92+
/* Avoid warnings. */
93+
#define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b))
94+
#define extwl(a, b) __builtin_alpha_extwl(a, (uint64_t) (b))
95+
#define extqh(a, b) __builtin_alpha_extqh(a, (uint64_t) (b))
96+
#define zap __builtin_alpha_zap
97+
#define zapnot __builtin_alpha_zapnot
98+
#define amask __builtin_alpha_amask
99+
#define implver __builtin_alpha_implver
100+
#define rpcc __builtin_alpha_rpcc
101+
#else
102+
#define prefetch(p) asm volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory")
103+
#define prefetch_en(p) asm volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory")
104+
#define prefetch_m(p) asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory")
105+
#define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory")
106+
#define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
107+
#define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
108+
#define extwl(a, b) ({ uint64_t __r; asm ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
109+
#define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
110+
#define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
111+
#define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
112+
#define amask(a) ({ uint64_t __r; asm ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; })
113+
#define implver() ({ uint64_t __r; asm ("implver %0" : "=r" (__r)); __r; })
114+
#define rpcc() ({ uint64_t __r; asm volatile ("rpcc %0" : "=r" (__r)); __r; })
115+
#endif
116+
#define wh64(p) asm volatile("wh64 (%0)" : : "r"(p) : "memory")
117+
118+
#if GNUC_PREREQ(3,3) && defined(__alpha_max__)
119+
#define minub8 __builtin_alpha_minub8
120+
#define minsb8 __builtin_alpha_minsb8
121+
#define minuw4 __builtin_alpha_minuw4
122+
#define minsw4 __builtin_alpha_minsw4
123+
#define maxub8 __builtin_alpha_maxub8
124+
#define maxsb8 __builtin_alpha_maxsb8
125+
#define maxuw4 __builtin_alpha_maxuw4
126+
#define maxsw4 __builtin_alpha_maxsw4
127+
#define perr __builtin_alpha_perr
128+
#define pklb __builtin_alpha_pklb
129+
#define pkwb __builtin_alpha_pkwb
130+
#define unpkbl __builtin_alpha_unpkbl
131+
#define unpkbw __builtin_alpha_unpkbw
132+
#else
133+
#define minub8(a, b) ({ uint64_t __r; asm (".arch ev6; minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
134+
#define minsb8(a, b) ({ uint64_t __r; asm (".arch ev6; minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
135+
#define minuw4(a, b) ({ uint64_t __r; asm (".arch ev6; minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
136+
#define minsw4(a, b) ({ uint64_t __r; asm (".arch ev6; minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
137+
#define maxub8(a, b) ({ uint64_t __r; asm (".arch ev6; maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
138+
#define maxsb8(a, b) ({ uint64_t __r; asm (".arch ev6; maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
139+
#define maxuw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
140+
#define maxsw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
141+
#define perr(a, b) ({ uint64_t __r; asm (".arch ev6; perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
142+
#define pklb(a) ({ uint64_t __r; asm (".arch ev6; pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
143+
#define pkwb(a) ({ uint64_t __r; asm (".arch ev6; pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
144+
#define unpkbl(a) ({ uint64_t __r; asm (".arch ev6; unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
145+
#define unpkbw(a) ({ uint64_t __r; asm (".arch ev6; unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
146+
#endif
147+
148+
#elif defined(__DECC) /* Digital/Compaq/hp "ccc" compiler */
149+
150+
#include <c_asm.h>
151+
#define ldq_u(a) asm ("ldq_u %v0,0(%a0)", a)
152+
#define uldq(a) (*(const __unaligned uint64_t *) (a))
153+
#define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b)
154+
#define extql(a, b) asm ("extql %a0,%a1,%v0", a, b)
155+
#define extwl(a, b) asm ("extwl %a0,%a1,%v0", a, b)
156+
#define extqh(a, b) asm ("extqh %a0,%a1,%v0", a, b)
157+
#define zap(a, b) asm ("zap %a0,%a1,%v0", a, b)
158+
#define zapnot(a, b) asm ("zapnot %a0,%a1,%v0", a, b)
159+
#define amask(a) asm ("amask %a0,%v0", a)
160+
#define implver() asm ("implver %v0")
161+
#define rpcc() asm ("rpcc %v0")
162+
#define minub8(a, b) asm ("minub8 %a0,%a1,%v0", a, b)
163+
#define minsb8(a, b) asm ("minsb8 %a0,%a1,%v0", a, b)
164+
#define minuw4(a, b) asm ("minuw4 %a0,%a1,%v0", a, b)
165+
#define minsw4(a, b) asm ("minsw4 %a0,%a1,%v0", a, b)
166+
#define maxub8(a, b) asm ("maxub8 %a0,%a1,%v0", a, b)
167+
#define maxsb8(a, b) asm ("maxsb8 %a0,%a1,%v0", a, b)
168+
#define maxuw4(a, b) asm ("maxuw4 %a0,%a1,%v0", a, b)
169+
#define maxsw4(a, b) asm ("maxsw4 %a0,%a1,%v0", a, b)
170+
#define perr(a, b) asm ("perr %a0,%a1,%v0", a, b)
171+
#define pklb(a) asm ("pklb %a0,%v0", a)
172+
#define pkwb(a) asm ("pkwb %a0,%v0", a)
173+
#define unpkbl(a) asm ("unpkbl %a0,%v0", a)
174+
#define unpkbw(a) asm ("unpkbw %a0,%v0", a)
175+
#define wh64(a) asm ("wh64 %a0", a)
176+
177+
#else
178+
#error "Unknown compiler!"
179+
#endif
180+
181+
#endif /* ALPHA_ASM_H */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* attributes.h
3+
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4+
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5+
*
6+
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7+
* See http://libmpeg2.sourceforge.net/ for updates.
8+
*
9+
* mpeg2dec is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 2 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* mpeg2dec is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22+
*/
23+
24+
/* use gcc attribs to align critical data structures */
25+
#ifdef ATTRIBUTE_ALIGNED_MAX
26+
#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
27+
#else
28+
#define ATTR_ALIGN(align)
29+
#endif
30+
31+
#ifdef HAVE_BUILTIN_EXPECT
32+
#define likely(x) __builtin_expect ((x) != 0, 1)
33+
#define unlikely(x) __builtin_expect ((x) != 0, 0)
34+
#else
35+
#define likely(x) (x)
36+
#define unlikely(x) (x)
37+
#endif

mythtv/libs/libmythmpeg2/config.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Include config options from main configure script. */
2+
#include "../../config.h"
3+
4+
/* Enable CPU-specific optimizations. */
5+
#define ACCEL_DETECT
6+
7+
/* The __builtin_expect function is used where available */
8+
/* (GCC 2.96.x and above). */
9+
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
10+
#define HAVE_BUILTIN_EXPECT
11+
#endif
12+
13+
/* Translate avcodec's ARCH_POWERPC into mpeg2's ARCH_PPC. */
14+
#ifdef ARCH_POWERPC
15+
#define ARCH_PPC
16+
#endif
17+
18+
/* Some detection code needs to know the return type of a */
19+
/* signal handler. */
20+
#define RETSIGTYPE void
21+
22+
/* Set the maximum alignment for variables. */
23+
#define ATTRIBUTE_ALIGNED_MAX 64

0 commit comments

Comments
 (0)