|
FFmpeg
|
Functions responsible for allocating, freeing, and copying memory. More...
Functions | |
| void * | av_malloc (size_t size) av_malloc_attrib 1(1) |
| Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU). More... | |
| void * | av_mallocz (size_t size) av_malloc_attrib 1(1) |
| Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block. More... | |
| void * | av_malloc_array (size_t nmemb, size_t size) |
| void * | av_calloc (size_t nmemb, size_t size) av_malloc_attrib 1(1 |
| Allocate a memory block for an array with av_mallocz(). More... | |
| void void * | av_realloc (void *ptr, size_t size) 1(2) |
| Allocate, reallocate, or free a block of memory. More... | |
| av_warn_unused_result int | av_reallocp (void *ptr, size_t size) |
| Allocate, reallocate, or free a block of memory through a pointer to a pointer. More... | |
| void * | av_realloc_f (void *ptr, size_t nelem, size_t elsize) |
| Allocate, reallocate, or free a block of memory. More... | |
| void * | av_realloc_array (void *ptr, size_t nmemb, size_t size) |
| int | av_reallocp_array (void *ptr, size_t nmemb, size_t size) |
| Allocate, reallocate an array through a pointer to a pointer. More... | |
| void * | av_fast_realloc (void *ptr, unsigned int *size, size_t min_size) |
| Reallocate the given buffer if it is not large enough, otherwise do nothing. More... | |
| void | av_fast_malloc (void *ptr, unsigned int *size, size_t min_size) |
| Allocate a buffer, reusing the given one if large enough. More... | |
| void | av_fast_mallocz (void *ptr, unsigned int *size, size_t min_size) |
| Allocate and clear a buffer, reusing the given one if large enough. More... | |
| void | av_free (void *ptr) |
| Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family. More... | |
| void | av_freep (void *ptr) |
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family, and set the pointer pointing to it to NULL. More... | |
| char * | av_strdup (const char *s) av_malloc_attrib |
| Duplicate a string. More... | |
| char * | av_strndup (const char *s, size_t len) av_malloc_attrib |
| Duplicate a substring of a string. More... | |
| void * | av_memdup (const void *p, size_t size) |
| Duplicate a buffer with av_malloc(). More... | |
| void | av_memcpy_backptr (uint8_t *dst, int back, int cnt) |
| Overlapping memcpy() implementation. More... | |
Functions responsible for allocating, freeing, and copying memory.
All memory allocation functions have a built-in upper limit of INT_MAX bytes. This may be changed with av_max_alloc(), although exercise extreme caution when doing so.
| void* av_malloc | ( | size_t | size | ) |
Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU).
| size | Size in bytes for the memory block to be allocated |
NULL if the block cannot be allocated Definition at line 98 of file mem.c.
Referenced by av_malloc(), av_malloc_array(), av_mallocz(), av_memdup(), and fast_malloc().
| void* av_mallocz | ( | size_t | size | ) |
Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block.
| size | Size in bytes for the memory block to be allocated |
NULL if it cannot be allocated Definition at line 256 of file mem.c.
Referenced by av_calloc(), and fast_malloc().
| void* av_calloc | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Allocate a memory block for an array with av_mallocz().
The allocated memory will have size size * nmemb bytes.
| nmemb | Number of elements |
| size | Size of the single element |
NULL if the block cannot be allocated| void void* av_realloc | ( | void * | ptr, |
| size_t | size | ||
| ) |
Allocate, reallocate, or free a block of memory.
If ptr is NULL and size > 0, allocate a new block. Otherwise, expand or shrink that block of memory according to size.
| ptr | Pointer to a memory block already allocated with av_realloc() or NULL |
| size | Size in bytes of the memory block to be allocated or reallocated |
NULL if the block cannot be reallocatedDefinition at line 155 of file mem.c.
Referenced by av_fast_realloc(), av_realloc_array(), av_realloc_f(), av_reallocp(), av_strdup(), and av_strndup().
| av_warn_unused_result int av_reallocp | ( | void * | ptr, |
| size_t | size | ||
| ) |
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
If *ptr is NULL and size > 0, allocate a new block. If size is zero, free the memory block pointed to by *ptr. Otherwise, expand or shrink that block of memory according to size.
| [in,out] | ptr | Pointer to a pointer to a memory block already allocated with av_realloc(), or a pointer to NULL. The pointer is updated on success, or freed on failure. |
| [in] | size | Size in bytes for the memory block to be allocated or reallocated |
Definition at line 188 of file mem.c.
Referenced by aom_init(), append_flv_data(), asfrtp_parse_packet(), auxiliary_info_alloc_size(), av_probe_input_buffer2(), av_vdpau_bind_context(), avi_read_header(), bmv_read_packet(), cbs_write_unit_data(), concatenate_packet(), decode_frame(), dyn_buf_write(), ff_cbs_h2645_assemble_fragment(), ff_els_decode_unsigned(), ff_opencl_filter_load_program_from_file(), fixup_vorbis_headers(), flashsv_decode_frame(), g2m_load_cursor(), get_tcp_server_response(), h264_extradata_to_annexb(), handle_metadata(), hap_decode(), hevc_extradata_to_annexb(), http_open(), jpg_decode_data(), mediacodec_receive(), mov_cenc_end_packet(), mov_realloc_extradata(), omx_encode_frame(), omx_encode_init(), opt_get_array(), parse_icy(), qt_rtp_parse_packet(), rdt_parse_sdp_line(), realloc_buffer(), rtmp_http_write(), rtmp_open(), rtmp_write(), set_segment_filename(), tdsc_decode_frame(), tdsc_decode_tiles(), tdsc_init(), tdsc_load_cursor(), tgv_decode_inter(), theora_header(), tls_handshake_loop(), tls_read(), vorbis_packet(), vpx_init(), and vvc_extradata_to_annexb().
| void* av_realloc_f | ( | void * | ptr, |
| size_t | nelem, | ||
| size_t | elsize | ||
| ) |
Allocate, reallocate, or free a block of memory.
This function does the same thing as av_realloc(), except:
nelem * elsize bytes, after checking the result of the multiplication for integer overflow.Definition at line 173 of file mem.c.
Referenced by av_reallocp_array().
| void* av_realloc_array | ( | void * | ptr, |
| size_t | nmemb, | ||
| size_t | size | ||
| ) |
Definition at line 217 of file mem.c.
Referenced by add_param_definition(), add_serial_pair(), add_side_data_from_buf_ext(), amf_encode_init_av1(), append_pad(), apv_add_configuration_entry(), apv_add_frameinfo(), aribcaption_init(), audio_element_obu(), av_dict_set(), av_fifo_alloc2(), av_fifo_grow2(), av_frame_replace(), av_opt_set_array(), av_program_add_stream_index(), avfilter_graph_alloc_filter(), avformat_new_stream(), avformat_stream_group_create(), codec_config_obu(), common_init(), decode_header(), decode_styl(), decode_unregistered_user_data(), decoded_frames_get_free(), ff_alsa_extend_reorder_buf(), ff_ass_add_rect2(), ff_cbs_sei_list_add(), ff_encode_add_cpb_side_data(), ff_framequeue_add(), ff_iamf_add_audio_element(), ff_iamf_add_mix_presentation(), ff_mov_write_packet(), ff_qsv_enc_init(), ff_rtmp_check_alloc_array(), ff_vaapi_decode_make_param_buffer(), ff_vaapi_decode_make_slice_buffer(), fill_codec_config(), fill_marker_resource(), filter_frame(), flv_queue_extradata(), frame_hash(), get_preset_file(), grow_array(), handle_file(), handler(), init(), jpeg2000_decode_packet(), log_callback(), mix_presentation_obu(), mkv_add_cuepoint(), mov_read_iinf(), mov_read_iloc(), mov_read_iref_dimg(), mxf_read_partition_pack(), new_stream_video(), ogg_new_stream(), open_virtual_track(), opt_set_array(), packet_side_data_add(), param_parse(), parse_audio_preroll(), parse_imf_asset_map_from_xml_dom(), progress_init(), push_main_audio_sequence(), push_marker_sequence(), rd_get(), realloc_section_array(), sample_queue_push(), slices_realloc(), sq_add_stream(), stream_group_add_stream(), tee_open(), update_block_dimensions(), update_frag_index(), vaapi_av1_decode_slice(), vaapi_encode_make_packed_header(), vaapi_encode_make_param_buffer(), wpp_progress_init(), wv_alloc_frame_context(), and xan_decode_frame().
| int av_reallocp_array | ( | void * | ptr, |
| size_t | nmemb, | ||
| size_t | size | ||
| ) |
Allocate, reallocate an array through a pointer to a pointer.
If *ptr is NULL and nmemb > 0, allocate a new block.
| [in,out] | ptr | Pointer to a pointer to a memory block already allocated with av_realloc(), or a pointer to NULL. The pointer is updated on success, or freed on failure. |
| [in] | nmemb | Number of elements |
| [in] | size | Size of the single element |
Definition at line 225 of file mem.c.
Referenced by add_fragment(), add_program(), add_segment(), add_tracked_method(), allocate_buffers(), ass_split_section(), evcc_array_add_nal_unit(), ff_h2645_extract_rbsp(), ff_h2645_sei_ctx_replace(), ff_hap_set_chunk_count(), gem_decode_frame(), gxf_write_map_packet(), gxf_write_packet(), hvcc_array_add_nal_unit(), hw_device_add(), init_tile_data(), mov_add_tfra_entries(), mov_build_index(), mov_finish_fragment(), mov_read_trex(), mxf_write_packet(), mxf_write_partition(), nut_write_packet(), ogg_restore(), opencl_frames_get_constraints(), parse_adaptation_sets(), parse_strk(), tgv_decode_inter(), tm2_read_stream(), update_dimensions_clear_info(), update_index(), vp56_size_changed(), vvcc_array_add_nal_unit(), and write_tiles().
| void* av_fast_realloc | ( | void * | ptr, |
| unsigned int * | size, | ||
| size_t | min_size | ||
| ) |
Reallocate the given buffer if it is not large enough, otherwise do nothing.
If the given buffer is NULL, then a new uninitialized buffer is allocated.
If the given buffer is not large enough, and reallocation fails, NULL is returned and *size is set to 0, but the original buffer is not changed or freed.
A typical use pattern follows:
| [in,out] | ptr | Already allocated buffer, or NULL |
| [in,out] | size | Pointer to the size of buffer ptr. *size is updated to the new allocated size, in particular 0 in case of failure. |
| [in] | min_size | Desired minimal size of buffer ptr |
ptr if the buffer is large enough, a pointer to newly reallocated buffer if the buffer was not large enough, or NULL in case of error Definition at line 497 of file mem.c.
Referenced by add_index_entry(), add_tts_entry(), av_exif_set_entry(), caf_write_packet(), config_output(), decode_frame(), dirac_combine_frame(), draw_items(), dxv_decode(), dxva2_av1_decode_slice(), evc_frame_merge_filter(), exif_parse_ifd_list(), ff_add_index_entry(), ff_af_queue_add(), ff_av1_packet_split(), ff_combine_frame(), ff_h2645_packet_split(), ff_mms_asf_header_parser(), ff_nvdec_simple_decode_slice(), ff_range_add(), ff_subtitles_queue_insert(), ff_tx_init_subtx(), ff_vdpau_add_buffer(), ff_videotoolbox_buffer_append(), ff_videotoolbox_buffer_copy(), ff_vk_decode_add_slice(), ff_vk_exec_add_dep_buf(), ff_vk_exec_add_dep_sw_frame(), filter_frame(), flac_fifo_read_wrap(), get_stats(), h264_extradata_to_annexb(), h264_mp4toannexb_save_ps(), init(), intercept_id3(), libx265_encode_frame(), lzf_realloc(), mov_merge_tts_data(), mov_parse_auxiliary_info(), mov_read_ctts(), mov_read_pssh(), mov_read_saio(), mov_read_senc(), mov_read_stts(), mov_read_trun(), mov_text_style_start(), mxg_update_cache(), nal_parse_units(), nvdec_av1_decode_slice(), nvdec_h264_decode_slice(), nvdec_hevc_decode_slice(), nvdec_vc1_decode_slice(), op_pass_setup(), open_track_file_resource(), parse_string(), prepare_sei_data_array(), push_main_audio_sequence(), push_main_image_2d_sequence(), queue_frames(), read_frame(), setup_frame(), shorten_decode_frame(), spdif_header_eac3(), update_frag_index(), and vc1_decode_frame().
| void av_fast_malloc | ( | void * | ptr, |
| unsigned int * | size, | ||
| size_t | min_size | ||
| ) |
Allocate a buffer, reusing the given one if large enough.
Contrary to av_fast_realloc(), the current buffer contents might not be preserved and on error the old buffer is freed, thus no special handling to avoid memleaks is necessary.
*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.
| [in,out] | ptr | Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure |
| [in,out] | size | Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure. |
| [in] | min_size | Desired minimal size of buffer *ptr |
Definition at line 557 of file mem.c.
Referenced by alloc_scratch_buffers(), allocate_buffers(), ape_decode_frame(), audio_decode_frame(), av_fast_padded_mallocz(), bl16_decode_8(), chs_alloc_lsb_band_data(), chs_alloc_msb_band_data(), chs_assemble_freq_bands(), codec_reinit(), crypto_write(), decode_frame(), decode_remap(), detect_clips(), do_interpolation(), ff_dca_core_filter_fixed(), ff_h274_hash_verify(), fic_decode_frame(), filter_frame_float(), find_motion(), gif_decode_frame(), gif_read_image(), id3v2_parse(), interpolation(), ljpeg_decode_rgb_scan(), magy_decode_frame(), opus_decode_subpacket(), parse_navi_table(), parse_utf(), pmp_packet(), rscc_decode_frame(), scale_internal(), spdif_header_dts4(), spdif_write_packet(), tak_decode_frame(), truemotion1_decode_header(), truemotion1_decode_init(), update_block_dimensions(), update_init_section(), update_md5_sum(), and verify_md5().
| void av_fast_mallocz | ( | void * | ptr, |
| unsigned int * | size, | ||
| size_t | min_size | ||
| ) |
Allocate and clear a buffer, reusing the given one if large enough.
Like av_fast_malloc(), but all newly allocated space is initially cleared. Reused buffer is not cleared.
*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.
| [in,out] | ptr | Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure |
| [in,out] | size | Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure. |
| [in] | min_size | Desired minimal size of buffer *ptr |
Definition at line 562 of file mem.c.
Referenced by alloc_sample_buffer(), alloc_scratch_buffers(), alloc_x96_sample_buffer(), av_exif_clone_ifd(), av_fast_padded_malloc(), decode_frame(), and g2m_init_buffers().
| void av_free | ( | void * | ptr | ) |
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family.
| ptr | Pointer to the memory block which should be freed. |
ptr = NULL is explicitly allowed. Definition at line 238 of file mem.c.
Referenced by av_freep(), and av_realloc_f().
| void av_freep | ( | void * | ptr | ) |
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family, and set the pointer pointing to it to NULL.
| ptr | Pointer to the pointer to the memory block which should be freed |
*ptr = NULL is safe and leads to no action. Definition at line 247 of file mem.c.
Referenced by av_dynarray2_add(), av_dynarray_add(), av_reallocp(), and fast_malloc().
| char* av_strdup | ( | const char * | s | ) |
Duplicate a string.
| s | String to be duplicated |
s or NULL if the string cannot be allocated | char* av_strndup | ( | const char * | s, |
| size_t | len | ||
| ) |
Duplicate a substring of a string.
| s | String to be duplicated |
| len | Maximum length of the resulting string (not counting the terminating byte) |
s or NULL if the string cannot be allocated Definition at line 284 of file mem.c.
Referenced by get_extension(), hw_device_init_from_string(), match_stream_specifier(), mpjpeg_get_boundary(), parse_adaptation_sets(), parse_cookie(), process_line(), stream_specifier_parse(), and vgs_parse_statement().
| void* av_memdup | ( | const void * | p, |
| size_t | size | ||
| ) |
Duplicate a buffer with av_malloc().
| p | Buffer to be duplicated |
| size | Size in bytes of the buffer copied |
p or NULL if the buffer cannot be allocated Definition at line 304 of file mem.c.
Referenced by aarch64_collect_op(), amf_filter_config_output(), amf_init_encoder(), aribcaption_trans_bitmap_subtitle(), av_bprint_finalize(), av_frame_ref(), av_frame_replace(), codec_parameters_copy_side_data(), compile(), compute_chapters_end(), copy_av_subtitle(), dnxhd_encode_init(), dvbsub_parse_clut_segment(), exif_clone_entry(), ff_filter_alloc(), ff_get_format(), ff_hevc_decode_nal_pps(), ff_hevc_decode_nal_sps(), ff_hevc_decode_nal_vps(), ff_iamf_write_audio_frame(), ff_mov_write_packet(), ff_mpv_init_duplicate_contexts(), ff_psy_init(), ff_setup_memdup(), ff_sws_op_list_duplicate(), fill_codec_config(), g723_1_encode_frame(), handle_nack_rtx(), init_thread(), libx265_encode_frame(), LLVMFuzzerTestOneInput(), main(), mov_create_chapter_track(), mpegts_set_stream_info(), opt_copy_elem(), parse_header(), prepare_sei_data_array(), process_frame(), save_subtitle_set(), set_aes_arg(), setup_frame(), solve_shuffle(), subtitle_wrap_frame(), and vorbis_header().
| void av_memcpy_backptr | ( | uint8_t * | dst, |
| int | back, | ||
| int | cnt | ||
| ) |
Overlapping memcpy() implementation.
| dst | Destination buffer |
| back | Number of bytes back to start copying (i.e. the initial size of the overlapping window); must be > 0 |
| cnt | Number of bytes to copy; must be >= 0 |
cnt > back is valid, this will copy the bytes we just copied, thus creating a repeating pattern with a period length of back. Definition at line 447 of file mem.c.
Referenced by color_frame(), copy_backptr(), decode_dsw1(), decode_frame(), decode_tsw1(), ff_lzf_uncompress(), fill_frame(), generate_missing_ref(), memset_bytes(), mszh_decomp(), picmemset(), qsv_fill_border(), qsvenc_fill_padding_area(), realloc_alpha_uv(), residual_interp(), synth_block_fcb_acb(), unpack(), and xan_unpack().
1.8.17