hevc.c (libav-12) | : | hevc.c (libav-12.1) | ||
---|---|---|---|---|
skipping to change at line 381 | skipping to change at line 381 | |||
} else if (sps->vui.vui_timing_info_present_flag) { | } else if (sps->vui.vui_timing_info_present_flag) { | |||
num = sps->vui.vui_num_units_in_tick; | num = sps->vui.vui_num_units_in_tick; | |||
den = sps->vui.vui_time_scale; | den = sps->vui.vui_time_scale; | |||
} | } | |||
if (num != 0 && den != 0) | if (num != 0 && den != 0) | |||
av_reduce(&avctx->framerate.den, &avctx->framerate.num, | av_reduce(&avctx->framerate.den, &avctx->framerate.num, | |||
num, den, 1 << 30); | num, den, 1 << 30); | |||
} | } | |||
static int set_sps(HEVCContext *s, const HEVCSPS *sps) | 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_VDPAU_HWACCEL) | |||
enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; | enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; | |||
int ret; | ||||
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_YUVJ420 P || | if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420 P || | |||
sps->pix_fmt == AV_PIX_FMT_YUV420P10) { | sps->pix_fmt == AV_PIX_FMT_YUV420P10) { | |||
#if CONFIG_HEVC_DXVA2_HWACCEL | #if CONFIG_HEVC_DXVA2_HWACCEL | |||
*fmt++ = AV_PIX_FMT_DXVA2_VLD; | *fmt++ = AV_PIX_FMT_DXVA2_VLD; | |||
#endif | #endif | |||
} | } | |||
if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420 P) { | if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420 P) { | |||
#if CONFIG_HEVC_D3D11VA_HWACCEL | #if CONFIG_HEVC_D3D11VA_HWACCEL | |||
*fmt++ = AV_PIX_FMT_D3D11VA_VLD; | *fmt++ = AV_PIX_FMT_D3D11VA_VLD; | |||
#endif | #endif | |||
#if CONFIG_HEVC_VDPAU_HWACCEL | #if CONFIG_HEVC_VDPAU_HWACCEL | |||
*fmt++ = AV_PIX_FMT_VDPAU; | *fmt++ = AV_PIX_FMT_VDPAU; | |||
#endif | #endif | |||
} | } | |||
*fmt++ = sps->pix_fmt; | *fmt++ = sps->pix_fmt; | |||
*fmt = AV_PIX_FMT_NONE; | *fmt = AV_PIX_FMT_NONE; | |||
ret = ff_get_format(s->avctx, pix_fmts); | return ff_get_format(s->avctx, pix_fmts); | |||
} | ||||
static int set_sps(HEVCContext *s, const HEVCSPS *sps, | ||||
enum AVPixelFormat pix_fmt) | ||||
{ | ||||
int ret; | ||||
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) | if (ret < 0) | |||
goto fail; | goto fail; | |||
s->avctx->pix_fmt = ret; | ||||
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_pred_init(&s->hpc, sps->bit_depth); | |||
ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth); | ff_hevc_dsp_init (&s->hevcdsp, sps->bit_depth); | |||
ff_videodsp_init (&s->vdsp, sps->bit_depth); | ff_videodsp_init (&s->vdsp, sps->bit_depth); | |||
if (sps->sao_enabled && !s->avctx->hwaccel) { | if (sps->sao_enabled && !s->avctx->hwaccel) { | |||
av_frame_unref(s->tmp_frame); | av_frame_unref(s->tmp_frame); | |||
ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF); | ret = ff_get_buffer(s->avctx, s->tmp_frame, AV_GET_BUFFER_FLAG_REF); | |||
if (ret < 0) | if (ret < 0) | |||
goto fail; | goto fail; | |||
skipping to change at line 476 | skipping to change at line 480 | |||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | |||
} | } | |||
if (!sh->first_slice_in_pic_flag && | if (!sh->first_slice_in_pic_flag && | |||
s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) { | s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) { | |||
av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); | av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); | |||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | |||
} | } | |||
s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data; | s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data; | |||
if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { | if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { | |||
s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; | const HEVCSPS *sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; | |||
enum AVPixelFormat pix_fmt; | ||||
ff_hevc_clear_refs(s); | ff_hevc_clear_refs(s); | |||
ret = set_sps(s, s->ps.sps); | ||||
pix_fmt = get_format(s, sps); | ||||
if (pix_fmt < 0) | ||||
return pix_fmt; | ||||
ret = set_sps(s, sps, pix_fmt); | ||||
if (ret < 0) | if (ret < 0) | |||
return ret; | return ret; | |||
s->seq_decode = (s->seq_decode + 1) & 0xff; | s->seq_decode = (s->seq_decode + 1) & 0xff; | |||
s->max_ra = INT_MAX; | s->max_ra = INT_MAX; | |||
} | } | |||
sh->dependent_slice_segment_flag = 0; | sh->dependent_slice_segment_flag = 0; | |||
if (!sh->first_slice_in_pic_flag) { | if (!sh->first_slice_in_pic_flag) { | |||
int slice_address_length; | int slice_address_length; | |||
skipping to change at line 2910 | skipping to change at line 2920 | |||
for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) { | for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) { | |||
av_buffer_unref(&s->ps.pps_list[i]); | av_buffer_unref(&s->ps.pps_list[i]); | |||
if (s0->ps.pps_list[i]) { | if (s0->ps.pps_list[i]) { | |||
s->ps.pps_list[i] = av_buffer_ref(s0->ps.pps_list[i]); | s->ps.pps_list[i] = av_buffer_ref(s0->ps.pps_list[i]); | |||
if (!s->ps.pps_list[i]) | if (!s->ps.pps_list[i]) | |||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | |||
} | } | |||
} | } | |||
if (s->ps.sps != s0->ps.sps) | if (s->ps.sps != s0->ps.sps) | |||
ret = set_sps(s, s0->ps.sps); | ret = set_sps(s, s0->ps.sps, src->pix_fmt); | |||
s->seq_decode = s0->seq_decode; | s->seq_decode = s0->seq_decode; | |||
s->seq_output = s0->seq_output; | s->seq_output = s0->seq_output; | |||
s->pocTid0 = s0->pocTid0; | s->pocTid0 = s0->pocTid0; | |||
s->max_ra = s0->max_ra; | s->max_ra = s0->max_ra; | |||
s->is_nalff = s0->is_nalff; | s->is_nalff = s0->is_nalff; | |||
s->nal_length_size = s0->nal_length_size; | s->nal_length_size = s0->nal_length_size; | |||
if (s0->eos) { | if (s0->eos) { | |||
End of changes. 7 change blocks. | ||||
20 lines changed or deleted | 30 lines changed or added |