videomixerorc-dist.c 80.5 KB
Newer Older
1

2
/* autogenerated from videomixerorc.orc */
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>

#ifndef _ORC_INTEGER_TYPEDEFS_
#define _ORC_INTEGER_TYPEDEFS_
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <stdint.h>
typedef int8_t orc_int8;
typedef int16_t orc_int16;
typedef int32_t orc_int32;
typedef int64_t orc_int64;
typedef uint8_t orc_uint8;
typedef uint16_t orc_uint16;
typedef uint32_t orc_uint32;
typedef uint64_t orc_uint64;
David Schleef's avatar
David Schleef committed
21
#define ORC_UINT64_C(x) UINT64_C(x)
22 23 24 25 26 27 28 29 30
#elif defined(_MSC_VER)
typedef signed __int8 orc_int8;
typedef signed __int16 orc_int16;
typedef signed __int32 orc_int32;
typedef signed __int64 orc_int64;
typedef unsigned __int8 orc_uint8;
typedef unsigned __int16 orc_uint16;
typedef unsigned __int32 orc_uint32;
typedef unsigned __int64 orc_uint64;
David Schleef's avatar
David Schleef committed
31
#define ORC_UINT64_C(x) (x##Ui64)
32
#define inline __inline
33 34 35 36 37 38 39 40 41 42 43
#else
#include <limits.h>
typedef signed char orc_int8;
typedef short orc_int16;
typedef int orc_int32;
typedef unsigned char orc_uint8;
typedef unsigned short orc_uint16;
typedef unsigned int orc_uint32;
#if INT_MAX == LONG_MAX
typedef long long orc_int64;
typedef unsigned long long orc_uint64;
David Schleef's avatar
David Schleef committed
44
#define ORC_UINT64_C(x) (x##ULL)
45 46 47
#else
typedef long orc_int64;
typedef unsigned long orc_uint64;
David Schleef's avatar
David Schleef committed
48
#define ORC_UINT64_C(x) (x##UL)
49 50 51
#endif
#endif
typedef union
David Schleef's avatar
David Schleef committed
52 53 54 55 56
{
  orc_int16 i;
  orc_int8 x2[2];
} orc_union16;
typedef union
57 58 59
{
  orc_int32 i;
  float f;
David Schleef's avatar
David Schleef committed
60 61
  orc_int16 x2[2];
  orc_int8 x4[4];
62 63 64 65 66
} orc_union32;
typedef union
{
  orc_int64 i;
  double f;
David Schleef's avatar
David Schleef committed
67
  orc_int32 x2[2];
David Schleef's avatar
David Schleef committed
68
  float x2f[2];
David Schleef's avatar
David Schleef committed
69
  orc_int16 x4[4];
70 71
} orc_union64;
#endif
72 73 74 75 76 77 78 79 80
#ifndef ORC_RESTRICT
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define ORC_RESTRICT restrict
#elif defined(__GNUC__) && __GNUC__ >= 4
#define ORC_RESTRICT __restrict__
#else
#define ORC_RESTRICT
#endif
#endif
81

Sebastian Dröge's avatar
Sebastian Dröge committed
82 83 84 85 86 87 88 89 90 91 92 93 94
#ifndef ORC_INTERNAL
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
#define ORC_INTERNAL __attribute__((visibility("hidden")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#define ORC_INTERNAL __hidden
#elif defined (__GNUC__)
#define ORC_INTERNAL __attribute__((visibility("hidden")))
#else
#define ORC_INTERNAL
#endif
#endif


95 96 97
#ifndef DISABLE_ORC
#include <orc/orc.h>
#endif
98 99 100 101
void video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n);
void video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1,
    const guint32 * ORC_RESTRICT s1, int n);
void video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride,
102
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m);
103
void video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride,
104
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m);
105
void video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride,
106
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m);
107
void video_mixer_orc_overlay_argb (guint8 * ORC_RESTRICT d1, int d1_stride,
108
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m);
109
void video_mixer_orc_overlay_bgra (guint8 * ORC_RESTRICT d1, int d1_stride,
110
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m);
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135


/* begin Orc C target preamble */
#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))
#define ORC_ABS(a) ((a)<0 ? -(a) : (a))
#define ORC_MIN(a,b) ((a)<(b) ? (a) : (b))
#define ORC_MAX(a,b) ((a)>(b) ? (a) : (b))
#define ORC_SB_MAX 127
#define ORC_SB_MIN (-1-ORC_SB_MAX)
#define ORC_UB_MAX 255
#define ORC_UB_MIN 0
#define ORC_SW_MAX 32767
#define ORC_SW_MIN (-1-ORC_SW_MAX)
#define ORC_UW_MAX 65535
#define ORC_UW_MIN 0
#define ORC_SL_MAX 2147483647
#define ORC_SL_MIN (-1-ORC_SL_MAX)
#define ORC_UL_MAX 4294967295U
#define ORC_UL_MIN 0
#define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX)
#define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX)
#define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX)
#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)
#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)
#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)
Sebastian Dröge's avatar
Sebastian Dröge committed
136 137
#define ORC_SWAP_W(x) ((((x)&0xffU)<<8) | (((x)&0xff00U)>>8))
#define ORC_SWAP_L(x) ((((x)&0xffU)<<24) | (((x)&0xff00U)<<8) | (((x)&0xff0000U)>>8) | (((x)&0xff000000U)>>24))
David Schleef's avatar
David Schleef committed
138
#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56))
139
#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))
David Schleef's avatar
David Schleef committed
140 141
#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))
#define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))
David Schleef's avatar
David Schleef committed
142 143
#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff)))
#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0))
144
#ifndef ORC_RESTRICT
David Schleef's avatar
David Schleef committed
145 146 147 148 149 150 151
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define ORC_RESTRICT restrict
#elif defined(__GNUC__) && __GNUC__ >= 4
#define ORC_RESTRICT __restrict__
#else
#define ORC_RESTRICT
#endif
152
#endif
153 154 155 156
/* end Orc C target preamble */



157
/* video_mixer_orc_splat_u32 */
158 159
#ifdef DISABLE_ORC
void
160
video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n)
161 162
{
  int i;
David Schleef's avatar
David Schleef committed
163 164 165
  orc_union32 *ORC_RESTRICT ptr0;
  orc_union32 var32;
  orc_union32 var33;
166 167 168

  ptr0 = (orc_union32 *) d1;

David Schleef's avatar
David Schleef committed
169 170 171
  /* 0: loadpl */
  var32.i = p1;

172
  for (i = 0; i < n; i++) {
David Schleef's avatar
David Schleef committed
173 174 175 176
    /* 1: copyl */
    var33.i = var32.i;
    /* 2: storel */
    ptr0[i] = var33;
177 178 179 180 181 182
  }

}

#else
static void
183
_backup_video_mixer_orc_splat_u32 (OrcExecutor * ORC_RESTRICT ex)
184 185 186
{
  int i;
  int n = ex->n;
David Schleef's avatar
David Schleef committed
187 188 189
  orc_union32 *ORC_RESTRICT ptr0;
  orc_union32 var32;
  orc_union32 var33;
190 191 192

  ptr0 = (orc_union32 *) ex->arrays[0];

David Schleef's avatar
David Schleef committed
193 194 195
  /* 0: loadpl */
  var32.i = ex->params[24];

196
  for (i = 0; i < n; i++) {
David Schleef's avatar
David Schleef committed
197 198 199 200
    /* 1: copyl */
    var33.i = var32.i;
    /* 2: storel */
    ptr0[i] = var33;
201 202 203 204 205
  }

}

