Ansel
0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
pixel/format.c
Go to the documentation of this file.
1
/*
2
This file is part of darktable,
3
Copyright (C) 2016 Roman Lebedev.
4
Copyright (C) 2018 Edgardo Hoszowski.
5
Copyright (C) 2019 Hanno Schwalm.
6
Copyright (C) 2020 Pascal Obry.
7
Copyright (C) 2022 Martin BaĆinka.
8
Copyright (C) 2022 Philipp Lutz.
9
10
darktable is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
darktable is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with darktable. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
/* The two helpers that operate on dt_iop_buffer_dsc_t alone, moved here from
25
* develop/format.c so that the definitions sit beside the declarations in pixel/format.h.
26
*
27
* The other three functions that header used to declare -- default_input_format(),
28
* default_output_format() and default_blend_colorspace() -- could NOT come with them: they
29
* take dt_iop_module_t and dt_dev_pixelpipe_t, which develop/ owns. Moving those down would
30
* have dragged layer 5 into layer 2. Their declarations moved up to develop/imageop.h
31
* instead, which is the same fix in the other direction.
32
*/
33
34
#include "
pixel/format.h
"
35
36
#include "
system/macros.h
"
37
38
#include <stddef.h>
39
#include <stdint.h>
40
41
void
dt_iop_buffer_dsc_update_bpp
(
dt_iop_buffer_dsc_t
*dsc)
42
{
43
dsc->
bpp
= dsc->
channels
;
44
45
switch
(dsc->
datatype
)
46
{
47
case
TYPE_FLOAT
:
48
dsc->
bpp
*=
sizeof
(float);
49
break
;
50
case
TYPE_UINT16
:
51
dsc->
bpp
*=
sizeof
(uint16_t);
52
break
;
53
case
TYPE_UINT8
:
54
dsc->
bpp
*=
sizeof
(uint8_t);
55
break
;
56
case
TYPE_UNKNOWN
:
57
dsc->
bpp
= 0;
58
break
;
59
default
:
60
dt_unreachable_codepath
();
61
break
;
62
}
63
}
64
65
size_t
dt_iop_buffer_dsc_to_bpp
(
const
struct
dt_iop_buffer_dsc_t
*dsc)
66
{
67
return
dsc->
bpp
;
68
}
69
70
// clang-format off
71
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
72
// vim: shiftwidth=2 expandtab tabstop=2 cindent
73
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
74
// clang-format on
format.h
TYPE_FLOAT
@ TYPE_FLOAT
Definition
format.h:56
TYPE_UNKNOWN
@ TYPE_UNKNOWN
Definition
format.h:55
TYPE_UINT8
@ TYPE_UINT8
Definition
format.h:58
TYPE_UINT16
@ TYPE_UINT16
Definition
format.h:57
macros.h
dt_unreachable_codepath
#define dt_unreachable_codepath()
Definition
macros.h:76
dt_iop_buffer_dsc_to_bpp
size_t dt_iop_buffer_dsc_to_bpp(const struct dt_iop_buffer_dsc_t *dsc)
Definition
pixel/format.c:65
dt_iop_buffer_dsc_update_bpp
void dt_iop_buffer_dsc_update_bpp(dt_iop_buffer_dsc_t *dsc)
Definition
pixel/format.c:41
dt_iop_buffer_dsc_t
Definition
format.h:81
dt_iop_buffer_dsc_t::channels
unsigned int channels
Definition
format.h:83
dt_iop_buffer_dsc_t::bpp
size_t bpp
Definition
format.h:87
dt_iop_buffer_dsc_t::datatype
dt_iop_buffer_type_t datatype
Definition
format.h:85
src
pixel
format.c
Generated by
1.9.8