libgpac
Documentation of the core library of GPAC
AV Parsing

Utility tools for audio and video raw media parsing. More...

+ Collaboration diagram for AV Parsing:

Data Structures

struct  GF_M4VDecSpecInfo
 
struct  ogg_audio_codec_desc
 
struct  GF_VorbisParser
 
struct  GF_M4ADecSpecInfo
 

Typedefs

typedef struct __tag_m4v_parser GF_M4VParser
 

Enumerations

enum  {
  GF_M4A_AAC_MAIN = 1 , GF_M4A_AAC_LC = 2 , GF_M4A_AAC_SSR = 3 , GF_M4A_AAC_LTP = 4 ,
  GF_M4A_AAC_SBR = 5 , GF_M4A_AAC_SCALABLE = 6 , GF_M4A_TWINVQ = 7 , GF_M4A_CELP = 8 ,
  GF_M4A_HVXC = 9 , GF_M4A_TTSI = 12 , GF_M4A_MAIN_SYNTHETIC = 13 , GF_M4A_WAVETABLE_SYNTHESIS = 14 ,
  GF_M4A_GENERAL_MIDI = 15 , GF_M4A_ALGO_SYNTH_AUDIO_FX = 16 , GF_M4A_ER_AAC_LC = 17 , GF_M4A_ER_AAC_LTP = 19 ,
  GF_M4A_ER_AAC_SCALABLE = 20 , GF_M4A_ER_TWINVQ = 21 , GF_M4A_ER_BSAC = 22 , GF_M4A_ER_AAC_LD = 23 ,
  GF_M4A_ER_CELP = 24 , GF_M4A_ER_HVXC = 25 , GF_M4A_ER_HILN = 26 , GF_M4A_ER_PARAMETRIC = 27 ,
  GF_M4A_SSC = 28 , GF_M4A_AAC_PS = 29 , GF_M4A_LAYER1 = 32 , GF_M4A_LAYER2 = 33 ,
  GF_M4A_LAYER3 = 34 , GF_M4A_DST = 35 , GF_M4A_ALS = 36 , GF_M4A_USAC = 42
}
 
enum  ObuType {
  OBU_RESERVED_0 = 0 , OBU_SEQUENCE_HEADER = 1 , OBU_TEMPORAL_DELIMITER = 2 , OBU_FRAME_HEADER = 3 ,
  OBU_TILE_GROUP = 4 , OBU_METADATA = 5 , OBU_FRAME = 6 , OBU_REDUNDANT_FRAME_HEADER = 7 ,
  OBU_TILE_LIST = 8 , OBU_RESERVED_9 = 9 , OBU_RESERVED_10 = 10 , OBU_RESERVED_11 = 11 ,
  OBU_RESERVED_12 = 12 , OBU_RESERVED_13 = 13 , OBU_RESERVED_14 = 14 , OBU_PADDING = 15
}
 OBU types.
 
enum  ObuMetadataType {
  OBU_METADATA_TYPE_HDR_CLL = 1 , OBU_METADATA_TYPE_HDR_MDCV = 2 , OBU_METADATA_TYPE_SCALABILITY = 3 , OBU_METADATA_TYPE_ITUT_T35 = 4 ,
  OBU_METADATA_TYPE_TIMECODE = 5
}
 OBU metadata types.
 

Functions

void gf_media_reduce_aspect_ratio (u32 *width, u32 *height)
 
void gf_media_get_reduced_frame_rate (u32 *timescale, u32 *sample_dur)
 
u32 gf_media_nalu_add_emulation_bytes (const u8 *buffer_src, u8 *buffer_dst, u32 nal_size)
 
u32 gf_media_nalu_emulation_bytes_add_count (u8 *buffer, u32 nal_size)
 
GF_M4VParsergf_m4v_parser_new (u8 *data, u64 data_size, Bool mpeg12video)
 
GF_M4VParsergf_m4v_parser_bs_new (GF_BitStream *bs, Bool mpeg12video)
 
void gf_m4v_parser_del (GF_M4VParser *m4v)
 
void gf_m4v_parser_del_no_bs (GF_M4VParser *m4v)
 
GF_Err gf_m4v_parse_config (GF_M4VParser *m4v, GF_M4VDecSpecInfo *dsi)
 
void gf_m4v_parser_reset (GF_M4VParser *m4v, u8 obj_type)
 
GF_Err gf_m4v_parse_frame (GF_M4VParser *m4v, GF_M4VDecSpecInfo *dsi, u8 *frame_type, u32 *time_inc, u64 *size, u64 *start, Bool *is_coded)
 
u64 gf_m4v_get_object_start (GF_M4VParser *m4v)
 
GF_Err gf_m4v_get_config (u8 *rawdsi, u32 rawdsi_size, GF_M4VDecSpecInfo *dsi)
 
GF_Err gf_mpegv12_get_config (u8 *rawdsi, u32 rawdsi_size, GF_M4VDecSpecInfo *dsi)
 
void gf_m4v_rewrite_pl (u8 **io_dsi, u32 *io_dsi_len, u8 PL)
 
GF_Err gf_m4v_rewrite_par (u8 **io_dsi, u32 *io_dsi_len, s32 par_n, s32 par_d)
 
