<commit_before>#include "bink.h"

int bink_isfile(const uint8_t *data, size_t input_len, size_t *lengthptr)
{
	if (input_len < BINK_HEADER_SIZE)
		return 0;

	uint32_t magic = MAGIC(data);
	if (!IS_BINK_MAGIC(magic))
		return 0;
	
	size_t   length      = le16toh(*(uint32_t *)(data +  4)) + 8;
	uint32_t frame_count = le16toh(*(uint32_t *)(data +  8));
	uint32_t width       = le16toh(*(uint32_t *)(data + 20));
	uint32_t height      = le16toh(*(uint32_t *)(data + 24));
	uint32_t fps_num     = le16toh(*(uint32_t *)(data + 28));
	uint32_t fps_den     = le16toh(*(uint32_t *)(data + 32));

	if (input_len < length ||
		frame_count == 0 ||
		width  > 7680 ||
		height > 4800 ||
		fps_num == 0  ||
		fps_den == 0)
	{
		return 0;
	}

	if (lengthptr) *lengthptr = length;

	return 1;
}<commit_msg>fix bink video parsing<commit_after>#include "bink.h"

int bink_isfile(const uint8_t *data, size_t input_len, size_t *lengthptr)
{
	if (input_len < BINK_HEADER_SIZE)
		return 0;

	uint32_t magic = MAGIC(data);
	if (!IS_BINK_MAGIC(magic))
		return 0;
	
	size_t length      = le32toh(*(uint32_t *)(data +  4)) + 8;
	size_t frame_count = le32toh(*(uint32_t *)(data +  8));
	size_t width       = le32toh(*(uint32_t *)(data + 20));
	size_t height      = le32toh(*(uint32_t *)(data + 24));
	size_t fps_num     = le32toh(*(uint32_t *)(data + 28));
	size_t fps_den     = le32toh(*(uint32_t *)(data + 32));

	if (input_len < length ||
		frame_count == 0 ||
		width  > 7680 ||
		height > 4800 ||
		fps_num == 0  ||
		fps_den == 0)
	{
		return 0;
	}

	if (lengthptr) *lengthptr = length;

	return 1;
}
{'fraction_non_alphanumeric': 0.15919140871762477, 'fraction_numerical': 0.07327858496525584, 'mean_word_length': 3.578034682080925, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6130829', 'n_tokens_mistral': 799, 'n_tokens_neox': 689, 'n_words': 151}