private SubbandAn getNextSubband(int c)
{
int down = 1;
int up = 0;
int direction = down;
SubbandAn nextsb;
nextsb = currentSubband[c];
//If it is the first call to this method
if (nextsb == null)
{
nextsb = getAnSubbandTree(tIdx, c);
//If there is no decomposition level then send the whole image
if (!nextsb.isNode)
{
return nextsb;
}
}
//Find the next subband to send
do
{
//If the current subband is null then break
if (nextsb == null)
{
break;
}
//If the current subband is a leaf then select the next leaf to
//send or go up in the decomposition tree if the leaf was a LL
//one.
else if (!nextsb.isNode)
{
switch (nextsb.orientation)
{
case Subband.WT_ORIENT_HH:
nextsb = (SubbandAn) nextsb.Parent.LH;
direction = down;
break;
case Subband.WT_ORIENT_LH:
nextsb = (SubbandAn) nextsb.Parent.HL;
direction = down;
break;
case Subband.WT_ORIENT_HL:
nextsb = (SubbandAn) nextsb.Parent.LL;
direction = down;
break;
case Subband.WT_ORIENT_LL:
nextsb = (SubbandAn) nextsb.Parent;
direction = up;
break;
}
}
//Else if the current subband is a node
else if (nextsb.isNode)
{
//If the direction is down the select the HH subband of the
//current node.
if (direction == down)
{
nextsb = (SubbandAn) nextsb.HH;
}
//Else the direction is up the select the next node to cover
//or still go up in the decomposition tree if the node is a LL
//subband
else if (direction == up)
{
switch (nextsb.orientation)
{
case Subband.WT_ORIENT_HH:
nextsb = (SubbandAn) nextsb.Parent.LH;
direction = down;
break;
case Subband.WT_ORIENT_LH:
nextsb = (SubbandAn) nextsb.Parent.HL;
direction = down;
break;
case Subband.WT_ORIENT_HL:
nextsb = (SubbandAn) nextsb.Parent.LL;
direction = down;
break;
case Subband.WT_ORIENT_LL:
nextsb = (SubbandAn) nextsb.Parent;
direction = up;
break;
}
}
}
if (nextsb == null)
{
break;
}
}
while (nextsb.isNode);
return nextsb;
}