1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

libmpeg2: drop libmpeg2 support

libavcodec mpeg2 decoder has been the default for a while and seems to
work fine.
This commit is contained in:
Uoti Urpala 2011-02-01 20:10:27 +02:00
parent 156ba34ac7
commit 7cd7416c73
31 changed files with 0 additions and 13963 deletions

View File

@ -28,19 +28,6 @@ Copyright: 1998-2008 VideoLAN
License: GNU General Public License
Name: libmpeg2
Version: 0.5.1 + patches
URL: http://libmpeg2.sourceforge.net/
Directory: libmpeg2
Copyright: 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
2000-2004 Michel Lespinasse <walken@zoy.org>
2002-2003 Falk Hueffner <falk@debian.org>
2003 David S. Miller <davem@redhat.com>
2003 Regis Duchesne <hpreg@zoy.org>
2003 Peter Gubanov <peter@elecard.net.ru>
License: GNU General Public License
Name: mpg123
Version: 0.59s + significant changes
URL: http://www.mpg123.de/

View File

@ -109,26 +109,6 @@ SRCS_COMMON-$(LIBDVDCSS_INTERNAL) += libdvdcss/css.c \
SRCS_COMMON-$(LIBMAD) += libmpcodecs/ad_libmad.c
SRCS_LIBMPEG2-$(ARCH_ALPHA) += libmpeg2/idct_alpha.c \
libmpeg2/motion_comp_alpha.c
SRCS_LIBMPEG2-$(ARCH_ARM) += libmpeg2/motion_comp_arm.c \
libmpeg2/motion_comp_arm_s.S
SRCS_LIBMPEG2-$(HAVE_ALTIVEC) += libmpeg2/idct_altivec.c \
libmpeg2/motion_comp_altivec.c
SRCS_LIBMPEG2-$(HAVE_MMX) += libmpeg2/idct_mmx.c \
libmpeg2/motion_comp_mmx.c
SRCS_LIBMPEG2-$(HAVE_VIS) += libmpeg2/motion_comp_vis.c
SRCS_COMMON-$(LIBMPEG2) += libmpcodecs/vd_libmpeg2.c \
libmpeg2/alloc.c \
libmpeg2/cpu_accel.c\
libmpeg2/cpu_state.c \
libmpeg2/decode.c \
libmpeg2/header.c \
libmpeg2/idct.c \
libmpeg2/motion_comp.c \
libmpeg2/slice.c \
$(SRCS_LIBMPEG2-yes)
SRCS_COMMON-$(LIBNEMESI) += libmpdemux/demux_nemesi.c \
stream/stream_nemesi.c
SRCS_COMMON-$(LIBNUT) += libmpdemux/demux_nut.c
@ -609,7 +589,6 @@ DIRS = . \
libmpcodecs \
libmpcodecs/native \
libmpdemux \
libmpeg2 \
libvo \
loader \
loader/dshow \

50
configure vendored
View File

@ -382,7 +382,6 @@ Codecs:
--enable-libdca enable libdca support [autodetect]
--disable-mp3lib disable builtin mp3lib [autodetect]
--disable-liba52 disable liba52 [autodetect]
--disable-libmpeg2 disable builtin libmpeg2 [autodetect]
--disable-musepack disable musepack support [autodetect]
Video output:
@ -621,7 +620,6 @@ _mpg123=auto
_mp3lib=auto
_liba52=auto
_libdca=auto
_libmpeg2=auto
_faad=auto
_ladspa=auto
_libbs2b=auto
@ -987,8 +985,6 @@ for ac_option do
--disable-liba52) _liba52=no ;;
--enable-libdca) _libdca=yes ;;
--disable-libdca) _libdca=no ;;
--enable-libmpeg2) _libmpeg2=yes ;;
--disable-libmpeg2) _libmpeg2=no ;;
--enable-musepack) _musepack=yes ;;
--disable-musepack) _musepack=no ;;
--enable-faad) _faad=yes ;;
@ -3096,23 +3092,6 @@ if test "$_inttypes" = no ; then
fi
echocheck "int_fastXY_t in inttypes.h"
_fast_inttypes=no
statement_check "inttypes.h" 'volatile int_fast16_t v = 0' && _fast_inttypes=yes
if test "$_fast_inttypes" = no ; then
def_fast_inttypes='
typedef signed char int_fast8_t;
typedef signed int int_fast16_t;
typedef signed int int_fast32_t;
typedef signed long long int_fast64_t;
typedef unsigned char uint_fast8_t;
typedef unsigned int uint_fast16_t;
typedef unsigned int uint_fast32_t;
typedef unsigned long long uint_fast64_t;'
fi
echores "$_fast_inttypes"
echocheck "malloc.h"
_malloc=no
header_check malloc.h && _malloc=yes
@ -5864,27 +5843,6 @@ else
fi
echores "$_liba52"
echocheck "internal libmpeg2 support"
if test "$_libmpeg2" = auto ; then
_libmpeg2=yes
if alpha && test cc_vendor=gnu; then
case $cc_version in
2*|3.0*|3.1*) # cannot compile MVI instructions
_libmpeg2=no
res_comment="broken gcc"
;;
esac
fi
fi
if test "$_libmpeg2" = yes ; then
def_libmpeg2='#define CONFIG_LIBMPEG2 1'
codecmodules="libmpeg2(internal) $codecmodules"
else
def_libmpeg2='#undef CONFIG_LIBMPEG2'
nocodecmodules="libmpeg2(internal) $nocodecmodules"
fi
echores "$_libmpeg2"
echocheck "libdca support"
if test "$_libdca" = auto ; then
_libdca=no
@ -6938,7 +6896,6 @@ LIBLZO = $_liblzo
LIBMAD = $_mad
LIBMENU = $_menu
LIBMENU_DVBIN = $_menu_dvbin
LIBMPEG2 = $_libmpeg2
LIBNEMESI = $_nemesi
LIBNUT = $_libnut
LIBSMBCLIENT = $_smb
@ -7072,10 +7029,6 @@ cat > $TMPH << EOF
#undef FAST_OSD
#undef FAST_OSD_TABLE
/* Define this to enable MPEG-1/2 image postprocessing in libmpeg2 */
#define MPEG12_POSTPROC 1
#define ATTRIBUTE_ALIGNED_MAX 16
#define CONFIGURATION "$configuration"
@ -7089,8 +7042,6 @@ $def_translation
/* definitions needed by included libraries */
#define HAVE_INTTYPES_H 1
/* libmpeg2 + FFmpeg */
$def_fast_inttypes
/* libdvdcss */
#define HAVE_ERRNO_H 1
/* libdvdcss + libdvdread */
@ -7219,7 +7170,6 @@ $def_liba52
$def_libdca
$def_libdv
$def_liblzo
$def_libmpeg2
$def_mad
$def_mp3lib
$def_mpg123

View File

@ -255,45 +255,6 @@ videocodec ffmpeg12
out YV12,I420,IYUV
out 422P,444P
videocodec mpeg12
info "MPEG-1 or 2 (libmpeg2)"
comment "with postprocessing"
status working
format 0x10000001 ; MPEG-1
format 0x10000002 ; MPEG-2
fourcc "DVR "
fourcc hdv2
fourcc mpg1
fourcc PIM1 ; Pinnacle hardware-MPEG-1
fourcc PIM2 ; Pinnacle hardware-MPEG-2
fourcc mpg2,MPG2
fourcc MPEG
fourcc hdv1
fourcc hdv3 ; HDV 1080i50
fourcc hdv5 ; HDV 720p25
fourcc mx5p ; MPEG IMX 625/50 (50 Mb/s)
fourcc MMES,mmes ; matrox mpeg2 in avi
fourcc M701 ; matrox mpeg2 intra-only
fourcc hdv6,hdv7,hdv8
fourcc xdv1,xdv2,xdv3
fourcc xdv4,xdv5,xdv6
fourcc xdv7,xdv8,xdv9
fourcc xdva,xdvb,xdvc
fourcc xdvd,xdve,xdvf
fourcc xd5a,xd5b,xd5c
fourcc xd5d,xd5e,xd5f
fourcc xd59,xd54
fourcc mx5n,mx4n,mx4p
fourcc mx3n,mx3p
fourcc AVmp
fourcc mp2v,mpgv
fourcc m2v1,m1v1
fourcc LMP2 ; Lead mpeg2 in avi
driver libmpeg2
; dll "libmpeg2"
out YV12,I420,IYUV
out 422P
videocodec ffmpeg12mc
info "FFmpeg MPEG-1/2 (XvMC)"
status buggy

View File

@ -50,7 +50,6 @@ extern const vd_functions_t mpcodecs_vd_mpng;
extern const vd_functions_t mpcodecs_vd_ijpg;
extern const vd_functions_t mpcodecs_vd_mtga;
extern const vd_functions_t mpcodecs_vd_sgi;
extern const vd_functions_t mpcodecs_vd_libmpeg2;
extern const vd_functions_t mpcodecs_vd_mpegpes;
extern const vd_functions_t mpcodecs_vd_realvid;
extern const vd_functions_t mpcodecs_vd_xvid;
@ -90,9 +89,6 @@ const vd_functions_t * const mpcodecs_vd_drivers[] = {
#endif
&mpcodecs_vd_mtga,
&mpcodecs_vd_sgi,
#ifdef CONFIG_LIBMPEG2
&mpcodecs_vd_libmpeg2,
#endif
&mpcodecs_vd_mpegpes,
#ifdef CONFIG_REALCODECS
&mpcodecs_vd_realvid,

View File

@ -1,314 +0,0 @@
/*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "options.h"
#include "mp_msg.h"
#include "vd_internal.h"
//#undef MPEG12_POSTPROC
static const vd_info_t info =
{
"libmpeg2 MPEG 1/2 Video decoder",
"libmpeg2",
"A'rpi & Fabian Franz",
"Aaron & Walken",
"native"
};
LIBVD_EXTERN(libmpeg2)
//#include "libvo/video_out.h" // FIXME!!!
#include "libmpeg2/mpeg2.h"
#include "libmpeg2/attributes.h"
#include "libmpeg2/mpeg2_internal.h"
#include "cpudetect.h"
typedef struct {
mpeg2dec_t *mpeg2dec;
int quant_store_idx;
char *quant_store[3];
int imgfmt;
int width;
int height;
double aspect;
} vd_libmpeg2_ctx_t;
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
vd_libmpeg2_ctx_t *context = sh->context;
mpeg2dec_t * mpeg2dec = context->mpeg2dec;
const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
switch(cmd) {
case VDCTRL_QUERY_FORMAT:
if (info->sequence->width >> 1 == info->sequence->chroma_width &&
info->sequence->height >> 1 == info->sequence->chroma_height &&
(*((int*)arg)) == IMGFMT_YV12)
return CONTROL_TRUE;
if (info->sequence->width >> 1 == info->sequence->chroma_width &&
info->sequence->height == info->sequence->chroma_height &&
(*((int*)arg)) == IMGFMT_422P)
return CONTROL_TRUE;
return CONTROL_FALSE;
}
return CONTROL_UNKNOWN;
}
// init driver
static int init(sh_video_t *sh){
vd_libmpeg2_ctx_t *context;
mpeg2dec_t * mpeg2dec;
// const mpeg2_info_t * info;
int accel;
accel = 0;
if(gCpuCaps.hasMMX)
accel |= MPEG2_ACCEL_X86_MMX;
if(gCpuCaps.hasMMX2)
accel |= MPEG2_ACCEL_X86_MMXEXT;
if(gCpuCaps.has3DNow)
accel |= MPEG2_ACCEL_X86_3DNOW;
if(gCpuCaps.hasSSE2)
accel |= MPEG2_ACCEL_X86_SSE2;
if(gCpuCaps.hasAltiVec)
accel |= MPEG2_ACCEL_PPC_ALTIVEC;
#if ARCH_ALPHA
accel |= MPEG2_ACCEL_ALPHA;
#elif ARCH_ARM
accel |= MPEG2_ACCEL_ARM;
#endif
#if HAVE_MVI
accel |= MPEG2_ACCEL_ALPHA_MVI;
#elif HAVE_VIS
accel |= MPEG2_ACCEL_SPARC_VIS;
#endif
mpeg2_accel(accel);
mpeg2dec = mpeg2_init ();
if(!mpeg2dec) return 0;
mpeg2_custom_fbuf(mpeg2dec,1); // enable DR1
context = calloc(1, sizeof(vd_libmpeg2_ctx_t));
context->mpeg2dec = mpeg2dec;
sh->context = context;
mpeg2dec->pending_buffer = 0;
mpeg2dec->pending_length = 0;
return 1;
}
// uninit driver
static void uninit(sh_video_t *sh){
int i;
vd_libmpeg2_ctx_t *context = sh->context;
mpeg2dec_t * mpeg2dec = context->mpeg2dec;
free(mpeg2dec->pending_buffer);
mpeg2dec->decoder.convert=NULL;
mpeg2dec->decoder.convert_id=NULL;
mpeg2_close (mpeg2dec);
for (i=0; i < 3; i++)
free(context->quant_store[i]);
free(sh->context);
}
static void draw_slice (void * _sh, uint8_t * const * src, unsigned int y){
sh_video_t* sh = (sh_video_t*) _sh;
vd_libmpeg2_ctx_t *context = sh->context;
mpeg2dec_t* mpeg2dec = context->mpeg2dec;
const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
int stride[MP_MAX_PLANES] = {mpeg2dec->decoder.stride, mpeg2dec->decoder.uv_stride, mpeg2dec->decoder.uv_stride};
uint8_t *srcs[MP_MAX_PLANES] = {src[0], src[1], src[2]};
// printf("draw_slice() y=%d \n",y);
mpcodecs_draw_slice(sh, srcs,
stride, info->sequence->picture_width,
(y+16<=info->sequence->picture_height) ? 16 :
info->sequence->picture_height-y,
0, y);
}
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
vd_libmpeg2_ctx_t *context = sh->context;
mpeg2dec_t * mpeg2dec = context->mpeg2dec;
const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
int drop_frame, framedrop=flags&3;
// MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context
mpeg2dec->decoder.convert=NULL;
mpeg2dec->decoder.convert_id=NULL;
if(len<=0) return NULL; // skipped null frame
// append extra 'end of frame' code:
((char*)data+len)[0]=0;
((char*)data+len)[1]=0;
((char*)data+len)[2]=1;
((char*)data+len)[3]=0xff;
len+=4;
if (mpeg2dec->pending_length) {
mpeg2_buffer (mpeg2dec, mpeg2dec->pending_buffer, mpeg2dec->pending_buffer + mpeg2dec->pending_length);
} else {
mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len);
}
while(1){
int state=mpeg2_parse (mpeg2dec);
int type, use_callback;
mp_image_t* mpi_new;
unsigned long pw, ph;
int imgfmt;
switch(state){
case STATE_BUFFER:
if (mpeg2dec->pending_length) {
// just finished the pending data, continue with processing of the passed buffer
mpeg2dec->pending_length = 0;
mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len);
} else {
// parsing of the passed buffer finished, return.
return 0;
}
break;
case STATE_SEQUENCE:
pw = info->sequence->display_width * info->sequence->pixel_width;
ph = info->sequence->display_height * info->sequence->pixel_height;
if(ph) sh->aspect = (float) pw / (float) ph;
// video parameters initialized/changed, (re)init libvo:
if (info->sequence->width >> 1 == info->sequence->chroma_width &&
info->sequence->height >> 1 == info->sequence->chroma_height) {
imgfmt = IMGFMT_YV12;
} else if (info->sequence->width >> 1 == info->sequence->chroma_width &&
info->sequence->height == info->sequence->chroma_height) {
imgfmt = IMGFMT_422P;
} else return 0;
if (imgfmt == context->imgfmt &&
info->sequence->picture_width == context->width &&
info->sequence->picture_height == context->height &&
sh->aspect == context->aspect)
break;
if(!mpcodecs_config_vo(sh,
info->sequence->picture_width,
info->sequence->picture_height, imgfmt))
return 0;
context->imgfmt = imgfmt;
context->width = info->sequence->picture_width;
context->height = info->sequence->picture_height;
context->aspect = sh->aspect;
break;
case STATE_PICTURE:
type=info->current_picture->flags&PIC_MASK_CODING_TYPE;
drop_frame = framedrop && (mpeg2dec->decoder.coding_type == B_TYPE);
drop_frame |= framedrop>=2; // hard drop
if (drop_frame) {
mpeg2_skip(mpeg2dec, 1);
//printf("Dropping Frame ...\n");
break;
}
mpeg2_skip(mpeg2dec, 0); //mpeg2skip skips frames until set again to 0
use_callback = (!framedrop && sh->opts->vd_use_slices &&
(info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME)) ?
MP_IMGFLAG_DRAW_CALLBACK:0;
// get_buffer "callback":
mpi_new=mpcodecs_get_image(sh,MP_IMGTYPE_IPB,
(type==PIC_FLAG_CODING_TYPE_B) ?
use_callback : (MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE),
info->sequence->width,
info->sequence->height);
if(!mpi_new) return 0; // VO ERROR!!!!!!!!
mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new);
mpi_new->stride[0] = info->sequence->width;
mpi_new->stride[1] = info->sequence->chroma_width;
mpi_new->stride[2] = info->sequence->chroma_width;
if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST)
mpi_new->fields |= MP_IMGFIELD_TOP_FIRST;
else mpi_new->fields &= ~MP_IMGFIELD_TOP_FIRST;
if (info->current_picture->flags&PIC_FLAG_REPEAT_FIRST_FIELD)
mpi_new->fields |= MP_IMGFIELD_REPEAT_FIRST;
else mpi_new->fields &= ~MP_IMGFIELD_REPEAT_FIRST;
mpi_new->fields |= MP_IMGFIELD_ORDERED;
if (!(info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME))
mpi_new->fields |= MP_IMGFIELD_INTERLACED;
#ifdef MPEG12_POSTPROC
mpi_new->qstride=info->sequence->width>>4;
{
char **p = &context->quant_store[type==PIC_FLAG_CODING_TYPE_B ?
2 : (context->quant_store_idx ^= 1)];
*p = realloc(*p, mpi_new->qstride*(info->sequence->height>>4));
mpi_new->qscale = *p;
}
mpeg2dec->decoder.quant_store=mpi_new->qscale;
mpeg2dec->decoder.quant_stride=mpi_new->qstride;
mpi_new->pict_type=type; // 1->I, 2->P, 3->B
mpi_new->qscale_type= 1;
#endif
if (mpi_new->flags&MP_IMGFLAG_DRAW_CALLBACK
&& !(mpi_new->flags&MP_IMGFLAG_DIRECT)) {
// nice, filter/vo likes draw_callback :)
mpeg2dec->decoder.convert=draw_slice;
mpeg2dec->decoder.convert_id=sh;
} else {
mpeg2dec->decoder.convert=NULL;
mpeg2dec->decoder.convert_id=NULL;
}
break;
case STATE_SLICE:
case STATE_END:
case STATE_INVALID_END:
// decoding done:
if(info->display_fbuf) {
mp_image_t* mpi = info->display_fbuf->id;
if (mpeg2dec->pending_length == 0) {
mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length);
memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
} else {
// still some data in the pending buffer, shouldn't happen
mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
memmove(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length);
mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length + len);
memcpy(mpeg2dec->pending_buffer+mpeg2dec->pending_length, data, len);
mpeg2dec->pending_length += len;
}
// fprintf(stderr, "pending = %d\n", mpeg2dec->pending_length);
return mpi;
}
}
}
}

View File

@ -1,70 +0,0 @@
/*
* alloc.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include <inttypes.h>
#include "mpeg2.h"
static void * (* malloc_hook) (unsigned size, mpeg2_alloc_t reason) = NULL;
static int (* free_hook) (void * buf) = NULL;
void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason)
{
char * buf;
if (malloc_hook) {
buf = (char *) malloc_hook (size, reason);
if (buf)
return buf;
}
if (size) {
buf = (char *) malloc (size + 63 + sizeof (void **));
if (buf) {
char * align_buf;
align_buf = buf + 63 + sizeof (void **);
align_buf -= (long)align_buf & 63;
*(((void **)align_buf) - 1) = buf;
return align_buf;
}
}
return NULL;
}
void mpeg2_free (void * buf)
{
if (free_hook && free_hook (buf))
return;
if (buf)
free (*(((void **)buf) - 1));
}
void mpeg2_malloc_hooks (void * alloc_func (unsigned, mpeg2_alloc_t),
int free_func (void *))
{
malloc_hook = alloc_func;
free_hook = free_func;
}

View File

@ -1,181 +0,0 @@
/*
* Alpha assembly macros
* Copyright (c) 2002-2003 Falk Hueffner <falk@debian.org>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LIBMPEG2_ALPHA_ASM_H
#define LIBMPEG2_ALPHA_ASM_H
#include <inttypes.h>
#if defined __GNUC__
# define GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define GNUC_PREREQ(maj, min) 0
#endif
#define AMASK_BWX (1 << 0)
#define AMASK_FIX (1 << 1)
#define AMASK_CIX (1 << 2)
#define AMASK_MVI (1 << 8)
#ifdef __alpha_bwx__
# define HAVE_BWX() 1
#else
# define HAVE_BWX() (amask(AMASK_BWX) == 0)
#endif
#ifdef __alpha_fix__
# define HAVE_FIX() 1
#else
# define HAVE_FIX() (amask(AMASK_FIX) == 0)
#endif
#ifdef __alpha_max__
# define HAVE_MVI() 1
#else
# define HAVE_MVI() (amask(AMASK_MVI) == 0)
#endif
#ifdef __alpha_cix__
# define HAVE_CIX() 1
#else
# define HAVE_CIX() (amask(AMASK_CIX) == 0)
#endif
inline static uint64_t BYTE_VEC(uint64_t x)
{
x |= x << 8;
x |= x << 16;
x |= x << 32;
return x;
}
inline static uint64_t WORD_VEC(uint64_t x)
{
x |= x << 16;
x |= x << 32;
return x;
}
#define ldq(p) (*(const uint64_t *) (p))
#define ldl(p) (*(const int32_t *) (p))
#define stl(l, p) do { *(uint32_t *) (p) = (l); } while (0)
#define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0)
#define sextw(x) ((int16_t) (x))
#ifdef __GNUC__
struct unaligned_long { uint64_t l; } __attribute__((packed));
#define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul))
#define uldq(a) (((const struct unaligned_long *) (a))->l)
#if GNUC_PREREQ(3,3)
#define prefetch(p) __builtin_prefetch((p), 0, 1)
#define prefetch_en(p) __builtin_prefetch((p), 0, 0)
#define prefetch_m(p) __builtin_prefetch((p), 1, 1)
#define prefetch_men(p) __builtin_prefetch((p), 1, 0)
#define cmpbge __builtin_alpha_cmpbge
/* Avoid warnings. */
#define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b))
#define extwl(a, b) __builtin_alpha_extwl(a, (uint64_t) (b))
#define extqh(a, b) __builtin_alpha_extqh(a, (uint64_t) (b))
#define zap __builtin_alpha_zap
#define zapnot __builtin_alpha_zapnot
#define amask __builtin_alpha_amask
#define implver __builtin_alpha_implver
#define rpcc __builtin_alpha_rpcc
#else
#define prefetch(p) asm volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory")
#define prefetch_en(p) asm volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory")
#define prefetch_m(p) asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory")
#define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory")
#define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
#define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
#define extwl(a, b) ({ uint64_t __r; asm ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
#define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
#define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
#define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
#define amask(a) ({ uint64_t __r; asm ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; })
#define implver() ({ uint64_t __r; asm ("implver %0" : "=r" (__r)); __r; })
#define rpcc() ({ uint64_t __r; asm volatile ("rpcc %0" : "=r" (__r)); __r; })
#endif
#define wh64(p) asm volatile("wh64 (%0)" : : "r"(p) : "memory")
#if GNUC_PREREQ(3,3) && defined(__alpha_max__)
#define minub8 __builtin_alpha_minub8
#define minsb8 __builtin_alpha_minsb8
#define minuw4 __builtin_alpha_minuw4
#define minsw4 __builtin_alpha_minsw4
#define maxub8 __builtin_alpha_maxub8
#define maxsb8 __builtin_alpha_maxsb8
#define maxuw4 __builtin_alpha_maxuw4
#define maxsw4 __builtin_alpha_maxsw4
#define perr __builtin_alpha_perr
#define pklb __builtin_alpha_pklb
#define pkwb __builtin_alpha_pkwb
#define unpkbl __builtin_alpha_unpkbl
#define unpkbw __builtin_alpha_unpkbw
#else
#define minub8(a, b) ({ uint64_t __r; asm (".arch ev6; minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define minsb8(a, b) ({ uint64_t __r; asm (".arch ev6; minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define minuw4(a, b) ({ uint64_t __r; asm (".arch ev6; minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define minsw4(a, b) ({ uint64_t __r; asm (".arch ev6; minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define maxub8(a, b) ({ uint64_t __r; asm (".arch ev6; maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define maxsb8(a, b) ({ uint64_t __r; asm (".arch ev6; maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define maxuw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define maxsw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
#define perr(a, b) ({ uint64_t __r; asm (".arch ev6; perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
#define pklb(a) ({ uint64_t __r; asm (".arch ev6; pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
#define pkwb(a) ({ uint64_t __r; asm (".arch ev6; pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
#define unpkbl(a) ({ uint64_t __r; asm (".arch ev6; unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
#define unpkbw(a) ({ uint64_t __r; asm (".arch ev6; unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
#endif
#elif defined(__DECC) /* Digital/Compaq/hp "ccc" compiler */
#include <c_asm.h>
#define ldq_u(a) asm ("ldq_u %v0,0(%a0)", a)
#define uldq(a) (*(const __unaligned uint64_t *) (a))
#define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b)
#define extql(a, b) asm ("extql %a0,%a1,%v0", a, b)
#define extwl(a, b) asm ("extwl %a0,%a1,%v0", a, b)
#define extqh(a, b) asm ("extqh %a0,%a1,%v0", a, b)
#define zap(a, b) asm ("zap %a0,%a1,%v0", a, b)
#define zapnot(a, b) asm ("zapnot %a0,%a1,%v0", a, b)
#define amask(a) asm ("amask %a0,%v0", a)
#define implver() asm ("implver %v0")
#define rpcc() asm ("rpcc %v0")
#define minub8(a, b) asm ("minub8 %a0,%a1,%v0", a, b)
#define minsb8(a, b) asm ("minsb8 %a0,%a1,%v0", a, b)
#define minuw4(a, b) asm ("minuw4 %a0,%a1,%v0", a, b)
#define minsw4(a, b) asm ("minsw4 %a0,%a1,%v0", a, b)
#define maxub8(a, b) asm ("maxub8 %a0,%a1,%v0", a, b)
#define maxsb8(a, b) asm ("maxsb8 %a0,%a1,%v0", a, b)
#define maxuw4(a, b) asm ("maxuw4 %a0,%a1,%v0", a, b)
#define maxsw4(a, b) asm ("maxsw4 %a0,%a1,%v0", a, b)
#define perr(a, b) asm ("perr %a0,%a1,%v0", a, b)
#define pklb(a) asm ("pklb %a0,%v0", a)
#define pkwb(a) asm ("pkwb %a0,%v0", a)
#define unpkbl(a) asm ("unpkbl %a0,%v0", a)
#define unpkbw(a) asm ("unpkbw %a0,%v0", a)
#define wh64(a) asm ("wh64 %a0", a)
#else
#error "Unknown compiler!"
#endif
#endif /* LIBMPEG2_ALPHA_ASM_H */

View File

@ -1,42 +0,0 @@
/*
* attributes.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LIBMPEG2_ATTRIBUTES_H
#define LIBMPEG2_ATTRIBUTES_H
/* use gcc attribs to align critical data structures */
#ifdef ATTRIBUTE_ALIGNED_MAX
#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
#else
#define ATTR_ALIGN(align)
#endif
#ifdef HAVE_BUILTIN_EXPECT
#define likely(x) __builtin_expect ((x) != 0, 1)
#define unlikely(x) __builtin_expect ((x) != 0, 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#endif /* LIBMPEG2_ATTRIBUTES_H */

View File

@ -1,283 +0,0 @@
/*
* cpu_accel.c
* Copyright (C) 2000-2004 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#include "config.h"
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#include "cpudetect.h"
#if ARCH_X86 || ARCH_X86_64
static inline uint32_t arch_accel (uint32_t accel)
{
/* Use MPlayer CPU detection instead of libmpeg2 variant. */
#if 0
if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
accel |= MPEG2_ACCEL_X86_MMX;
if (accel & (MPEG2_ACCEL_X86_SSE2 | MPEG2_ACCEL_X86_SSE3))
accel |= MPEG2_ACCEL_X86_MMXEXT;
if (accel & (MPEG2_ACCEL_X86_SSE3))
accel |= MPEG2_ACCEL_X86_SSE2;
#ifdef ACCEL_DETECT
if (accel & MPEG2_ACCEL_DETECT) {
uint32_t eax, ebx, ecx, edx;
int AMD;
#if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__))
#define cpuid(op,eax,ebx,ecx,edx) \
__asm__ ("cpuid" \
: "=a" (eax), \
"=b" (ebx), \
"=c" (ecx), \
"=d" (edx) \
: "a" (op) \
: "cc")
#else /* PIC version : save ebx (not needed on x86_64) */
#define cpuid(op,eax,ebx,ecx,edx) \
__asm__ ("pushl %%ebx\n\t" \
"cpuid\n\t" \
"movl %%ebx,%1\n\t" \
"popl %%ebx" \
: "=a" (eax), \
"=r" (ebx), \
"=c" (ecx), \
"=d" (edx) \
: "a" (op) \
: "cc")
#endif
#ifndef __x86_64__ /* x86_64 supports the cpuid op */
__asm__ ("pushf\n\t"
"pushf\n\t"
"pop %0\n\t"
"movl %0,%1\n\t"
"xorl $0x200000,%0\n\t"
"push %0\n\t"
"popf\n\t"
"pushf\n\t"
"pop %0\n\t"
"popf"
: "=r" (eax),
"=r" (ebx)
:
: "cc");
if (eax == ebx) /* no cpuid */
return accel;
#endif
cpuid (0x00000000, eax, ebx, ecx, edx);
if (!eax) /* vendor string only */
return accel;
AMD = (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65);
cpuid (0x00000001, eax, ebx, ecx, edx);
if (! (edx & 0x00800000)) /* no MMX */
return accel;
accel |= MPEG2_ACCEL_X86_MMX;
if (edx & 0x02000000) /* SSE - identical to AMD MMX ext. */
accel |= MPEG2_ACCEL_X86_MMXEXT;
if (edx & 0x04000000) /* SSE2 */
accel |= MPEG2_ACCEL_X86_SSE2;
if (ecx & 0x00000001) /* SSE3 */
accel |= MPEG2_ACCEL_X86_SSE3;
cpuid (0x80000000, eax, ebx, ecx, edx);
if (eax < 0x80000001) /* no extended capabilities */
return accel;
cpuid (0x80000001, eax, ebx, ecx, edx);
if (edx & 0x80000000)
accel |= MPEG2_ACCEL_X86_3DNOW;
if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
accel |= MPEG2_ACCEL_X86_MMXEXT;
}
#endif /* ACCEL_DETECT */
return accel;
#else /* 0 */
accel = 0;
if (gCpuCaps.hasMMX)
accel |= MPEG2_ACCEL_X86_MMX;
if (gCpuCaps.hasSSE2)
accel |= MPEG2_ACCEL_X86_SSE2;
if (gCpuCaps.hasMMX2)
accel |= MPEG2_ACCEL_X86_MMXEXT;
if (gCpuCaps.has3DNow)
accel |= MPEG2_ACCEL_X86_3DNOW;
return accel;
#endif /* 0 */
}
#endif /* ARCH_X86 || ARCH_X86_64 */
#if defined(ACCEL_DETECT) && (ARCH_PPC || ARCH_SPARC)
#include <signal.h>
#include <setjmp.h>
static sigjmp_buf jmpbuf;
static volatile sig_atomic_t canjump = 0;
static RETSIGTYPE sigill_handler (int sig)
{
if (!canjump) {
signal (sig, SIG_DFL);
raise (sig);
}
canjump = 0;
siglongjmp (jmpbuf, 1);
}
#endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */
#if ARCH_PPC
static uint32_t arch_accel (uint32_t accel)
{
#ifdef ACCEL_DETECT
if ((accel & (MPEG2_ACCEL_PPC_ALTIVEC | MPEG2_ACCEL_DETECT)) ==
MPEG2_ACCEL_DETECT) {
static RETSIGTYPE (* oldsig) (int);
oldsig = signal (SIGILL, sigill_handler);
if (sigsetjmp (jmpbuf, 1)) {
signal (SIGILL, oldsig);
return accel;
}
canjump = 1;
#if defined(__APPLE_CC__) /* apple */
#define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
#else /* gnu */
#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
#endif
asm volatile ("mtspr 256, %0\n\t"
VAND (0, 0, 0)
:
: "r" (-1));
canjump = 0;
accel |= MPEG2_ACCEL_PPC_ALTIVEC;
signal (SIGILL, oldsig);
}
#endif /* ACCEL_DETECT */
return accel;
}
#endif /* ARCH_PPC */
#if ARCH_SPARC
static uint32_t arch_accel (uint32_t accel)
{
if (accel & MPEG2_ACCEL_SPARC_VIS2)
accel |= MPEG2_ACCEL_SPARC_VIS;
#ifdef ACCEL_DETECT
if ((accel & (MPEG2_ACCEL_SPARC_VIS2 | MPEG2_ACCEL_DETECT)) ==
MPEG2_ACCEL_DETECT) {
static RETSIGTYPE (* oldsig) (int);
oldsig = signal (SIGILL, sigill_handler);
if (sigsetjmp (jmpbuf, 1)) {
signal (SIGILL, oldsig);
return accel;
}
canjump = 1;
/* pdist %f0, %f0, %f0 */
__asm__ __volatile__(".word\t0x81b007c0");
canjump = 0;
accel |= MPEG2_ACCEL_SPARC_VIS;
if (sigsetjmp (jmpbuf, 1)) {
signal (SIGILL, oldsig);
return accel;
}
canjump = 1;
/* edge8n %g0, %g0, %g0 */
__asm__ __volatile__(".word\t0x81b00020");
canjump = 0;
accel |= MPEG2_ACCEL_SPARC_VIS2;
signal (SIGILL, oldsig);
}
#endif /* ACCEL_DETECT */
return accel;
}
#endif /* ARCH_SPARC */
#if ARCH_ALPHA
static inline uint32_t arch_accel (uint32_t accel)
{
if (accel & MPEG2_ACCEL_ALPHA_MVI)
accel |= MPEG2_ACCEL_ALPHA;
#ifdef ACCEL_DETECT
if (accel & MPEG2_ACCEL_DETECT) {
uint64_t no_mvi;
asm volatile ("amask %1, %0"
: "=r" (no_mvi)
: "rI" (256)); /* AMASK_MVI */
accel |= no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
MPEG2_ACCEL_ALPHA_MVI);
}
#endif /* ACCEL_DETECT */
return accel;
}
#endif /* ARCH_ALPHA */
uint32_t mpeg2_detect_accel (uint32_t accel)
{
#if ARCH_X86 || ARCH_X86_64 || ARCH_PPC || ARCH_ALPHA || ARCH_SPARC
accel = arch_accel (accel);
#endif
return accel;
}

