Exemplo n.º 1
0
static void check_unweighted_pred(HEVCDSPContext *h, uint8_t *dst0, uint8_t *dst1,
                                  int16_t *src0, int16_t *src1, int bit_depth)
{
    int i;

    randomize_buffers(src0, BUF_SIZE, 8);
    randomize_buffers(src1, BUF_SIZE, 8);

    memset(dst0, 0, BUF_SIZE * sizeof(*dst0));
    memset(dst1, 0, BUF_SIZE * sizeof(*dst1));

    for (i = 0; i < FF_ARRAY_ELEMS(pred_widths); i++) {
        const int width = pred_widths[i];
        const int srcstride = FFALIGN(width, 16) * sizeof(*src0);
        const int dststride = FFALIGN(width, 16) * PIXEL_SIZE(bit_depth);

        {
            declare_func(void, uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride, int height);
            if (check_func(h->put_unweighted_pred[i], "put_unweighted_pred_%d_%d", width, bit_depth))
                UNWEIGHTED_PRED(dst0, dst1, src0, width, bit_depth);
            if (check_func(h->put_unweighted_pred_chroma[i], "put_unweighted_pred_%d_%d", width / 2, bit_depth))
                UNWEIGHTED_PRED(dst0, dst1, src0, width, bit_depth);
        }
        {
            declare_func(void, uint8_t *dst, ptrdiff_t dststride,
                         int16_t *src0, int16_t *src1, ptrdiff_t srcstride, int height);
            if (check_func(h->put_unweighted_pred_avg[i], "put_unweighted_pred_avg_%d_%d", width, bit_depth))
                UNWEIGHTED_PRED_AVG(dst0, dst1, src0, src1, width, bit_depth);
            if (check_func(h->put_unweighted_pred_avg_chroma[i], "put_unweighted_pred_avg_%d_%d", width / 2, bit_depth))
                UNWEIGHTED_PRED_AVG(dst0, dst1, src0, src1, width, bit_depth);
        }
    }
}
Exemplo n.º 2
0
Arquivo: dcadsp.c Projeto: AVLeo/libav
void checkasm_check_dcadsp(void)
{
    DCADSPContext c;

    ff_dcadsp_init(&c);

    /* values are limited to {-8, 8} so absolute epsilon is good enough */
    if (check_func(c.lfe_fir[0], "dca_lfe_fir0"))
        check_lfe_fir(32, 1.0e-6f);

    if (check_func(c.lfe_fir[1], "dca_lfe_fir1"))
        check_lfe_fir(64, 1.0e-6f);

    report("dcadsp");
}
Exemplo n.º 3
0
static void check_add_bytes(LLVidDSPContext c, int width)
{
    uint8_t *src0 = av_mallocz(width);
    uint8_t *src1 = av_mallocz(width);
    uint8_t *dst0 = av_mallocz(width);
    uint8_t *dst1 = av_mallocz(width);
    declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, ptrdiff_t w);

    if (!src0 || !src1 || !dst0 || !dst1)
        fail();

    randomize_buffers(src0, width);
    memcpy(src1, src0, width);

    if (check_func(c.add_bytes, "add_bytes")) {
        call_ref(dst0, src0, width);
        call_new(dst1, src1, width);
        if (memcmp(dst0, dst1, width))
            fail();
        bench_new(dst1, src1, width);
    }

    av_free(src0);
    av_free(src1);
    av_free(dst0);
    av_free(dst1);
}
Exemplo n.º 4
0
static void check_add_res(HEVCDSPContext h, int bit_depth)
{
    int i;
    LOCAL_ALIGNED(32, int16_t, res0, [32 * 32]);
    LOCAL_ALIGNED(32, int16_t, res1, [32 * 32]);
    LOCAL_ALIGNED(32, uint8_t, dst0, [32 * 32 * 2]);
    LOCAL_ALIGNED(32, uint8_t, dst1, [32 * 32 * 2]);

    for (i = 2; i <= 5; i++) {
        int block_size = 1 << i;
        int size = block_size * block_size;
        ptrdiff_t stride = block_size << (bit_depth > 8);
        declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *res, ptrdiff_t stride);

        randomize_buffers(res0, size);
        randomize_buffers2(dst0, size);
        memcpy(res1, res0, sizeof(*res0) * size);
        memcpy(dst1, dst0, size);

        if (check_func(h.add_residual[i - 2], "add_res_%dx%d_%d", block_size, block_size, bit_depth)) {
            call_ref(dst0, res0, stride);
            call_new(dst1, res1, stride);
            if (memcmp(dst0, dst1, size))
                fail();
            bench_new(dst1, res1, stride);
        }
    }
}
Exemplo n.º 5
0
void
seq_test (const char *file_name, void *buf, size_t size, size_t initial_size,
          size_t (*block_size_func) (void),
          void (*check_func) (int fd, long ofs))
{
  size_t ofs;
  int fd;

  random_bytes (buf, size);
  CHECK (create (file_name, initial_size), "create \"%s\"", file_name);
  CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);

  ofs = 0;
  msg ("writing \"%s\"", file_name);
  while (ofs < size)
    {
      size_t block_size = block_size_func ();
      if (block_size > size - ofs)
        block_size = size - ofs;

      if (write (fd, buf + ofs, block_size) != (int) block_size)
        fail ("write %zu bytes at offset %zu in \"%s\" failed",
              block_size, ofs, file_name);

      ofs += block_size;
      if (check_func != NULL)
        check_func (fd, ofs);
    }
  msg ("close \"%s\"", file_name);
  close (fd);
  check_file (file_name, buf, size);
}
Exemplo n.º 6
0
void* check_through_list_element( dlist *destlist, list_ele_compare check_func )
{
	dlist *listitem;
	void *eleret; 

	ASSERT( NULL != destlist );

	listitem = destlist;
	if( listitem == NULL )
	{
		ASSERT( FALSE ); 
		return NULL; 
	}

	listitem = listitem->next;
	if( listitem == NULL )
	{
		ASSERT( FALSE ); 
		return NULL; 
	}

	eleret = listitem->info; 
	for( ; NULL != listitem->next; listitem = listitem->next )
	{
		eleret = check_func( eleret, listitem->next->info );  
	}

	ASSERT( eleret != NULL ); 
	return eleret;
}
Exemplo n.º 7
0
				static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
					tracking.use(1);
					bool success = check_func(L, index) == 1;
					if (!success) {
						// expected type, actual type
						handler(L, index, expected, type_of(L, index));
					}
					return success;
				}
