diff options
author | Roberto Togni <r_togni@tiscali.it> | 2007-11-18 22:40:02 +0000 |
---|---|---|
committer | Roberto Togni <r_togni@tiscali.it> | 2007-11-18 22:40:02 +0000 |
commit | e11d0145e29c38a2721fe131728d83512e5c30b9 (patch) | |
tree | c899cca0303386dd5cdf8da0ea0b95c7ea38d597 /libavformat/rmdec.c | |
parent | 289987e454cf3705c9cc824fdda3e25949f78898 (diff) | |
download | ffmpeg-streaming-e11d0145e29c38a2721fe131728d83512e5c30b9.zip ffmpeg-streaming-e11d0145e29c38a2721fe131728d83512e5c30b9.tar.gz |
Optimize memory management to create an av_packet from multiple slices:
- remove memmove to pack the data, instead copy only the used areas
from the temp buffer in their final position
- use the minimum possible size for the av_packet (relevant when some
slices are missing)
Originally committed as revision 11052 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rmdec.c')
-rw-r--r-- | libavformat/rmdec.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 6027e31..8793487 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -519,14 +519,11 @@ static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket * rm->remaining_len-= len; if(type == 2 || (rm->videobufpos) == rm->videobufsize){ - //adjust slice headers - memmove(rm->videobuf + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, rm->videobufsize - 1 - 8*rm->slices); - ssize = rm->videobufsize - 8*(rm->slices - rm->cur_slice); - rm->videobuf[0] = rm->cur_slice-1; - if(av_new_packet(pkt, ssize) < 0) + if(av_new_packet(pkt, rm->videobufpos - 8*(rm->slices - rm->cur_slice)) < 0) return AVERROR(ENOMEM); - memcpy(pkt->data, rm->videobuf, ssize); + memcpy(pkt->data, rm->videobuf, 1 + 8*rm->cur_slice); + memcpy(pkt->data + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, rm->videobufpos - 1 - 8*rm->slices); pkt->pts = AV_NOPTS_VALUE; pkt->pos = rm->pktpos; return 0; |