ffmpeg | branch: master | Clément Bœsch <[email protected]> | Wed Apr 26 13:35:57 2017 +0200| [76cc100afba25308eaa909acd8804cc0b42057f6] | committer: Clément Bœsch
Merge commit '86157e6db2c7a9222f77fa7e7f50fb9aebc3aa81' * commit '86157e6db2c7a9222f77fa7e7f50fb9aebc3aa81': hevc: decouple calling get_format() from exporting the SPS parameters See 786032cad8ecabe577d9cff0356da6e9e9488a2d (which has been reverted and replaced with Anton's version to reduce diffs between the two projects). Merged-by: Clément Bœsch <[email protected]> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=76cc100afba25308eaa909acd8804cc0b42057f6 --- libavcodec/hevcdec.c | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 7b935260d6..0c620d40fa 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -330,24 +330,10 @@ static void export_stream_params(AVCodecContext *avctx, const HEVCParamSets *ps, num, den, 1 << 30); } -static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fmt) +static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) { #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + CONFIG_HEVC_VAAPI_HWACCEL + CONFIG_HEVC_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; - int ret, i; - - pic_arrays_free(s); - s->ps.sps = NULL; - s->ps.vps = NULL; - - if (!sps) - return 0; - - ret = pic_arrays_init(s, sps); - if (ret < 0) - goto fail; - - export_stream_params(s->avctx, &s->ps, sps); switch (sps->pix_fmt) { case AV_PIX_FMT_YUV420P: @@ -378,18 +364,31 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fm break; } - if (pix_fmt == AV_PIX_FMT_NONE) { - *fmt++ = sps->pix_fmt; - *fmt = AV_PIX_FMT_NONE; + *fmt++ = sps->pix_fmt; + *fmt = AV_PIX_FMT_NONE; - ret = ff_thread_get_format(s->avctx, pix_fmts); - if (ret < 0) - goto fail; - s->avctx->pix_fmt = ret; - } - else { - s->avctx->pix_fmt = pix_fmt; - } + return ff_get_format(s->avctx, pix_fmts); +} + +static int set_sps(HEVCContext *s, const HEVCSPS *sps, + enum AVPixelFormat pix_fmt) +{ + int ret, i; + + pic_arrays_free(s); + s->ps.sps = NULL; + s->ps.vps = NULL; + + if (!sps) + return 0; + + ret = pic_arrays_init(s, sps); + if (ret < 0) + goto fail; + + export_stream_params(s->avctx, &s->ps, sps); + + s->avctx->pix_fmt = pix_fmt; ff_hevc_pred_init(&s->hpc, sps->bit_depth); ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth); @@ -461,6 +460,8 @@ static int hls_slice_header(HEVCContext *s) if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { const HEVCSPS* last_sps = s->ps.sps; + enum AVPixelFormat pix_fmt; + s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) { if (s->ps.sps->width != last_sps->width || s->ps.sps->height != last_sps->height || @@ -469,7 +470,12 @@ static int hls_slice_header(HEVCContext *s) sh->no_output_of_prior_pics_flag = 0; } ff_hevc_clear_refs(s); - ret = set_sps(s, s->ps.sps, AV_PIX_FMT_NONE); + + pix_fmt = get_format(s, s->ps.sps); + if (pix_fmt < 0) + return pix_fmt; + + ret = set_sps(s, s->ps.sps, pix_fmt); if (ret < 0) return ret; ====================================================================== diff --cc libavcodec/hevcdec.c index 7b935260d6,27fd6832ab..0c620d40fa --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@@ -330,28 -380,13 +330,14 @@@ static void export_stream_params(AVCode num, den, 1 << 30); } - static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fmt) + static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) { - #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + CONFIG_HEVC_VDPAU_HWACCEL) + #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + CONFIG_HEVC_VAAPI_HWACCEL + CONFIG_HEVC_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; - int ret, i; - - pic_arrays_free(s); - s->ps.sps = NULL; - s->ps.vps = NULL; - - if (!sps) - return 0; - - ret = pic_arrays_init(s, sps); - if (ret < 0) - goto fail; - - export_stream_params(s->avctx, &s->ps, sps); - if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P || - sps->pix_fmt == AV_PIX_FMT_YUV420P10) { + switch (sps->pix_fmt) { + case AV_PIX_FMT_YUV420P: + case AV_PIX_FMT_YUVJ420P: #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif @@@ -364,32 -398,33 +350,45 @@@ #if CONFIG_HEVC_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif + break; + case AV_PIX_FMT_YUV420P10: +#if CONFIG_HEVC_DXVA2_HWACCEL + *fmt++ = AV_PIX_FMT_DXVA2_VLD; +#endif +#if CONFIG_HEVC_D3D11VA_HWACCEL + *fmt++ = AV_PIX_FMT_D3D11VA_VLD; +#endif +#if CONFIG_HEVC_VAAPI_HWACCEL + *fmt++ = AV_PIX_FMT_VAAPI; +#endif + break; } - if (pix_fmt == AV_PIX_FMT_NONE) { - *fmt++ = sps->pix_fmt; - *fmt = AV_PIX_FMT_NONE; + *fmt++ = sps->pix_fmt; + *fmt = AV_PIX_FMT_NONE; - ret = ff_thread_get_format(s->avctx, pix_fmts); - if (ret < 0) - goto fail; - s->avctx->pix_fmt = ret; - } - else { - s->avctx->pix_fmt = pix_fmt; - } + return ff_get_format(s->avctx, pix_fmts); + } + + static int set_sps(HEVCContext *s, const HEVCSPS *sps, + enum AVPixelFormat pix_fmt) + { - int ret; ++ int ret, i; + + pic_arrays_free(s); + s->ps.sps = NULL; + s->ps.vps = NULL; + + if (!sps) + return 0; + + ret = pic_arrays_init(s, sps); + if (ret < 0) + goto fail; + + export_stream_params(s->avctx, &s->ps, sps); + + s->avctx->pix_fmt = pix_fmt; ff_hevc_pred_init(&s->hpc, sps->bit_depth); ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth); @@@ -456,20 -477,19 +455,27 @@@ static int hls_slice_header(HEVCContex return AVERROR_INVALIDDATA; } s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data; + if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) + sh->no_output_of_prior_pics_flag = 1; if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { + const HEVCSPS* last_sps = s->ps.sps; + enum AVPixelFormat pix_fmt; + s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; - + if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) { + if (s->ps.sps->width != last_sps->width || s->ps.sps->height != last_sps->height || + s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering != + last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering) + sh->no_output_of_prior_pics_flag = 0; + } ff_hevc_clear_refs(s); - ret = set_sps(s, s->ps.sps, AV_PIX_FMT_NONE); + + pix_fmt = get_format(s, s->ps.sps); + if (pix_fmt < 0) + return pix_fmt; + + ret = set_sps(s, s->ps.sps, pix_fmt); if (ret < 0) return ret; _______________________________________________ ffmpeg-cvslog mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
