FFmpeg
Data Structures | Functions | Variables
avio_internal.h File Reference
#include "avio.h"
#include "libavutil/log.h"

Go to the source code of this file.

Data Structures

struct  FFIOContext
 

Functions

static av_always_inline FFIOContextffiocontext (AVIOContext *ctx)
 
void ffio_init_context (FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, const uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
 
void ffio_init_read_context (FFIOContext *s, const uint8_t *buffer, int buffer_size)
 Wrap a buffer in an AVIOContext for reading. More...
 
void ffio_init_write_context (FFIOContext *s, uint8_t *buffer, int buffer_size)
 Wrap a buffer in an AVIOContext for writing. More...
 
int ffio_read_indirect (AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
 Read size bytes from AVIOContext, returning a pointer. More...
 
void ffio_fill (AVIOContext *s, int b, int64_t count)
 
static av_always_inline void ffio_wfourcc (AVIOContext *pb, const uint8_t *s)
 
int ffio_rewind_with_probe_data (AVIOContext *s, unsigned char **buf, int buf_size)
 Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file. More...
 
uint64_t ffio_read_varlen (AVIOContext *bc)
 
unsigned int ffio_read_leb (AVIOContext *s)
 Read a unsigned integer coded as a variable number of up to eight little-endian bytes, where the MSB in a byte signals another byte must be read. More...
 
void ffio_write_leb (AVIOContext *s, unsigned val)
 
void ffio_write_lines (AVIOContext *s, const unsigned char *buf, int size, const unsigned char *ending)
 Write a sequence of text lines, converting line endings. More...
 
int ffio_read_size (AVIOContext *s, unsigned char *buf, int size)
 Read size bytes from AVIOContext into buf. More...
 
int ffio_realloc_buf (AVIOContext *s, int buf_size)
 Reallocate a given buffer for AVIOContext. More...
 
int ffio_ensure_seekback (AVIOContext *s, int64_t buf_size)
 Ensures that the requested seekback buffer size will be available. More...
 
int ffio_limit (AVIOContext *s, int size)
 
void ffio_init_checksum (AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
 
unsigned long ffio_get_checksum (AVIOContext *s)
 
unsigned long ff_crc04C11DB7_update (unsigned long checksum, const uint8_t *buf, unsigned int len)
 
unsigned long ff_crcEDB88320_update (unsigned long checksum, const uint8_t *buf, unsigned int len)
 
unsigned long ff_crcA001_update (unsigned long checksum, const uint8_t *buf, unsigned int len)
 
int ffio_open_dyn_packet_buf (AVIOContext **s, int max_packet_size)
 Open a write only packetized memory stream with a maximum packet size of 'max_packet_size'. More...
 
struct URLContextffio_geturlcontext (AVIOContext *s)
 Return the URLContext associated with the AVIOContext. More...
 
int ffio_fdopen (AVIOContext **s, struct URLContext *h)
 Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h. More...
 
int ffio_copy_url_options (AVIOContext *pb, AVDictionary **avio_opts)
 Read url related dictionary options from the AVIOContext and write to the given dictionary. More...
 
int ffio_open_null_buf (AVIOContext **s)
 Open a write-only fake memory stream. More...
 
int ffio_open_whitelist (AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
 
int ffio_close_null_buf (AVIOContext *s)
 Close a null buffer. More...
 
void ffio_reset_dyn_buf (AVIOContext *s)
 Reset a dynamic buffer. More...
 
void ffio_free_dyn_buf (AVIOContext **s)
 Free a dynamic buffer. More...
 
int64_t ff_read_line_to_bprint_overwrite (AVIOContext *s, struct AVBPrint *bp)
 Read a whole line of text from AVIOContext to an AVBPrint buffer overwriting its contents. More...
 
int64_t ff_read_string_to_bprint_overwrite (AVIOContext *s, struct AVBPrint *bp, int64_t max_len)
 Read a whole null-terminated string of text from AVIOContext to an AVBPrint buffer overwriting its contents. More...
 

Variables

const AVClass ff_avio_class
 

Function Documentation

◆ ffiocontext()

static av_always_inline FFIOContext* ffiocontext ( AVIOContext ctx)
static

◆ ffio_init_context()

void ffio_init_context ( FFIOContext s,
unsigned char *  buffer,
int  buffer_size,
int  write_flag,
void *  opaque,
int(*)(void *opaque, uint8_t *buf, int buf_size)  read_packet,
int(*)(void *opaque, const uint8_t *buf, int buf_size)  write_packet,
int64_t(*)(void *opaque, int64_t offset, int whence)  seek 
)

◆ ffio_init_read_context()

void ffio_init_read_context ( FFIOContext s,
const uint8_t *  buffer,
int  buffer_size 
)

◆ ffio_init_write_context()

void ffio_init_write_context ( FFIOContext s,
uint8_t *  buffer,
int  buffer_size 
)

Wrap a buffer in an AVIOContext for writing.

Definition at line 103 of file aviobuf.c.

Referenced by asf_write_header(), ff_av1_filter_obus_buf(), flush_packet(), mms_put_utf16(), and ogg_write_vorbiscomment().

◆ ffio_read_indirect()

int ffio_read_indirect ( AVIOContext s,
unsigned char *  buf,
int  size,
const unsigned char **  data 
)

Read size bytes from AVIOContext, returning a pointer.

Note that the data pointed at by the returned pointer is only valid until the next call that references the same IO context.

Parameters
sIO context
bufpointer to buffer into which to assemble the requested data if it is not available in contiguous addresses in the underlying buffer
sizenumber of bytes requested
dataaddress at which to store pointer: this will be a a direct pointer into the underlying buffer if the requested number of bytes are available at contiguous addresses, otherwise will be a copy of buf
Returns
number of bytes read or AVERROR

Definition at line 671 of file aviobuf.c.

Referenced by read_packet().

◆ ffio_fill()

void ffio_fill ( AVIOContext s,
int  b,
int64_t  count 
)

◆ ffio_wfourcc()

static av_always_inline void ffio_wfourcc ( AVIOContext pb,
const uint8_t *  s 
)
static

Definition at line 124 of file avio_internal.h.

Referenced by aiff_write_header(), amv_start_tag(), amv_write_alist(), amv_write_header(), amv_write_packet_internal(), amv_write_trailer(), amv_write_vlist(), ast_write_header(), ast_write_packet(), avi_start_new_riff(), avi_write_header(), avi_write_idx1(), avi_write_ix(), avi_write_trailer(), caf_write_header(), caf_write_trailer(), ff_mov_cenc_write_sinf_tag(), ff_mov_write_packet(), ff_riff_write_info(), ff_riff_write_info_tag(), ff_start_tag(), mov_cenc_write_saio_tag(), mov_cenc_write_saiz_tag(), mov_cenc_write_schi_tag(), mov_cenc_write_senc_tag(), mov_flush_fragment(), mov_preroll_write_stbl_atoms(), mov_write_3gp_udta_tag(), mov_write_ac3_tag(), mov_write_amr_tag(), mov_write_amve_tag(), mov_write_audio_tag(), mov_write_aux_tag(), mov_write_av1c_tag(), mov_write_avcc_tag(), mov_write_avid_tag(), mov_write_btrt_tag(), mov_write_ccst_tag(), mov_write_chan_tag(), mov_write_chnl_tag(), mov_write_chpl_tag(), mov_write_clap_tag(), mov_write_clli_tag(), mov_write_colr_tag(), mov_write_covr(), mov_write_ctts_tag(), mov_write_d263_tag(), mov_write_dfla_tag(), mov_write_dinf_tag(), mov_write_dmlp_tag(), mov_write_dops_tag(), mov_write_dpxe_tag(), mov_write_dref_tag(), mov_write_dvc1_tag(), mov_write_dvcc_dvvc_tag(), mov_write_eac3_tag(), mov_write_edts_tag(), mov_write_enda_tag(), mov_write_enda_tag_be(), mov_write_esds_tag(), mov_write_evcc_tag(), mov_write_fiel_tag(), mov_write_ftyp_tag(), mov_write_ftyp_tag_internal(), mov_write_gama_tag(), mov_write_glbl_tag(), mov_write_gmhd_tag(), mov_write_gpmd_tag(), mov_write_hdlr_tag(), mov_write_hmhd_tag(), mov_write_hvcc_tag(), mov_write_iacb_tag(), mov_write_iinf_tag(), mov_write_iloc_tag(), mov_write_ilst_tag(), mov_write_int8_metadata(), mov_write_iods_tag(), mov_write_ipco_tag(), mov_write_ipma_tag(), mov_write_iprp_tag(), mov_write_iref_tag(), mov_write_isml_manifest(), mov_write_ispe_tag(), mov_write_itunes_hdlr_tag(), mov_write_loci_tag(), mov_write_mdat_tag(), mov_write_mdcv_tag(), mov_write_mdhd_tag(), mov_write_mdia_tag(), mov_write_mdta_hdlr_tag(), mov_write_mdta_ilst_tag(), mov_write_mdta_keys_tag(), mov_write_meta_tag(), mov_write_mfhd_tag(), mov_write_mfra_tag(), mov_write_minf_tag(), mov_write_moof_tag_internal(), mov_write_moov_tag(), mov_write_mvex_tag(), mov_write_mvhd_tag(), mov_write_nmhd_tag(), mov_write_pasp_tag(), mov_write_pcmc_tag(), mov_write_pitm_tag(), mov_write_pixi_tag(), mov_write_prft_tag(), mov_write_raw_metadata_tag(), mov_write_rtp_tag(), mov_write_sdtp_tag(), mov_write_sidx_tag(), mov_write_smhd_tag(), mov_write_source_reference_tag(), mov_write_st3d_tag(), mov_write_stbl_tag(), mov_write_stco_tag(), mov_write_sthd_tag(), mov_write_string_data_tag(), mov_write_string_tag(), mov_write_stsc_tag(), mov_write_stsd_tag(), mov_write_stss_tag(), mov_write_stsz_tag(), mov_write_stts_tag(), mov_write_sv3d_tag(), mov_write_tapt_tag(), mov_write_tcmi_tag(), mov_write_tfdt_tag(), mov_write_tfhd_tag(), mov_write_tfra_tag(), mov_write_tfrf_tag(), mov_write_tfxd_tag(), mov_write_tkhd_tag(), mov_write_tmcd_tag(), mov_write_tmpo_tag(), mov_write_track_kind(), mov_write_track_metadata(), mov_write_track_udta_tag(), mov_write_traf_tag(), mov_write_trailer(), mov_write_trak_tag(), mov_write_tref_tag(), mov_write_trex_tag(), mov_write_trkn_tag(), mov_write_trun_tag(), mov_write_udta_sdp(), mov_write_udta_tag(), mov_write_uuid_tag_ipod(), mov_write_uuid_tag_psp(), mov_write_uuidprof_tag(), mov_write_uuidusmt_tag(), mov_write_video_tag(), mov_write_vmhd_tag(), mov_write_vpcc_tag(), mov_write_vvcc_tag(), mov_write_wave_tag(), mov_write_wfex_tag(), mp3_write_xing(), oma_write_header(), rv10_write_header(), sox_write_header(), update_odml_entry(), write_odml_master(), and write_styp().

◆ ffio_rewind_with_probe_data()

int ffio_rewind_with_probe_data ( AVIOContext s,
unsigned char **  buf,
int  buf_size 
)

Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file.

Used after probing to avoid seeking. Joins buf and s->buffer, taking any overlap into consideration.

Note
s->buffer must overlap with buf or they can't be joined and the function fails
Parameters
sThe read-only AVIOContext to rewind
bufThe probe buffer containing the first buf_size bytes of the file
buf_sizeThe size of buf
Returns
>= 0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 1147 of file aviobuf.c.

Referenced by av_probe_input_buffer2(), and ff_img_read_header().

◆ ffio_read_varlen()

uint64_t ffio_read_varlen ( AVIOContext bc)

◆ ffio_read_leb()

unsigned int ffio_read_leb ( AVIOContext s)

Read a unsigned integer coded as a variable number of up to eight little-endian bytes, where the MSB in a byte signals another byte must be read.

All coded bytes are read, but values > UINT_MAX are truncated.

Definition at line 926 of file aviobuf.c.

Referenced by ambisonics_config(), audio_element_obu(), audio_frame_obu(), codec_config_obu(), mix_presentation_obu(), mov_read_iacb(), param_parse(), and parameter_block_obu().

◆ ffio_write_leb()

void ffio_write_leb ( AVIOContext s,
unsigned  val 
)

◆ ffio_write_lines()

void ffio_write_lines ( AVIOContext s,
const unsigned char *  buf,
int  size,
const unsigned char *  ending 
)

Write a sequence of text lines, converting line endings.

All input line endings (LF, CRLF, CR) are converted to the configured line ending.

Parameters
sThe AVIOContext to write to
bufThe buffer to write
sizeThe size of the buffer, or <0 to use the full length of a null-terminated string
endingThe line ending sequence to convert to, or NULL for

Definition at line 959 of file aviobuf.c.

Referenced by write_header(), and write_trailer().

◆ ffio_read_size()

int ffio_read_size ( AVIOContext s,
unsigned char *  buf,
int  size 
)

◆ ffio_realloc_buf()

int ffio_realloc_buf ( AVIOContext s,
int  buf_size 
)

Reallocate a given buffer for AVIOContext.

Parameters
sthe AVIOContext to realloc.
buf_sizerequired new buffer size.
Returns
0 on success, a negative AVERROR on failure.

Definition at line 1102 of file aviobuf.c.

Referenced by ff_configure_buffers_for_index().

◆ ffio_ensure_seekback()

int ffio_ensure_seekback ( AVIOContext s,
int64_t  buf_size 
)

Ensures that the requested seekback buffer size will be available.

Will ensure that when reading sequentially up to buf_size, seeking within the current pos and pos+buf_size is possible. Once the stream position moves outside this window or another ffio_ensure_seekback call requests a buffer outside this window this guarantee is lost.

Definition at line 1022 of file aviobuf.c.

Referenced by apng_read_header(), apng_read_packet(), bonk_read_header(), dhav_read_header(), evc_read_packet(), ff_iamf_read_packet(), ff_iamfdec_read_descriptors(), id3v2_parse(), id3v2_read_internal(), ivr_read_header(), mlp_read_header(), mov_read_wave(), mp3_read_header(), mpegps_read_packet(), mpegps_read_pes_header(), mpegts_read_header(), mpegts_resync(), mpjpeg_read_packet(), ogg_read_page(), qoa_read_header(), resync(), rm_read_header(), set_spdif(), sga_read_packet(), subviewer_read_header(), and wsvqa_read_packet().

◆ ffio_limit()

int ffio_limit ( AVIOContext s,
int  size 
)

◆ ffio_init_checksum()

void ffio_init_checksum ( AVIOContext s,
unsigned long(*)(unsigned long c, const uint8_t *p, unsigned int len update_checksum,
unsigned long  checksum 
)

◆ ffio_get_checksum()

unsigned long ffio_get_checksum ( AVIOContext s)

◆ ff_crc04C11DB7_update()

unsigned long ff_crc04C11DB7_update ( unsigned long  checksum,
const uint8_t *  buf,
unsigned int  len 
)

Definition at line 564 of file aviobuf.c.

Referenced by get_packetheader(), nut_write_packet(), ogg_read_page(), and put_packet().

◆ ff_crcEDB88320_update()

unsigned long ff_crcEDB88320_update ( unsigned long  checksum,
const uint8_t *  buf,
unsigned int  len 
)

Definition at line 570 of file aviobuf.c.

Referenced by tta_read_header(), and tta_write_header().

◆ ff_crcA001_update()

unsigned long ff_crcA001_update ( unsigned long  checksum,
const uint8_t *  buf,
unsigned int  len 
)

Definition at line 576 of file aviobuf.c.

Referenced by mp3_parse_vbr_tags().

◆ ffio_open_dyn_packet_buf()

int ffio_open_dyn_packet_buf ( AVIOContext **  s,
int  max_packet_size 
)

Open a write only packetized memory stream with a maximum packet size of 'max_packet_size'.

The stream is stored in a memory buffer with a big-endian 4 byte header giving the packet size in bytes.

Parameters
snew IO context
max_packet_sizemaximum packet size (must be > 0)
Returns
zero if no error.

Definition at line 1366 of file aviobuf.c.

Referenced by ff_mov_add_hinted_packet(), ff_rtp_chain_mux_open(), and ff_rtsp_tcp_write_packet().

◆ ffio_geturlcontext()

struct URLContext* ffio_geturlcontext ( AVIOContext s)

Return the URLContext associated with the AVIOContext.

Parameters
sIO context
Returns
pointer to URLContext or NULL.

Definition at line 106 of file avio.c.

Referenced by dashenc_io_close(), dashenc_io_open(), hlsenc_io_close(), hlsenc_io_open(), and open_url_keepalive().

◆ ffio_fdopen()

int ffio_fdopen ( AVIOContext **  s,
struct URLContext h 
)

Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h.

Note
When the URLContext h has been opened in read+write mode, the AVIOContext can be used only for writing.
Parameters
sUsed to return the pointer to the created AVIOContext. In case of failure the pointed to value is set to NULL.
Returns
>= 0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 411 of file avio.c.

Referenced by avio_accept(), ff_rtp_chain_mux_open(), and ffio_open_whitelist().

◆ ffio_copy_url_options()

int ffio_copy_url_options ( AVIOContext pb,
AVDictionary **  avio_opts 
)

Read url related dictionary options from the AVIOContext and write to the given dictionary.

Definition at line 990 of file aviobuf.c.

Referenced by dash_read_header(), hls_read_header(), and imf_read_header().

◆ ffio_open_null_buf()

int ffio_open_null_buf ( AVIOContext **  s)

Open a write-only fake memory stream.

The written data is not stored anywhere - this is only used for measuring the amount of data written.

Parameters
snew IO context
Returns
zero if no error.

Definition at line 1456 of file aviobuf.c.

Referenced by get_moov_size(), get_sidx_size(), mov_write_moof_tag(), and mov_write_sidx_tags().

◆ ffio_open_whitelist()

int ffio_open_whitelist ( AVIOContext **  s,
const char *  url,
int  flags,
const AVIOInterruptCB int_cb,
AVDictionary **  options,
const char *  whitelist,
const char *  blacklist 
)

Definition at line 470 of file avio.c.

Referenced by avio_open2(), import_pem(), io_open_default(), and parse_playlist().

◆ ffio_close_null_buf()

int ffio_close_null_buf ( AVIOContext s)

Close a null buffer.

Parameters
san IO context opened by ffio_open_null_buf
Returns
the number of bytes written to the null buffer

Definition at line 1466 of file aviobuf.c.

Referenced by get_moov_size(), get_sidx_size(), mov_write_moof_tag(), and mov_write_sidx_tags().

◆ ffio_reset_dyn_buf()

void ffio_reset_dyn_buf ( AVIOContext s)

Reset a dynamic buffer.

Resets everything, but keeps the allocated buffer for later use.

Definition at line 1395 of file aviobuf.c.

Referenced by asf_write_header1(), asf_write_markers(), end_ebml_master_crc32(), mkv_assemble_cues(), mkv_update_codecprivate(), mkv_write_tag(), mkv_write_track(), mkv_write_trailer(), put_packet(), and put_str16().

◆ ffio_free_dyn_buf()

void ffio_free_dyn_buf ( AVIOContext **  s)

Free a dynamic buffer.

Parameters
sa pointer to an IO context opened by avio_open_dyn_buf()

Definition at line 1434 of file aviobuf.c.

Referenced by ac3_close_context(), ac3_handle_packet(), asf_write_header1(), asfrtp_close_context(), asfrtp_parse_packet(), dash_free(), decode_str(), dv_close_context(), dv_handle_packet(), end_ebml_master_crc32(), ff_ape_write_tag(), ff_hevc_annexb2mp4_buf(), ff_iamf_write_audio_frame(), ff_id3v2_write_apic(), ff_isom_write_av1c(), ff_isom_write_avcc(), ff_mov_close_hinting(), ff_mov_generate_squashed_ttml_packet(), ff_rtp_chain_mux_open(), ff_rtsp_undo_setup(), ff_vvc_annexb2mp4_buf(), film_deinit(), h261_close_context(), h261_handle_packet(), h263_close_context(), h263_handle_packet(), hls_write_trailer(), iamf_write_audio_element(), iamf_write_codec_config(), iamf_write_mixing_presentation(), id3v2_put_priv(), id3v2_put_ttag(), jpeg_close_context(), jpeg_parse_packet(), latm_close_context(), latm_parse_packet(), mkv_deinit(), mkv_write_attachments(), mkv_write_chapters(), mkv_write_trailer(), mov_flush_fragment(), mov_flush_fragment_interleaving(), mov_free(), mov_write_mfra_tag(), mov_write_track_udta_tag(), mov_write_udta_tag(), mpa_robust_close_context(), mpa_robust_parse_packet(), mpegts_write_packet_internal(), nut_write_packet(), nut_write_trailer(), rtp_mpegts_write_close(), rtp_mpegts_write_header(), set_codec_str(), svq3_close_context(), svq3_parse_packet(), tta_deinit(), vc2hq_handle_frame_fragment(), vc2hq_handle_packet(), vp8_broken_sequence(), vp8_close_context(), vp8_handle_packet(), vp9_close_context(), vp9_handle_packet(), webm_chunk_deinit(), write_chapter(), write_ctoc(), write_headers(), write_parameter_block(), xiph_close_context(), and xiph_handle_packet().

◆ ff_read_line_to_bprint_overwrite()

int64_t ff_read_line_to_bprint_overwrite ( AVIOContext s,
struct AVBPrint *  bp 
)

Read a whole line of text from AVIOContext to an AVBPrint buffer overwriting its contents.

Stop reading after reaching a \r, a \n, a \r\n, a \0 or EOF. The line ending characters are NOT included in the buffer, but they are skipped on the input.

Parameters
sthe read-only AVIOContext
bpthe AVBPrint buffer
Returns
the length of the read line not including the line endings, negative on error, or if the buffer becomes truncated.

Definition at line 854 of file aviobuf.c.

Referenced by concat_parse_script().

◆ ff_read_string_to_bprint_overwrite()

int64_t ff_read_string_to_bprint_overwrite ( AVIOContext s,
struct AVBPrint *  bp,
int64_t  max_len 
)

Read a whole null-terminated string of text from AVIOContext to an AVBPrint buffer overwriting its contents.

Stop reading after reaching the maximum length, a \0 or EOF.

Parameters
sthe read-only AVIOContext
bpthe AVBPrint buffer
max_lenthe maximum length to be read from the AVIOContext. Negative (< 0) values signal that there is no known maximum length applicable. A maximum length of zero means that the AVIOContext is not touched, and the function returns with a read length of zero. In all cases the AVBprint is cleared.
Returns
the length of the read string not including the terminating null, negative on error, or if the buffer becomes truncated.

Definition at line 859 of file aviobuf.c.

Referenced by mov_read_infe(), and mov_read_kind().

Variable Documentation

◆ ff_avio_class

const AVClass ff_avio_class

Definition at line 97 of file avio.c.

Referenced by ffio_fdopen(), and format_child_class_iterate().