const char * gf_m4v_get_profile_name (u8 video_pl)
 
s32 gf_mv12_next_start_code (u8 *pbuffer, u32 buflen, u32 *optr, u32 *scode)
 
s32 gf_mv12_next_slice_start (u8 *pbuffer, u32 startoffset, u32 buflen, u32 *slice_offset)
 
u8 gf_mp3_num_channels (u32 hdr)
 
u16 gf_mp3_sampling_rate (u32 hdr)
 
u16 gf_mp3_window_size (u32 hdr)
 
u32 gf_mp3_bit_rate (u32 hdr)
 
u8 gf_mp3_object_type_indication (u32 hdr)
 
u8 gf_mp3_layer (u32 hdr)
 
u16 gf_mp3_frame_size (u32 hdr)
 
u32 gf_mp3_get_next_header (FILE *fin)
 
u32 gf_mp3_get_next_header_mem (const u8 *buffer, u32 size, u32 *pos)
 
u8 gf_mp3_version (u32 hdr)
 
const char * gf_mp3_version_name (u32 hdr)
 
Bool gf_vorbis_parse_header (GF_VorbisParser *vp, u8 *data, u32 data_len)
 
u32 gf_vorbis_check_frame (GF_VorbisParser *vp, u8 *data, u32 data_len)
 
Bool gf_opus_parse_header (GF_OpusConfig *cfg, u8 *data, u32 data_len)
 
u32 gf_opus_check_frame (GF_OpusConfig *cfg, u8 *data, u32 data_len)
 
u64 gf_mpegh_escaped_value (GF_BitStream *bs, u32 nBits1, u32 nBits2, u32 nBits3)
 
s32 gf_mpegh_get_mhas_pl (u8 *ptr, u32 size, u64 *chan_layout)
 
u32 gf_id3_read_size (GF_BitStream *bs)
 
u32 gf_m4a_get_channel_cfg (u32 nb_chan)
 
GF_Err gf_m4a_get_config (u8 *dsi, u32 dsi_size, GF_M4ADecSpecInfo *cfg)
 
u32 gf_m4a_get_profile (GF_M4ADecSpecInfo *cfg)
 
GF_Err gf_m4a_write_config (GF_M4ADecSpecInfo *cfg, u8 **dsi, u32 *dsi_size)
 
GF_Err gf_m4a_write_config_bs (GF_BitStream *bs, GF_M4ADecSpecInfo *cfg)
 
GF_Err gf_m4a_parse_config (GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_known)
 
GF_Err gf_m4a_parse_program_config_element (GF_BitStream *bs, GF_M4ADecSpecInfo *cfg)
 
GF_Err gf_m4a_write_program_config_element_bs (GF_BitStream *bs, GF_M4ADecSpecInfo *cfg)
 
const char * gf_m4a_object_type_name (u32 objectType)
 
const char * gf_m4a_get_profile_name (u8 audio_pl)
 
Bool gf_ac3_parser (u8 *buffer, u32 buffer_size, u32 *pos, GF_AC3Config *out_hdr, Bool full_parse)
 
Bool gf_ac3_parser_bs (GF_BitStream *bs, GF_AC3Config *hdr, Bool full_parse)
 
Bool gf_eac3_parser (u8 *buffer, u32 buffer_size, u32 *pos, GF_AC3Config *hdr, Bool full_parse)
 
Bool gf_eac3_parser_bs (GF_BitStream *bs, GF_AC3Config *hdr, Bool full_parse)
 
u32 gf_eac3_get_chan_loc_count (u32 chan_loc)
 
u64 gf_ac3_get_channel_layout (GF_AC3Config *ac3)
 
u32 gf_ac3_get_total_channels (u32 acmod)
 
u32 gf_ac3_get_surround_channels (u32 acmod)
 
u32 gf_ac3_get_bitrate (u32 brcode)
 
GF_Err gf_avc_get_sps_info (u8 *sps, u32 sps_size, u32 *sps_id, u32 *width, u32 *height, s32 *par_n, s32 *par_d)
 
GF_Err gf_avc_get_pps_info (u8 *pps, u32 pps_size, u32 *pps_id, u32 *sps_id)
 
GF_Err gf_hevc_get_sps_info (u8 *sps_data, u32 sps_size, u32 *sps_id, u32 *width, u32 *height, s32 *par_n, s32 *par_d)
 
GF_Err gf_vvc_get_sps_info (u8 *sps_data, u32 sps_size, u32 *sps_id, u32 *width, u32 *height, s32 *par_n, s32 *par_d)
 
const char * gf_vvc_get_profile_name (u8 video_prof)
 
const char * gf_avc_hevc_get_chroma_format_name (u8 chroma_format)
 
const char * gf_avc_get_profile_name (u8 profile_idc)
 
Bool gf_avcc_use_extensions (u8 profile_idc)
 
const char * gf_hevc_get_profile_name (u8 profile_idc)
 
void gf_img_parse (GF_BitStream *bs, u32 *codecid, u32 *width, u32 *height, u8 **dsi, u32 *dsi_len)
 
