From 36d04801ba9d8622c2d759c172aea18561bac74d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Jan 2015 22:28:46 +0100 Subject: h264: move the scratch buffers into the per-slice context Also change the method for allocating them. Instead of two possible alloc calls from different places, just ensure they are allocated at the start of each slice. This should be simpler and less bug-prone than the previous method. --- libavcodec/svq3.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'libavcodec/svq3.c') diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 56b5fb40b9..d28b2d2f19 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -296,6 +296,7 @@ static inline void svq3_mc_dir_part(SVQ3Context *s, int thirdpel, int dir, int avg) { H264Context *h = &s->h; + H264SliceContext *sl = &h->slice_ctx[0]; const H264Picture *pic = (dir == 0) ? s->last_pic : s->next_pic; uint8_t *src, *dest; int i, emu = 0; @@ -316,11 +317,11 @@ static inline void svq3_mc_dir_part(SVQ3Context *s, src = pic->f.data[0] + mx + my * h->linesize; if (emu) { - h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src, + h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src, h->linesize, h->linesize, width + 1, height + 1, mx, my, s->h_edge_pos, s->v_edge_pos); - src = h->edge_emu_buffer; + src = sl->edge_emu_buffer; } if (thirdpel) (avg ? s->tdsp.avg_tpel_pixels_tab @@ -343,12 +344,12 @@ static inline void svq3_mc_dir_part(SVQ3Context *s, src = pic->f.data[i] + mx + my * h->uvlinesize; if (emu) { - h->vdsp.emulated_edge_mc(h->edge_emu_buffer, src, + h->vdsp.emulated_edge_mc(sl->edge_emu_buffer, src, h->uvlinesize, h->uvlinesize, width + 1, height + 1, mx, my, (s->h_edge_pos >> 1), s->v_edge_pos >> 1); - src = h->edge_emu_buffer; + src = sl->edge_emu_buffer; } if (thirdpel) (avg ? s->tdsp.avg_tpel_pixels_tab @@ -1060,6 +1061,7 @@ static int get_buffer(AVCodecContext *avctx, H264Picture *pic) { SVQ3Context *s = avctx->priv_data; H264Context *h = &s->h; + H264SliceContext *sl = &h->slice_ctx[0]; const int big_mb_num = h->mb_stride * (h->mb_height + 1) + 1; const int mb_array_size = h->mb_stride * h->mb_height; const int b4_stride = h->mb_width * 4 + 1; @@ -1093,9 +1095,9 @@ static int get_buffer(AVCodecContext *avctx, H264Picture *pic) if (ret < 0) goto fail; - if (!h->edge_emu_buffer) { - h->edge_emu_buffer = av_mallocz(pic->f.linesize[0] * 17); - if (!h->edge_emu_buffer) + if (!sl->edge_emu_buffer) { + sl->edge_emu_buffer = av_mallocz(pic->f.linesize[0] * 17); + if (!sl->edge_emu_buffer) return AVERROR(ENOMEM); } -- cgit v1.2.3