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