Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
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#include "develop/format.h"
25#include "develop/imageop.h"
26#include "develop/develop.h"
27
29{
30 dsc->bpp = dsc->channels;
31
32 switch(dsc->datatype)
33 {
34 case TYPE_FLOAT:
35 dsc->bpp *= sizeof(float);
36 break;
37 case TYPE_UINT16:
38 dsc->bpp *= sizeof(uint16_t);
39 break;
40 case TYPE_UINT8:
41 dsc->bpp *= sizeof(uint8_t);
42 break;
43 case TYPE_UNKNOWN:
44 dsc->bpp = 0;
45 break;
46 default:
48 break;
49 }
50}
51
53{
54 return dsc->bpp;
55}
56
59{
60 dsc->channels = 4;
61 dsc->datatype = TYPE_FLOAT;
62 dsc->cst = self->default_colorspace(self, pipe, piece);
63
64 if(dsc->cst == IOP_CS_RAW)
65 {
66 if(dt_image_is_raw(&pipe->dev->image_storage)) dsc->channels = 1;
67
69 <= dt_ioppr_get_iop_order(pipe->iop_order_list, "rawprepare", 0)
70 && ((piece && piece->dsc_in.filters) || (!piece && pipe->dev->image_storage.dsc.filters)))
71 dsc->datatype = TYPE_UINT16;
72 }
73}
74
77{
78 dsc->channels = 4;
79 dsc->datatype = TYPE_FLOAT;
80 dsc->cst = self->default_colorspace(self, pipe, piece);
81
82 if(dsc->cst == IOP_CS_RAW)
83 {
84 if(dt_image_is_raw(&pipe->dev->image_storage)) dsc->channels = 1;
85
86 // FIXME: this is shit. Chain it in input/output_format() so each module
87 // actually tells what it does without relying on pipeline-centric hardcoded assumptions
88 // like that.
90 < dt_ioppr_get_iop_order(pipe->iop_order_list, "rawprepare", 0)
91 && ((piece && piece->dsc_in.filters) || (!piece && pipe->dev->image_storage.dsc.filters)))
92 dsc->datatype = TYPE_UINT16;
93 }
94}
95
97 const dt_dev_pixelpipe_iop_t *piece)
98{
99 return self->default_colorspace(self, pipe, piece);
100}
101
102// clang-format off
103// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
104// vim: shiftwidth=2 expandtab tabstop=2 cindent
105// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
106// clang-format on
@ IOP_CS_RAW
gboolean dt_image_is_raw(const dt_image_t *img)
#define dt_unreachable_codepath()
Definition darktable.h:979
void default_output_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
Definition format.c:75
void default_input_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
Definition format.c:57
size_t dt_iop_buffer_dsc_to_bpp(const struct dt_iop_buffer_dsc_t *dsc)
Definition format.c:52
int default_blend_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
Definition format.c:96
void dt_iop_buffer_dsc_update_bpp(dt_iop_buffer_dsc_t *dsc)
Definition format.c:28
@ TYPE_FLOAT
Definition format.h:46
@ TYPE_UNKNOWN
Definition format.h:45
@ TYPE_UINT8
Definition format.h:48
@ TYPE_UINT16
Definition format.h:47
int dt_ioppr_get_iop_order(GList *iop_order_list, const char *op_name, const int multi_priority)
Return the iop_order for a given operation/instance pair.
Definition iop_order.c:868
dt_iop_buffer_dsc_t dsc_in
struct dt_develop_t * dev
dt_image_t image_storage
Definition develop.h:259
dt_iop_buffer_dsc_t dsc
Definition image.h:337
uint32_t filters
Definition format.h:60
unsigned int channels
Definition format.h:54
dt_iop_buffer_type_t datatype
Definition format.h:56
GModule *dt_dev_operation_t op
Definition imageop.h:256