void
206
video_mixer_orc_splat_u32 (guint32 * ORC_RESTRICT d1, int p1, int n)
207 208
{
  OrcExecutor _ex, *ex = &_ex;
Sebastian Dröge's avatar
Sebastian Dröge committed
209
  static volatile int p_inited = 0;
210
  static OrcCode *c = 0;
211 212 213 214 215
  void (*func) (OrcExecutor *);

  if (!p_inited) {
    orc_once_mutex_lock ();
    if (!p_inited) {
216
      OrcProgram *p;
217

Sebastian Dröge's avatar
Sebastian Dröge committed
218 219 220 221 222 223 224 225 226
#if 1
      static const orc_uint8 bc[] = {
        1, 9, 25, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, 111,
        114, 99, 95, 115, 112, 108, 97, 116, 95, 117, 51, 50, 11, 4, 4, 16,
        4, 112, 0, 24, 2, 0,
      };
      p = orc_program_new_from_static_bytecode (bc);
      orc_program_set_backup_function (p, _backup_video_mixer_orc_splat_u32);
#else
227
      p = orc_program_new ();
228 229
      orc_program_set_name (p, "video_mixer_orc_splat_u32");
      orc_program_set_backup_function (p, _backup_video_mixer_orc_splat_u32);
230 231 232
      orc_program_add_destination (p, 4, "d1");
      orc_program_add_parameter (p, 4, "p1");

David Schleef's avatar
David Schleef committed
233 234
      orc_program_append_2 (p, "copyl", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1,
          ORC_VAR_D1);
Sebastian Dröge's avatar
Sebastian Dröge committed
235
#endif
236

237
      orc_program_compile (p);
238 239
      c = orc_program_take_code (p);
      orc_program_free (p);
240 241 242 243
    }
    p_inited = TRUE;
    orc_once_mutex_unlock ();
  }
244 245
  ex->arrays[ORC_VAR_A2] = c;
  ex->program = 0;
246 247 248 249 250

  ex->n = n;
  ex->arrays[ORC_VAR_D1] = d1;
  ex->params[ORC_VAR_P1] = p1;

251
  func = c->exec;
252 253 254 255 256
  func (ex);
}
#endif


257
/* video_mixer_orc_memcpy_u32 */
258 259
#ifdef DISABLE_ORC
void
260 261
video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1,
    const guint32 * ORC_RESTRICT s1, int n)
262 263
{
  int i;
David Schleef's avatar
David Schleef committed
264 265 266 267
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union32 var32;
  orc_union32 var33;
268 269 270 271

  ptr0 = (orc_union32 *) d1;
  ptr4 = (orc_union32 *) s1;

David Schleef's avatar
David Schleef committed
272

273
  for (i = 0; i < n; i++) {
David Schleef's avatar
David Schleef committed
274 275 276 277 278 279
    /* 0: loadl */
    var32 = ptr4[i];
    /* 1: copyl */
    var33.i = var32.i;
    /* 2: storel */
    ptr0[i] = var33;
280 281 282 283 284 285
  }

}

#else
static void
286
_backup_video_mixer_orc_memcpy_u32 (OrcExecutor * ORC_RESTRICT ex)
287 288 289
{
  int i;
  int n = ex->n;
David Schleef's avatar
David Schleef committed
290 291 292 293
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union32 var32;
  orc_union32 var33;
294 295 296 297

  ptr0 = (orc_union32 *) ex->arrays[0];
  ptr4 = (orc_union32 *) ex->arrays[4];

David Schleef's avatar
David Schleef committed
298

299
  for (i = 0; i < n; i++) {
David Schleef's avatar
David Schleef committed
300 301 302 303 304 305
    /* 0: loadl */
    var32 = ptr4[i];
    /* 1: copyl */
    var33.i = var32.i;
    /* 2: storel */
    ptr0[i] = var33;
306 307 308 309 310
  }

}

void
311 312
video_mixer_orc_memcpy_u32 (guint32 * ORC_RESTRICT d1,
    const guint32 * ORC_RESTRICT s1, int n)
313 314
{
  OrcExecutor _ex, *ex = &_ex;
Sebastian Dröge's avatar
Sebastian Dröge committed
315
  static volatile int p_inited = 0;
316
  static OrcCode *c = 0;
317 318 319 320 321
  void (*func) (OrcExecutor *);

  if (!p_inited) {
    orc_once_mutex_lock ();
    if (!p_inited) {
322
      OrcProgram *p;
323

Sebastian Dröge's avatar
Sebastian Dröge committed
324 325 326 327 328 329 330 331 332
#if 1
      static const orc_uint8 bc[] = {
        1, 9, 26, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95, 111,
        114, 99, 95, 109, 101, 109, 99, 112, 121, 95, 117, 51, 50, 11, 4, 4,
        12, 4, 4, 112, 0, 4, 2, 0,
      };
      p = orc_program_new_from_static_bytecode (bc);
      orc_program_set_backup_function (p, _backup_video_mixer_orc_memcpy_u32);
#else
333
      p = orc_program_new ();
334 335
      orc_program_set_name (p, "video_mixer_orc_memcpy_u32");
      orc_program_set_backup_function (p, _backup_video_mixer_orc_memcpy_u32);
336 337 338
      orc_program_add_destination (p, 4, "d1");
      orc_program_add_source (p, 4, "s1");

David Schleef's avatar
David Schleef committed
339 340
      orc_program_append_2 (p, "copyl", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1,
          ORC_VAR_D1);
Sebastian Dröge's avatar
Sebastian Dröge committed
341
#endif
342

343
      orc_program_compile (p);
344 345
      c = orc_program_take_code (p);
      orc_program_free (p);
346 347 348 349
    }
    p_inited = TRUE;
    orc_once_mutex_unlock ();
  }
350 351
  ex->arrays[ORC_VAR_A2] = c;
  ex->program = 0;
352 353 354 355 356

  ex->n = n;
  ex->arrays[ORC_VAR_D1] = d1;
  ex->arrays[ORC_VAR_S1] = (void *) s1;

357
  func = c->exec;
358 359 360 361 362
  func (ex);
}
#endif


363
/* video_mixer_orc_blend_u8 */
364 365
#ifdef DISABLE_ORC
void
366
video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride,
367
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
368 369 370
{
  int i;
  int j;
David Schleef's avatar
David Schleef committed
371 372 373 374 375 376 377 378 379 380 381 382 383
  orc_int8 *ORC_RESTRICT ptr0;
  const orc_int8 *ORC_RESTRICT ptr4;
  orc_int8 var34;
  orc_int8 var35;
  orc_union16 var36;
  orc_int8 var37;
  orc_union16 var38;
  orc_union16 var39;
  orc_union16 var40;
  orc_union16 var41;
  orc_union16 var42;
  orc_union16 var43;
  orc_union16 var44;
384 385 386 387 388

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j);
    ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j);

David Schleef's avatar
David Schleef committed
389 390 391
    /* 5: loadpw */
    var36.i = p1;

