<commit_before>/*
   (c) Copyright 2001-2007  The DirectFB Organization (directfb.org)
   (c) Copyright 2000-2004  Convergence (integrated media) GmbH

   All rights reserved.

   Written by <NAME> <<EMAIL>>,
              <NAME> <<EMAIL>>,
              <NAME> <<EMAIL>>,
              <NAME> <<EMAIL>> and
              <NAME> <<EMAIL>>.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

/*
 * Example:
 * #define RGB_MASK 0x7fff
 * #define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_15
 * #define Bop_PFI_OP_Aop_PFI( op ) Bop_15_##op##_Aop_15
 * #include "template_ckey_16.h"
 */

#if RGB_MASK == 0xffff
#define MASK_RGB( p ) (p)
#else
#define MASK_RGB( p ) ((p) & RGB_MASK)
#endif

#define MASK_RGB_L( p ) ((p) & RGB_MASK)
#define MASK_RGB_H( p ) ((p) & (RGB_MASK << 16))
#define MASK_RGB_32( p ) ((p) & (RGB_MASK << 16 | RGB_MASK))

/********************************* Cop_toK_Aop_PFI ****************************/

static void Cop_OP_Aop_PFI(toK)( GenefxState *gfxs )
{
     int  l    = gfxs->length;
     u16 *D    = gfxs->Aop[0];
     u16  Dkey = gfxs->Dkey;
     u16  Cop  = gfxs->Cop;

     while (l--) {
          if (MASK_RGB( *D ) == Dkey)
               *D = Cop;

          D++;
     }
}

/********************************* Bop_PFI_Kto_Aop_PFI ************************/

static void Bop_PFI_OP_Aop_PFI(Kto)( GenefxState *gfxs )
{
     int  w, l  = gfxs->length;
     int  Ostep = gfxs->Ostep;
     u16 *S     = gfxs->Bop[0];
     u16 *D     = gfxs->Aop[0];
     u16  Skey  = gfxs->Skey;
     u32  SkeyH = gfxs->Skey << 16;

     /* blit direction */
     if (Ostep < 0) {
          S += gfxs->length - 1;
          D += gfxs->length - 1;
     }

     if (((long)S & 2) != ((long)D & 2)) {
          /* source and destination misaligned */
          while (l--) {
               u16 s = *S;

               if (MASK_RGB( s ) != Skey)
                    *D = s;

               S += Ostep;
               D += Ostep;
          }

          return;
     }

     /* fix alignment */
     if (Ostep > 0) {
          if ((long)D & 2) {
               /* align / leftmost pixel */
               u16 s = *S;

               if (MASK_RGB( s ) != Skey)
                    *D = s;

               S++;
               D++;
               l--;
          }
     } else { /* Ostep < 0 */
          if ((long)D & 2) {
               /* align */
               S--;
               D--;
          } else {
               /* rightmost pixel */
               u16 s = *S;

               if (MASK_RGB( s ) != Skey)
                    *D = s;

               S -= 2;
               D -= 2;
               l--;
          }
     }

     /* blit */
     Ostep <<= 1;
     w = l >> 1;
     while (w--) {
          u32 s = *(u32 *) S;

          if (MASK_RGB_L( s ) != Skey) {
               if (MASK_RGB_H( s ) != SkeyH) {
                    *(u32 *) D = s;
               } else {
#ifdef WORDS_BIGENDIAN
                    D[0] = (u16) s;
#else
                    D[1] = (u16) s;
#endif
               }
          } else if (MASK_RGB_H( s ) != SkeyH) {
#ifdef WORDS_BIGENDIAN
               D[1] = (u16) (s >> 16);
#else
               D[0] = (u16) (s >> 16);
#endif
          }

          S += Ostep;
          D += Ostep;
     }

     /* last potential pixel */
     if (l & 1) {
          u16 s;

          if (Ostep < 0) {
               S++;
               D++;
          }

          s = *S;
          if (MASK_RGB( s ) != Skey)
               *D = s;
     }
}

/********************************* Bop_PFI_toK_Aop_PFI ************************/