GF_Err gf_img_jpeg_dec (u8 *jpg, u32 jpg_size, u32 *width, u32 *height, u32 *pixel_format, u8 *dst, u32 *dst_size, u32 dst_nb_comp)
 
GF_Err gf_img_png_dec (u8 *png, u32 png_size, u32 *width, u32 *height, u32 *pixel_format, u8 *dst, u32 *dst_size)
 
GF_Err gf_img_png_enc (u8 *data, u32 width, u32 height, s32 stride, u32 pixel_format, u8 *dst, u32 *dst_size)
 
const char * gf_av1_get_obu_name (ObuType obu_type)
 

Variables

static const u32 GF_M4ASampleRates []
 
static const u32 GF_M4ANumChannels []
 

Detailed Description

This section documents the audio and video parsing functions of the GPAC framework.


Data Structure Documentation

◆ GF_M4VDecSpecInfo

struct GF_M4VDecSpecInfo

MPEG-1, MPEG-1, MPEG-4 part 2 decoder specific info (only serialized for MPEG-4)

Data Fields
u8 VideoPL

video PL

u8 RAP_stream

set if stream is RAP only

u8 objectType

MPEG-4 part 2 video object type

u8 has_shape

set if object has shape coding

u8 enh_layer

set if object is an enhancement layer

u16 width

video horizontal size

u16 height

video vertical size

u8 par_num

pixel aspect ratio numerator

u8 par_den

pixel aspect ratio denominator

u16 clock_rate

video clock rate - frames are spaced by time_increment/clock_rate seconds

u8 NumBitsTimeIncrement

number of bits to code the time increment (internal use only)

u32 time_increment

time increment between frames

Double fps

framerate, for MPEG 1/2

u32 next_object_start

position of next object in the bitstream

Bool progresive

progressive video sequence

u8 chroma_fmt

chroma format

◆ GF_VorbisParser

struct GF_VorbisParser

OGG Vorbis parser

Data Fields
u32 version
u32 num_headers
u32 min_block
u32 max_block
u32 max_r
u32 avg_r
u32 low_r
u32 modebits
Bool mode_flag[64]
u32 nb_init
GF_BitStream * vbs
u32 sample_rate
u32 channels

◆ GF_M4ADecSpecInfo

struct GF_M4ADecSpecInfo

MPEG-4 Audio decoder specific info

Data Fields
u32 nb_chan
u32 base_object_type
u32 base_sr
u32 base_sr_index
Bool has_sbr
u32 sbr_object_type
u32 sbr_sr
u32 sbr_sr_index
Bool has_ps
u8 audioPL
u32 chan_cfg
Bool program_config_element_present
Bool mono_mixdown_present
Bool stereo_mixdown_present
Bool matrix_mixdown_idx_present
Bool pseudo_surround_enable
u8 element_instance_tag
u8 object_type
u8 sampling_frequency_index
u8 num_front_channel_elements
u8 num_side_channel_elements
u8 num_back_channel_elements
u8 num_lfe_channel_elements
u8 num_assoc_data_elements
u8 num_valid_cc_elements
u8 mono_mixdown_element_number
u8 stereo_mixdown_element_number
u8 matrix_mixdown_idx
u8 front_element_is_cpe[15]
u8 front_element_tag_select[15]
u8 side_element_is_cpe[15]
u8 side_element_tag_select[15]
u8 back_element_is_cpe[15]
u8 back_element_tag_select[15]
u8 lfe_element_tag_select[15]
u8 assoc_data_element_tag_select[15]
u8 cc_element_is_ind_sw[15]
u8 valid_cc_element_tag_select[15]
u8 comment_field_bytes
u8 comments[255]
u32 cpe_channels

Typedef Documentation

◆ GF_M4VParser

typedef struct __tag_m4v_parser GF_M4VParser

MPEG (1,2,4) visual object parser (DSI extraction and timing/framing)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

MPEG-4 audio object types

Enumerator
GF_M4A_AAC_MAIN 

AAC main

GF_M4A_AAC_LC 

AAC LC

GF_M4A_AAC_SSR 

AAC SSR

GF_M4A_AAC_LTP 

AAC LTP

GF_M4A_AAC_SBR 

AAC SBR

GF_M4A_AAC_SCALABLE 

AAC scalable

GF_M4A_TWINVQ 

TwinVQ

GF_M4A_CELP 

CELP

GF_M4A_HVXC 

HVXC

GF_M4A_TTSI 

TTSI

GF_M4A_MAIN_SYNTHETIC 

Main Synthetic

GF_M4A_WAVETABLE_SYNTHESIS 

Wavetable synthesis

GF_M4A_GENERAL_MIDI 

General Midi

GF_M4A_ALGO_SYNTH_AUDIO_FX 

AudioFX synthesis

GF_M4A_ER_AAC_LC 

Error Resilient AAC LC

GF_M4A_ER_AAC_LTP 

Error Resilient AAC LTP

GF_M4A_ER_AAC_SCALABLE 

Error Resilient AAC Scalable

GF_M4A_ER_TWINVQ 

Error Resilient TwinVQ

GF_M4A_ER_BSAC 

Error Resilient BSAC