392
    for (i = 0; i < n; i++) {
David Schleef's avatar
David Schleef committed
393 394
      /* 0: loadb */
      var34 = ptr0[i];
395
      /* 1: convubw */
David Schleef's avatar
David Schleef committed
396 397 398 399 400 401 402 403 404 405
      var38.i = (orc_uint8) var34;
      /* 2: loadb */
      var35 = ptr4[i];
      /* 3: convubw */
      var39.i = (orc_uint8) var35;
      /* 4: subw */
      var40.i = var39.i - var38.i;
      /* 6: mullw */
      var41.i = (var40.i * var36.i) & 0xffff;
      /* 7: shlw */
Sebastian Dröge's avatar
Sebastian Dröge committed
406
      var42.i = ((orc_uint16) var38.i) << 8;
David Schleef's avatar
David Schleef committed
407 408 409 410 411 412 413 414
      /* 8: addw */
      var43.i = var42.i + var41.i;
      /* 9: shruw */
      var44.i = ((orc_uint16) var43.i) >> 8;
      /* 10: convsuswb */
      var37 = ORC_CLAMP_UB (var44.i);
      /* 11: storeb */
      ptr0[i] = var37;
415 416 417 418 419 420 421
    }
  }

}

#else
static void
422
_backup_video_mixer_orc_blend_u8 (OrcExecutor * ORC_RESTRICT ex)
423 424 425 426 427
{
  int i;
  int j;
  int n = ex->n;
  int m = ex->params[ORC_VAR_A1];
David Schleef's avatar
David Schleef committed
428 429 430 431 432 433 434 435 436 437 438 439 440
  orc_int8 *ORC_RESTRICT ptr0;
  const orc_int8 *ORC_RESTRICT ptr4;
  orc_int8 var34;
  orc_int8 var35;
  orc_union16 var36;
  orc_int8 var37;
  orc_union16 var38;
  orc_union16 var39;
  orc_union16 var40;
  orc_union16 var41;
  orc_union16 var42;
  orc_union16 var43;
  orc_union16 var44;
441 442 443 444 445

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j);
    ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j);

David Schleef's avatar
David Schleef committed
446 447 448
    /* 5: loadpw */
    var36.i = ex->params[24];

449
    for (i = 0; i < n; i++) {
David Schleef's avatar
David Schleef committed
450 451
      /* 0: loadb */
      var34 = ptr0[i];
452
      /* 1: convubw */
David Schleef's avatar
David Schleef committed
453 454 455 456 457 458 459 460 461 462
      var38.i = (orc_uint8) var34;
      /* 2: loadb */
      var35 = ptr4[i];
      /* 3: convubw */
      var39.i = (orc_uint8) var35;
      /* 4: subw */
      var40.i = var39.i - var38.i;
      /* 6: mullw */
      var41.i = (var40.i * var36.i) & 0xffff;
      /* 7: shlw */
Sebastian Dröge's avatar
Sebastian Dröge committed
463
      var42.i = ((orc_uint16) var38.i) << 8;
David Schleef's avatar
David Schleef committed
464 465 466 467 468 469 470 471
      /* 8: addw */
      var43.i = var42.i + var41.i;
      /* 9: shruw */
      var44.i = ((orc_uint16) var43.i) >> 8;
      /* 10: convsuswb */
      var37 = ORC_CLAMP_UB (var44.i);
      /* 11: storeb */
      ptr0[i] = var37;
472 473 474 475 476 477
    }
  }

}

void
478
video_mixer_orc_blend_u8 (guint8 * ORC_RESTRICT d1, int d1_stride,
479
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
480 481
{
  OrcExecutor _ex, *ex = &_ex;
Sebastian Dröge's avatar
Sebastian Dröge committed
482
  static volatile int p_inited = 0;
483
  static OrcCode *c = 0;
484 485 486 487 488
  void (*func) (OrcExecutor *);

  if (!p_inited) {
    orc_once_mutex_lock ();
    if (!p_inited) {
489
      OrcProgram *p;
490

Sebastian Dröge's avatar
Sebastian Dröge committed
491 492 493 494 495 496 497 498 499 500 501
#if 1
      static const orc_uint8 bc[] = {
        1, 7, 9, 24, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95,
        111, 114, 99, 95, 98, 108, 101, 110, 100, 95, 117, 56, 11, 1, 1, 12,
        1, 1, 14, 1, 8, 0, 0, 0, 16, 2, 20, 2, 20, 2, 150, 32,
        0, 150, 33, 4, 98, 33, 33, 32, 89, 33, 33, 24, 93, 32, 32, 16,
        70, 33, 32, 33, 95, 33, 33, 16, 160, 0, 33, 2, 0,
      };
      p = orc_program_new_from_static_bytecode (bc);
      orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_u8);
#else
502 503
      p = orc_program_new ();
      orc_program_set_2d (p);
504 505
      orc_program_set_name (p, "video_mixer_orc_blend_u8");
      orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_u8);
506 507
      orc_program_add_destination (p, 1, "d1");
      orc_program_add_source (p, 1, "s1");
David Schleef's avatar
David Schleef committed
508
      orc_program_add_constant (p, 1, 0x00000008, "c1");
509 510 511 512
      orc_program_add_parameter (p, 2, "p1");
      orc_program_add_temporary (p, 2, "t1");
      orc_program_add_temporary (p, 2, "t2");

David Schleef's avatar
David Schleef committed
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
      orc_program_append_2 (p, "convubw", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 0, ORC_VAR_T2, ORC_VAR_S1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "subw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_T1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "mullw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_P1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "shlw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "addw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_T2,
          ORC_VAR_D1);
      orc_program_append_2 (p, "shruw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_C1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convsuswb", 0, ORC_VAR_D1, ORC_VAR_T2,
          ORC_VAR_D1, ORC_VAR_D1);
Sebastian Dröge's avatar
Sebastian Dröge committed
529
#endif
530

531
      orc_program_compile (p);
532 533
      c = orc_program_take_code (p);
      orc_program_free (p);
534 535 536 537
    }
    p_inited = TRUE;
    orc_once_mutex_unlock ();
  }
538 539
  ex->arrays[ORC_VAR_A2] = c;
  ex->program = 0;
540 541 542 543 544 545 546 547 548

  ex->n = n;
  ORC_EXECUTOR_M (ex) = m;
  ex->arrays[ORC_VAR_D1] = d1;
  ex->params[ORC_VAR_D1] = d1_stride;
  ex->arrays[ORC_VAR_S1] = (void *) s1;
  ex->params[ORC_VAR_S1] = s1_stride;
  ex->params[ORC_VAR_P1] = p1;

549
  func = c->exec;
550 551 552
  func (ex);
}
#endif
553 554


555
/* video_mixer_orc_blend_argb */
556 557
#ifdef DISABLE_ORC
void
558
video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride,
559
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
560 561 562 563 564 565
{
  int i;
  int j;
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union64 var39;
Sebastian Dröge's avatar
Sebastian Dröge committed
566 567 568
#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__)
  volatile orc_union32 var40;
#else
569
  orc_union32 var40;
Sebastian Dröge's avatar
Sebastian Dröge committed
570
#endif
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
  orc_union32 var41;
  orc_union16 var42;
  orc_int8 var43;
  orc_union32 var44;
  orc_union64 var45;
  orc_union64 var46;
  orc_union64 var47;
  orc_union64 var48;
  orc_union32 var49;
  orc_union64 var50;
  orc_union64 var51;
  orc_union64 var52;
  orc_union64 var53;
  orc_union64 var54;
  orc_union32 var55;
  orc_union32 var56;

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j);
    ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j);