View File

@ -1,129 +0,0 @@
/*
* cpu_state.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdlib.h>
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#if ARCH_X86 || ARCH_X86_64
#include "mmx.h"
#endif
void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
#if ARCH_X86 || ARCH_X86_64
static void state_restore_mmx (cpu_state_t * state)
{
emms ();
}
#endif
#if ARCH_PPC
#if defined(__APPLE_CC__) /* apple */
#define LI(a,b) "li r" #a "," #b "\n\t"
#define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
#define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t"
#define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t"
#define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t"
#else /* gnu */
#define LI(a,b) "li " #a "," #b "\n\t"
#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
#endif
static void state_save_altivec (cpu_state_t * state)
{
asm (LI (9, 16)
STVX0 (20, 0, 3)
LI (11, 32)
STVX (21, 9, 3)
LI (9, 48)
STVX (22, 11, 3)
LI (11, 64)
STVX (23, 9, 3)
LI (9, 80)
STVX (24, 11, 3)
LI (11, 96)
STVX (25, 9, 3)
LI (9, 112)
STVX (26, 11, 3)
LI (11, 128)
STVX (27, 9, 3)
LI (9, 144)
STVX (28, 11, 3)
LI (11, 160)
STVX (29, 9, 3)
LI (9, 176)
STVX (30, 11, 3)
STVX (31, 9, 3));
}
static void state_restore_altivec (cpu_state_t * state)
{
asm (LI (9, 16)
LVX0 (20, 0, 3)
LI (11, 32)
LVX (21, 9, 3)
LI (9, 48)
LVX (22, 11, 3)
LI (11, 64)
LVX (23, 9, 3)
LI (9, 80)
LVX (24, 11, 3)
LI (11, 96)
LVX (25, 9, 3)
LI (9, 112)
LVX (26, 11, 3)
LI (11, 128)
LVX (27, 9, 3)
LI (9, 144)
LVX (28, 11, 3)
LI (11, 160)
LVX (29, 9, 3)
LI (9, 176)
LVX (30, 11, 3)
LVX (31, 9, 3));
}
#endif
void mpeg2_cpu_state_init (uint32_t accel)
{
#if ARCH_X86 || ARCH_X86_64
if (accel & MPEG2_ACCEL_X86_MMX) {
mpeg2_cpu_state_restore = state_restore_mmx;
}
#endif
#if ARCH_PPC
if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
mpeg2_cpu_state_save = state_save_altivec;
mpeg2_cpu_state_restore = state_restore_altivec;
}
#endif
}

View File

@ -1,452 +0,0 @@
/*
* decode.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#include "config.h"
#include <string.h> /* memcmp/memset, try to remove */
#include <stdlib.h>
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
static int mpeg2_accels = 0;
#define BUFFER_SIZE (1194 * 1024)
const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec)
{
return &(mpeg2dec->info);
}
static inline int skip_chunk (mpeg2dec_t * mpeg2dec, int bytes)
{
uint8_t * current;
uint32_t shift;
uint8_t * limit;
uint8_t byte;
if (!bytes)
return 0;
current = mpeg2dec->buf_start;
shift = mpeg2dec->shift;
limit = current + bytes;
do {
byte = *current++;
if (shift == 0x00000100) {
int skipped;
mpeg2dec->shift = 0xffffff00;
skipped = current - mpeg2dec->buf_start;
mpeg2dec->buf_start = current;
return skipped;
}
shift = (shift | byte) << 8;
} while (current < limit);
mpeg2dec->shift = shift;
mpeg2dec->buf_start = current;
return 0;
}
static inline int copy_chunk (mpeg2dec_t * mpeg2dec, int bytes)
{
uint8_t * current;
uint32_t shift;
uint8_t * chunk_ptr;
uint8_t * limit;
uint8_t byte;
if (!bytes)
return 0;
current = mpeg2dec->buf_start;
shift = mpeg2dec->shift;
chunk_ptr = mpeg2dec->chunk_ptr;
limit = current + bytes;
do {
byte = *current++;
if (shift == 0x00000100) {
int copied;
mpeg2dec->shift = 0xffffff00;
mpeg2dec->chunk_ptr = chunk_ptr + 1;
copied = current - mpeg2dec->buf_start;
mpeg2dec->buf_start = current;
return copied;
}
shift = (shift | byte) << 8;
*chunk_ptr++ = byte;
} while (current < limit);
mpeg2dec->shift = shift;
mpeg2dec->buf_start = current;
return 0;
}
void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end)
{
mpeg2dec->buf_start = start;
mpeg2dec->buf_end = end;
}
int mpeg2_getpos (mpeg2dec_t * mpeg2dec)
{
return mpeg2dec->buf_end - mpeg2dec->buf_start;
}
static inline mpeg2_state_t seek_chunk (mpeg2dec_t * mpeg2dec)
{
int size, skipped;
size = mpeg2dec->buf_end - mpeg2dec->buf_start;
skipped = skip_chunk (mpeg2dec, size);
if (!skipped) {
mpeg2dec->bytes_since_tag += size;
return STATE_BUFFER;
}
mpeg2dec->bytes_since_tag += skipped;
mpeg2dec->code = mpeg2dec->buf_start[-1];
return STATE_INTERNAL_NORETURN;
}
mpeg2_state_t mpeg2_seek_header (mpeg2dec_t * mpeg2dec)
{
while (!(mpeg2dec->code == 0xb3 ||
((mpeg2dec->code == 0xb7 || mpeg2dec->code == 0xb8 ||
!mpeg2dec->code) && mpeg2dec->sequence.width != (unsigned)-1)))
if (seek_chunk (mpeg2dec) == STATE_BUFFER)
return STATE_BUFFER;
mpeg2dec->chunk_start = mpeg2dec->chunk_ptr = mpeg2dec->chunk_buffer;
mpeg2dec->user_data_len = 0;
return ((mpeg2dec->code == 0xb7) ?
mpeg2_header_end (mpeg2dec) : mpeg2_parse_header (mpeg2dec));
}
#define RECEIVED(code,state) (((state) << 8) + (code))
mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec)
{
int size_buffer, size_chunk, copied;
if (mpeg2dec->action) {
mpeg2_state_t state;
state = mpeg2dec->action (mpeg2dec);
if ((int)state > (int)STATE_INTERNAL_NORETURN)
return state;
}
while (1) {
while ((unsigned) (mpeg2dec->code - mpeg2dec->first_decode_slice) <
mpeg2dec->nb_decode_slices) {
size_buffer = mpeg2dec->buf_end - mpeg2dec->buf_start;
size_chunk = (mpeg2dec->chunk_buffer + BUFFER_SIZE -
mpeg2dec->chunk_ptr);
if (size_buffer <= size_chunk) {
copied = copy_chunk (mpeg2dec, size_buffer);
if (!copied) {
mpeg2dec->bytes_since_tag += size_buffer;
mpeg2dec->chunk_ptr += size_buffer;
return STATE_BUFFER;
}
} else {
copied = copy_chunk (mpeg2dec, size_chunk);
if (!copied) {
/* filled the chunk buffer without finding a start code */
mpeg2dec->bytes_since_tag += size_chunk;
mpeg2dec->action = seek_chunk;
return STATE_INVALID;
}
}
mpeg2dec->bytes_since_tag += copied;
mpeg2_slice (&(mpeg2dec->decoder), mpeg2dec->code,
mpeg2dec->chunk_start);
mpeg2dec->code = mpeg2dec->buf_start[-1];
mpeg2dec->chunk_ptr = mpeg2dec->chunk_start;
}
if ((unsigned) (mpeg2dec->code - 1) >= 0xb0 - 1)
break;
if (seek_chunk (mpeg2dec) == STATE_BUFFER)
return STATE_BUFFER;
}
mpeg2dec->action = mpeg2_seek_header;
switch (mpeg2dec->code) {
case 0x00:
return mpeg2dec->state;
case 0xb3:
case 0xb7:
case 0xb8:
return (mpeg2dec->state == STATE_SLICE) ? STATE_SLICE : STATE_INVALID;
default:
mpeg2dec->action = seek_chunk;
return STATE_INVALID;
}
}
mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec)
{
static int (* process_header[]) (mpeg2dec_t * mpeg2dec) = {
mpeg2_header_picture, mpeg2_header_extension, mpeg2_header_user_data,
mpeg2_header_sequence, NULL, NULL, NULL, NULL, mpeg2_header_gop
};
int size_buffer, size_chunk, copied;
mpeg2dec->action = mpeg2_parse_header;
mpeg2dec->info.user_data = NULL; mpeg2dec->info.user_data_len = 0;
while (1) {
size_buffer = mpeg2dec->buf_end - mpeg2dec->buf_start;
size_chunk = (mpeg2dec->chunk_buffer + BUFFER_SIZE -
mpeg2dec->chunk_ptr);
if (size_buffer <= size_chunk) {
copied = copy_chunk (mpeg2dec, size_buffer);
if (!copied) {
mpeg2dec->bytes_since_tag += size_buffer;
mpeg2dec->chunk_ptr += size_buffer;
return STATE_BUFFER;
}
} else {
copied = copy_chunk (mpeg2dec, size_chunk);
if (!copied) {
/* filled the chunk buffer without finding a start code */
mpeg2dec->bytes_since_tag += size_chunk;
mpeg2dec->code = 0xb4;
mpeg2dec->action = mpeg2_seek_header;
return STATE_INVALID;
}
}
mpeg2dec->bytes_since_tag += copied;
if (process_header[mpeg2dec->code & 0x0b] (mpeg2dec)) {
mpeg2dec->code = mpeg2dec->buf_start[-1];
mpeg2dec->action = mpeg2_seek_header;
return STATE_INVALID;
}
mpeg2dec->code = mpeg2dec->buf_start[-1];
switch (RECEIVED (mpeg2dec->code, mpeg2dec->state)) {
/* state transition after a sequence header */
case RECEIVED (0x00, STATE_SEQUENCE):
case RECEIVED (0xb8, STATE_SEQUENCE):
mpeg2_header_sequence_finalize (mpeg2dec);
break;
/* other legal state transitions */
case RECEIVED (0x00, STATE_GOP):
mpeg2_header_gop_finalize (mpeg2dec);
break;
case RECEIVED (0x01, STATE_PICTURE):
case RECEIVED (0x01, STATE_PICTURE_2ND):
mpeg2_header_picture_finalize (mpeg2dec, mpeg2_accels);
mpeg2dec->action = mpeg2_header_slice_start;
break;
/* legal headers within a given state */
case RECEIVED (0xb2, STATE_SEQUENCE):
case RECEIVED (0xb2, STATE_GOP):
case RECEIVED (0xb2, STATE_PICTURE):
case RECEIVED (0xb2, STATE_PICTURE_2ND):
case RECEIVED (0xb5, STATE_SEQUENCE):
case RECEIVED (0xb5, STATE_PICTURE):
case RECEIVED (0xb5, STATE_PICTURE_2ND):
mpeg2dec->chunk_ptr = mpeg2dec->chunk_start;
continue;
default:
mpeg2dec->action = mpeg2_seek_header;
return STATE_INVALID;
}
mpeg2dec->chunk_start = mpeg2dec->chunk_ptr = mpeg2dec->chunk_buffer;
mpeg2dec->user_data_len = 0;
return mpeg2dec->state;
}
}
int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg)
{
mpeg2_convert_init_t convert_init;
int error;
error = convert (MPEG2_CONVERT_SET, NULL, &(mpeg2dec->sequence), 0,
mpeg2_accels, arg, &convert_init);
if (!error) {
mpeg2dec->convert = convert;
mpeg2dec->convert_arg = arg;
mpeg2dec->convert_id_size = convert_init.id_size;
mpeg2dec->convert_stride = 0;
}
return error;
}
int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride)
{
if (!mpeg2dec->convert) {
if (stride < (int) mpeg2dec->sequence.width)
stride = mpeg2dec->sequence.width;
mpeg2dec->decoder.stride_frame = stride;
} else {
mpeg2_convert_init_t convert_init;
stride = mpeg2dec->convert (MPEG2_CONVERT_STRIDE, NULL,
&(mpeg2dec->sequence), stride,
mpeg2_accels, mpeg2dec->convert_arg,
&convert_init);
mpeg2dec->convert_id_size = convert_init.id_size;
mpeg2dec->convert_stride = stride;
}
return stride;
}
void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id)
{
mpeg2_fbuf_t * fbuf;
if (mpeg2dec->custom_fbuf) {
if (mpeg2dec->state == STATE_SEQUENCE) {
mpeg2dec->fbuf[2] = mpeg2dec->fbuf[1];
mpeg2dec->fbuf[1] = mpeg2dec->fbuf[0];
}
mpeg2_set_fbuf (mpeg2dec, (mpeg2dec->decoder.coding_type ==
PIC_FLAG_CODING_TYPE_B));
fbuf = mpeg2dec->fbuf[0];
} else {
fbuf = &(mpeg2dec->fbuf_alloc[mpeg2dec->alloc_index].fbuf);
mpeg2dec->alloc_index_user = ++mpeg2dec->alloc_index;
}
fbuf->buf[0] = buf[0];
fbuf->buf[1] = buf[1];
fbuf->buf[2] = buf[2];
fbuf->id = id;
// HACK! FIXME! At first I frame, copy pointers to prediction frame too!
if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
mpeg2dec->fbuf[1]->buf[0]=buf[0];
mpeg2dec->fbuf[1]->buf[1]=buf[1];
mpeg2dec->fbuf[1]->buf[2]=buf[2];
mpeg2dec->fbuf[1]->id=NULL;
}
// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
}
void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
{
mpeg2dec->custom_fbuf = custom_fbuf;
}
void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip)
{
mpeg2dec->first_decode_slice = 1;
mpeg2dec->nb_decode_slices = skip ? 0 : (0xb0 - 1);
}
void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end)
{
start = (start < 1) ? 1 : (start > 0xb0) ? 0xb0 : start;
end = (end < start) ? start : (end > 0xb0) ? 0xb0 : end;
mpeg2dec->first_decode_slice = start;
mpeg2dec->nb_decode_slices = end - start;
}
void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2)
{
mpeg2dec->tag_previous = mpeg2dec->tag_current;
mpeg2dec->tag2_previous = mpeg2dec->tag2_current;
mpeg2dec->tag_current = tag;
mpeg2dec->tag2_current = tag2;
mpeg2dec->num_tags++;
mpeg2dec->bytes_since_tag = 0;
}
uint32_t mpeg2_accel (uint32_t accel)
{
if (!mpeg2_accels) {
mpeg2_accels = mpeg2_detect_accel (accel) | MPEG2_ACCEL_DETECT;
mpeg2_cpu_state_init (mpeg2_accels);
mpeg2_idct_init (mpeg2_accels);
mpeg2_mc_init (mpeg2_accels);
}
return mpeg2_accels & ~MPEG2_ACCEL_DETECT;
}
void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset)
{
mpeg2dec->buf_start = mpeg2dec->buf_end = NULL;
mpeg2dec->num_tags = 0;
mpeg2dec->shift = 0xffffff00;
mpeg2dec->code = 0xb4;
mpeg2dec->action = mpeg2_seek_header;
mpeg2dec->state = STATE_INVALID;
mpeg2dec->first = 1;
mpeg2_reset_info(&(mpeg2dec->info));
mpeg2dec->info.gop = NULL;
mpeg2dec->info.user_data = NULL;
mpeg2dec->info.user_data_len = 0;
if (full_reset) {
mpeg2dec->info.sequence = NULL;
mpeg2_header_state_init (mpeg2dec);
}
}
mpeg2dec_t * mpeg2_init (void)
{
mpeg2dec_t * mpeg2dec;
mpeg2_accel (MPEG2_ACCEL_DETECT);
mpeg2dec = (mpeg2dec_t *) mpeg2_malloc (sizeof (mpeg2dec_t),
MPEG2_ALLOC_MPEG2DEC);
if (mpeg2dec == NULL)
return NULL;
memset (mpeg2dec->decoder.DCTblock, 0, 64 * sizeof (int16_t));
memset (mpeg2dec->quantizer_matrix, 0, 4 * 64 * sizeof (uint8_t));
mpeg2dec->chunk_buffer = (uint8_t *) mpeg2_malloc (BUFFER_SIZE + 4,
MPEG2_ALLOC_CHUNK);
mpeg2dec->sequence.width = (unsigned)-1;
mpeg2_reset (mpeg2dec, 1);
return mpeg2dec;
}
void mpeg2_close (mpeg2dec_t * mpeg2dec)
{
mpeg2_header_state_init (mpeg2dec);
mpeg2_free (mpeg2dec->chunk_buffer);
mpeg2_free (mpeg2dec);
}

View File