GF_M4A_ER_AAC_LD 

Error Resilient AAC LD

GF_M4A_ER_CELP 

Error Resilient CELP

GF_M4A_ER_HVXC 

Error Resilient HVXC

GF_M4A_ER_HILN 

Error Resilient HILN

GF_M4A_ER_PARAMETRIC 

Error Resilient Parametric

GF_M4A_SSC 

SSC

GF_M4A_AAC_PS 

AAC PS

GF_M4A_LAYER1 

MPEG-1/2 layer 1

GF_M4A_LAYER2 

MPEG-1/2 layer 2

GF_M4A_LAYER3 

MPEG-1/2 layer 3

GF_M4A_DST 

DST

GF_M4A_ALS 

ALS

GF_M4A_USAC 

USAC

Function Documentation

◆ gf_media_reduce_aspect_ratio()

void gf_media_reduce_aspect_ratio ( u32 width,
u32 height 
)

Reduces input width/height to common aspect ration num/denum values

Parameters
widthwidth of the aspect ratio
heightheight of the aspect ratio

◆ gf_media_get_reduced_frame_rate()

void gf_media_get_reduced_frame_rate ( u32 timescale,
u32 sample_dur 
)

Reduces input FPS to a more compact value (eg 25000/1000 -> 25/1)

Parameters
timescaletimescale of the aspect ratio
sample_dursample duration of the aspect ratio in the given timescale

◆ gf_media_nalu_add_emulation_bytes()

u32 gf_media_nalu_add_emulation_bytes ( const u8 buffer_src,
u8 buffer_dst,
u32  nal_size 
)

inserts emulation prevention bytes from buffer_src into buffer_dst

Parameters
buffer_srcsource buffer (NAL without EPB)
buffer_dstdestination buffer (NAL with EPB)
nal_sizesource buffer size
Returns
size of buffer after adding emulation prevention bytes

◆ gf_media_nalu_emulation_bytes_add_count()

u32 gf_media_nalu_emulation_bytes_add_count ( u8 buffer,
u32  nal_size 
)

gets the number of emulation prevention bytes to add to a non emulated buffer

Parameters
buffersource buffer (NAL without EPB)
nal_sizesource buffer size
Returns
the number of emulation prevention bytes to add

◆ gf_m4v_parser_new()

GF_M4VParser* gf_m4v_parser_new ( u8 data,
u64  data_size,
Bool  mpeg12video 
)

Creates a new MPEG-1/2/4 video parser

Parameters
databuffer to parse
data_sizesize of buffer to parse
mpeg12videoif set, parses as MPEG-1 or MPEG-2
Returns
the created parser

◆ gf_m4v_parser_bs_new()

GF_M4VParser* gf_m4v_parser_bs_new ( GF_BitStream bs,
Bool  mpeg12video 
)

Creates a new MPEG-1/2/4 video parser from a bitstream object

Parameters
bsthe bitstream object to use for parsing
mpeg12videoif set, parses as MPEG-1 or MPEG-2
Returns
the created parser

◆ gf_m4v_parser_del()

void gf_m4v_parser_del ( GF_M4VParser m4v)

Deletes a MPEG-1/2/4 video parser

Parameters
m4vthe mpeg video parser

◆ gf_m4v_parser_del_no_bs()

void gf_m4v_parser_del_no_bs ( GF_M4VParser m4v)

Deletes a MPEG-1/2/4 video parser without destroying associated bitstream

Parameters
m4vthe mpeg video parser

◆ gf_m4v_parse_config()

GF_Err gf_m4v_parse_config ( GF_M4VParser m4v,
GF_M4VDecSpecInfo dsi 
)

parses the decoder specific info (if found)

Parameters
m4vthe mpeg video parser
dsithe decoder spcific info structure to fill
Returns
GF_OK if found, GF_EOS if not enough data, error otherwise

◆ gf_m4v_parser_reset()

void gf_m4v_parser_reset ( GF_M4VParser m4v,
u8  obj_type 
)

resets the parser

Parameters
m4vthe mpeg video parser
obj_typeif not 0, skip next start code and use (obj_type-1) for next obj parsing

◆ gf_m4v_parse_frame()

GF_Err gf_m4v_parse_frame ( GF_M4VParser m4v,
GF_M4VDecSpecInfo dsi,
u8 frame_type,
u32 time_inc,
u64 size,
u64 start,
Bool is_coded 
)

parses a frame. The parser ALWAYS resync on the next object in the bitstream thus you can seek the bitstream to copy the payload without re-seeking it

Parameters
m4vthe mpeg video parser
dsipointer to the decoder specific info parsed
frame_typeset to the frame type (I:1, P:2, B:3, 0: no frame header found)
time_incset to the time increment since last frame
sizeset to the size of the compressed frame
startset to the position of the first byte in the buffer/bitstream
is_codedset to 1 if frame is coded, 0 if skip frame, untouched if no frame found
Returns
error if any

◆ gf_m4v_get_object_start()

u64 gf_m4v_get_object_start ( GF_M4VParser m4v)

returns current object start in bitstream

Parameters
m4vthe mpeg video parser
Returns
the the position in the buffer/bitstream

