libgpac
Documentation of the core library of GPAC
|
Utility tools for audio and video raw media parsing. More...
Data Structures | |
struct | GF_M4VDecSpecInfo |
struct | ogg_audio_codec_desc |
struct | GF_VorbisParser |
struct | GF_M4ADecSpecInfo |
Variables | |
static const u32 | GF_M4ASampleRates [] |
static const u32 | GF_M4ANumChannels [] |
This section documents the audio and video parsing functions of the GPAC framework.
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 |
struct GF_VorbisParser |
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 |
anonymous enum |
MPEG-4 audio object types
enum ObuType |
enum ObuMetadataType |
Reduces input width/height to common aspect ration num/denum values
width | width of the aspect ratio |
height | height of the aspect ratio |
Reduces input FPS to a more compact value (eg 25000/1000 -> 25/1)
timescale | timescale of the aspect ratio |
sample_dur | sample duration of the aspect ratio in the given timescale |
inserts emulation prevention bytes from buffer_src into buffer_dst
buffer_src | source buffer (NAL without EPB) |
buffer_dst | destination buffer (NAL with EPB) |
nal_size | source buffer size |
gets the number of emulation prevention bytes to add to a non emulated buffer
buffer | source buffer (NAL without EPB) |
nal_size | source buffer size |
Creates a new MPEG-1/2/4 video parser
data | buffer to parse |
data_size | size of buffer to parse |
mpeg12video | if set, parses as MPEG-1 or MPEG-2 |
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
bs | the bitstream object to use for parsing |
mpeg12video | if set, parses as MPEG-1 or MPEG-2 |
void gf_m4v_parser_del | ( | GF_M4VParser * | m4v | ) |
Deletes a MPEG-1/2/4 video parser
m4v | the mpeg video parser |
void gf_m4v_parser_del_no_bs | ( | GF_M4VParser * | m4v | ) |
Deletes a MPEG-1/2/4 video parser without destroying associated bitstream
m4v | the mpeg video parser |
GF_Err gf_m4v_parse_config | ( | GF_M4VParser * | m4v, |
GF_M4VDecSpecInfo * | dsi | ||
) |
parses the decoder specific info (if found)
m4v | the mpeg video parser |
dsi | the decoder spcific info structure to fill |
void gf_m4v_parser_reset | ( | GF_M4VParser * | m4v, |
u8 | obj_type | ||
) |
resets the parser
m4v | the mpeg video parser |
obj_type | if not 0, skip next start code and use (obj_type-1) for next obj parsing |
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
m4v | the mpeg video parser |
dsi | pointer to the decoder specific info parsed |
frame_type | set to the frame type (I:1, P:2, B:3, 0: no frame header found) |
time_inc | set to the time increment since last frame |
size | set to the size of the compressed frame |
start | set to the position of the first byte in the buffer/bitstream |
is_coded | set to 1 if frame is coded, 0 if skip frame, untouched if no frame found |
u64 gf_m4v_get_object_start | ( | GF_M4VParser * | m4v | ) |
returns current object start in bitstream
m4v | the mpeg video parser |
GF_Err gf_m4v_get_config | ( | u8 * | rawdsi, |
u32 | rawdsi_size, | ||
GF_M4VDecSpecInfo * | dsi | ||
) |
decodes DSI/VOSHeader for MPEG4
rawdsi | encoded MPEG-4 decoder config |
rawdsi_size | size of encoded MPEG-4 decoder config |
dsi | the decoder spcific info structure to fill |
GF_Err gf_mpegv12_get_config | ( | u8 * | rawdsi, |
u32 | rawdsi_size, | ||
GF_M4VDecSpecInfo * | dsi | ||
) |
decodes DSI/VOSHeader for MPEG12
rawdsi | encoded MPEG-1/2 decoder config |
rawdsi_size | size of encoded MPEG-1/2 decoder config |
dsi | the decoder spcific info structure to fill |
rewrites Profile and Level indicator in MPEG-4 DSI
io_dsi | encoded MPEG-4 decoder config |
io_dsi_len | size of encoded MPEG-4 decoder config |
PL | the new Profile/level to set |
rewrites PAR code in DSI. Negative values will remove the par
io_dsi | encoded MPEG-4 decoder config |
io_dsi_len | size of encoded MPEG-4 decoder config |
par_n | the numerator of the new aspect ratio to write |
par_d | the denominator of the new aspect ratio to write |
const char* gf_m4v_get_profile_name | ( | u8 | video_pl | ) |
returns readable description of profile
video_pl | the Profile/level |
returns next start code in mpeg 1/2 video buffer
pbuffer | the video buffer |
buflen | size of the video buffer |
optr | set to the byte offset in the buffer |
scode | set to the start code value if found |
returns next slice start in mpeg 1/2 video buffer
pbuffer | the video buffer |
startoffset | the offset in the buffer at which analysis shall begin |
buflen | size of the video buffer |
slice_offset | set to the byte offset of the slice start |
gets the number of channels in an MPEG-1/2/3 audio frame
hdr | the frame header |
gets the sampling rate of an MPEG-1/2/3 audio frame
hdr | the frame header |
gets the window size (number of samples) in an MPEG-1/2/3 audio frame
hdr | the frame header |
gets the bitrate of an MPEG-1/2/3 audio frame
hdr | the frame header |
gets the MPEG-4 object type indication of an MPEG-1/2/3 audio frame
hdr | the frame header |
gets the layer of an MPEG-1/2/3 audio frame
hdr | the frame header |
gets the frame size of an MPEG-1/2/3 audio frame
hdr | the frame header |
u32 gf_mp3_get_next_header | ( | FILE * | fin | ) |
locates the next frame start in an MPEG-1/2/3 audio stream file
fin | file to search |
locates the next frame start in an MPEG-1/2/3 audio buffer
buffer | buffer to search |
size | size of buffer to search |
pos | set to the start position of the frame header in the buffer |
gets the version size of an MPEG-1/2/3 audio frame
hdr | the frame header |
const char* gf_mp3_version_name | ( | u32 | hdr | ) |
gets the version name of an MPEG-1/2/3 audio frame
hdr | the frame 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
vp | pointer to a vorbis parser to use |
data | source buffer |
data_len | size of buffer |
u32 gf_vorbis_check_frame | ( | GF_VorbisParser * | vp, |
u8 * | data, | ||
u32 | data_len | ||
) |
checks vorbis frame
vp | the vorbis parser to use |
data | source buffer |
data_len | size of buffer |
Bool gf_opus_parse_header | ( | GF_OpusConfig * | ocfg, |
u8 * | data, | ||
u32 | data_len | ||
) |
parses opus header packets - initializes the config on success, leave it to NULL otherwise
cfg | pointer to a opus config to fill |
data | opus header buffer to parse |
data_len | size of opus header buffer |
defined(GPAC_DISABLE_AV_PARSERS) && !defined (GPAC_DISABLE_OGG)
u32 gf_opus_check_frame | ( | GF_OpusConfig * | cfg, |
u8 * | data, | ||
u32 | data_len | ||
) |
checks if an opus frame is valid
cfg | pointer to a opus config to use |
data | source buffer |
data_len | size of buffer |
defined(GPAC_DISABLE_AV_PARSERS) && !defined (GPAC_DISABLE_OGG)
reads escaped value according to usac/mpegh
bs | bitstream object |
nBits1 | first number of bits |
nBits2 | second number of bits |
nBits3 | third number set of bits |
parse profile and level from a MHAS payload
ptr | the MHAS payload |
size | size of the MHAS payload |
chan_layout | set to the channel layout if found, 0 otherwise - optional, may be NULL |
u32 gf_id3_read_size | ( | GF_BitStream * | bs | ) |
reads a 32 bit sync safe integer of id3v2 from a bitstream object
bs | the bitstream object to use - has to be positioned on the start if an id3v2 size field |
returns channel config value (as written in AAC DSI) for the given number of channels
nb_chan | the number of channels |
GF_Err gf_m4a_get_config | ( | u8 * | dsi, |
u32 | dsi_size, | ||
GF_M4ADecSpecInfo * | cfg | ||
) |
parses MPEG-4 audio dsi
dsi | the buffer containing the decoder config |
dsi_size | size of the buffer containing the decoder config |
cfg | will be filled with the parsed value |
u32 gf_m4a_get_profile | ( | GF_M4ADecSpecInfo * | cfg | ) |
gets audio profile and level for a given configuration
cfg | the parsed MPEG-4 audio configuration |
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
cfg | the configuration to write |
dsi | set to the encoded buffer (to be freed by caller) |
dsi_size | set to the size of the encoded buffer |
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
bs | the bitstream object to write to |
cfg | the configuration to write |
GF_Err gf_m4a_parse_config | ( | GF_BitStream * | bs, |
GF_M4ADecSpecInfo * | cfg, | ||
Bool | size_known | ||
) |
parses MPEG-4 audio dsi from bitstream
bs | the bitstream object to use (shall start in the beginning of the dsi) |
cfg | will be filled with the parsed value |
size_known | set to GF_TRUE if the bitstream contains the complete DSI (and only it), to parse backward-compatible extensions |
GF_Err gf_m4a_parse_program_config_element | ( | GF_BitStream * | bs, |
GF_M4ADecSpecInfo * | cfg | ||
) |
reads program config element of MPEG-4 audio dsi
bs | the bitstream object to use (shall start in the beginning of the dsi) |
cfg | the config to fill |
GF_Err gf_m4a_write_program_config_element_bs | ( | GF_BitStream * | bs, |
GF_M4ADecSpecInfo * | cfg | ||
) |
writes program config element of MPEG-4 audio dsi
bs | the bitstream object to use (shall start in the beginning of the dsi) |
cfg | the config to write |
const char* gf_m4a_object_type_name | ( | u32 | objectType | ) |
gets the name of a given MPEG-4 audio object type
objectType | the object type |
const char* gf_m4a_get_profile_name | ( | u8 | audio_pl | ) |
gets the name of the the given MPEG-4 audio profile
audio_pl | the profile/level |
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
buffer | buffer to parse |
buffer_size | size of buffer to parse |
pos | set to start offset (in bytes) of the AC3 header parsed |
out_hdr | will be filled by parser |
full_parse | if GF_TRUE, complete parsing of the header will be done |
Bool gf_ac3_parser_bs | ( | GF_BitStream * | bs, |
GF_AC3Config * | hdr, | ||
Bool | full_parse | ||
) |
parses an AC-3 header from a bitstream
bs | bitstream to parse |
hdr | will be filled by parser |
full_parse | if GF_TRUE, complete parsing of the header will be done |
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
buffer | buffer to parse |
buffer_size | size of buffer to parse |
pos | set to start offset (in bytes) of the AC3 header parsed |
hdr | will be filled by parser |
full_parse | if GF_TRUE, complete parsing of the header and check for next frame/blocks presence will be done |
Bool gf_eac3_parser_bs | ( | GF_BitStream * | bs, |
GF_AC3Config * | hdr, | ||
Bool | full_parse | ||
) |
parses an EAC-3 header from a bitstream
bs | bitstream to parse |
hdr | will be filled by parser |
full_parse | if GF_TRUE, complete parsing of the header and check for next frame/blocks presence will be done |
gets the number of channels from chan_loc info of EAC3 config
chan_loc | acmod of the associated frame header |
u64 gf_ac3_get_channel_layout | ( | GF_AC3Config * | ac3 | ) |
gets the channel layout mask from EAC3 config
ac3 | the decoded AC3 configuration |
gets the total number of channels in an AC3 frame, including surround but not lfe
acmod | acmod of the associated frame header |
gets the number of surround channels in an AC3 frame
acmod | acmod of the associated frame header |
gets the bitrate of an AC3 frame
brcode | brcode of the associated frame header |
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
sps | SPS NAL buffer |
sps_size | size of buffer |
sps_id | set to the ID |
width | set to the width |
height | set to the height |
par_n | set to the pixel aspect ratio numerator |
par_d | set to the pixel aspect ratio denominator |
gets basic information from an AVC Picture Parameter Set
pps | PPS NAL buffer |
pps_size | size of buffer |
pps_id | set to the ID of the PPS |
sps_id | set to the SPS ID of the PPS |
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
sps_data | SPS NAL buffer |
sps_size | size of buffer |
sps_id | set to the ID |
width | set to the width |
height | set to the height |
par_n | set to the pixel aspect ratio numerator |
par_d | set to the pixel aspect ratio denominator |
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
sps_data | SPS NAL buffer |
sps_size | size of buffer |
sps_id | set to the ID |
width | set to the width |
height | set to the height |
par_n | set to the pixel aspect ratio numerator |
par_d | set to the pixel aspect ratio denominator |
const char* gf_vvc_get_profile_name | ( | u8 | video_prof | ) |
get VVC profile name
video_prof | profile value |
const char* gf_avc_hevc_get_chroma_format_name | ( | u8 | chroma_format | ) |
gets chroma format name from MPEG chroma format
chroma_format | the chroma format to query (1: 420, 2: 422, 3: 444) |
const char* gf_avc_get_profile_name | ( | u8 | profile_idc | ) |
gets AVC profile name from profile indication
profile_idc | the PL indication |
checks if avcc extensions are used for this profile
profile_idc | the PL indication |
const char* gf_hevc_get_profile_name | ( | u8 | profile_idc | ) |
gets HEVC profile name from profile indication
profile_idc | the PL indication |
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.
bs | the source bitstream |
codecid | set to the codec ID of the image |
width | set to the width of the image |
height | set to the height of the image |
dsi | set to a buffer containing the decoder config of the image if any (in whihc case this buffer shall be freed by the caller) |
dsi_len | set to the allocated buffer size |
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
jpg | the JPEG buffer |
jpg_size | size of the JPEG buffer |
width | set to width of the image |
height | set to height of the image |
pixel_format | set to pixel format of the image |
dst | buffer to hold the decoded pixels (may be NULL) |
dst_size | size in bytes of the buffer to hold the decoded pixels (may be 0) |
dst_nb_comp | number of components in destination buffer |
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
png | the PNG buffer |
png_size | size of the PNG buffer |
width | set to width of the image |
height | set to height of the image |
pixel_format | set to pixel format of the image |
dst | buffer to hold the decoded pixels (may be NULL) |
dst_size | size in bytes of the buffer to hold the decoded pixels (may be 0) |
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
data | the pixel data |
width | the pixel width |
height | the pixel height |
stride | the pixel horizontal stride |
pixel_format | pixel format of the image |
dst | buffer to hold the decoded pixels (may be NULL) |
dst_size | set to the size in bytes of the buffer to hold the decoded pixels (may be 0) |
const char* gf_av1_get_obu_name | ( | ObuType | obu_type | ) |
gets the name of a given OBU type
obu_type | the OBU type |
|
static |
AAC sample rates
|
static |
AAC channel configurations