David Schleef's avatar
David Schleef committed
592 593 594 595 596 597
    /* 5: loadpw */
    var39.x4[0] = p1;
    var39.x4[1] = p1;
    var39.x4[2] = p1;
    var39.x4[3] = p1;
    /* 16: loadpl */
598
    var40.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */
David Schleef's avatar
David Schleef committed
599

600 601 602 603 604 605 606 607 608
    for (i = 0; i < n; i++) {
      /* 0: loadl */
      var41 = ptr4[i];
      /* 1: convlw */
      var42.i = var41.i;
      /* 2: convwb */
      var43 = var42.i;
      /* 3: splatbl */
      var44.i =
Sebastian Dröge's avatar
Sebastian Dröge committed
609 610 611
          ((((orc_uint32) var43) & 0xff) << 24) | ((((orc_uint32) var43) & 0xff)
          << 16) | ((((orc_uint32) var43) & 0xff) << 8) | (((orc_uint32) var43)
          & 0xff);
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
      /* 4: convubw */
      var45.x4[0] = (orc_uint8) var44.x4[0];
      var45.x4[1] = (orc_uint8) var44.x4[1];
      var45.x4[2] = (orc_uint8) var44.x4[2];
      var45.x4[3] = (orc_uint8) var44.x4[3];
      /* 6: mullw */
      var46.x4[0] = (var45.x4[0] * var39.x4[0]) & 0xffff;
      var46.x4[1] = (var45.x4[1] * var39.x4[1]) & 0xffff;
      var46.x4[2] = (var45.x4[2] * var39.x4[2]) & 0xffff;
      var46.x4[3] = (var45.x4[3] * var39.x4[3]) & 0xffff;
      /* 7: shruw */
      var47.x4[0] = ((orc_uint16) var46.x4[0]) >> 8;
      var47.x4[1] = ((orc_uint16) var46.x4[1]) >> 8;
      var47.x4[2] = ((orc_uint16) var46.x4[2]) >> 8;
      var47.x4[3] = ((orc_uint16) var46.x4[3]) >> 8;
      /* 8: convubw */
      var48.x4[0] = (orc_uint8) var41.x4[0];
      var48.x4[1] = (orc_uint8) var41.x4[1];
      var48.x4[2] = (orc_uint8) var41.x4[2];
      var48.x4[3] = (orc_uint8) var41.x4[3];
      /* 9: loadl */
      var49 = ptr0[i];
      /* 10: convubw */
      var50.x4[0] = (orc_uint8) var49.x4[0];
      var50.x4[1] = (orc_uint8) var49.x4[1];
      var50.x4[2] = (orc_uint8) var49.x4[2];
      var50.x4[3] = (orc_uint8) var49.x4[3];
      /* 11: subw */
      var51.x4[0] = var48.x4[0] - var50.x4[0];
      var51.x4[1] = var48.x4[1] - var50.x4[1];
      var51.x4[2] = var48.x4[2] - var50.x4[2];
      var51.x4[3] = var48.x4[3] - var50.x4[3];
      /* 12: mullw */
      var52.x4[0] = (var51.x4[0] * var47.x4[0]) & 0xffff;
      var52.x4[1] = (var51.x4[1] * var47.x4[1]) & 0xffff;
      var52.x4[2] = (var51.x4[2] * var47.x4[2]) & 0xffff;
      var52.x4[3] = (var51.x4[3] * var47.x4[3]) & 0xffff;
      /* 13: div255w */
      var53.x4[0] =
651
          ((orc_uint16) (((orc_uint16) (var52.x4[0] + 128)) +
652 653
              (((orc_uint16) (var52.x4[0] + 128)) >> 8))) >> 8;
      var53.x4[1] =
654
          ((orc_uint16) (((orc_uint16) (var52.x4[1] + 128)) +
655 656
              (((orc_uint16) (var52.x4[1] + 128)) >> 8))) >> 8;
      var53.x4[2] =
657
          ((orc_uint16) (((orc_uint16) (var52.x4[2] + 128)) +
658 659
              (((orc_uint16) (var52.x4[2] + 128)) >> 8))) >> 8;
      var53.x4[3] =
660
          ((orc_uint16) (((orc_uint16) (var52.x4[3] + 128)) +
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
              (((orc_uint16) (var52.x4[3] + 128)) >> 8))) >> 8;
      /* 14: addw */
      var54.x4[0] = var50.x4[0] + var53.x4[0];
      var54.x4[1] = var50.x4[1] + var53.x4[1];
      var54.x4[2] = var50.x4[2] + var53.x4[2];
      var54.x4[3] = var50.x4[3] + var53.x4[3];
      /* 15: convwb */
      var55.x4[0] = var54.x4[0];
      var55.x4[1] = var54.x4[1];
      var55.x4[2] = var54.x4[2];
      var55.x4[3] = var54.x4[3];
      /* 17: orl */
      var56.i = var55.i | var40.i;
      /* 18: storel */
      ptr0[i] = var56;
    }
  }

}

#else
static void
683
_backup_video_mixer_orc_blend_argb (OrcExecutor * ORC_RESTRICT ex)
684 685 686 687 688 689 690 691
{
  int i;
  int j;
  int n = ex->n;
  int m = ex->params[ORC_VAR_A1];
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union64 var39;
Sebastian Dröge's avatar
Sebastian Dröge committed
692 693 694
#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__)
  volatile orc_union32 var40;
#else
695
  orc_union32 var40;
Sebastian Dröge's avatar
Sebastian Dröge committed
696
#endif
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
  orc_union32 var41;
  orc_union16 var42;
  orc_int8 var43;
  orc_union32 var44;
  orc_union64 var45;
  orc_union64 var46;
  orc_union64 var47;
  orc_union64 var48;
  orc_union32 var49;
  orc_union64 var50;
  orc_union64 var51;
  orc_union64 var52;
  orc_union64 var53;
  orc_union64 var54;
  orc_union32 var55;
  orc_union32 var56;

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j);
    ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j);

David Schleef's avatar
David Schleef committed
718 719 720 721 722 723
    /* 5: loadpw */
    var39.x4[0] = ex->params[24];
    var39.x4[1] = ex->params[24];
    var39.x4[2] = ex->params[24];
    var39.x4[3] = ex->params[24];
    /* 16: loadpl */
724
    var40.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */
David Schleef's avatar
David Schleef committed
725