@ -1,972 +0,0 @@
/*
* header.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 2003 Regis Duchesne <hpreg@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#include "config.h"
#include <inttypes.h>
#include <stdlib.h> /* defines NULL */
#include <string.h> /* memcmp */
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#define SEQ_EXT 2
#define SEQ_DISPLAY_EXT 4
#define QUANT_MATRIX_EXT 8
#define COPYRIGHT_EXT 0x10
#define PIC_DISPLAY_EXT 0x80
#define PIC_CODING_EXT 0x100
/* default intra quant matrix, in zig-zag order */
static const uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = {
8,
16, 16,
19, 16, 19,
22, 22, 22, 22,
22, 22, 26, 24, 26,
27, 27, 27, 26, 26, 26,
26, 27, 27, 27, 29, 29, 29,
34, 34, 34, 29, 29, 29, 27, 27,
29, 29, 32, 32, 34, 34, 37,
38, 37, 35, 35, 34, 35,
38, 38, 40, 40, 40,
48, 48, 46, 46,
56, 56, 58,
69, 69,
83
};
uint8_t mpeg2_scan_norm[64] ATTR_ALIGN(16) = {
/* Zig-Zag scan pattern */
0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
};
uint8_t mpeg2_scan_alt[64] ATTR_ALIGN(16) = {
/* Alternate scan pattern */
0, 8, 16, 24, 1, 9, 2, 10, 17, 25, 32, 40, 48, 56, 57, 49,
41, 33, 26, 18, 3, 11, 4, 12, 19, 27, 34, 42, 50, 58, 35, 43,
51, 59, 20, 28, 5, 13, 6, 14, 21, 29, 36, 44, 52, 60, 37, 45,
53, 61, 22, 30, 7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63
};
void mpeg2_header_state_init (mpeg2dec_t * mpeg2dec)
{
if (mpeg2dec->sequence.width != (unsigned)-1) {
int i;
mpeg2dec->sequence.width = (unsigned)-1;
if (!mpeg2dec->custom_fbuf)
for (i = mpeg2dec->alloc_index_user;
i < mpeg2dec->alloc_index; i++) {
mpeg2_free (mpeg2dec->fbuf_alloc[i].fbuf.buf[0]);
mpeg2_free (mpeg2dec->fbuf_alloc[i].fbuf.buf[1]);
mpeg2_free (mpeg2dec->fbuf_alloc[i].fbuf.buf[2]);
}
if (mpeg2dec->convert_start)
for (i = 0; i < 3; i++) {
mpeg2_free (mpeg2dec->yuv_buf[i][0]);
mpeg2_free (mpeg2dec->yuv_buf[i][1]);
mpeg2_free (mpeg2dec->yuv_buf[i][2]);
}
if (mpeg2dec->decoder.convert_id)
mpeg2_free (mpeg2dec->decoder.convert_id);
}
mpeg2dec->decoder.coding_type = I_TYPE;
mpeg2dec->decoder.convert = NULL;
mpeg2dec->decoder.convert_id = NULL;
mpeg2dec->picture = mpeg2dec->pictures;
memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
mpeg2dec->first = 1;
mpeg2dec->alloc_index = 0;
mpeg2dec->alloc_index_user = 0;
mpeg2dec->first_decode_slice = 1;
mpeg2dec->nb_decode_slices = 0xb0 - 1;
mpeg2dec->convert = NULL;
mpeg2dec->convert_start = NULL;
mpeg2dec->custom_fbuf = 0;
mpeg2dec->yuv_index = 0;
}
void mpeg2_reset_info (mpeg2_info_t * info)
{
info->current_picture = info->current_picture_2nd = NULL;
info->display_picture = info->display_picture_2nd = NULL;
info->current_fbuf = info->display_fbuf = info->discard_fbuf = NULL;
}
static void info_user_data (mpeg2dec_t * mpeg2dec)
{
if (mpeg2dec->user_data_len) {
mpeg2dec->info.user_data = mpeg2dec->chunk_buffer;
mpeg2dec->info.user_data_len = mpeg2dec->user_data_len - 3;
}
}
int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_sequence_t * sequence = &(mpeg2dec->new_sequence);
static unsigned int frame_period[16] = {
0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000,
/* unofficial: xing 15 fps */
1800000,
/* unofficial: libmpeg3 "Unofficial economy rates" 5/10/12/15 fps */
5400000, 2700000, 2250000, 1800000, 0, 0
};
int i;
if ((buffer[6] & 0x20) != 0x20) /* missing marker_bit */
return 1;
i = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
if (! (sequence->display_width = sequence->picture_width = i >> 12))
return 1;
if (! (sequence->display_height = sequence->picture_height = i & 0xfff))
return 1;
sequence->width = (sequence->picture_width + 15) & ~15;
sequence->height = (sequence->picture_height + 15) & ~15;
sequence->chroma_width = sequence->width >> 1;
sequence->chroma_height = sequence->height >> 1;
sequence->flags = (SEQ_FLAG_PROGRESSIVE_SEQUENCE |
SEQ_VIDEO_FORMAT_UNSPECIFIED);
sequence->pixel_width = buffer[3] >> 4; /* aspect ratio */
sequence->frame_period = frame_period[buffer[3] & 15];
sequence->byte_rate = (buffer[4]<<10) | (buffer[5]<<2) | (buffer[6]>>6);
sequence->vbv_buffer_size = ((buffer[6]<<16)|(buffer[7]<<8))&0x1ff800;
if (buffer[7] & 4)
sequence->flags |= SEQ_FLAG_CONSTRAINED_PARAMETERS;
mpeg2dec->copy_matrix = 3;
if (buffer[7] & 2) {
for (i = 0; i < 64; i++)
mpeg2dec->new_quantizer_matrix[0][mpeg2_scan_norm[i]] =
(buffer[i+7] << 7) | (buffer[i+8] >> 1);
buffer += 64;
} else
for (i = 0; i < 64; i++)
mpeg2dec->new_quantizer_matrix[0][mpeg2_scan_norm[i]] =
default_intra_quantizer_matrix[i];
if (buffer[7] & 1)
for (i = 0; i < 64; i++)
mpeg2dec->new_quantizer_matrix[1][mpeg2_scan_norm[i]] =
buffer[i+8];
else
memset (mpeg2dec->new_quantizer_matrix[1], 16, 64);
sequence->profile_level_id = 0x80;
sequence->colour_primaries = 0;
sequence->transfer_characteristics = 0;
sequence->matrix_coefficients = 0;
mpeg2dec->ext_state = SEQ_EXT;
mpeg2dec->state = STATE_SEQUENCE;
mpeg2dec->display_offset_x = mpeg2dec->display_offset_y = 0;
return 0;
}
static int sequence_ext (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_sequence_t * sequence = &(mpeg2dec->new_sequence);
uint32_t flags;
if (!(buffer[3] & 1))
return 1;
sequence->profile_level_id = (buffer[0] << 4) | (buffer[1] >> 4);
sequence->display_width = sequence->picture_width +=
((buffer[1] << 13) | (buffer[2] << 5)) & 0x3000;
sequence->display_height = sequence->picture_height +=
(buffer[2] << 7) & 0x3000;
sequence->width = (sequence->picture_width + 15) & ~15;
sequence->height = (sequence->picture_height + 15) & ~15;
flags = sequence->flags | SEQ_FLAG_MPEG2;
if (!(buffer[1] & 8)) {
flags &= ~SEQ_FLAG_PROGRESSIVE_SEQUENCE;
sequence->height = (sequence->height + 31) & ~31;
}
if (buffer[5] & 0x80)
flags |= SEQ_FLAG_LOW_DELAY;
sequence->flags = flags;
sequence->chroma_width = sequence->width;
sequence->chroma_height = sequence->height;
switch (buffer[1] & 6) {
case 0: /* invalid */
return 1;
case 2: /* 4:2:0 */
sequence->chroma_height >>= 1;
case 4: /* 4:2:2 */
sequence->chroma_width >>= 1;
}
sequence->byte_rate += ((buffer[2]<<25) | (buffer[3]<<17)) & 0x3ffc0000;
sequence->vbv_buffer_size |= buffer[4] << 21;
sequence->frame_period =
sequence->frame_period * ((buffer[5]&31)+1) / (((buffer[5]>>5)&3)+1);
mpeg2dec->ext_state = SEQ_DISPLAY_EXT;
return 0;
}
static int sequence_display_ext (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_sequence_t * sequence = &(mpeg2dec->new_sequence);
sequence->flags = ((sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) |
((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT));
if (buffer[0] & 1) {
sequence->flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
sequence->colour_primaries = buffer[1];
sequence->transfer_characteristics = buffer[2];
sequence->matrix_coefficients = buffer[3];
buffer += 3;
}
if (!(buffer[2] & 2)) /* missing marker_bit */
return 1;
if( (buffer[1] << 6) | (buffer[2] >> 2) )
sequence->display_width = (buffer[1] << 6) | (buffer[2] >> 2);
if( ((buffer[2]& 1 ) << 13) | (buffer[3] << 5) | (buffer[4] >> 3) )
sequence->display_height =
((buffer[2]& 1 ) << 13) | (buffer[3] << 5) | (buffer[4] >> 3);
return 0;
}
static inline void simplify (unsigned int * u, unsigned int * v)
{
unsigned int a, b, tmp;
a = *u; b = *v;
while (a) { /* find greatest common divisor */
tmp = a; a = b % tmp; b = tmp;
}
*u /= b; *v /= b;
}
static inline void finalize_sequence (mpeg2_sequence_t * sequence)
{
int width;
int height;
sequence->byte_rate *= 50;
if (sequence->flags & SEQ_FLAG_MPEG2) {
switch (sequence->pixel_width) {
case 1: /* square pixels */
sequence->pixel_width = sequence->pixel_height = 1; return;
case 2: /* 4:3 aspect ratio */
width = 4; height = 3; break;
case 3: /* 16:9 aspect ratio */
width = 16; height = 9; break;
case 4: /* 2.21:1 aspect ratio */
width = 221; height = 100; break;
default: /* illegal */
sequence->pixel_width = sequence->pixel_height = 0; return;
}
width *= sequence->display_height;
height *= sequence->display_width;
} else {
if (sequence->byte_rate == 50 * 0x3ffff)
sequence->byte_rate = 0; /* mpeg-1 VBR */
switch (sequence->pixel_width) {
case 0: case 15: /* illegal */
sequence->pixel_width = sequence->pixel_height = 0; return;
case 1: /* square pixels */
sequence->pixel_width = sequence->pixel_height = 1; return;
case 3: /* 720x576 16:9 */
sequence->pixel_width = 64; sequence->pixel_height = 45; return;
case 6: /* 720x480 16:9 */
sequence->pixel_width = 32; sequence->pixel_height = 27; return;
case 8: /* BT.601 625 lines 4:3 */
sequence->pixel_width = 59; sequence->pixel_height = 54; return;
case 12: /* BT.601 525 lines 4:3 */
sequence->pixel_width = 10; sequence->pixel_height = 11; return;
default:
height = 88 * sequence->pixel_width + 1171;
width = 2000;
}
}
sequence->pixel_width = width;
sequence->pixel_height = height;
simplify (&sequence->pixel_width, &sequence->pixel_height);
}
int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence,
unsigned int * pixel_width,
unsigned int * pixel_height)
{
static struct {
unsigned int width, height;
} video_modes[] = {
{720, 576}, /* 625 lines, 13.5 MHz (D1, DV, DVB, DVD) */
{704, 576}, /* 625 lines, 13.5 MHz (1/1 D1, DVB, DVD, 4CIF) */
{544, 576}, /* 625 lines, 10.125 MHz (DVB, laserdisc) */
{528, 576}, /* 625 lines, 10.125 MHz (3/4 D1, DVB, laserdisc) */
{480, 576}, /* 625 lines, 9 MHz (2/3 D1, DVB, SVCD) */
{352, 576}, /* 625 lines, 6.75 MHz (D2, 1/2 D1, CVD, DVB, DVD) */
{352, 288}, /* 625 lines, 6.75 MHz, 1 field (D4, VCD, DVB, DVD, CIF) */
{176, 144}, /* 625 lines, 3.375 MHz, half field (QCIF) */
{720, 486}, /* 525 lines, 13.5 MHz (D1) */
{704, 486}, /* 525 lines, 13.5 MHz */
{720, 480}, /* 525 lines, 13.5 MHz (DV, DSS, DVD) */
{704, 480}, /* 525 lines, 13.5 MHz (1/1 D1, ATSC, DVD) */
{544, 480}, /* 525 lines. 10.125 MHz (DSS, laserdisc) */
{528, 480}, /* 525 lines. 10.125 MHz (3/4 D1, laserdisc) */
{480, 480}, /* 525 lines, 9 MHz (2/3 D1, SVCD) */
{352, 480}, /* 525 lines, 6.75 MHz (D2, 1/2 D1, CVD, DVD) */
{352, 240} /* 525 lines. 6.75 MHz, 1 field (D4, VCD, DSS, DVD) */
};
unsigned int width, height, pix_width, pix_height, i, DAR_16_9;
*pixel_width = sequence->pixel_width;
*pixel_height = sequence->pixel_height;
width = sequence->picture_width;
height = sequence->picture_height;
for (i = 0; i < sizeof (video_modes) / sizeof (video_modes[0]); i++)
if (width == video_modes[i].width && height == video_modes[i].height)
break;
if (i == sizeof (video_modes) / sizeof (video_modes[0]) ||
(sequence->pixel_width == 1 && sequence->pixel_height == 1) ||
width != sequence->display_width || height != sequence->display_height)
return 0;
for (pix_height = 1; height * pix_height < 480; pix_height <<= 1);
height *= pix_height;
for (pix_width = 1; width * pix_width <= 352; pix_width <<= 1);
width *= pix_width;
if (! (sequence->flags & SEQ_FLAG_MPEG2)) {
static unsigned int mpeg1_check[2][2] = {{11, 54}, {27, 45}};
DAR_16_9 = (sequence->pixel_height == 27 ||
sequence->pixel_height == 45);
if (width < 704 ||
sequence->pixel_height != mpeg1_check[DAR_16_9][height == 576])
return 0;
} else {
DAR_16_9 = (3 * sequence->picture_width * sequence->pixel_width >
4 * sequence->picture_height * sequence->pixel_height);
switch (width) {
case 528: case 544: pix_width *= 4; pix_height *= 3; break;
case 480: pix_width *= 3; pix_height *= 2; break;
}
}
if (DAR_16_9) {
pix_width *= 4; pix_height *= 3;
}
if (height == 576) {
pix_width *= 59; pix_height *= 54;
} else {
pix_width *= 10; pix_height *= 11;
}
*pixel_width = pix_width;
*pixel_height = pix_height;
simplify (pixel_width, pixel_height);
return (height == 576) ? 1 : 2;
}
static void copy_matrix (mpeg2dec_t * mpeg2dec, int idx)
{
if (memcmp (mpeg2dec->quantizer_matrix[idx],
mpeg2dec->new_quantizer_matrix[idx], 64)) {
memcpy (mpeg2dec->quantizer_matrix[idx],
mpeg2dec->new_quantizer_matrix[idx], 64);
mpeg2dec->scaled[idx] = -1;
}
}
static void finalize_matrix (mpeg2dec_t * mpeg2dec)
{
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
int i;
for (i = 0; i < 2; i++) {
if (mpeg2dec->copy_matrix & (1 << i))
copy_matrix (mpeg2dec, i);
if ((mpeg2dec->copy_matrix & (4 << i)) &&
memcmp (mpeg2dec->quantizer_matrix[i],
mpeg2dec->new_quantizer_matrix[i+2], 64)) {
copy_matrix (mpeg2dec, i + 2);
decoder->chroma_quantizer[i] = decoder->quantizer_prescale[i+2];
} else if (mpeg2dec->copy_matrix & (5 << i))
decoder->chroma_quantizer[i] = decoder->quantizer_prescale[i];
}
}
static mpeg2_state_t invalid_end_action (mpeg2dec_t * mpeg2dec)
{
mpeg2_reset_info (&(mpeg2dec->info));
mpeg2dec->info.gop = NULL;
info_user_data (mpeg2dec);
mpeg2_header_state_init (mpeg2dec);
mpeg2dec->sequence = mpeg2dec->new_sequence;
mpeg2dec->action = mpeg2_seek_header;
mpeg2dec->state = STATE_SEQUENCE;
return STATE_SEQUENCE;
}
void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec)
{
mpeg2_sequence_t * sequence = &(mpeg2dec->new_sequence);
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
finalize_sequence (sequence);
finalize_matrix (mpeg2dec);
decoder->mpeg1 = !(sequence->flags & SEQ_FLAG_MPEG2);
decoder->width = sequence->width;
decoder->height = sequence->height;
decoder->vertical_position_extension = (sequence->picture_height > 2800);
decoder->chroma_format = ((sequence->chroma_width == sequence->width) +
(sequence->chroma_height == sequence->height));
if (mpeg2dec->sequence.width != (unsigned)-1) {
/*
* According to 6.1.1.6, repeat sequence headers should be
* identical to the original. However some encoders do not
* respect that and change various fields (including bitrate
* and aspect ratio) in the repeat sequence headers. So we
* choose to be as conservative as possible and only restart
* the decoder if the width, height, chroma_width,
* chroma_height or low_delay flag are modified.
*/
if (sequence->width != mpeg2dec->sequence.width ||
sequence->height != mpeg2dec->sequence.height ||
sequence->chroma_width != mpeg2dec->sequence.chroma_width ||
sequence->chroma_height != mpeg2dec->sequence.chroma_height ||
((sequence->flags ^ mpeg2dec->sequence.flags) &
SEQ_FLAG_LOW_DELAY)) {
decoder->stride_frame = sequence->width;
mpeg2_header_end (mpeg2dec);
mpeg2dec->action = invalid_end_action;
mpeg2dec->state = STATE_INVALID_END;
return;
}
mpeg2dec->state = (memcmp (&(mpeg2dec->sequence), sequence,
sizeof (mpeg2_sequence_t)) ?
STATE_SEQUENCE_MODIFIED : STATE_SEQUENCE_REPEATED);
} else
decoder->stride_frame = sequence->width;
mpeg2dec->sequence = *sequence;
mpeg2_reset_info (&(mpeg2dec->info));
mpeg2dec->info.sequence = &(mpeg2dec->sequence);
mpeg2dec->info.gop = NULL;
info_user_data (mpeg2dec);
}
int mpeg2_header_gop (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_gop_t * gop = &(mpeg2dec->new_gop);
if (! (buffer[1] & 8))
return 1;
gop->hours = (buffer[0] >> 2) & 31;
gop->minutes = ((buffer[0] << 4) | (buffer[1] >> 4)) & 63;
gop->seconds = ((buffer[1] << 3) | (buffer[2] >> 5)) & 63;
gop->pictures = ((buffer[2] << 1) | (buffer[3] >> 7)) & 63;
gop->flags = (buffer[0] >> 7) | ((buffer[3] >> 4) & 6);
mpeg2dec->state = STATE_GOP;
return 0;
}
void mpeg2_header_gop_finalize (mpeg2dec_t * mpeg2dec)
{
mpeg2dec->gop = mpeg2dec->new_gop;
mpeg2_reset_info (&(mpeg2dec->info));
mpeg2dec->info.gop = &(mpeg2dec->gop);
info_user_data (mpeg2dec);
}
void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type)
{
int i;
for (i = 0; i < 3; i++)
if (mpeg2dec->fbuf[1] != &mpeg2dec->fbuf_alloc[i].fbuf &&
mpeg2dec->fbuf[2] != &mpeg2dec->fbuf_alloc[i].fbuf) {
mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[i].fbuf;
mpeg2dec->info.current_fbuf = mpeg2dec->fbuf[0];
if (b_type || (mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY)) {
if (b_type || mpeg2dec->convert)
mpeg2dec->info.discard_fbuf = mpeg2dec->fbuf[0];
mpeg2dec->info.display_fbuf = mpeg2dec->fbuf[0];
}
break;
}
}
int mpeg2_header_picture (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_picture_t * picture = &(mpeg2dec->new_picture);
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
int type;
mpeg2dec->state = ((mpeg2dec->state != STATE_SLICE_1ST) ?
STATE_PICTURE : STATE_PICTURE_2ND);
mpeg2dec->ext_state = PIC_CODING_EXT;
picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6);
type = (buffer [1] >> 3) & 7;
if (type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B) {
/* forward_f_code and backward_f_code - used in mpeg1 only */
decoder->f_motion.f_code[1] = (buffer[3] >> 2) & 1;
decoder->f_motion.f_code[0] =
(((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
decoder->b_motion.f_code[1] = (buffer[4] >> 6) & 1;
decoder->b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
}
picture->flags = PIC_FLAG_PROGRESSIVE_FRAME | type;
picture->tag = picture->tag2 = 0;
if (mpeg2dec->num_tags) {
if (mpeg2dec->bytes_since_tag >= mpeg2dec->chunk_ptr - buffer + 4) {
mpeg2dec->num_tags = 0;
picture->tag = mpeg2dec->tag_current;
picture->tag2 = mpeg2dec->tag2_current;
picture->flags |= PIC_FLAG_TAGS;
} else if (mpeg2dec->num_tags > 1) {
mpeg2dec->num_tags = 1;
picture->tag = mpeg2dec->tag_previous;
picture->tag2 = mpeg2dec->tag2_previous;
picture->flags |= PIC_FLAG_TAGS;
}
}
picture->nb_fields = 2;
picture->display_offset[0].x = picture->display_offset[1].x =
picture->display_offset[2].x = mpeg2dec->display_offset_x;
picture->display_offset[0].y = picture->display_offset[1].y =
picture->display_offset[2].y = mpeg2dec->display_offset_y;
/* XXXXXX decode extra_information_picture as well */
decoder->q_scale_type = 0;
decoder->intra_dc_precision = 7;
decoder->frame_pred_frame_dct = 1;
decoder->concealment_motion_vectors = 0;
decoder->scan = mpeg2_scan_norm;
decoder->picture_structure = FRAME_PICTURE;
mpeg2dec->copy_matrix = 0;
return 0;
}
static int picture_coding_ext (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_picture_t * picture = &(mpeg2dec->new_picture);
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
uint32_t flags;
/* pre subtract 1 for use later in compute_motion_vector */
decoder->f_motion.f_code[0] = (buffer[0] & 15) - 1;
decoder->f_motion.f_code[1] = (buffer[1] >> 4) - 1;
decoder->b_motion.f_code[0] = (buffer[1] & 15) - 1;
decoder->b_motion.f_code[1] = (buffer[2] >> 4) - 1;
flags = picture->flags;
decoder->intra_dc_precision = 7 - ((buffer[2] >> 2) & 3);
decoder->picture_structure = buffer[2] & 3;
switch (decoder->picture_structure) {
case TOP_FIELD:
flags |= PIC_FLAG_TOP_FIELD_FIRST;
case BOTTOM_FIELD:
picture->nb_fields = 1;
break;
case FRAME_PICTURE:
if (!(mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)) {
picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
flags |= (buffer[3] & 2) ? PIC_FLAG_REPEAT_FIRST_FIELD : 0;
} else
picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2;
break;
default:
return 1;
}
decoder->top_field_first = buffer[3] >> 7;
decoder->frame_pred_frame_dct = (buffer[3] >> 6) & 1;
decoder->concealment_motion_vectors = (buffer[3] >> 5) & 1;
decoder->q_scale_type = buffer[3] & 16;
decoder->intra_vlc_format = (buffer[3] >> 3) & 1;
decoder->scan = (buffer[3] & 4) ? mpeg2_scan_alt : mpeg2_scan_norm;
if (!(buffer[4] & 0x80))
flags &= ~PIC_FLAG_PROGRESSIVE_FRAME;
if (buffer[4] & 0x40)
flags |= (((buffer[4]<<26) | (buffer[5]<<18) | (buffer[6]<<10)) &
PIC_MASK_COMPOSITE_DISPLAY) | PIC_FLAG_COMPOSITE_DISPLAY;
picture->flags = flags;
mpeg2dec->ext_state = PIC_DISPLAY_EXT | COPYRIGHT_EXT | QUANT_MATRIX_EXT;
return 0;
}
static int picture_display_ext (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
mpeg2_picture_t * picture = &(mpeg2dec->new_picture);
int i, nb_pos;
nb_pos = picture->nb_fields;
if (mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
nb_pos >>= 1;
for (i = 0; i < nb_pos; i++) {
int x, y;
x = ((buffer[4*i] << 24) | (buffer[4*i+1] << 16) |
(buffer[4*i+2] << 8) | buffer[4*i+3]) >> (11-2*i);
y = ((buffer[4*i+2] << 24) | (buffer[4*i+3] << 16) |
(buffer[4*i+4] << 8) | buffer[4*i+5]) >> (10-2*i);
if (! (x & y & 1))
return 1;
picture->display_offset[i].x = mpeg2dec->display_offset_x = x >> 1;
picture->display_offset[i].y = mpeg2dec->display_offset_y = y >> 1;
}
for (; i < 3; i++) {
picture->display_offset[i].x = mpeg2dec->display_offset_x;
picture->display_offset[i].y = mpeg2dec->display_offset_y;
}
return 0;
}
void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels)
{
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
int old_type_b = (decoder->coding_type == B_TYPE);
int low_delay = mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY;
finalize_matrix (mpeg2dec);
decoder->coding_type = mpeg2dec->new_picture.flags & PIC_MASK_CODING_TYPE;
if (mpeg2dec->state == STATE_PICTURE) {
mpeg2_picture_t * picture;
mpeg2_picture_t * other;
decoder->second_field = 0;
picture = other = mpeg2dec->pictures;
if (old_type_b ^ (mpeg2dec->picture < mpeg2dec->pictures + 2))
picture += 2;
else
other += 2;
mpeg2dec->picture = picture;
*picture = mpeg2dec->new_picture;
if (!old_type_b) {
mpeg2dec->fbuf[2] = mpeg2dec->fbuf[1];
mpeg2dec->fbuf[1] = mpeg2dec->fbuf[0];
}
mpeg2dec->fbuf[0] = NULL;
mpeg2_reset_info (&(mpeg2dec->info));
mpeg2dec->info.current_picture = picture;
mpeg2dec->info.display_picture = picture;
if (decoder->coding_type != B_TYPE) {
if (!low_delay) {
if (mpeg2dec->first) {
mpeg2dec->info.display_picture = NULL;
mpeg2dec->first = 0;
} else {
mpeg2dec->info.display_picture = other;
if (other->nb_fields == 1)
mpeg2dec->info.display_picture_2nd = other + 1;
mpeg2dec->info.display_fbuf = mpeg2dec->fbuf[1];
}
}
if (!low_delay + !mpeg2dec->convert)
mpeg2dec->info.discard_fbuf =
mpeg2dec->fbuf[!low_delay + !mpeg2dec->convert];
}
if (mpeg2dec->convert) {
mpeg2_convert_init_t convert_init;
if (!mpeg2dec->convert_start) {
int y_size, uv_size;
mpeg2dec->decoder.convert_id =
mpeg2_malloc (mpeg2dec->convert_id_size,
MPEG2_ALLOC_CONVERT_ID);
mpeg2dec->convert (MPEG2_CONVERT_START,
mpeg2dec->decoder.convert_id,
&(mpeg2dec->sequence),
mpeg2dec->convert_stride, accels,
mpeg2dec->convert_arg, &convert_init);
mpeg2dec->convert_start = convert_init.start;
mpeg2dec->decoder.convert = convert_init.copy;
y_size = decoder->stride_frame * mpeg2dec->sequence.height;
uv_size = y_size >> (2 - mpeg2dec->decoder.chroma_format);
mpeg2dec->yuv_buf[0][0] =
(uint8_t *) mpeg2_malloc (y_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[0][1] =
(uint8_t *) mpeg2_malloc (uv_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[0][2] =
(uint8_t *) mpeg2_malloc (uv_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[1][0] =
(uint8_t *) mpeg2_malloc (y_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[1][1] =
(uint8_t *) mpeg2_malloc (uv_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[1][2] =
(uint8_t *) mpeg2_malloc (uv_size, MPEG2_ALLOC_YUV);
y_size = decoder->stride_frame * 32;
uv_size = y_size >> (2 - mpeg2dec->decoder.chroma_format);
mpeg2dec->yuv_buf[2][0] =
(uint8_t *) mpeg2_malloc (y_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[2][1] =
(uint8_t *) mpeg2_malloc (uv_size, MPEG2_ALLOC_YUV);
mpeg2dec->yuv_buf[2][2] =
(uint8_t *) mpeg2_malloc (uv_size, MPEG2_ALLOC_YUV);
}
if (!mpeg2dec->custom_fbuf) {
while (mpeg2dec->alloc_index < 3) {
mpeg2_fbuf_t * fbuf;
fbuf = &mpeg2dec->fbuf_alloc[mpeg2dec->alloc_index++].fbuf;
fbuf->id = NULL;
fbuf->buf[0] =
(uint8_t *) mpeg2_malloc (convert_init.buf_size[0],
MPEG2_ALLOC_CONVERTED);
fbuf->buf[1] =
(uint8_t *) mpeg2_malloc (convert_init.buf_size[1],
MPEG2_ALLOC_CONVERTED);
fbuf->buf[2] =
(uint8_t *) mpeg2_malloc (convert_init.buf_size[2],
MPEG2_ALLOC_CONVERTED);
}
mpeg2_set_fbuf (mpeg2dec, (decoder->coding_type == B_TYPE));
}
} else if (!mpeg2dec->custom_fbuf) {
while (mpeg2dec->alloc_index < 3) {
mpeg2_fbuf_t * fbuf;
int y_size, uv_size;
fbuf = &(mpeg2dec->fbuf_alloc[mpeg2dec->alloc_index++].fbuf);
fbuf->id = NULL;
y_size = decoder->stride_frame * mpeg2dec->sequence.height;
uv_size = y_size >> (2 - decoder->chroma_format);
fbuf->buf[0] = (uint8_t *) mpeg2_malloc (y_size,
MPEG2_ALLOC_YUV);
fbuf->buf[1] = (uint8_t *) mpeg2_malloc (uv_size,
MPEG2_ALLOC_YUV);
fbuf->buf[2] = (uint8_t *) mpeg2_malloc (uv_size,
MPEG2_ALLOC_YUV);
}
mpeg2_set_fbuf (mpeg2dec, (decoder->coding_type == B_TYPE));
}
} else {
decoder->second_field = 1;
mpeg2dec->picture++; /* second field picture */
*(mpeg2dec->picture) = mpeg2dec->new_picture;
mpeg2dec->info.current_picture_2nd = mpeg2dec->picture;
if (low_delay || decoder->coding_type == B_TYPE)
mpeg2dec->info.display_picture_2nd = mpeg2dec->picture;
}
info_user_data (mpeg2dec);
}
static int copyright_ext (mpeg2dec_t * mpeg2dec)
{
return 0;
}
static int quant_matrix_ext (mpeg2dec_t * mpeg2dec)
{
uint8_t * buffer = mpeg2dec->chunk_start;
int i, j;
for (i = 0; i < 4; i++)
if (buffer[0] & (8 >> i)) {
for (j = 0; j < 64; j++)
mpeg2dec->new_quantizer_matrix[i][mpeg2_scan_norm[j]] =
(buffer[j] << (i+5)) | (buffer[j+1] >> (3-i));
mpeg2dec->copy_matrix |= 1 << i;
buffer += 64;
}
return 0;
}
int mpeg2_header_extension (mpeg2dec_t * mpeg2dec)
{
static int (* parser[]) (mpeg2dec_t *) = {
0, sequence_ext, sequence_display_ext, quant_matrix_ext,
copyright_ext, 0, 0, picture_display_ext, picture_coding_ext
};
int ext, ext_bit;
ext = mpeg2dec->chunk_start[0] >> 4;
ext_bit = 1 << ext;
if (!(mpeg2dec->ext_state & ext_bit))
return 0; /* ignore illegal extensions */
mpeg2dec->ext_state &= ~ext_bit;
return parser[ext] (mpeg2dec);
}
int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec)
{
mpeg2dec->user_data_len += mpeg2dec->chunk_ptr - 1 - mpeg2dec->chunk_start;
mpeg2dec->chunk_start = mpeg2dec->chunk_ptr - 1;
return 0;
}
static void prescale (mpeg2dec_t * mpeg2dec, int idx)
{
static int non_linear_scale [] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 10, 12, 14, 16, 18, 20, 22,
24, 28, 32, 36, 40, 44, 48, 52,
56, 64, 72, 80, 88, 96, 104, 112
};
int i, j, k;
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
if (mpeg2dec->scaled[idx] != decoder->q_scale_type) {
mpeg2dec->scaled[idx] = decoder->q_scale_type;
for (i = 0; i < 32; i++) {
k = decoder->q_scale_type ? non_linear_scale[i] : (i << 1);
decoder->quantizer_scales[i] = k;
for (j = 0; j < 64; j++)
decoder->quantizer_prescale[idx][i][j] =
k * mpeg2dec->quantizer_matrix[idx][j];
}
}
}
mpeg2_state_t mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec)
{
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
mpeg2dec->info.user_data = NULL; mpeg2dec->info.user_data_len = 0;
mpeg2dec->state = ((mpeg2dec->picture->nb_fields > 1 ||
mpeg2dec->state == STATE_PICTURE_2ND) ?
STATE_SLICE : STATE_SLICE_1ST);
if (mpeg2dec->decoder.coding_type != D_TYPE) {
prescale (mpeg2dec, 0);
if (decoder->chroma_quantizer[0] == decoder->quantizer_prescale[2])
prescale (mpeg2dec, 2);
if (mpeg2dec->decoder.coding_type != I_TYPE) {
prescale (mpeg2dec, 1);
if (decoder->chroma_quantizer[1] == decoder->quantizer_prescale[3])
prescale (mpeg2dec, 3);
}
}
if (!(mpeg2dec->nb_decode_slices))
mpeg2dec->picture->flags |= PIC_FLAG_SKIP;
else if (mpeg2dec->convert_start) {
mpeg2dec->convert_start (decoder->convert_id, mpeg2dec->fbuf[0],
mpeg2dec->picture, mpeg2dec->info.gop);
if (mpeg2dec->decoder.coding_type == B_TYPE)
mpeg2_init_fbuf (&(mpeg2dec->decoder), mpeg2dec->yuv_buf[2],
mpeg2dec->yuv_buf[mpeg2dec->yuv_index ^ 1],
mpeg2dec->yuv_buf[mpeg2dec->yuv_index]);
else {
mpeg2_init_fbuf (&(mpeg2dec->decoder),
mpeg2dec->yuv_buf[mpeg2dec->yuv_index ^ 1],
mpeg2dec->yuv_buf[mpeg2dec->yuv_index],
mpeg2dec->yuv_buf[mpeg2dec->yuv_index]);
if (mpeg2dec->state == STATE_SLICE)
mpeg2dec->yuv_index ^= 1;
}
} else {
int b_type;
b_type = (mpeg2dec->decoder.coding_type == B_TYPE);
mpeg2_init_fbuf (&(mpeg2dec->decoder), mpeg2dec->fbuf[0]->buf,
mpeg2dec->fbuf[b_type + 1]->buf,
mpeg2dec->fbuf[b_type]->buf);
}
mpeg2dec->action = NULL;
return STATE_INTERNAL_NORETURN;
}
static mpeg2_state_t seek_sequence (mpeg2dec_t * mpeg2dec)
{
mpeg2_reset_info (&(mpeg2dec->info));
mpeg2dec->info.sequence = NULL;
mpeg2dec->info.gop = NULL;
mpeg2_header_state_init (mpeg2dec);
mpeg2dec->action = mpeg2_seek_header;
return mpeg2_seek_header (mpeg2dec);
}
mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec)
{
mpeg2_picture_t * picture;
int b_type;
b_type = (mpeg2dec->decoder.coding_type == B_TYPE);
picture = mpeg2dec->pictures;
if ((mpeg2dec->picture >= picture + 2) ^ b_type)
picture = mpeg2dec->pictures + 2;
mpeg2_reset_info (&(mpeg2dec->info));
if (!(mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY)) {
mpeg2dec->info.display_picture = picture;
if (picture->nb_fields == 1)
mpeg2dec->info.display_picture_2nd = picture + 1;
mpeg2dec->info.display_fbuf = mpeg2dec->fbuf[b_type];
if (!mpeg2dec->convert)
mpeg2dec->info.discard_fbuf = mpeg2dec->fbuf[b_type + 1];
} else if (!mpeg2dec->convert)
mpeg2dec->info.discard_fbuf = mpeg2dec->fbuf[b_type];
mpeg2dec->action = seek_sequence;
return STATE_END;
}

View File

@ -1,299 +0,0 @@
/*
* idct.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#include "config.h"
#include <stdlib.h>
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */
#define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */
#define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */
#define W5 1609 /* 2048 * sqrt (2) * cos (5 * pi / 16) */
#define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */
#define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */
/* idct main entry point */
void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
void (* mpeg2_idct_add) (int last, int16_t * block,
uint8_t * dest, int stride);
/*
* In legal streams, the IDCT output should be between -384 and +384.
* In corrupted streams, it is possible to force the IDCT output to go
* to +-3826 - this is the worst case for a column IDCT where the
* column inputs are 16-bit values.
*/
uint8_t mpeg2_clip[3840 * 2 + 256];
#define CLIP(i) ((mpeg2_clip + 3840)[i])
#if 0
#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
do { \
t0 = W0 * d0 + W1 * d1; \
t1 = W0 * d1 - W1 * d0; \
} while (0)
#else
#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
do { \
int tmp = W0 * (d0 + d1); \
t0 = tmp + (W1 - W0) * d1; \
t1 = tmp - (W1 + W0) * d0; \
} while (0)
#endif
static inline void idct_row (int16_t * const block)
{
int d0, d1, d2, d3;
int a0, a1, a2, a3, b0, b1, b2, b3;
int t0, t1, t2, t3;
/* shortcut */
if (likely (!(block[1] | ((int32_t *)block)[1] | ((int32_t *)block)[2] |
((int32_t *)block)[3]))) {
uint32_t tmp = (uint16_t) (block[0] >> 1);
tmp |= tmp << 16;
((int32_t *)block)[0] = tmp;
((int32_t *)block)[1] = tmp;
((int32_t *)block)[2] = tmp;
((int32_t *)block)[3] = tmp;
return;
}
d0 = (block[0] << 11) + 2048;
d1 = block[1];
d2 = block[2] << 11;
d3 = block[3];
t0 = d0 + d2;
t1 = d0 - d2;
BUTTERFLY (t2, t3, W6, W2, d3, d1);
a0 = t0 + t2;
a1 = t1 + t3;
a2 = t1 - t3;
a3 = t0 - t2;
d0 = block[4];
d1 = block[5];
d2 = block[6];
d3 = block[7];
BUTTERFLY (t0, t1, W7, W1, d3, d0);
BUTTERFLY (t2, t3, W3, W5, d1, d2);
b0 = t0 + t2;
b3 = t1 + t3;
t0 -= t2;
t1 -= t3;
b1 = ((t0 + t1) >> 8) * 181;
b2 = ((t0 - t1) >> 8) * 181;
block[0] = (a0 + b0) >> 12;
block[1] = (a1 + b1) >> 12;
block[2] = (a2 + b2) >> 12;
block[3] = (a3 + b3) >> 12;
block[4] = (a3 - b3) >> 12;
block[5] = (a2 - b2) >> 12;
block[6] = (a1 - b1) >> 12;
block[7] = (a0 - b0) >> 12;
}
static inline void idct_col (int16_t * const block)
{
int d0, d1, d2, d3;
int a0, a1, a2, a3, b0, b1, b2, b3;
int t0, t1, t2, t3;
d0 = (block[8*0] << 11) + 65536;
d1 = block[8*1];
d2 = block[8*2] << 11;
d3 = block[8*3];
t0 = d0 + d2;
t1 = d0 - d2;
BUTTERFLY (t2, t3, W6, W2, d3, d1);
a0 = t0 + t2;
a1 = t1 + t3;
a2 = t1 - t3;
a3 = t0 - t2;
d0 = block[8*4];
d1 = block[8*5];
d2 = block[8*6];
d3 = block[8*7];
BUTTERFLY (t0, t1, W7, W1, d3, d0);
BUTTERFLY (t2, t3, W3, W5, d1, d2);
b0 = t0 + t2;
b3 = t1 + t3;
t0 -= t2;
t1 -= t3;
b1 = ((t0 + t1) >> 8) * 181;
b2 = ((t0 - t1) >> 8) * 181;
block[8*0] = (a0 + b0) >> 17;
block[8*1] = (a1 + b1) >> 17;
block[8*2] = (a2 + b2) >> 17;
block[8*3] = (a3 + b3) >> 17;
block[8*4] = (a3 - b3) >> 17;
block[8*5] = (a2 - b2) >> 17;
block[8*6] = (a1 - b1) >> 17;
block[8*7] = (a0 - b0) >> 17;
}
static void mpeg2_idct_copy_c (int16_t * block, uint8_t * dest,
const int stride)
{
int i;
for (i = 0; i < 8; i++)
idct_row (block + 8 * i);
for (i = 0; i < 8; i++)
idct_col (block + i);
do {
dest[0] = CLIP (block[0]);
dest[1] = CLIP (block[1]);
dest[2] = CLIP (block[2]);
dest[3] = CLIP (block[3]);
dest[4] = CLIP (block[4]);
dest[5] = CLIP (block[5]);
dest[6] = CLIP (block[6]);
dest[7] = CLIP (block[7]);
((int32_t *)block)[0] = 0; ((int32_t *)block)[1] = 0;
((int32_t *)block)[2] = 0; ((int32_t *)block)[3] = 0;
dest += stride;
block += 8;
} while (--i);
}
static void mpeg2_idct_add_c (const int last, int16_t * block,
uint8_t * dest, const int stride)
{
int i;
if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) {
for (i = 0; i < 8; i++)
idct_row (block + 8 * i);
for (i = 0; i < 8; i++)
idct_col (block + i);
do {
dest[0] = CLIP (block[0] + dest[0]);
dest[1] = CLIP (block[1] + dest[1]);
dest[2] = CLIP (block[2] + dest[2]);
dest[3] = CLIP (block[3] + dest[3]);
dest[4] = CLIP (block[4] + dest[4]);
dest[5] = CLIP (block[5] + dest[5]);
dest[6] = CLIP (block[6] + dest[6]);
dest[7] = CLIP (block[7] + dest[7]);
((int32_t *)block)[0] = 0; ((int32_t *)block)[1] = 0;
((int32_t *)block)[2] = 0; ((int32_t *)block)[3] = 0;
dest += stride;
block += 8;
} while (--i);
} else {
int DC;
DC = (block[0] + 64) >> 7;
block[0] = block[63] = 0;
i = 8;
do {
dest[0] = CLIP (DC + dest[0]);
dest[1] = CLIP (DC + dest[1]);
dest[2] = CLIP (DC + dest[2]);
dest[3] = CLIP (DC + dest[3]);
dest[4] = CLIP (DC + dest[4]);
dest[5] = CLIP (DC + dest[5]);
dest[6] = CLIP (DC + dest[6]);
dest[7] = CLIP (DC + dest[7]);
dest += stride;
} while (--i);
}
}
void mpeg2_idct_init (uint32_t accel)
{
#if HAVE_SSE2
if (accel & MPEG2_ACCEL_X86_SSE2) {
mpeg2_idct_copy = mpeg2_idct_copy_sse2;
mpeg2_idct_add = mpeg2_idct_add_sse2;
mpeg2_idct_mmx_init ();
} else
#elif HAVE_MMX2
if (accel & MPEG2_ACCEL_X86_MMXEXT) {
mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
mpeg2_idct_add = mpeg2_idct_add_mmxext;
mpeg2_idct_mmx_init ();
} else
#elif HAVE_MMX
if (accel & MPEG2_ACCEL_X86_MMX) {
mpeg2_idct_copy = mpeg2_idct_copy_mmx;
mpeg2_idct_add = mpeg2_idct_add_mmx;
mpeg2_idct_mmx_init ();
} else
#endif
#if HAVE_ALTIVEC
if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
mpeg2_idct_copy = mpeg2_idct_copy_altivec;
mpeg2_idct_add = mpeg2_idct_add_altivec;
mpeg2_idct_altivec_init ();
} else
#endif
#if HAVE_MVI
if (accel & MPEG2_ACCEL_ALPHA_MVI) {
mpeg2_idct_copy = mpeg2_idct_copy_mvi;
mpeg2_idct_add = mpeg2_idct_add_mvi;
mpeg2_idct_alpha_init ();
} else
#elif ARCH_ALPHA
if (accel & MPEG2_ACCEL_ALPHA) {
int i;
mpeg2_idct_copy = mpeg2_idct_copy_alpha;
mpeg2_idct_add = mpeg2_idct_add_alpha;
mpeg2_idct_alpha_init ();
for (i = -3840; i < 3840 + 256; i++)
CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
} else
#endif
{
int i, j;
mpeg2_idct_copy = mpeg2_idct_copy_c;
mpeg2_idct_add = mpeg2_idct_add_c;
for (i = -3840; i < 3840 + 256; i++)
CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
for (i = 0; i < 64; i++) {
j = mpeg2_scan_norm[i];
mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
j = mpeg2_scan_alt[i];
mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
}
}
}

View File

@ -1,377 +0,0 @@
/*
* idct_alpha.c
* Copyright (C) 2002-2003 Falk Hueffner <falk@debian.org>
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#if ARCH_ALPHA
#include <stdlib.h>
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#include "alpha_asm.h"
#define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */
#define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */
#define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */
#define W5 1609 /* 2048 * sqrt (2) * cos (5 * pi / 16) */
#define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */
#define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */
extern uint8_t mpeg2_clip[3840 * 2 + 256];
#define CLIP(i) ((mpeg2_clip + 3840)[i])
#if 0
#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
do { \
t0 = W0 * d0 + W1 * d1; \
t1 = W0 * d1 - W1 * d0; \
} while (0)
#else
#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
do { \
int_fast32_t tmp = W0 * (d0 + d1); \
t0 = tmp + (W1 - W0) * d1; \
t1 = tmp - (W1 + W0) * d0; \
} while (0)
#endif
static inline void idct_row (int16_t * const block)
{
uint64_t l, r;
int_fast32_t d0, d1, d2, d3;
int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
int_fast32_t t0, t1, t2, t3;
l = ldq (block);
r = ldq (block + 4);
/* shortcut */
if (likely (!((l & ~0xffffUL) | r))) {
uint64_t tmp = (uint16_t) (l >> 1);
tmp |= tmp << 16;
tmp |= tmp << 32;
((int32_t *)block)[0] = tmp;
((int32_t *)block)[1] = tmp;
((int32_t *)block)[2] = tmp;
((int32_t *)block)[3] = tmp;
return;
}
d0 = (sextw (l) << 11) + 2048;
d1 = sextw (extwl (l, 2));
d2 = sextw (extwl (l, 4)) << 11;
d3 = sextw (extwl (l, 6));
t0 = d0 + d2;
t1 = d0 - d2;
BUTTERFLY (t2, t3, W6, W2, d3, d1);
a0 = t0 + t2;
a1 = t1 + t3;
a2 = t1 - t3;
a3 = t0 - t2;
d0 = sextw (r);
d1 = sextw (extwl (r, 2));
d2 = sextw (extwl (r, 4));
d3 = sextw (extwl (r, 6));
BUTTERFLY (t0, t1, W7, W1, d3, d0);
BUTTERFLY (t2, t3, W3, W5, d1, d2);
b0 = t0 + t2;
b3 = t1 + t3;
t0 -= t2;
t1 -= t3;
b1 = ((t0 + t1) >> 8) * 181;
b2 = ((t0 - t1) >> 8) * 181;
block[0] = (a0 + b0) >> 12;
block[1] = (a1 + b1) >> 12;
block[2] = (a2 + b2) >> 12;
block[3] = (a3 + b3) >> 12;
block[4] = (a3 - b3) >> 12;
block[5] = (a2 - b2) >> 12;
block[6] = (a1 - b1) >> 12;
block[7] = (a0 - b0) >> 12;
}
static inline void idct_col (int16_t * const block)
{
int_fast32_t d0, d1, d2, d3;
int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
int_fast32_t t0, t1, t2, t3;
d0 = (block[8*0] << 11) + 65536;
d1 = block[8*1];
d2 = block[8*2] << 11;
d3 = block[8*3];
t0 = d0 + d2;
t1 = d0 - d2;
BUTTERFLY (t2, t3, W6, W2, d3, d1);
a0 = t0 + t2;
a1 = t1 + t3;
a2 = t1 - t3;
a3 = t0 - t2;
d0 = block[8*4];
d1 = block[8*5];
d2 = block[8*6];
d3 = block[8*7];
BUTTERFLY (t0, t1, W7, W1, d3, d0);
BUTTERFLY (t2, t3, W3, W5, d1, d2);
b0 = t0 + t2;
b3 = t1 + t3;
t0 -= t2;
t1 -= t3;
b1 = ((t0 + t1) >> 8) * 181;
b2 = ((t0 - t1) >> 8) * 181;
block[8*0] = (a0 + b0) >> 17;
block[8*1] = (a1 + b1) >> 17;
block[8*2] = (a2 + b2) >> 17;
block[8*3] = (a3 + b3) >> 17;
block[8*4] = (a3 - b3) >> 17;
block[8*5] = (a2 - b2) >> 17;
block[8*6] = (a1 - b1) >> 17;
block[8*7] = (a0 - b0) >> 17;
}
void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, const int stride)
{
uint64_t clampmask;
int i;
for (i = 0; i < 8; i++)
idct_row (block + 8 * i);
for (i = 0; i < 8; i++)
idct_col (block + i);
clampmask = zap (-1, 0xaa); /* 0x00ff00ff00ff00ff */
do {
uint64_t shorts0, shorts1;
shorts0 = ldq (block);
shorts0 = maxsw4 (shorts0, 0);
shorts0 = minsw4 (shorts0, clampmask);
stl (pkwb (shorts0), dest);
shorts1 = ldq (block + 4);
shorts1 = maxsw4 (shorts1, 0);
shorts1 = minsw4 (shorts1, clampmask);
stl (pkwb (shorts1), dest + 4);
stq (0, block);
stq (0, block + 4);
dest += stride;
block += 8;
} while (--i);
}
void mpeg2_idct_add_mvi (const int last, int16_t * block,
uint8_t * dest, const int stride)
{
uint64_t clampmask;
uint64_t signmask;
int i;
if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) {
for (i = 0; i < 8; i++)
idct_row (block + 8 * i);
for (i = 0; i < 8; i++)
idct_col (block + i);
clampmask = zap (-1, 0xaa); /* 0x00ff00ff00ff00ff */
signmask = zap (-1, 0x33);
signmask ^= signmask >> 1; /* 0x8000800080008000 */
do {
uint64_t shorts0, pix0, signs0;
uint64_t shorts1, pix1, signs1;
shorts0 = ldq (block);
shorts1 = ldq (block + 4);
pix0 = unpkbw (ldl (dest));
/* signed subword add (MMX paddw). */
signs0 = shorts0 & signmask;
shorts0 &= ~signmask;
shorts0 += pix0;
shorts0 ^= signs0;
/* clamp. */
shorts0 = maxsw4 (shorts0, 0);
shorts0 = minsw4 (shorts0, clampmask);
/* next 4. */
pix1 = unpkbw (ldl (dest + 4));
signs1 = shorts1 & signmask;
shorts1 &= ~signmask;
shorts1 += pix1;
shorts1 ^= signs1;
shorts1 = maxsw4 (shorts1, 0);
shorts1 = minsw4 (shorts1, clampmask);
stl (pkwb (shorts0), dest);
stl (pkwb (shorts1), dest + 4);
stq (0, block);
stq (0, block + 4);
dest += stride;
block += 8;
} while (--i);
} else {
int DC;
uint64_t p0, p1, p2, p3, p4, p5, p6, p7;
uint64_t DCs;
DC = (block[0] + 64) >> 7;
block[0] = block[63] = 0;
p0 = ldq (dest + 0 * stride);
p1 = ldq (dest + 1 * stride);
p2 = ldq (dest + 2 * stride);
p3 = ldq (dest + 3 * stride);
p4 = ldq (dest + 4 * stride);
p5 = ldq (dest + 5 * stride);
p6 = ldq (dest + 6 * stride);
p7 = ldq (dest + 7 * stride);
if (DC > 0) {
DCs = BYTE_VEC (likely (DC <= 255) ? DC : 255);
p0 += minub8 (DCs, ~p0);
p1 += minub8 (DCs, ~p1);
p2 += minub8 (DCs, ~p2);
p3 += minub8 (DCs, ~p3);
p4 += minub8 (DCs, ~p4);
p5 += minub8 (DCs, ~p5);
p6 += minub8 (DCs, ~p6);
p7 += minub8 (DCs, ~p7);
} else {
DCs = BYTE_VEC (likely (-DC <= 255) ? -DC : 255);
p0 -= minub8 (DCs, p0);
p1 -= minub8 (DCs, p1);
p2 -= minub8 (DCs, p2);
p3 -= minub8 (DCs, p3);
p4 -= minub8 (DCs, p4);
p5 -= minub8 (DCs, p5);
p6 -= minub8 (DCs, p6);
p7 -= minub8 (DCs, p7);
}
stq (p0, dest + 0 * stride);
stq (p1, dest + 1 * stride);
stq (p2, dest + 2 * stride);
stq (p3, dest + 3 * stride);
stq (p4, dest + 4 * stride);
stq (p5, dest + 5 * stride);
stq (p6, dest + 6 * stride);
stq (p7, dest + 7 * stride);
}
}
void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, const int stride)
{
int i;
for (i = 0; i < 8; i++)
idct_row (block + 8 * i);
for (i = 0; i < 8; i++)
idct_col (block + i);
do {
dest[0] = CLIP (block[0]);
dest[1] = CLIP (block[1]);
dest[2] = CLIP (block[2]);
dest[3] = CLIP (block[3]);
dest[4] = CLIP (block[4]);
dest[5] = CLIP (block[5]);
dest[6] = CLIP (block[6]);
dest[7] = CLIP (block[7]);
stq(0, block);
stq(0, block + 4);
dest += stride;
block += 8;
} while (--i);
}
void mpeg2_idct_add_alpha (const int last, int16_t * block,
uint8_t * dest, const int stride)
{
int i;
if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) {
for (i = 0; i < 8; i++)
idct_row (block + 8 * i);
for (i = 0; i < 8; i++)
idct_col (block + i);
do {
dest[0] = CLIP (block[0] + dest[0]);
dest[1] = CLIP (block[1] + dest[1]);
dest[2] = CLIP (block[2] + dest[2]);
dest[3] = CLIP (block[3] + dest[3]);
dest[4] = CLIP (block[4] + dest[4]);
dest[5] = CLIP (block[5] + dest[5]);
dest[6] = CLIP (block[6] + dest[6]);
dest[7] = CLIP (block[7] + dest[7]);
stq(0, block);
stq(0, block + 4);
dest += stride;
block += 8;
} while (--i);
} else {
int DC;
DC = (block[0] + 64) >> 7;
block[0] = block[63] = 0;
i = 8;
do {
dest[0] = CLIP (DC + dest[0]);
dest[1] = CLIP (DC + dest[1]);
dest[2] = CLIP (DC + dest[2]);
dest[3] = CLIP (DC + dest[3]);
dest[4] = CLIP (DC + dest[4]);
dest[5] = CLIP (DC + dest[5]);
dest[6] = CLIP (DC + dest[6]);
dest[7] = CLIP (DC + dest[7]);
dest += stride;
} while (--i);
}
}
void mpeg2_idct_alpha_init (void)
{
int i, j;
for (i = 0; i < 64; i++) {
j = mpeg2_scan_norm[i];
mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
j = mpeg2_scan_alt[i];
mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
}
}
#endif /* ARCH_ALPHA */

