2013-10-12 12:55:48 +03:00
|
|
|
/*
|
2013-08-11 10:02:07 +03:00
|
|
|
* HEVC video decoder
|
2013-10-12 12:55:48 +03:00
|
|
|
*
|
|
|
|
* Copyright (C) 2012 - 2013 Guillaume Martres
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2016-08-21 17:14:24 +02:00
|
|
|
#ifndef AVCODEC_HEVCDEC_H
|
|
|
|
#define AVCODEC_HEVCDEC_H
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2017-03-22 19:23:17 +02:00
|
|
|
#include <stdatomic.h>
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
#include "libavutil/buffer.h"
|
|
|
|
|
|
|
|
#include "avcodec.h"
|
2014-02-13 19:57:05 +03:00
|
|
|
#include "bswapdsp.h"
|
2013-10-12 12:55:48 +03:00
|
|
|
#include "cabac.h"
|
|
|
|
#include "get_bits.h"
|
|
|
|
#include "hevcpred.h"
|
2016-03-21 08:26:42 +02:00
|
|
|
#include "h2645_parse.h"
|
2016-08-21 17:35:28 +02:00
|
|
|
#include "hevc.h"
|
2016-08-21 18:02:02 +02:00
|
|
|
#include "hevc_ps.h"
|
2017-04-30 16:34:06 +02:00
|
|
|
#include "hevc_sei.h"
|
2013-10-12 12:55:48 +03:00
|
|
|
#include "hevcdsp.h"
|
|
|
|
#include "internal.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "videodsp.h"
|
|
|
|
|
2013-10-21 12:49:35 +03:00
|
|
|
#define MAX_NB_THREADS 16
|
|
|
|
#define SHIFT_CTB_WPP 2
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
//TODO: check if this is really the maximum
|
|
|
|
#define MAX_TRANSFORM_DEPTH 5
|
|
|
|
|
|
|
|
#define MAX_TB_SIZE 32
|
|
|
|
#define MAX_QP 51
|
|
|
|
#define DEFAULT_INTRA_TC_OFFSET 2
|
|
|
|
|
2014-07-13 11:38:13 +03:00
|
|
|
#define HEVC_CONTEXTS 199
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
#define MRG_MAX_NUM_CANDS 5
|
|
|
|
|
|
|
|
#define L0 0
|
|
|
|
#define L1 1
|
|
|
|
|
|
|
|
#define EPEL_EXTRA_BEFORE 1
|
|
|
|
#define EPEL_EXTRA_AFTER 2
|
|
|
|
#define EPEL_EXTRA 3
|
2014-04-26 16:35:23 +03:00
|
|
|
#define QPEL_EXTRA_BEFORE 3
|
|
|
|
#define QPEL_EXTRA_AFTER 4
|
|
|
|
#define QPEL_EXTRA 7
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2014-01-03 11:10:38 +03:00
|
|
|
#define EDGE_EMU_BUFFER_STRIDE 80
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
/**
|
|
|
|
* Value of the luma sample at position (x, y) in the 2D array tab.
|
|
|
|
*/
|
|
|
|
#define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
|
2013-10-27 14:56:48 +03:00
|
|
|
#define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2017-03-23 19:27:48 +02:00
|
|
|
#define IS_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || (s)->nal_unit_type == HEVC_NAL_IDR_N_LP)
|
|
|
|
#define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || (s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \
|
|
|
|
(s)->nal_unit_type == HEVC_NAL_BLA_N_LP)
|
2014-05-25 04:36:03 +03:00
|
|
|
#define IS_IRAP(s) ((s)->nal_unit_type >= 16 && (s)->nal_unit_type <= 23)
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
enum RPSType {
|
|
|
|
ST_CURR_BEF = 0,
|
|
|
|
ST_CURR_AFT,
|
|
|
|
ST_FOLL,
|
|
|
|
LT_CURR,
|
|
|
|
LT_FOLL,
|
|
|
|
NB_RPS_TYPE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SyntaxElement {
|
|
|
|
SAO_MERGE_FLAG = 0,
|
|
|
|
SAO_TYPE_IDX,
|
|
|
|
SAO_EO_CLASS,
|
|
|
|
SAO_BAND_POSITION,
|
|
|
|
SAO_OFFSET_ABS,
|
|
|
|
SAO_OFFSET_SIGN,
|
|
|
|
END_OF_SLICE_FLAG,
|
|
|
|
SPLIT_CODING_UNIT_FLAG,
|
|
|
|
CU_TRANSQUANT_BYPASS_FLAG,
|
|
|
|
SKIP_FLAG,
|
|
|
|
CU_QP_DELTA,
|
|
|
|
PRED_MODE_FLAG,
|
|
|
|
PART_MODE,
|
|
|
|
PCM_FLAG,
|
|
|
|
PREV_INTRA_LUMA_PRED_FLAG,
|
|
|
|
MPM_IDX,
|
|
|
|
REM_INTRA_LUMA_PRED_MODE,
|
|
|
|
INTRA_CHROMA_PRED_MODE,
|
|
|
|
MERGE_FLAG,
|
|
|
|
MERGE_IDX,
|
|
|
|
INTER_PRED_IDC,
|
|
|
|
REF_IDX_L0,
|
|
|
|
REF_IDX_L1,
|
|
|
|
ABS_MVD_GREATER0_FLAG,
|
|
|
|
ABS_MVD_GREATER1_FLAG,
|
|
|
|
ABS_MVD_MINUS2,
|
|
|
|
MVD_SIGN_FLAG,
|
|
|
|
MVP_LX_FLAG,
|
|
|
|
NO_RESIDUAL_DATA_FLAG,
|
|
|
|
SPLIT_TRANSFORM_FLAG,
|
|
|
|
CBF_LUMA,
|
|
|
|
CBF_CB_CR,
|
|
|
|
TRANSFORM_SKIP_FLAG,
|
2014-07-13 11:38:13 +03:00
|
|
|
EXPLICIT_RDPCM_FLAG,
|
|
|
|
EXPLICIT_RDPCM_DIR_FLAG,
|
2013-10-12 12:55:48 +03:00
|
|
|
LAST_SIGNIFICANT_COEFF_X_PREFIX,
|
|
|
|
LAST_SIGNIFICANT_COEFF_Y_PREFIX,
|
|
|
|
LAST_SIGNIFICANT_COEFF_X_SUFFIX,
|
|
|
|
LAST_SIGNIFICANT_COEFF_Y_SUFFIX,
|
|
|
|
SIGNIFICANT_COEFF_GROUP_FLAG,
|
|
|
|
SIGNIFICANT_COEFF_FLAG,
|
|
|
|
COEFF_ABS_LEVEL_GREATER1_FLAG,
|
|
|
|
COEFF_ABS_LEVEL_GREATER2_FLAG,
|
|
|
|
COEFF_ABS_LEVEL_REMAINING,
|
|
|
|
COEFF_SIGN_FLAG,
|
2014-07-13 11:38:13 +03:00
|
|
|
LOG2_RES_SCALE_ABS,
|
|
|
|
RES_SCALE_SIGN_FLAG,
|
|
|
|
CU_CHROMA_QP_OFFSET_FLAG,
|
|
|
|
CU_CHROMA_QP_OFFSET_IDX,
|
2013-10-12 12:55:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum PartMode {
|
|
|
|
PART_2Nx2N = 0,
|
|
|
|
PART_2NxN = 1,
|
|
|
|
PART_Nx2N = 2,
|
|
|
|
PART_NxN = 3,
|
|
|
|
PART_2NxnU = 4,
|
|
|
|
PART_2NxnD = 5,
|
|
|
|
PART_nLx2N = 6,
|
|
|
|
PART_nRx2N = 7,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PredMode {
|
|
|
|
MODE_INTER = 0,
|
|
|
|
MODE_INTRA,
|
|
|
|
MODE_SKIP,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum InterPredIdc {
|
|
|
|
PRED_L0 = 0,
|
|
|
|
PRED_L1,
|
|
|
|
PRED_BI,
|
|
|
|
};
|
|
|
|
|
2014-04-26 16:35:23 +03:00
|
|
|
enum PredFlag {
|
|
|
|
PF_INTRA = 0,
|
|
|
|
PF_L0,
|
|
|
|
PF_L1,
|
|
|
|
PF_BI,
|
|
|
|
};
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
enum IntraPredMode {
|
|
|
|
INTRA_PLANAR = 0,
|
|
|
|
INTRA_DC,
|
|
|
|
INTRA_ANGULAR_2,
|
|
|
|
INTRA_ANGULAR_3,
|
|
|
|
INTRA_ANGULAR_4,
|
|
|
|
INTRA_ANGULAR_5,
|
|
|
|
INTRA_ANGULAR_6,
|
|
|
|
INTRA_ANGULAR_7,
|
|
|
|
INTRA_ANGULAR_8,
|
|
|
|
INTRA_ANGULAR_9,
|
|
|
|
INTRA_ANGULAR_10,
|
|
|
|
INTRA_ANGULAR_11,
|
|
|
|
INTRA_ANGULAR_12,
|
|
|
|
INTRA_ANGULAR_13,
|
|
|
|
INTRA_ANGULAR_14,
|
|
|
|
INTRA_ANGULAR_15,
|
|
|
|
INTRA_ANGULAR_16,
|
|
|
|
INTRA_ANGULAR_17,
|
|
|
|
INTRA_ANGULAR_18,
|
|
|
|
INTRA_ANGULAR_19,
|
|
|
|
INTRA_ANGULAR_20,
|
|
|
|
INTRA_ANGULAR_21,
|
|
|
|
INTRA_ANGULAR_22,
|
|
|
|
INTRA_ANGULAR_23,
|
|
|
|
INTRA_ANGULAR_24,
|
|
|
|
INTRA_ANGULAR_25,
|
|
|
|
INTRA_ANGULAR_26,
|
|
|
|
INTRA_ANGULAR_27,
|
|
|
|
INTRA_ANGULAR_28,
|
|
|
|
INTRA_ANGULAR_29,
|
|
|
|
INTRA_ANGULAR_30,
|
|
|
|
INTRA_ANGULAR_31,
|
|
|
|
INTRA_ANGULAR_32,
|
|
|
|
INTRA_ANGULAR_33,
|
|
|
|
INTRA_ANGULAR_34,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SAOType {
|
|
|
|
SAO_NOT_APPLIED = 0,
|
|
|
|
SAO_BAND,
|
|
|
|
SAO_EDGE,
|
2014-07-17 00:15:32 +03:00
|
|
|
SAO_APPLIED
|
2013-10-12 12:55:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SAOEOClass {
|
|
|
|
SAO_EO_HORIZ = 0,
|
|
|
|
SAO_EO_VERT,
|
|
|
|
SAO_EO_135D,
|
|
|
|
SAO_EO_45D,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ScanType {
|
|
|
|
SCAN_DIAG = 0,
|
|
|
|
SCAN_HORIZ,
|
|
|
|
SCAN_VERT,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct RefPicList {
|
2016-08-21 18:02:02 +02:00
|
|
|
struct HEVCFrame *ref[HEVC_MAX_REFS];
|
|
|
|
int list[HEVC_MAX_REFS];
|
|
|
|
int isLongTerm[HEVC_MAX_REFS];
|
2013-10-12 12:55:48 +03:00
|
|
|
int nb_refs;
|
|
|
|
} RefPicList;
|
|
|
|
|
|
|
|
typedef struct RefPicListTab {
|
|
|
|
RefPicList refPicList[2];
|
|
|
|
} RefPicListTab;
|
|
|
|
|
|
|
|
typedef struct CodingUnit {
|
2013-10-27 14:56:48 +03:00
|
|
|
int x;
|
|
|
|
int y;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-08-11 10:02:07 +03:00
|
|
|
enum PredMode pred_mode; ///< PredMode
|
|
|
|
enum PartMode part_mode; ///< PartMode
|
2013-10-27 14:56:48 +03:00
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
// Inferred parameters
|
2013-08-11 10:02:07 +03:00
|
|
|
uint8_t intra_split_flag; ///< IntraSplitFlag
|
|
|
|
uint8_t max_trafo_depth; ///< MaxTrafoDepth
|
2013-10-27 14:56:48 +03:00
|
|
|
uint8_t cu_transquant_bypass_flag;
|
2013-10-12 12:55:48 +03:00
|
|
|
} CodingUnit;
|
|
|
|
|
|
|
|
typedef struct Mv {
|
2013-08-11 10:02:07 +03:00
|
|
|
int16_t x; ///< horizontal component of motion vector
|
|
|
|
int16_t y; ///< vertical component of motion vector
|
2013-10-12 12:55:48 +03:00
|
|
|
} Mv;
|
|
|
|
|
|
|
|
typedef struct MvField {
|
2014-07-12 17:51:09 +03:00
|
|
|
DECLARE_ALIGNED(4, Mv, mv)[2];
|
2013-10-27 14:56:48 +03:00
|
|
|
int8_t ref_idx[2];
|
2014-04-26 16:35:23 +03:00
|
|
|
int8_t pred_flag;
|
2013-10-12 12:55:48 +03:00
|
|
|
} MvField;
|
|
|
|
|
|
|
|
typedef struct NeighbourAvailable {
|
|
|
|
int cand_bottom_left;
|
|
|
|
int cand_left;
|
|
|
|
int cand_up;
|
|
|
|
int cand_up_left;
|
|
|
|
int cand_up_right;
|
|
|
|
int cand_up_right_sap;
|
|
|
|
} NeighbourAvailable;
|
|
|
|
|
|
|
|
typedef struct PredictionUnit {
|
|
|
|
int mpm_idx;
|
|
|
|
int rem_intra_luma_pred_mode;
|
|
|
|
uint8_t intra_pred_mode[4];
|
|
|
|
Mv mvd;
|
2013-10-27 14:56:48 +03:00
|
|
|
uint8_t merge_flag;
|
2014-07-15 01:16:53 +03:00
|
|
|
uint8_t intra_pred_mode_c[4];
|
|
|
|
uint8_t chroma_mode_c[4];
|
2013-10-12 12:55:48 +03:00
|
|
|
} PredictionUnit;
|
|
|
|
|
|
|
|
typedef struct TransformUnit {
|
|
|
|
int cu_qp_delta;
|
|
|
|
|
2014-07-15 01:20:22 +03:00
|
|
|
int res_scale_val;
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
// Inferred parameters;
|
2014-07-15 01:16:53 +03:00
|
|
|
int intra_pred_mode;
|
|
|
|
int intra_pred_mode_c;
|
|
|
|
int chroma_mode_c;
|
2013-10-27 14:56:48 +03:00
|
|
|
uint8_t is_cu_qp_delta_coded;
|
2014-07-15 01:20:22 +03:00
|
|
|
uint8_t is_cu_chroma_qp_offset_coded;
|
|
|
|
int8_t cu_qp_offset_cb;
|
|
|
|
int8_t cu_qp_offset_cr;
|
|
|
|
uint8_t cross_pf;
|
2013-10-12 12:55:48 +03:00
|
|
|
} TransformUnit;
|
|
|
|
|
|
|
|
typedef struct DBParams {
|
|
|
|
int beta_offset;
|
|
|
|
int tc_offset;
|
|
|
|
} DBParams;
|
|
|
|
|
|
|
|
#define HEVC_FRAME_FLAG_OUTPUT (1 << 0)
|
|
|
|
#define HEVC_FRAME_FLAG_SHORT_REF (1 << 1)
|
|
|
|
#define HEVC_FRAME_FLAG_LONG_REF (1 << 2)
|
2014-07-26 15:27:56 +03:00
|
|
|
#define HEVC_FRAME_FLAG_BUMPING (1 << 3)
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
typedef struct HEVCFrame {
|
|
|
|
AVFrame *frame;
|
|
|
|
ThreadFrame tf;
|
|
|
|
MvField *tab_mvf;
|
|
|
|
RefPicList *refPicList;
|
|
|
|
RefPicListTab **rpl_tab;
|
|
|
|
int ctb_count;
|
2013-10-27 14:56:48 +03:00
|
|
|
int poc;
|
2013-10-12 12:55:48 +03:00
|
|
|
struct HEVCFrame *collocated_ref;
|
|
|
|
|
2013-10-27 14:56:48 +03:00
|
|
|
HEVCWindow window;
|
|
|
|
|
|
|
|
AVBufferRef *tab_mvf_buf;
|
|
|
|
AVBufferRef *rpl_tab_buf;
|
|
|
|
AVBufferRef *rpl_buf;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2015-01-25 14:01:09 +02:00
|
|
|
AVBufferRef *hwaccel_priv_buf;
|
|
|
|
void *hwaccel_picture_private;
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
/**
|
|
|
|
* A sequence counter, so that old frames are output first
|
|
|
|
* after a POC reset
|
|
|
|
*/
|
|
|
|
uint16_t sequence;
|
|
|
|
|
2013-10-27 14:56:48 +03:00
|
|
|
/**
|
|
|
|
* A combination of HEVC_FRAME_FLAG_*
|
|
|
|
*/
|
|
|
|
uint8_t flags;
|
2013-10-12 12:55:48 +03:00
|
|
|
} HEVCFrame;
|
|
|
|
|
|
|
|
typedef struct HEVCLocalContext {
|
|
|
|
uint8_t cabac_state[HEVC_CONTEXTS];
|
2013-10-27 14:56:48 +03:00
|
|
|
|
2014-07-15 01:20:22 +03:00
|
|
|
uint8_t stat_coeff[4];
|
|
|
|
|
2013-10-27 14:56:48 +03:00
|
|
|
uint8_t first_qp_group;
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
GetBitContext gb;
|
|
|
|
CABACContext cc;
|
2013-10-27 14:56:48 +03:00
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
int8_t qp_y;
|
|
|
|
int8_t curr_qp_y;
|
2013-10-27 14:56:48 +03:00
|
|
|
|
2014-02-08 01:28:22 +03:00
|
|
|
int qPy_pred;
|
|
|
|
|
2013-10-27 14:56:48 +03:00
|
|
|
TransformUnit tu;
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
uint8_t ctb_left_flag;
|
|
|
|
uint8_t ctb_up_flag;
|
|
|
|
uint8_t ctb_up_right_flag;
|
|
|
|
uint8_t ctb_up_left_flag;
|
|
|
|
int end_of_tiles_x;
|
|
|
|
int end_of_tiles_y;
|
2014-01-03 11:10:38 +03:00
|
|
|
/* +7 is for subpixel interpolation, *2 for high bit depths */
|
|
|
|
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
|
2015-02-02 16:51:45 +02:00
|
|
|
/* The extended size between the new edge emu buffer is abused by SAO */
|
2014-04-26 16:35:23 +03:00
|
|
|
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer2)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
|
2015-02-05 21:20:42 +02:00
|
|
|
DECLARE_ALIGNED(32, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]);
|
2014-04-26 16:35:23 +03:00
|
|
|
|
2014-09-24 00:36:41 +03:00
|
|
|
int ct_depth;
|
2013-10-12 12:55:48 +03:00
|
|
|
CodingUnit cu;
|
|
|
|
PredictionUnit pu;
|
|
|
|
NeighbourAvailable na;
|
2013-10-27 14:56:48 +03:00
|
|
|
|
2014-07-28 02:06:32 +03:00
|
|
|
#define BOUNDARY_LEFT_SLICE (1 << 0)
|
|
|
|
#define BOUNDARY_LEFT_TILE (1 << 1)
|
|
|
|
#define BOUNDARY_UPPER_SLICE (1 << 2)
|
|
|
|
#define BOUNDARY_UPPER_TILE (1 << 3)
|
|
|
|
/* properties of the boundary of the current CTB for the purposes
|
|
|
|
* of the deblocking filter */
|
|
|
|
int boundary_flags;
|
2013-10-12 12:55:48 +03:00
|
|
|
} HEVCLocalContext;
|
|
|
|
|
|
|
|
typedef struct HEVCContext {
|
|
|
|
const AVClass *c; // needed by private avoptions
|
2013-12-10 17:37:21 +03:00
|
|
|
AVCodecContext *avctx;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-11-21 13:25:32 +03:00
|
|
|
struct HEVCContext *sList[MAX_NB_THREADS];
|
2013-10-21 12:49:35 +03:00
|
|
|
|
2013-11-21 13:25:32 +03:00
|
|
|
HEVCLocalContext *HEVClcList[MAX_NB_THREADS];
|
|
|
|
HEVCLocalContext *HEVClc;
|
2013-10-21 12:49:35 +03:00
|
|
|
|
|
|
|
uint8_t threads_type;
|
|
|
|
uint8_t threads_number;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
2013-10-21 12:49:35 +03:00
|
|
|
uint8_t *cabac_state;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-10-27 14:56:48 +03:00
|
|
|
/** 1 if the independent slice segment header was successfully parsed */
|
|
|
|
uint8_t slice_initialized;
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
AVFrame *frame;
|
|
|
|
AVFrame *output_frame;
|
2015-01-13 00:09:23 +02:00
|
|
|
uint8_t *sao_pixel_buffer_h[3];
|
|
|
|
uint8_t *sao_pixel_buffer_v[3];
|
2013-11-02 13:59:02 +03:00
|
|
|
|
2015-07-09 14:22:43 +02:00
|
|
|
HEVCParamSets ps;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-10-27 14:56:48 +03:00
|
|
|
AVBufferPool *tab_mvf_pool;
|
|
|
|
AVBufferPool *rpl_tab_pool;
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
///< candidate references for the current frame
|
|
|
|
RefPicList rps[5];
|
|
|
|
|
|
|
|
SliceHeader sh;
|
|
|
|
SAOParams *sao;
|
|
|
|
DBParams *deblock;
|
2016-08-21 17:35:28 +02:00
|
|
|
enum HEVCNALUnitType nal_unit_type;
|
2013-10-12 12:55:48 +03:00
|
|
|
int temporal_id; ///< temporal_id_plus1 - 1
|
|
|
|
HEVCFrame *ref;
|
|
|
|
HEVCFrame DPB[32];
|
|
|
|
int poc;
|
|
|
|
int pocTid0;
|
|
|
|
int slice_idx; ///< number of the slice being currently decoded
|
|
|
|
int eos; ///< current packet contains an EOS/EOB NAL
|
2014-04-29 12:29:16 +03:00
|
|
|
int last_eos; ///< last packet contains an EOS/EOB NAL
|
2013-10-12 12:55:48 +03:00
|
|
|
int max_ra;
|
|
|
|
int bs_width;
|
|
|
|
int bs_height;
|
|
|
|
|
|
|
|
int is_decoded;
|
2015-09-12 21:50:24 +02:00
|
|
|
int no_rasl_output_flag;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
HEVCPredContext hpc;
|
|
|
|
HEVCDSPContext hevcdsp;
|
|
|
|
VideoDSPContext vdsp;
|
2014-02-13 19:57:05 +03:00
|
|
|
BswapDSPContext bdsp;
|
2013-10-12 12:55:48 +03:00
|
|
|
int8_t *qp_y_tab;
|
|
|
|
uint8_t *horizontal_bs;
|
|
|
|
uint8_t *vertical_bs;
|
|
|
|
|
|
|
|
int32_t *tab_slice_address;
|
|
|
|
|
|
|
|
// CU
|
|
|
|
uint8_t *skip_flag;
|
|
|
|
uint8_t *tab_ct_depth;
|
|
|
|
// PU
|
|
|
|
uint8_t *tab_ipm;
|
|
|
|
|
|
|
|
uint8_t *cbf_luma; // cbf_luma of colocated TU
|
|
|
|
uint8_t *is_pcm;
|
|
|
|
|
|
|
|
// CTB-level flags affecting loop filter operation
|
|
|
|
uint8_t *filter_slice_edges;
|
|
|
|
|
|
|
|
/** used on BE to byteswap the lines for checksumming */
|
|
|
|
uint8_t *checksum_buf;
|
|
|
|
int checksum_buf_size;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sequence counters for decoded and output frames, so that old
|
|
|
|
* frames are output first after a POC reset
|
|
|
|
*/
|
|
|
|
uint16_t seq_decode;
|
|
|
|
uint16_t seq_output;
|
|
|
|
|
2013-10-21 12:49:35 +03:00
|
|
|
int enable_parallel_tiles;
|
2017-03-22 19:23:17 +02:00
|
|
|
atomic_int wpp_err;
|
2013-10-21 12:49:35 +03:00
|
|
|
|
2014-04-22 21:41:34 +03:00
|
|
|
const uint8_t *data;
|
2013-10-21 12:49:35 +03:00
|
|
|
|
2016-03-21 08:26:42 +02:00
|
|
|
H2645Packet pkt;
|
2014-02-02 15:35:48 +03:00
|
|
|
// type of the first VCL NAL of the current frame
|
2016-08-21 17:35:28 +02:00
|
|
|
enum HEVCNALUnitType first_nal_type;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-12-10 17:37:21 +03:00
|
|
|
uint8_t context_initialized;
|
2017-04-02 20:41:10 +02:00
|
|
|
int is_nalff; ///< this flag is != 0 if bitstream is encapsulated
|
2013-08-11 10:02:07 +03:00
|
|
|
///< as a format defined in 14496-15
|
|
|
|
int apply_defdispwin;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-08-11 10:02:07 +03:00
|
|
|
int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
|
2013-10-27 14:56:48 +03:00
|
|
|
int nuh_layer_id;
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2017-04-30 03:01:03 +02:00
|
|
|
HEVCSEIContext sei;
|
2013-10-12 12:55:48 +03:00
|
|
|
} HEVCContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark all frames in DPB as unused for reference.
|
|
|
|
*/
|
|
|
|
void ff_hevc_clear_refs(HEVCContext *s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop all frames currently in DPB.
|
|
|
|
*/
|
|
|
|
void ff_hevc_flush_dpb(HEVCContext *s);
|
|
|
|
|
2013-08-11 10:02:07 +03:00
|
|
|
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame,
|
|
|
|
int x0, int y0);
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct the reference picture sets for the current frame.
|
|
|
|
*/
|
|
|
|
int ff_hevc_frame_rps(HEVCContext *s);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct the reference picture list(s) for the current slice.
|
|
|
|
*/
|
|
|
|
int ff_hevc_slice_rpl(HEVCContext *s);
|
|
|
|
|
|
|
|
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts);
|
|
|
|
void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts);
|
|
|
|
int ff_hevc_sao_merge_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_sao_type_idx_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_sao_band_position_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_sao_offset_abs_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_sao_offset_sign_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_sao_eo_class_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_end_of_slice_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s);
|
2013-08-11 10:02:07 +03:00
|
|
|
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0,
|
|
|
|
int x_cb, int y_cb);
|
2013-10-12 12:55:48 +03:00
|
|
|
int ff_hevc_pred_mode_decode(HEVCContext *s);
|
2013-08-11 10:02:07 +03:00
|
|
|
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth,
|
|
|
|
int x0, int y0);
|
2013-10-12 12:55:48 +03:00
|
|
|
int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size);
|
|
|
|
int ff_hevc_pcm_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_mpm_idx_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_intra_chroma_pred_mode_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_merge_idx_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_merge_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH);
|
|
|
|
int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx);
|
|
|
|
int ff_hevc_mvp_lx_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s);
|
|
|
|
int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size);
|
|
|
|
int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth);
|
|
|
|
int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth);
|
2014-07-15 01:20:22 +03:00
|
|
|
int ff_hevc_log2_res_scale_abs(HEVCContext *s, int idx);
|
|
|
|
int ff_hevc_res_scale_sign_flag(HEVCContext *s, int idx);
|
2013-10-12 12:55:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the number of candidate references for the current frame.
|
|
|
|
*/
|
|
|
|
int ff_hevc_frame_nb_refs(HEVCContext *s);
|
2013-11-02 13:59:02 +03:00
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find next frame in output order and put a reference to it in frame.
|
|
|
|
* @return 1 if a frame was output, 0 otherwise
|
|
|
|
*/
|
|
|
|
int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush);
|
|
|
|
|
2014-07-26 15:27:56 +03:00
|
|
|
void ff_hevc_bump_frame(HEVCContext *s);
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags);
|
|
|
|
|
2013-08-11 10:02:07 +03:00
|
|
|
void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
|
|
|
|
int nPbW, int nPbH);
|
|
|
|
void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0,
|
|
|
|
int nPbW, int nPbH, int log2_cb_size,
|
|
|
|
int part_idx, int merge_idx, MvField *mv);
|
|
|
|
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0,
|
|
|
|
int nPbW, int nPbH, int log2_cb_size,
|
|
|
|
int part_idx, int merge_idx,
|
|
|
|
MvField *mv, int mvp_lx_flag, int LX);
|
2014-07-27 23:56:06 +03:00
|
|
|
void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase,
|
2013-08-11 10:02:07 +03:00
|
|
|
int log2_cb_size);
|
|
|
|
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
|
2014-04-26 16:35:23 +03:00
|
|
|
int log2_trafo_size);
|
2013-10-12 12:55:48 +03:00
|
|
|
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s);
|
|
|
|
int ff_hevc_cu_qp_delta_abs(HEVCContext *s);
|
2014-07-15 01:20:22 +03:00
|
|
|
int ff_hevc_cu_chroma_qp_offset_flag(HEVCContext *s);
|
|
|
|
int ff_hevc_cu_chroma_qp_offset_idx(HEVCContext *s);
|
2014-07-15 11:23:20 +03:00
|
|
|
void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size);
|
2013-10-12 12:55:48 +03:00
|
|
|
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size);
|
2013-10-18 17:16:48 +03:00
|
|
|
void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
|
|
|
|
int log2_trafo_size, enum ScanType scan_idx,
|
|
|
|
int c_idx);
|
2013-10-12 12:55:48 +03:00
|
|
|
|
2013-10-18 21:01:29 +03:00
|
|
|
void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size);
|
|
|
|
|
2013-10-12 12:55:48 +03:00
|
|
|
extern const uint8_t ff_hevc_qpel_extra_before[4];
|
|
|
|
extern const uint8_t ff_hevc_qpel_extra_after[4];
|
|
|
|
extern const uint8_t ff_hevc_qpel_extra[4];
|
|
|
|
|
2016-08-21 17:14:24 +02:00
|
|
|
#endif /* AVCODEC_HEVCDEC_H */
|