◆ gf_m4v_get_config()

GF_Err gf_m4v_get_config ( u8 rawdsi,
u32  rawdsi_size,
GF_M4VDecSpecInfo dsi 
)

decodes DSI/VOSHeader for MPEG4

Parameters
rawdsiencoded MPEG-4 decoder config
rawdsi_sizesize of encoded MPEG-4 decoder config
dsithe decoder spcific info structure to fill
Returns
error if any

◆ gf_mpegv12_get_config()

GF_Err gf_mpegv12_get_config ( u8 rawdsi,
u32  rawdsi_size,
GF_M4VDecSpecInfo dsi 
)

decodes DSI/VOSHeader for MPEG12

Parameters
rawdsiencoded MPEG-1/2 decoder config
rawdsi_sizesize of encoded MPEG-1/2 decoder config
dsithe decoder spcific info structure to fill
Returns
error if any

◆ gf_m4v_rewrite_pl()

void gf_m4v_rewrite_pl ( u8 **  io_dsi,
u32 io_dsi_len,
u8  PL 
)

rewrites Profile and Level indicator in MPEG-4 DSI

Parameters
io_dsiencoded MPEG-4 decoder config
io_dsi_lensize of encoded MPEG-4 decoder config
PLthe new Profile/level to set

◆ gf_m4v_rewrite_par()

GF_Err gf_m4v_rewrite_par ( u8 **  io_dsi,
u32 io_dsi_len,
s32  par_n,
s32  par_d 
)

rewrites PAR code in DSI. Negative values will remove the par

Parameters
io_dsiencoded MPEG-4 decoder config
io_dsi_lensize of encoded MPEG-4 decoder config
par_nthe numerator of the new aspect ratio to write
par_dthe denominator of the new aspect ratio to write
Returns
error if any

◆ gf_m4v_get_profile_name()

const char* gf_m4v_get_profile_name ( u8  video_pl)

returns readable description of profile

Parameters
video_plthe Profile/level
Returns
name of the profile (never NULL)

◆ gf_mv12_next_start_code()

s32 gf_mv12_next_start_code ( u8 pbuffer,
u32  buflen,
u32 optr,
u32 scode 
)

returns next start code in mpeg 1/2 video buffer

Parameters
pbufferthe video buffer
buflensize of the video buffer
optrset to the byte offset in the buffer
scodeset to the start code value if found
Returns
0 if found, -1 otherwise

◆ gf_mv12_next_slice_start()

s32 gf_mv12_next_slice_start ( u8 pbuffer,
u32  startoffset,
u32  buflen,
u32 slice_offset 
)

returns next slice start in mpeg 1/2 video buffer

Parameters
pbufferthe video buffer
startoffsetthe offset in the buffer at which analysis shall begin
buflensize of the video buffer
slice_offsetset to the byte offset of the slice start
Returns
0 if found, -1 otherwise

◆ gf_mp3_num_channels()

u8 gf_mp3_num_channels ( u32  hdr)

gets the number of channels in an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the number of channels

◆ gf_mp3_sampling_rate()

u16 gf_mp3_sampling_rate ( u32  hdr)

gets the sampling rate of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the sampling rate

◆ gf_mp3_window_size()

u16 gf_mp3_window_size ( u32  hdr)

gets the window size (number of samples) in an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the window size

◆ gf_mp3_bit_rate()

u32 gf_mp3_bit_rate ( u32  hdr)

gets the bitrate of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the bit rate

◆ gf_mp3_object_type_indication()

u8 gf_mp3_object_type_indication ( u32  hdr)

gets the MPEG-4 object type indication of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the object type indication

◆ gf_mp3_layer()

u8 gf_mp3_layer ( u32  hdr)

gets the layer of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the layer

◆ gf_mp3_frame_size()

u16 gf_mp3_frame_size ( u32  hdr)

gets the frame size of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the size in bytes (includes the 4 bytes header size)

◆ gf_mp3_get_next_header()

u32 gf_mp3_get_next_header ( FILE *  fin)

locates the next frame start in an MPEG-1/2/3 audio stream file

Parameters
finfile to search
Returns
the frame header value, or 0 if not found

◆ gf_mp3_get_next_header_mem()

u32 gf_mp3_get_next_header_mem ( const u8 buffer,
u32  size,
u32 pos 
)

locates the next frame start in an MPEG-1/2/3 audio buffer

Parameters
bufferbuffer to search
sizesize of buffer to search
posset to the start position of the frame header in the buffer
Returns
the frame header value, or 0 if not found

◆ gf_mp3_version()

u8 gf_mp3_version ( u32  hdr)

gets the version size of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the version

◆ gf_mp3_version_name()

const char* gf_mp3_version_name ( u32  hdr)

gets the version name of an MPEG-1/2/3 audio frame

Parameters
hdrthe frame header
Returns
the version name

◆ gf_vorbis_parse_header()

Bool gf_vorbis_parse_header ( GF_VorbisParser vp,
u8 data,
u32  data_len 
)

parses vorbis header packets initializes the parser on success, leave it to NULL otherwise

Parameters
vppointer to a vorbis parser to use
datasource buffer
data_lensize of buffer
Returns
GF_TRUE if success, GF_FALSE otherwise

