00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <inttypes.h>
00023 #include <stdlib.h>
00024
00025 #include "libswscale/swscale.h"
00026 #include "libswscale/swscale_internal.h"
00027
00028 #define YUV2RGB_INIT \
00029 "wr %%g0, 0x10, %%gsr \n\t" \
00030 "ldd [%5], %%f32 \n\t" \
00031 "ldd [%5 + 8], %%f34 \n\t" \
00032 "ldd [%5 + 16], %%f36 \n\t" \
00033 "ldd [%5 + 24], %%f38 \n\t" \
00034 "ldd [%5 + 32], %%f40 \n\t" \
00035 "ldd [%5 + 40], %%f42 \n\t" \
00036 "ldd [%5 + 48], %%f44 \n\t" \
00037 "ldd [%5 + 56], %%f46 \n\t" \
00038 "ldd [%5 + 64], %%f48 \n\t" \
00039 "ldd [%5 + 72], %%f50 \n\t"
00040
00041 #define YUV2RGB_KERNEL \
00042 \
00043 "fmul8x16 %%f3, %%f48, %%f6 \n\t" \
00044 "fmul8x16 %%f19, %%f48, %%f22 \n\t" \
00045 "fmul8x16 %%f5, %%f44, %%f8 \n\t" \
00046 "fmul8x16 %%f21, %%f44, %%f24 \n\t" \
00047 "fmul8x16 %%f0, %%f42, %%f0 \n\t" \
00048 "fmul8x16 %%f16, %%f42, %%f16 \n\t" \
00049 "fmul8x16 %%f3, %%f50, %%f2 \n\t" \
00050 "fmul8x16 %%f19, %%f50, %%f18 \n\t" \
00051 "fmul8x16 %%f5, %%f46, %%f4 \n\t" \
00052 "fmul8x16 %%f21, %%f46, %%f20 \n\t" \
00053 \
00054 "fpsub16 %%f6, %%f34, %%f6 \n\t" \
00055 "fpsub16 %%f22, %%f34, %%f22 \n\t" \
00056 "fpsub16 %%f8, %%f38, %%f8 \n\t" \
00057 "fpsub16 %%f24, %%f38, %%f24 \n\t" \
00058 "fpsub16 %%f0, %%f32, %%f0 \n\t" \
00059 "fpsub16 %%f16, %%f32, %%f16 \n\t" \
00060 "fpsub16 %%f2, %%f36, %%f2 \n\t" \
00061 "fpsub16 %%f18, %%f36, %%f18 \n\t" \
00062 "fpsub16 %%f4, %%f40, %%f4 \n\t" \
00063 "fpsub16 %%f20, %%f40, %%f20 \n\t" \
00064 \
00065 "fpadd16 %%f0, %%f8, %%f8 \n\t" \
00066 "fpadd16 %%f16, %%f24, %%f24 \n\t" \
00067 "fpadd16 %%f0, %%f4, %%f4 \n\t" \
00068 "fpadd16 %%f16, %%f20, %%f20 \n\t" \
00069 "fpadd16 %%f0, %%f6, %%f6 \n\t" \
00070 "fpadd16 %%f16, %%f22, %%f22 \n\t" \
00071 "fpadd16 %%f8, %%f2, %%f2 \n\t" \
00072 "fpadd16 %%f24, %%f18, %%f18 \n\t" \
00073 \
00074 "fpack16 %%f4, %%f4 \n\t" \
00075 "fpack16 %%f20, %%f20 \n\t" \
00076 "fpack16 %%f6, %%f6 \n\t" \
00077 "fpack16 %%f22, %%f22 \n\t" \
00078 "fpack16 %%f2, %%f2 \n\t" \
00079 "fpack16 %%f18, %%f18 \n\t"
00080
00081
00082 static int vis_420P_ARGB32(SwsContext *c, uint8_t *src[], int srcStride[],
00083 int srcSliceY, int srcSliceH,
00084 uint8_t *dst[], int dstStride[])
00085 {
00086 int y, out1, out2, out3, out4, out5, out6;
00087
00088 for (y = 0; y < srcSliceH; ++y)
00089 __asm__ volatile (
00090 YUV2RGB_INIT
00091 "wr %%g0, 0xd2, %%asi \n\t"
00092 "1: \n\t"
00093 "ldda [%1] %%asi, %%f2 \n\t"
00094 "ldda [%1 + 2] %%asi, %%f18 \n\t"
00095 "ldda [%2] %%asi, %%f4 \n\t"
00096 "ldda [%2 + 2] %%asi, %%f20 \n\t"
00097 "ld [%0], %%f0 \n\t"
00098 "ld [%0+4], %%f16 \n\t"
00099 "fpmerge %%f3, %%f3, %%f2 \n\t"
00100 "fpmerge %%f19, %%f19, %%f18 \n\t"
00101 "fpmerge %%f5, %%f5, %%f4 \n\t"
00102 "fpmerge %%f21, %%f21, %%f20 \n\t"
00103 YUV2RGB_KERNEL
00104 "fzero %%f0 \n\t"
00105 "fpmerge %%f4, %%f6, %%f8 \n\t"
00106 "fpmerge %%f20, %%f22, %%f24 \n\t"
00107 "fpmerge %%f0, %%f2, %%f10 \n\t"
00108 "fpmerge %%f0, %%f18, %%f26 \n\t"
00109 "fpmerge %%f10, %%f8, %%f4 \n\t"
00110 "fpmerge %%f26, %%f24, %%f20 \n\t"
00111 "fpmerge %%f11, %%f9, %%f6 \n\t"
00112 "fpmerge %%f27, %%f25, %%f22 \n\t"
00113 "std %%f4, [%3] \n\t"
00114 "std %%f20, [%3 + 16] \n\t"
00115 "std %%f6, [%3 + 8] \n\t"
00116 "std %%f22, [%3 + 24] \n\t"
00117
00118 "add %0, 8, %0 \n\t"
00119 "add %1, 4, %1 \n\t"
00120 "add %2, 4, %2 \n\t"
00121 "subcc %4, 8, %4 \n\t"
00122 "bne 1b \n\t"
00123 "add %3, 32, %3 \n\t"
00124 : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5), "=r" (out6)
00125 : "0" (src[0] + (y + srcSliceY) * srcStride[0]), "1" (src[1] + ((y + srcSliceY) >> 1) * srcStride[1]),
00126 "2" (src[2] + ((y + srcSliceY) >> 1) * srcStride[2]), "3" (dst[0] + (y + srcSliceY) * dstStride[0]),
00127 "4" (c->dstW),
00128 "5" (c->sparc_coeffs)
00129 );
00130
00131 return srcSliceH;
00132 }
00133
00134
00135 static int vis_422P_ARGB32(SwsContext *c, uint8_t *src[], int srcStride[],
00136 int srcSliceY, int srcSliceH,
00137 uint8_t *dst[], int dstStride[])
00138 {
00139 int y, out1, out2, out3, out4, out5, out6;
00140
00141 for (y = 0; y < srcSliceH; ++y)
00142 __asm__ volatile (
00143 YUV2RGB_INIT
00144 "wr %%g0, 0xd2, %%asi \n\t"
00145 "1: \n\t"
00146 "ldda [%1] %%asi, %%f2 \n\t"
00147 "ldda [%1 + 2] %%asi, %%f18 \n\t"
00148 "ldda [%2] %%asi, %%f4 \n\t"
00149 "ldda [%2 + 2] %%asi, %%f20 \n\t"
00150 "ld [%0], %%f0 \n\t"
00151 "ld [%0 + 4], %%f16 \n\t"
00152 "fpmerge %%f3, %%f3, %%f2 \n\t"
00153 "fpmerge %%f19, %%f19, %%f18 \n\t"
00154 "fpmerge %%f5, %%f5, %%f4 \n\t"
00155 "fpmerge %%f21, %%f21, %%f20 \n\t"
00156 YUV2RGB_KERNEL
00157 "fzero %%f0 \n\t"
00158 "fpmerge %%f4, %%f6, %%f8 \n\t"
00159 "fpmerge %%f20, %%f22, %%f24 \n\t"
00160 "fpmerge %%f0, %%f2, %%f10 \n\t"
00161 "fpmerge %%f0, %%f18, %%f26 \n\t"
00162 "fpmerge %%f10, %%f8, %%f4 \n\t"
00163 "fpmerge %%f26, %%f24, %%f20 \n\t"
00164 "fpmerge %%f11, %%f9, %%f6 \n\t"
00165 "fpmerge %%f27, %%f25, %%f22 \n\t"
00166 "std %%f4, [%3] \n\t"
00167 "std %%f20, [%3 + 16] \n\t"
00168 "std %%f6, [%3 + 8] \n\t"
00169 "std %%f22, [%3 + 24] \n\t"
00170
00171 "add %0, 8, %0 \n\t"
00172 "add %1, 4, %1 \n\t"
00173 "add %2, 4, %2 \n\t"
00174 "subcc %4, 8, %4 \n\t"
00175 "bne 1b \n\t"
00176 "add %3, 32, %3 \n\t"
00177 : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5), "=r" (out6)
00178 : "0" (src[0] + (y + srcSliceY) * srcStride[0]), "1" (src[1] + (y + srcSliceY) * srcStride[1]),
00179 "2" (src[2] + (y + srcSliceY) * srcStride[2]), "3" (dst[0] + (y + srcSliceY) * dstStride[0]),
00180 "4" (c->dstW),
00181 "5" (c->sparc_coeffs)
00182 );
00183
00184 return srcSliceH;
00185 }
00186
00187 SwsFunc ff_yuv2rgb_init_vis(SwsContext *c)
00188 {
00189 c->sparc_coeffs[5] = c->yCoeff;
00190 c->sparc_coeffs[6] = c->vgCoeff;
00191 c->sparc_coeffs[7] = c->vrCoeff;
00192 c->sparc_coeffs[8] = c->ubCoeff;
00193 c->sparc_coeffs[9] = c->ugCoeff;
00194
00195 c->sparc_coeffs[0] = (((int16_t)c->yOffset * (int16_t)c->yCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
00196 c->sparc_coeffs[1] = (((int16_t)c->uOffset * (int16_t)c->ubCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
00197 c->sparc_coeffs[2] = (((int16_t)c->uOffset * (int16_t)c->ugCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
00198 c->sparc_coeffs[3] = (((int16_t)c->vOffset * (int16_t)c->vgCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
00199 c->sparc_coeffs[4] = (((int16_t)c->vOffset * (int16_t)c->vrCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
00200
00201 if (c->dstFormat == PIX_FMT_RGB32 && c->srcFormat == PIX_FMT_YUV422P && (c->dstW & 7) == 0) {
00202 av_log(c, AV_LOG_INFO,
00203 "SPARC VIS accelerated YUV422P -> RGB32 (WARNING: alpha value is wrong)\n");
00204 return vis_422P_ARGB32;
00205 } else if (c->dstFormat == PIX_FMT_RGB32 && c->srcFormat == PIX_FMT_YUV420P && (c->dstW & 7) == 0) {
00206 av_log(c, AV_LOG_INFO,
00207 "SPARC VIS accelerated YUV420P -> RGB32 (WARNING: alpha value is wrong)\n");
00208 return vis_420P_ARGB32;
00209 }
00210 return NULL;
00211 }