[FFmpeg-cvslog] ff_alloc_packet: modify the size of the packet to match the requested size
Justin Ruggles
git at videolan.org
Fri Feb 3 04:15:57 CET 2012
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Feb 1 16:23:19 2012 -0500| [1a670973a756e6e1a7a170d58f3589fd5ad4c088] | committer: Justin Ruggles
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a670973a756e6e1a7a170d58f3589fd5ad4c088
---
libavcodec/internal.h | 1 +
libavcodec/utils.c | 4 +---
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 441430e..b435a35 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -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
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 34eff00..606537b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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);
More information about the ffmpeg-cvslog
mailing list