Mercurial > libavcodec.hg
comparison h264.c @ 6193:52ccab2531bd libavcodec
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
author | heydowns |
---|---|
date | Mon, 28 Jan 2008 21:12:38 +0000 |
parents | 2aa536e36c89 |
children | c9433472cb95 |
comparison
equal
deleted
inserted
replaced
6192:3e13247560d4 | 6193:52ccab2531bd |
---|---|
1949 hx = h->thread_context[i]; | 1949 hx = h->thread_context[i]; |
1950 if(!hx) continue; | 1950 if(!hx) continue; |
1951 av_freep(&hx->top_borders[1]); | 1951 av_freep(&hx->top_borders[1]); |
1952 av_freep(&hx->top_borders[0]); | 1952 av_freep(&hx->top_borders[0]); |
1953 av_freep(&hx->s.obmc_scratchpad); | 1953 av_freep(&hx->s.obmc_scratchpad); |
1954 av_freep(&hx->s.allocated_edge_emu_buffer); | |
1955 } | 1954 } |
1956 } | 1955 } |
1957 | 1956 |
1958 static void init_dequant8_coeff_table(H264Context *h){ | 1957 static void init_dequant8_coeff_table(H264Context *h){ |
1959 int i,q,x; | 1958 int i,q,x; |
2094 MpegEncContext * const s = &h->s; | 2093 MpegEncContext * const s = &h->s; |
2095 | 2094 |
2096 CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) | 2095 CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) |
2097 CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) | 2096 CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) |
2098 | 2097 |
2099 // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264) | |
2100 CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, | |
2101 (s->width+64)*2*21*2); //(width + edge + align)*interlaced*MBsize*tolerance | |
2102 s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21; | |
2103 return 0; | 2098 return 0; |
2104 fail: | 2099 fail: |
2105 return -1; // free_tables will clean up for us | 2100 return -1; // free_tables will clean up for us |
2106 } | 2101 } |
2107 | 2102 |
3905 alloc_tables(h); | 3900 alloc_tables(h); |
3906 | 3901 |
3907 for(i = 1; i < s->avctx->thread_count; i++) { | 3902 for(i = 1; i < s->avctx->thread_count; i++) { |
3908 H264Context *c; | 3903 H264Context *c; |
3909 c = h->thread_context[i] = av_malloc(sizeof(H264Context)); | 3904 c = h->thread_context[i] = av_malloc(sizeof(H264Context)); |
3910 memcpy(c, h, sizeof(MpegEncContext)); | 3905 memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext)); |
3911 memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext)); | 3906 memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext)); |
3912 c->sps = h->sps; | 3907 c->sps = h->sps; |
3913 c->pps = h->pps; | 3908 c->pps = h->pps; |
3914 init_scan_tables(c); | 3909 init_scan_tables(c); |
3915 clone_tables(c, h); | 3910 clone_tables(c, h); |