Exemplo n.º 8
0
static void check_weighted_pred(HEVCDSPContext *h, uint8_t *dst0, uint8_t *dst1,
                                int16_t *src0, int16_t *src1, int bit_depth)
{
    uint8_t denom;
    int16_t weight0, weight1, offset0, offset1;
    int i;

    randomize_buffers(src0, BUF_SIZE, 8);
    randomize_buffers(src1, BUF_SIZE, 8);

    denom   = rnd() & 7;
    weight0 = denom + ((rnd() & 255) - 128);
    weight1 = denom + ((rnd() & 255) - 128);
    offset0 = (rnd() & 255) - 128;
    offset1 = (rnd() & 255) - 128;

    memset(dst0, 0, BUF_SIZE * sizeof(*dst0));
    memset(dst1, 0, BUF_SIZE * sizeof(*dst1));

    for (i = 0; i < FF_ARRAY_ELEMS(pred_widths); i++) {
        const int width = pred_widths[i];
        const int srcstride = FFALIGN(width, 16) * sizeof(*src0);
        const int dststride = FFALIGN(width, 16) * PIXEL_SIZE(bit_depth);

        {
            declare_func(void, uint8_t denom, int16_t weight, int16_t offset,
                         uint8_t *dst, ptrdiff_t dststride, int16_t *src, ptrdiff_t srcstride, int height);
            if (check_func(h->weighted_pred[i], "weighted_pred_%d_%d", width, bit_depth))
                WEIGHTED_PRED(dst0, dst1, src0, width, bit_depth);
            if (check_func(h->weighted_pred_chroma[i], "weighted_pred_%d_%d", width / 2, bit_depth))
                WEIGHTED_PRED(dst0, dst1, src0, width, bit_depth);
        }
        {
            declare_func(void, uint8_t denom, int16_t weight0, int16_t weight1, int16_t offset0, int16_t offset1,
                         uint8_t *dst, ptrdiff_t dststride, int16_t *src0, int16_t *src1, ptrdiff_t srcstride, int height);
            if (check_func(h->weighted_pred_avg[i], "weighted_pred_avg_%d_%d", width, bit_depth))
                WEIGHTED_PRED_AVG(dst0, dst1, src0, src1, width, bit_depth);
            if (check_func(h->weighted_pred_avg_chroma[i], "weighted_pred_avg_%d_%d", width / 2, bit_depth))
                WEIGHTED_PRED_AVG(dst0, dst1, src0, src1, width, bit_depth);
        }
    }
}
Exemplo n.º 9
0
static void
run_check_for_file (const gchar * filename, CheckTagsFunc * check_func)
{
  GstTagList *tags;

  /* first, pull-based */
  tags = read_tags_from_file (filename, FALSE);
  fail_unless (tags != NULL, "Failed to extract tags from '%s'", filename);
  check_func (tags, filename);
  gst_tag_list_unref (tags);

  /* FIXME: need to fix id3demux for short content in push mode */
#if 0
  /* now try push-based */
  tags = read_tags_from_file (filename, TRUE);
  fail_unless (tags != NULL, "Failed to extract tags from '%s'", filename);
  check_func (tags, filename);
  gst_tag_list_unref (tags);
#endif
}
Exemplo n.º 10
0
int main(int argc, char * argv[])
{
    DB * db = new MariaDB();

    if(check_func(db) == false)
        return 0;

    delete db;

    return 0;
}
Exemplo n.º 11
0
 int check_node(ast::abstract::Node* node) {
     assert(node != nullptr);
     switch(*node) {
     case ast::ExternNode:
         return EXIT_SUCCESS;
     case ast::FuncNode:
         return check_func(dynamic_cast<ast::Func*>(node));
         break;
     }
     assert(false);
     return EXIT_SUCCESS;
 }