726 727 728 729 730 731 732 733 734
    for (i = 0; i < n; i++) {
      /* 0: loadl */
      var41 = ptr4[i];
      /* 1: convlw */
      var42.i = var41.i;
      /* 2: convwb */
      var43 = var42.i;
      /* 3: splatbl */
      var44.i =
Sebastian Dröge's avatar
Sebastian Dröge committed
735 736 737
          ((((orc_uint32) var43) & 0xff) << 24) | ((((orc_uint32) var43) & 0xff)
          << 16) | ((((orc_uint32) var43) & 0xff) << 8) | (((orc_uint32) var43)
          & 0xff);
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
      /* 4: convubw */
      var45.x4[0] = (orc_uint8) var44.x4[0];
      var45.x4[1] = (orc_uint8) var44.x4[1];
      var45.x4[2] = (orc_uint8) var44.x4[2];
      var45.x4[3] = (orc_uint8) var44.x4[3];
      /* 6: mullw */
      var46.x4[0] = (var45.x4[0] * var39.x4[0]) & 0xffff;
      var46.x4[1] = (var45.x4[1] * var39.x4[1]) & 0xffff;
      var46.x4[2] = (var45.x4[2] * var39.x4[2]) & 0xffff;
      var46.x4[3] = (var45.x4[3] * var39.x4[3]) & 0xffff;
      /* 7: shruw */
      var47.x4[0] = ((orc_uint16) var46.x4[0]) >> 8;
      var47.x4[1] = ((orc_uint16) var46.x4[1]) >> 8;
      var47.x4[2] = ((orc_uint16) var46.x4[2]) >> 8;
      var47.x4[3] = ((orc_uint16) var46.x4[3]) >> 8;
      /* 8: convubw */
      var48.x4[0] = (orc_uint8) var41.x4[0];
      var48.x4[1] = (orc_uint8) var41.x4[1];
      var48.x4[2] = (orc_uint8) var41.x4[2];
      var48.x4[3] = (orc_uint8) var41.x4[3];
      /* 9: loadl */
      var49 = ptr0[i];
      /* 10: convubw */
      var50.x4[0] = (orc_uint8) var49.x4[0];
      var50.x4[1] = (orc_uint8) var49.x4[1];
      var50.x4[2] = (orc_uint8) var49.x4[2];
      var50.x4[3] = (orc_uint8) var49.x4[3];
      /* 11: subw */
      var51.x4[0] = var48.x4[0] - var50.x4[0];
      var51.x4[1] = var48.x4[1] - var50.x4[1];
      var51.x4[2] = var48.x4[2] - var50.x4[2];
      var51.x4[3] = var48.x4[3] - var50.x4[3];
      /* 12: mullw */
      var52.x4[0] = (var51.x4[0] * var47.x4[0]) & 0xffff;
      var52.x4[1] = (var51.x4[1] * var47.x4[1]) & 0xffff;
      var52.x4[2] = (var51.x4[2] * var47.x4[2]) & 0xffff;
      var52.x4[3] = (var51.x4[3] * var47.x4[3]) & 0xffff;
      /* 13: div255w */
      var53.x4[0] =
777
          ((orc_uint16) (((orc_uint16) (var52.x4[0] + 128)) +
778 779
              (((orc_uint16) (var52.x4[0] + 128)) >> 8))) >> 8;
      var53.x4[1] =
780
          ((orc_uint16) (((orc_uint16) (var52.x4[1] + 128)) +
781 782
              (((orc_uint16) (var52.x4[1] + 128)) >> 8))) >> 8;
      var53.x4[2] =
783
          ((orc_uint16) (((orc_uint16) (var52.x4[2] + 128)) +
784 785
              (((orc_uint16) (var52.x4[2] + 128)) >> 8))) >> 8;
      var53.x4[3] =
786
          ((orc_uint16) (((orc_uint16) (var52.x4[3] + 128)) +
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
              (((orc_uint16) (var52.x4[3] + 128)) >> 8))) >> 8;
      /* 14: addw */
      var54.x4[0] = var50.x4[0] + var53.x4[0];
      var54.x4[1] = var50.x4[1] + var53.x4[1];
      var54.x4[2] = var50.x4[2] + var53.x4[2];
      var54.x4[3] = var50.x4[3] + var53.x4[3];
      /* 15: convwb */
      var55.x4[0] = var54.x4[0];
      var55.x4[1] = var54.x4[1];
      var55.x4[2] = var54.x4[2];
      var55.x4[3] = var54.x4[3];
      /* 17: orl */
      var56.i = var55.i | var40.i;
      /* 18: storel */
      ptr0[i] = var56;
    }
  }

}

void
808
video_mixer_orc_blend_argb (guint8 * ORC_RESTRICT d1, int d1_stride,
809
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
810 811
{
  OrcExecutor _ex, *ex = &_ex;
Sebastian Dröge's avatar
Sebastian Dröge committed
812
  static volatile int p_inited = 0;
813
  static OrcCode *c = 0;
814 815 816 817 818
  void (*func) (OrcExecutor *);

  if (!p_inited) {
    orc_once_mutex_lock ();
    if (!p_inited) {
819
      OrcProgram *p;
820

Sebastian Dröge's avatar
Sebastian Dröge committed
821 822 823 824
#if 1
      static const orc_uint8 bc[] = {
        1, 7, 9, 26, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95,
        111, 114, 99, 95, 98, 108, 101, 110, 100, 95, 97, 114, 103, 98, 11, 4,
Sebastian Dröge's avatar
Sebastian Dröge committed
825
        4, 12, 4, 4, 14, 4, 255, 0, 0, 0, 14, 2, 8, 0, 0, 0,
Sebastian Dröge's avatar
Sebastian Dröge committed
826 827 828 829 830 831 832 833 834 835
        16, 2, 20, 4, 20, 2, 20, 1, 20, 4, 20, 8, 20, 8, 20, 8,
        113, 32, 4, 163, 33, 32, 157, 34, 33, 152, 35, 34, 21, 2, 150, 38,
        35, 21, 2, 89, 38, 38, 24, 21, 2, 95, 38, 38, 17, 21, 2, 150,
        37, 32, 113, 32, 0, 21, 2, 150, 36, 32, 21, 2, 98, 37, 37, 36,
        21, 2, 89, 37, 37, 38, 21, 2, 80, 37, 37, 21, 2, 70, 36, 36,
        37, 21, 2, 157, 32, 36, 123, 32, 32, 16, 128, 0, 32, 2, 0,
      };
      p = orc_program_new_from_static_bytecode (bc);
      orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_argb);
#else
836 837
      p = orc_program_new ();
      orc_program_set_2d (p);
838 839
      orc_program_set_name (p, "video_mixer_orc_blend_argb");
      orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_argb);
840 841 842
      orc_program_add_destination (p, 4, "d1");
      orc_program_add_source (p, 4, "s1");
      orc_program_add_constant (p, 4, 0x000000ff, "c1");
Sebastian Dröge's avatar
Sebastian Dröge committed
843
      orc_program_add_constant (p, 2, 0x00000008, "c2");
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886
      orc_program_add_parameter (p, 2, "p1");
      orc_program_add_temporary (p, 4, "t1");
      orc_program_add_temporary (p, 2, "t2");
      orc_program_add_temporary (p, 1, "t3");
      orc_program_add_temporary (p, 4, "t4");
      orc_program_add_temporary (p, 8, "t5");
      orc_program_add_temporary (p, 8, "t6");
      orc_program_add_temporary (p, 8, "t7");

      orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convlw", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convwb", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 2, ORC_VAR_T7, ORC_VAR_T4, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "mullw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_P1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "shruw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_C2,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 2, ORC_VAR_T6, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 2, ORC_VAR_T5, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "subw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T5,
          ORC_VAR_D1);
      orc_program_append_2 (p, "mullw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T7,
          ORC_VAR_D1);
      orc_program_append_2 (p, "div255w", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "addw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_T6,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convwb", 2, ORC_VAR_T1, ORC_VAR_T5, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "orl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "storel", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
Sebastian Dröge's avatar
Sebastian Dröge committed
887
#endif
888

889
      orc_program_compile (p);
890 891
      c = orc_program_take_code (p);
      orc_program_free (p);
892 893 894 895
    }
    p_inited = TRUE;
    orc_once_mutex_unlock ();
  }
