<commit_before>/*
 *			GPAC - Multimedia Framework C SDK
 *
 *			Authors: <NAME>
 *			Copyright (c) Telecom ParisTech 2000-2012
 *					All rights reserved
 *
 *  This file is part of GPAC / common tools sub-project
 *
 *  GPAC is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  GPAC is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef _GF_BITSTREAM_H_
#define _GF_BITSTREAM_H_

#ifdef __cplusplus
extern "C" {
#endif

/*!
 *	\file <gpac/bitstream.h>
 *	\brief bitstream reading and writing.
 */

/*!
 *	\addtogroup bs_grp Bitstream
 *	\ingroup utils_grp
 *	\brief BitStream object
 *
 *	This section documents the bitstream object of the GPAC framework.
 *	\note Unless specified, all functions assume Big-Endian ordering of data in the bitstream.
 *	@{
 */

#include <gpac/tools.h>


enum
{
	GF_BITSTREAM_READ = 0,
	GF_BITSTREAM_WRITE
};

typedef struct __tag_bitstream GF_BitStream;

/*!
 *	\brief bitstream constructor
 *
 *	Constructs a bitstream from a buffer (read or write mode)
 *	\param buffer buffer to read or write. In WRITE mode, this can be NULL to let the bitstream object dynamically allocate memory, in which case the size param is ignored.
 *	\param size size of the buffer given.
 *	\param mode operation mode for this bitstream: GF_BITSTREAM_READ for read, GF_BITSTREAM_WRITE for write.
 *	\return new bitstream object
 *	\note In write mode on an existing data buffer, data overflow is never signaled but simply ignored, it is the caller responsability to ensure it
 *	does not write more than possible.
 */
GF_BitStream *gf_bs_new(const char *buffer, u64 size, u32 mode);
/*!
 *	\brief bitstream constructor from file handle
 *
 * Creates a bitstream from a file handle.
 * \param f handle of the file to use. This handle must be created with binary mode.
 *	\param mode operation mode for this bitstream: GF_BITSTREAM_READ for read, GF_BITSTREAM_WRITE for write.
 *	\return new bitstream object
 *	\note - You have to open your file in the appropriated mode:\n
 *	- GF_BITSTREAM_READ: bitstream is constructed for reading\n
 *	- GF_BITSTREAM_WRITE: bitstream is constructed for writing\n
 *	\note - you may use any of these modes for a file with read/write access.
 *	\warning RESULTS ARE UNEXPECTED IF YOU TOUCH THE FILE WHILE USING THE BITSTREAM.
 */
GF_BitStream *gf_bs_from_file(FILE *f, u32 mode);
/*!
 *	\brief bitstream constructor from file handle
 *<commit_msg>fix typo<commit_after>/*
 *			GPAC - Multimedia Framework C SDK
 *
 *			Authors: <NAME>
 *			Copyright (c) Telecom ParisTech 2000-2012
 *					All rights reserved
 *
 *  This file is part of GPAC / common tools sub-project
 *
 *  GPAC is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  GPAC is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef _GF_BITSTREAM_H_
#define _GF_BITSTREAM_H_

#ifdef __cplusplus
extern "C" {
#endif

/*!
 *	\file <gpac/bitstream.h>
 *	\brief bitstream reading and writing.
 */

/*!
 *	\addtogroup bs_grp Bitstream
 *	\ingroup utils_grp
 *	\brief BitStream object
 *
 *	This section documents the bitstream object of the GPAC framework.
 *	\note Unless specified, all functions assume Big-Endian ordering of data in the bitstream.
 *	@{
 */

#include <gpac/tools.h>


enum
{
	GF_BITSTREAM_READ = 0,
	GF_BITSTREAM_WRITE
};

typedef struct __tag_bitstream GF_BitStream;

/*!
 *	\brief bitstream constructor
 *
 *	Constructs a bitstream from a buffer (read or write mode)
 *	\param buffer buffer to read or write. In WRITE mode, this can be NULL to let the bitstream object dynamically allocate memory, in which case the size param is ignored.
 *	\param size size of the buffer given.
 *	\param mode operation mode for this bitstream: GF_BITSTREAM_READ for read, GF_BITSTREAM_WRITE for write.
 *	\return new bitstream object
 *	\note In write mode on an existing data buffer, data overflow is never signaled but simply ignored, it is the caller responsability to ensure it
 *	does not write more than possible.
 */
GF_BitStream *gf_bs_new(const char *buffer, u64 size, u32 mode);
/*!
 *	\brief bitstream constructor from file handle
 *
 * Creates a bitstream from a file handle.
 * \param f handle of the file to use. This handle must be created with binary mode.
 *	\param mode operation mode for this bitstream: GF_BITSTREAM_READ for read, GF_BITSTREAM_WRITE for write.
 *	\return new bitstream object
 *	\note - You have to open your file in the appropriated mode:\n
 *	- GF_BITSTREAM_READ: bitstream is constructed for reading\n
 *	- GF_BITSTREAM_WRITE: bitstream is constructed for writing\n
 *	\note - you may use any of these modes for a file with read/write access.
 *	\warning RESULTS ARE UNEXPECTED IF YOU TOUCH THE FILE WHILE USING THE BITSTREAM.
 */
GF_BitStream *gf_bs_from_file(FILE *f, u32 mode);
/*!
 *	\brief bitstream destructor from file handle
 *
{'fraction_non_alphanumeric': 0.06824234354194407, 'fraction_numerical': 0.007989347536617843, 'mean_word_length': 3.6799065420560746, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5075949', 'n_tokens_mistral': 1836, 'n_tokens_neox': 1767, 'n_words': 815}