105 #undef PROFILE_THE_BEAST
108 typedef unsigned char ubyte;
109 typedef signed char sbyte;
147 static const vector
unsigned char
148 perm_rgb_0 = { 0x00, 0x01, 0x10, 0x02, 0x03, 0x11, 0x04, 0x05,
149 0x12, 0x06, 0x07, 0x13, 0x08, 0x09, 0x14, 0x0a },
150 perm_rgb_1 = { 0x0b, 0x15, 0x0c, 0x0d, 0x16, 0x0e, 0x0f, 0x17,
151 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
152 perm_rgb_2 = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
153 0x00, 0x01, 0x18, 0x02, 0x03, 0x19, 0x04, 0x05 },
154 perm_rgb_3 = { 0x1a, 0x06, 0x07, 0x1b, 0x08, 0x09, 0x1c, 0x0a,
155 0x0b, 0x1d, 0x0c, 0x0d, 0x1e, 0x0e, 0x0f, 0x1f };
157 #define vec_merge3(x2, x1, x0, y0, y1, y2) \
159 __typeof__(x0) o0, o2, o3; \
160 o0 = vec_mergeh(x0, x1); \
161 y0 = vec_perm(o0, x2, perm_rgb_0); \
162 o2 = vec_perm(o0, x2, perm_rgb_1); \
163 o3 = vec_mergel(x0, x1); \
164 y1 = vec_perm(o3, o2, perm_rgb_2); \
165 y2 = vec_perm(o3, o2, perm_rgb_3); \
168 #define vec_mstbgr24(x0, x1, x2, ptr) \
170 __typeof__(x0) _0, _1, _2; \
171 vec_merge3(x0, x1, x2, _0, _1, _2); \
172 vec_st(_0, 0, ptr++); \
173 vec_st(_1, 0, ptr++); \
174 vec_st(_2, 0, ptr++); \
177 #define vec_mstrgb24(x0, x1, x2, ptr) \
179 __typeof__(x0) _0, _1, _2; \
180 vec_merge3(x2, x1, x0, _0, _1, _2); \
181 vec_st(_0, 0, ptr++); \
182 vec_st(_1, 0, ptr++); \
183 vec_st(_2, 0, ptr++); \
190 #define vec_mstrgb32(T, x0, x1, x2, x3, ptr) \
193 _0 = vec_mergeh(x0, x1); \
194 _1 = vec_mergeh(x2, x3); \
195 _2 = (T) vec_mergeh((vector unsigned short) _0, \
196 (vector unsigned short) _1); \
197 _3 = (T) vec_mergel((vector unsigned short) _0, \
198 (vector unsigned short) _1); \
199 vec_st(_2, 0 * 16, (T *) ptr); \
200 vec_st(_3, 1 * 16, (T *) ptr); \
201 _0 = vec_mergel(x0, x1); \
202 _1 = vec_mergel(x2, x3); \
203 _2 = (T) vec_mergeh((vector unsigned short) _0, \
204 (vector unsigned short) _1); \
205 _3 = (T) vec_mergel((vector unsigned short) _0, \
206 (vector unsigned short) _1); \
207 vec_st(_2, 2 * 16, (T *) ptr); \
208 vec_st(_3, 3 * 16, (T *) ptr); \
227 (vector signed short) \
228 vec_perm(x, (__typeof__(x)) { 0 }, \
229 ((vector unsigned char) { \
230 0x10, 0x00, 0x10, 0x01, 0x10, 0x02, 0x10, 0x03, \
231 0x10, 0x04, 0x10, 0x05, 0x10, 0x06, 0x10, 0x07 }))
234 (vector signed short) \
235 vec_perm(x, (__typeof__(x)) { 0 }, \
236 ((vector unsigned char) { \
237 0x10, 0x08, 0x10, 0x09, 0x10, 0x0A, 0x10, 0x0B, \
238 0x10, 0x0C, 0x10, 0x0D, 0x10, 0x0E, 0x10, 0x0F }))
240 #define vec_unh(x)(vector signed short) vec_mergeh(x,(__typeof__(x)) { 0 })
241 #define vec_unl(x)(vector signed short) vec_mergel(x,(__typeof__(x)) { 0 })
244 #define vec_clip_s16(x) \
245 vec_max(vec_min(x, ((vector signed short) { \
246 235, 235, 235, 235, 235, 235, 235, 235 })), \
247 ((vector signed short) { 16, 16, 16, 16, 16, 16, 16, 16 }))
249 #define vec_packclp(x, y) \
250 (vector unsigned char) \
251 vec_packs((vector unsigned short) \
252 vec_max(x, ((vector signed short) { 0 })), \
253 (vector unsigned short) \
254 vec_max(y, ((vector signed short) { 0 })))
256 static inline void cvtyuvtoRGB(
SwsContext *
c, vector
signed short Y,
257 vector
signed short U, vector
signed short V,
258 vector
signed short *
R, vector
signed short *
G,
259 vector
signed short *
B)
261 vector
signed short vx, ux, uvx;
263 Y = vec_mradds(Y, c->CY, c->OY);
264 U = vec_sub(U, (vector
signed short)
265 vec_splat((vector
signed short) { 128 }, 0));
266 V = vec_sub(V, (vector
signed short)
267 vec_splat((vector
signed short) { 128 }, 0));
270 ux = vec_sl(U, c->CSHIFT);
271 *B = vec_mradds(ux, c->CBU, Y);
274 vx = vec_sl(V, c->CSHIFT);
275 *R = vec_mradds(vx, c->CRV, Y);
278 uvx = vec_mradds(U, c->CGU, Y);
279 *G = vec_mradds(V, c->CGV, uvx);
288 #define DEFCSP420_CVT(name, out_pixels) \
289 static int altivec_ ## name(SwsContext *c, const unsigned char **in, \
290 int *instrides, int srcSliceY, int srcSliceH, \
291 unsigned char **oplanes, int *outstrides) \
296 int instrides_scl[3]; \
297 vector unsigned char y0, y1; \
299 vector signed char u, v; \
301 vector signed short Y0, Y1, Y2, Y3; \
302 vector signed short U, V; \
303 vector signed short vx, ux, uvx; \
304 vector signed short vx0, ux0, uvx0; \
305 vector signed short vx1, ux1, uvx1; \
306 vector signed short R0, G0, B0; \
307 vector signed short R1, G1, B1; \
308 vector unsigned char R, G, B; \
310 const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP; \
311 vector unsigned char align_perm; \
313 vector signed short lCY = c->CY; \
314 vector signed short lOY = c->OY; \
315 vector signed short lCRV = c->CRV; \
316 vector signed short lCBU = c->CBU; \
317 vector signed short lCGU = c->CGU; \
318 vector signed short lCGV = c->CGV; \
319 vector unsigned short lCSHIFT = c->CSHIFT; \
321 const ubyte *y1i = in[0]; \
322 const ubyte *y2i = in[0] + instrides[0]; \
323 const ubyte *ui = in[1]; \
324 const ubyte *vi = in[2]; \
326 vector unsigned char *oute, *outo; \
329 instrides_scl[0] = instrides[0] * 2 - w; \
331 instrides_scl[1] = instrides[1] - w / 2; \
333 instrides_scl[2] = instrides[2] - w / 2; \
335 for (i = 0; i < h / 2; i++) { \
336 oute = (vector unsigned char *)(oplanes[0] + outstrides[0] * \
337 (srcSliceY + i * 2)); \
338 outo = oute + (outstrides[0] >> 4); \
339 vec_dstst(outo, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 0); \
340 vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1); \
342 for (j = 0; j < w / 16; j++) { \
343 y1ivP = (const vector unsigned char *) y1i; \
344 y2ivP = (const vector unsigned char *) y2i; \
345 uivP = (const vector unsigned char *) ui; \
346 vivP = (const vector unsigned char *) vi; \
348 align_perm = vec_lvsl(0, y1i); \
349 y0 = (vector unsigned char) \
350 vec_perm(y1ivP[0], y1ivP[1], align_perm); \
352 align_perm = vec_lvsl(0, y2i); \
353 y1 = (vector unsigned char) \
354 vec_perm(y2ivP[0], y2ivP[1], align_perm); \
356 align_perm = vec_lvsl(0, ui); \
357 u = (vector signed char) \
358 vec_perm(uivP[0], uivP[1], align_perm); \
360 align_perm = vec_lvsl(0, vi); \
361 v = (vector signed char) \
362 vec_perm(vivP[0], vivP[1], align_perm); \
364 u = (vector signed char) \
366 (vector signed char) \
367 vec_splat((vector signed char) { 128 }, 0)); \
368 v = (vector signed char) \
370 (vector signed char) \
371 vec_splat((vector signed char) { 128 }, 0)); \
373 U = vec_unpackh(u); \
374 V = vec_unpackh(v); \
381 Y0 = vec_mradds(Y0, lCY, lOY); \
382 Y1 = vec_mradds(Y1, lCY, lOY); \
383 Y2 = vec_mradds(Y2, lCY, lOY); \
384 Y3 = vec_mradds(Y3, lCY, lOY); \
387 ux = vec_sl(U, lCSHIFT); \
388 ux = vec_mradds(ux, lCBU, (vector signed short) { 0 }); \
389 ux0 = vec_mergeh(ux, ux); \
390 ux1 = vec_mergel(ux, ux); \
393 vx = vec_sl(V, lCSHIFT); \
394 vx = vec_mradds(vx, lCRV, (vector signed short) { 0 }); \
395 vx0 = vec_mergeh(vx, vx); \
396 vx1 = vec_mergel(vx, vx); \
399 uvx = vec_mradds(U, lCGU, (vector signed short) { 0 }); \
400 uvx = vec_mradds(V, lCGV, uvx); \
401 uvx0 = vec_mergeh(uvx, uvx); \
402 uvx1 = vec_mergel(uvx, uvx); \
404 R0 = vec_add(Y0, vx0); \
405 G0 = vec_add(Y0, uvx0); \
406 B0 = vec_add(Y0, ux0); \
407 R1 = vec_add(Y1, vx1); \
408 G1 = vec_add(Y1, uvx1); \
409 B1 = vec_add(Y1, ux1); \
411 R = vec_packclp(R0, R1); \
412 G = vec_packclp(G0, G1); \
413 B = vec_packclp(B0, B1); \
415 out_pixels(R, G, B, oute); \
417 R0 = vec_add(Y2, vx0); \
418 G0 = vec_add(Y2, uvx0); \
419 B0 = vec_add(Y2, ux0); \
420 R1 = vec_add(Y3, vx1); \
421 G1 = vec_add(Y3, uvx1); \
422 B1 = vec_add(Y3, ux1); \
423 R = vec_packclp(R0, R1); \
424 G = vec_packclp(G0, G1); \
425 B = vec_packclp(B0, B1); \
428 out_pixels(R, G, B, outo); \
436 ui += instrides_scl[1]; \
437 vi += instrides_scl[2]; \
438 y1i += instrides_scl[0]; \
439 y2i += instrides_scl[0]; \
444 #define out_abgr(a, b, c, ptr) \
445 vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), c, b, a, ptr)
446 #define out_bgra(a, b, c, ptr) \
447 vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255 }), ptr)
448 #define out_rgba(a, b, c, ptr) \
449 vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255 }), ptr)
450 #define out_argb(a, b, c, ptr) \
451 vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, b, c, ptr)
452 #define out_rgb24(a, b, c, ptr) vec_mstrgb24(a, b, c, ptr)
453 #define out_bgr24(a, b, c, ptr) vec_mstbgr24(a, b, c, ptr)
455 DEFCSP420_CVT(yuv2_abgr, out_abgr)
456 DEFCSP420_CVT(yuv2_bgra, out_bgra)
457 DEFCSP420_CVT(yuv2_rgba, out_rgba)
458 DEFCSP420_CVT(yuv2_argb, out_argb)
459 DEFCSP420_CVT(yuv2_rgb24, out_rgb24)
460 DEFCSP420_CVT(yuv2_bgr24, out_bgr24)
464 static const vector
unsigned char
465 demux_u = { 0x10, 0x00, 0x10, 0x00,
466 0x10, 0x04, 0x10, 0x04,
467 0x10, 0x08, 0x10, 0x08,
468 0x10, 0x0c, 0x10, 0x0c },
469 demux_v = { 0x10, 0x02, 0x10, 0x02,
470 0x10, 0x06, 0x10, 0x06,
471 0x10, 0x0A, 0x10, 0x0A,
472 0x10, 0x0E, 0x10, 0x0E },
473 demux_y = { 0x10, 0x01, 0x10, 0x03,
474 0x10, 0x05, 0x10, 0x07,
475 0x10, 0x09, 0x10, 0x0B,
476 0x10, 0x0D, 0x10, 0x0F };
481 static int altivec_uyvy_rgb32(
SwsContext *c,
const unsigned char **
in,
482 int *instrides,
int srcSliceY,
int srcSliceH,
483 unsigned char **oplanes,
int *outstrides)
488 vector
unsigned char uyvy;
489 vector
signed short Y,
U,
V;
490 vector
signed short R0, G0,
B0,
R1, G1,
B1;
491 vector
unsigned char R,
G,
B;
492 vector
unsigned char *
out;
496 out = (vector
unsigned char *) (oplanes[0] + srcSliceY * outstrides[0]);
498 for (i = 0; i <
h; i++)
499 for (j = 0; j < w / 16; j++) {
500 uyvy = vec_ld(0, img);
502 U = (vector
signed short)
503 vec_perm(uyvy, (vector
unsigned char) { 0 }, demux_u);
504 V = (vector
signed short)
505 vec_perm(uyvy, (vector
unsigned char) { 0 }, demux_v);
506 Y = (vector
signed short)
507 vec_perm(uyvy, (vector
unsigned char) { 0 }, demux_y);
509 cvtyuvtoRGB(c, Y, U, V, &R0, &G0, &B0);
511 uyvy = vec_ld(16, img);
513 U = (vector
signed short)
514 vec_perm(uyvy, (vector
unsigned char) { 0 }, demux_u);
515 V = (vector
signed short)
516 vec_perm(uyvy, (vector
unsigned char) { 0 }, demux_v);
517 Y = (vector
signed short)
518 vec_perm(uyvy, (vector
unsigned char) { 0 }, demux_y);
520 cvtyuvtoRGB(c, Y, U, V, &R1, &G1, &B1);
522 R = vec_packclp(R0, R1);
523 G = vec_packclp(G0, G1);
524 B = vec_packclp(B0, B1);
527 out_rgba(R, G, B, out);
555 if ((c->
srcW & 0xf) != 0)
565 if ((c->
srcH & 0x1) != 0)
571 return altivec_yuv2_rgb24;
574 return altivec_yuv2_bgr24;
577 return altivec_yuv2_argb;
580 return altivec_yuv2_abgr;
583 return altivec_yuv2_rgba;
586 return altivec_yuv2_bgra;
587 default:
return NULL;
595 return altivec_uyvy_rgb32;
596 default:
return NULL;
606 const int inv_table[4],
614 vector
signed short vec;
620 buf.tmp[0] = ((0xffffLL) * contrast >> 8) >> 9;
621 buf.tmp[1] = -256 * brightness;
622 buf.tmp[2] = (inv_table[0] >> 3) * (contrast >> 16) * (saturation >> 16);
623 buf.tmp[3] = (inv_table[1] >> 3) * (contrast >> 16) * (saturation >> 16);
624 buf.tmp[4] = -((inv_table[2] >> 1) * (contrast >> 16) * (saturation >> 16));
625 buf.tmp[5] = -((inv_table[3] >> 1) * (contrast >> 16) * (saturation >> 16));
627 c->CSHIFT = (vector
unsigned short) vec_splat_u16(2);
628 c->CY = vec_splat((vector
signed short)
buf.vec, 0);
629 c->OY = vec_splat((vector
signed short)
buf.vec, 1);
630 c->CRV = vec_splat((vector
signed short)
buf.vec, 2);
631 c->CBU = vec_splat((vector
signed short)
buf.vec, 3);
632 c->CGU = vec_splat((vector
signed short)
buf.vec, 4);
633 c->CGV = vec_splat((vector
signed short)
buf.vec, 5);
641 const int16_t *lumFilter,
642 const int16_t **lumSrc,
644 const int16_t *chrFilter,
645 const int16_t **chrUSrc,
646 const int16_t **chrVSrc,
648 const int16_t **alpSrc,
654 vector
signed short X, X0, X1, Y0, U0, V0, Y1, U1, V1,
U,
V;
655 vector
signed short R0, G0,
B0,
R1, G1,
B1;
657 vector
unsigned char R,
G,
B;
658 vector
unsigned char *
out, *nout;
660 vector
signed short RND = vec_splat_s16(1 << 3);
661 vector
unsigned short SCL = vec_splat_u16(4);
664 vector
signed short *YCoeffs, *CCoeffs;
666 YCoeffs = c->vYCoeffsBank + dstY * lumFilterSize;
667 CCoeffs = c->vCCoeffsBank + dstY * chrFilterSize;
669 out = (vector
unsigned char *) dest;
671 for (i = 0; i < dstW; i += 16) {
675 for (j = 0; j < lumFilterSize; j++) {
676 X0 = vec_ld(0, &lumSrc[j][i]);
677 X1 = vec_ld(16, &lumSrc[j][i]);
678 Y0 = vec_mradds(X0, YCoeffs[j], Y0);
679 Y1 = vec_mradds(X1, YCoeffs[j], Y1);
685 for (j = 0; j < chrFilterSize; j++) {
686 X = vec_ld(0, &chrUSrc[j][i / 2]);
687 U = vec_mradds(X, CCoeffs[j], U);
688 X = vec_ld(0, &chrVSrc[j][i / 2]);
689 V = vec_mradds(X, CCoeffs[j], V);
693 Y0 = vec_sra(Y0, SCL);
694 Y1 = vec_sra(Y1, SCL);
698 Y0 = vec_clip_s16(Y0);
699 Y1 = vec_clip_s16(Y1);
712 U0 = vec_mergeh(U, U);
713 V0 = vec_mergeh(V, V);
715 U1 = vec_mergel(U, U);
716 V1 = vec_mergel(V, V);
718 cvtyuvtoRGB(c, Y0, U0, V0, &R0, &G0, &B0);
719 cvtyuvtoRGB(c, Y1, U1, V1, &R1, &G1, &B1);
721 R = vec_packclp(R0, R1);
722 G = vec_packclp(G0, G1);
723 B = vec_packclp(B0, B1);
727 out_abgr(R, G, B, out);
730 out_bgra(R, G, B, out);
733 out_rgba(R, G, B, out);
736 out_argb(R, G, B, out);
739 out_rgb24(R, G, B, out);
742 out_bgr24(R, G, B, out);
748 static int printed_error_message;
749 if (!printed_error_message) {
751 "altivec_yuv2packedX doesn't support %s output\n",
753 printed_error_message = 1;
766 for (j = 0; j < lumFilterSize; j++) {
767 X0 = vec_ld(0, &lumSrc[j][i]);
768 X1 = vec_ld(16, &lumSrc[j][i]);
769 Y0 = vec_mradds(X0, YCoeffs[j], Y0);
770 Y1 = vec_mradds(X1, YCoeffs[j], Y1);
776 for (j = 0; j < chrFilterSize; j++) {
777 X = vec_ld(0, &chrUSrc[j][i / 2]);
778 U = vec_mradds(X, CCoeffs[j], U);
779 X = vec_ld(0, &chrVSrc[j][i / 2]);
780 V = vec_mradds(X, CCoeffs[j], V);
784 Y0 = vec_sra(Y0, SCL);
785 Y1 = vec_sra(Y1, SCL);
789 Y0 = vec_clip_s16(Y0);
790 Y1 = vec_clip_s16(Y1);
803 U0 = vec_mergeh(U, U);
804 V0 = vec_mergeh(V, V);
806 U1 = vec_mergel(U, U);
807 V1 = vec_mergel(V, V);
809 cvtyuvtoRGB(c, Y0, U0, V0, &R0, &G0, &B0);
810 cvtyuvtoRGB(c, Y1, U1, V1, &R1, &G1, &B1);
812 R = vec_packclp(R0, R1);
813 G = vec_packclp(G0, G1);
814 B = vec_packclp(B0, B1);
816 nout = (vector
unsigned char *) scratch;
819 out_abgr(R, G, B, nout);
822 out_bgra(R, G, B, nout);
825 out_rgba(R, G, B, nout);
828 out_argb(R, G, B, nout);
831 out_rgb24(R, G, B, nout);
834 out_bgr24(R, G, B, nout);
839 "altivec_yuv2packedX doesn't support %s output\n",
844 memcpy(&((uint32_t *) dest)[i], scratch, (dstW - i) / 4);
848 #define YUV2PACKEDX_WRAPPER(suffix, pixfmt) \
849 void ff_yuv2 ## suffix ## _X_altivec(SwsContext *c, \
850 const int16_t *lumFilter, \
851 const int16_t **lumSrc, \
853 const int16_t *chrFilter, \
854 const int16_t **chrUSrc, \
855 const int16_t **chrVSrc, \
857 const int16_t **alpSrc, \
858 uint8_t *dest, int dstW, int dstY) \
860 yuv2packedX_altivec(c, lumFilter, lumSrc, lumFilterSize, \
861 chrFilter, chrUSrc, chrVSrc, \
862 chrFilterSize, alpSrc, \
863 dest, dstW, dstY, pixfmt); \
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define AV_CPU_FLAG_ALTIVEC
standard
av_cold void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
#define DECLARE_ALIGNED(n, t, v)
Macro definitions for various function/variable attributes.
int srcH
Height of source luma/alpha planes.
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
enum AVPixelFormat dstFormat
Destination pixel format.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define R0(v, w, x, y, z, i)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
as above, but U and V bytes are swapped
packed RGB 8:8:8, 24bpp, BGRBGR...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
av_cold SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
enum AVPixelFormat srcFormat
Source pixel format.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int srcW
Width of source luma/alpha planes.
AVPixelFormat
Pixel format.