View File

@ -1,286 +0,0 @@
/*
* idct_altivec.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#if ARCH_PPC
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
#endif
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
typedef vector signed char vector_s8_t;
typedef vector unsigned char vector_u8_t;
typedef vector signed short vector_s16_t;
typedef vector unsigned short vector_u16_t;
typedef vector signed int vector_s32_t;
typedef vector unsigned int vector_u32_t;
#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_CC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
/* work around gcc <3.3 vec_mergel bug */
static inline vector_s16_t my_vec_mergel (vector_s16_t const A,
vector_s16_t const B)
{
static const vector_u8_t mergel = {
0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
};
return vec_perm (A, B, mergel);
}
#undef vec_mergel
#define vec_mergel my_vec_mergel
#endif
#ifdef HAVE_ALTIVEC_H /* gnu */
#define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
#else /* apple */
#define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) (a, b, c, d, e, f, g, h)
#endif
static const vector_s16_t constants ATTR_ALIGN(16) =
VEC_S16 (23170, 13573, 6518, 21895, -23170, -21895, 32, 31);
static const vector_s16_t constants_1 ATTR_ALIGN(16) =
VEC_S16 (16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725);
static const vector_s16_t constants_2 ATTR_ALIGN(16) =
VEC_S16 (16069, 22289, 20995, 18895, 16069, 18895, 20995, 22289);
static const vector_s16_t constants_3 ATTR_ALIGN(16) =
VEC_S16 (21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692);
static const vector_s16_t constants_4 ATTR_ALIGN(16) =
VEC_S16 (13623, 18895, 17799, 16019, 13623, 16019, 17799, 18895);
#define IDCT \
vector_s16_t vx0, vx1, vx2, vx3, vx4, vx5, vx6, vx7; \
vector_s16_t vy0, vy1, vy2, vy3, vy4, vy5, vy6, vy7; \
vector_s16_t a0, a1, a2, ma2, c4, mc4, zero, bias; \
vector_s16_t t0, t1, t2, t3, t4, t5, t6, t7, t8; \
vector_u16_t shift; \
\
c4 = vec_splat (constants, 0); \
a0 = vec_splat (constants, 1); \
a1 = vec_splat (constants, 2); \
a2 = vec_splat (constants, 3); \
mc4 = vec_splat (constants, 4); \
ma2 = vec_splat (constants, 5); \
bias = (vector_s16_t)vec_splat ((vector_s32_t)constants, 3); \
\
zero = vec_splat_s16 (0); \
\
vx0 = vec_adds (block[0], block[4]); \
vx4 = vec_subs (block[0], block[4]); \
t5 = vec_mradds (vx0, constants_1, zero); \
t0 = vec_mradds (vx4, constants_1, zero); \
\
vx1 = vec_mradds (a1, block[7], block[1]); \
vx7 = vec_mradds (a1, block[1], vec_subs (zero, block[7])); \
t1 = vec_mradds (vx1, constants_2, zero); \
t8 = vec_mradds (vx7, constants_2, zero); \
\
vx2 = vec_mradds (a0, block[6], block[2]); \
vx6 = vec_mradds (a0, block[2], vec_subs (zero, block[6])); \
t2 = vec_mradds (vx2, constants_3, zero); \
t4 = vec_mradds (vx6, constants_3, zero); \
\
vx3 = vec_mradds (block[3], constants_4, zero); \
vx5 = vec_mradds (block[5], constants_4, zero); \
t7 = vec_mradds (a2, vx5, vx3); \
t3 = vec_mradds (ma2, vx3, vx5); \
\
t6 = vec_adds (t8, t3); \
t3 = vec_subs (t8, t3); \
t8 = vec_subs (t1, t7); \
t1 = vec_adds (t1, t7); \
t6 = vec_mradds (a0, t6, t6); /* a0+1 == 2*c4 */ \
t1 = vec_mradds (a0, t1, t1); /* a0+1 == 2*c4 */ \
\
t7 = vec_adds (t5, t2); \
t2 = vec_subs (t5, t2); \
t5 = vec_adds (t0, t4); \
t0 = vec_subs (t0, t4); \
t4 = vec_subs (t8, t3); \
t3 = vec_adds (t8, t3); \
\
vy0 = vec_adds (t7, t1); \
vy7 = vec_subs (t7, t1); \
vy1 = vec_adds (t5, t3); \
vy6 = vec_subs (t5, t3); \
vy2 = vec_adds (t0, t4); \
vy5 = vec_subs (t0, t4); \
vy3 = vec_adds (t2, t6); \
vy4 = vec_subs (t2, t6); \
\
vx0 = vec_mergeh (vy0, vy4); \
vx1 = vec_mergel (vy0, vy4); \
vx2 = vec_mergeh (vy1, vy5); \
vx3 = vec_mergel (vy1, vy5); \
vx4 = vec_mergeh (vy2, vy6); \
vx5 = vec_mergel (vy2, vy6); \
vx6 = vec_mergeh (vy3, vy7); \
vx7 = vec_mergel (vy3, vy7); \
\
vy0 = vec_mergeh (vx0, vx4); \
vy1 = vec_mergel (vx0, vx4); \
vy2 = vec_mergeh (vx1, vx5); \
vy3 = vec_mergel (vx1, vx5); \
vy4 = vec_mergeh (vx2, vx6); \
vy5 = vec_mergel (vx2, vx6); \
vy6 = vec_mergeh (vx3, vx7); \
vy7 = vec_mergel (vx3, vx7); \
\
vx0 = vec_mergeh (vy0, vy4); \
vx1 = vec_mergel (vy0, vy4); \
vx2 = vec_mergeh (vy1, vy5); \
vx3 = vec_mergel (vy1, vy5); \
vx4 = vec_mergeh (vy2, vy6); \
vx5 = vec_mergel (vy2, vy6); \
vx6 = vec_mergeh (vy3, vy7); \
vx7 = vec_mergel (vy3, vy7); \
\
vx0 = vec_adds (vx0, bias); \
t5 = vec_adds (vx0, vx4); \
t0 = vec_subs (vx0, vx4); \
\
t1 = vec_mradds (a1, vx7, vx1); \
t8 = vec_mradds (a1, vx1, vec_subs (zero, vx7)); \
\
t2 = vec_mradds (a0, vx6, vx2); \
t4 = vec_mradds (a0, vx2, vec_subs (zero, vx6)); \
\
t7 = vec_mradds (a2, vx5, vx3); \
t3 = vec_mradds (ma2, vx3, vx5); \
\
t6 = vec_adds (t8, t3); \
t3 = vec_subs (t8, t3); \
t8 = vec_subs (t1, t7); \
t1 = vec_adds (t1, t7); \
\
t7 = vec_adds (t5, t2); \
t2 = vec_subs (t5, t2); \
t5 = vec_adds (t0, t4); \
t0 = vec_subs (t0, t4); \
t4 = vec_subs (t8, t3); \
t3 = vec_adds (t8, t3); \
\
vy0 = vec_adds (t7, t1); \
vy7 = vec_subs (t7, t1); \
vy1 = vec_mradds (c4, t3, t5); \
vy6 = vec_mradds (mc4, t3, t5); \
vy2 = vec_mradds (c4, t4, t0); \
vy5 = vec_mradds (mc4, t4, t0); \
vy3 = vec_adds (t2, t6); \
vy4 = vec_subs (t2, t6); \
\
shift = vec_splat_u16 (6); \
vx0 = vec_sra (vy0, shift); \
vx1 = vec_sra (vy1, shift); \
vx2 = vec_sra (vy2, shift); \
vx3 = vec_sra (vy3, shift); \
vx4 = vec_sra (vy4, shift); \
vx5 = vec_sra (vy5, shift); \
vx6 = vec_sra (vy6, shift); \
vx7 = vec_sra (vy7, shift);
void mpeg2_idct_copy_altivec (int16_t * const _block, uint8_t * dest,
const int stride)
{
vector_s16_t * const block = (vector_s16_t *)_block;
vector_u8_t tmp;
IDCT
#define COPY(dest,src) \
tmp = vec_packsu (src, src); \
vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest); \
vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);
COPY (dest, vx0) dest += stride;
COPY (dest, vx1) dest += stride;
COPY (dest, vx2) dest += stride;
COPY (dest, vx3) dest += stride;
COPY (dest, vx4) dest += stride;
COPY (dest, vx5) dest += stride;
COPY (dest, vx6) dest += stride;
COPY (dest, vx7)
block[0] = block[1] = block[2] = block[3] = zero;
block[4] = block[5] = block[6] = block[7] = zero;
}
void mpeg2_idct_add_altivec (const int last, int16_t * const _block,
uint8_t * dest, const int stride)
{
vector_s16_t * const block = (vector_s16_t *)_block;
vector_u8_t tmp;
vector_s16_t tmp2, tmp3;
vector_u8_t perm0;
vector_u8_t perm1;
vector_u8_t p0, p1, p;
IDCT
p0 = vec_lvsl (0, dest);
p1 = vec_lvsl (stride, dest);
p = vec_splat_u8 (-1);
perm0 = vec_mergeh (p, p0);
perm1 = vec_mergeh (p, p1);
#define ADD(dest,src,perm) \
/* *(uint64_t *)&tmp = *(uint64_t *)dest; */ \
tmp = vec_ld (0, dest); \
tmp2 = (vector_s16_t)vec_perm (tmp, (vector_u8_t)zero, perm); \
tmp3 = vec_adds (tmp2, src); \
tmp = vec_packsu (tmp3, tmp3); \
vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest); \
vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);
ADD (dest, vx0, perm0) dest += stride;
ADD (dest, vx1, perm1) dest += stride;
ADD (dest, vx2, perm0) dest += stride;
ADD (dest, vx3, perm1) dest += stride;
ADD (dest, vx4, perm0) dest += stride;
ADD (dest, vx5, perm1) dest += stride;
ADD (dest, vx6, perm0) dest += stride;
ADD (dest, vx7, perm1)
block[0] = block[1] = block[2] = block[3] = zero;
block[4] = block[5] = block[6] = block[7] = zero;
}
void mpeg2_idct_altivec_init (void)
{
int i, j;
/* the altivec idct uses a transposed input, so we patch scan tables */
for (i = 0; i < 64; i++) {
j = mpeg2_scan_norm[i];
mpeg2_scan_norm[i] = (j >> 3) | ((j & 7) << 3);
j = mpeg2_scan_alt[i];
mpeg2_scan_alt[i] = (j >> 3) | ((j & 7) << 3);
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,439 +0,0 @@
--- libmpeg2/cpu_accel.c 2006-06-16 20:12:26.000000000 +0200
+++ libmpeg2/cpu_accel.c 2006-06-16 20:12:50.000000000 +0200
@@ -29,9 +33,13 @@
#include "attributes.h"
#include "mpeg2_internal.h"
+#include "cpudetect.h"
+
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if ARCH_X86 || ARCH_X86_64
static inline uint32_t arch_accel (uint32_t accel)
{
+/* Use MPlayer CPU detection instead of libmpeg2 variant. */
+#if 0
if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
accel |= MPEG2_ACCEL_X86_MMX;
@@ -124,6 +132,21 @@
#endif /* ACCEL_DETECT */
return accel;
+
+#else /* 0 */
+ accel = 0;
+ if (gCpuCaps.hasMMX)
+ accel |= MPEG2_ACCEL_X86_MMX;
+ if (gCpuCaps.hasSSE2)
+ accel |= MPEG2_ACCEL_X86_SSE2;
+ if (gCpuCaps.hasMMX2)
+ accel |= MPEG2_ACCEL_X86_MMXEXT;
+ if (gCpuCaps.has3DNow)
+ accel |= MPEG2_ACCEL_X86_3DNOW;
+
+ return accel;
+
+#endif /* 0 */
}
#endif /* ARCH_X86 || ARCH_X86_64 */
@@ -127,7 +150,7 @@
}
#endif /* ARCH_X86 || ARCH_X86_64 */
-#if defined(ACCEL_DETECT) && (defined(ARCH_PPC) || defined(ARCH_SPARC))
+#if defined(ACCEL_DETECT) && (ARCH_PPC || ARCH_SPARC)
#include <signal.h>
#include <setjmp.h>
@@ -146,7 +169,7 @@
}
#endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */
-#ifdef ARCH_PPC
+#if ARCH_PPC
static uint32_t arch_accel (uint32_t accel)
{
#ifdef ACCEL_DETECT
@@ -183,7 +206,7 @@
}
#endif /* ARCH_PPC */
-#ifdef ARCH_SPARC
+#if ARCH_SPARC
static uint32_t arch_accel (uint32_t accel)
{
if (accel & MPEG2_ACCEL_SPARC_VIS2)
@@ -229,7 +252,7 @@
}
#endif /* ARCH_SPARC */
-#ifdef ARCH_ALPHA
+#if ARCH_ALPHA
static inline uint32_t arch_accel (uint32_t accel)
{
if (accel & MPEG2_ACCEL_ALPHA_MVI)
@@ -253,7 +276,7 @@
uint32_t mpeg2_detect_accel (uint32_t accel)
{
-#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
+#if ARCH_X86 || ARCH_X86_64 || ARCH_PPC || ARCH_ALPHA || ARCH_SPARC
accel = arch_accel (accel);
#endif
return accel;
Index: libmpeg2/cpu_state.c
===================================================================
--- libmpeg2/cpu_state.c (revision 28324)
+++ libmpeg2/cpu_state.c (revision 28325)
@@ -29,21 +29,21 @@
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if ARCH_X86 || ARCH_X86_64
#include "mmx.h"
#endif
void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if ARCH_X86 || ARCH_X86_64
static void state_restore_mmx (cpu_state_t * state)
{
emms ();
}
#endif
-#ifdef ARCH_PPC
+#if ARCH_PPC
#if defined(__APPLE_CC__) /* apple */
#define LI(a,b) "li r" #a "," #b "\n\t"
#define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
@@ -115,12 +115,12 @@
void mpeg2_cpu_state_init (uint32_t accel)
{
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if ARCH_X86 || ARCH_X86_64
if (accel & MPEG2_ACCEL_X86_MMX) {
mpeg2_cpu_state_restore = state_restore_mmx;
}
#endif
-#ifdef ARCH_PPC
+#if ARCH_PPC
if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
mpeg2_cpu_state_save = state_save_altivec;
mpeg2_cpu_state_restore = state_restore_altivec;
--- libmpeg2/decode.c 2006-06-16 20:12:26.000000000 +0200
+++ libmpeg2/decode.c 2006-06-16 20:12:50.000000000 +0200
@@ -345,6 +349,15 @@
fbuf->buf[1] = buf[1];
fbuf->buf[2] = buf[2];
fbuf->id = id;
+ // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
+ if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
+ mpeg2dec->fbuf[1]->buf[0]=buf[0];
+ mpeg2dec->fbuf[1]->buf[1]=buf[1];
+ mpeg2dec->fbuf[1]->buf[2]=buf[2];
+ mpeg2dec->fbuf[1]->id=NULL;
+ }
+// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
+// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
}
void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
--- libmpeg2/header.c 2006-06-16 20:12:26.000000000 +0200
+++ libmpeg2/header.c 2006-06-16 20:12:50.000000000 +0200
@@ -100,6 +104,9 @@
mpeg2dec->decoder.convert = NULL;
mpeg2dec->decoder.convert_id = NULL;
mpeg2dec->picture = mpeg2dec->pictures;
+ memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
+ memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
+ memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
@@ -872,6 +879,7 @@
mpeg2dec->scaled[idx] = decoder->q_scale_type;
for (i = 0; i < 32; i++) {
k = decoder->q_scale_type ? non_linear_scale[i] : (i << 1);
+ decoder->quantizer_scales[i] = k;
for (j = 0; j < 64; j++)
decoder->quantizer_prescale[idx][i][j] =
k * mpeg2dec->quantizer_matrix[idx][j];
--- libmpeg2/idct.c (revision 26652)
+++ libmpeg2/idct.c (working copy)
@@ -235,34 +239,40 @@
void mpeg2_idct_init (uint32_t accel)
{
-#ifdef ARCH_X86
+#if HAVE_SSE2
if (accel & MPEG2_ACCEL_X86_SSE2) {
mpeg2_idct_copy = mpeg2_idct_copy_sse2;
mpeg2_idct_add = mpeg2_idct_add_sse2;
mpeg2_idct_mmx_init ();
- } else if (accel & MPEG2_ACCEL_X86_MMXEXT) {
+ } else
+#elif HAVE_MMX2
+ if (accel & MPEG2_ACCEL_X86_MMXEXT) {
mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
mpeg2_idct_add = mpeg2_idct_add_mmxext;
mpeg2_idct_mmx_init ();
- } else if (accel & MPEG2_ACCEL_X86_MMX) {
+ } else
+#elif HAVE_MMX
+ if (accel & MPEG2_ACCEL_X86_MMX) {
mpeg2_idct_copy = mpeg2_idct_copy_mmx;
mpeg2_idct_add = mpeg2_idct_add_mmx;
mpeg2_idct_mmx_init ();
} else
#endif
-#ifdef ARCH_PPC
+#if HAVE_ALTIVEC
if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
mpeg2_idct_copy = mpeg2_idct_copy_altivec;
mpeg2_idct_add = mpeg2_idct_add_altivec;
mpeg2_idct_altivec_init ();
} else
#endif
-#ifdef ARCH_ALPHA
+#if HAVE_MVI
if (accel & MPEG2_ACCEL_ALPHA_MVI) {
mpeg2_idct_copy = mpeg2_idct_copy_mvi;
mpeg2_idct_add = mpeg2_idct_add_mvi;
mpeg2_idct_alpha_init ();
- } else if (accel & MPEG2_ACCEL_ALPHA) {
+ } else
+#elif ARCH_ALPHA
+ if (accel & MPEG2_ACCEL_ALPHA) {
int i;
mpeg2_idct_copy = mpeg2_idct_copy_alpha;
Index: libmpeg2/idct_alpha.c
===================================================================
--- libmpeg2/idct_alpha.c (revision 28324)
+++ libmpeg2/idct_alpha.c (revision 28325)
@@ -24,7 +24,7 @@
#include "config.h"
-#ifdef ARCH_ALPHA
+#if ARCH_ALPHA
#include <stdlib.h>
#include <inttypes.h>
Index: libmpeg2/idct_altivec.c
===================================================================
--- libmpeg2/idct_altivec.c (revision 28324)
+++ libmpeg2/idct_altivec.c (revision 28325)
@@ -23,7 +23,7 @@
#include "config.h"
-#ifdef ARCH_PPC
+#if ARCH_PPC
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
Index: libmpeg2/idct_mmx.c
===================================================================
--- libmpeg2/idct_mmx.c (revision 28324)
+++ libmpeg2/idct_mmx.c (revision 28325)
@@ -23,7 +23,7 @@
#include "config.h"
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if ARCH_X86 || ARCH_X86_64
#include <inttypes.h>
--- libmpeg2/motion_comp.c 2006-06-16 20:12:26.000000000 +0200
+++ libmpeg2/motion_comp.c 2006-06-16 20:12:50.000000000 +0200
@@ -33,34 +37,40 @@
void mpeg2_mc_init (uint32_t accel)
{
-#ifdef ARCH_X86
+#if HAVE_MMX2
if (accel & MPEG2_ACCEL_X86_MMXEXT)
mpeg2_mc = mpeg2_mc_mmxext;
- else if (accel & MPEG2_ACCEL_X86_3DNOW)
+ else
+#endif
+#if HAVE_AMD3DNOW
+ if (accel & MPEG2_ACCEL_X86_3DNOW)
mpeg2_mc = mpeg2_mc_3dnow;
- else if (accel & MPEG2_ACCEL_X86_MMX)
+ else
+#endif
+#if HAVE_MMX
+ if (accel & MPEG2_ACCEL_X86_MMX)
mpeg2_mc = mpeg2_mc_mmx;
else
#endif
-#ifdef ARCH_PPC
+#if HAVE_ALTIVEC
if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
mpeg2_mc = mpeg2_mc_altivec;
else
#endif
-#ifdef ARCH_ALPHA
+#if ARCH_ALPHA
if (accel & MPEG2_ACCEL_ALPHA)
mpeg2_mc = mpeg2_mc_alpha;
else
#endif
-#ifdef ARCH_SPARC
+#if HAVE_VIS
if (accel & MPEG2_ACCEL_SPARC_VIS)
mpeg2_mc = mpeg2_mc_vis;
else
#endif
-#ifdef ARCH_ARM
+#if ARCH_ARM
- if (accel & MPEG2_ACCEL_ARM) {
+ if (accel & MPEG2_ACCEL_ARM)
mpeg2_mc = mpeg2_mc_arm;
- } else
+ else
#endif
mpeg2_mc = mpeg2_mc_c;
}
Index: libmpeg2/motion_comp_alpha.c
===================================================================
--- libmpeg2/motion_comp_alpha.c (revision 28324)
+++ libmpeg2/motion_comp_alpha.c (revision 28325)
@@ -22,7 +22,7 @@
#include "config.h"
-#ifdef ARCH_ALPHA
+#if ARCH_ALPHA
#include <inttypes.h>
Index: libmpeg2/motion_comp_altivec.c
===================================================================
--- libmpeg2/motion_comp_altivec.c (revision 28324)
+++ libmpeg2/motion_comp_altivec.c (revision 28325)
@@ -23,7 +23,7 @@
#include "config.h"
-#ifdef ARCH_PPC
+#if ARCH_PPC
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
Index: libmpeg2/motion_comp_arm.c
===================================================================
--- libmpeg2/motion_comp_arm.c (revision 28324)
+++ libmpeg2/motion_comp_arm.c (revision 28325)
@@ -22,7 +22,7 @@
#include "config.h"
-#ifdef ARCH_ARM
+#if ARCH_ARM
#include <inttypes.h>
Index: libmpeg2/motion_comp_mmx.c
===================================================================
--- libmpeg2/motion_comp_mmx.c (revision 28324)
+++ libmpeg2/motion_comp_mmx.c (revision 28325)
@@ -23,7 +23,7 @@
#include "config.h"
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
+#if ARCH_X86 || ARCH_X86_64
#include <inttypes.h>
Index: libmpeg2/motion_comp_vis.c
===================================================================
--- libmpeg2/motion_comp_vis.c (revision 28324)
+++ libmpeg2/motion_comp_vis.c (revision 28325)
@@ -22,7 +22,7 @@
#include "config.h"
-#ifdef ARCH_SPARC
+#if ARCH_SPARC
#include <inttypes.h>
--- libmpeg2/mpeg2_internal.h 2006-06-16 20:12:26.000000000 +0200
+++ libmpeg2/mpeg2_internal.h 2006-06-16 20:12:50.000000000 +0200
@@ -152,6 +156,11 @@
/* XXX: stuff due to xine shit */
int8_t q_scale_type;
+
+ int quantizer_scales[32];
+ int quantizer_scale;
+ char* quant_store;
+ int quant_stride;
};
typedef struct {
@@ -223,6 +232,9 @@
//int8_t q_scale_type, scaled[4];
uint8_t quantizer_matrix[4][64];
uint8_t new_quantizer_matrix[4][64];
+
+ unsigned char *pending_buffer;
+ int pending_length;
};
typedef struct {
@@ -226,7 +238,7 @@
};
typedef struct {
-#ifdef ARCH_PPC
+#if ARCH_PPC
uint8_t regv[12*16];
#endif
int dummy;
--- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200
+++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200
@@ -142,6 +146,7 @@
quantizer_scale_code = UBITS (bit_buf, 5);
DUMPBITS (bit_buf, bits, 5);
+ decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
decoder->quantizer_matrix[0] =
decoder->quantizer_prescale[0][quantizer_scale_code];
@@ -1564,6 +1569,24 @@
#define NEXT_MACROBLOCK \
do { \
+ if(decoder->quant_store) { \
+ if (decoder->picture_structure == TOP_FIELD) \
+ decoder->quant_store[2 * decoder->quant_stride \
+ * (decoder->v_offset >> 4) \
+ + (decoder->offset >> 4)] \
+ = decoder->quantizer_scale; \
+ else if (decoder->picture_structure == BOTTOM_FIELD) \
+ decoder->quant_store[2 * decoder->quant_stride \
+ * (decoder->v_offset >> 4) \
+ + decoder->quant_stride \
+ + (decoder->offset >> 4)] \
+ = decoder->quantizer_scale; \
+ else \
+ decoder->quant_store[decoder->quant_stride \
+ * (decoder->v_offset >> 4) \
+ + (decoder->offset >> 4)] \
+ = decoder->quantizer_scale; \
+ } \
decoder->offset += 16; \
if (decoder->offset == decoder->width) { \
do { /* just so we can use the break statement */ \

View File

@ -1,292 +0,0 @@
/*
* mmx.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LIBMPEG2_MMX_H
#define LIBMPEG2_MMX_H
/*
* The type of an value that fits in an MMX register (note that long
* long constant values MUST be suffixed by LL and unsigned long long
* values by ULL, lest they be truncated by the compiler)
*/
typedef union {
long long q; /* Quadword (64-bit) value */
unsigned long long uq; /* Unsigned Quadword */
int d[2]; /* 2 Doubleword (32-bit) values */
unsigned int ud[2]; /* 2 Unsigned Doubleword */
short w[4]; /* 4 Word (16-bit) values */
unsigned short uw[4]; /* 4 Unsigned Word */
char b[8]; /* 8 Byte (8-bit) values */
unsigned char ub[8]; /* 8 Unsigned Byte */
float s[2]; /* Single-precision (32-bit) value */
} ATTR_ALIGN(8) mmx_t; /* On an 8-byte (64-bit) boundary */
#define mmx_i2r(op,imm,reg) \
__asm__ __volatile__ (#op " %0, %%" #reg \
: /* nothing */ \
: "i" (imm) )
#define mmx_m2r(op,mem,reg) \
__asm__ __volatile__ (#op " %0, %%" #reg \
: /* nothing */ \
: "m" (mem))
#define mmx_r2m(op,reg,mem) \
__asm__ __volatile__ (#op " %%" #reg ", %0" \
: "=m" (mem) \
: /* nothing */ )
#define mmx_r2r(op,regs,regd) \
__asm__ __volatile__ (#op " %" #regs ", %" #regd)
#define emms() __asm__ __volatile__ ("emms")
#define movd_m2r(var,reg) mmx_m2r (movd, var, reg)
#define movd_r2m(reg,var) mmx_r2m (movd, reg, var)
#define movd_v2r(var,reg) __asm__ __volatile__ ("movd %0, %%" #reg \
: /* nothing */ \
: "rm" (var))
#define movd_r2v(reg,var) __asm__ __volatile__ ("movd %%" #reg ", %0" \
: "=rm" (var) \
: /* nothing */ )
#define movq_m2r(var,reg) mmx_m2r (movq, var, reg)
#define movq_r2m(reg,var) mmx_r2m (movq, reg, var)
#define movq_r2r(regs,regd) mmx_r2r (movq, regs, regd)
#define packssdw_m2r(var,reg) mmx_m2r (packssdw, var, reg)
#define packssdw_r2r(regs,regd) mmx_r2r (packssdw, regs, regd)
#define packsswb_m2r(var,reg) mmx_m2r (packsswb, var, reg)
#define packsswb_r2r(regs,regd) mmx_r2r (packsswb, regs, regd)
#define packuswb_m2r(var,reg) mmx_m2r (packuswb, var, reg)
#define packuswb_r2r(regs,regd) mmx_r2r (packuswb, regs, regd)
#define paddb_m2r(var,reg) mmx_m2r (paddb, var, reg)
#define paddb_r2r(regs,regd) mmx_r2r (paddb, regs, regd)
#define paddd_m2r(var,reg) mmx_m2r (paddd, var, reg)
#define paddd_r2r(regs,regd) mmx_r2r (paddd, regs, regd)
#define paddw_m2r(var,reg) mmx_m2r (paddw, var, reg)
#define paddw_r2r(regs,regd) mmx_r2r (paddw, regs, regd)
#define paddsb_m2r(var,reg) mmx_m2r (paddsb, var, reg)
#define paddsb_r2r(regs,regd) mmx_r2r (paddsb, regs, regd)
#define paddsw_m2r(var,reg) mmx_m2r (paddsw, var, reg)
#define paddsw_r2r(regs,regd) mmx_r2r (paddsw, regs, regd)
#define paddusb_m2r(var,reg) mmx_m2r (paddusb, var, reg)
#define paddusb_r2r(regs,regd) mmx_r2r (paddusb, regs, regd)
#define paddusw_m2r(var,reg) mmx_m2r (paddusw, var, reg)
#define paddusw_r2r(regs,regd) mmx_r2r (paddusw, regs, regd)
#define pand_m2r(var,reg) mmx_m2r (pand, var, reg)
#define pand_r2r(regs,regd) mmx_r2r (pand, regs, regd)
#define pandn_m2r(var,reg) mmx_m2r (pandn, var, reg)
#define pandn_r2r(regs,regd) mmx_r2r (pandn, regs, regd)
#define pcmpeqb_m2r(var,reg) mmx_m2r (pcmpeqb, var, reg)
#define pcmpeqb_r2r(regs,regd) mmx_r2r (pcmpeqb, regs, regd)
#define pcmpeqd_m2r(var,reg) mmx_m2r (pcmpeqd, var, reg)
#define pcmpeqd_r2r(regs,regd) mmx_r2r (pcmpeqd, regs, regd)
#define pcmpeqw_m2r(var,reg) mmx_m2r (pcmpeqw, var, reg)
#define pcmpeqw_r2r(regs,regd) mmx_r2r (pcmpeqw, regs, regd)
#define pcmpgtb_m2r(var,reg) mmx_m2r (pcmpgtb, var, reg)
#define pcmpgtb_r2r(regs,regd) mmx_r2r (pcmpgtb, regs, regd)
#define pcmpgtd_m2r(var,reg) mmx_m2r (pcmpgtd, var, reg)
#define pcmpgtd_r2r(regs,regd) mmx_r2r (pcmpgtd, regs, regd)
#define pcmpgtw_m2r(var,reg) mmx_m2r (pcmpgtw, var, reg)
#define pcmpgtw_r2r(regs,regd) mmx_r2r (pcmpgtw, regs, regd)
#define pmaddwd_m2r(var,reg) mmx_m2r (pmaddwd, var, reg)
#define pmaddwd_r2r(regs,regd) mmx_r2r (pmaddwd, regs, regd)
#define pmulhw_m2r(var,reg) mmx_m2r (pmulhw, var, reg)
#define pmulhw_r2r(regs,regd) mmx_r2r (pmulhw, regs, regd)
#define pmullw_m2r(var,reg) mmx_m2r (pmullw, var, reg)
#define pmullw_r2r(regs,regd) mmx_r2r (pmullw, regs, regd)
#define por_m2r(var,reg) mmx_m2r (por, var, reg)
#define por_r2r(regs,regd) mmx_r2r (por, regs, regd)
#define pslld_i2r(imm,reg) mmx_i2r (pslld, imm, reg)
#define pslld_m2r(var,reg) mmx_m2r (pslld, var, reg)
#define pslld_r2r(regs,regd) mmx_r2r (pslld, regs, regd)
#define psllq_i2r(imm,reg) mmx_i2r (psllq, imm, reg)
#define psllq_m2r(var,reg) mmx_m2r (psllq, var, reg)
#define psllq_r2r(regs,regd) mmx_r2r (psllq, regs, regd)
#define psllw_i2r(imm,reg) mmx_i2r (psllw, imm, reg)
#define psllw_m2r(var,reg) mmx_m2r (psllw, var, reg)
#define psllw_r2r(regs,regd) mmx_r2r (psllw, regs, regd)
#define psrad_i2r(imm,reg) mmx_i2r (psrad, imm, reg)
#define psrad_m2r(var,reg) mmx_m2r (psrad, var, reg)
#define psrad_r2r(regs,regd) mmx_r2r (psrad, regs, regd)
#define psraw_i2r(imm,reg) mmx_i2r (psraw, imm, reg)
#define psraw_m2r(var,reg) mmx_m2r (psraw, var, reg)
#define psraw_r2r(regs,regd) mmx_r2r (psraw, regs, regd)
#define psrld_i2r(imm,reg) mmx_i2r (psrld, imm, reg)
#define psrld_m2r(var,reg) mmx_m2r (psrld, var, reg)
#define psrld_r2r(regs,regd) mmx_r2r (psrld, regs, regd)
#define psrlq_i2r(imm,reg) mmx_i2r (psrlq, imm, reg)
#define psrlq_m2r(var,reg) mmx_m2r (psrlq, var, reg)
#define psrlq_r2r(regs,regd) mmx_r2r (psrlq, regs, regd)
#define psrlw_i2r(imm,reg) mmx_i2r (psrlw, imm, reg)
#define psrlw_m2r(var,reg) mmx_m2r (psrlw, var, reg)
#define psrlw_r2r(regs,regd) mmx_r2r (psrlw, regs, regd)
#define psubb_m2r(var,reg) mmx_m2r (psubb, var, reg)
#define psubb_r2r(regs,regd) mmx_r2r (psubb, regs, regd)
#define psubd_m2r(var,reg) mmx_m2r (psubd, var, reg)
#define psubd_r2r(regs,regd) mmx_r2r (psubd, regs, regd)
#define psubw_m2r(var,reg) mmx_m2r (psubw, var, reg)
#define psubw_r2r(regs,regd) mmx_r2r (psubw, regs, regd)
#define psubsb_m2r(var,reg) mmx_m2r (psubsb, var, reg)
#define psubsb_r2r(regs,regd) mmx_r2r (psubsb, regs, regd)
#define psubsw_m2r(var,reg) mmx_m2r (psubsw, var, reg)
#define psubsw_r2r(regs,regd) mmx_r2r (psubsw, regs, regd)
#define psubusb_m2r(var,reg) mmx_m2r (psubusb, var, reg)
#define psubusb_r2r(regs,regd) mmx_r2r (psubusb, regs, regd)
#define psubusw_m2r(var,reg) mmx_m2r (psubusw, var, reg)
#define psubusw_r2r(regs,regd) mmx_r2r (psubusw, regs, regd)
#define punpckhbw_m2r(var,reg) mmx_m2r (punpckhbw, var, reg)
#define punpckhbw_r2r(regs,regd) mmx_r2r (punpckhbw, regs, regd)
#define punpckhdq_m2r(var,reg) mmx_m2r (punpckhdq, var, reg)
#define punpckhdq_r2r(regs,regd) mmx_r2r (punpckhdq, regs, regd)
#define punpckhwd_m2r(var,reg) mmx_m2r (punpckhwd, var, reg)
#define punpckhwd_r2r(regs,regd) mmx_r2r (punpckhwd, regs, regd)
#define punpcklbw_m2r(var,reg) mmx_m2r (punpcklbw, var, reg)
#define punpcklbw_r2r(regs,regd) mmx_r2r (punpcklbw, regs, regd)
#define punpckldq_m2r(var,reg) mmx_m2r (punpckldq, var, reg)
#define punpckldq_r2r(regs,regd) mmx_r2r (punpckldq, regs, regd)
#define punpcklwd_m2r(var,reg) mmx_m2r (punpcklwd, var, reg)
#define punpcklwd_r2r(regs,regd) mmx_r2r (punpcklwd, regs, regd)
#define pxor_m2r(var,reg) mmx_m2r (pxor, var, reg)
#define pxor_r2r(regs,regd) mmx_r2r (pxor, regs, regd)
/* 3DNOW extensions */
#define pavgusb_m2r(var,reg) mmx_m2r (pavgusb, var, reg)
#define pavgusb_r2r(regs,regd) mmx_r2r (pavgusb, regs, regd)
/* AMD MMX extensions - also available in intel SSE */
#define mmx_m2ri(op,mem,reg,imm) \
__asm__ __volatile__ (#op " %1, %0, %%" #reg \
: /* nothing */ \
: "m" (mem), "i" (imm))
#define mmx_r2ri(op,regs,regd,imm) \
__asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \
: /* nothing */ \
: "i" (imm) )
#define mmx_fetch(mem,hint) \
__asm__ __volatile__ ("prefetch" #hint " %0" \
: /* nothing */ \
: "m" (mem))
#define maskmovq(regs,maskreg) mmx_r2ri (maskmovq, regs, maskreg)
#define movntq_r2m(mmreg,var) mmx_r2m (movntq, mmreg, var)
#define pavgb_m2r(var,reg) mmx_m2r (pavgb, var, reg)
#define pavgb_r2r(regs,regd) mmx_r2r (pavgb, regs, regd)
#define pavgw_m2r(var,reg) mmx_m2r (pavgw, var, reg)
#define pavgw_r2r(regs,regd) mmx_r2r (pavgw, regs, regd)
#define pextrw_r2r(mmreg,reg,imm) mmx_r2ri (pextrw, mmreg, reg, imm)
#define pinsrw_r2r(reg,mmreg,imm) mmx_r2ri (pinsrw, reg, mmreg, imm)
#define pmaxsw_m2r(var,reg) mmx_m2r (pmaxsw, var, reg)
#define pmaxsw_r2r(regs,regd) mmx_r2r (pmaxsw, regs, regd)
#define pmaxub_m2r(var,reg) mmx_m2r (pmaxub, var, reg)
#define pmaxub_r2r(regs,regd) mmx_r2r (pmaxub, regs, regd)
#define pminsw_m2r(var,reg) mmx_m2r (pminsw, var, reg)
#define pminsw_r2r(regs,regd) mmx_r2r (pminsw, regs, regd)
#define pminub_m2r(var,reg) mmx_m2r (pminub, var, reg)
#define pminub_r2r(regs,regd) mmx_r2r (pminub, regs, regd)
#define pmovmskb(mmreg,reg) \
__asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg)
#define pmulhuw_m2r(var,reg) mmx_m2r (pmulhuw, var, reg)
#define pmulhuw_r2r(regs,regd) mmx_r2r (pmulhuw, regs, regd)
#define prefetcht0(mem) mmx_fetch (mem, t0)
#define prefetcht1(mem) mmx_fetch (mem, t1)
#define prefetcht2(mem) mmx_fetch (mem, t2)
#define prefetchnta(mem) mmx_fetch (mem, nta)
#define psadbw_m2r(var,reg) mmx_m2r (psadbw, var, reg)
#define psadbw_r2r(regs,regd) mmx_r2r (psadbw, regs, regd)
/* SSE2 */
typedef union {
long long q[2]; /* Quadword (64-bit) value */
unsigned long long uq[2]; /* Unsigned Quadword */
int d[4]; /* 2 Doubleword (32-bit) values */
unsigned int ud[4]; /* 2 Unsigned Doubleword */
short w[8]; /* 4 Word (16-bit) values */
unsigned short uw[8]; /* 4 Unsigned Word */
char b[16]; /* 8 Byte (8-bit) values */
unsigned char ub[16]; /* 8 Unsigned Byte */
float s[4]; /* Single-precision (32-bit) value */
} ATTR_ALIGN(16) sse_t; /* On an 16-byte (128-bit) boundary */
#define movdqu_m2r(var,reg) mmx_m2r (movdqu, var, reg)
#define movdqu_r2m(reg,var) mmx_r2m (movdqu, reg, var)
#define movdqu_r2r(regs,regd) mmx_r2r (movdqu, regs, regd)
#define movdqa_m2r(var,reg) mmx_m2r (movdqa, var, reg)
#define movdqa_r2m(reg,var) mmx_r2m (movdqa, reg, var)
#define movdqa_r2r(regs,regd) mmx_r2r (movdqa, regs, regd)
#define pshufd_r2r(regs,regd,imm) mmx_r2ri(pshufd, regs, regd, imm)
#define pshufw_m2r(var,reg,imm) mmx_m2ri(pshufw, var, reg, imm)
#define pshufw_r2r(regs,regd,imm) mmx_r2ri(pshufw, regs, regd, imm)
#define sfence() __asm__ __volatile__ ("sfence\n\t")
#endif /* LIBMPEG2_MMX_H */

View File

@ -1,145 +0,0 @@
/*
* motion_comp.c
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#include "config.h"
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
mpeg2_mc_t mpeg2_mc;
void mpeg2_mc_init (uint32_t accel)
{
#if HAVE_MMX2
if (accel & MPEG2_ACCEL_X86_MMXEXT)
mpeg2_mc = mpeg2_mc_mmxext;
else
#endif
#if HAVE_AMD3DNOW
if (accel & MPEG2_ACCEL_X86_3DNOW)
mpeg2_mc = mpeg2_mc_3dnow;
else
#endif
#if HAVE_MMX
if (accel & MPEG2_ACCEL_X86_MMX)
mpeg2_mc = mpeg2_mc_mmx;
else
#endif
#if HAVE_ALTIVEC
if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
mpeg2_mc = mpeg2_mc_altivec;
else
#endif
#if ARCH_ALPHA
if (accel & MPEG2_ACCEL_ALPHA)
mpeg2_mc = mpeg2_mc_alpha;
else
#endif
#if HAVE_VIS
if (accel & MPEG2_ACCEL_SPARC_VIS)
mpeg2_mc = mpeg2_mc_vis;
else
#endif
#if ARCH_ARM
if (accel & MPEG2_ACCEL_ARM)
mpeg2_mc = mpeg2_mc_arm;
else
#endif
mpeg2_mc = mpeg2_mc_c;
}
#define avg2(a,b) ((a+b+1)>>1)
#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
#define predict_o(i) (ref[i])
#define predict_x(i) (avg2 (ref[i], ref[i+1]))
#define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
(ref+stride)[i], (ref+stride)[i+1]))
#define put(predictor,i) dest[i] = predictor (i)
#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
/* mc function template */
#define MC_FUNC(op,xy) \
static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
const int stride, int height) \
{ \
do { \
op (predict_##xy, 0); \
op (predict_##xy, 1); \
op (predict_##xy, 2); \
op (predict_##xy, 3); \
op (predict_##xy, 4); \
op (predict_##xy, 5); \
op (predict_##xy, 6); \
op (predict_##xy, 7); \
op (predict_##xy, 8); \
op (predict_##xy, 9); \
op (predict_##xy, 10); \
op (predict_##xy, 11); \
op (predict_##xy, 12); \
op (predict_##xy, 13); \
op (predict_##xy, 14); \
op (predict_##xy, 15); \
ref += stride; \
dest += stride; \
} while (--height); \
} \
static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
const int stride, int height) \
{ \
do { \
op (predict_##xy, 0); \
op (predict_##xy, 1); \
op (predict_##xy, 2); \
op (predict_##xy, 3); \
op (predict_##xy, 4); \
op (predict_##xy, 5); \
op (predict_##xy, 6); \
op (predict_##xy, 7); \
ref += stride; \
dest += stride; \
} while (--height); \
}
/* definitions of the actual mc functions */
MC_FUNC (put,o)
MC_FUNC (avg,o)
MC_FUNC (put,x)
MC_FUNC (avg,x)
MC_FUNC (put,y)
MC_FUNC (avg,y)
MC_FUNC (put,xy)
MC_FUNC (avg,xy)
MPEG2_MC_EXTERN (c)

View File

@ -1,253 +0,0 @@
/*
* motion_comp_alpha.c
* Copyright (C) 2002-2003 Falk Hueffner <falk@debian.org>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#if ARCH_ALPHA
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#include "alpha_asm.h"
static inline uint64_t avg2 (uint64_t a, uint64_t b)
{
return (a | b) - (((a ^ b) & BYTE_VEC (0xfe)) >> 1);
}
// Load two unaligned quadwords from addr. This macro only works if
// addr is actually unaligned.
#define ULOAD16(ret_l,ret_r,addr) \
do { \
uint64_t _l = ldq_u (addr + 0); \
uint64_t _m = ldq_u (addr + 8); \
uint64_t _r = ldq_u (addr + 16); \
ret_l = extql (_l, addr) | extqh (_m, addr); \
ret_r = extql (_m, addr) | extqh (_r, addr); \
} while (0)
// Load two aligned quadwords from addr.
#define ALOAD16(ret_l,ret_r,addr) \
do { \
ret_l = ldq (addr); \
ret_r = ldq (addr + 8); \
} while (0)
#define OP8(LOAD,LOAD16,STORE) \
do { \
STORE (LOAD (pixels), block); \
pixels += line_size; \
block += line_size; \
} while (--h)
#define OP16(LOAD,LOAD16,STORE) \
do { \
uint64_t l, r; \
LOAD16 (l, r, pixels); \
STORE (l, block); \
STORE (r, block + 8); \
pixels += line_size; \
block += line_size; \
} while (--h)
#define OP8_X2(LOAD,LOAD16,STORE) \
do { \
uint64_t p0, p1; \
\
p0 = LOAD (pixels); \
p1 = p0 >> 8 | ((uint64_t) pixels[8] << 56); \
STORE (avg2 (p0, p1), block); \
pixels += line_size; \
block += line_size; \
} while (--h)
#define OP16_X2(LOAD,LOAD16,STORE) \
do { \
uint64_t p0, p1; \
\
LOAD16 (p0, p1, pixels); \
STORE (avg2(p0, p0 >> 8 | p1 << 56), block); \
STORE (avg2(p1, p1 >> 8 | (uint64_t) pixels[16] << 56), \
block + 8); \
pixels += line_size; \
block += line_size; \
} while (--h)
#define OP8_Y2(LOAD,LOAD16,STORE) \
do { \
uint64_t p0, p1; \
p0 = LOAD (pixels); \
pixels += line_size; \
p1 = LOAD (pixels); \
do { \
uint64_t av = avg2 (p0, p1); \
if (--h == 0) line_size = 0; \
pixels += line_size; \
p0 = p1; \
p1 = LOAD (pixels); \
STORE (av, block); \
block += line_size; \
} while (h); \
} while (0)
#define OP16_Y2(LOAD,LOAD16,STORE) \
do { \
uint64_t p0l, p0r, p1l, p1r; \
LOAD16 (p0l, p0r, pixels); \
pixels += line_size; \
LOAD16 (p1l, p1r, pixels); \
do { \
uint64_t avl, avr; \
if (--h == 0) line_size = 0; \
avl = avg2 (p0l, p1l); \
avr = avg2 (p0r, p1r); \
p0l = p1l; \
p0r = p1r; \
pixels += line_size; \
LOAD16 (p1l, p1r, pixels); \
STORE (avl, block); \
STORE (avr, block + 8); \
block += line_size; \
} while (h); \
} while (0)
#define OP8_XY2(LOAD,LOAD16,STORE) \
do { \
uint64_t pl, ph; \
uint64_t p1 = LOAD (pixels); \
uint64_t p2 = p1 >> 8 | ((uint64_t) pixels[8] << 56); \
\
ph = (((p1 & ~BYTE_VEC (0x03)) >> 2) + \
((p2 & ~BYTE_VEC (0x03)) >> 2)); \
pl = ((p1 & BYTE_VEC (0x03)) + \
(p2 & BYTE_VEC (0x03))); \
\
do { \
uint64_t npl, nph; \
\
pixels += line_size; \
p1 = LOAD (pixels); \
p2 = (p1 >> 8) | ((uint64_t) pixels[8] << 56); \
nph = (((p1 & ~BYTE_VEC (0x03)) >> 2) + \
((p2 & ~BYTE_VEC (0x03)) >> 2)); \
npl = ((p1 & BYTE_VEC (0x03)) + \
(p2 & BYTE_VEC (0x03))); \
\
STORE (ph + nph + \
(((pl + npl + BYTE_VEC (0x02)) >> 2) & \
BYTE_VEC (0x03)), block); \
\
block += line_size; \
pl = npl; \
ph = nph; \
} while (--h); \
} while (0)
#define OP16_XY2(LOAD,LOAD16,STORE) \
do { \
uint64_t p0, p1, p2, p3, pl_l, ph_l, pl_r, ph_r; \
LOAD16 (p0, p2, pixels); \
p1 = p0 >> 8 | (p2 << 56); \
p3 = p2 >> 8 | ((uint64_t)pixels[16] << 56); \
\
ph_l = (((p0 & ~BYTE_VEC (0x03)) >> 2) + \
((p1 & ~BYTE_VEC (0x03)) >> 2)); \
pl_l = ((p0 & BYTE_VEC (0x03)) + \
(p1 & BYTE_VEC(0x03))); \
ph_r = (((p2 & ~BYTE_VEC (0x03)) >> 2) + \
((p3 & ~BYTE_VEC (0x03)) >> 2)); \
pl_r = ((p2 & BYTE_VEC (0x03)) + \
(p3 & BYTE_VEC (0x03))); \
\
do { \
uint64_t npl_l, nph_l, npl_r, nph_r; \
\
pixels += line_size; \
LOAD16 (p0, p2, pixels); \
p1 = p0 >> 8 | (p2 << 56); \
p3 = p2 >> 8 | ((uint64_t)pixels[16] << 56); \
nph_l = (((p0 & ~BYTE_VEC (0x03)) >> 2) + \
((p1 & ~BYTE_VEC (0x03)) >> 2)); \
npl_l = ((p0 & BYTE_VEC (0x03)) + \
(p1 & BYTE_VEC (0x03))); \
nph_r = (((p2 & ~BYTE_VEC (0x03)) >> 2) + \
((p3 & ~BYTE_VEC (0x03)) >> 2)); \
npl_r = ((p2 & BYTE_VEC (0x03)) + \
(p3 & BYTE_VEC (0x03))); \
\
STORE (ph_l + nph_l + \
(((pl_l + npl_l + BYTE_VEC (0x02)) >> 2) & \
BYTE_VEC(0x03)), block); \
STORE (ph_r + nph_r + \
(((pl_r + npl_r + BYTE_VEC (0x02)) >> 2) & \
BYTE_VEC(0x03)), block + 8); \
\
block += line_size; \
pl_l = npl_l; \
ph_l = nph_l; \
pl_r = npl_r; \
ph_r = nph_r; \
} while (--h); \
} while (0)
#define MAKE_OP(OPNAME,SIZE,SUFF,OPKIND,STORE) \
static void MC_ ## OPNAME ## _ ## SUFF ## _ ## SIZE ## _alpha \
(uint8_t *restrict block, const uint8_t *restrict pixels, \
int line_size, int h) \
{ \
if ((uint64_t) pixels & 0x7) { \
OPKIND (uldq, ULOAD16, STORE); \
} else { \
OPKIND (ldq, ALOAD16, STORE); \
} \
}
#define PIXOP(OPNAME,STORE) \
MAKE_OP (OPNAME, 8, o, OP8, STORE); \
MAKE_OP (OPNAME, 8, x, OP8_X2, STORE); \
MAKE_OP (OPNAME, 8, y, OP8_Y2, STORE); \
MAKE_OP (OPNAME, 8, xy, OP8_XY2, STORE); \
MAKE_OP (OPNAME, 16, o, OP16, STORE); \
MAKE_OP (OPNAME, 16, x, OP16_X2, STORE); \
MAKE_OP (OPNAME, 16, y, OP16_Y2, STORE); \
MAKE_OP (OPNAME, 16, xy, OP16_XY2, STORE);
#define STORE(l,b) stq (l, b)
PIXOP (put, STORE);
#undef STORE
#define STORE(l,b) stq (avg2 (l, ldq (b)), b);
PIXOP (avg, STORE);
mpeg2_mc_t mpeg2_mc_alpha = {
{ MC_put_o_16_alpha, MC_put_x_16_alpha,
MC_put_y_16_alpha, MC_put_xy_16_alpha,
MC_put_o_8_alpha, MC_put_x_8_alpha,
MC_put_y_8_alpha, MC_put_xy_8_alpha },
{ MC_avg_o_16_alpha, MC_avg_x_16_alpha,
MC_avg_y_16_alpha, MC_avg_xy_16_alpha,
MC_avg_o_8_alpha, MC_avg_x_8_alpha,
MC_avg_y_8_alpha, MC_avg_xy_8_alpha }
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,185 +0,0 @@
/*
* motion_comp_arm.c
* Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with mpeg2dec; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#if ARCH_ARM
#include <inttypes.h>
#include "mpeg2.h"
#include "attributes.h"
#include "mpeg2_internal.h"
#define avg2(a,b) ((a+b+1)>>1)
#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
#define predict_o(i) (ref[i])
#define predict_x(i) (avg2 (ref[i], ref[i+1]))
#define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
(ref+stride)[i], (ref+stride)[i+1]))
#define put(predictor,i) dest[i] = predictor (i)
#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
/* mc function template */
#define MC_FUNC(op,xy) \
static void inline MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
const int stride, int height) \
{ \
do { \
op (predict_##xy, 0); \
op (predict_##xy, 1); \
op (predict_##xy, 2); \
op (predict_##xy, 3); \
op (predict_##xy, 4); \
op (predict_##xy, 5); \
op (predict_##xy, 6); \
op (predict_##xy, 7); \
op (predict_##xy, 8); \
op (predict_##xy, 9); \
op (predict_##xy, 10); \
op (predict_##xy, 11); \
op (predict_##xy, 12); \
op (predict_##xy, 13); \
op (predict_##xy, 14); \
op (predict_##xy, 15); \
ref += stride; \
dest += stride; \
} while (--height); \
} \
static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
const int stride, int height) \
{ \
do { \
op (predict_##xy, 0); \
op (predict_##xy, 1); \
op (predict_##xy, 2); \
op (predict_##xy, 3); \
op (predict_##xy, 4); \
op (predict_##xy, 5); \
op (predict_##xy, 6); \
op (predict_##xy, 7); \
ref += stride; \
dest += stride; \
} while (--height); \
} \
/* definitions of the actual mc functions */
MC_FUNC (avg,o)
MC_FUNC (avg,x)
MC_FUNC (put,y)
MC_FUNC (avg,y)
MC_FUNC (put,xy)
MC_FUNC (avg,xy)
extern void MC_put_o_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height);
extern void MC_put_x_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height);
static void MC_put_y_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_put_y_16_c(dest, ref, stride, height);
}
static void MC_put_xy_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_put_xy_16_c(dest, ref, stride, height);
}
extern void MC_put_o_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height);
extern void MC_put_x_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height);
static void MC_put_y_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_put_y_8_c(dest, ref, stride, height);
}
static void MC_put_xy_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_put_xy_8_c(dest, ref, stride, height);
}
static void MC_avg_o_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_o_16_c(dest, ref, stride, height);
}
static void MC_avg_x_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_x_16_c(dest, ref, stride, height);
}
static void MC_avg_y_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_y_16_c(dest, ref, stride, height);
}
static void MC_avg_xy_16_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_xy_16_c(dest, ref, stride, height);
}
static void MC_avg_o_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_o_8_c(dest, ref, stride, height);
}
static void MC_avg_x_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_x_8_c(dest, ref, stride, height);
}
static void MC_avg_y_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_y_8_c(dest, ref, stride, height);
}
static void MC_avg_xy_8_arm (uint8_t * dest, const uint8_t * ref,
int stride, int height)
{
MC_avg_xy_8_c(dest, ref, stride, height);
}
MPEG2_MC_EXTERN (arm)
#endif

View File

@ -1,323 +0,0 @@
@ motion_comp_arm_s.S
@ Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
@
@ This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
@ See http://libmpeg2.sourceforge.net/ for updates.
@
@ mpeg2dec is free software; you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation; either version 2 of the License, or
@ (at your option) any later version.
@
@ mpeg2dec is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with mpeg2dec; if not, write to the Free Software
@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
.text
@ ----------------------------------------------------------------
.align
.global MC_put_o_16_arm
MC_put_o_16_arm:
@@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
pld [r1]
stmfd sp!, {r4-r11, lr} @ R14 is also called LR
and r4, r1, #3
adr r5, MC_put_o_16_arm_align_jt
add r5, r5, r4, lsl #2
ldr pc, [r5]
MC_put_o_16_arm_align0:
ldmia r1, {r4-r7}
add r1, r1, r2
pld [r1]
stmia r0, {r4-r7}
subs r3, r3, #1
add r0, r0, r2
bne MC_put_o_16_arm_align0
ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
.macro PROC shift
ldmia r1, {r4-r8}
add r1, r1, r2
mov r9, r4, lsr #(\shift)
pld [r1]
mov r10, r5, lsr #(\shift)
orr r9, r9, r5, lsl #(32-\shift)
mov r11, r6, lsr #(\shift)
orr r10, r10, r6, lsl #(32-\shift)
mov r12, r7, lsr #(\shift)
orr r11, r11, r7, lsl #(32-\shift)
orr r12, r12, r8, lsl #(32-\shift)
stmia r0, {r9-r12}
subs r3, r3, #1
add r0, r0, r2
.endm
MC_put_o_16_arm_align1:
and r1, r1, #0xFFFFFFFC
1: PROC(8)
bne 1b
ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
MC_put_o_16_arm_align2:
and r1, r1, #0xFFFFFFFC
1: PROC(16)
bne 1b
ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
MC_put_o_16_arm_align3:
and r1, r1, #0xFFFFFFFC
1: PROC(24)
bne 1b
ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
MC_put_o_16_arm_align_jt:
.word MC_put_o_16_arm_align0
.word MC_put_o_16_arm_align1
.word MC_put_o_16_arm_align2
.word MC_put_o_16_arm_align3
@ ----------------------------------------------------------------
.align
.global MC_put_o_8_arm
MC_put_o_8_arm:
@@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
pld [r1]
stmfd sp!, {r4-r10, lr} @ R14 is also called LR
and r4, r1, #3
adr r5, MC_put_o_8_arm_align_jt
add r5, r5, r4, lsl #2
ldr pc, [r5]
MC_put_o_8_arm_align0:
ldmia r1, {r4-r5}
add r1, r1, r2
pld [r1]
stmia r0, {r4-r5}
add r0, r0, r2
subs r3, r3, #1
bne MC_put_o_8_arm_align0
ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
.macro PROC8 shift
ldmia r1, {r4-r6}
add r1, r1, r2
mov r9, r4, lsr #(\shift)
pld [r1]
mov r10, r5, lsr #(\shift)
orr r9, r9, r5, lsl #(32-\shift)
orr r10, r10, r6, lsl #(32-\shift)
stmia r0, {r9-r10}
subs r3, r3, #1
add r0, r0, r2
.endm
MC_put_o_8_arm_align1:
and r1, r1, #0xFFFFFFFC
1: PROC8(8)
bne 1b
ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
MC_put_o_8_arm_align2:
and r1, r1, #0xFFFFFFFC
1: PROC8(16)
bne 1b
ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
MC_put_o_8_arm_align3:
and r1, r1, #0xFFFFFFFC
1: PROC8(24)
bne 1b
ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
MC_put_o_8_arm_align_jt:
.word MC_put_o_8_arm_align0
.word MC_put_o_8_arm_align1
.word MC_put_o_8_arm_align2
.word MC_put_o_8_arm_align3
@ ----------------------------------------------------------------
.macro AVG_PW rW1, rW2
mov \rW2, \rW2, lsl #24
orr \rW2, \rW2, \rW1, lsr #8
eor r9, \rW1, \rW2
and \rW2, \rW1, \rW2
and r10, r9, r12
add \rW2, \rW2, r10, lsr #1
and r10, r9, r11
add \rW2, \rW2, r10
.endm
.align
.global MC_put_x_16_arm
MC_put_x_16_arm:
@@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
pld [r1]
stmfd sp!, {r4-r11,lr} @ R14 is also called LR
and r4, r1, #3
adr r5, MC_put_x_16_arm_align_jt
ldr r11, [r5]
mvn r12, r11
add r5, r5, r4, lsl #2
ldr pc, [r5, #4]
.macro ADJ_ALIGN_QW shift, R0, R1, R2, R3, R4
mov \R0, \R0, lsr #(\shift)
orr \R0, \R0, \R1, lsl #(32 - \shift)
mov \R1, \R1, lsr #(\shift)
orr \R1, \R1, \R2, lsl #(32 - \shift)
mov \R2, \R2, lsr #(\shift)
orr \R2, \R2, \R3, lsl #(32 - \shift)
mov \R3, \R3, lsr #(\shift)
orr \R3, \R3, \R4, lsl #(32 - \shift)
mov \R4, \R4, lsr #(\shift)
@ and \R4, \R4, #0xFF
.endm
MC_put_x_16_arm_align0:
ldmia r1, {r4-r8}
add r1, r1, r2
pld [r1]
AVG_PW r7, r8
AVG_PW r6, r7
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r8}
subs r3, r3, #1
add r0, r0, r2
bne MC_put_x_16_arm_align0
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_16_arm_align1:
and r1, r1, #0xFFFFFFFC
1: ldmia r1, {r4-r8}
add r1, r1, r2
pld [r1]
ADJ_ALIGN_QW 8, r4, r5, r6, r7, r8
AVG_PW r7, r8
AVG_PW r6, r7
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r8}
subs r3, r3, #1
add r0, r0, r2
bne 1b
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_16_arm_align2:
and r1, r1, #0xFFFFFFFC
1: ldmia r1, {r4-r8}
add r1, r1, r2
pld [r1]
ADJ_ALIGN_QW 16, r4, r5, r6, r7, r8
AVG_PW r7, r8
AVG_PW r6, r7
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r8}
subs r3, r3, #1
add r0, r0, r2
bne 1b
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_16_arm_align3:
and r1, r1, #0xFFFFFFFC
1: ldmia r1, {r4-r8}
add r1, r1, r2
pld [r1]
ADJ_ALIGN_QW 24, r4, r5, r6, r7, r8
AVG_PW r7, r8
AVG_PW r6, r7
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r8}
subs r3, r3, #1
add r0, r0, r2
bne 1b
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_16_arm_align_jt:
.word 0x01010101
.word MC_put_x_16_arm_align0
.word MC_put_x_16_arm_align1
.word MC_put_x_16_arm_align2
.word MC_put_x_16_arm_align3
@ ----------------------------------------------------------------
.align
.global MC_put_x_8_arm
MC_put_x_8_arm:
@@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
pld [r1]
stmfd sp!, {r4-r11,lr} @ R14 is also called LR
and r4, r1, #3
adr r5, MC_put_x_8_arm_align_jt
ldr r11, [r5]
mvn r12, r11
add r5, r5, r4, lsl #2
ldr pc, [r5, #4]
.macro ADJ_ALIGN_DW shift, R0, R1, R2
mov \R0, \R0, lsr #(\shift)
orr \R0, \R0, \R1, lsl #(32 - \shift)
mov \R1, \R1, lsr #(\shift)
orr \R1, \R1, \R2, lsl #(32 - \shift)
mov \R2, \R2, lsr #(\shift)
@ and \R4, \R4, #0xFF
.endm
MC_put_x_8_arm_align0:
ldmia r1, {r4-r6}
add r1, r1, r2
pld [r1]
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r6}
subs r3, r3, #1
add r0, r0, r2
bne MC_put_x_8_arm_align0
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_8_arm_align1:
and r1, r1, #0xFFFFFFFC
1: ldmia r1, {r4-r6}
add r1, r1, r2
pld [r1]
ADJ_ALIGN_DW 8, r4, r5, r6
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r6}
subs r3, r3, #1
add r0, r0, r2
bne 1b
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_8_arm_align2:
and r1, r1, #0xFFFFFFFC
1: ldmia r1, {r4-r6}
add r1, r1, r2
pld [r1]
ADJ_ALIGN_DW 16, r4, r5, r6
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r6}
subs r3, r3, #1
add r0, r0, r2
bne 1b
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_8_arm_align3:
and r1, r1, #0xFFFFFFFC
1: ldmia r1, {r4-r6}
add r1, r1, r2
pld [r1]
ADJ_ALIGN_DW 24, r4, r5, r6
AVG_PW r5, r6
AVG_PW r4, r5
stmia r0, {r5-r6}
subs r3, r3, #1
add r0, r0, r2
bne 1b
ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
MC_put_x_8_arm_align_jt:
.word 0x01010101
.word MC_put_x_8_arm_align0
.word MC_put_x_8_arm_align1
.word MC_put_x_8_arm_align2
.word MC_put_x_8_arm_align3

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,208 +0,0 @@
/*
* mpeg2.h
* Copyright (C) 2000-2004 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#ifndef LIBMPEG2_MPEG2_H
#define LIBMPEG2_MPEG2_H
#define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
#define MPEG2_RELEASE MPEG2_VERSION (0, 5, 1) /* 0.5.1 */
#define SEQ_FLAG_MPEG2 1
#define SEQ_FLAG_CONSTRAINED_PARAMETERS 2
#define SEQ_FLAG_PROGRESSIVE_SEQUENCE 4
#define SEQ_FLAG_LOW_DELAY 8
#define SEQ_FLAG_COLOUR_DESCRIPTION 16
#define SEQ_MASK_VIDEO_FORMAT 0xe0
#define SEQ_VIDEO_FORMAT_COMPONENT 0
#define SEQ_VIDEO_FORMAT_PAL 0x20
#define SEQ_VIDEO_FORMAT_NTSC 0x40
#define SEQ_VIDEO_FORMAT_SECAM 0x60
#define SEQ_VIDEO_FORMAT_MAC 0x80
#define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0
typedef struct mpeg2_sequence_s {
unsigned int width, height;
unsigned int chroma_width, chroma_height;
unsigned int byte_rate;
unsigned int vbv_buffer_size;
uint32_t flags;
unsigned int picture_width, picture_height;
unsigned int display_width, display_height;
unsigned int pixel_width, pixel_height;
unsigned int frame_period;
uint8_t profile_level_id;
uint8_t colour_primaries;
uint8_t transfer_characteristics;
uint8_t matrix_coefficients;
} mpeg2_sequence_t;
#define GOP_FLAG_DROP_FRAME 1
#define GOP_FLAG_BROKEN_LINK 2
#define GOP_FLAG_CLOSED_GOP 4
typedef struct mpeg2_gop_s {
uint8_t hours;
uint8_t minutes;
uint8_t seconds;
uint8_t pictures;
uint32_t flags;
} mpeg2_gop_t;
#define PIC_MASK_CODING_TYPE 7
#define PIC_FLAG_CODING_TYPE_I 1
#define PIC_FLAG_CODING_TYPE_P 2
#define PIC_FLAG_CODING_TYPE_B 3
#define PIC_FLAG_CODING_TYPE_D 4
#define PIC_FLAG_TOP_FIELD_FIRST 8
#define PIC_FLAG_PROGRESSIVE_FRAME 16
#define PIC_FLAG_COMPOSITE_DISPLAY 32
#define PIC_FLAG_SKIP 64
#define PIC_FLAG_TAGS 128
#define PIC_FLAG_REPEAT_FIRST_FIELD 256
#define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
typedef struct mpeg2_picture_s {
unsigned int temporal_reference;
unsigned int nb_fields;
uint32_t tag, tag2;
uint32_t flags;
struct {
int x, y;
} display_offset[3];
} mpeg2_picture_t;
typedef struct mpeg2_fbuf_s {
uint8_t * buf[3];
void * id;
} mpeg2_fbuf_t;
typedef struct mpeg2_info_s {
const mpeg2_sequence_t * sequence;
const mpeg2_gop_t * gop;
const mpeg2_picture_t * current_picture;
const mpeg2_picture_t * current_picture_2nd;
const mpeg2_fbuf_t * current_fbuf;
const mpeg2_picture_t * display_picture;
const mpeg2_picture_t * display_picture_2nd;
const mpeg2_fbuf_t * display_fbuf;
const mpeg2_fbuf_t * discard_fbuf;
const uint8_t * user_data;
unsigned int user_data_len;
} mpeg2_info_t;
typedef struct mpeg2dec_s mpeg2dec_t;
typedef struct mpeg2_decoder_s mpeg2_decoder_t;
typedef enum {
STATE_BUFFER = 0,
STATE_SEQUENCE = 1,
STATE_SEQUENCE_REPEATED = 2,
STATE_GOP = 3,
STATE_PICTURE = 4,
STATE_SLICE_1ST = 5,
STATE_PICTURE_2ND = 6,
STATE_SLICE = 7,
STATE_END = 8,
STATE_INVALID = 9,
STATE_INVALID_END = 10,
STATE_SEQUENCE_MODIFIED = 11
} mpeg2_state_t;
typedef struct mpeg2_convert_init_s {
unsigned int id_size;
unsigned int buf_size[3];
void (* start) (void * id, const mpeg2_fbuf_t * fbuf,
const mpeg2_picture_t * picture, const mpeg2_gop_t * gop);
void (* copy) (void * id, uint8_t * const * src, unsigned int v_offset);
} mpeg2_convert_init_t;
typedef enum {
MPEG2_CONVERT_SET = 0,
MPEG2_CONVERT_STRIDE = 1,
MPEG2_CONVERT_START = 2
} mpeg2_convert_stage_t;
typedef int mpeg2_convert_t (int stage, void * id,
const mpeg2_sequence_t * sequence, int stride,
uint32_t accel, void * arg,
mpeg2_convert_init_t * result);
int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id);
void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf);
#define MPEG2_ACCEL_X86_MMX 1
#define MPEG2_ACCEL_X86_3DNOW 2
#define MPEG2_ACCEL_X86_MMXEXT 4
#define MPEG2_ACCEL_X86_SSE2 8
#define MPEG2_ACCEL_X86_SSE3 16
#define MPEG2_ACCEL_PPC_ALTIVEC 1
#define MPEG2_ACCEL_ALPHA 1
#define MPEG2_ACCEL_ALPHA_MVI 2
#define MPEG2_ACCEL_SPARC_VIS 1
#define MPEG2_ACCEL_SPARC_VIS2 2
#define MPEG2_ACCEL_ARM 1
#define MPEG2_ACCEL_DETECT 0x80000000
uint32_t mpeg2_accel (uint32_t accel);
mpeg2dec_t * mpeg2_init (void);
const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec);
void mpeg2_close (mpeg2dec_t * mpeg2dec);
void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end);
int mpeg2_getpos (mpeg2dec_t * mpeg2dec);
mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec);
void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset);
void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip);
void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end);
void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2);
void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]);
void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer);
int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence,
unsigned int * pixel_width,
unsigned int * pixel_height);
typedef enum {
MPEG2_ALLOC_MPEG2DEC = 0,
MPEG2_ALLOC_CHUNK = 1,
MPEG2_ALLOC_YUV = 2,
MPEG2_ALLOC_CONVERT_ID = 3,
MPEG2_ALLOC_CONVERTED = 4
} mpeg2_alloc_t;
void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
void mpeg2_free (void * buf);
void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
int free (void *));
#endif /* LIBMPEG2_MPEG2_H */

View File

@ -1,329 +0,0 @@
/*
* mpeg2_internal.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
* detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
* $Id$
*/
#ifndef LIBMPEG2_MPEG2_INTERNAL_H
#define LIBMPEG2_MPEG2_INTERNAL_H
#define STATE_INTERNAL_NORETURN ((mpeg2_state_t)-1)
/* macroblock modes */
#define MACROBLOCK_INTRA 1
#define MACROBLOCK_PATTERN 2
#define MACROBLOCK_MOTION_BACKWARD 4
#define MACROBLOCK_MOTION_FORWARD 8
#define MACROBLOCK_QUANT 16
#define DCT_TYPE_INTERLACED 32
/* motion_type */
#define MOTION_TYPE_SHIFT 6
#define MC_FIELD 1
#define MC_FRAME 2
#define MC_16X8 2
#define MC_DMV 3
/* picture structure */
#define TOP_FIELD 1
#define BOTTOM_FIELD 2
#define FRAME_PICTURE 3
/* picture coding type */
#define I_TYPE 1
#define P_TYPE 2
#define B_TYPE 3
#define D_TYPE 4
typedef void mpeg2_mc_fct (uint8_t *, const uint8_t *, int, int);
typedef struct {
uint8_t * ref[2][3];
uint8_t ** ref2[2];
int pmv[2][2];
int f_code[2];
} motion_t;
typedef void motion_parser_t (mpeg2_decoder_t * decoder,
motion_t * motion,
mpeg2_mc_fct * const * table);
struct mpeg2_decoder_s {
/* first, state that carries information from one macroblock to the */
/* next inside a slice, and is never used outside of mpeg2_slice() */
/* bit parsing stuff */
uint32_t bitstream_buf; /* current 32 bit working set */
int bitstream_bits; /* used bits in working set */
const uint8_t * bitstream_ptr; /* buffer with stream data */
uint8_t * dest[3];
int offset;
int stride;
int uv_stride;
int slice_stride;
int slice_uv_stride;
int stride_frame;
unsigned int limit_x;
unsigned int limit_y_16;
unsigned int limit_y_8;
unsigned int limit_y;
/* Motion vectors */
/* The f_ and b_ correspond to the forward and backward motion */
/* predictors */
motion_t b_motion;
motion_t f_motion;
motion_parser_t * motion_parser[5];
/* predictor for DC coefficients in intra blocks */
int16_t dc_dct_pred[3];
/* DCT coefficients */
int16_t DCTblock[64] ATTR_ALIGN(64);
uint8_t * picture_dest[3];
void (* convert) (void * convert_id, uint8_t * const * src,
unsigned int v_offset);
void * convert_id;
int dmv_offset;
unsigned int v_offset;
/* now non-slice-specific information */
/* sequence header stuff */
uint16_t * quantizer_matrix[4];
uint16_t (* chroma_quantizer[2])[64];
uint16_t quantizer_prescale[4][32][64];
/* The width and height of the picture snapped to macroblock units */
int width;
int height;
int vertical_position_extension;
int chroma_format;
/* picture header stuff */
/* what type of picture this is (I, P, B, D) */
int coding_type;
/* picture coding extension stuff */
/* quantization factor for intra dc coefficients */
int intra_dc_precision;
/* top/bottom/both fields */
int picture_structure;
/* bool to indicate all predictions are frame based */
int frame_pred_frame_dct;
/* bool to indicate whether intra blocks have motion vectors */
/* (for concealment) */
int concealment_motion_vectors;
/* bool to use different vlc tables */
int intra_vlc_format;
/* used for DMV MC */
int top_field_first;
/* stuff derived from bitstream */
/* pointer to the zigzag scan we're supposed to be using */
const uint8_t * scan;
int second_field;
int mpeg1;
/* XXX: stuff due to xine shit */
int8_t q_scale_type;
int quantizer_scales[32];
int quantizer_scale;
char* quant_store;
int quant_stride;
};
typedef struct {
mpeg2_fbuf_t fbuf;
} fbuf_alloc_t;
struct mpeg2dec_s {
mpeg2_decoder_t decoder;
mpeg2_info_t info;
uint32_t shift;
int is_display_initialized;
mpeg2_state_t (* action) (struct mpeg2dec_s * mpeg2dec);
mpeg2_state_t state;
uint32_t ext_state;
/* allocated in init - gcc has problems allocating such big structures */
uint8_t * chunk_buffer;
/* pointer to start of the current chunk */
uint8_t * chunk_start;
/* pointer to current position in chunk_buffer */
uint8_t * chunk_ptr;
/* last start code ? */
uint8_t code;
/* picture tags */
uint32_t tag_current, tag2_current, tag_previous, tag2_previous;
int num_tags;
int bytes_since_tag;
int first;
int alloc_index_user;
int alloc_index;
uint8_t first_decode_slice;
uint8_t nb_decode_slices;
unsigned int user_data_len;
mpeg2_sequence_t new_sequence;
mpeg2_sequence_t sequence;
mpeg2_gop_t new_gop;
mpeg2_gop_t gop;
mpeg2_picture_t new_picture;
mpeg2_picture_t pictures[4];
mpeg2_picture_t * picture;
/*const*/ mpeg2_fbuf_t * fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
fbuf_alloc_t fbuf_alloc[3];
int custom_fbuf;
uint8_t * yuv_buf[3][3];
int yuv_index;
mpeg2_convert_t * convert;
void * convert_arg;
unsigned int convert_id_size;
int convert_stride;
void (* convert_start) (void * id, const mpeg2_fbuf_t * fbuf,
const mpeg2_picture_t * picture,
const mpeg2_gop_t * gop);
uint8_t * buf_start;
uint8_t * buf_end;
int16_t display_offset_x, display_offset_y;
int copy_matrix;
int8_t scaled[4]; /* XXX: MOVED */
//int8_t q_scale_type, scaled[4];
uint8_t quantizer_matrix[4][64];
uint8_t new_quantizer_matrix[4][64];
unsigned char *pending_buffer;
int pending_length;
};
typedef struct {
#if ARCH_PPC
uint8_t regv[12*16];
#endif
int dummy;
} cpu_state_t;
/* cpu_accel.c */
uint32_t mpeg2_detect_accel (uint32_t accel);
/* cpu_state.c */
void mpeg2_cpu_state_init (uint32_t accel);
/* decode.c */
mpeg2_state_t mpeg2_seek_header (mpeg2dec_t * mpeg2dec);
mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec);
/* header.c */
void mpeg2_header_state_init (mpeg2dec_t * mpeg2dec);
void mpeg2_reset_info (mpeg2_info_t * info);
int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec);
int mpeg2_header_gop (mpeg2dec_t * mpeg2dec);
mpeg2_state_t mpeg2_header_picture_start (mpeg2dec_t * mpeg2dec);
int mpeg2_header_picture (mpeg2dec_t * mpeg2dec);
int mpeg2_header_extension (mpeg2dec_t * mpeg2dec);
int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec);
void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec);
void mpeg2_header_gop_finalize (mpeg2dec_t * mpeg2dec);
void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels);
mpeg2_state_t mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec);
mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec);
void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type);
/* idct.c */
extern void mpeg2_idct_init (uint32_t accel);
extern uint8_t mpeg2_scan_norm[64];
extern uint8_t mpeg2_scan_alt[64];
/* idct_mmx.c */
void mpeg2_idct_copy_sse2 (int16_t * block, uint8_t * dest, int stride);
void mpeg2_idct_add_sse2 (int last, int16_t * block,
uint8_t * dest, int stride);
void mpeg2_idct_copy_mmxext (int16_t * block, uint8_t * dest, int stride);
void mpeg2_idct_add_mmxext (int last, int16_t * block,
uint8_t * dest, int stride);
void mpeg2_idct_copy_mmx (int16_t * block, uint8_t * dest, int stride);
void mpeg2_idct_add_mmx (int last, int16_t * block,
uint8_t * dest, int stride);
void mpeg2_idct_mmx_init (void);
/* idct_altivec.c */
void mpeg2_idct_copy_altivec (int16_t * block, uint8_t * dest, int stride);
void mpeg2_idct_add_altivec (int last, int16_t * block,
uint8_t * dest, int stride);
void mpeg2_idct_altivec_init (void);
/* idct_alpha.c */
void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, int stride);
void mpeg2_idct_add_mvi (int last, int16_t * block,
uint8_t * dest, int stride);
void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, int stride);
void mpeg2_idct_add_alpha (int last, int16_t * block,
uint8_t * dest, int stride);
void mpeg2_idct_alpha_init (void);
/* motion_comp.c */
void mpeg2_mc_init (uint32_t accel);
typedef struct {
mpeg2_mc_fct * put [8];
mpeg2_mc_fct * avg [8];
} mpeg2_mc_t;
#define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
{MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \
{MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
MC_avg_o_8_##x, MC_avg_x_8_##x, MC_avg_y_8_##x, MC_avg_xy_8_##x} \
};
extern mpeg2_mc_t mpeg2_mc_c;
extern mpeg2_mc_t mpeg2_mc_mmx;
extern mpeg2_mc_t mpeg2_mc_mmxext;
extern mpeg2_mc_t mpeg2_mc_3dnow;
extern mpeg2_mc_t mpeg2_mc_altivec;
extern mpeg2_mc_t mpeg2_mc_alpha;
extern mpeg2_mc_t mpeg2_mc_vis;
extern mpeg2_mc_t mpeg2_mc_arm;
#endif /* LIBMPEG2_MPEG2_INTERNAL_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,333 +0,0 @@
/*
* vis.h
* Copyright (C) 2003 David S. Miller <davem@redhat.com>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* You may be asking why I hard-code the instruction opcodes and don't
* use the normal VIS assembler mnenomics for the VIS instructions.
*
* The reason is that Sun, in their infinite wisdom, decided that a binary
* using a VIS instruction will cause it to be marked (in the ELF headers)
* as doing so, and this prevents the OS from loading such binaries if the
* current cpu doesn't have VIS. There is no way to easily override this
* behavior of the assembler that I am aware of.
*
* This totally defeats what libmpeg2 is trying to do which is allow a
* single binary to be created, and then detect the availability of VIS
* at runtime.
*
* I'm not saying that tainting the binary by default is bad, rather I'm
* saying that not providing a way to override this easily unnecessarily
* ties people's hands.
*
* Thus, we do the opcode encoding by hand and output 32-bit words in
* the assembler to keep the binary from becoming tainted.
*/
#ifndef LIBMPEG2_VIS_H
#define LIBMPEG2_VIS_H
#define vis_opc_base ((0x1 << 31) | (0x36 << 19))
#define vis_opf(X) ((X) << 5)
#define vis_sreg(X) (X)
#define vis_dreg(X) (((X)&0x1f)|((X)>>5))
#define vis_rs1_s(X) (vis_sreg(X) << 14)
#define vis_rs1_d(X) (vis_dreg(X) << 14)
#define vis_rs2_s(X) (vis_sreg(X) << 0)
#define vis_rs2_d(X) (vis_dreg(X) << 0)
#define vis_rd_s(X) (vis_sreg(X) << 25)
#define vis_rd_d(X) (vis_dreg(X) << 25)
#define vis_ss2s(opf,rs1,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs1_s(rs1) | \
vis_rs2_s(rs2) | \
vis_rd_s(rd)))
#define vis_dd2d(opf,rs1,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs1_d(rs1) | \
vis_rs2_d(rs2) | \
vis_rd_d(rd)))
#define vis_ss2d(opf,rs1,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs1_s(rs1) | \
vis_rs2_s(rs2) | \
vis_rd_d(rd)))
#define vis_sd2d(opf,rs1,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs1_s(rs1) | \
vis_rs2_d(rs2) | \
vis_rd_d(rd)))
#define vis_d2s(opf,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs2_d(rs2) | \
vis_rd_s(rd)))
#define vis_s2d(opf,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs2_s(rs2) | \
vis_rd_d(rd)))
#define vis_d12d(opf,rs1,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs1_d(rs1) | \
vis_rd_d(rd)))
#define vis_d22d(opf,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs2_d(rs2) | \
vis_rd_d(rd)))
#define vis_s12s(opf,rs1,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs1_s(rs1) | \
vis_rd_s(rd)))
#define vis_s22s(opf,rs2,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rs2_s(rs2) | \
vis_rd_s(rd)))
#define vis_s(opf,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rd_s(rd)))
#define vis_d(opf,rd) \
__asm__ __volatile__ (".word %0" \
: : "i" (vis_opc_base | vis_opf(opf) | \
vis_rd_d(rd)))
#define vis_r2m(op,rd,mem) \
__asm__ __volatile__ (#op "\t%%f" #rd ", [%0]" : : "r" (&(mem)) )
#define vis_r2m_2(op,rd,mem1,mem2) \
__asm__ __volatile__ (#op "\t%%f" #rd ", [%0 + %1]" : : "r" (mem1), "r" (mem2) )
#define vis_m2r(op,mem,rd) \
__asm__ __volatile__ (#op "\t[%0], %%f" #rd : : "r" (&(mem)) )
#define vis_m2r_2(op,mem1,mem2,rd) \
__asm__ __volatile__ (#op "\t[%0 + %1], %%f" #rd : : "r" (mem1), "r" (mem2) )
static inline void vis_set_gsr(unsigned int _val)
{
register unsigned int val asm("g1");
val = _val;
__asm__ __volatile__(".word 0xa7804000"
: : "r" (val));
}
#define VIS_GSR_ALIGNADDR_MASK 0x0000007
#define VIS_GSR_ALIGNADDR_SHIFT 0
#define VIS_GSR_SCALEFACT_MASK 0x0000078
#define VIS_GSR_SCALEFACT_SHIFT 3
#define vis_ld32(mem,rs1) vis_m2r(ld, mem, rs1)
#define vis_ld32_2(mem1,mem2,rs1) vis_m2r_2(ld, mem1, mem2, rs1)
#define vis_st32(rs1,mem) vis_r2m(st, rs1, mem)
#define vis_st32_2(rs1,mem1,mem2) vis_r2m_2(st, rs1, mem1, mem2)
#define vis_ld64(mem,rs1) vis_m2r(ldd, mem, rs1)
#define vis_ld64_2(mem1,mem2,rs1) vis_m2r_2(ldd, mem1, mem2, rs1)
#define vis_st64(rs1,mem) vis_r2m(std, rs1, mem)
#define vis_st64_2(rs1,mem1,mem2) vis_r2m_2(std, rs1, mem1, mem2)
#define vis_ldblk(mem, rd) \
do { register void *__mem asm("g1"); \
__mem = &(mem); \
__asm__ __volatile__(".word 0xc1985e00 | %1" \
: \
: "r" (__mem), \
"i" (vis_rd_d(rd)) \
: "memory"); \
} while (0)
#define vis_stblk(rd, mem) \
do { register void *__mem asm("g1"); \
__mem = &(mem); \
__asm__ __volatile__(".word 0xc1b85e00 | %1" \
: \
: "r" (__mem), \
"i" (vis_rd_d(rd)) \
: "memory"); \
} while (0)
#define vis_membar_storestore() \
__asm__ __volatile__(".word 0x8143e008" : : : "memory")
#define vis_membar_sync() \
__asm__ __volatile__(".word 0x8143e040" : : : "memory")
/* 16 and 32 bit partitioned addition and subtraction. The normal
* versions perform 4 16-bit or 2 32-bit additions or subtractions.
* The 's' versions perform 2 16-bit or 2 32-bit additions or
* subtractions.
*/
#define vis_padd16(rs1,rs2,rd) vis_dd2d(0x50, rs1, rs2, rd)
#define vis_padd16s(rs1,rs2,rd) vis_ss2s(0x51, rs1, rs2, rd)
#define vis_padd32(rs1,rs2,rd) vis_dd2d(0x52, rs1, rs2, rd)
#define vis_padd32s(rs1,rs2,rd) vis_ss2s(0x53, rs1, rs2, rd)
#define vis_psub16(rs1,rs2,rd) vis_dd2d(0x54, rs1, rs2, rd)
#define vis_psub16s(rs1,rs2,rd) vis_ss2s(0x55, rs1, rs2, rd)
#define vis_psub32(rs1,rs2,rd) vis_dd2d(0x56, rs1, rs2, rd)
#define vis_psub32s(rs1,rs2,rd) vis_ss2s(0x57, rs1, rs2, rd)
/* Pixel formatting instructions. */
#define vis_pack16(rs2,rd) vis_d2s( 0x3b, rs2, rd)
#define vis_pack32(rs1,rs2,rd) vis_dd2d(0x3a, rs1, rs2, rd)
#define vis_packfix(rs2,rd) vis_d2s( 0x3d, rs2, rd)
#define vis_expand(rs2,rd) vis_s2d( 0x4d, rs2, rd)
#define vis_pmerge(rs1,rs2,rd) vis_ss2d(0x4b, rs1, rs2, rd)
/* Partitioned multiply instructions. */
#define vis_mul8x16(rs1,rs2,rd) vis_sd2d(0x31, rs1, rs2, rd)
#define vis_mul8x16au(rs1,rs2,rd) vis_ss2d(0x33, rs1, rs2, rd)
#define vis_mul8x16al(rs1,rs2,rd) vis_ss2d(0x35, rs1, rs2, rd)
#define vis_mul8sux16(rs1,rs2,rd) vis_dd2d(0x36, rs1, rs2, rd)
#define vis_mul8ulx16(rs1,rs2,rd) vis_dd2d(0x37, rs1, rs2, rd)
#define vis_muld8sux16(rs1,rs2,rd) vis_ss2d(0x38, rs1, rs2, rd)
#define vis_muld8ulx16(rs1,rs2,rd) vis_ss2d(0x39, rs1, rs2, rd)
/* Alignment instructions. */
static inline void *vis_alignaddr(void *_ptr)
{
register void *ptr asm("g1");
ptr = _ptr;
__asm__ __volatile__(".word %2"
: "=&r" (ptr)
: "0" (ptr),
"i" (vis_opc_base | vis_opf(0x18) |
vis_rs1_s(1) |
vis_rs2_s(0) |
vis_rd_s(1)));
return ptr;
}
static inline void vis_alignaddr_g0(void *_ptr)
{
register void *ptr asm("g1");
ptr = _ptr;
__asm__ __volatile__(".word %2"
: "=&r" (ptr)
: "0" (ptr),
"i" (vis_opc_base | vis_opf(0x18) |
vis_rs1_s(1) |
vis_rs2_s(0) |
vis_rd_s(0)));
}
static inline void *vis_alignaddrl(void *_ptr)
{
register void *ptr asm("g1");
ptr = _ptr;
__asm__ __volatile__(".word %2"
: "=&r" (ptr)
: "0" (ptr),
"i" (vis_opc_base | vis_opf(0x19) |
vis_rs1_s(1) |
vis_rs2_s(0) |
vis_rd_s(1)));
return ptr;
}
static inline void vis_alignaddrl_g0(void *_ptr)
{
register void *ptr asm("g1");
ptr = _ptr;
__asm__ __volatile__(".word %2"
: "=&r" (ptr)
: "0" (ptr),
"i" (vis_opc_base | vis_opf(0x19) |
vis_rs1_s(1) |
vis_rs2_s(0) |
vis_rd_s(0)));
}
#define vis_faligndata(rs1,rs2,rd) vis_dd2d(0x48, rs1, rs2, rd)
/* Logical operate instructions. */
#define vis_fzero(rd) vis_d( 0x60, rd)
#define vis_fzeros(rd) vis_s( 0x61, rd)
#define vis_fone(rd) vis_d( 0x7e, rd)
#define vis_fones(rd) vis_s( 0x7f, rd)
#define vis_src1(rs1,rd) vis_d12d(0x74, rs1, rd)
#define vis_src1s(rs1,rd) vis_s12s(0x75, rs1, rd)
#define vis_src2(rs2,rd) vis_d22d(0x78, rs2, rd)
#define vis_src2s(rs2,rd) vis_s22s(0x79, rs2, rd)
#define vis_not1(rs1,rd) vis_d12d(0x6a, rs1, rd)
#define vis_not1s(rs1,rd) vis_s12s(0x6b, rs1, rd)
#define vis_not2(rs2,rd) vis_d22d(0x66, rs2, rd)
#define vis_not2s(rs2,rd) vis_s22s(0x67, rs2, rd)
#define vis_or(rs1,rs2,rd) vis_dd2d(0x7c, rs1, rs2, rd)
#define vis_ors(rs1,rs2,rd) vis_ss2s(0x7d, rs1, rs2, rd)
#define vis_nor(rs1,rs2,rd) vis_dd2d(0x62, rs1, rs2, rd)
#define vis_nors(rs1,rs2,rd) vis_ss2s(0x63, rs1, rs2, rd)
#define vis_and(rs1,rs2,rd) vis_dd2d(0x70, rs1, rs2, rd)
#define vis_ands(rs1,rs2,rd) vis_ss2s(0x71, rs1, rs2, rd)
#define vis_nand(rs1,rs2,rd) vis_dd2d(0x6e, rs1, rs2, rd)
#define vis_nands(rs1,rs2,rd) vis_ss2s(0x6f, rs1, rs2, rd)
#define vis_xor(rs1,rs2,rd) vis_dd2d(0x6c, rs1, rs2, rd)
#define vis_xors(rs1,rs2,rd) vis_ss2s(0x6d, rs1, rs2, rd)
#define vis_xnor(rs1,rs2,rd) vis_dd2d(0x72, rs1, rs2, rd)
#define vis_xnors(rs1,rs2,rd) vis_ss2s(0x73, rs1, rs2, rd)
#define vis_ornot1(rs1,rs2,rd) vis_dd2d(0x7a, rs1, rs2, rd)
#define vis_ornot1s(rs1,rs2,rd) vis_ss2s(0x7b, rs1, rs2, rd)
#define vis_ornot2(rs1,rs2,rd) vis_dd2d(0x76, rs1, rs2, rd)
#define vis_ornot2s(rs1,rs2,rd) vis_ss2s(0x77, rs1, rs2, rd)
#define vis_andnot1(rs1,rs2,rd) vis_dd2d(0x68, rs1, rs2, rd)
#define vis_andnot1s(rs1,rs2,rd) vis_ss2s(0x69, rs1, rs2, rd)
#define vis_andnot2(rs1,rs2,rd) vis_dd2d(0x64, rs1, rs2, rd)
#define vis_andnot2s(rs1,rs2,rd) vis_ss2s(0x65, rs1, rs2, rd)
/* Pixel component distance. */
#define vis_pdist(rs1,rs2,rd) vis_dd2d(0x3e, rs1, rs2, rd)
#endif /* LIBMPEG2_VIS_H */

View File

@ -1,434 +0,0 @@
/*
* vlc.h
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LIBMPEG2_VLC_H
#define LIBMPEG2_VLC_H
#define GETWORD(bit_buf,shift,bit_ptr) \
do { \
bit_buf |= ((bit_ptr[0] << 8) | bit_ptr[1]) << (shift); \
bit_ptr += 2; \
} while (0)
static inline void bitstream_init (mpeg2_decoder_t * decoder,
const uint8_t * start)
{
decoder->bitstream_buf =
(start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3];
decoder->bitstream_ptr = start + 4;
decoder->bitstream_bits = -16;
}
/* make sure that there are at least 16 valid bits in bit_buf */
#define NEEDBITS(bit_buf,bits,bit_ptr) \
do { \
if (unlikely (bits > 0)) { \
GETWORD (bit_buf, bits, bit_ptr); \
bits -= 16; \
} \
} while (0)
/* remove num valid bits from bit_buf */
#define DUMPBITS(bit_buf,bits,num) \
do { \
bit_buf <<= (num); \
bits += (num); \
} while (0)
/* take num bits from the high part of bit_buf and zero extend them */
#define UBITS(bit_buf,num) (((uint32_t)(bit_buf)) >> (32 - (num)))
/* take num bits from the high part of bit_buf and sign extend them */
#define SBITS(bit_buf,num) (((int32_t)(bit_buf)) >> (32 - (num)))
typedef struct {
uint8_t modes;
uint8_t len;
} MBtab;
typedef struct {
uint8_t delta;
uint8_t len;
} MVtab;
typedef struct {
int8_t dmv;
uint8_t len;
} DMVtab;
typedef struct {
uint8_t cbp;
uint8_t len;
} CBPtab;
typedef struct {
uint8_t size;
uint8_t len;
} DCtab;
typedef struct {
uint8_t run;
uint8_t level;
uint8_t len;
} DCTtab;
typedef struct {
uint8_t mba;
uint8_t len;
} MBAtab;
#define INTRA MACROBLOCK_INTRA
#define QUANT MACROBLOCK_QUANT
static const MBtab MB_I [] = {
{INTRA|QUANT, 2}, {INTRA, 1}
};
#define MC MACROBLOCK_MOTION_FORWARD
#define CODED MACROBLOCK_PATTERN
static const MBtab MB_P [] = {
{INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA, 5},
{MC, 3}, {MC, 3}, {MC, 3}, {MC, 3},
{CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
{CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
{MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
{MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
{MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
{MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}
};
#define FWD MACROBLOCK_MOTION_FORWARD
#define BWD MACROBLOCK_MOTION_BACKWARD
#define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
static const MBtab MB_B [] = {
{0, 6}, {INTRA|QUANT, 6},
{BWD|CODED|QUANT, 6}, {FWD|CODED|QUANT, 6},
{INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
{INTRA, 5}, {INTRA, 5},
{FWD, 4}, {FWD, 4}, {FWD, 4}, {FWD, 4},
{FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4},
{BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
{BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
{BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
{BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
{INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
{INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
{INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
{INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
};
#undef INTRA
#undef QUANT
#undef MC
#undef CODED
#undef FWD
#undef BWD
#undef INTER
static const MVtab MV_4 [] = {
{ 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
};
static const MVtab MV_10 [] = {
{ 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
{ 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
{11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
{ 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
{ 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
{ 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
};
static const DMVtab DMV_2 [] = {
{ 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
};
static const CBPtab CBP_7 [] = {
{0x11, 7}, {0x12, 7}, {0x14, 7}, {0x18, 7},
{0x21, 7}, {0x22, 7}, {0x24, 7}, {0x28, 7},
{0x3f, 6}, {0x3f, 6}, {0x30, 6}, {0x30, 6},
{0x09, 6}, {0x09, 6}, {0x06, 6}, {0x06, 6},
{0x1f, 5}, {0x1f, 5}, {0x1f, 5}, {0x1f, 5},
{0x10, 5}, {0x10, 5}, {0x10, 5}, {0x10, 5},
{0x2f, 5}, {0x2f, 5}, {0x2f, 5}, {0x2f, 5},
{0x20, 5}, {0x20, 5}, {0x20, 5}, {0x20, 5},
{0x07, 5}, {0x07, 5}, {0x07, 5}, {0x07, 5},
{0x0b, 5}, {0x0b, 5}, {0x0b, 5}, {0x0b, 5},
{0x0d, 5}, {0x0d, 5}, {0x0d, 5}, {0x0d, 5},
{0x0e, 5}, {0x0e, 5}, {0x0e, 5}, {0x0e, 5},
{0x05, 5}, {0x05, 5}, {0x05, 5}, {0x05, 5},
{0x0a, 5}, {0x0a, 5}, {0x0a, 5}, {0x0a, 5},
{0x03, 5}, {0x03, 5}, {0x03, 5}, {0x03, 5},
{0x0c, 5}, {0x0c, 5}, {0x0c, 5}, {0x0c, 5},
{0x01, 4}, {0x01, 4}, {0x01, 4}, {0x01, 4},
{0x01, 4}, {0x01, 4}, {0x01, 4}, {0x01, 4},
{0x02, 4}, {0x02, 4}, {0x02, 4}, {0x02, 4},
{0x02, 4}, {0x02, 4}, {0x02, 4}, {0x02, 4},
{0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
{0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
{0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
{0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
{0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3},
{0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3},
{0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3},
{0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3}
};
static const CBPtab CBP_9 [] = {
{0, 9}, {0x00, 9}, {0x39, 9}, {0x36, 9},
{0x37, 9}, {0x3b, 9}, {0x3d, 9}, {0x3e, 9},
{0x17, 8}, {0x17, 8}, {0x1b, 8}, {0x1b, 8},
{0x1d, 8}, {0x1d, 8}, {0x1e, 8}, {0x1e, 8},
{0x27, 8}, {0x27, 8}, {0x2b, 8}, {0x2b, 8},
{0x2d, 8}, {0x2d, 8}, {0x2e, 8}, {0x2e, 8},
{0x19, 8}, {0x19, 8}, {0x16, 8}, {0x16, 8},
{0x29, 8}, {0x29, 8}, {0x26, 8}, {0x26, 8},
{0x35, 8}, {0x35, 8}, {0x3a, 8}, {0x3a, 8},
{0x33, 8}, {0x33, 8}, {0x3c, 8}, {0x3c, 8},
{0x15, 8}, {0x15, 8}, {0x1a, 8}, {0x1a, 8},
{0x13, 8}, {0x13, 8}, {0x1c, 8}, {0x1c, 8},
{0x25, 8}, {0x25, 8}, {0x2a, 8}, {0x2a, 8},
{0x23, 8}, {0x23, 8}, {0x2c, 8}, {0x2c, 8},
{0x31, 8}, {0x31, 8}, {0x32, 8}, {0x32, 8},
{0x34, 8}, {0x34, 8}, {0x38, 8}, {0x38, 8}
};
static const DCtab DC_lum_5 [] = {
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
{0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
{4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
};
static const DCtab DC_chrom_5 [] = {
{0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
{3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
};
static const DCtab DC_long [] = {
{6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
{6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
{7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
{8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
};
static const DCTtab DCT_16 [] = {
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
{ 2,18, 0}, { 2,17, 0}, { 2,16, 0}, { 2,15, 0},
{ 7, 3, 0}, { 17, 2, 0}, { 16, 2, 0}, { 15, 2, 0},
{ 14, 2, 0}, { 13, 2, 0}, { 12, 2, 0}, { 32, 1, 0},
{ 31, 1, 0}, { 30, 1, 0}, { 29, 1, 0}, { 28, 1, 0}
};
static const DCTtab DCT_15 [] = {
{ 1,40,15}, { 1,39,15}, { 1,38,15}, { 1,37,15},
{ 1,36,15}, { 1,35,15}, { 1,34,15}, { 1,33,15},
{ 1,32,15}, { 2,14,15}, { 2,13,15}, { 2,12,15},
{ 2,11,15}, { 2,10,15}, { 2, 9,15}, { 2, 8,15},
{ 1,31,14}, { 1,31,14}, { 1,30,14}, { 1,30,14},
{ 1,29,14}, { 1,29,14}, { 1,28,14}, { 1,28,14},
{ 1,27,14}, { 1,27,14}, { 1,26,14}, { 1,26,14},
{ 1,25,14}, { 1,25,14}, { 1,24,14}, { 1,24,14},
{ 1,23,14}, { 1,23,14}, { 1,22,14}, { 1,22,14},
{ 1,21,14}, { 1,21,14}, { 1,20,14}, { 1,20,14},
{ 1,19,14}, { 1,19,14}, { 1,18,14}, { 1,18,14},
{ 1,17,14}, { 1,17,14}, { 1,16,14}, { 1,16,14}
};
static const DCTtab DCT_13 [] = {
{ 11, 2,13}, { 10, 2,13}, { 6, 3,13}, { 4, 4,13},
{ 3, 5,13}, { 2, 7,13}, { 2, 6,13}, { 1,15,13},
{ 1,14,13}, { 1,13,13}, { 1,12,13}, { 27, 1,13},
{ 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
{ 1,11,12}, { 1,11,12}, { 9, 2,12}, { 9, 2,12},
{ 5, 3,12}, { 5, 3,12}, { 1,10,12}, { 1,10,12},
{ 3, 4,12}, { 3, 4,12}, { 8, 2,12}, { 8, 2,12},
{ 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
{ 1, 9,12}, { 1, 9,12}, { 20, 1,12}, { 20, 1,12},
{ 19, 1,12}, { 19, 1,12}, { 2, 5,12}, { 2, 5,12},
{ 4, 3,12}, { 4, 3,12}, { 1, 8,12}, { 1, 8,12},
{ 7, 2,12}, { 7, 2,12}, { 18, 1,12}, { 18, 1,12}
};
static const DCTtab DCT_B14_10 [] = {
{ 17, 1,10}, { 6, 2,10}, { 1, 7,10}, { 3, 3,10},
{ 2, 4,10}, { 16, 1,10}, { 15, 1,10}, { 5, 2,10}
};
static const DCTtab DCT_B14_8 [] = {
{ 65, 0,12}, { 65, 0,12}, { 65, 0,12}, { 65, 0,12},
{ 3, 2, 7}, { 3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
{ 1, 4, 7}, { 1, 4, 7}, { 9, 1, 7}, { 9, 1, 7},
{ 8, 1, 6}, { 8, 1, 6}, { 8, 1, 6}, { 8, 1, 6},
{ 7, 1, 6}, { 7, 1, 6}, { 7, 1, 6}, { 7, 1, 6},
{ 2, 2, 6}, { 2, 2, 6}, { 2, 2, 6}, { 2, 2, 6},
{ 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
{ 14, 1, 8}, { 1, 6, 8}, { 13, 1, 8}, { 12, 1, 8},
{ 4, 2, 8}, { 2, 3, 8}, { 1, 5, 8}, { 11, 1, 8}
};
static const DCTtab DCT_B14AC_5 [] = {
{ 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
{ 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
{129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}
};
static const DCTtab DCT_B14DC_5 [] = {
{ 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
{ 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
{ 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
{ 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
{ 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}
};
static const DCTtab DCT_B15_10 [] = {
{ 6, 2, 9}, { 6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
{ 3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
};
static const DCTtab DCT_B15_8 [] = {
{ 65, 0,12}, { 65, 0,12}, { 65, 0,12}, { 65, 0,12},
{ 8, 1, 7}, { 8, 1, 7}, { 9, 1, 7}, { 9, 1, 7},
{ 7, 1, 7}, { 7, 1, 7}, { 3, 2, 7}, { 3, 2, 7},
{ 1, 7, 6}, { 1, 7, 6}, { 1, 7, 6}, { 1, 7, 6},
{ 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6},
{ 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6},
{ 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
{ 2, 5, 8}, { 12, 1, 8}, { 1,11, 8}, { 1,10, 8},
{ 14, 1, 8}, { 13, 1, 8}, { 4, 2, 8}, { 2, 4, 8},
{ 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
{ 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
{ 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5},
{ 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5},
{ 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5},
{ 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{ 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
{129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
{129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
{129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
{129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
{ 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
{ 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
{ 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
{ 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
{ 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5},
{ 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5},
{ 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
{ 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
{ 10, 1, 7}, { 10, 1, 7}, { 2, 3, 7}, { 2, 3, 7},
{ 11, 1, 7}, { 11, 1, 7}, { 1, 8, 7}, { 1, 8, 7},
{ 1, 9, 7}, { 1, 9, 7}, { 1,12, 8}, { 1,13, 8},
{ 3, 3, 8}, { 5, 2, 8}, { 1,14, 8}, { 1,15, 8}
};
static const MBAtab MBA_5 [] = {
{6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1},
{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}
};
static const MBAtab MBA_11 [] = {
{32, 11}, {31, 11}, {30, 11}, {29, 11},
{28, 11}, {27, 11}, {26, 11}, {25, 11},
{24, 11}, {23, 11}, {22, 11}, {21, 11},
{20, 10}, {20, 10}, {19, 10}, {19, 10},
{18, 10}, {18, 10}, {17, 10}, {17, 10},
{16, 10}, {16, 10}, {15, 10}, {15, 10},
{14, 8}, {14, 8}, {14, 8}, {14, 8},
{14, 8}, {14, 8}, {14, 8}, {14, 8},
{13, 8}, {13, 8}, {13, 8}, {13, 8},
{13, 8}, {13, 8}, {13, 8}, {13, 8},
{12, 8}, {12, 8}, {12, 8}, {12, 8},
{12, 8}, {12, 8}, {12, 8}, {12, 8},
{11, 8}, {11, 8}, {11, 8}, {11, 8},
{11, 8}, {11, 8}, {11, 8}, {11, 8},
{10, 8}, {10, 8}, {10, 8}, {10, 8},
{10, 8}, {10, 8}, {10, 8}, {10, 8},
{ 9, 8}, { 9, 8}, { 9, 8}, { 9, 8},
{ 9, 8}, { 9, 8}, { 9, 8}, { 9, 8},
{ 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
{ 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
{ 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
{ 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
{ 7, 7}, { 7, 7}, { 7, 7}, { 7, 7},
{ 7, 7}, { 7, 7}, { 7, 7}, { 7, 7},
{ 7, 7}, { 7, 7}, { 7, 7}, { 7, 7},
{ 7, 7}, { 7, 7}, { 7, 7}, { 7, 7}
};
#endif /* LIBMPEG2_VLC_H */