示例#1
0
文件: vszimg.c 项目: theomission/zimg
static int graph_unpack_yuy2(void *user, unsigned i, unsigned left, unsigned right)
{
	struct callback_data *cb = user;
	const uint8_t *yuy2 = buffer_get_line_const(&cb->plane_buf.c, 0, i);
	uint8_t *planar_y = buffer_get_line(&cb->line_buf.m, 0, i);
	uint8_t *planar_u = buffer_get_line(&cb->line_buf.m, 1, i);
	uint8_t *planar_v = buffer_get_line(&cb->line_buf.m, 2, i);
	unsigned j;

	left = left % 2 ? left - 1 : left;
	right = right % 2 ? right + 1 : right;

	for (j = left; j < right; j += 2) {
		uint8_t y0, y1, u, v;

		y0 = yuy2[j * 2 + 0];
		u = yuy2[j * 2 + 1];
		y1 = yuy2[j * 2 + 2];
		v = yuy2[j * 2 + 3];

		planar_y[j + 0] = y0;
		planar_y[j + 1] = y1;
		planar_u[j / 2] = u;
		planar_v[j / 2] = v;
	}

	return 0;
}
示例#2
0
文件: vszimg.c 项目: theomission/zimg
static int graph_unpack_bgr32(void *user, unsigned i, unsigned left, unsigned right)
{
	struct callback_data *cb = user;
	const uint8_t *bgr32 = buffer_get_line_const(&cb->plane_buf.c, 0, cb->height - i - 1);
	uint8_t *planar_r = buffer_get_line(&cb->line_buf.m, 0, i);
	uint8_t *planar_g = buffer_get_line(&cb->line_buf.m, 1, i);
	uint8_t *planar_b = buffer_get_line(&cb->line_buf.m, 2, i);
	unsigned j;

	for (j = left; j < right; ++j) {
		uint8_t r, g, b;

		b = bgr32[j * 4 + 0];
		g = bgr32[j * 4 + 1];
		r = bgr32[j * 4 + 2];

		planar_r[j] = r;
		planar_g[j] = g;
		planar_b[j] = b;
	}

	return 0;
}
示例#3
0
文件: vim.c 项目: alex-vim/neovim
/// Return the current line
///
/// @param[out] err Details of an error that may have occurred
/// @return The current line string
String vim_get_current_line(Error *err)
{
  return buffer_get_line(curbuf->handle, curwin->w_cursor.lnum - 1, err);
}
示例#4
0
文件: test.c 项目: adsr/a
/**
 * Test basic buffer edits
 */
char* test_buffer_simple() {
    buffer_t* b;
    int line_size;
    int line_len;
    char* line;
    int ret_line;
    int ret_col;

    line_size = 1024;
    line = (char*)calloc(line_size + 1, sizeof(char));

    b = buffer_new();
    ATTO_TEST_ASSERT(b->line_count == 1, "line_count should be 1");
    ATTO_TEST_ASSERT(b->byte_count == 0, "byte_count should be 0");
    ATTO_TEST_ASSERT(b->blines[0].offset == 0, "line 0 should start at offset 0");

    buffer_get_line(b, 0, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 0, "line 0 len should be 0");

    buffer_insert(b, 0, "Test line 1", 11, NULL, NULL, &ret_col);
    ATTO_TEST_ASSERT(b->line_count == 1, "line_count should still be 1");
    ATTO_TEST_ASSERT(b->byte_count == 11, "byte_count should be 11");
    ATTO_TEST_ASSERT(b->blines[0].offset == 0, "line 0 should still start at offset 0");
    ATTO_TEST_ASSERT(ret_col == 11, "ret_col should be 11");

    buffer_get_line(b, 0, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 11, "line 0 len should be 11");
    ATTO_TEST_ASSERT(!strncmp(line, "Test line 1", line_len), "line 0 should contain: Test line 1");

    buffer_insert(b, 11, "\n", 1, NULL, NULL, NULL);
    ATTO_TEST_ASSERT(b->line_count == 2, "line_count should be 2 now");
    ATTO_TEST_ASSERT(b->byte_count == 12, "byte_count should be 12");
    ATTO_TEST_ASSERT(b->blines[1].offset == 12, "line 1 should start at offset 12");

    buffer_get_line(b, 1, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 0, "line 1 len should be 0");

    buffer_insert(b, 11, "\n", 1, NULL, NULL, NULL);
    ATTO_TEST_ASSERT(b->line_count == 3, "line_count should be 3 now");
    ATTO_TEST_ASSERT(b->byte_count == 13, "byte_count should be 13");
    ATTO_TEST_ASSERT(b->blines[2].offset == 13, "line 2 should start at offset 13");

    buffer_get_line(b, 1, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 0, "line 1 len should still be 0");

    buffer_get_line(b, 2, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 0, "line 2 len should be 0");

    buffer_insert(b, 13, "a", 1, NULL, &ret_line, &ret_col);
    ATTO_TEST_ASSERT(ret_line == 2, "ret_line should be 2");
    ATTO_TEST_ASSERT(ret_col == 1, "ret_col should be 1");

    buffer_get_line(b, 2, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 1, "line 2 len should now be 1");
    ATTO_TEST_ASSERT(!strncmp(line, "a", line_len), "line 2 should contain: a");

    buffer_insert(b, 13, "!", 1, NULL, &ret_line, &ret_col);
    buffer_get_line(b, 2, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 2, "line 2 len should now be 2");
    ATTO_TEST_ASSERT(!strncmp(line, "!a", line_len), "line 2 should contain: !a");

    buffer_delete(b, 13, 1);
    buffer_get_line(b, 2, 0, line, line_size, &line, &line_len);
    ATTO_TEST_ASSERT(line_len == 1, "line 2 len should be 1 again");

    free(line);
    buffer_destroy(b);
    return NULL;
}