Commit ca411fc1 authored by Diego Biurrun's avatar Diego Biurrun

avcodec: Remove broken MMI optimizations

The code fails to compile and is broken beyond repair.
parent bc4620e5
......@@ -104,7 +104,7 @@ config.h: .config
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
ARMV5TE-OBJS ARMV6-OBJS ARMVFP-OBJS NEON-OBJS \
MMI-OBJS ALTIVEC-OBJS VIS-OBJS \
ALTIVEC-OBJS VIS-OBJS \
MMX-OBJS YASM-OBJS \
OBJS HOSTOBJS TESTOBJS
......
......@@ -3,8 +3,6 @@ OBJS-$(HAVE_ARMV6) += $(ARMV6-OBJS) $(ARMV6-OBJS-yes)
OBJS-$(HAVE_ARMVFP) += $(ARMVFP-OBJS) $(ARMVFP-OBJS-yes)
OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes)
OBJS-$(HAVE_MMI) += $(MMI-OBJS) $(MMI-OBJS-yes)
OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
OBJS-$(HAVE_VIS) += $(VIS-OBJS) $(VIS-OBJS-yes)
......
......@@ -259,7 +259,6 @@ Optimization options (experts only):
--disable-armv6 disable armv6 optimizations
--disable-armv6t2 disable armv6t2 optimizations
--disable-armvfp disable ARM VFP optimizations
--disable-mmi disable MMI optimizations
--disable-neon disable NEON optimizations
--disable-vis disable VIS optimizations
--disable-inline-asm disable use of inline assembler
......@@ -1101,7 +1100,6 @@ ARCH_EXT_LIST="
armv6
armv6t2
armvfp
mmi
neon
ppc4xx
vfpv3
......@@ -1351,8 +1349,6 @@ armvfp_deps="arm"
neon_deps="arm"
vfpv3_deps="armvfp"
mmi_deps="mips"
altivec_deps="ppc"
ppc4xx_deps="ppc"
......@@ -3031,7 +3027,6 @@ EOF
elif enabled mips; then
check_inline_asm loongson '"dmult.g $1, $2, $3"'
enabled mmi && check_inline_asm mmi '"lq $2, 0($2)"'
elif enabled ppc; then
......@@ -3578,9 +3573,6 @@ if enabled arm; then
echo "ARM VFP enabled ${armvfp-no}"
echo "NEON enabled ${neon-no}"
fi
if enabled mips; then
echo "MMI enabled ${mmi-no}"
fi
if enabled ppc; then
echo "AltiVec enabled ${altivec-no}"
echo "PPC 4xx optimizations ${ppc4xx-no}"
......
......@@ -2623,7 +2623,9 @@ typedef struct AVCodecContext {
#if FF_API_LIBMPEG2
#define FF_IDCT_LIBMPEG2MMX 4
#endif
#if FF_API_MMI
#define FF_IDCT_MMI 5
#endif
#define FF_IDCT_ARM 7
#define FF_IDCT_ALTIVEC 8
#define FF_IDCT_SH4 9
......
......@@ -2976,7 +2976,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);
if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);
if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);
if (HAVE_MMI) ff_dsputil_init_mmi (c, avctx);
if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);
if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);
......
......@@ -599,7 +599,6 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){
void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
......@@ -607,7 +606,7 @@ void ff_dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_dwt(DSPContext *c);
#if (ARCH_ARM && HAVE_NEON) || ARCH_PPC || HAVE_MMI || HAVE_MMX
#if (ARCH_ARM && HAVE_NEON) || ARCH_PPC || HAVE_MMX
# define STRIDE_ALIGN 16
#else
# define STRIDE_ALIGN 8
......
MMI-OBJS += mips/dsputil_mmi.o \
mips/idct_mmi.o \
MMI-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_mmi.o
/*
* MMI optimized DSP utils
* Copyright (c) 2000, 2001 Fabrice Bellard
*
* MMI optimization by Leon van Stuivenberg
* clear_blocks_mmi() by BroadQ
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavcodec/dsputil.h"
#include "mmi.h"
static void clear_blocks_mmi(DCTELEM * blocks)
{
__asm__ volatile(
".set noreorder \n"
"addiu $9, %0, 768 \n"
"nop \n"
"1: \n"
"sq $0, 0(%0) \n"
"move $8, %0 \n"
"addi %0, %0, 64 \n"
"sq $0, 16($8) \n"
"slt $10, %0, $9 \n"
"sq $0, 32($8) \n"
"bnez $10, 1b \n"
"sq $0, 48($8) \n"
".set reorder \n"
: "+r" (blocks) :: "$8", "$9", "memory" );
}
static void get_pixels_mmi(DCTELEM *block, const uint8_t *pixels, int line_size)
{
__asm__ volatile(
".set push \n\t"
".set mips3 \n\t"
"ld $8, 0(%0) \n\t"
"add %0, %0, %2 \n\t"
"ld $9, 0(%0) \n\t"
"add %0, %0, %2 \n\t"
"ld $10, 0(%0) \n\t"
"pextlb $8, $0, $8 \n\t"
"sq $8, 0(%1) \n\t"
"add %0, %0, %2 \n\t"
"ld $8, 0(%0) \n\t"
"pextlb $9, $0, $9 \n\t"
"sq $9, 16(%1) \n\t"
"add %0, %0, %2 \n\t"
"ld $9, 0(%0) \n\t"
"pextlb $10, $0, $10 \n\t"
"sq $10, 32(%1) \n\t"
"add %0, %0, %2 \n\t"
"ld $10, 0(%0) \n\t"
"pextlb $8, $0, $8 \n\t"
"sq $8, 48(%1) \n\t"
"add %0, %0, %2 \n\t"
"ld $8, 0(%0) \n\t"
"pextlb $9, $0, $9 \n\t"
"sq $9, 64(%1) \n\t"
"add %0, %0, %2 \n\t"
"ld $9, 0(%0) \n\t"
"pextlb $10, $0, $10 \n\t"
"sq $10, 80(%1) \n\t"
"pextlb $8, $0, $8 \n\t"
"sq $8, 96(%1) \n\t"
"pextlb $9, $0, $9 \n\t"
"sq $9, 112(%1) \n\t"
".set pop \n\t"
: "+r" (pixels) : "r" (block), "r" (line_size) : "$8", "$9", "$10", "memory" );
}
static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm__ volatile(
".set push \n\t"
".set mips3 \n\t"
"1: \n\t"
"ldr $8, 0(%1) \n\t"
"addiu %2, %2, -1 \n\t"
"ldl $8, 7(%1) \n\t"
"add %1, %1, %3 \n\t"
"sd $8, 0(%0) \n\t"
"add %0, %0, %3 \n\t"
"bgtz %2, 1b \n\t"
".set pop \n\t"
: "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
: "$8", "memory" );
}
static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
{
__asm__ volatile (
".set push \n\t"
".set mips3 \n\t"
"1: \n\t"
"ldr $8, 0(%1) \n\t"
"add $11, %1, %3 \n\t"
"ldl $8, 7(%1) \n\t"
"add $10, %0, %3 \n\t"
"ldr $9, 8(%1) \n\t"
"ldl $9, 15(%1) \n\t"
"ldr $12, 0($11) \n\t"
"add %1, $11, %3 \n\t"
"ldl $12, 7($11) \n\t"
"pcpyld $8, $9, $8 \n\t"
"sq $8, 0(%0) \n\t"
"ldr $13, 8($11) \n\t"
"addiu %2, %2, -2 \n\t"
"ldl $13, 15($11) \n\t"
"add %0, $10, %3 \n\t"
"pcpyld $12, $13, $12 \n\t"
"sq $12, 0($10) \n\t"
"bgtz %2, 1b \n\t"
".set pop \n\t"
: "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
: "$8", "$9", "$10", "$11", "$12", "$13", "memory" );
}
void ff_dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
{
const int idct_algo= avctx->idct_algo;
const int high_bit_depth = avctx->bits_per_raw_sample > 8;
if (!high_bit_depth) {
c->clear_blocks = clear_blocks_mmi;
c->put_pixels_tab[1][0] = put_pixels8_mmi;
c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
c->put_pixels_tab[0][0] = put_pixels16_mmi;
c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
c->get_pixels = get_pixels_mmi;
}
if (avctx->bits_per_raw_sample <= 8 &&
(idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_MMI)) {
c->idct_put= ff_mmi_idct_put;
c->idct_add= ff_mmi_idct_add;
c->idct = ff_mmi_idct;
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
}
}
This diff is collapsed.
/*
* copyright (c) 2002 Leon van Stuivenberg
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_MIPS_MMI_H
#define AVCODEC_MIPS_MMI_H
#include <stdint.h>
#include "libavcodec/dsputil.h"
void ff_mmi_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
void ff_mmi_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
void ff_mmi_idct(DCTELEM *block);
#define align16 __attribute__ ((aligned (16)))
/*
#define r0 $zero
#define r1 $at //assembler!
#define r2 $v0 //return
#define r3 $v1 //return
#define r4 $a0 //arg
#define r5 $a1 //arg
#define r6 $a2 //arg
#define r7 $a3 //arg
#define r8 $t0 //temp
#define r9 $t1 //temp
#define r10 $t2 //temp
#define r11 $t3 //temp
#define r12 $t4 //temp
#define r13 $t5 //temp
#define r14 $t6 //temp
#define r15 $t7 //temp
#define r16 $s0 //saved temp
#define r17 $s1 //saved temp
#define r18 $s2 //saved temp
#define r19 $s3 //saved temp
#define r20 $s4 //saved temp
#define r21 $s5 //saved temp
#define r22 $s6 //saved temp
#define r23 $s7 //saved temp
#define r24 $t8 //temp
#define r25 $t9 //temp
#define r26 $k0 //kernel
#define r27 $k1 //kernel
#define r28 $gp //global ptr
#define r29 $sp //stack ptr
#define r30 $fp //frame ptr
#define r31 $ra //return addr
*/
#define lq(base, off, reg) \
__asm__ volatile ("lq " #reg ", %0("#base ")" : : "i" (off) )
#define lq2(mem, reg) \
__asm__ volatile ("lq " #reg ", %0" : : "r" (mem))
#define sq(reg, off, base) \
__asm__ volatile ("sq " #reg ", %0("#base ")" : : "i" (off) )
/*
#define ld(base, off, reg) \
__asm__ volatile ("ld " #reg ", " #off "("#base ")")
*/
#define ld3(base, off, reg) \
__asm__ volatile (".word %0" : : "i" ( 0xdc000000 | (base<<21) | (reg<<16) | (off)))
#define ldr3(base, off, reg) \
__asm__ volatile (".word %0" : : "i" ( 0x6c000000 | (base<<21) | (reg<<16) | (off)))
#define ldl3(base, off, reg) \
__asm__ volatile (".word %0" : : "i" ( 0x68000000 | (base<<21) | (reg<<16) | (off)))
/*
#define sd(reg, off, base) \
__asm__ volatile ("sd " #reg ", " #off "("#base ")")
*/
//seems assembler has bug encoding mnemonic 'sd', so DIY
#define sd3(reg, off, base) \
__asm__ volatile (".word %0" : : "i" ( 0xfc000000 | (base<<21) | (reg<<16) | (off)))
#define sw(reg, off, base) \
__asm__ volatile ("sw " #reg ", " #off "("#base ")")
#define sq2(reg, mem) \
__asm__ volatile ("sq " #reg ", %0" : : "m" (*(mem)))
#define pinth(rs, rt, rd) \
__asm__ volatile ("pinth " #rd ", " #rs ", " #rt )
#define phmadh(rs, rt, rd) \
__asm__ volatile ("phmadh " #rd ", " #rs ", " #rt )
#define pcpyud(rs, rt, rd) \
__asm__ volatile ("pcpyud " #rd ", " #rs ", " #rt )
#define pcpyld(rs, rt, rd) \
__asm__ volatile ("pcpyld " #rd ", " #rs ", " #rt )
#define pcpyh(rt, rd) \
__asm__ volatile ("pcpyh " #rd ", " #rt )
#define paddw(rs, rt, rd) \
__asm__ volatile ("paddw " #rd ", " #rs ", " #rt )
#define pextlw(rs, rt, rd) \
__asm__ volatile ("pextlw " #rd ", " #rs ", " #rt )
#define pextuw(rs, rt, rd) \
__asm__ volatile ("pextuw " #rd ", " #rs ", " #rt )
#define pextlh(rs, rt, rd) \
__asm__ volatile ("pextlh " #rd ", " #rs ", " #rt )
#define pextuh(rs, rt, rd) \
__asm__ volatile ("pextuh " #rd ", " #rs ", " #rt )
#define psubw(rs, rt, rd) \
__asm__ volatile ("psubw " #rd ", " #rs ", " #rt )
#define psraw(rt, sa, rd) \
__asm__ volatile ("psraw " #rd ", " #rt ", %0" : : "i"(sa) )
#define ppach(rs, rt, rd) \
__asm__ volatile ("ppach " #rd ", " #rs ", " #rt )
#define ppacb(rs, rt, rd) \
__asm__ volatile ("ppacb " #rd ", " #rs ", " #rt )
#define prevh(rt, rd) \
__asm__ volatile ("prevh " #rd ", " #rt )
#define pmulth(rs, rt, rd) \
__asm__ volatile ("pmulth " #rd ", " #rs ", " #rt )
#define pmaxh(rs, rt, rd) \
__asm__ volatile ("pmaxh " #rd ", " #rs ", " #rt )
#define pminh(rs, rt, rd) \
__asm__ volatile ("pminh " #rd ", " #rs ", " #rt )
#define pinteh(rs, rt, rd) \
__asm__ volatile ("pinteh " #rd ", " #rs ", " #rt )
#define paddh(rs, rt, rd) \
__asm__ volatile ("paddh " #rd ", " #rs ", " #rt )
#define psubh(rs, rt, rd) \
__asm__ volatile ("psubh " #rd ", " #rs ", " #rt )
#define psrah(rt, sa, rd) \
__asm__ volatile ("psrah " #rd ", " #rt ", %0" : : "i"(sa) )
#define pmfhl_uw(rd) \
__asm__ volatile ("pmfhl.uw " #rd)
#define pextlb(rs, rt, rd) \
__asm__ volatile ("pextlb " #rd ", " #rs ", " #rt )
#endif /* AVCODEC_MIPS_MMI_H */
/*
* Copyright (c) 2000,2001 Fabrice Bellard
*
* MMI optimization by Leon van Stuivenberg
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h"
static void dct_unquantize_h263_mmi(MpegEncContext *s,
DCTELEM *block, int n, int qscale)
{
int level=0, qmul, qadd;
int nCoeffs;
assert(s->block_last_index[n]>=0);
qadd = (qscale - 1) | 1;
qmul = qscale << 1;
if (s->mb_intra) {
if (!s->h263_aic) {
if (n < 4)
level = block[0] * s->y_dc_scale;
else
level = block[0] * s->c_dc_scale;
}else {
qadd = 0;
level = block[0];
}
nCoeffs= 63; //does not always use zigzag table
} else {
nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
}
__asm__ volatile(
"add $14, $0, %3 \n\t"
"pcpyld $8, %0, %0 \n\t"
"pcpyh $8, $8 \n\t" //r8 = qmul
"pcpyld $9, %1, %1 \n\t"
"pcpyh $9, $9 \n\t" //r9 = qadd
".p2align 2 \n\t"
"1: \n\t"
"lq $10, 0($14) \n\t" //r10 = level
"addi $14, $14, 16 \n\t" //block+=8
"addi %2, %2, -8 \n\t"
"pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
"pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
"por $12, $11, $12 \n\t"
"pmulth $10, $10, $8 \n\t"
"paddh $13, $9, $11 \n\t"
"pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
"pmfhl.uw $11 \n\t"
"pinteh $10, $11, $10 \n\t" //r10 = level * qmul
"paddh $10, $10, $13 \n\t"
"pand $10, $10, $12 \n\t"
"sq $10, -16($14) \n\t"
"bgez %2, 1b \n\t"
:: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
if(s->mb_intra)
block[0]= level;
}
void ff_MPV_common_init_mmi(MpegEncContext *s)
{
s->dct_unquantize_h263_intra =
s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi;
}
......@@ -189,8 +189,6 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
ff_MPV_common_init_x86(s);
#elif ARCH_ALPHA
ff_MPV_common_init_axp(s);
#elif HAVE_MMI
ff_MPV_common_init_mmi(s);
#elif ARCH_ARM
ff_MPV_common_init_arm(s);
#elif HAVE_ALTIVEC
......
......@@ -765,7 +765,6 @@ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
void ff_MPV_encode_init_x86(MpegEncContext *s);
void ff_MPV_common_init_x86(MpegEncContext *s);
void ff_MPV_common_init_axp(MpegEncContext *s);
void ff_MPV_common_init_mmi(MpegEncContext *s);
void ff_MPV_common_init_arm(MpegEncContext *s);
void ff_MPV_common_init_altivec(MpegEncContext *s);
void ff_MPV_common_init_bfin(MpegEncContext *s);
......
......@@ -25,6 +25,7 @@
#include "libavutil/opt.h"
#include "avcodec.h"
#include "version.h"
#include "config.h"
#define OFFSET(x) offsetof(AVCodecContext,x)
......@@ -194,7 +195,9 @@ static const AVOption options[]={
{"int", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_INT }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"simple", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLE }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"simplemmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, "idct"},
#if FF_API_MMI
{"mmi", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_MMI }, INT_MIN, INT_MAX, V|E|D, "idct"},
#endif
{"arm", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ARM }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ALTIVEC }, INT_MIN, INT_MAX, V|E|D, "idct"},
{"sh4", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SH4 }, INT_MIN, INT_MAX, V|E|D, "idct"},
......
......@@ -88,5 +88,8 @@
#ifndef FF_API_LIBMPEG2
#define FF_API_LIBMPEG2 (LIBAVCODEC_VERSION_MAJOR < 55)
#endif
#ifndef FF_API_MMI
#define FF_API_MMI (LIBAVCODEC_VERSION_MAJOR < 55)
#endif
#endif /* AVCODEC_VERSION_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment