view libtwamr/dhf_check.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 9beb01439a90
children
line wrap: on
line source

/*
 * This module implements the DHF checking function.
 */

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

static const Word16 * const dhf_per_mode[8] = {
	amr_dhf_mr475,
	amr_dhf_mr515,
	amr_dhf_mr59,
	amr_dhf_mr67,
	amr_dhf_mr74,
	amr_dhf_mr795,
	amr_dhf_mr102,
	amr_dhf_mr122
};

int amr_check_dhf(const struct amr_param_frame *frame, int first_sub_only)
{
	const Word16 *table;
	Word16 nparam;

	if (frame->type != RX_SPEECH_GOOD)
		return 0;
	if ((frame->mode & 0x87) == 0x87)
		table = amr_dhf_gsmefr;
	else
		table = dhf_per_mode[frame->mode & 7];
	if (first_sub_only)
		nparam = prmnofsf[frame->mode & 7];
	else
		nparam = prmno[frame->mode & 7];
	if (memcmp(frame->param, table, nparam * sizeof(int16_t)))
		return 0;
	else
		return 1;
}