summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorJeff Downs <heydowns@borg.com>2008-01-28 21:12:38 +0000
committerJeff Downs <heydowns@borg.com>2008-01-28 21:12:38 +0000
commit79db7ac6ef235a06c3049d7792eda39da28ee3fd (patch)
treeb3f4458f724d3da7978cb8c7902d8779fa260f8d /libavcodec/h264.c
parent0b98a7b3b2b2cd9fe22cd693254544890b0d8fd9 (diff)
Fix memory leak in h264 decoder. allocated_edge_emu_buffer was being allocated
in both mpegvideo and h264 decoder. Fixed by allowing all (master and duplicate) contexts to fully initialize in MPV_frame_start and copying these into H264Contexts. Mailing list discussion: [FFmpeg-devel] Memory leak in h264 Tue, 22 Jan 2008 15:22:55 Originally committed as revision 11657 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 841d85479b..9d0e4a1d46 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1951,7 +1951,6 @@ static void free_tables(H264Context *h){
av_freep(&hx->top_borders[1]);
av_freep(&hx->top_borders[0]);
av_freep(&hx->s.obmc_scratchpad);
- av_freep(&hx->s.allocated_edge_emu_buffer);
}
}
@@ -2096,10 +2095,6 @@ static int context_init(H264Context *h){
CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t))
CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t))
- // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264)
- CHECKED_ALLOCZ(s->allocated_edge_emu_buffer,
- (s->width+64)*2*21*2); //(width + edge + align)*interlaced*MBsize*tolerance
- s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21;
return 0;
fail:
return -1; // free_tables will clean up for us
@@ -3907,7 +3902,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
for(i = 1; i < s->avctx->thread_count; i++) {
H264Context *c;
c = h->thread_context[i] = av_malloc(sizeof(H264Context));
- memcpy(c, h, sizeof(MpegEncContext));
+ memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext));
c->sps = h->sps;
c->pps = h->pps;