1 From ef86b05da8ad38c9c83e6f075536635647e6b799 Mon Sep 17 00:00:00 2001
2 From: Rainer Hochecker <fernetmenta@online.de>
3 Date: Thu, 12 Mar 2015 12:49:48 +0100
4 Subject: [PATCH] hevc: avoid unnecessary calls to get_format
6 Patch part of the XBMC patch set for ffmpeg, downloaded from
7 https://github.com/xbmc/FFmpeg/.
9 Upstream status: committed to master
10 http://git.videolan.org/?p=ffmpeg.git;a=commit;h=786032cad8ecabe577d9cff0356da6e9e9488a2d
12 Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
14 libavcodec/hevc.c | 23 ++++++++++++++---------
15 1 file changed, 14 insertions(+), 9 deletions(-)
17 diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
18 index b7ad29a..77b0c0c 100644
19 --- a/libavcodec/hevc.c
20 +++ b/libavcodec/hevc.c
21 @@ -280,7 +280,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
25 -static int set_sps(HEVCContext *s, const HEVCSPS *sps)
26 +static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fmt)
28 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL)
29 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;
30 @@ -304,13 +304,18 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
34 - *fmt++ = sps->pix_fmt;
35 - *fmt = AV_PIX_FMT_NONE;
36 + if (pix_fmt == AV_PIX_FMT_NONE) {
37 + *fmt++ = sps->pix_fmt;
38 + *fmt = AV_PIX_FMT_NONE;
40 - ret = ff_thread_get_format(s->avctx, pix_fmts);
43 - s->avctx->pix_fmt = ret;
44 + ret = ff_thread_get_format(s->avctx, pix_fmts);
47 + s->avctx->pix_fmt = ret;
50 + s->avctx->pix_fmt = pix_fmt;
53 ff_set_sar(s->avctx, sps->vui.sar);
55 @@ -420,7 +425,7 @@ static int hls_slice_header(HEVCContext *s)
56 sh->no_output_of_prior_pics_flag = 0;
58 ff_hevc_clear_refs(s);
59 - ret = set_sps(s, s->sps);
60 + ret = set_sps(s, s->sps, AV_PIX_FMT_NONE);
64 @@ -3335,7 +3340,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
67 if (s->sps != s0->sps)
68 - if ((ret = set_sps(s, s0->sps)) < 0)
69 + if ((ret = set_sps(s, s0->sps, src->pix_fmt)) < 0)
72 s->seq_decode = s0->seq_decode;