view libtwamr/tseq_in.c @ 585:3c6bf0d26ee7 default tip

TW-TS-005 reader: fix maximum line length bug TW-TS-005 section 4.1 states: The maximum allowed length of each line is 80 characters, not including the OS-specific newline encoding. The implementation of this line length limit in the TW-TS-005 hex file reader function in the present suite was wrong, such that lines of the full maximum length could not be read. Fix it. Note that this bug affects comment lines too, not just actual RTP payloads. Neither Annex A nor Annex B features an RTP payload format that goes to the maximum of 40 bytes, but if a comment line goes to the maximum allowed length of 80 characters not including the terminating newline, the bug will be triggered, necessitating the present fix.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 25 Feb 2025 07:49:28 +0000
parents 3ce30a95769e
children
line wrap: on
line source

/*
 * In this module we implement decoder input conversion from 3GPP
 * test sequence format to our internal struct amr_param_frame.
 */

#include <stdint.h>
#include <string.h>
#include "tw_amr.h"
#include "namespace.h"
#include "typedef.h"
#include "cnst.h"
#include "bits2prm.h"

int amr_frame_from_tseq(const uint16_t *cod, int use_rxtype,
			struct amr_param_frame *frame)
{
	enum RXFrameType rx_type;
	int rc;

	if (use_rxtype) {
		if (cod[0] >= RX_N_FRAMETYPES)
			return -1;
		rx_type = cod[0];
	} else {
		rc = amr_txtype_to_rxtype(cod[0], &rx_type);
		if (rc < 0)
			return -1;
	}
	frame->type = rx_type;
	if (rx_type == RX_NO_DATA) {
		frame->mode = 0xFF;
		return 0;
	}
	if (cod[MAX_SERIAL_SIZE+1] > 7)
		return -2;
	frame->mode = cod[MAX_SERIAL_SIZE+1];
	switch (rx_type) {
	case RX_SPEECH_GOOD:
	case RX_SPEECH_DEGRADED:
	case RX_SPEECH_BAD:
		Bits2prm(frame->mode, cod + 1, frame->param);
		break;
	case RX_SID_UPDATE:
	case RX_SID_BAD:
		Bits2prm(MRDTX, cod + 1, frame->param);
		break;
	}
	return 0;
}