◆ gf_vorbis_check_frame()

u32 gf_vorbis_check_frame ( GF_VorbisParser vp,
u8 data,
u32  data_len 
)

checks vorbis frame

Parameters
vpthe vorbis parser to use
datasource buffer
data_lensize of buffer
Returns
0 if init error or not a vorbis frame, otherwise returns the number of audio samples in this frame

◆ gf_opus_parse_header()

Bool gf_opus_parse_header ( GF_OpusConfig cfg,
u8 data,
u32  data_len 
)

parses opus header packets - initializes the config on success, leave it to NULL otherwise

Parameters
cfgpointer to a opus config to fill
dataopus header buffer to parse
data_lensize of opus header buffer
Returns
1 if success, 0 if error

◆ gf_opus_check_frame()

u32 gf_opus_check_frame ( GF_OpusConfig cfg,
u8 data,
u32  data_len 
)

checks if an opus frame is valid

Parameters
cfgpointer to a opus config to use
datasource buffer
data_lensize of buffer
Returns
0 if init error or not a vorbis frame, otherwise returns the number of audio samples in this frame

◆ gf_mpegh_escaped_value()

u64 gf_mpegh_escaped_value ( GF_BitStream bs,
u32  nBits1,
u32  nBits2,
u32  nBits3 
)

defined(GPAC_DISABLE_AV_PARSERS) && !defined (GPAC_DISABLE_OGG)

reads escaped value according to usac/mpegh

Parameters
bsbitstream object
nBits1first number of bits
nBits2second number of bits
nBits3third number set of bits
Returns
value read

◆ gf_mpegh_get_mhas_pl()

s32 gf_mpegh_get_mhas_pl ( u8 ptr,
u32  size,
u64 chan_layout 
)

parse profile and level from a MHAS payload

Parameters
ptrthe MHAS payload
sizesize of the MHAS payload
chan_layoutset to the channel layout if found, 0 otherwise - optional, may be NULL
Returns
the MHAS profile found, or -1 of not found

◆ gf_id3_read_size()

u32 gf_id3_read_size ( GF_BitStream bs)

reads a 32 bit sync safe integer of id3v2 from a bitstream object

Parameters
bsthe bitstream object to use - has to be positioned on the start if an id3v2 size field
Returns
the id3v2 size field read

◆ gf_m4a_get_channel_cfg()

u32 gf_m4a_get_channel_cfg ( u32  nb_chan)

returns channel config value (as written in AAC DSI) for the given number of channels

Parameters
nb_chanthe number of channels
Returns
the MPEG-4 AAC channel config value

◆ gf_m4a_get_config()

GF_Err gf_m4a_get_config ( u8 dsi,
u32  dsi_size,
GF_M4ADecSpecInfo cfg 
)

parses MPEG-4 audio dsi

Parameters
dsithe buffer containing the decoder config
dsi_sizesize of the buffer containing the decoder config
cfgwill be filled with the parsed value
Returns
error code if any

◆ gf_m4a_get_profile()

u32 gf_m4a_get_profile ( GF_M4ADecSpecInfo cfg)

gets audio profile and level for a given configuration

Parameters
cfgthe parsed MPEG-4 audio configuration
Returns
audio PL

◆ gf_m4a_write_config()

GF_Err gf_m4a_write_config ( GF_M4ADecSpecInfo cfg,
u8 **  dsi,
u32 dsi_size 
)

writes MPEG-4 audio dsi in a byte buffer - backward-compatible signaling extensions are not written

Parameters
cfgthe configuration to write
dsiset to the encoded buffer (to be freed by caller)
dsi_sizeset to the size of the encoded buffer
Returns
error code if any

◆ gf_m4a_write_config_bs()

GF_Err gf_m4a_write_config_bs ( GF_BitStream bs,
GF_M4ADecSpecInfo cfg 
)

writes MPEG-4 audio dsi in a bitstream object - backward-compatible signaling extensions are not written

Parameters
bsthe bitstream object to write to
cfgthe configuration to write
Returns
error code if any

◆ gf_m4a_parse_config()

GF_Err gf_m4a_parse_config ( GF_BitStream bs,
GF_M4ADecSpecInfo cfg,
Bool  size_known 
)

parses MPEG-4 audio dsi from bitstream

Parameters
bsthe bitstream object to use (shall start in the beginning of the dsi)
cfgwill be filled with the parsed value
size_knownset to GF_TRUE if the bitstream contains the complete DSI (and only it), to parse backward-compatible extensions
Returns
error code if any

◆ gf_m4a_parse_program_config_element()

GF_Err gf_m4a_parse_program_config_element ( GF_BitStream bs,
GF_M4ADecSpecInfo cfg 
)

reads program config element of MPEG-4 audio dsi

Parameters
bsthe bitstream object to use (shall start in the beginning of the dsi)
cfgthe config to fill
Returns
error code if any

◆ gf_m4a_write_program_config_element_bs()

GF_Err gf_m4a_write_program_config_element_bs ( GF_BitStream bs,
GF_M4ADecSpecInfo cfg 
)

writes program config element of MPEG-4 audio dsi

