int objectVersion = buffer.getByte(index+1); // object_version_number
int objectSequenceOrder = buffer.getByte(index+3); // 8bit first_in_sequence (0x80), last_in_sequence (0x40), 6bits reserved
boolean first = (objectSequenceOrder & 0x80) == 0x80;
boolean last = (objectSequenceOrder & 0x40) == 0x40;
ImageObject imageObject;
if (objectID >= subPictureBD.getImageObjectList().size()) {
imageObject = new ImageObject();
subPictureBD.getImageObjectList().add(imageObject);
} else {
imageObject = subPictureBD.getImageObject(objectID);
}
ImageObjectFragment imageObjectFragment;
if (imageObject.getFragmentList().isEmpty() || first) { // 8bit object_version_number
// skipped:
// 24bit object_data_length - full RLE buffer length (including 4 bytes size info)
int width = buffer.getWord(index + 7); // object_width
int height = buffer.getWord(index + 9); // object_height
if (width <= subPictureBD.getWidth() && height <= subPictureBD.getHeight()) {
imageObjectFragment = new ImageObjectFragment(index + 11, pcsSegment.size - (index + 11 - pcsSegment.offset));
imageObject.getFragmentList().add(imageObjectFragment);
imageObject.setBufferSize(imageObjectFragment.getImagePacketSize());
imageObject.setHeight(height);
imageObject.setWidth(width);
message.append("ID: ").append(objectID).append(", update: ").append(objectVersion).append(", seq: ").append((first ? "first" : "")).append(((first && last) ? "/" : "")).append((last ? "" + "last" : ""));
return true;
} else {
logger.warn("Invalid image size - ignored\n");
return false;
}
} else {
// object_data_fragment
// skipped:
// 16bit object_id
// 8bit object_version_number
// 8bit first_in_sequence (0x80), last_in_sequence (0x40), 6bits reserved
imageObjectFragment = new ImageObjectFragment(index + 4, pcsSegment.size - (index + 4 - pcsSegment.offset));
imageObject.getFragmentList().add(imageObjectFragment);
imageObject.setBufferSize(imageObject.getBufferSize() + imageObjectFragment.getImagePacketSize());
message.append("ID: ").append(objectID).append(", update: ").append(objectVersion).append(", seq: ").append((first ? "first" : "")).append(((first && last) ? "/" : "")).append((last ? "" + "last" : ""));
return false;
}
}