896 897
  ex->arrays[ORC_VAR_A2] = c;
  ex->program = 0;
898 899 900 901 902 903 904 905 906

  ex->n = n;
  ORC_EXECUTOR_M (ex) = m;
  ex->arrays[ORC_VAR_D1] = d1;
  ex->params[ORC_VAR_D1] = d1_stride;
  ex->arrays[ORC_VAR_S1] = (void *) s1;
  ex->params[ORC_VAR_S1] = s1_stride;
  ex->params[ORC_VAR_P1] = p1;

907
  func = c->exec;
908 909 910 911 912
  func (ex);
}
#endif


913
/* video_mixer_orc_blend_bgra */
914 915
#ifdef DISABLE_ORC
void
916
video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride,
917
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
918 919 920 921 922 923
{
  int i;
  int j;
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union64 var40;
Sebastian Dröge's avatar
Sebastian Dröge committed
924 925 926
#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__)
  volatile orc_union32 var41;
#else
927
  orc_union32 var41;
Sebastian Dröge's avatar
Sebastian Dröge committed
928
#endif
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
  orc_union32 var42;
  orc_union32 var43;
  orc_union16 var44;
  orc_int8 var45;
  orc_union32 var46;
  orc_union64 var47;
  orc_union64 var48;
  orc_union64 var49;
  orc_union64 var50;
  orc_union32 var51;
  orc_union64 var52;
  orc_union64 var53;
  orc_union64 var54;
  orc_union64 var55;
  orc_union64 var56;
  orc_union32 var57;
  orc_union32 var58;

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j);
    ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j);

David Schleef's avatar
David Schleef committed
951 952 953 954 955 956
    /* 6: loadpw */
    var40.x4[0] = p1;
    var40.x4[1] = p1;
    var40.x4[2] = p1;
    var40.x4[3] = p1;
    /* 17: loadpl */
957
    var41.i = (int) 0xff000000; /* -16777216 or 2.11371e-314f */
David Schleef's avatar
David Schleef committed
958

959 960 961 962 963 964 965 966 967 968 969
    for (i = 0; i < n; i++) {
      /* 0: loadl */
      var42 = ptr4[i];
      /* 1: shrul */
      var43.i = ((orc_uint32) var42.i) >> 24;
      /* 2: convlw */
      var44.i = var43.i;
      /* 3: convwb */
      var45 = var44.i;
      /* 4: splatbl */
      var46.i =
Sebastian Dröge's avatar
Sebastian Dröge committed
970 971 972
          ((((orc_uint32) var45) & 0xff) << 24) | ((((orc_uint32) var45) & 0xff)
          << 16) | ((((orc_uint32) var45) & 0xff) << 8) | (((orc_uint32) var45)
          & 0xff);
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
      /* 5: convubw */
      var47.x4[0] = (orc_uint8) var46.x4[0];
      var47.x4[1] = (orc_uint8) var46.x4[1];
      var47.x4[2] = (orc_uint8) var46.x4[2];
      var47.x4[3] = (orc_uint8) var46.x4[3];
      /* 7: mullw */
      var48.x4[0] = (var47.x4[0] * var40.x4[0]) & 0xffff;
      var48.x4[1] = (var47.x4[1] * var40.x4[1]) & 0xffff;
      var48.x4[2] = (var47.x4[2] * var40.x4[2]) & 0xffff;
      var48.x4[3] = (var47.x4[3] * var40.x4[3]) & 0xffff;
      /* 8: shruw */
      var49.x4[0] = ((orc_uint16) var48.x4[0]) >> 8;
      var49.x4[1] = ((orc_uint16) var48.x4[1]) >> 8;
      var49.x4[2] = ((orc_uint16) var48.x4[2]) >> 8;
      var49.x4[3] = ((orc_uint16) var48.x4[3]) >> 8;
      /* 9: convubw */
      var50.x4[0] = (orc_uint8) var42.x4[0];
      var50.x4[1] = (orc_uint8) var42.x4[1];
      var50.x4[2] = (orc_uint8) var42.x4[2];
      var50.x4[3] = (orc_uint8) var42.x4[3];
      /* 10: loadl */
      var51 = ptr0[i];
      /* 11: convubw */
      var52.x4[0] = (orc_uint8) var51.x4[0];
      var52.x4[1] = (orc_uint8) var51.x4[1];
      var52.x4[2] = (orc_uint8) var51.x4[2];
      var52.x4[3] = (orc_uint8) var51.x4[3];
      /* 12: subw */
      var53.x4[0] = var50.x4[0] - var52.x4[0];
      var53.x4[1] = var50.x4[1] - var52.x4[1];
      var53.x4[2] = var50.x4[2] - var52.x4[2];
      var53.x4[3] = var50.x4[3] - var52.x4[3];
      /* 13: mullw */
      var54.x4[0] = (var53.x4[0] * var49.x4[0]) & 0xffff;
      var54.x4[1] = (var53.x4[1] * var49.x4[1]) & 0xffff;
      var54.x4[2] = (var53.x4[2] * var49.x4[2]) & 0xffff;
      var54.x4[3] = (var53.x4[3] * var49.x4[3]) & 0xffff;
      /* 14: div255w */
      var55.x4[0] =
1012
          ((orc_uint16) (((orc_uint16) (var54.x4[0] + 128)) +
1013 1014
              (((orc_uint16) (var54.x4[0] + 128)) >> 8))) >> 8;
      var55.x4[1] =
1015
          ((orc_uint16) (((orc_uint16) (var54.x4[1] + 128)) +
1016 1017
              (((orc_uint16) (var54.x4[1] + 128)) >> 8))) >> 8;
      var55.x4[2] =
1018
          ((orc_uint16) (((orc_uint16) (var54.x4[2] + 128)) +
1019 1020
              (((orc_uint16) (var54.x4[2] + 128)) >> 8))) >> 8;
      var55.x4[3] =
1021
          ((orc_uint16) (((orc_uint16) (var54.x4[3] + 128)) +
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
              (((orc_uint16) (var54.x4[3] + 128)) >> 8))) >> 8;
      /* 15: addw */
      var56.x4[0] = var52.x4[0] + var55.x4[0];
      var56.x4[1] = var52.x4[1] + var55.x4[1];
      var56.x4[2] = var52.x4[2] + var55.x4[2];
      var56.x4[3] = var52.x4[3] + var55.x4[3];
      /* 16: convwb */
      var57.x4[0] = var56.x4[0];
      var57.x4[1] = var56.x4[1];
      var57.x4[2] = var56.x4[2];
      var57.x4[3] = var56.x4[3];
      /* 18: orl */
      var58.i = var57.i | var41.i;
      /* 19: storel */
      ptr0[i] = var58;
    }
  }

}

