-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscm-file.hpp
117 lines (82 loc) · 3.22 KB
/
scm-file.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright (C) 2011-2012 Robert Kooima
//
// LIBSCM is free software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITH-
// OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
#ifndef SCM_FILE_HPP
#define SCM_FILE_HPP
#include <string>
#include <vector>
#include <tiffio.h>
#include <SDL.h>
#include <SDL_thread.h>
#include "scm-queue.hpp"
#include "scm-guard.hpp"
#include "scm-task.hpp"
#include "scm-sample.hpp"
//------------------------------------------------------------------------------
typedef std::vector<SDL_Thread *> thread_v;
typedef std::vector<SDL_Thread *>::iterator thread_i;
//------------------------------------------------------------------------------
/// An scm_file encapsulates an open SCM data file.
class scm_file
{
public:
scm_file(const std::string&,
const std::string&);
virtual ~scm_file();
void activate(scm_cache *);
void deactivate();
bool is_active() const;
bool add_need(scm_task&);
virtual bool get_page_status(uint64) const;
virtual uint64 get_page_offset(uint64) const;
virtual void get_page_bounds(uint64, float&, float&) const;
virtual float get_page_sample(const double *);
virtual uint32 get_w() const { return w; }
virtual uint32 get_h() const { return h; }
virtual uint16 get_c() const { return c; }
virtual uint16 get_b() const { return b; }
const char *get_path() const { return path.c_str(); }
const char *get_name() const { return name.c_str(); }
uint64 find_page(long long, double&, double&) const;
protected:
std::string path;
std::string name;
private:
// IO handling and threading data
scm_cache *cache;
scm_queue<scm_task> needs;
scm_guard<bool> active;
scm_sample *sampler;
thread_v threads;
// Image parameters
uint32 w; ///< Page width
uint32 h; ///< Page height
uint16 c; ///< Sample count
uint16 b; ///< Sample depth
uint64 *xv; ///< Page indices
uint64 xc; ///< Page indices count
uint64 *ov; ///< Page offsets
uint64 oc; ///< Page offsets count
void *av; ///< Page minima
uint64 ac; ///< Page minima count
void *zv; ///< Page maxima
uint64 zc; ///< Page maxima count
float tofloat(const void *, uint64) const;
void fromfloat(const void *, uint64, float) const;
uint64 toindex(uint64) const;
friend int loader(void *);
};
//------------------------------------------------------------------------------
/// @file
bool scm_load_page(const char *, long long,
TIFF *, uint64, int, int, int, int, void *);
//------------------------------------------------------------------------------
#endif