static void Bop_PFI_OP_Aop_PFI(toK)( GenefxState *gfxs )<commit_msg>Fix hi/lo mixup for big/little endian in 32 bit wise 16 bit color keying code.<commit_after>/*
   (c) Copyright 2001-2007  The DirectFB Organization (directfb.org)
   (c) Copyright 2000-2004  Convergence (integrated media) GmbH

   All rights reserved.

   Written by <NAME> <<EMAIL>>,
              <NAME> <<EMAIL>>,
              <NAME> <<EMAIL>>,
              <NAME> <<EMAIL>> and
              <NAME> <<EMAIL>>.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

/*
 * Example:
 * #define RGB_MASK 0x7fff
 * #define Cop_OP_Aop_PFI( op ) Cop_##op##_Aop_15
 * #define Bop_PFI_OP_Aop_PFI( op ) Bop_15_##op##_Aop_15
 * #include "template_ckey_16.h"
 */

#if RGB_MASK == 0xffff
#define MASK_RGB( p ) (p)
#else
#define MASK_RGB( p ) ((p) & RGB_MASK)
#endif

#define MASK_RGB_L( p ) ((p) & RGB_MASK)
#define MASK_RGB_H( p ) ((p) & (RGB_MASK << 16))
#define MASK_RGB_32( p ) ((p) & (RGB_MASK << 16 | RGB_MASK))

/********************************* Cop_toK_Aop_PFI ****************************/

static void Cop_OP_Aop_PFI(toK)( GenefxState *gfxs )
{
     int  l    = gfxs->length;
     u16 *D    = gfxs->Aop[0];
     u16  Dkey = gfxs->Dkey;
     u16  Cop  = gfxs->Cop;

     while (l--) {
          if (MASK_RGB( *D ) == Dkey)
               *D = Cop;

          D++;
     }
}

/********************************* Bop_PFI_Kto_Aop_PFI ************************/

static void Bop_PFI_OP_Aop_PFI(Kto)( GenefxState *gfxs )
{
     int  w, l  = gfxs->length;
     int  Ostep = gfxs->Ostep;
     u16 *S     = gfxs->Bop[0];
     u16 *D     = gfxs->Aop[0];
     u16  Skey  = gfxs->Skey;
     u32  SkeyH = gfxs->Skey << 16;

     /* blit direction */
     if (Ostep < 0) {
          S += gfxs->length - 1;
          D += gfxs->length - 1;
     }

     if (((long)S & 2) != ((long)D & 2)) {
          /* source and destination misaligned */
          while (l--) {
               u16 s = *S;

               if (MASK_RGB( s ) != Skey)
                    *D = s;

               S += Ostep;
               D += Ostep;
          }

          return;
     }

     /* fix alignment */
     if (Ostep > 0) {
          if ((long)D & 2) {
               /* align / leftmost pixel */
               u16 s = *S;

               if (MASK_RGB( s ) != Skey)
                    *D = s;

               S++;
               D++;
               l--;
          }
     } else { /* Ostep < 0 */
          if ((long)D & 2) {
               /* align */
               S--;
               D--;
          } else {
               /* rightmost pixel */
               u16 s = *S;

               if (MASK_RGB( s ) != Skey)
                    *D = s;

               S -= 2;
               D -= 2;
               l--;
          }
     }

     /* blit */
     Ostep <<= 1;
     w = l >> 1;
     while (w--) {
          u32 s = *(u32 *) S;

          if (MASK_RGB_L( s ) != Skey) {
               if (MASK_RGB_H( s ) != SkeyH) {
                    *(u32 *) D = s;
               } else {
#ifdef WORDS_BIGENDIAN
                    D[1] = (u16) s;
#else
                    D[0] = (u16) s;
#endif
               }
          } else if (MASK_RGB_H( s ) != SkeyH) {
#ifdef WORDS_BIGENDIAN
               D[0] = (u16) (s >> 16);
#else
               D[1] = (u16) (s >> 16);
#endif
          }

          S += Ostep;
          D += Ostep;
     }

     /* last potential pixel */
     if (l & 1) {
          u16 s;

          if (Ostep < 0) {
               S++;
               D++;
          }

          s = *S;
          if (MASK_RGB( s ) != Skey)
               *D = s;
     }
}

/********************************* Bop_PFI_toK_Aop_PFI ************************/

static void Bop_PFI_OP_Aop_PFI(toK)( GenefxState *gfxs )
{'fraction_non_alphanumeric': 0.16618547176348308, 'fraction_numerical': 0.026330985102205797, 'mean_word_length': 1.481375358166189, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2124000', 'n_tokens_mistral': 3155, 'n_tokens_neox': 2913, 'n_words': 840}