#else
static void
1044
_backup_video_mixer_orc_blend_bgra (OrcExecutor * ORC_RESTRICT ex)
1045 1046 1047 1048 1049 1050 1051 1052
{
  int i;
  int j;
  int n = ex->n;
  int m = ex->params[ORC_VAR_A1];
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union64 var40;
Sebastian Dröge's avatar
Sebastian Dröge committed
1053 1054 1055
#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__)
  volatile orc_union32 var41;
#else
1056
  orc_union32 var41;
Sebastian Dröge's avatar
Sebastian Dröge committed
1057
#endif
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
  orc_union32 var42;
  orc_union32 var43;
  orc_union16 var44;
  orc_int8 var45;
  orc_union32 var46;
  orc_union64 var47;
  orc_union64 var48;
  orc_union64 var49;
  orc_union64 var50;
  orc_union32 var51;
  orc_union64 var52;
  orc_union64 var53;
  orc_union64 var54;
  orc_union64 var55;
  orc_union64 var56;
  orc_union32 var57;
  orc_union32 var58;

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (ex->arrays[0], ex->params[0] * j);
    ptr4 = ORC_PTR_OFFSET (ex->arrays[4], ex->params[4] * j);

David Schleef's avatar
David Schleef committed
1080 1081 1082 1083 1084 1085
    /* 6: loadpw */
    var40.x4[0] = ex->params[24];
    var40.x4[1] = ex->params[24];
    var40.x4[2] = ex->params[24];
    var40.x4[3] = ex->params[24];
    /* 17: loadpl */
1086
    var41.i = (int) 0xff000000; /* -16777216 or 2.11371e-314f */
David Schleef's avatar
David Schleef committed
1087

1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
    for (i = 0; i < n; i++) {
      /* 0: loadl */
      var42 = ptr4[i];
      /* 1: shrul */
      var43.i = ((orc_uint32) var42.i) >> 24;
      /* 2: convlw */
      var44.i = var43.i;
      /* 3: convwb */
      var45 = var44.i;
      /* 4: splatbl */
      var46.i =
Sebastian Dröge's avatar
Sebastian Dröge committed
1099 1100 1101
          ((((orc_uint32) var45) & 0xff) << 24) | ((((orc_uint32) var45) & 0xff)
          << 16) | ((((orc_uint32) var45) & 0xff) << 8) | (((orc_uint32) var45)
          & 0xff);
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140
      /* 5: convubw */
      var47.x4[0] = (orc_uint8) var46.x4[0];
      var47.x4[1] = (orc_uint8) var46.x4[1];
      var47.x4[2] = (orc_uint8) var46.x4[2];
      var47.x4[3] = (orc_uint8) var46.x4[3];
      /* 7: mullw */
      var48.x4[0] = (var47.x4[0] * var40.x4[0]) & 0xffff;
      var48.x4[1] = (var47.x4[1] * var40.x4[1]) & 0xffff;
      var48.x4[2] = (var47.x4[2] * var40.x4[2]) & 0xffff;
      var48.x4[3] = (var47.x4[3] * var40.x4[3]) & 0xffff;
      /* 8: shruw */
      var49.x4[0] = ((orc_uint16) var48.x4[0]) >> 8;
      var49.x4[1] = ((orc_uint16) var48.x4[1]) >> 8;
      var49.x4[2] = ((orc_uint16) var48.x4[2]) >> 8;
      var49.x4[3] = ((orc_uint16) var48.x4[3]) >> 8;
      /* 9: convubw */
      var50.x4[0] = (orc_uint8) var42.x4[0];
      var50.x4[1] = (orc_uint8) var42.x4[1];
      var50.x4[2] = (orc_uint8) var42.x4[2];
      var50.x4[3] = (orc_uint8) var42.x4[3];
      /* 10: loadl */
      var51 = ptr0[i];
      /* 11: convubw */
      var52.x4[0] = (orc_uint8) var51.x4[0];
      var52.x4[1] = (orc_uint8) var51.x4[1];
      var52.x4[2] = (orc_uint8) var51.x4[2];
      var52.x4[3] = (orc_uint8) var51.x4[3];
      /* 12: subw */
      var53.x4[0] = var50.x4[0] - var52.x4[0];
      var53.x4[1] = var50.x4[1] - var52.x4[1];
      var53.x4[2] = var50.x4[2] - var52.x4[2];
      var53.x4[3] = var50.x4[3] - var52.x4[3];
      /* 13: mullw */
      var54.x4[0] = (var53.x4[0] * var49.x4[0]) & 0xffff;
      var54.x4[1] = (var53.x4[1] * var49.x4[1]) & 0xffff;
      var54.x4[2] = (var53.x4[2] * var49.x4[2]) & 0xffff;
      var54.x4[3] = (var53.x4[3] * var49.x4[3]) & 0xffff;
      /* 14: div255w */
      var55.x4[0] =
1141
          ((orc_uint16) (((orc_uint16) (var54.x4[0] + 128)) +
1142 1143
              (((orc_uint16) (var54.x4[0] + 128)) >> 8))) >> 8;
      var55.x4[1] =
1144
          ((orc_uint16) (((orc_uint16) (var54.x4[1] + 128)) +
1145 1146
              (((orc_uint16) (var54.x4[1] + 128)) >> 8))) >> 8;
      var55.x4[2] =
1147
          ((orc_uint16) (((orc_uint16) (var54.x4[2] + 128)) +
1148 1149
              (((orc_uint16) (var54.x4[2] + 128)) >> 8))) >> 8;
      var55.x4[3] =
1150
          ((orc_uint16) (((orc_uint16) (var54.x4[3] + 128)) +
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
              (((orc_uint16) (var54.x4[3] + 128)) >> 8))) >> 8;
      /* 15: addw */
      var56.x4[0] = var52.x4[0] + var55.x4[0];
      var56.x4[1] = var52.x4[1] + var55.x4[1];
      var56.x4[2] = var52.x4[2] + var55.x4[2];
      var56.x4[3] = var52.x4[3] + var55.x4[3];
      /* 16: convwb */
      var57.x4[0] = var56.x4[0];
      var57.x4[1] = var56.x4[1];
      var57.x4[2] = var56.x4[2];
      var57.x4[3] = var56.x4[3];
      /* 18: orl */
      var58.i = var57.i | var41.i;
      /* 19: storel */
      ptr0[i] = var58;
    }
  }

}