Parameters
bsthe bitstream object to use (shall start in the beginning of the dsi)
cfgthe config to write
Returns
error code if any

◆ gf_m4a_object_type_name()

const char* gf_m4a_object_type_name ( u32  objectType)

gets the name of a given MPEG-4 audio object type

Parameters
objectTypethe object type
Returns
the MPEG-4 audio object type name

◆ gf_m4a_get_profile_name()

const char* gf_m4a_get_profile_name ( u8  audio_pl)

gets the name of the the given MPEG-4 audio profile

Parameters
audio_plthe profile/level
Returns
the MPEG-4 audio profile name

◆ gf_ac3_parser()

Bool gf_ac3_parser ( u8 buffer,
u32  buffer_size,
u32 pos,
GF_AC3Config out_hdr,
Bool  full_parse 
)

parses an AC-3 header from a buffer

Parameters
bufferbuffer to parse
buffer_sizesize of buffer to parse
posset to start offset (in bytes) of the AC3 header parsed
out_hdrwill be filled by parser
full_parseif GF_TRUE, complete parsing of the header will be done
Returns
GF_TRUE if success

◆ gf_ac3_parser_bs()

Bool gf_ac3_parser_bs ( GF_BitStream bs,
GF_AC3Config hdr,
Bool  full_parse 
)

parses an AC-3 header from a bitstream

Parameters
bsbitstream to parse
hdrwill be filled by parser
full_parseif GF_TRUE, complete parsing of the header will be done
Returns
GF_TRUE if success

◆ gf_eac3_parser()

Bool gf_eac3_parser ( u8 buffer,
u32  buffer_size,
u32 pos,
GF_AC3Config hdr,
Bool  full_parse 
)

parses an EAC-3 header from a buffer and checks for next frame/blocks presence

Parameters
bufferbuffer to parse
buffer_sizesize of buffer to parse
posset to start offset (in bytes) of the AC3 header parsed
hdrwill be filled by parser
full_parseif GF_TRUE, complete parsing of the header and check for next frame/blocks presence will be done
Returns
GF_TRUE if success

◆ gf_eac3_parser_bs()

Bool gf_eac3_parser_bs ( GF_BitStream bs,
GF_AC3Config hdr,
Bool  full_parse 
)

parses an EAC-3 header from a bitstream

Parameters
bsbitstream to parse
hdrwill be filled by parser
full_parseif GF_TRUE, complete parsing of the header and check for next frame/blocks presence will be done
Returns
GF_TRUE if success

◆ gf_eac3_get_chan_loc_count()

u32 gf_eac3_get_chan_loc_count ( u32  chan_loc)

gets the number of channels from chan_loc info of EAC3 config

Parameters
chan_locacmod of the associated frame header
Returns
number of channels

◆ gf_ac3_get_channel_layout()

u64 gf_ac3_get_channel_layout ( GF_AC3Config ac3)

gets the channel layout mask from EAC3 config

Parameters
ac3the decoded AC3 configuration
Returns
channel mask

◆ gf_ac3_get_total_channels()

u32 gf_ac3_get_total_channels ( u32  acmod)

gets the total number of channels in an AC3 frame, including surround but not lfe

Parameters
acmodacmod of the associated frame header
Returns
number of channels

◆ gf_ac3_get_surround_channels()

u32 gf_ac3_get_surround_channels ( u32  acmod)

gets the number of surround channels in an AC3 frame

Parameters
acmodacmod of the associated frame header
Returns
number of surround channels

◆ gf_ac3_get_bitrate()

u32 gf_ac3_get_bitrate ( u32  brcode)

gets the bitrate of an AC3 frame

Parameters
brcodebrcode of the associated frame header
Returns
bitrate in bps

◆ gf_avc_get_sps_info()

GF_Err gf_avc_get_sps_info ( u8 sps,
u32  sps_size,
u32 sps_id,
u32 width,
u32 height,
s32 par_n,
s32 par_d 
)

gets basic information from an AVC Sequence Parameter Set

Parameters
spsSPS NAL buffer
sps_sizesize of buffer
sps_idset to the ID
widthset to the width
heightset to the height
par_nset to the pixel aspect ratio numerator
par_dset to the pixel aspect ratio denominator
Returns
error code if any

◆ gf_avc_get_pps_info()

GF_Err gf_avc_get_pps_info ( u8 pps,
u32  pps_size,
u32 pps_id,
u32 sps_id 
)

gets basic information from an AVC Picture Parameter Set

Parameters
ppsPPS NAL buffer
pps_sizesize of buffer
pps_idset to the ID of the PPS
sps_idset to the SPS ID of the PPS
Returns
error code if any

◆ gf_hevc_get_sps_info()

GF_Err gf_hevc_get_sps_info ( u8 sps_data,
u32  sps_size,
u32 sps_id,
u32 width,
u32 height,
s32 par_n,
s32 par_d 
)

gets basic information from an HEVC Sequence Parameter Set

Parameters
sps_dataSPS NAL buffer
sps_sizesize of buffer
sps_idset to the ID
widthset to the width
heightset to the height
par_nset to the pixel aspect ratio numerator
par_dset to the pixel aspect ratio denominator
Returns
error code if any

