Function ff_alloc_packet2

Source
pub unsafe extern "C" fn ff_alloc_packet2(
    avctx: *mut AVCodecContext,
    avpkt: *mut AVPacket,
    size: i64,
    min_size: i64,
) -> c_int
Expand description

Check AVPacket size and/or allocate data.

Encoders supporting AVCodec.encode2() can use this as a convenience to ensure the output packet data is large enough, whether provided by the user or allocated in this function.

@param avctx the AVCodecContext of the encoder @param avpkt the AVPacket If avpkt->data is already set, avpkt->size is checked to ensure it is large enough. If avpkt->data is NULL, a new buffer is allocated. avpkt->size is set to the specified size. All other AVPacket fields will be reset with av_init_packet(). @param size the minimum required packet size @param min_size This is a hint to the allocation algorithm, which indicates to what minimal size the caller might later shrink the packet to. Encoders often allocate packets which are larger than the amount of data that is written into them as the exact amount is not known at the time of allocation. min_size represents the size a packet might be shrunk to by the caller. Can be set to 0. setting this roughly correctly allows the allocation code to choose between several allocation strategies to improve speed slightly. @return non negative on success, negative error code on failure