<commit_before>/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
 * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
 *                                                                  *
 ********************************************************************

  function:
    last mod: $Id$

 ********************************************************************/
#include <string.h>
#include "c64xint.h"



/*14 cycles.*/
void oc_frag_copy_c64x(unsigned char *restrict _dst,
 const unsigned char *restrict _src,int _ystride){
  unsigned char *restrict       d2;
  const unsigned char *restrict s2;
  d2=_dst+_ystride;
  s2=_src+_ystride;
#define OC_ITER() \
  do{ \
    _amem8(_dst)=_mem8(_src); \
    _dst+=2*_ystride; \
    _src+=2*_ystride; \
    _amem8(d2)=_mem8(s2); \
    d2+=2*_ystride; \
    s2+=2*_ystride; \
  } \
  while(0)
  OC_ITER();
  OC_ITER();
  OC_ITER();
  OC_ITER();
#undef OC_ITER
}

void oc_frag_copy_list_c64x(unsigned char *_dst_frame,
 const unsigned char *_src_frame,int _ystride,
 const ptrdiff_t *_fragis,ptrdiff_t _nfragis,const ptrdiff_t *_frag_buf_offs){
  ptrdiff_t fragii;
  /*9 cycles per iteration.*/
  for(fragii=0;fragii<_nfragis;fragii++){
    const unsigned char *restrict src;
    const unsigned char *restrict s2;
    unsigned char       *restrict dst;
    unsigned char       *restrict d2;
    ptrdiff_t                     frag_buf_off;
    frag_buf_off=_frag_buf_offs[_fragis[fragii]];
    dst=_dst_frame+frag_buf_off;
    src=_src_frame+frag_buf_off;
    d2=dst+_ystride;
    s2=src+_ystride;
#define OC_ITER() \
  do{ \
    _amem8(dst)=_amem8_const(src); \
    dst+=2*_ystride; \
    src+=2*_ystride; \
    _amem8(d2)=_amem8_const(s2); \
    d2+=2*_ystride; \
    s2+=2*_ystride; \
  } \
  while(0)
    OC_ITER();
    OC_ITER();
    OC_ITER();
    OC_ITER();
#undef OC_ITER
  }
}

/*34 cycles.*/
void oc_frag_recon_intra_c64x(unsigned char *_dst,int _ystride,
 const ogg_int16_t _residue[64]){
  int i;
  for(i=0;i<8;i++){
    long long ll;
    int       x1;
    int       y1;
    int       x2;
    int       y2;
    ll=_amem8_const(_residue+i*8+0);
    x1=_sadd2(_loll(ll),0x00800080);
    y1=_sadd2(_hill(ll),0x00800080);
    ll=_amem8_const(_residue+i*8+4);
    x2=_sadd2(_loll(ll),0x00800080);
    y2=_sadd2(_hill(ll),0x00800080);
    _amem8(_dst)=_itoll(_spacku4(y2,x2),_spacku4(y1,x1));
    _dst+=_ystride;
  }
}

/*41 cycles.*/
void oc_frag_recon_inter_c64x(unsigned char *_dst,const unsigned char *_src,
 int _ystride,const ogg_int16_t _residue[64]){
  int i;
  for(i=0;i<8;i++){
    long long ll;
    int       x1;
    int       y1;
    int       z1;
    int       x2;
    int       y2;
    int       z2;
    ll=_mem8_const(_src);
    z1=_loll(ll);
    z2=_hill(ll);
    ll=_amem8_const(_residue+i*8+0);
    x1=_sadd2(_unpklu4(z1),_loll(ll));
    y1=_sadd2(_unpkhu4(z1),_hill(ll));
    ll=_amem8_const(_residue+i*8+4);
    x2=_sadd2(_unpklu4(z2),_loll(ll));
    y2=_sadd2(_unpkhu4(z2),_hill(ll));
    _amem8(_dst)=_itoll(_spacku4(y2,x2),_spacku4(y1,x1));
    _dst+=_ystride;
    _src+=_ystride;
  }
}

