// SPDX-FileCopyrightText: © 2025 Allegro DVT <github-ip@allegrodvt.com>
// SPDX-License-Identifier: MIT

/******************************************************************************
   \addtogroup Buffers
   !@{
   \file
 **************************************************************************/
#pragma once

#define AL_ENC_MAX_SEI_SIZE (10 * 1024)
#define AL_ENC_MAX_CONFIG_HEADER_SIZE (2 * 1024)
#define AL_ENC_MAX_HEADER_SIZE (AL_ENC_MAX_CONFIG_HEADER_SIZE + AL_ENC_MAX_SEI_SIZE)

#include "Profiles.h"
#include "lib_common/PicFormat.h"

/*****************************************************************************
   \brief Retrieves the maximum size of one VCL NAL unit
   This returns the actual worst case a NAL unit could take.
   If you want the decoder bitstream buffer to always be able to hold a frame,
   you should use this function to allocate them as the decoder can't assume
   the possible worst case stream generated by the encoder which generated
   the stream. If you are in a controlled environment, you might want to look
   at AL_GetMitigatedMaxNalSize().
   \param[in] tDim Frame dimension
   \param[in] eMode Chroma subsampling
   \param[in] iBitDepth Bitdepth
   \param[in] eProfile Profile
   \param[in] iLevel Level
   \return maximum size of one NAL unit
*****************************************************************************/
int32_t AL_GetMaxNalSize(AL_TDimension tDim, AL_EChromaMode eMode, int32_t iBitDepth, AL_EProfile eProfile, int32_t iLevel);

/*****************************************************************************
   \brief Retrieves the most likely to happen real worst case size of the encoder
   generated NAL unit.
   You should use this function to allocate the encoder bitstream buffers as
   it optimize the memory footprint.
   \param[in] tDim Frame dimension
   \param[in] eMode Chroma subsampling
   \param[in] iBitDepth Bitdepth
   \return maximum size of one NAL unit
*****************************************************************************/
int32_t AL_GetMitigatedMaxNalSize(AL_TDimension tDim, AL_EChromaMode eMode, int32_t iBitDepth);

/*****************************************************************************
   \brief Retrieves the minimal memory space needed for the encoder to generate
   one frame.
   You should use this function to determine the minimal allocated buffer used for
   encoding. The user must add space for the slice data of the frame
   \param[in] iNumSlices Number of slices in the frame
   \param[in] eCodec Codec used for encoding
   \return Minimal size for non-VCL NAL unit, slice header and
   specific structure to encode one frame
*****************************************************************************/
int32_t AL_GetMinimalNalSize(int32_t iNumSlices, AL_ECodec eCodec);

/*!@}*/
