Example #1
0
/* apply Q-permutation to x */
void Q(hashState *ctx, u8 x[ROWS][COLS1024]) {
  u8 i;
  Variant v = ctx->columns==8?Q512:Q1024;
#ifndef TURN_OFF_PRINTING
  printf(":: BEGIN Q\n");
  printf("Input:\n");
  PrintState(ctx, x);
#endif
  for (i = 0; i < ctx->rounds; i++) {
    AddRoundConstant(x, ctx->columns, i, v);
#ifndef TURN_OFF_PRINTING
    printf("t=%d (AddRoundConstant):\n", i);
    PrintState(ctx, x);
#endif
    SubBytes(x, ctx->columns);
#ifndef TURN_OFF_PRINTING
    printf("t=%d (SubBytes):\n", i);
    PrintState(ctx, x);
#endif
    ShiftBytes(x, ctx->columns, v);
#ifndef TURN_OFF_PRINTING
    printf("t=%d (ShiftBytes):\n", i);
    PrintState(ctx, x);
#endif
    MixBytes(x, ctx->columns);
#ifndef TURN_OFF_PRINTING
    printf("t=%d (MixBytes):\n", i);
    PrintState(ctx, x);
#endif
  }
#ifndef TURN_OFF_PRINTING
  printf(":: END Q\n\n");
#endif
}
Example #2
0
void VP8LFillBitWindow(VP8LBitReader* const br) {
  if (br->bit_pos_ >= WBITS) {
#if (defined(__x86_64__) || defined(_M_X64))
    if (br->pos_ + sizeof(br->val_) < br->len_) {
      br->val_ >>= WBITS;
      br->bit_pos_ -= WBITS;
      // The expression below needs a little-endian arch to work correctly.
      // This gives a large speedup for decoding speed.
      br->val_ |= *(const vp8l_val_t*)(br->buf_ + br->pos_) << (LBITS - WBITS);
      br->pos_ += LOG8_WBITS;
      return;
    }
#endif
    ShiftBytes(br);       // Slow path.
    br->eos_ = IsEndOfStreamSpecial(br);
  }
Example #3
0
uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
  assert(n_bits >= 0);
  // Flag an error if end_of_stream or n_bits is more than allowed limit.
  if (!br->eos_ && n_bits < MAX_NUM_BIT_READ) {
    const uint32_t val =
        (uint32_t)(br->val_ >> br->bit_pos_) & kBitMask[n_bits];
    const int new_bits = br->bit_pos_ + n_bits;
    br->bit_pos_ = new_bits;
    // If this read is going to cross the read buffer, set the eos flag.
    if (br->pos_ == br->len_) {
      if (new_bits >= LBITS) {
        br->eos_ = 1;
      }
    }
    ShiftBytes(br);
    return val;
  } else {