Exemplo n.º 12
0
void checkasm_check_afir(void)
{
    LOCAL_ALIGNED_32(float, src0, [LEN*2+8]);
    LOCAL_ALIGNED_32(float, src1, [LEN*2+8]);
    LOCAL_ALIGNED_32(float, src2, [LEN*2+8]);
    AudioFIRDSPContext fir = { 0 };

    ff_afir_init(&fir);

    randomize_buffer(src0);
    randomize_buffer(src1);
    randomize_buffer(src2);

    if (check_func(fir.fcmul_add, "fcmul_add"))
        test_fcmul_add(src0, src1, src2);
    report("fcmul_add");
}
Exemplo n.º 13
0
static void check_qpel(HEVCDSPContext *h, int16_t *dst0, int16_t *dst1,
                       uint8_t *src, int16_t *mcbuffer, int bit_depth)
{
    int i, j, k, l, mx, my;

    declare_func(void, int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
                 int height, int mx, int my, int16_t *mcbuffer);

    randomize_buffers(src, BUF_SIZE, bit_depth);

    memset(dst0, 0, BUF_SIZE * sizeof(*dst0));
    memset(dst1, 0, BUF_SIZE * sizeof(*dst1));

    for (i = 0; i < 2; i++) {
        for (j = 0; j < 2; j++) {
            for (k = 0; k < FF_ARRAY_ELEMS(h->put_hevc_qpel[i][j]); k++) {
                int width = pred_widths[k];
                int dststride = FFALIGN(width, 16) * sizeof(*dst0);
                int srcstride = FFALIGN(width + 7, 8) * PIXEL_SIZE(bit_depth);

                if (!check_func(h->put_hevc_qpel[i][j][k], "qpel_%s_%d_%d", interp_names[i][j], width, bit_depth))
                    continue;

                for (l = 0; l < FF_ARRAY_ELEMS(pred_heights[0]); l++) {
                    int height = pred_heights[width][l];

                    if (!height)
                        continue;

                    for (my = i; my < (i ? 2 : 1); my++)
                        for (mx = j; mx < (j ? 2 : 1); mx++) {
                            call_ref(dst0, dststride, src + 3 * srcstride + 3 * PIXEL_SIZE(bit_depth), srcstride, height, mx, my, mcbuffer);
                            call_new(dst1, dststride, src + 3 * srcstride + 3 * PIXEL_SIZE(bit_depth), srcstride, height, mx, my, mcbuffer);

                            if (memcmp(dst0, dst1, dststride * height * sizeof(*dst0)))
                                fail();

                            bench_new(dst1, dststride, src + 3 * srcstride + 3 * PIXEL_SIZE(bit_depth), srcstride, height, mx, my, mcbuffer);
                        }
                }
            }
        }
    }
}
Exemplo n.º 14
0
static void check_idct_dc(HEVCDSPContext h, int bit_depth)
{
    int i;
    LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]);
    LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]);

    for (i = 2; i <= 5; i++) {
        int block_size = 1 << i;
        int size = block_size * block_size;
        declare_func_emms(AV_CPU_FLAG_MMXEXT, void, int16_t *coeffs);

        randomize_buffers(coeffs0, size);
        memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size);

        if (check_func(h.idct_dc[i - 2], "idct_%dx%d_dc_%d", block_size, block_size, bit_depth)) {
            call_ref(coeffs0);
            call_new(coeffs1);
            if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size))
                fail();
            bench_new(coeffs1);
        }
    }
}
Exemplo n.º 15
0
/**
 * telnet_check_suboption:
 * @self: 
 * @ep: 
 *
 * 
 *
 * Returns:
 * 
 */
