[FFmpeg-devel] [PATCH 1/2] avcodec/hevcdec: fix stat_coeff save/load for persistent_rice_adaptation_enabled_flag

Guangxin Xu oddstone at gmail.com
Wed Sep 9 08:42:57 EEST 2020


Hi Mickaƫl & all,
any suggestions?

On Sat, Aug 29, 2020 at 1:52 PM Xu Guangxin <oddstone at gmail.com> wrote:

> It's required by 9.3.1. following clips have this feature:
>
> WPP_HIGH_TP_444_8BIT_RExt_Apple_2.bit
> Bitdepth_A_RExt_Sony_1.bin
> Bitdepth_B_RExt_Sony_1.bin
> EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_10BIT_RExt_Sony_1.bit
> EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_12BIT_RExt_Sony_1.bit
> EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_8BIT_RExt_Sony_1.bit
> EXTPREC_MAIN_444_16_INTRA_10BIT_RExt_Sony_1.bit
> EXTPREC_MAIN_444_16_INTRA_12BIT_RExt_Sony_1.bit
> EXTPREC_MAIN_444_16_INTRA_8BIT_RExt_Sony_1.bit
> WPP_AND_TILE_10Bit422Test_HIGH_TP_444_10BIT_RExt_Apple_2.bit
> WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_0_HIGH_TP_444_14BIT_RExt_Apple_2.bit
> WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_1_HIGH_TP_444_14BIT_RExt_Apple_2.bit
> WPP_AND_TILE_HIGH_TP_444_8BIT_RExt_Apple_2.bit
>
> you can download them from:
>
> https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/RExt/
>
> Signed-off-by: Xu Guangxin <oddstone at gmail.com>
> ---
>  libavcodec/hevc_cabac.c | 6 ++++++
>  libavcodec/hevcdec.h    | 4 +++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
> index 3dc0987dad..635b4edef3 100644
> --- a/libavcodec/hevc_cabac.c
> +++ b/libavcodec/hevc_cabac.c
> @@ -454,12 +454,18 @@ void ff_hevc_save_states(HEVCContext *s, int
> ctb_addr_ts)
>           (s->ps.sps->ctb_width == 2 &&
>            ctb_addr_ts % s->ps.sps->ctb_width == 0))) {
>          memcpy(s->cabac_state, s->HEVClc->cabac_state, HEVC_CONTEXTS);
> +        if (s->ps.sps->persistent_rice_adaptation_enabled_flag) {
> +            memcpy(s->stat_coeff, s->HEVClc->stat_coeff,
> HEVC_STAT_COEFFS);
> +        }
>      }
>  }
>
>  static void load_states(HEVCContext *s)
>  {
>      memcpy(s->HEVClc->cabac_state, s->cabac_state, HEVC_CONTEXTS);
> +    if (s->ps.sps->persistent_rice_adaptation_enabled_flag) {
> +        memcpy(s->HEVClc->stat_coeff, s->stat_coeff, HEVC_STAT_COEFFS);
> +    }
>  }
>
>  static int cabac_reinit(HEVCLocalContext *lc)
> diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
> index 39c5c7f89f..d41aed4556 100644
> --- a/libavcodec/hevcdec.h
> +++ b/libavcodec/hevcdec.h
> @@ -53,6 +53,7 @@
>  #define DEFAULT_INTRA_TC_OFFSET 2
>
>  #define HEVC_CONTEXTS 199
> +#define HEVC_STAT_COEFFS 4
>
>  #define MRG_MAX_NUM_CANDS     5
>
> @@ -424,7 +425,7 @@ typedef struct HEVCFrame {
>  typedef struct HEVCLocalContext {
>      uint8_t cabac_state[HEVC_CONTEXTS];
>
> -    uint8_t stat_coeff[4];
> +    uint8_t stat_coeff[HEVC_STAT_COEFFS];
>
>      uint8_t first_qp_group;
>
> @@ -480,6 +481,7 @@ typedef struct HEVCContext {
>      int                 height;
>
>      uint8_t *cabac_state;
> +    uint8_t stat_coeff[HEVC_STAT_COEFFS];
>
>      /** 1 if the independent slice segment header was successfully parsed
> */
>      uint8_t slice_initialized;
> --
> 2.17.1
>
>


More information about the ffmpeg-devel mailing list