OpenJPH
Open-source implementation of JPEG2000 Part-15
ojph_params_local.h
Go to the documentation of this file.
1//***************************************************************************/
2// This software is released under the 2-Clause BSD license, included
3// below.
4//
5// Copyright (c) 2019, Aous Naman
6// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
7// Copyright (c) 2019, The University of New South Wales, Australia
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// 1. Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// 2. Redistributions in binary form must reproduce the above copyright
17// notice, this list of conditions and the following disclaimer in the
18// documentation and/or other materials provided with the distribution.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31//***************************************************************************/
32// This file is part of the OpenJPH software implementation.
33// File: ojph_params_local.h
34// Author: Aous Naman
35// Date: 28 August 2019
36//***************************************************************************/
37
38
39#ifndef OJPH_PARAMS_LOCAL_H
40#define OJPH_PARAMS_LOCAL_H
41
42#include <cstring>
43#include <cassert>
44
45#include "ojph_defs.h"
46#include "ojph_base.h"
47#include "ojph_arch.h"
48#include "ojph_message.h"
49
50namespace ojph {
51
53 class outfile_base;
54 class infile_base;
55
58 {
63 OJPH_PO_CPRL = 4
64 };
65
67 const char OJPH_PO_STRING_LRCP[] = "LRCP";
68 const char OJPH_PO_STRING_RLCP[] = "RLCP";
69 const char OJPH_PO_STRING_RPCL[] = "RPCL";
70 const char OJPH_PO_STRING_PCRL[] = "PCRL";
71 const char OJPH_PO_STRING_CPRL[] = "CPRL";
72
75 {
84 OJPH_PN_IMF = 8
85 };
86
88 const char OJPH_PN_STRING_PROFILE0[] = "PROFILE0";
89 const char OJPH_PN_STRING_PROFILE1[] = "PROFILE1";
90 const char OJPH_PN_STRING_CINEMA2K[] = "CINEMA2K";
91 const char OJPH_PN_STRING_CINEMA4K[] = "CINEMA4K";
92 const char OJPH_PN_STRING_CINEMAS2K[] = "CINEMAS2K";
93 const char OJPH_PN_STRING_CINEMAS4K[] = "CINEMAS4K";
94 const char OJPH_PN_STRING_BROADCAST[] = "BROADCAST";
95 const char OJPH_PN_STRING_IMF[] = "IMF";
96
99 OJPH_TILEPART_NO_DIVISIONS = 0x0, // no divisions to tile parts
102 OJPH_TILEPART_LAYERS = 0x4, // these are meaningless with HTJ2K
103 };
104
105 namespace local {
106
107 //defined here
108 struct param_siz;
109 struct param_cod;
110 struct param_qcd;
111 struct param_qcc;
112 struct param_cap;
113 struct param_sot;
114 struct param_tlm;
115 struct param_dfs;
116 struct param_atk;
117
120 {
121 SOC = 0xFF4F, //start of codestream (required)
122 CAP = 0xFF50, //extended capability
123 SIZ = 0xFF51, //image and tile size (required)
124 COD = 0xFF52, //coding style default (required)
125 COC = 0xFF53, //coding style component
126 TLM = 0xFF55, //tile-part lengths
127 PRF = 0xFF56, //profile
128 PLM = 0xFF57, //packet length, main header
129 PLT = 0xFF58, //packet length, tile-part header
130 CPF = 0xFF59, //corresponding profile values
131 QCD = 0xFF5C, //qunatization default (required)
132 QCC = 0xFF5D, //quantization component
133 RGN = 0xFF5E, //region of interest
134 POC = 0xFF5F, //progression order change
135 PPM = 0xFF60, //packed packet headers, main header
136 PPT = 0xFF61, //packed packet headers, tile-part header
137 CRG = 0xFF63, //component registration
138 COM = 0xFF64, //comment
139 DFS = 0xFF72, //downsampling factor styles
140 ADS = 0xFF73, //arbitrary decomposition styles
141 NLT = 0xFF76, //non-linearity point transformation
142 ATK = 0xFF79, //arbitrary transformation kernels
143 SOT = 0xFF90, //start of tile-part
144 SOP = 0xFF91, //start of packet
145 EPH = 0xFF92, //end of packet
146 SOD = 0xFF93, //start of data
147 EOC = 0xFFD9, //end of codestream (required)
148 };
149
151 //
152 //
153 //
154 //
155 //
158 {
162 };
163
166 {
167 friend ::ojph::param_siz;
168
169 public:
170 enum : ui16 {
172 RSIZ_HT_FLAG = 0x4000,
174 };
175
176 public:
178 {
179 Lsiz = Csiz = 0;
180 Xsiz = Ysiz = XOsiz = YOsiz = XTsiz = YTsiz = XTOsiz = YTOsiz = 0;
182 memset(store, 0, sizeof(store));
184 cod = NULL;
185 dfs = NULL;
187 cptr = store;
188 old_Csiz = 4;
189 }
190
192 {
193 if (cptr != store) delete[] cptr;
194 }
195
196 void set_num_components(ui32 num_comps)
197 {
198 Csiz = (ui16)num_comps;
199 if (Csiz > old_Csiz)
200 {
201 if (cptr != store)
202 delete[] cptr;
203 cptr = new siz_comp_info[num_comps];
204 old_Csiz = Csiz;
205 }
206 memset(cptr, 0, sizeof(local::siz_comp_info) * num_comps);
207 }
208
209 void set_comp_info(ui32 comp_num, const point& downsampling,
210 ui32 bit_depth, bool is_signed)
211 {
212 assert(comp_num < Csiz);
213 assert(downsampling.x != 0 && downsampling.y != 0);
214 cptr[comp_num].SSiz = (ui8)(bit_depth - 1 + (is_signed ? 0x80 : 0));
215 cptr[comp_num].XRsiz = (ui8)downsampling.x;
216 cptr[comp_num].YRsiz = (ui8)downsampling.y;
217 }
218
220 {
221 this->cod = &cod;
222
223 if (XTsiz == 0 && YTsiz == 0)
224 { XTsiz = Xsiz + XOsiz; YTsiz = Ysiz + YOsiz; }
225 if (Xsiz == 0 || Ysiz == 0 || XTsiz == 0 || YTsiz == 0)
226 OJPH_ERROR(0x00040001,
227 "You cannot set image extent nor tile size to zero");
228 if (XTOsiz > XOsiz || YTOsiz > YOsiz)
229 OJPH_ERROR(0x00040002,
230 "tile offset has to be smaller than image offset");
231 if (XTsiz + XTOsiz <= XOsiz || YTsiz + YTOsiz <= YOsiz)
232 OJPH_ERROR(0x00040003,
233 "the top left tile must intersect with the image");
234 }
235
236 ui16 get_num_components() const { return Csiz; }
237 ui32 get_bit_depth(ui32 comp_num) const
238 {
239 assert(comp_num < Csiz);
240 return (cptr[comp_num].SSiz & 0x7F) + 1u;
241 }
242 bool is_signed(ui32 comp_num) const
243 {
244 assert(comp_num < Csiz);
245 return (cptr[comp_num].SSiz & 0x80) != 0;
246 }
248 {
249 assert(comp_num < Csiz);
250 return point(cptr[comp_num].XRsiz, cptr[comp_num].YRsiz);
251 }
252
253 bool write(outfile_base *file);
254 void read(infile_base *file);
255
256 void link(const param_cod* cod)
257 { this->cod = cod; }
258
259 void link(const param_dfs* dfs)
260 { this->dfs = dfs; }
261
263 { this->skipped_resolutions = skipped_resolutions; }
264
265 ui32 get_width(ui32 comp_num) const
266 {
267 assert(comp_num < get_num_components());
268 ui32 ds = (ui32)cptr[comp_num].XRsiz;
269 ui32 t = ojph_div_ceil(Xsiz, ds) - ojph_div_ceil(XOsiz, ds);
270 return t;
271 }
272
273 ui32 get_height(ui32 comp_num) const
274 {
275 assert(comp_num < get_num_components());
276 ui32 ds = (ui32)cptr[comp_num].YRsiz;
277 ui32 t = ojph_div_ceil(Ysiz, ds) - ojph_div_ceil(YOsiz, ds);
278 return t;
279 }
280
281 point get_recon_downsampling(ui32 comp_num) const;
282 point get_recon_size(ui32 comp_num) const;
283 ui32 get_recon_width(ui32 comp_num) const
284 { return get_recon_size(comp_num).x; }
285 ui32 get_recon_height(ui32 comp_num) const
286 { return get_recon_size(comp_num).y; }
287
290
292 { Rsiz |= flag; }
294 { Rsiz = (ui16)(Rsiz & ~flag); }
295
296 private:
309
310 private:
318 param_siz(const param_siz&) = delete; //prevent copy constructor
319 param_siz& operator=(const param_siz&) = delete; //prevent copy
320 };
321
323 //
324 //
325 //
326 //
327 //
330 {
336 ui8 precinct_size[33]; //num_decomp is in [0,32]
337
339 { return size(block_width + 2, block_height + 2); }
341 { size t = get_log_block_dims(); return size(1 << t.w, 1 << t.h); }
343 {
344 assert(res_num <= num_decomp);
345 size ps(precinct_size[res_num] & 0xF, precinct_size[res_num] >> 4);
346 return ps;
347 }
348 };
349
352 {
356 };
357
360 {
361 // serves for both COD and COC markers
362
363 friend ::ojph::param_cod;
367 HT_MODE = 0x40
368 };
370 enum cod_type : ui8 {
375 COC_TILE = 4
376 };
378 enum dwt_type : ui8 {
381 };
382
383 public: // COD_MAIN and COC_MAIN common functions
386 {
387 memset(this, 0, sizeof(param_cod));
390 SGCod.num_layers = 1;
391 SGCod.mc_trans = 0;
392 SPcod.num_decomp = 5;
393 SPcod.block_width = 4; //64
394 SPcod.block_height = 4; //64
395 next = NULL;
396 }
397
399 void set_reversible(bool reversible)
400 {
401 assert(type == UNDEFINED || type == COD_MAIN);
402 type = COD_MAIN;
403 SPcod.wavelet_trans = reversible ? DWT_REV53 : DWT_IRV97;
404 }
405
408 {
409 assert(val == 0 || val == 1);
410 assert(type == UNDEFINED || type == COD_MAIN);
411 type = COD_MAIN;
412 SGCod.mc_trans = val;
413 }
414
416 void check_validity(const param_siz& siz)
417 {
418 assert(type == UNDEFINED || type == COD_MAIN);
419 type = COD_MAIN;
420
421 //check that colour transform and match number of components and
422 // downsampling
423 int num_comps = siz.get_num_components();
424 if (SGCod.mc_trans == 1 && num_comps < 3)
425 OJPH_ERROR(0x00040011,
426 "color transform can only be employed when the image has 3 or "
427 "more color components");
428
429 if (SGCod.mc_trans == 1)
430 {
431 bool test = false;
432 point p = siz.get_downsampling(0);
433 for (ui32 i = 1; i < 3; ++i)
434 {
435 point p1 = siz.get_downsampling(i);
436 test = test || (p.x != p1.x || p.y != p1.y);
437 }
438 if (test)
439 OJPH_ERROR(0x00040012,
440 "when color transform is used, the first 3 colour "
441 "components must have the same downsampling.");
442 }
443
444 //check the progression order matches downsampling
445 if (SGCod.prog_order == 2 || SGCod.prog_order == 3)
446 {
447 ui32 num_comps = siz.get_num_components();
448 for (ui32 i = 0; i < num_comps; ++i)
449 {
450 point r = siz.get_downsampling(i);
451 if (r.x & (r.x - 1) || r.y & (r.y - 1))
452 OJPH_ERROR(0x00040013, "For RPCL and PCRL progression orders,"
453 "component downsampling factors have to be powers of 2");
454 }
455 }
456 }
457
460 {
461 if (type == COD_MAIN)
462 return SPcod.num_decomp;
463 else if (type == COC_MAIN)
464 {
465 if (is_dfs_defined())
467 else
468 return SPcod.num_decomp;
469 }
470 else {
471 assert(0);
472 return 0; // just in case
473 }
474 }
475
478 { return SPcod.get_block_dims(); }
479
482 { return SPcod.get_log_block_dims(); }
483
486 { return SPcod.wavelet_trans; }
487
490 { return (SGCod.mc_trans == 1); }
491
494 {
495 size t = get_log_precinct_size(res_num);
496 return size(1 << t.w, 1 << t.h);
497 }
498
501 {
502 if (Scod & 1)
503 return SPcod.get_log_precinct_size(res_num);
504 else
505 return size(15, 15);
506 }
507
510 {
511 if (parent)
512 return (parent->Scod & 2) == 2;
513 else
514 return (Scod & 2) == 2;
515 }
516
518 bool packets_use_eph() const
519 {
520 if (parent)
521 return (parent->Scod & 4) == 4;
522 else
523 return (Scod & 4) == 4;
524 }
525
527 ui32 propose_precision(const param_siz* siz, ui32 comp_num) const;
528
530 bool write(outfile_base *file);
531
533 void read(infile_base *file, cod_type type);
534
536 void read(infile_base* file, cod_type type, ui32 num_comps,
537 param_cod* cod);
538
540 void update_atk(const param_atk* atk);
541
543 void link_cod(const param_cod* coc)
544 { this->next = coc; }
545
548 {
549 const param_cod* result = this->next;
550 while (result != NULL && result->get_comp_num() != comp_num)
551 result = result->next;
552 if (result)
553 return result;
554 else
555 return this;
556 }
557
559 const param_atk* access_atk() const { return atk; }
560
561 public: // COC_MAIN only functions
563 bool is_dfs_defined() const
564 { return (SPcod.num_decomp & 0x80) != 0; }
565
567 ui16 get_dfs_index() const // cannot be more than 15
568 { return SPcod.num_decomp & 0xF; }
569
572 { assert(type == COC_MAIN); return comp_num; }
573
574 private: // Common variables
575 cod_type type; // The type of this cod structure
576 ui16 Lcod; // serves as Lcod and Scod
577 ui8 Scod; // serves as Scod and Scoc
578 cod_SGcod SGCod; // Used in COD and copied to COC
579 cod_SPcod SPcod; // serves as SPcod and SPcoc
580 const param_cod* next;// to chain coc parameters to cod
581 const param_atk* atk; // used to read transform information
582
583 private: // COC only variables
584 param_cod* parent; // parent COD structure
585 ui16 comp_num; // component index of this COC structure
586 };
587
589 //
590 //
591 //
592 //
593 //
596 {
597 friend ::ojph::param_qcd;
598 public:
600 {
601 Lqcd = 0;
602 Sqcd = 0;
603 memset(u16_SPqcd, 0, sizeof(u16_SPqcd));
604 num_subbands = 0;
605 base_delta = -1.0f;
606 }
607
608 void set_delta(float delta) { base_delta = delta; }
609
610 void check_validity(const param_siz& siz, const param_cod& cod)
611 {
612 ui32 num_decomps = cod.get_num_decompositions();
613 num_subbands = 1 + 3 * num_decomps;
615 {
616 ui32 bit_depth = 0;
617 for (ui32 i = 0; i < siz.get_num_components(); ++i)
618 bit_depth = ojph_max(bit_depth, siz.get_bit_depth(i));
619 set_rev_quant(num_decomps, bit_depth,
621 }
622 else if (cod.get_wavelet_kern() == param_cod::DWT_IRV97)
623 {
624 if (base_delta == -1.0f) {
625 ui32 bit_depth = 0;
626 for (ui32 i = 0; i < siz.get_num_components(); ++i)
627 bit_depth =
628 ojph_max(bit_depth, siz.get_bit_depth(i) + siz.is_signed(i));
629 base_delta = 1.0f / (float)(1 << bit_depth);
630 }
631 set_irrev_quant(num_decomps);
632 }
633 else
634 assert(0);
635 }
636 ui32 get_num_guard_bits() const;
637 ui32 get_MAGBp() const;
638 ui32 get_Kmax(const param_dfs* dfs, ui32 num_decompositions,
639 ui32 resolution, ui32 subband) const;
640 float irrev_get_delta(const param_dfs* dfs,
641 ui32 num_decompositions,
642 ui32 resolution, ui32 subband) const;
643
644 bool write(outfile_base *file);
645 void read(infile_base *file);
646
647 protected:
648 void set_rev_quant(ui32 num_decomps, ui32 bit_depth,
649 bool is_employing_color_transform);
650 void set_irrev_quant(ui32 num_decomps);
651
653 { return (ui8)(v >> 3); }
655 { return (ui8)(v << 3); }
656 protected:
659 union
660 {
663 };
664 ui32 num_subbands; // number of subbands
665 float base_delta; // base quantization step size -- all other
666 // step sizes are derived from it.
667 };
668
670 //
671 //
672 //
673 //
674 //
676 struct param_qcc : public param_qcd
677 {
678 public:
680 { comp_idx = 0; }
681
683 void read(infile_base *file, ui32 num_comps);
684
685 protected:
687 };
688
690 //
691 //
692 //
693 //
694 //
696 // data structures used by param_nlt
698 {
700 public:
702 Lnlt = 6;
703 Cnlt = special_comp_num::ALL_COMPS; // default
704 BDnlt = 0;
705 Tnlt = 3;
706 enabled = false; next = NULL; alloced_next = false;
707 }
708
710 if (next && alloced_next) {
711 delete next;
712 alloced_next = false;
713 next = NULL;
714 }
715 }
716
717 void check_validity(param_siz& siz);
718 void set_type3_transformation(ui32 comp_num, bool enable);
719 bool get_type3_transformation(ui32 comp_num, ui8& bit_depth,
720 bool& is_signed) const;
721 bool write(outfile_base* file) const;
722 void read(infile_base* file);
723
724 private:
725 const param_nlt* get_comp_object(ui32 comp_num) const;
726 param_nlt* get_comp_object(ui32 comp_num);
727 param_nlt* add_object(ui32 comp_num);
728 bool is_any_enabled() const;
729 void trim_non_existing_components(ui32 num_comps);
730
731 private:
732 ui16 Lnlt; // length of the marker segment excluding marker
733 ui16 Cnlt; // Component involved in the transformation
734 ui8 BDnlt; // Decoded image component bit depth parameter
735 ui8 Tnlt; // Type of non-linearity
736 bool enabled; // true if this object is used
737 param_nlt* next; // for chaining NLT markers
738 bool alloced_next; // true if next was allocated, not just set to an
739 // existing object
740
741 // The top level param_nlt object is not allocated, but as part of
742 // codestream, and is used to manage allocated next objects.
743 // next holds a list of param_nlt objects, which are managed by the top
744 // param_nlt object.
745 };
746
748 //
749 //
750 //
751 //
752 //
755 {
756 public:
758 {
759 memset(this, 0, sizeof(param_cap));
760 Lcap = 8;
761 Pcap = 0x00020000; //for jph, Pcap^15 must be set, the 15th MSB
762 }
763
764 void check_validity(const param_cod& cod, const param_qcd& qcd)
765 {
767 Ccap[0] &= 0xFFDF;
768 else
769 Ccap[0] |= 0x0020;
770 Ccap[0] &= 0xFFE0;
771 ui32 Bp = 0;
772 ui32 B = qcd.get_MAGBp();
773 if (B <= 8)
774 Bp = 0;
775 else if (B < 28)
776 Bp = B - 8;
777 else if (B < 48)
778 Bp = 13 + (B >> 2);
779 else
780 Bp = 31;
781 Ccap[0] = (ui16)(Ccap[0] | (ui16)Bp);
782 }
783
784 bool write(outfile_base *file);
785 void read(infile_base *file);
786
787 private:
790 ui16 Ccap[32]; //a maximum of 32
791 };
792
793
795 //
796 //
797 //
798 //
799 //
802 {
803 public:
804 void init(ui32 payload_length = 0, ui16 tile_idx = 0,
805 ui8 tile_part_index = 0, ui8 num_tile_parts = 0)
806 {
807 Lsot = 10;
808 Psot = payload_length + 12; //total = payload + SOT marker
809 Isot = tile_idx;
810 TPsot = tile_part_index;
811 TNsot = num_tile_parts;
812 }
813
814 bool write(outfile_base *file, ui32 payload_len);
815 bool write(outfile_base *file, ui32 payload_len, ui8 TPsot, ui8 TNsot);
816 bool read(infile_base *file, bool resilient);
817
818 ui16 get_tile_index() const { return Isot; }
819 ui32 get_payload_length() const { return Psot > 0 ? Psot - 12 : 0; }
820 ui8 get_tile_part_index() const { return TPsot; }
821 ui8 get_num_tile_parts() const { return TNsot; }
822
823 private:
829 };
830
832 //
833 //
834 //
835 //
836 //
839 {
841 {
844 };
845
846 public:
847 param_tlm() { pairs = NULL; num_pairs = 0; next_pair_index = 0; };
848 void init(ui32 num_pairs, Ttlm_Ptlm_pair* store);
849
850 void set_next_pair(ui16 Ttlm, ui32 Ptlm);
851 bool write(outfile_base *file);
852
853 private:
860 };
861
863 //
864 //
865 //
866 //
867 //
870 {
871 public:
873 NO_DWT = 0, // no wavelet transform
874 BIDIR_DWT = 1, // bidirectional DWT (this the conventional DWT)
875 HORZ_DWT = 2, // horizontal only DWT transform
876 VERT_DWT = 3, // vertical only DWT transform
877 };
878
879 public: // member functions
881 ~param_dfs() { if (next) delete next; }
882 void init()
883 { Ldfs = Sdfs = Ids = 0; memset(Ddfs, 0, sizeof(Ddfs)); next = NULL; }
884 bool read(infile_base *file);
885 bool exists() const { return Ldfs != 0; }
886
887 // get_dfs return a dfs structure Sdfs == index, or NULL if not found
888 const param_dfs* get_dfs(int index) const;
889 // decomp_level is the decomposition level, starting from 1 for highest
890 // resolution to num_decomps for the coarsest resolution
891 dfs_dwt_type get_dwt_type(ui32 decomp_level) const;
892 ui32 get_subband_idx(ui32 num_decompositions, ui32 resolution,
893 ui32 subband) const;
894 point get_res_downsamp(ui32 skipped_resolutions) const;
895
896 private: // member variables
897 ui16 Ldfs; // length of the segment marker
898 ui16 Sdfs; // index of this DFS marker segment
899 ui8 Ids; // number of elements in Ddfs, 2 bits per sub-level
900 ui8 Ddfs[8]; // a string defining number of decomposition sub-levels
901 // 8 bytes should be enough for 32 levels
902 param_dfs* next; // used for linking other dfs segments
903 };
904
906 //
907 //
908 //
909 //
910 //
912 // data structures used by param_atk
913
915 struct irv_data {
916 // si8 Oatk; // only for arbitrary filter
917 // ui8 LCatk; // number of lifting coefficients in a step
918 float Aatk; // lifting coefficient
919 };
920
921 struct rev_data {
922 // si8 Oatk; // only for arbitrary filter, offset of filter
923 ui8 Eatk; // only for reversible, epsilon, the power of 2
924 si16 Batk; // only for reversible, beta, the additive residue
925 // ui8 LCatk; // number of lifting coefficients in a step
926 si16 Aatk; // lifting coefficient
927 };
928
931 };
932
934 {
935 // Limitations:
936 // Arbitrary filters (ARB) are not supported
937 // Up to 6 steps are supported -- more than 6 are not supported
938 // Only one coefficient per step -- first order filter
939 // Only even-indexed subsequence in first reconstruction step,
940 // m_init = 0 is supported
941
942 public: // member functions
945 if (next && alloced_next) {
946 delete next;
947 next = NULL;
948 }
949 if (d != NULL && d != d_store) {
950 delete[] d;
951 init(false);
952 }
953 }
954 bool read(infile_base *file);
955 bool read_coefficient(infile_base *file, float &K);
956 bool read_coefficient(infile_base *file, si16 &K);
957 void init(bool clear_all = true) {
958 if (clear_all)
959 {
960 Latk = Satk = 0;
961 Katk = 0.0f;
962 Natk = 0;
963 d = NULL;
964 max_steps = 0;
965 memset(d_store, 0, sizeof(d_store));
966 next = NULL;
967 alloced_next = false;
968 }
969 d = d_store; max_steps = sizeof(d_store) / sizeof(lifting_step);
970 }
971 void init_irv97();
972 void init_rev53();
974 { assert(this->next == NULL); this->next = next; alloced_next = false; }
975
976 ui8 get_index() const { return (ui8)(Satk & 0xFF); }
977 int get_coeff_type() const { return (Satk >> 8) & 0x7; }
978 bool is_whole_sample() const { return (Satk & 0x800) != 0; }
979 bool is_reversible() const { return (Satk & 0x1000) != 0; }
980 bool is_m_init0() const { return (Satk & 0x2000) == 0; }
981 bool is_using_ws_extension() const { return (Satk & 0x4000) != 0; }
982 const param_atk* get_atk(int index) const;
983 const lifting_step* get_step(ui32 s) const
984 { assert(s < Natk); return d + s; }
985 ui32 get_num_steps() const { return Natk; }
986 float get_K() const { return Katk; }
987
988 private: // member variables
989 ui16 Latk; // structure length
990 ui16 Satk; // carries a variety of information
991 float Katk; // only for irreversible scaling factor K
992 ui8 Natk; // number of lifting steps
993 lifting_step* d; // pointer to data, initialized to d_store
994 int max_steps; // maximum number of steps without memory allocation
995 lifting_step d_store[6]; // lifting step coefficient
996 param_atk* next; // used for chaining if more than one atk segment
997 // exist in the codestream
998 bool alloced_next; // true if next was allocated, not just set to an
999 // existing object
1000 };
1001 } // !local namespace
1002} // !ojph namespace
1003
1004#endif // !OJPH_PARAMS_LOCAL_H
const char OJPH_PN_STRING_BROADCAST[]
const char OJPH_PN_STRING_CINEMAS4K[]
const char OJPH_PO_STRING_PCRL[]
const char OJPH_PN_STRING_IMF[]
const char OJPH_PN_STRING_CINEMA4K[]
uint16_t ui16
Definition: ojph_defs.h:52
const char OJPH_PO_STRING_RLCP[]
const char OJPH_PN_STRING_CINEMA2K[]
const char OJPH_PO_STRING_RPCL[]
OJPH_TILEPART_DIVISIONS
@ OJPH_TILEPART_RESOLUTIONS
@ OJPH_TILEPART_NO_DIVISIONS
@ OJPH_TILEPART_LAYERS
@ OJPH_TILEPART_COMPONENTS
const char OJPH_PO_STRING_CPRL[]
@ OJPH_PN_PROFILE1
@ OJPH_PN_BROADCAST
@ OJPH_PN_CINEMA4K
@ OJPH_PN_CINEMA2K
@ OJPH_PN_CINEMAS4K
@ OJPH_PN_UNDEFINED
@ OJPH_PN_CINEMAS2K
@ OJPH_PN_PROFILE0
int32_t si32
Definition: ojph_defs.h:55
const char OJPH_PN_STRING_PROFILE0[]
int16_t si16
Definition: ojph_defs.h:53
const char OJPH_PN_STRING_CINEMAS2K[]
uint32_t ui32
Definition: ojph_defs.h:54
uint8_t ui8
Definition: ojph_defs.h:50
const char OJPH_PO_STRING_LRCP[]
const char OJPH_PN_STRING_PROFILE1[]
#define ojph_max(a, b)
Definition: ojph_defs.h:73
#define ojph_div_ceil(a, b)
Definition: ojph_defs.h:70
#define OJPH_ERROR(t,...)
Definition: ojph_message.h:287
size get_log_precinct_size(ui32 res_num) const
const param_atk * get_atk(int index) const
bool read(infile_base *file)
void init(bool clear_all=true)
bool read_coefficient(infile_base *file, float &K)
const lifting_step * get_step(ui32 s) const
void link(param_atk *next)
bool is_using_ws_extension() const
void check_validity(const param_cod &cod, const param_qcd &qcd)
void read(infile_base *file)
bool write(outfile_base *file)
void check_validity(const param_siz &siz)
bool write(outfile_base *file)
void link_cod(const param_cod *coc)
void set_reversible(bool reversible)
const param_cod * get_cod(ui32 comp_num) const
bool is_employing_color_transform() const
void employ_color_transform(ui8 val)
const param_atk * access_atk() const
size get_log_precinct_size(ui32 res_num) const
ui8 get_num_decompositions() const
void read(infile_base *file, cod_type type)
void update_atk(const param_atk *atk)
bool packets_may_use_sop() const
size get_precinct_size(ui32 res_num) const
ui32 propose_precision(const param_siz *siz, ui32 comp_num) const
const param_cod * next
bool read(infile_base *file)
dfs_dwt_type get_dwt_type(ui32 decomp_level) const
point get_res_downsamp(ui32 skipped_resolutions) const
ui32 get_subband_idx(ui32 num_decompositions, ui32 resolution, ui32 subband) const
const param_dfs * get_dfs(int index) const
void set_type3_transformation(ui32 comp_num, bool enable)
bool get_type3_transformation(ui32 comp_num, ui8 &bit_depth, bool &is_signed) const
bool write(outfile_base *file) const
param_nlt * add_object(ui32 comp_num)
void trim_non_existing_components(ui32 num_comps)
void read(infile_base *file)
const param_nlt * get_comp_object(ui32 comp_num) const
void check_validity(param_siz &siz)
bool is_any_enabled() const
void read(infile_base *file, ui32 num_comps)
float irrev_get_delta(const param_dfs *dfs, ui32 num_decompositions, ui32 resolution, ui32 subband) const
ui8 encode_SPqcd(ui8 v) const
void set_rev_quant(ui32 num_decomps, ui32 bit_depth, bool is_employing_color_transform)
void set_irrev_quant(ui32 num_decomps)
ui32 get_num_guard_bits() const
void set_delta(float delta)
void check_validity(const param_siz &siz, const param_cod &cod)
bool write(outfile_base *file)
void read(infile_base *file)
ui32 get_Kmax(const param_dfs *dfs, ui32 num_decompositions, ui32 resolution, ui32 subband) const
ui8 decode_SPqcd(ui8 v) const
void set_skipped_resolutions(ui32 skipped_resolutions)
ui32 get_bit_depth(ui32 comp_num) const
ui32 get_recon_height(ui32 comp_num) const
bool is_signed(ui32 comp_num) const
void check_validity(const param_cod &cod)
bool write(outfile_base *file)
param_siz(const param_siz &)=delete
point get_recon_downsampling(ui32 comp_num) const
void set_Rsiz_flag(ui16 flag)
point get_recon_size(ui32 comp_num) const
ui32 get_height(ui32 comp_num) const
void set_comp_info(ui32 comp_num, const point &downsampling, ui32 bit_depth, bool is_signed)
void link(const param_cod *cod)
point get_downsampling(ui32 comp_num) const
void reset_Rsiz_flag(ui16 flag)
void read(infile_base *file)
param_siz & operator=(const param_siz &)=delete
void link(const param_dfs *dfs)
void set_num_components(ui32 num_comps)
ui32 get_width(ui32 comp_num) const
ui32 get_recon_width(ui32 comp_num) const
void init(ui32 payload_length=0, ui16 tile_idx=0, ui8 tile_part_index=0, ui8 num_tile_parts=0)
bool read(infile_base *file, bool resilient)
bool write(outfile_base *file, ui32 payload_len)
void set_next_pair(ui16 Ttlm, ui32 Ptlm)
bool write(outfile_base *file)
void init(ui32 num_pairs, Ttlm_Ptlm_pair *store)
ui32 w
Definition: ojph_base.h:50
ui32 h
Definition: ojph_base.h:51