diff options
author | Christophe Gisquet <christophe.gisquet@gmail.com> | 2015-02-02 15:51:45 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-04 01:54:22 +0100 |
commit | 52f2adc015ba4a05c3da730e87b63b343747424d (patch) | |
tree | 81ebae92bd1e84784f159ce212310851573fbf95 /libavcodec/hevc.c | |
parent | 00fe77855b2aaf5de5bfe4d566a4ddd80aa6812e (diff) |
avcodec/hevc: Update the USE_SAO_SMALL_BUFFER case for the alignment requirements in FFmpeg
Use edge emu buffers
And enable the code unconditionally
Speed difference without USE_SAO_SMALL_BUFFER and with the new code:
Decicycles: 26772->26220 (BO32), 83803->80942 (BO64)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/hevc.c')
-rw-r--r-- | libavcodec/hevc.c | 62 |
1 files changed, 8 insertions, 54 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index b77dbcde4c..0624cb0c72 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -280,24 +280,6 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) return 0; } -static int get_buffer_sao(HEVCContext *s, AVFrame *frame, const HEVCSPS *sps) -{ - int ret, i; - - frame->width = FFALIGN(s->avctx->coded_width + 2, FF_INPUT_BUFFER_PADDING_SIZE); - frame->height = s->avctx->coded_height + 3; - if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) - return ret; - for (i = 0; frame->data[i]; i++) { - int offset = frame->linesize[i] + FF_INPUT_BUFFER_PADDING_SIZE; - frame->data[i] += offset; - } - frame->width = s->avctx->coded_width; - frame->height = s->avctx->coded_height; - - return 0; -} - static int set_sps(HEVCContext *s, const HEVCSPS *sps) { #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL) @@ -353,34 +335,19 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) ff_videodsp_init (&s->vdsp, sps->bit_depth); if (sps->sao_enabled && !s->avctx->hwaccel) { -#ifdef USE_SAO_SMALL_BUFFER - { - int ctb_size = 1 << sps->log2_ctb_size; - int c_count = (sps->chroma_format_idc != 0) ? 3 : 1; - int c_idx, i; - - for (i = 0; i < s->threads_number ; i++) { - HEVCLocalContext *lc = s->HEVClcList[i]; - lc->sao_pixel_buffer = - av_malloc(((ctb_size + 2) * (ctb_size + 2)) << - sps->pixel_shift); - } - for(c_idx = 0; c_idx < c_count; c_idx++) { - int w = sps->width >> sps->hshift[c_idx]; - int h = sps->height >> sps->vshift[c_idx]; - s->sao_pixel_buffer_h[c_idx] = + int c_count = (sps->chroma_format_idc != 0) ? 3 : 1; + int c_idx; + + for(c_idx = 0; c_idx < c_count; c_idx++) { + int w = sps->width >> sps->hshift[c_idx]; + int h = sps->height >> sps->vshift[c_idx]; + s->sao_pixel_buffer_h[c_idx] = av_malloc((w * 2 * sps->ctb_height) << sps->pixel_shift); - s->sao_pixel_buffer_v[c_idx] = + s->sao_pixel_buffer_v[c_idx] = av_malloc((h * 2 * sps->ctb_width) << sps->pixel_shift); - } } -#else - av_frame_unref(s->tmp_frame); - ret = get_buffer_sao(s, s->tmp_frame, sps); - s->sao_frame = s->tmp_frame; -#endif } s->sps = sps; @@ -3211,17 +3178,10 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_freep(&s->cabac_state); -#ifdef USE_SAO_SMALL_BUFFER - for (i = 0; i < s->threads_number; i++) { - av_freep(&s->HEVClcList[i]->sao_pixel_buffer); - } for (i = 0; i < 3; i++) { av_freep(&s->sao_pixel_buffer_h[i]); av_freep(&s->sao_pixel_buffer_v[i]); } -#else - av_frame_free(&s->tmp_frame); -#endif av_frame_free(&s->output_frame); for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { @@ -3281,12 +3241,6 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) if (!s->cabac_state) goto fail; -#ifndef USE_SAO_SMALL_BUFFER - s->tmp_frame = av_frame_alloc(); - if (!s->tmp_frame) - goto fail; -#endif - s->output_frame = av_frame_alloc(); if (!s->output_frame) goto fail; |