00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "libavcodec/dsputil.h"
00026 #include "mmi.h"
00027
00028 static void clear_blocks_mmi(DCTELEM * blocks)
00029 {
00030 __asm__ volatile(
00031 ".set noreorder \n"
00032 "addiu $9, %0, 768 \n"
00033 "nop \n"
00034 "1: \n"
00035 "sq $0, 0(%0) \n"
00036 "move $8, %0 \n"
00037 "addi %0, %0, 64 \n"
00038 "sq $0, 16($8) \n"
00039 "slt $10, %0, $9 \n"
00040 "sq $0, 32($8) \n"
00041 "bnez $10, 1b \n"
00042 "sq $0, 48($8) \n"
00043 ".set reorder \n"
00044 : "+r" (blocks) :: "$8", "$9", "memory" );
00045 }
00046
00047
00048 static void get_pixels_mmi(DCTELEM *block, const uint8_t *pixels, int line_size)
00049 {
00050 __asm__ volatile(
00051 ".set push \n\t"
00052 ".set mips3 \n\t"
00053 "ld $8, 0(%0) \n\t"
00054 "add %0, %0, %2 \n\t"
00055 "ld $9, 0(%0) \n\t"
00056 "add %0, %0, %2 \n\t"
00057 "ld $10, 0(%0) \n\t"
00058 "pextlb $8, $0, $8 \n\t"
00059 "sq $8, 0(%1) \n\t"
00060 "add %0, %0, %2 \n\t"
00061 "ld $8, 0(%0) \n\t"
00062 "pextlb $9, $0, $9 \n\t"
00063 "sq $9, 16(%1) \n\t"
00064 "add %0, %0, %2 \n\t"
00065 "ld $9, 0(%0) \n\t"
00066 "pextlb $10, $0, $10 \n\t"
00067 "sq $10, 32(%1) \n\t"
00068 "add %0, %0, %2 \n\t"
00069 "ld $10, 0(%0) \n\t"
00070 "pextlb $8, $0, $8 \n\t"
00071 "sq $8, 48(%1) \n\t"
00072 "add %0, %0, %2 \n\t"
00073 "ld $8, 0(%0) \n\t"
00074 "pextlb $9, $0, $9 \n\t"
00075 "sq $9, 64(%1) \n\t"
00076 "add %0, %0, %2 \n\t"
00077 "ld $9, 0(%0) \n\t"
00078 "pextlb $10, $0, $10 \n\t"
00079 "sq $10, 80(%1) \n\t"
00080 "pextlb $8, $0, $8 \n\t"
00081 "sq $8, 96(%1) \n\t"
00082 "pextlb $9, $0, $9 \n\t"
00083 "sq $9, 112(%1) \n\t"
00084 ".set pop \n\t"
00085 : "+r" (pixels) : "r" (block), "r" (line_size) : "$8", "$9", "$10", "memory" );
00086 }
00087
00088
00089 static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
00090 {
00091 __asm__ volatile(
00092 ".set push \n\t"
00093 ".set mips3 \n\t"
00094 "1: \n\t"
00095 "ldr $8, 0(%1) \n\t"
00096 "addiu %2, %2, -1 \n\t"
00097 "ldl $8, 7(%1) \n\t"
00098 "add %1, %1, %3 \n\t"
00099 "sd $8, 0(%0) \n\t"
00100 "add %0, %0, %3 \n\t"
00101 "bgtz %2, 1b \n\t"
00102 ".set pop \n\t"
00103 : "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
00104 : "$8", "memory" );
00105 }
00106
00107
00108 static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
00109 {
00110 __asm__ volatile (
00111 ".set push \n\t"
00112 ".set mips3 \n\t"
00113 "1: \n\t"
00114 "ldr $8, 0(%1) \n\t"
00115 "add $11, %1, %3 \n\t"
00116 "ldl $8, 7(%1) \n\t"
00117 "add $10, %0, %3 \n\t"
00118 "ldr $9, 8(%1) \n\t"
00119 "ldl $9, 15(%1) \n\t"
00120 "ldr $12, 0($11) \n\t"
00121 "add %1, $11, %3 \n\t"
00122 "ldl $12, 7($11) \n\t"
00123 "pcpyld $8, $9, $8 \n\t"
00124 "sq $8, 0(%0) \n\t"
00125 "ldr $13, 8($11) \n\t"
00126 "addiu %2, %2, -2 \n\t"
00127 "ldl $13, 15($11) \n\t"
00128 "add %0, $10, %3 \n\t"
00129 "pcpyld $12, $13, $12 \n\t"
00130 "sq $12, 0($10) \n\t"
00131 "bgtz %2, 1b \n\t"
00132 ".set pop \n\t"
00133 : "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
00134 : "$8", "$9", "$10", "$11", "$12", "$13", "memory" );
00135 }
00136
00137
00138 void ff_dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
00139 {
00140 const int idct_algo= avctx->idct_algo;
00141 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
00142
00143 if (!high_bit_depth) {
00144 c->clear_blocks = clear_blocks_mmi;
00145
00146 c->put_pixels_tab[1][0] = put_pixels8_mmi;
00147 c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
00148
00149 c->put_pixels_tab[0][0] = put_pixels16_mmi;
00150 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
00151
00152 c->get_pixels = get_pixels_mmi;
00153 }
00154
00155 if (avctx->bits_per_raw_sample <= 8 &&
00156 (idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_MMI)) {
00157 c->idct_put= ff_mmi_idct_put;
00158 c->idct_add= ff_mmi_idct_add;
00159 c->idct = ff_mmi_idct;
00160 c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
00161 }
00162 }