◆ gf_vvc_get_sps_info()

GF_Err gf_vvc_get_sps_info ( u8 sps_data,
u32  sps_size,
u32 sps_id,
u32 width,
u32 height,
s32 par_n,
s32 par_d 
)

gets basic information from a VVC Sequence Parameter Set

Parameters
sps_dataSPS NAL buffer
sps_sizesize of buffer
sps_idset to the ID
widthset to the width
heightset to the height
par_nset to the pixel aspect ratio numerator
par_dset to the pixel aspect ratio denominator
Returns
error code if any

◆ gf_vvc_get_profile_name()

const char* gf_vvc_get_profile_name ( u8  video_prof)

get VVC profile name

Parameters
video_profprofile value
Returns
the profile name

◆ gf_avc_hevc_get_chroma_format_name()

const char* gf_avc_hevc_get_chroma_format_name ( u8  chroma_format)

gets chroma format name from MPEG chroma format

Parameters
chroma_formatthe chroma format to query (1: 420, 2: 422, 3: 444)
Returns
the name of the format

◆ gf_avc_get_profile_name()

const char* gf_avc_get_profile_name ( u8  profile_idc)

gets AVC profile name from profile indication

Parameters
profile_idcthe PL indication
Returns
the name of the profile

◆ gf_avcc_use_extensions()

Bool gf_avcc_use_extensions ( u8  profile_idc)

checks if avcc extensions are used for this profile

Parameters
profile_idcthe PL indication
Returns
GF_TRUE if extensions must be written in avcc for the given profile

◆ gf_hevc_get_profile_name()

const char* gf_hevc_get_profile_name ( u8  profile_idc)

gets HEVC profile name from profile indication

Parameters
profile_idcthe PL indication
Returns
the name of the profile

◆ gf_img_parse()

void gf_img_parse ( GF_BitStream bs,
u32 codecid,
u32 width,
u32 height,
u8 **  dsi,
u32 dsi_len 
)

parses an image from a bitstream oject. The bitstream must contain the whole image. If a thumbnail is included in the image, the indicated resolution is the one of the main image.

Parameters
bsthe source bitstream
codecidset to the codec ID of the image
widthset to the width of the image
heightset to the height of the image
dsiset to a buffer containing the decoder config of the image if any (in whihc case this buffer shall be freed by the caller)
dsi_lenset to the allocated buffer size

◆ gf_img_jpeg_dec()

GF_Err gf_img_jpeg_dec ( u8 jpg,
u32  jpg_size,
u32 width,
u32 height,
u32 pixel_format,
u8 dst,
u32 dst_size,
u32  dst_nb_comp 
)

decodes a JPEG image in a preallocated buffer

Parameters
jpgthe JPEG buffer
jpg_sizesize of the JPEG buffer
widthset to width of the image
heightset to height of the image
pixel_formatset to pixel format of the image
dstbuffer to hold the decoded pixels (may be NULL)
dst_sizesize in bytes of the buffer to hold the decoded pixels (may be 0)
dst_nb_compnumber of components in destination buffer
Returns
GF_BUFFER_TOO_SMALL if destination buffer is too small or error if any

◆ gf_img_png_dec()

GF_Err gf_img_png_dec ( u8 png,
u32  png_size,
u32 width,
u32 height,
u32 pixel_format,
u8 dst,
u32 dst_size 
)

decodes a PNG image in a preallocated buffer

Parameters
pngthe PNG buffer
png_sizesize of the PNG buffer
widthset to width of the image
heightset to height of the image
pixel_formatset to pixel format of the image
dstbuffer to hold the decoded pixels (may be NULL)
dst_sizesize in bytes of the buffer to hold the decoded pixels (may be 0)
Returns
GF_BUFFER_TOO_SMALL if destination buffer is too small or error if any

◆ gf_img_png_enc()

GF_Err gf_img_png_enc ( u8 data,
u32  width,
u32  height,
s32  stride,
u32  pixel_format,
u8 dst,
u32 dst_size 
)

encodes a raw image into a PNG image

Parameters
datathe pixel data
widththe pixel width
heightthe pixel height
stridethe pixel horizontal stride
pixel_formatpixel format of the image
dstbuffer to hold the decoded pixels (may be NULL)
dst_sizeset to the size in bytes of the buffer to hold the decoded pixels (may be 0)
Returns
GF_BUFFER_TOO_SMALL if destination buffer is too small or error if any

◆ gf_av1_get_obu_name()

const char* gf_av1_get_obu_name ( ObuType  obu_type)

gets the name of a given OBU type

Parameters
obu_typethe OBU type
Returns
the OBU name

Variable Documentation

◆ GF_M4ASampleRates

const u32 GF_M4ASampleRates[]
static
Initial value:
=
{
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
16000, 12000, 11025, 8000, 7350, 0, 0, 0
}

AAC sample rates

◆ GF_M4ANumChannels

const u32 GF_M4ANumChannels[]
static
Initial value:
=
{
1, 2, 3, 4, 5, 6, 8, 0, 0, 0, 7, 8, 0, 8, 0
}

AAC channel configurations