1 package org
.diracvideo
.Jirac
;
2 import java
.awt
.Dimension
;
5 /* static array of wavelets */
6 private static Wavelet
[] wavs
= {
7 new DeslauriesDebuc9_7(),
9 new DeslauriesDebuc13_7(),
11 new HaarSingleShift(),
17 /* Wavelet transform parameters */
18 public int transformDepth
= 4, wavelet_index
;
19 public int codeblock_mode_index
= 0;
20 public boolean no_ac
, is_ref
, is_lowdelay
, is_intra
;
21 public int[] horiz_codeblocks
= new int[7],
22 vert_codeblocks
= new int[7];
24 public Dimension iwtLumaSize
, iwtChromaSize
;
25 /* Motion prediction parametrs */
26 public int xblen_luma
, yblen_luma
,
27 xbsep_luma
, ybsep_luma
;
28 public int x_num_blocks
, y_num_blocks
,
30 public boolean have_global_motion
;
31 public int picture_prediction_mode
, mv_precision
;
32 public int picture_weight_bits
= 1,
33 picture_weight_1
= 1,picture_weight_2
= 1;
34 public Global global
[] = new Global
[2];
36 public Parameters(int c
) {
37 no_ac
= !((c
& 0x48) == 0x8);
39 is_ref
= (c
& 0x0c) == 0x0c;
40 is_lowdelay
= ((c
& 0x88) == 0x88);
41 is_intra
= (num_refs
== 0);
44 public void calculateIwtSizes(VideoFormat format
) {
46 format
.getPictureLumaSize(size
);
47 iwtLumaSize
= new Dimension(Util
.roundUpPow2(size
[0], transformDepth
),
48 Util
.roundUpPow2(size
[1], transformDepth
));
49 format
.getPictureChromaSize(size
);
50 iwtChromaSize
= new Dimension(Util
.roundUpPow2(size
[0], transformDepth
),
51 Util
.roundUpPow2(size
[1], transformDepth
));
54 public void verifyBlockParams() throws Exception
{
56 ok
= ok
&& xblen_luma
>= 0;
57 ok
= ok
&& yblen_luma
>= 0;
58 ok
= ok
&& xbsep_luma
>= 0;
59 ok
= ok
&& ybsep_luma
>= 0;
61 throw new Exception("Block Paramters incorrect");
65 public void setBlockParams(int i
)
69 xblen_luma
= yblen_luma
= 8;
70 xbsep_luma
= ybsep_luma
= 4;
73 xblen_luma
= yblen_luma
= 12;
74 xbsep_luma
= ybsep_luma
= 8;
77 xblen_luma
= yblen_luma
= 16;
78 xbsep_luma
= ybsep_luma
= 12;
81 xblen_luma
= yblen_luma
= 24;
82 xbsep_luma
= ybsep_luma
= 16;
85 throw new Exception("Unsupported Block Parameters index");
90 public void calculateMCSizes() {
91 x_num_blocks
= 4*Util
.divideRoundUp(iwtLumaSize
.width
, 4*xbsep_luma
);
92 y_num_blocks
= 4*Util
.divideRoundUp(iwtLumaSize
.height
, 4*ybsep_luma
);
93 x_offset
= (xblen_luma
- xbsep_luma
)/2;
94 y_offset
= (yblen_luma
- ybsep_luma
)/2;
97 public Wavelet
getWavelet() {
98 return wavs
[wavelet_index
];
101 public String
toString() {
102 StringBuilder sb
= new StringBuilder();
103 sb
.append("\nParameters:\n");
104 sb
.append(String
.format("Transform depth: %d\n", transformDepth
));
105 sb
.append(String
.format("Using ac: %c\n", (no_ac ?
'n' : 'y')));
106 sb
.append(String
.format("Is ref: %c", (is_ref ?
'y' : 'n')));
107 for(int i
= 0; i
< transformDepth
; i
++) {
108 sb
.append(String
.format("\nHorizBlocks: %d\tVertBlocks: %d",
109 horiz_codeblocks
[i
], vert_codeblocks
[i
]));
111 sb
.append(String
.format("\nxblen: %d\t yblen: %d", xblen_luma
, yblen_luma
));
112 sb
.append(String
.format("\nxbsep: %d\t ybsep: %d", xbsep_luma
, ybsep_luma
));
113 return sb
.toString();