static guint
telnet_check_suboption(TelnetProxy *self, guint ep)
{
  guint                 res;
  TelnetOptionFunction  check_func;
  ZIOBuffer             *sbuf = &self->suboptions[ep];
  gchar                 buf[TELNET_BUFFER_SIZE + 1];
  guint                 i, j;

  z_proxy_enter(self);
  /* check if allowed in this session */
  if (!(self->options[self->opneg_option[ep]][OTHER_EP(ep)] & (SENT_WILL | GOT_DO)) &&
      !(self->options[self->opneg_option[ep]][ep] & (SENT_WILL | GOT_DO)))
    {
      z_proxy_log(self, TELNET_VIOLATION, 3, "Option not allowed in the session; option='%d'", self->opneg_option[ep]);
      z_proxy_return(self, TELNET_CHECK_ABORT);
    }

  /* check if valid */
  if ((check_func = self->telnet_options[self->opneg_option[ep]]) == NULL)
    {
      /* option has no suboption check function */
      /* copy suboption negotiation buffer into policy_value */
      for (j = 0, i = sbuf->ofs; i < sbuf->end; j++, i++)
          buf[j] = sbuf->buf[i];
      g_string_assign(self->policy_name, "");
      g_string_assign(self->policy_value, buf);
      /* call policy check */
      res = telnet_policy_suboption(self, (guchar) buf[0], "", buf);
    }
  else
    {
      /* call check function, and check function calls policy */
      res = check_func(self, ep);
    }
  z_proxy_return(self, res);
}
Exemplo n.º 16
0
void config_list_save_ex(FILE *f, const struct config_list *clist, void *config_data, int save_all,
	bool (*check_func)(const struct config_list *clist, void *config_data, const char *setting))
{
	const struct config_list *c;
	for (c = clist; c->opt_type != OPT_UNKNOWN; c++) {
		void *var = config_data + c->var_offset;
		if (check_func && c->opt_type != OPT_UNKNOWN) {
			if (!check_func(clist, config_data, c->config_name))
				continue;
		}
		switch (c->opt_type) {
		case OPT_INT8: {
			int8_t val = *(int8_t *)var;
			if (save_all || val != c->def.d_int8)
				fprintf_conf(f, c->config_name, "%d\n", val);
			continue;
		}
		case OPT_UINT8: {
			uint8_t val = *(uint8_t *)var;
			if (save_all || val != c->def.d_uint8)
				fprintf_conf(f, c->config_name, "%u\n", val);
			continue;
		}
		case OPT_INT32: {
			int32_t val = *(int32_t *)var;
			if (save_all || val != c->def.d_int32)
				fprintf_conf(f, c->config_name, "%d\n", val);
			continue;
		}
		case OPT_UINT32: {
			uint32_t val = *(uint32_t *)var;
			if (save_all || val != c->def.d_uint32)
				fprintf_conf(f, c->config_name, "%u\n", val);
			continue;
		}
		case OPT_STRING: {
			char **val = var;
			if (save_all || !streq(*val, c->def.d_char)) {
				fprintf_conf(f, c->config_name, "%s\n", *val ? *val : "");
			}
			continue;
		}
		case OPT_SSTRING: {
			char *val = var;
			if (save_all || !streq(val, c->def.d_char)) {
				fprintf_conf(f, c->config_name, "%s\n", val[0] ? val : "");
			}
			continue;
		}
		case OPT_FUNC: {
			c->ops.process_fn((const char *)c->config_name, NULL, var, f);
			continue;
		}
		case OPT_FUNC_EXTRA: {
			c->ops.process_fn_extra((const char *)c->config_name, NULL, var, c->def.d_extra, f);
			continue;
		}
		case OPT_FIXUP_FUNC:
		case OPT_SAVE_FUNC:
			continue;
		case OPT_UNKNOWN:
			break;
		}
	}
}
Exemplo n.º 17
0
/*
 * check_memmove -- invoke check function with pmem_memcpy_persist
 */
