From c1d5496c96eebeb985ed5ab8ca808df3532814b6 Mon Sep 17 00:00:00 2001 From: David Hilvert Date: Sun, 8 Feb 2009 20:57:18 +0000 Subject: [PATCH] Relegate frame-related functions to a new file, src/frame.c. --- Makefile.am | 2 +- src/frame.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/libale.c | 48 ------------------------------------- 3 files changed, 78 insertions(+), 49 deletions(-) create mode 100644 src/frame.c diff --git a/Makefile.am b/Makefile.am index 63e93d8..f4056bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,7 +41,7 @@ AM_LDFLAGS = -rpath $(libdir) # lib_LTLIBRARIES = libale.la -libale_la_SOURCES = src/libale.c src/context.c +libale_la_SOURCES = src/libale.c src/context.c src/frame.c libale_la_LIBADD = @LIBALE_LIBS@ @LIBALE_LDFLAGS@ libale_la_CFLAGS = $(AM_CFLAGS) @LIBALE_CFLAGS@ include_HEADERS = include/ale.h diff --git a/src/frame.c b/src/frame.c new file mode 100644 index 0000000..50b8ca8 --- /dev/null +++ b/src/frame.c @@ -0,0 +1,77 @@ +/* + * Copyright 2008, 2009 David Hilvert + * + * This file is part of libale. + * + * libale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Affero General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * libale 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 Affero General Public License for + * more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with libale. If not, see . +*/ + +#include "libale.h" + +/* + * API types. + */ + +TYPE(ale_frame, \ + size_t height; \ + size_t width; \ + int bayer; \ + int type; \ + ale_context ac; \ + double exposure; \ + double black; \ + double gamma; \ + cl_mem frame_data;, \ + clReleaseMemObject(this->frame_data);) + +/* + * API Implementation. + */ + +ale_frame ale_new_frame(ale_context ac, size_t width, size_t height, int bayer, int type, cl_mem buffer) { + ale_frame result; + + if (!ale_context_valid(ac)) + return NULL; + + if (buffer == ((cl_mem) 0) || clRetainMemObject(buffer) != CL_SUCCESS) + return NULL; + + result = ale_frame_alloc(); + + if (!result) { + clReleaseMemObject(buffer); + return NULL; + } + + result->exposure = 1.0; + result->gamma = 0.45; + result->black = 0.0; + + result->ac = ac; + result->width = width; + result->height = height; + result->bayer = bayer; + result->type = type; + result->frame_data = buffer; + + return result; +} + +PARAMETER_RW(ale_frame, exposure, double) + +PARAMETER_RW(ale_frame, gamma, double) + +PARAMETER_RW(ale_frame, black, double) + diff --git a/src/libale.c b/src/libale.c index 2cef754..15e855d 100644 --- a/src/libale.c +++ b/src/libale.c @@ -30,18 +30,6 @@ * API types. */ -TYPE(ale_frame, \ - size_t height; \ - size_t width; \ - int bayer; \ - int type; \ - ale_context ac; \ - double exposure; \ - double black; \ - double gamma; \ - cl_mem frame_data;, \ - clReleaseMemObject(this->frame_data);) - TYPE(ale_approx, \ size_t height; \ size_t width; \ @@ -70,42 +58,6 @@ static int type_size(int type) { * API Implementation. */ -ale_frame ale_new_frame(ale_context ac, size_t width, size_t height, int bayer, int type, cl_mem buffer) { - ale_frame result; - - if (!ale_context_valid(ac)) - return NULL; - - if (buffer == ((cl_mem) 0) || clRetainMemObject(buffer) != CL_SUCCESS) - return NULL; - - result = ale_frame_alloc(); - - if (!result) { - clReleaseMemObject(buffer); - return NULL; - } - - result->exposure = 1.0; - result->gamma = 0.45; - result->black = 0.0; - - result->ac = ac; - result->width = width; - result->height = height; - result->bayer = bayer; - result->type = type; - result->frame_data = buffer; - - return result; -} - -PARAMETER_RW(ale_frame, exposure, double) - -PARAMETER_RW(ale_frame, gamma, double) - -PARAMETER_RW(ale_frame, black, double) - cl_mem ale_return(ale_approx aa) { if (!ale_approx_valid(aa)) return ((cl_mem) 0); -- 2.11.4.GIT