From 839e13442eb1d45072cf4e0d6a456e41bd8b3dd7 Mon Sep 17 00:00:00 2001
From: Hendrik Leppkes <h.leppkes@gmail.com>
Date: Sat, 12 Sep 2015 21:50:24 +0200
Subject: [PATCH] hevc: properly handle no_rasl_output_flag when removing
pictures from the DPB
---
libavcodec/hevc.c | 5 +++++
libavcodec/hevc.h | 1 +
libavcodec/hevc_refs.c | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 8d4db22..e45f4a4 100644
|
a
|
b
|
static int hls_slice_header(HEVCContext *s)
|
| 809 | 809 | s->HEVClc->tu.cu_qp_offset_cb = 0; |
| 810 | 810 | s->HEVClc->tu.cu_qp_offset_cr = 0; |
| 811 | 811 | |
| | 812 | s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == NAL_CRA_NUT && s->last_eos); |
| | 813 | |
| 812 | 814 | return 0; |
| 813 | 815 | } |
| 814 | 816 | |
| … |
… |
static int hevc_update_thread_context(AVCodecContext *dst,
|
| 3135 | 3137 | s->pocTid0 = s0->pocTid0; |
| 3136 | 3138 | s->max_ra = s0->max_ra; |
| 3137 | 3139 | s->eos = s0->eos; |
| | 3140 | s->no_rasl_output_flag = s0->no_rasl_output_flag; |
| 3138 | 3141 | |
| 3139 | 3142 | s->is_nalff = s0->is_nalff; |
| 3140 | 3143 | s->nal_length_size = s0->nal_length_size; |
| … |
… |
static av_cold int hevc_decode_init(AVCodecContext *avctx)
|
| 3239 | 3242 | |
| 3240 | 3243 | s->enable_parallel_tiles = 0; |
| 3241 | 3244 | s->picture_struct = 0; |
| | 3245 | s->eos = 1; |
| 3242 | 3246 | |
| 3243 | 3247 | if(avctx->active_thread_type & FF_THREAD_SLICE) |
| 3244 | 3248 | s->threads_number = avctx->thread_count; |
| … |
… |
static void hevc_decode_flush(AVCodecContext *avctx)
|
| 3280 | 3284 | HEVCContext *s = avctx->priv_data; |
| 3281 | 3285 | ff_hevc_flush_dpb(s); |
| 3282 | 3286 | s->max_ra = INT_MAX; |
| | 3287 | s->eos = 1; |
| 3283 | 3288 | } |
| 3284 | 3289 | |
| 3285 | 3290 | #define OFFSET(x) offsetof(HEVCContext, x) |
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 32d6da9..66b9a2f 100644
|
a
|
b
|
typedef struct HEVCContext {
|
| 866 | 866 | int bs_height; |
| 867 | 867 | |
| 868 | 868 | int is_decoded; |
| | 869 | int no_rasl_output_flag; |
| 869 | 870 | |
| 870 | 871 | HEVCPredContext hpc; |
| 871 | 872 | HEVCDSPContext hevcdsp; |
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index e85ce89..611ad45 100644
|
a
|
b
|
int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
|
| 174 | 174 | int min_poc = INT_MAX; |
| 175 | 175 | int i, min_idx, ret; |
| 176 | 176 | |
| 177 | | if (s->sh.no_output_of_prior_pics_flag == 1) { |
| | 177 | if (s->sh.no_output_of_prior_pics_flag == 1 && s->no_rasl_output_flag == 1) { |
| 178 | 178 | for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { |
| 179 | 179 | HEVCFrame *frame = &s->DPB[i]; |
| 180 | 180 | if (!(frame->flags & HEVC_FRAME_FLAG_BUMPING) && frame->poc != s->poc && |