diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-05-26 20:17:12 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-05-26 20:17:12 +0000 |
commit | 2692067a45e4cb4ce0028e170673f2b2f5039721 (patch) | |
tree | 19b10f28c74700113729a7ae6861c734e8bfab01 /libavformat/utils.c | |
parent | 4aa606ec179a7df514fe5839b7ab5e24b42145b8 (diff) | |
download | ffmpeg-2692067a45e4cb4ce0028e170673f2b2f5039721.tar.gz |
AVPacket.pos
Originally committed as revision 4314 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 9791cc2686..45972e1f4a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -195,6 +195,31 @@ int av_new_packet(AVPacket *pkt, int size) return 0; } +/** + * Allocate and read the payload of a packet and intialized its fields to default values. + * + * @param pkt packet + * @param size wanted payload size + * @return >0 (read size) if OK. AVERROR_xxx otherwise. + */ +int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size) +{ + int ret= av_new_packet(pkt, size); + + if(ret<0) + return ret; + + pkt->pos= url_ftell(s); + + ret= get_buffer(s, pkt->data, size); + if(ret<=0) + av_free_packet(pkt); + else + pkt->size= ret; + + return ret; +} + /* This is a hack - the packet memory allocation stuff is broken. The packet is allocated if it was not really allocated */ int av_dup_packet(AVPacket *pkt) |