libcdio-paranoia 10.2+2.0.2
p_block.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2004, 2005, 2008 Rocky Bernstein <rocky@gnu.org>
3 Copyright (C) 2014 Robert Kausch <robert.kausch@freac.org>
4 Copyright (C) by Monty (xiphmont@mit.edu)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef _P_BLOCK_H_
21#define _P_BLOCK_H_
22
24#include <cdio/paranoia/cdda.h>
25
26#define MIN_WORDS_OVERLAP 64 /* 16 bit words */
27#define MIN_WORDS_SEARCH 64 /* 16 bit words */
28#define MIN_WORDS_RIFT 16 /* 16 bit words */
29#define MAX_SECTOR_OVERLAP 32 /* sectors */
30#define MIN_SECTOR_EPSILON 128 /* words */
31#define MIN_SECTOR_BACKUP 16 /* sectors */
32#define JIGGLE_MODULO 15 /* sectors */
33#define MIN_SILENCE_BOUNDARY 1024 /* 16 bit words */
34#define CACHEMODEL_SECTORS 1200
35
36#define min(x,y) ((x)>(y)?(y):(x))
37#define max(x,y) ((x)<(y)?(y):(x))
38
39#include "isort.h"
40
41typedef struct {
42 /* linked list */
45
46 void *(*new_poly)();
47 void (*free_poly)(void *poly);
48 long current;
49 long active;
50
52
53typedef struct linked_element{
54 void *ptr;
57
59 int stamp;
61
62extern linked_list_t *new_list(void *(*new_fn)(void),void (*free)(void *));
64extern linked_element *add_elem(linked_list_t *list,void *elem);
65extern void free_list(linked_list_t *list,int free_ptr); /* unlink or free */
66extern void free_elem(linked_element *e,int free_ptr); /* unlink or free */
67extern void *get_elem(linked_element *e);
68
69/* This is a shallow copy; it doesn't copy contained structures */
70extern linked_list_t *copy_list(linked_list_t *p_list);
71
72typedef struct c_block {
73 /* The buffer */
74 int16_t *vector;
75 long begin;
76 long size;
77
78 /* auxiliary support structures */
79 unsigned char *flags; /* 1 known boundaries in read data
80 2 known blanked data
81 4 matched sample
82 8 reserved
83 16 reserved
84 32 reserved
85 64 reserved
86 128 reserved
87 */
88
89 /* end of session cases */
93
95
96extern void free_c_block(c_block_t *c);
97extern void i_cblock_destructor(c_block_t *c);
99
100typedef struct v_fragment_s {
102
103 long begin;
104 long size;
105 int16_t *vector;
106
107 /* end of session cases */
109
110 /* linked list */
113
115
116extern void free_v_fragment(v_fragment_t *c);
118 long int begin, long int end,
119 int lastsector);
120extern int16_t *v_buffer(v_fragment_t *v);
121
124extern c_block_t *c_next(c_block_t *c);
125extern c_block_t *c_prev(c_block_t *c);
126
131
132typedef struct root_block{
136
137 c_block_t *vector; /* doesn't use any sorting */
141
142typedef struct offsets{
143
148 long offmin;
149 long offmax;
150
152
155
156 root_block root; /* verified/reconstructed cached data */
157 linked_list_t *cache; /* our data as read from the cdrom */
158 long int cache_limit;
159 linked_list_t *fragments; /* fragments of blocks that have been 'verified' */
161
162 /* cache tracking */
166 int jitter;
167
169 long int cursor;
172
173 /* statistics for drift/overlap */
176
179
180 /* statistics for verification */
181
182};
183
184extern c_block_t *c_alloc(int16_t *vector,long begin,long size);
185extern void c_set(c_block_t *v,long begin);
186extern void c_insert(c_block_t *v,long pos,int16_t *b,long size);
187extern void c_remove(c_block_t *v,long cutpos,long cutsize);
188extern void c_overwrite(c_block_t *v,long pos,int16_t *b,long size);
189extern void c_append(c_block_t *v, int16_t *vector, long size);
190extern void c_removef(c_block_t *v, long cut);
191
192#define ce(v) (v->begin+v->size)
193#define cb(v) (v->begin)
194#define cs(v) (v->size)
195
196/* pos here is vector position from zero */
197
198extern void recover_cache(cdrom_paranoia_t *p);
200
201#define cv(c) (c->vector)
202
203#define fe(f) (f->begin+f->size)
204#define fb(f) (f->begin)
205#define fs(f) (f->size)
206#define fv(f) (v_buffer(f))
207
208#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
210#define linked_list linked_list_t
211#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
212
213#define CDP_COMPILE
214#endif /*_P_BLOCK_H_*/
215
The top-level interface header for libcdio_cdda. Applications include this for paranoia access.
void i_paranoia_firstlast(cdrom_paranoia_t *p)
Definition: p_block.c:375
void free_c_block(c_block_t *c)
Definition: p_block.c:134
void c_remove(c_block_t *v, long cutpos, long cutsize)
Definition: p_block.c:313
void free_v_fragment(v_fragment_t *c)
Definition: p_block.c:187
struct offsets offsets
v_fragment_t * v_last(cdrom_paranoia_t *p)
Definition: p_block.c:234
void i_cblock_destructor(c_block_t *c)
Definition: p_block.c:114
void c_set(c_block_t *v, long begin)
Definition: p_block.c:288
void recover_cache(cdrom_paranoia_t *p)
Definition: p_block.c:258
c_block_t * c_next(c_block_t *c)
Definition: p_block.c:209
void c_append(c_block_t *v, int16_t *vector, long size)
Definition: p_block.c:339
struct v_fragment_s v_fragment_t
linked_list_t * copy_list(linked_list_t *p_list)
Definition: p_block.c:92
struct root_block root_block
v_fragment_t * v_first(cdrom_paranoia_t *p)
Definition: p_block.c:225
v_fragment_t * v_prev(v_fragment_t *v)
Definition: p_block.c:250
struct c_block c_block_t
c_block_t * c_prev(c_block_t *c)
Definition: p_block.c:217
void free_list(linked_list_t *list, int free_ptr)
Definition: p_block.c:80
linked_element * new_elem(linked_list_t *list)
Definition: p_block.c:53
c_block_t * c_first(cdrom_paranoia_t *p)
Definition: p_block.c:193
void free_elem(linked_element *e, int free_ptr)
Definition: p_block.c:60
void c_removef(c_block_t *v, long cut)
Definition: p_block.c:355
void c_overwrite(c_block_t *v, long pos, int16_t *b, long size)
Definition: p_block.c:328
void * get_elem(linked_element *e)
Definition: p_block.c:87
c_block_t * c_last(cdrom_paranoia_t *p)
Definition: p_block.c:201
v_fragment_t * v_next(v_fragment_t *v)
Definition: p_block.c:242
void c_insert(c_block_t *v, long pos, int16_t *b, long size)
Definition: p_block.c:294
int16_t * v_buffer(v_fragment_t *v)
Definition: p_block.c:270
linked_list_t * new_list(void *(*new_fn)(void), void(*free)(void *))
Definition: p_block.c:24
linked_element * add_elem(linked_list_t *list, void *elem)
Definition: p_block.c:32
v_fragment_t * new_v_fragment(cdrom_paranoia_t *p, c_block_t *one, long int begin, long int end, int lastsector)
Definition: p_block.c:162
c_block_t * new_c_block(cdrom_paranoia_t *p)
Definition: p_block.c:125
struct linked_element linked_element
c_block_t * c_alloc(int16_t *vector, long begin, long size)
Definition: p_block.c:279
The top-level header for libcdda_paranoia: a device- and OS- independent library for reading CD-DA wi...
paranoia_cb_mode_t
Definition: paranoia.h:70
Definition: p_block.h:72
struct linked_element * e
Definition: p_block.h:92
cdrom_paranoia_t * p
Definition: p_block.h:91
unsigned char * flags
Definition: p_block.h:79
long lastsector
Definition: p_block.h:90
long begin
Definition: p_block.h:75
long size
Definition: p_block.h:76
int16_t * vector
Definition: p_block.h:74
Structure for cdparanoia's CD-ROM access.
Definition: cdda.h:80
Definition: p_block.h:153
long dyndrift
Definition: p_block.h:178
struct offsets stage1
Definition: p_block.h:174
int cdcache_size
Definition: p_block.h:163
long int current_firstsector
Definition: p_block.h:171
long dynoverlap
Definition: p_block.h:177
long int cursor
Definition: p_block.h:169
linked_list_t * fragments
Definition: p_block.h:159
sort_info_t * sortcache
Definition: p_block.h:160
cdrom_drive_t * d
Definition: p_block.h:154
long int current_lastsector
Definition: p_block.h:170
int cdcache_end
Definition: p_block.h:165
int cdcache_begin
Definition: p_block.h:164
long int cache_limit
Definition: p_block.h:158
int jitter
Definition: p_block.h:166
paranoia_cb_mode_t enable
Definition: p_block.h:168
struct offsets stage2
Definition: p_block.h:175
root_block root
Definition: p_block.h:156
linked_list_t * cache
Definition: p_block.h:157
Definition: p_block.h:53
struct linked_element * next
Definition: p_block.h:56
struct linked_element * prev
Definition: p_block.h:55
int stamp
Definition: p_block.h:59
linked_list_t * list
Definition: p_block.h:58
void * ptr
Definition: p_block.h:54
Definition: p_block.h:41
struct linked_element * tail
Definition: p_block.h:44
struct linked_element * head
Definition: p_block.h:43
long active
Definition: p_block.h:49
long current
Definition: p_block.h:48
Definition: p_block.h:142
long offpoints
Definition: p_block.h:144
long offmax
Definition: p_block.h:149
long offaccum
Definition: p_block.h:146
long offmin
Definition: p_block.h:148
long newpoints
Definition: p_block.h:145
long offdiff
Definition: p_block.h:147
Definition: p_block.h:132
long silencebegin
Definition: p_block.h:139
long lastsector
Definition: p_block.h:134
cdrom_paranoia_t * p
Definition: p_block.h:135
c_block_t * vector
Definition: p_block.h:137
long returnedlimit
Definition: p_block.h:133
int silenceflag
Definition: p_block.h:138
Definition: isort.h:28
Definition: p_block.h:100
long begin
Definition: p_block.h:103
int16_t * vector
Definition: p_block.h:105
struct linked_element * e
Definition: p_block.h:112
c_block_t * one
Definition: p_block.h:101
long size
Definition: p_block.h:104
cdrom_paranoia_t * p
Definition: p_block.h:111
long lastsector
Definition: p_block.h:108