diff options
author | Mickaƫl Raulet <mraulet@insa-rennes.fr> | 2014-07-16 23:15:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-18 22:46:50 +0200 |
commit | d249e6828e8a84758010ec020a84dfcd156b585e (patch) | |
tree | 14a2103e8c7bd59d1082915c3c7e277e1b974108 /libavcodec/hevc.c | |
parent | 2897447ddf805edc0a7935ab633c28e29a89b7b3 (diff) | |
download | ffmpeg-d249e6828e8a84758010ec020a84dfcd156b585e.tar.gz |
hevc/sao: optimze sao implementation
- adding one extra pixel all around the frame
- do not copy when SAO is not applied
5% improvement
cherry picked from commit 10fc29fc19a12c4d8168fbe1a954b76386db12d0
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/hevc.c')
-rw-r--r-- | libavcodec/hevc.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index afb2baaf65..d466aa6253 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -276,6 +276,24 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) return 0; } +static int get_buffer_sao(HEVCContext *s, AVFrame *frame) +{ + int ret, i; + + frame->width = s->avctx->width + 2; + frame->height = s->avctx->height + 2; + 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] + 1; + frame->data[i] += offset; + } + frame->width = s->avctx->width; + frame->height = s->avctx->height; + + return 0; +} + static int set_sps(HEVCContext *s, const HEVCSPS *sps) { int ret; @@ -317,10 +335,8 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) if (sps->sao_enabled) { av_frame_unref(s->tmp_frame); - ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF); - if (ret < 0) - goto fail; - s->frame = s->tmp_frame; + ret = get_buffer_sao(s, s->tmp_frame); + s->sao_frame = s->tmp_frame; } s->sps = sps; @@ -2582,8 +2598,7 @@ static int hevc_frame_start(HEVCContext *s) if (s->pps->tiles_enabled_flag) lc->end_of_tiles_x = s->pps->column_width[0] << s->sps->log2_ctb_size; - ret = ff_hevc_set_new_ref(s, s->sps->sao_enabled ? &s->sao_frame : &s->frame, - s->poc); + ret = ff_hevc_set_new_ref(s, &s->frame, s->poc); if (ret < 0) goto fail; |