/*56 cycles.*/
void oc_frag_recon_inter2_c64x(unsigned char *_dst,
 const unsigned char *_src1,const unsigned char *_src2,int _ystride,
 const ogg_int16_t _residue[64]){
  int i;
  for(i=0;i<8;i++){
    long long ll;
    int       a;
    int       b;
    int       c;
    int       d;
    int       x1;
    int       y1;
    int       z1;
    int       x2;
    int       y2;
    int       z2;
    ll=_mem8_const(_src1);
    a=_loll(ll);
    b=_hill(ll);
    ll=_mem8_const(_src2);
    c=_loll(ll);
    d=_hill(ll);
    ll=_amem8_const(_residue+i*8+0);
    z1=~_avgu4(~a,~c);
    x1=_sadd2(_unpklu4(z1),_loll(ll));
    y1=_sadd2(_unpkhu4(z1),_hill(ll));
    ll=_amem8_const(_residue+i*8+4);
    z2=~_avgu4(~b,~d);
    x2=_sadd2(_unpklu4(z2),_loll(ll));
    y2=_sadd2(_unpkhu4(z2),_hill(ll));
    _amem8(_dst)=_itoll(_spacku4(y2,x2),_spacku4(y1,x1));
    _dst+=_ystride;
    _src1+=_ystride;
    _src2+=_ystride;
  }
}

void oc_state_frag_recon_c64x(const oc_theora_state *_state,ptrdiff_t _fragi,
 int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,ogg_uint16_t _dc_quant){
  unsigned char *dst;
  ptrdiff_t      frag_buf_off;
  int            ystride;
  int            refi;
  /*Apply the inverse transform.*/
  /*Special case only having a DC component.*/
  if(_last_zzi<2){
    int         p;
    long long   ll;
    int         ci;
    /*We round this dequant product (and not any of the others) because there's
       no iDCT rounding.*/
    p=_dct_coeffs[0]*(ogg_int32_t)_dc_quant+15>>5;
    ll=_itoll(_pack2(p,p),_pack2(p,p));
    for(ci=0;ci<64;ci+=4)_amem8(_dct_coeffs+64+ci)=ll;
  }
  else{
    /*First, dequantize the DC coefficient.*/
    _dct_coeffs[0]=(ogg_int16_t)(_dct_coeffs[0]*(int)_dc_quant);
    oc_idct8x8_c64x(_dct_coeffs+64,_dct_coeffs,_last_zzi);
  }
  /*Fill in the target buffer.*/
  frag_buf_off=_state->frag_buf_offs[_fragi];
  refi=_state->frags[_fragi].refi;
  ystride=_state->ref_ystride[_pli];
  dst=_state->ref_frame_data[_state->ref_frame_idx[OC_FRAME_SELF]]+frag_buf_off;
  if(refi==OC_FRAME_SELF)oc_frag_recon_intra_c64x(dst,ystride,_dct_coeffs+64);
  else{
    const unsigned char *ref;
    int                  mvoffsets[2];
    ref=_state->ref_frame_data[_state->ref_frame_idx[refi]]+frag_buf_off;
    if(oc_state_get_mv_offsets(_state,mvoffsets,_pli,
     _state->frag_mvs[_fragi])>1){
      oc_frag_recon_inter2_c64x(dst,ref+mvoffsets[0],ref+mvoffsets[1],
       ystride,_dct_coeffs+64);
    }
    else oc_frag_recon_inter_c64x(dst,ref+mvoffsets[0],ystride,_dct_coeffs+64);
  }
}

