mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-15 11:44:49 +00:00
ff_alloc_packet: modify the size of the packet to match the requested size
This will simplify encoders which use this function to request the exact packet size rather than the maximum size.
This commit is contained in:
parent
5ff88020ac
commit
1a670973a7
@ -120,6 +120,7 @@ int avpriv_unlock_avformat(void);
|
||||
* 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
|
||||
* @return 0 on success, negative error code on failure
|
||||
|
@ -839,16 +839,14 @@ int ff_alloc_packet(AVPacket *avpkt, int size)
|
||||
|
||||
if (avpkt->data) {
|
||||
uint8_t *pkt_data;
|
||||
int pkt_size;
|
||||
|
||||
if (avpkt->size < size)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
pkt_data = avpkt->data;
|
||||
pkt_size = avpkt->size;
|
||||
av_init_packet(avpkt);
|
||||
avpkt->data = pkt_data;
|
||||
avpkt->size = pkt_size;
|
||||
avpkt->size = size;
|
||||
return 0;
|
||||
} else {
|
||||
return av_new_packet(avpkt, size);
|
||||
|
Loading…
Reference in New Issue
Block a user