void
1172
video_mixer_orc_blend_bgra (guint8 * ORC_RESTRICT d1, int d1_stride,
1173
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
1174 1175
{
  OrcExecutor _ex, *ex = &_ex;
Sebastian Dröge's avatar
Sebastian Dröge committed
1176
  static volatile int p_inited = 0;
1177
  static OrcCode *c = 0;
1178 1179 1180 1181 1182
  void (*func) (OrcExecutor *);

  if (!p_inited) {
    orc_once_mutex_lock ();
    if (!p_inited) {
1183
      OrcProgram *p;
1184

Sebastian Dröge's avatar
Sebastian Dröge committed
1185 1186 1187 1188 1189
#if 1
      static const orc_uint8 bc[] = {
        1, 7, 9, 26, 118, 105, 100, 101, 111, 95, 109, 105, 120, 101, 114, 95,
        111, 114, 99, 95, 98, 108, 101, 110, 100, 95, 98, 103, 114, 97, 11, 4,
        4, 12, 4, 4, 14, 4, 0, 0, 0, 255, 14, 4, 24, 0, 0, 0,
Sebastian Dröge's avatar
Sebastian Dröge committed
1190
        14, 2, 8, 0, 0, 0, 16, 2, 20, 4, 20, 4, 20, 2, 20, 1,
Sebastian Dröge's avatar
Sebastian Dröge committed
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
        20, 4, 20, 8, 20, 8, 20, 8, 113, 32, 4, 126, 33, 32, 17, 163,
        34, 33, 157, 35, 34, 152, 36, 35, 21, 2, 150, 39, 36, 21, 2, 89,
        39, 39, 24, 21, 2, 95, 39, 39, 18, 21, 2, 150, 38, 32, 113, 32,
        0, 21, 2, 150, 37, 32, 21, 2, 98, 38, 38, 37, 21, 2, 89, 38,
        38, 39, 21, 2, 80, 38, 38, 21, 2, 70, 37, 37, 38, 21, 2, 157,
        32, 37, 123, 32, 32, 16, 128, 0, 32, 2, 0,
      };
      p = orc_program_new_from_static_bytecode (bc);
      orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_bgra);
#else
1201 1202
      p = orc_program_new ();
      orc_program_set_2d (p);
1203 1204
      orc_program_set_name (p, "video_mixer_orc_blend_bgra");
      orc_program_set_backup_function (p, _backup_video_mixer_orc_blend_bgra);
1205 1206
      orc_program_add_destination (p, 4, "d1");
      orc_program_add_source (p, 4, "s1");
David Schleef's avatar
David Schleef committed
1207
      orc_program_add_constant (p, 4, 0xff000000, "c1");
David Schleef's avatar
David Schleef committed
1208
      orc_program_add_constant (p, 4, 0x00000018, "c2");
Sebastian Dröge's avatar
Sebastian Dröge committed
1209
      orc_program_add_constant (p, 2, 0x00000008, "c3");
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255
      orc_program_add_parameter (p, 2, "p1");
      orc_program_add_temporary (p, 4, "t1");
      orc_program_add_temporary (p, 4, "t2");
      orc_program_add_temporary (p, 2, "t3");
      orc_program_add_temporary (p, 1, "t4");
      orc_program_add_temporary (p, 4, "t5");
      orc_program_add_temporary (p, 8, "t6");
      orc_program_add_temporary (p, 8, "t7");
      orc_program_add_temporary (p, 8, "t8");

      orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "shrul", 0, ORC_VAR_T2, ORC_VAR_T1, ORC_VAR_C2,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convlw", 0, ORC_VAR_T3, ORC_VAR_T2, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convwb", 0, ORC_VAR_T4, ORC_VAR_T3, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "splatbl", 0, ORC_VAR_T5, ORC_VAR_T4, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 2, ORC_VAR_T8, ORC_VAR_T5, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "mullw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_P1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "shruw", 2, ORC_VAR_T8, ORC_VAR_T8, ORC_VAR_C3,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 2, ORC_VAR_T7, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_D1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convubw", 2, ORC_VAR_T6, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "subw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_T6,
          ORC_VAR_D1);
      orc_program_append_2 (p, "mullw", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_T8,
          ORC_VAR_D1);
      orc_program_append_2 (p, "div255w", 2, ORC_VAR_T7, ORC_VAR_T7, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "addw", 2, ORC_VAR_T6, ORC_VAR_T6, ORC_VAR_T7,
          ORC_VAR_D1);
      orc_program_append_2 (p, "convwb", 2, ORC_VAR_T1, ORC_VAR_T6, ORC_VAR_D1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "orl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1,
          ORC_VAR_D1);
      orc_program_append_2 (p, "storel", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1,
          ORC_VAR_D1);
Sebastian Dröge's avatar
Sebastian Dröge committed
1256
#endif
1257

1258
      orc_program_compile (p);
1259 1260
      c = orc_program_take_code (p);
      orc_program_free (p);
1261 1262 1263 1264
    }
    p_inited = TRUE;
    orc_once_mutex_unlock ();
  }
1265 1266
  ex->arrays[ORC_VAR_A2] = c;
  ex->program = 0;
1267 1268 1269 1270 1271 1272 1273 1274 1275

  ex->n = n;
  ORC_EXECUTOR_M (ex) = m;
  ex->arrays[ORC_VAR_D1] = d1;
  ex->params[ORC_VAR_D1] = d1_stride;
  ex->arrays[ORC_VAR_S1] = (void *) s1;
  ex->params[ORC_VAR_S1] = s1_stride;
  ex->params[ORC_VAR_P1] = p1;

1276
  func = c->exec;
1277 1278 1279
  func (ex);
}
#endif
1280 1281


1282
/* video_mixer_orc_overlay_argb */
1283 1284
#ifdef DISABLE_ORC
void
1285
video_mixer_orc_overlay_argb (guint8 * ORC_RESTRICT d1, int d1_stride,
1286
    const guint8 * ORC_RESTRICT s1, int s1_stride, int p1, int n, int m)
1287 1288 1289 1290 1291 1292
{
  int i;
  int j;
  orc_union32 *ORC_RESTRICT ptr0;
  const orc_union32 *ORC_RESTRICT ptr4;
  orc_union64 var41;
Sebastian Dröge's avatar
Sebastian Dröge committed
1293 1294 1295
#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__)
  volatile orc_union32 var42;
#else
1296
  orc_union32 var42;
Sebastian Dröge's avatar
Sebastian Dröge committed
1297 1298 1299 1300
#endif
#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__)
  volatile orc_union32 var43;
#else
1301
  orc_union32 var43;
Sebastian Dröge's avatar
Sebastian Dröge committed
1302
#endif
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
  orc_union32 var44;
  orc_union16 var45;
  orc_int8 var46;
  orc_union32 var47;
  orc_union64 var48;
  orc_union64 var49;
  orc_union64 var50;
  orc_union64 var51;
  orc_union64 var52;
  orc_union32 var53;
  orc_union64 var54;
  orc_union64 var55;
  orc_union32 var56;
  orc_union16 var57;
  orc_int8 var58;
1318 1319
  orc_union32 var59;
  orc_union64 var60;
1320 1321 1322 1323 1324 1325 1326
  orc_union64 var61;
  orc_union64 var62;
  orc_union64 var63;
  orc_union64 var64;
  orc_union64 var65;
  orc_union64 var66;
  orc_union64 var67;
1327
  orc_union32 var68;
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
  orc_union32 var69;
  orc_union32 var70;
  orc_union32 var71;
  orc_union32 var72;

  for (j = 0; j < m; j++) {
    ptr0 = ORC_PTR_OFFSET (d1, d1_stride * j);
    ptr4 = ORC_PTR_OFFSET (s1, s1_stride * j);

    /* 5: loadpw */
    var41.x4[0] = p1;
    var41.x4[1] = p1;
    var41.x4[2] = p1;
    var41.x4[3] = p1;
    /* 10: loadpl */
    var53.i = (int) 0xffffffff; /* -1 or 2.122e-314f */
1344
    /* 26: loadpl */
1345
    var42.i = (int) 0xffffff00; /* -256 or 2.122e-314f */
1346
    /* 29: loadpl */
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357
    var43.i = (int) 0x000000ff; /* 255 or 1.25987e-321f */

    for (i = 0; i < n; i++) {
      /* 0: loadl */
      var44 = ptr4[i];