static void
check_memcpy(void *dest, void *src, size_t len)
{
	check_func(dest, src, len, pmem_memcpy_persist);
}
Exemplo n.º 18
0
int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
			    int (*check_func)(struct btrfs_fs_info *, u8 *, u8,
					      u64))
{
	struct btrfs_root *root = fs_info->uuid_root;
	struct btrfs_key key;
	struct btrfs_path *path;
	int ret = 0;
	struct extent_buffer *leaf;
	int slot;
	u32 item_size;
	unsigned long offset;

	path = btrfs_alloc_path();
	if (!path) {
		ret = -ENOMEM;
		goto out;
	}

	key.objectid = 0;
	key.type = 0;
	key.offset = 0;

again_search_slot:
	ret = btrfs_search_forward(root, &key, path, BTRFS_OLDEST_GENERATION);
	if (ret) {
		if (ret > 0)
			ret = 0;
		goto out;
	}

	while (1) {
		cond_resched();
		leaf = path->nodes[0];
		slot = path->slots[0];
		btrfs_item_key_to_cpu(leaf, &key, slot);

		if (key.type != BTRFS_UUID_KEY_SUBVOL &&
		    key.type != BTRFS_UUID_KEY_RECEIVED_SUBVOL)
			goto skip;

		offset = btrfs_item_ptr_offset(leaf, slot);
		item_size = btrfs_item_size_nr(leaf, slot);
		if (!IS_ALIGNED(item_size, sizeof(u64))) {
			btrfs_warn(fs_info,
				   "uuid item with illegal size %lu!",
				   (unsigned long)item_size);
			goto skip;
		}
		while (item_size) {
			u8 uuid[BTRFS_UUID_SIZE];
			__le64 subid_le;
			u64 subid_cpu;

			put_unaligned_le64(key.objectid, uuid);
			put_unaligned_le64(key.offset, uuid + sizeof(u64));
			read_extent_buffer(leaf, &subid_le, offset,
					   sizeof(subid_le));
			subid_cpu = le64_to_cpu(subid_le);
			ret = check_func(fs_info, uuid, key.type, subid_cpu);
			if (ret < 0)
				goto out;
			if (ret > 0) {
				btrfs_release_path(path);
				ret = btrfs_uuid_iter_rem(root, uuid, key.type,
							  subid_cpu);
				if (ret == 0) {
					/*
					 * this might look inefficient, but the
					 * justification is that it is an
					 * exception that check_func returns 1,
					 * and that in the regular case only one
					 * entry per UUID exists.
					 */
					goto again_search_slot;
				}
				if (ret < 0 && ret != -ENOENT)
					goto out;
			}
			item_size -= sizeof(subid_le);
			offset += sizeof(subid_le);
		}

skip:
		ret = btrfs_next_item(root, path);
		if (ret == 0)
			continue;
		else if (ret > 0)
			ret = 0;
		break;
	}

out:
	btrfs_free_path(path);
	return ret;
}
Exemplo n.º 19
0
void config_list_save_ex(FILE *f, const struct config_list *clist, void *config_data, int save_all,
						 bool (*check_func)(const struct config_list *clist, void *config_data, const char *setting))
{
	const struct config_list *c;
	for(c = clist; c->opt_type != OPT_UNKNOWN; c++)
	{
		void *var = config_data + c->var_offset;
		if(check_func && c->opt_type != OPT_UNKNOWN)
		{
			if(!check_func(clist, config_data, c->config_name))
				{ continue; }
		}
		switch(c->opt_type)
		{
		case OPT_INT8:
		{
			int8_t val = *(int8_t *)var;
			if(save_all || val != c->def.d_int8)
				{ fprintf_conf(f, c->config_name, "%d\n", val); }
			continue;
		}
		case OPT_UINT8:
		{
			uint8_t val = *(uint8_t *)var;
			if(save_all || val != c->def.d_uint8)
				{ fprintf_conf(f, c->config_name, "%u\n", val); }
			continue;
		}
		case OPT_INT32:
		{
			int32_t val;
			memcpy(&val, var, sizeof(int32_t));
			if(save_all || val != c->def.d_int32)
				{ fprintf_conf(f, c->config_name, "%d\n", val); }
			continue;
		}
		case OPT_UINT32:
		{
			uint32_t val;
			memcpy(&val, var, sizeof(uint32_t));
			if(save_all || val != c->def.d_uint32)
				{ fprintf_conf(f, c->config_name, "%u\n", val); }
			continue;
		}
		case OPT_STRING:
		{
			char **val = var;
			if(save_all || !streq(*val, c->def.d_char))
			{
				fprintf_conf(f, c->config_name, "%s\n", *val ? *val : "");
			}
			continue;
		}
		case OPT_SSTRING:
		{
			char *val = var;
			if(save_all || !streq(val, c->def.d_char))
			{
				fprintf_conf(f, c->config_name, "%s\n", val[0] ? val : "");
			}
			continue;
		}
		case OPT_HEX_ARRAY:
		{
			uint8_t *hex_array = var;
			uint32_t ok = check_filled(hex_array, c->def.array_size);
			if(save_all || ok)
			{
				fprintf_conf(f, c->config_name, "%s", ""); // it should not have \n at the end
				if(ok)
				{
					for(ok = 0; ok < c->def.array_size; ok++)
					{
						fprintf(f, "%02X", hex_array[ok]);
					}
				}
				fprintf(f, "\n");
			}
			continue;
		}
		case OPT_FUNC:
		{
			c->ops.process_fn((const char *)c->config_name, NULL, var, f);
			continue;
		}
		case OPT_FUNC_EXTRA:
		{
			c->ops.process_fn_extra((const char *)c->config_name, NULL, var, c->def.d_extra, f);
			continue;
		}
		case OPT_FIXUP_FUNC:
		case OPT_SAVE_FUNC:
			continue;
		case OPT_UNKNOWN:
			break;
		}
	}
}
Exemplo n.º 20
0
/*
 * check_memmove -- invoke check function with pmem_memmove_persist
 */
void
check_memmove(void *dest, void *src, size_t len)
{
	check_func(dest, src, len, pmem_memmove_persist);
}