From d78415252689fab22e499a270958f55272949317 Mon Sep 17 00:00:00 2001
From: Philip Langdale <philipl@overt.org>
Date: Sat, 12 Sep 2015 12:40:00 -0700
Subject: [PATCH] hevc: try to handle the NoRaslOutputFlag logic
---
libavcodec/hevc.c | 8 ++++++++
libavcodec/hevc.h | 1 +
libavcodec/hevc_refs.c | 2 +-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 8d4db22..da4f687 100644
|
a
|
b
|
static int hevc_frame_start(HEVCContext *s)
|
| 2610 | 2610 | if (ret < 0) |
| 2611 | 2611 | goto fail; |
| 2612 | 2612 | |
| | 2613 | if (IS_IRAP(s)) |
| | 2614 | s->NoRaslOutputFlag = 0; |
| | 2615 | |
| 2613 | 2616 | if (!s->avctx->hwaccel) |
| 2614 | 2617 | ff_thread_finish_setup(s->avctx); |
| 2615 | 2618 | |
| … |
… |
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
|
| 2770 | 2773 | |
| 2771 | 2774 | s->ref = NULL; |
| 2772 | 2775 | s->last_eos = s->eos; |
| | 2776 | if (s->last_eos) |
| | 2777 | s->NoRaslOutputFlag = 1; |
| 2773 | 2778 | s->eos = 0; |
| 2774 | 2779 | |
| 2775 | 2780 | /* split the input packet into NAL units, so we know the upper bound on the |
| … |
… |
static int hevc_update_thread_context(AVCodecContext *dst,
|
| 3135 | 3140 | s->pocTid0 = s0->pocTid0; |
| 3136 | 3141 | s->max_ra = s0->max_ra; |
| 3137 | 3142 | s->eos = s0->eos; |
| | 3143 | s->NoRaslOutputFlag = s0->NoRaslOutputFlag; |
| 3138 | 3144 | |
| 3139 | 3145 | s->is_nalff = s0->is_nalff; |
| 3140 | 3146 | s->nal_length_size = s0->nal_length_size; |
| … |
… |
static av_cold int hevc_decode_init(AVCodecContext *avctx)
|
| 3239 | 3245 | |
| 3240 | 3246 | s->enable_parallel_tiles = 0; |
| 3241 | 3247 | s->picture_struct = 0; |
| | 3248 | s->NoRaslOutputFlag = 1; |
| 3242 | 3249 | |
| 3243 | 3250 | if(avctx->active_thread_type & FF_THREAD_SLICE) |
| 3244 | 3251 | s->threads_number = avctx->thread_count; |
| … |
… |
static void hevc_decode_flush(AVCodecContext *avctx)
|
| 3280 | 3287 | HEVCContext *s = avctx->priv_data; |
| 3281 | 3288 | ff_hevc_flush_dpb(s); |
| 3282 | 3289 | s->max_ra = INT_MAX; |
| | 3290 | s->NoRaslOutputFlag = 1; |
| 3283 | 3291 | } |
| 3284 | 3292 | |
| 3285 | 3293 | #define OFFSET(x) offsetof(HEVCContext, x) |
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 32d6da9..196191a 100644
|
a
|
b
|
typedef struct HEVCContext {
|
| 866 | 866 | int bs_height; |
| 867 | 867 | |
| 868 | 868 | int is_decoded; |
| | 869 | int NoRaslOutputFlag; |
| 869 | 870 | |
| 870 | 871 | HEVCPredContext hpc; |
| 871 | 872 | HEVCDSPContext hevcdsp; |
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index e85ce89..77d24fd 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->NoRaslOutputFlag) { |
| 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 && |