关于void *av_malloc(size_t size)可以参考av_malloc
av_packet_alloc实际是分配AVPacket以后,调用av_init_packet对AVPacket的成员变量进行初始化赋值。
AVPacket *av_packet_alloc(void)
{AVPacket *pkt = av_mallocz(sizeof(AVPacket));if (!pkt)return pkt;av_init_packet(pkt);return pkt;
}void av_init_packet(AVPacket *pkt)
{pkt->pts = AV_NOPTS_VALUE;pkt->dts = AV_NOPTS_VALUE;pkt->pos = -1;pkt->duration = 0;
#if FF_API_CONVERGENCE_DURATION
FF_DISABLE_DEPRECATION_WARNINGSpkt->convergence_duration = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endifpkt->flags = 0;pkt->stream_index = 0;pkt->buf = NULL;pkt->side_data = NULL;pkt->side_data_elems = 0;
}
av_packet_free 实际是释放AVPacket的空间
void av_packet_free(AVPacket **pkt)
{if (!pkt || !*pkt)return;av_packet_unref(*pkt);av_freep(pkt);
}