On 3/24/2019 7:55 AM, Michael Niedermayer wrote: > This should be more robust as it avoids 2 conditions in seperate places which > need to stay the same > > Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > --- > libavcodec/hevcdec.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > index 4d149f4d9f..fe4b5fdb5b 100644 > --- a/libavcodec/hevcdec.c > +++ b/libavcodec/hevcdec.c > @@ -489,7 +489,7 @@ static int hls_slice_header(HEVCContext *s) > // Coded parameters > sh->first_slice_in_pic_flag = get_bits1(gb); > if (s->ref && sh->first_slice_in_pic_flag) > - return 0; // This slice will be skiped later, do not corrupt state > + return 1; // This slice will be skiped later, do not corrupt state > > if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) { > s->seq_decode = (s->seq_decode + 1) & 0xff; > @@ -2921,6 +2921,11 @@ static int decode_nal_unit(HEVCContext *s, const > H2645NAL *nal) > ret = hls_slice_header(s); > if (ret < 0) > return ret; > + if (ret == 1) { > + av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the > first in the same frame.\n");
I think it makes more sense to print this in hls_slice_header(). We could in the future intend to return 1 for some other error that only needs to hard fail in explode mode, and this log message wouldn't apply to it. Alternatively, error code generation could also be handled in hls_slice_header(), returning 0 or AVERROR_INVALIDDATA depending on explode mode or not, and just let the ret < 0 check above do its thing. > + goto fail; > + } > + > > if ( > (s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == > HEVC_SLICE_B) || > @@ -2930,10 +2935,6 @@ static int decode_nal_unit(HEVCContext *s, const > H2645NAL *nal) > } > > if (s->sh.first_slice_in_pic_flag) { > - if (s->ref) { > - av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being > the first in the same frame.\n"); > - goto fail; > - } > if (s->max_ra == INT_MAX) { > if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) { > s->max_ra = s->poc; > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".