Message ID | DB3PR0202MB34527902EAA40AC50386DB7BEC3D0@DB3PR0202MB3452.eurprd02.prod.outlook.com |
---|---|
State | Superseded |
Headers | show |
On Tue, Dec 05, 2017 at 10:35:50PM +0000, Stefan _ wrote: > On 04.12.2017 at 21:06 Carl Eugen Hoyos wrote: > > 2017-12-01 0:22 GMT+01:00 Stefan _ <sfan5@live.de>: > > > >> Attached patch adds full support for skip_loop_filter > >> (all levels) to the hevc decoder. > > Will you also work on -skip_frame for hevc? > > > > Carl Eugen > > I gave it a try. The different levels should all work correctly, since I > compared the "effects" to a H.264 sample. > > 'make fate-hevc' passes. > > hevcdec.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > 79234a40e0eb99673a032351e021d9d375c43ad6 0001-libavcodec-hevc_filter-implement-skip_frame.patch > From 8ee08adebd9994c3517c692cc99f0839d3d8f7ca Mon Sep 17 00:00:00 2001 > From: sfan5 <sfan5@live.de> > Date: Tue, 5 Dec 2017 23:26:14 +0100 > Subject: [PATCH] libavcodec/hevc_filter: implement skip_frame > > --- > libavcodec/hevcdec.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > index 433a7056ea..37f2ad76eb 100644 > --- a/libavcodec/hevcdec.c > +++ b/libavcodec/hevcdec.c > @@ -2905,6 +2905,13 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) > if (ret < 0) > return ret; > > + if ( > + (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) || > + (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != HEVC_SLICE_I) || > + (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s))) { > + break; > + } > + > if (s->sh.first_slice_in_pic_flag) { > if (s->max_ra == INT_MAX) { > if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) { > @@ -3028,7 +3035,29 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) > > /* decode the NAL units */ > for (i = 0; i < s->pkt.nb_nals; i++) { > - ret = decode_nal_unit(s, &s->pkt.nals[i]); > + H2645NAL *nal = &s->pkt.nals[i]; > + int is_n = 0; > + > + switch (nal->type) { > + case HEVC_NAL_TRAIL_N: > + case HEVC_NAL_TSA_N: > + case HEVC_NAL_STSA_N: > + case HEVC_NAL_RADL_N: > + case HEVC_NAL_RASL_N: > + case HEVC_NAL_VCL_N10: > + case HEVC_NAL_VCL_N12: > + case HEVC_NAL_VCL_N14: > + case HEVC_NAL_BLA_N_LP: > + case HEVC_NAL_IDR_N_LP: > + is_n = 1; > + break; > + default: break; > + } This is duplicated, it should be moved into a seperate function [...]
From 8ee08adebd9994c3517c692cc99f0839d3d8f7ca Mon Sep 17 00:00:00 2001 From: sfan5 <sfan5@live.de> Date: Tue, 5 Dec 2017 23:26:14 +0100 Subject: [PATCH] libavcodec/hevc_filter: implement skip_frame --- libavcodec/hevcdec.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 433a7056ea..37f2ad76eb 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2905,6 +2905,13 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) if (ret < 0) return ret; + if ( + (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) || + (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != HEVC_SLICE_I) || + (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IDR(s))) { + break; + } + if (s->sh.first_slice_in_pic_flag) { if (s->max_ra == INT_MAX) { if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) { @@ -3028,7 +3035,29 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) /* decode the NAL units */ for (i = 0; i < s->pkt.nb_nals; i++) { - ret = decode_nal_unit(s, &s->pkt.nals[i]); + H2645NAL *nal = &s->pkt.nals[i]; + int is_n = 0; + + switch (nal->type) { + case HEVC_NAL_TRAIL_N: + case HEVC_NAL_TSA_N: + case HEVC_NAL_STSA_N: + case HEVC_NAL_RADL_N: + case HEVC_NAL_RASL_N: + case HEVC_NAL_VCL_N10: + case HEVC_NAL_VCL_N12: + case HEVC_NAL_VCL_N14: + case HEVC_NAL_BLA_N_LP: + case HEVC_NAL_IDR_N_LP: + is_n = 1; + break; + default: break; + } + if ((s->avctx->skip_frame >= AVDISCARD_NONREF && is_n) || + s->avctx->skip_frame >= AVDISCARD_ALL) + continue; + + ret = decode_nal_unit(s, nal); if (ret < 0) { av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i); -- 2.15.0