Restructure protobuf/add annotations
All checks were successful
Tests / Tests (pull_request) Successful in 14s

This commit is contained in:
2024-05-24 14:28:41 -06:00
parent 044d8fa46d
commit fcac551806
4 changed files with 564 additions and 124 deletions

View File

@@ -1,7 +1,95 @@
export interface Box {
left?: number;
top?: number;
width?: number;
height?: number;
}
export function encodeBox(message: Box): Uint8Array {
let bb = popByteBuffer();
_encodeBox(message, bb);
return toUint8Array(bb);
}
function _encodeBox(message: Box, bb: ByteBuffer): void {
// optional float left = 1;
let $left = message.left;
if ($left !== undefined) {
writeVarint32(bb, 13);
writeFloat(bb, $left);
}
// optional float top = 2;
let $top = message.top;
if ($top !== undefined) {
writeVarint32(bb, 21);
writeFloat(bb, $top);
}
// optional float width = 3;
let $width = message.width;
if ($width !== undefined) {
writeVarint32(bb, 29);
writeFloat(bb, $width);
}
// optional float height = 4;
let $height = message.height;
if ($height !== undefined) {
writeVarint32(bb, 37);
writeFloat(bb, $height);
}
}
export function decodeBox(binary: Uint8Array): Box {
return _decodeBox(wrapByteBuffer(binary));
}
function _decodeBox(bb: ByteBuffer): Box {
let message: Box = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// optional float left = 1;
case 1: {
message.left = readFloat(bb);
break;
}
// optional float top = 2;
case 2: {
message.top = readFloat(bb);
break;
}
// optional float width = 3;
case 3: {
message.width = readFloat(bb);
break;
}
// optional float height = 4;
case 4: {
message.height = readFloat(bb);
break;
}
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface Point {
x?: number;
y?: number;
count?: number;
}
export function encodePoint(message: Point): Uint8Array {
@@ -24,13 +112,6 @@ function _encodePoint(message: Point, bb: ByteBuffer): void {
writeVarint32(bb, 21);
writeFloat(bb, $y);
}
// optional int32 count = 3;
let $count = message.count;
if ($count !== undefined) {
writeVarint32(bb, 24);
writeVarint64(bb, intToLong($count));
}
}
export function decodePoint(binary: Uint8Array): Point {
@@ -59,9 +140,282 @@ function _decodePoint(bb: ByteBuffer): Point {
break;
}
// optional int32 count = 3;
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface BallDetection {
plane_position?: Point;
annotation?: Box;
interpolated?: boolean;
}
export function encodeBallDetection(message: BallDetection): Uint8Array {
let bb = popByteBuffer();
_encodeBallDetection(message, bb);
return toUint8Array(bb);
}
function _encodeBallDetection(message: BallDetection, bb: ByteBuffer): void {
// optional Point plane_position = 1;
let $plane_position = message.plane_position;
if ($plane_position !== undefined) {
writeVarint32(bb, 10);
let nested = popByteBuffer();
_encodePoint($plane_position, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional Box annotation = 2;
let $annotation = message.annotation;
if ($annotation !== undefined) {
writeVarint32(bb, 18);
let nested = popByteBuffer();
_encodeBox($annotation, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional bool interpolated = 3;
let $interpolated = message.interpolated;
if ($interpolated !== undefined) {
writeVarint32(bb, 24);
writeByte(bb, $interpolated ? 1 : 0);
}
}
export function decodeBallDetection(binary: Uint8Array): BallDetection {
return _decodeBallDetection(wrapByteBuffer(binary));
}
function _decodeBallDetection(bb: ByteBuffer): BallDetection {
let message: BallDetection = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// optional Point plane_position = 1;
case 1: {
let limit = pushTemporaryLength(bb);
message.plane_position = _decodePoint(bb);
bb.limit = limit;
break;
}
// optional Box annotation = 2;
case 2: {
let limit = pushTemporaryLength(bb);
message.annotation = _decodeBox(bb);
bb.limit = limit;
break;
}
// optional bool interpolated = 3;
case 3: {
message.count = readVarint32(bb);
message.interpolated = !!readByte(bb);
break;
}
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface RLEBallDetection {
detection?: BallDetection;
count?: number;
}
export function encodeRLEBallDetection(message: RLEBallDetection): Uint8Array {
let bb = popByteBuffer();
_encodeRLEBallDetection(message, bb);
return toUint8Array(bb);
}
function _encodeRLEBallDetection(
message: RLEBallDetection,
bb: ByteBuffer,
): void {
// optional BallDetection detection = 1;
let $detection = message.detection;
if ($detection !== undefined) {
writeVarint32(bb, 10);
let nested = popByteBuffer();
_encodeBallDetection($detection, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional uint32 count = 2;
let $count = message.count;
if ($count !== undefined) {
writeVarint32(bb, 16);
writeVarint32(bb, $count);
}
}
export function decodeRLEBallDetection(binary: Uint8Array): RLEBallDetection {
return _decodeRLEBallDetection(wrapByteBuffer(binary));
}
function _decodeRLEBallDetection(bb: ByteBuffer): RLEBallDetection {
let message: RLEBallDetection = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// optional BallDetection detection = 1;
case 1: {
let limit = pushTemporaryLength(bb);
message.detection = _decodeBallDetection(bb);
bb.limit = limit;
break;
}
// optional uint32 count = 2;
case 2: {
message.count = readVarint32(bb) >>> 0;
break;
}
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface RLEDetectionHistory {
detections?: RLEBallDetection[];
}
export function encodeRLEDetectionHistory(
message: RLEDetectionHistory,
): Uint8Array {
let bb = popByteBuffer();
_encodeRLEDetectionHistory(message, bb);
return toUint8Array(bb);
}
function _encodeRLEDetectionHistory(
message: RLEDetectionHistory,
bb: ByteBuffer,
): void {
// repeated RLEBallDetection detections = 1;
let array$detections = message.detections;
if (array$detections !== undefined) {
for (let value of array$detections) {
writeVarint32(bb, 10);
let nested = popByteBuffer();
_encodeRLEBallDetection(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
}
}
export function decodeRLEDetectionHistory(
binary: Uint8Array,
): RLEDetectionHistory {
return _decodeRLEDetectionHistory(wrapByteBuffer(binary));
}
function _decodeRLEDetectionHistory(bb: ByteBuffer): RLEDetectionHistory {
let message: RLEDetectionHistory = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// repeated RLEBallDetection detections = 1;
case 1: {
let limit = pushTemporaryLength(bb);
let values = message.detections || (message.detections = []);
values.push(_decodeRLEBallDetection(bb));
bb.limit = limit;
break;
}
default:
skipUnknownField(bb, tag & 7);
}
}
return message;
}
export interface DetectionHistory {
detections?: BallDetection[];
}
export function encodeDetectionHistory(message: DetectionHistory): Uint8Array {
let bb = popByteBuffer();
_encodeDetectionHistory(message, bb);
return toUint8Array(bb);
}
function _encodeDetectionHistory(
message: DetectionHistory,
bb: ByteBuffer,
): void {
// repeated BallDetection detections = 1;
let array$detections = message.detections;
if (array$detections !== undefined) {
for (let value of array$detections) {
writeVarint32(bb, 10);
let nested = popByteBuffer();
_encodeBallDetection(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
}
}
export function decodeDetectionHistory(binary: Uint8Array): DetectionHistory {
return _decodeDetectionHistory(wrapByteBuffer(binary));
}
function _decodeDetectionHistory(bb: ByteBuffer): DetectionHistory {
let message: DetectionHistory = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
switch (tag >>> 3) {
case 0:
break end_of_message;
// repeated BallDetection detections = 1;
case 1: {
let limit = pushTemporaryLength(bb);
let values = message.detections || (message.detections = []);
values.push(_decodeBallDetection(bb));
bb.limit = limit;
break;
}
@@ -76,8 +430,10 @@ function _decodePoint(bb: ByteBuffer): Point {
export interface Path {
start_frame?: number;
end_frame?: number;
detections?: DetectionHistory;
rle_detections?: RLEDetectionHistory;
not_present?: boolean;
is_static?: boolean;
points?: Point[];
}
export function encodePath(message: Path): Uint8Array {
@@ -87,39 +443,55 @@ export function encodePath(message: Path): Uint8Array {
}
function _encodePath(message: Path, bb: ByteBuffer): void {
// optional int32 start_frame = 1;
// optional uint32 start_frame = 1;
let $start_frame = message.start_frame;
if ($start_frame !== undefined) {
writeVarint32(bb, 8);
writeVarint64(bb, intToLong($start_frame));
writeVarint32(bb, $start_frame);
}
// optional int32 end_frame = 2;
// optional uint32 end_frame = 2;
let $end_frame = message.end_frame;
if ($end_frame !== undefined) {
writeVarint32(bb, 16);
writeVarint64(bb, intToLong($end_frame));
writeVarint32(bb, $end_frame);
}
// optional bool is_static = 3;
// optional DetectionHistory detections = 3;
let $detections = message.detections;
if ($detections !== undefined) {
writeVarint32(bb, 26);
let nested = popByteBuffer();
_encodeDetectionHistory($detections, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional RLEDetectionHistory rle_detections = 4;
let $rle_detections = message.rle_detections;
if ($rle_detections !== undefined) {
writeVarint32(bb, 34);
let nested = popByteBuffer();
_encodeRLEDetectionHistory($rle_detections, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
// optional bool not_present = 5;
let $not_present = message.not_present;
if ($not_present !== undefined) {
writeVarint32(bb, 40);
writeByte(bb, $not_present ? 1 : 0);
}
// optional bool is_static = 6;
let $is_static = message.is_static;
if ($is_static !== undefined) {
writeVarint32(bb, 24);
writeVarint32(bb, 48);
writeByte(bb, $is_static ? 1 : 0);
}
// repeated Point points = 4;
let array$points = message.points;
if (array$points !== undefined) {
for (let value of array$points) {
writeVarint32(bb, 34);
let nested = popByteBuffer();
_encodePoint(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
}
}
}
export function decodePath(binary: Uint8Array): Path {
@@ -136,33 +508,46 @@ function _decodePath(bb: ByteBuffer): Path {
case 0:
break end_of_message;
// optional int32 start_frame = 1;
// optional uint32 start_frame = 1;
case 1: {
message.start_frame = readVarint32(bb);
message.start_frame = readVarint32(bb) >>> 0;
break;
}
// optional int32 end_frame = 2;
// optional uint32 end_frame = 2;
case 2: {
message.end_frame = readVarint32(bb);
message.end_frame = readVarint32(bb) >>> 0;
break;
}
// optional bool is_static = 3;
// optional DetectionHistory detections = 3;
case 3: {
message.is_static = !!readByte(bb);
let limit = pushTemporaryLength(bb);
message.detections = _decodeDetectionHistory(bb);
bb.limit = limit;
break;
}
// repeated Point points = 4;
// optional RLEDetectionHistory rle_detections = 4;
case 4: {
let limit = pushTemporaryLength(bb);
let values = message.points || (message.points = []);
values.push(_decodePoint(bb));
message.rle_detections = _decodeRLEDetectionHistory(bb);
bb.limit = limit;
break;
}
// optional bool not_present = 5;
case 5: {
message.not_present = !!readByte(bb);
break;
}
// optional bool is_static = 6;
case 6: {
message.is_static = !!readByte(bb);
break;
}
default:
skipUnknownField(bb, tag & 7);
}
@@ -171,23 +556,28 @@ function _decodePath(bb: ByteBuffer): Path {
return message;
}
export interface BallPaths {
export interface IdentifierHistory {
ball_identifier?: number;
paths?: Path[];
}
export function encodeBallPaths(message: BallPaths): Uint8Array {
export function encodeIdentifierHistory(
message: IdentifierHistory,
): Uint8Array {
let bb = popByteBuffer();
_encodeBallPaths(message, bb);
_encodeIdentifierHistory(message, bb);
return toUint8Array(bb);
}
function _encodeBallPaths(message: BallPaths, bb: ByteBuffer): void {
// optional int32 ball_identifier = 1;
function _encodeIdentifierHistory(
message: IdentifierHistory,
bb: ByteBuffer,
): void {
// optional uint32 ball_identifier = 1;
let $ball_identifier = message.ball_identifier;
if ($ball_identifier !== undefined) {
writeVarint32(bb, 8);
writeVarint64(bb, intToLong($ball_identifier));
writeVarint32(bb, $ball_identifier);
}
// repeated Path paths = 2;
@@ -204,12 +594,12 @@ function _encodeBallPaths(message: BallPaths, bb: ByteBuffer): void {
}
}
export function decodeBallPaths(binary: Uint8Array): BallPaths {
return _decodeBallPaths(wrapByteBuffer(binary));
export function decodeIdentifierHistory(binary: Uint8Array): IdentifierHistory {
return _decodeIdentifierHistory(wrapByteBuffer(binary));
}
function _decodeBallPaths(bb: ByteBuffer): BallPaths {
let message: BallPaths = {} as any;
function _decodeIdentifierHistory(bb: ByteBuffer): IdentifierHistory {
let message: IdentifierHistory = {} as any;
end_of_message: while (!isAtEnd(bb)) {
let tag = readVarint32(bb);
@@ -218,9 +608,9 @@ function _decodeBallPaths(bb: ByteBuffer): BallPaths {
case 0:
break end_of_message;
// optional int32 ball_identifier = 1;
// optional uint32 ball_identifier = 1;
case 1: {
message.ball_identifier = readVarint32(bb);
message.ball_identifier = readVarint32(bb) >>> 0;
break;
}
@@ -242,9 +632,7 @@ function _decodeBallPaths(bb: ByteBuffer): BallPaths {
}
export interface Shot {
start_frame?: number;
end_frame?: number;
ball_paths?: BallPaths[];
identifier_histories?: IdentifierHistory[];
}
export function encodeShot(message: Shot): Uint8Array {
@@ -254,27 +642,13 @@ export function encodeShot(message: Shot): Uint8Array {
}
function _encodeShot(message: Shot, bb: ByteBuffer): void {
// optional int32 start_frame = 1;
let $start_frame = message.start_frame;
if ($start_frame !== undefined) {
writeVarint32(bb, 8);
writeVarint64(bb, intToLong($start_frame));
}
// optional int32 end_frame = 2;
let $end_frame = message.end_frame;
if ($end_frame !== undefined) {
writeVarint32(bb, 16);
writeVarint64(bb, intToLong($end_frame));
}
// repeated BallPaths ball_paths = 3;
let array$ball_paths = message.ball_paths;
if (array$ball_paths !== undefined) {
for (let value of array$ball_paths) {
// repeated IdentifierHistory identifier_histories = 3;
let array$identifier_histories = message.identifier_histories;
if (array$identifier_histories !== undefined) {
for (let value of array$identifier_histories) {
writeVarint32(bb, 26);
let nested = popByteBuffer();
_encodeBallPaths(value, nested);
_encodeIdentifierHistory(value, nested);
writeVarint32(bb, nested.limit);
writeByteBuffer(bb, nested);
pushByteBuffer(nested);
@@ -296,23 +670,12 @@ function _decodeShot(bb: ByteBuffer): Shot {
case 0:
break end_of_message;
// optional int32 start_frame = 1;
case 1: {
message.start_frame = readVarint32(bb);
break;
}
// optional int32 end_frame = 2;
case 2: {
message.end_frame = readVarint32(bb);
break;
}
// repeated BallPaths ball_paths = 3;
// repeated IdentifierHistory identifier_histories = 3;
case 3: {
let limit = pushTemporaryLength(bb);
let values = message.ball_paths || (message.ball_paths = []);
values.push(_decodeBallPaths(bb));
let values =
message.identifier_histories || (message.identifier_histories = []);
values.push(_decodeIdentifierHistory(bb));
bb.limit = limit;
break;
}