/*46 cycles.*/
static void loop_filter_h(unsigned char *restrict _pix,int _ystride,int _ll){
  int p0;
  int p1;
  int p2;
  int p3;
  int p4;
  int p5;
  int p6;
  int p7;<commit_msg>Add c64x changes for r17563, as they were accidentally omitted.<commit_after>/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
 * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
 *                                                                  *
 ********************************************************************

  function:
    last mod: $Id$

 ********************************************************************/
#include <string.h>
#include "c64xint.h"



/*14 cycles.*/
void oc_frag_copy_c64x(unsigned char *restrict _dst,
 const unsigned char *restrict _src,int _ystride){
  unsigned char *restrict       d2;
  const unsigned char *restrict s2;
  d2=_dst+_ystride;
  s2=_src+_ystride;
#define OC_ITER() \
  do{ \
    _amem8(_dst)=_mem8(_src); \
    _dst+=2*_ystride; \
    _src+=2*_ystride; \
    _amem8(d2)=_mem8(s2); \
    d2+=2*_ystride; \
    s2+=2*_ystride; \
  } \
  while(0)
  OC_ITER();
  OC_ITER();
  OC_ITER();
  OC_ITER();
#undef OC_ITER
}

void oc_frag_copy_list_c64x(unsigned char *_dst_frame,
 const unsigned char *_src_frame,int _ystride,
 const ptrdiff_t *_fragis,ptrdiff_t _nfragis,const ptrdiff_t *_frag_buf_offs){
  ptrdiff_t fragii;
  /*9 cycles per iteration.*/
  for(fragii=0;fragii<_nfragis;fragii++){
    const unsigned char *restrict src;
    const unsigned char *restrict s2;
    unsigned char       *restrict dst;
    unsigned char       *restrict d2;
    ptrdiff_t                     frag_buf_off;
    frag_buf_off=_frag_buf_offs[_fragis[fragii]];
    dst=_dst_frame+frag_buf_off;
    src=_src_frame+frag_buf_off;
    d2=dst+_ystride;
    s2=src+_ystride;
#define OC_ITER() \
  do{ \
    _amem8(dst)=_amem8_const(src); \
    dst+=2*_ystride; \
    src+=2*_ystride; \
    _amem8(d2)=_amem8_const(s2); \
    d2+=2*_ystride; \
    s2+=2*_ystride; \
  } \
  while(0)
    OC_ITER();
    OC_ITER();
    OC_ITER();
    OC_ITER();
#undef OC_ITER
  }
}

/*34 cycles.*/
void oc_frag_recon_intra_c64x(unsigned char *_dst,int _ystride,
 const ogg_int16_t _residue[64]){
  int i;
  for(i=0;i<8;i++){
    long long ll;
    int       x1;
    int       y1;
    int       x2;
    int       y2;
    ll=_amem8_const(_residue+i*8+0);
    x1=_sadd2(_loll(ll),0x00800080);
    y1=_sadd2(_hill(ll),0x00800080);
    ll=_amem8_const(_residue+i*8+4);
    x2=_sadd2(_loll(ll),0x00800080);
    y2=_sadd2(_hill(ll),0x00800080);
    _amem8(_dst)=_itoll(_spacku4(y2,x2),_spacku4(y1,x1));
    _dst+=_ystride;
  }
}

/*41 cycles.*/
void oc_frag_recon_inter_c64x(unsigned char *_dst,const unsigned char *_src,
 int _ystride,const ogg_int16_t _residue[64]){
  int i;
  for(i=0;i<8;i++){
    long long ll;
    int       x1;
    int       y1;
    int       z1;
    int       x2;
    int       y2;
    int       z2;
    ll=_mem8_const(_src);
    z1=_loll(ll);
    z2=_hill(ll);
    ll=_amem8_const(_residue+i*8+0);
    x1=_sadd2(_unpklu4(z1),_loll(ll));
    y1=_sadd2(_unpkhu4(z1),_hill(ll));
    ll=_amem8_const(_residue+i*8+4);
    x2=_sadd2(_unpklu4(z2),_loll(ll));
    y2=_sadd2(_unpkhu4(z2),_hill(ll));
    _amem8(_dst)=_itoll(_spacku4(y2,x2),_spacku4(y1,x1));
    _dst+=_ystride;
    _src+=_ystride;
  }
}

/*56 cycles.*/
void oc_frag_recon_inter2_c64x(unsigned char *_dst,
 const unsigned char *_src1,const unsigned char *_src2,int _ystride,
 const ogg_int16_t _residue[64]){
  int i;
  for(i=0;i<8;i++){
    long long ll;
    int       a;
    int       b;
    int       c;
    int       d;
    int       x1;
    int       y1;
    int       z1;
    int       x2;
    int       y2;
    int       z2;
    ll=_mem8_const(_src1);
    a=_loll(ll);
    b=_hill(ll);
    ll=_mem8_const(_src2);
    c=_loll(ll);
    d=_hill(ll);
    ll=_amem8_const(_residue+i*8+0);
    z1=~_avgu4(~a,~c);
    x1=_sadd2(_unpklu4(z1),_loll(ll));
    y1=_sadd2(_unpkhu4(z1),_hill(ll));
    ll=_amem8_const(_residue+i*8+4);
    z2=~_avgu4(~b,~d);
    x2=_sadd2(_unpklu4(z2),_loll(ll));
    y2=_sadd2(_unpkhu4(z2),_hill(ll));
    _amem8(_dst)=_itoll(_spacku4(y2,x2),_spacku4(y1,x1));
    _dst+=_ystride;
    _src1+=_ystride;
    _src2+=_ystride;
  }
}

void oc_state_frag_recon_c64x(const oc_theora_state *_state,ptrdiff_t _fragi,
 int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,ogg_uint16_t _dc_quant){
  unsigned char *dst;
  ptrdiff_t      frag_buf_off;
  int            ystride;
  int            refi;
  /*Apply the inverse transform.*/
  /*Special case only having a DC component.*/
  if(_last_zzi<2){
    int         p;
    long long   ll;
    int         ci;
    /*We round this dequant product (and not any of the others) because there's
       no iDCT rounding.*/
    p=_dct_coeffs[0]*(ogg_int32_t)_dc_quant+15>>5;
    ll=_itoll(_pack2(p,p),_pack2(p,p));
    for(ci=0;ci<64;ci+=4)_amem8(_dct_coeffs+64+ci)=ll;
  }
  else{
    /*First, dequantize the DC coefficient.*/
    _dct_coeffs[0]=(ogg_int16_t)(_dct_coeffs[0]*(int)_dc_quant);
    oc_idct8x8_c64x(_dct_coeffs+64,_dct_coeffs,_last_zzi);
  }
  /*Fill in the target buffer.*/
  frag_buf_off=_state->frag_buf_offs[_fragi];
  refi=_state->frags[_fragi].refi;
  ystride=_state->ref_ystride[_pli];
  dst=_state->ref_frame_data[OC_FRAME_SELF]+frag_buf_off;
  if(refi==OC_FRAME_SELF)oc_frag_recon_intra_c64x(dst,ystride,_dct_coeffs+64);
  else{
    const unsigned char *ref;
    int                  mvoffsets[2];
    ref=_state->ref_frame_data[refi]+frag_buf_off;
    if(oc_state_get_mv_offsets(_state,mvoffsets,_pli,
     _state->frag_mvs[_fragi])>1){
      oc_frag_recon_inter2_c64x(dst,ref+mvoffsets[0],ref+mvoffsets[1],
       ystride,_dct_coeffs+64);
    }
    else oc_frag_recon_inter_c64x(dst,ref+mvoffsets[0],ystride,_dct_coeffs+64);
  }
}

/*46 cycles.*/
static void loop_filter_h(unsigned char *restrict _pix,int _ystride,int _ll){
  int p0;
  int p1;
  int p2;
  int p3;
  int p4;
  int p5;
  int p6;
  int p7;
{'fraction_non_alphanumeric': 0.1630901287553648, 'fraction_numerical': 0.04697186456843109, 'mean_word_length': 3.008601465434852, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6917034', 'n_tokens_mistral': 5464, 'n_tokens_neox': 5279, 'n_words': 840}