You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

674 lines
19KB

  1. /*
  2. * HEVC video decoder
  3. *
  4. * Copyright (C) 2012 - 2013 Guillaume Martres
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * Libav is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_HEVCDEC_H
  23. #define AVCODEC_HEVCDEC_H
  24. #include <stddef.h>
  25. #include <stdint.h>
  26. #include "libavutil/buffer.h"
  27. #include "libavutil/md5.h"
  28. #include "avcodec.h"
  29. #include "bswapdsp.h"
  30. #include "cabac.h"
  31. #include "get_bits.h"
  32. #include "h2645_parse.h"
  33. #include "hevc.h"
  34. #include "hevc_ps.h"
  35. #include "hevcdsp.h"
  36. #include "internal.h"
  37. #include "thread.h"
  38. #include "videodsp.h"
  39. //TODO: check if this is really the maximum
  40. #define MAX_TRANSFORM_DEPTH 5
  41. #define MAX_TB_SIZE 32
  42. #define MAX_PB_SIZE 64
  43. #define MAX_QP 51
  44. #define DEFAULT_INTRA_TC_OFFSET 2
  45. #define HEVC_CONTEXTS 183
  46. #define MRG_MAX_NUM_CANDS 5
  47. #define L0 0
  48. #define L1 1
  49. #define EPEL_EXTRA_BEFORE 1
  50. #define EPEL_EXTRA_AFTER 2
  51. #define EPEL_EXTRA 3
  52. #define EDGE_EMU_BUFFER_STRIDE 80
  53. /**
  54. * Value of the luma sample at position (x, y) in the 2D array tab.
  55. */
  56. #define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
  57. #define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
  58. #define IS_IDR(s) (s->nal_unit_type == HEVC_NAL_IDR_W_RADL || s->nal_unit_type == HEVC_NAL_IDR_N_LP)
  59. #define IS_BLA(s) (s->nal_unit_type == HEVC_NAL_BLA_W_RADL || s->nal_unit_type == HEVC_NAL_BLA_W_LP || \
  60. s->nal_unit_type == HEVC_NAL_BLA_N_LP)
  61. #define IS_IRAP(s) (s->nal_unit_type >= 16 && s->nal_unit_type <= 23)
  62. #define FFUDIV(a,b) (((a) > 0 ? (a) : (a) - (b) + 1) / (b))
  63. #define FFUMOD(a,b) ((a) - (b) * FFUDIV(a,b))
  64. enum RPSType {
  65. ST_CURR_BEF = 0,
  66. ST_CURR_AFT,
  67. ST_FOLL,
  68. LT_CURR,
  69. LT_FOLL,
  70. NB_RPS_TYPE,
  71. };
  72. enum SyntaxElement {
  73. SAO_MERGE_FLAG = 0,
  74. SAO_TYPE_IDX,
  75. SAO_EO_CLASS,
  76. SAO_BAND_POSITION,
  77. SAO_OFFSET_ABS,
  78. SAO_OFFSET_SIGN,
  79. END_OF_SLICE_FLAG,
  80. SPLIT_CODING_UNIT_FLAG,
  81. CU_TRANSQUANT_BYPASS_FLAG,
  82. SKIP_FLAG,
  83. CU_QP_DELTA,
  84. PRED_MODE_FLAG,
  85. PART_MODE,
  86. PCM_FLAG,
  87. PREV_INTRA_LUMA_PRED_FLAG,
  88. MPM_IDX,
  89. REM_INTRA_LUMA_PRED_MODE,
  90. INTRA_CHROMA_PRED_MODE,
  91. MERGE_FLAG,
  92. MERGE_IDX,
  93. INTER_PRED_IDC,
  94. REF_IDX_L0,
  95. REF_IDX_L1,
  96. ABS_MVD_GREATER0_FLAG,
  97. ABS_MVD_GREATER1_FLAG,
  98. ABS_MVD_MINUS2,
  99. MVD_SIGN_FLAG,
  100. MVP_LX_FLAG,
  101. NO_RESIDUAL_DATA_FLAG,
  102. SPLIT_TRANSFORM_FLAG,
  103. CBF_LUMA,
  104. CBF_CB_CR,
  105. TRANSFORM_SKIP_FLAG,
  106. LAST_SIGNIFICANT_COEFF_X_PREFIX,
  107. LAST_SIGNIFICANT_COEFF_Y_PREFIX,
  108. LAST_SIGNIFICANT_COEFF_X_SUFFIX,
  109. LAST_SIGNIFICANT_COEFF_Y_SUFFIX,
  110. SIGNIFICANT_COEFF_GROUP_FLAG,
  111. SIGNIFICANT_COEFF_FLAG,
  112. COEFF_ABS_LEVEL_GREATER1_FLAG,
  113. COEFF_ABS_LEVEL_GREATER2_FLAG,
  114. COEFF_ABS_LEVEL_REMAINING,
  115. COEFF_SIGN_FLAG,
  116. };
  117. enum PartMode {
  118. PART_2Nx2N = 0,
  119. PART_2NxN = 1,
  120. PART_Nx2N = 2,
  121. PART_NxN = 3,
  122. PART_2NxnU = 4,
  123. PART_2NxnD = 5,
  124. PART_nLx2N = 6,
  125. PART_nRx2N = 7,
  126. };
  127. enum PredMode {
  128. MODE_INTER = 0,
  129. MODE_INTRA,
  130. MODE_SKIP,
  131. };
  132. enum InterPredIdc {
  133. PRED_L0 = 0,
  134. PRED_L1,
  135. PRED_BI,
  136. };
  137. enum IntraPredMode {
  138. INTRA_PLANAR = 0,
  139. INTRA_DC,
  140. INTRA_ANGULAR_2,
  141. INTRA_ANGULAR_3,
  142. INTRA_ANGULAR_4,
  143. INTRA_ANGULAR_5,
  144. INTRA_ANGULAR_6,
  145. INTRA_ANGULAR_7,
  146. INTRA_ANGULAR_8,
  147. INTRA_ANGULAR_9,
  148. INTRA_ANGULAR_10,
  149. INTRA_ANGULAR_11,
  150. INTRA_ANGULAR_12,
  151. INTRA_ANGULAR_13,
  152. INTRA_ANGULAR_14,
  153. INTRA_ANGULAR_15,
  154. INTRA_ANGULAR_16,
  155. INTRA_ANGULAR_17,
  156. INTRA_ANGULAR_18,
  157. INTRA_ANGULAR_19,
  158. INTRA_ANGULAR_20,
  159. INTRA_ANGULAR_21,
  160. INTRA_ANGULAR_22,
  161. INTRA_ANGULAR_23,
  162. INTRA_ANGULAR_24,
  163. INTRA_ANGULAR_25,
  164. INTRA_ANGULAR_26,
  165. INTRA_ANGULAR_27,
  166. INTRA_ANGULAR_28,
  167. INTRA_ANGULAR_29,
  168. INTRA_ANGULAR_30,
  169. INTRA_ANGULAR_31,
  170. INTRA_ANGULAR_32,
  171. INTRA_ANGULAR_33,
  172. INTRA_ANGULAR_34,
  173. };
  174. enum SAOType {
  175. SAO_NOT_APPLIED = 0,
  176. SAO_BAND,
  177. SAO_EDGE,
  178. };
  179. enum SAOEOClass {
  180. SAO_EO_HORIZ = 0,
  181. SAO_EO_VERT,
  182. SAO_EO_135D,
  183. SAO_EO_45D,
  184. };
  185. enum ScanType {
  186. SCAN_DIAG = 0,
  187. SCAN_HORIZ,
  188. SCAN_VERT,
  189. };
  190. typedef struct LongTermRPS {
  191. int poc[32];
  192. uint8_t used[32];
  193. uint8_t nb_refs;
  194. } LongTermRPS;
  195. typedef struct RefPicList {
  196. struct HEVCFrame *ref[HEVC_MAX_REFS];
  197. int list[HEVC_MAX_REFS];
  198. int isLongTerm[HEVC_MAX_REFS];
  199. int nb_refs;
  200. } RefPicList;
  201. typedef struct RefPicListTab {
  202. RefPicList refPicList[2];
  203. } RefPicListTab;
  204. typedef struct SliceHeader {
  205. unsigned int pps_id;
  206. ///< address (in raster order) of the first block in the current slice segment
  207. unsigned int slice_segment_addr;
  208. ///< address (in raster order) of the first block in the current slice
  209. unsigned int slice_addr;
  210. enum HEVCSliceType slice_type;
  211. int pic_order_cnt_lsb;
  212. uint8_t first_slice_in_pic_flag;
  213. uint8_t dependent_slice_segment_flag;
  214. uint8_t pic_output_flag;
  215. uint8_t colour_plane_id;
  216. ///< RPS coded in the slice header itself is stored here
  217. int short_term_ref_pic_set_sps_flag;
  218. int short_term_ref_pic_set_size;
  219. ShortTermRPS slice_rps;
  220. const ShortTermRPS *short_term_rps;
  221. int long_term_ref_pic_set_size;
  222. LongTermRPS long_term_rps;
  223. unsigned int list_entry_lx[2][32];
  224. uint8_t rpl_modification_flag[2];
  225. uint8_t no_output_of_prior_pics_flag;
  226. uint8_t slice_temporal_mvp_enabled_flag;
  227. unsigned int nb_refs[2];
  228. uint8_t slice_sample_adaptive_offset_flag[3];
  229. uint8_t mvd_l1_zero_flag;
  230. uint8_t cabac_init_flag;
  231. uint8_t disable_deblocking_filter_flag; ///< slice_header_disable_deblocking_filter_flag
  232. uint8_t slice_loop_filter_across_slices_enabled_flag;
  233. uint8_t collocated_list;
  234. unsigned int collocated_ref_idx;
  235. int slice_qp_delta;
  236. int slice_cb_qp_offset;
  237. int slice_cr_qp_offset;
  238. int beta_offset; ///< beta_offset_div2 * 2
  239. int tc_offset; ///< tc_offset_div2 * 2
  240. unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
  241. int num_entry_point_offsets;
  242. int8_t slice_qp;
  243. uint8_t luma_log2_weight_denom;
  244. int16_t chroma_log2_weight_denom;
  245. int16_t luma_weight_l0[16];
  246. int16_t chroma_weight_l0[16][2];
  247. int16_t chroma_weight_l1[16][2];
  248. int16_t luma_weight_l1[16];
  249. int16_t luma_offset_l0[16];
  250. int16_t chroma_offset_l0[16][2];
  251. int16_t luma_offset_l1[16];
  252. int16_t chroma_offset_l1[16][2];
  253. int slice_ctb_addr_rs;
  254. } SliceHeader;
  255. typedef struct CodingTree {
  256. int depth; ///< ctDepth
  257. } CodingTree;
  258. typedef struct CodingUnit {
  259. int x;
  260. int y;
  261. enum PredMode pred_mode; ///< PredMode
  262. enum PartMode part_mode; ///< PartMode
  263. // Inferred parameters
  264. uint8_t intra_split_flag; ///< IntraSplitFlag
  265. uint8_t max_trafo_depth; ///< MaxTrafoDepth
  266. uint8_t cu_transquant_bypass_flag;
  267. } CodingUnit;
  268. typedef struct Mv {
  269. int16_t x; ///< horizontal component of motion vector
  270. int16_t y; ///< vertical component of motion vector
  271. } Mv;
  272. typedef struct MvField {
  273. DECLARE_ALIGNED(4, Mv, mv)[2];
  274. int8_t ref_idx[2];
  275. int8_t pred_flag[2];
  276. uint8_t is_intra;
  277. } MvField;
  278. typedef struct NeighbourAvailable {
  279. int cand_bottom_left;
  280. int cand_left;
  281. int cand_up;
  282. int cand_up_left;
  283. int cand_up_right;
  284. int cand_up_right_sap;
  285. } NeighbourAvailable;
  286. typedef struct PredictionUnit {
  287. int mpm_idx;
  288. int rem_intra_luma_pred_mode;
  289. uint8_t intra_pred_mode[4];
  290. Mv mvd;
  291. uint8_t merge_flag;
  292. uint8_t intra_pred_mode_c;
  293. } PredictionUnit;
  294. typedef struct TransformUnit {
  295. int cu_qp_delta;
  296. // Inferred parameters;
  297. int cur_intra_pred_mode;
  298. uint8_t is_cu_qp_delta_coded;
  299. } TransformUnit;
  300. typedef struct DBParams {
  301. int beta_offset;
  302. int tc_offset;
  303. } DBParams;
  304. #define HEVC_FRAME_FLAG_OUTPUT (1 << 0)
  305. #define HEVC_FRAME_FLAG_SHORT_REF (1 << 1)
  306. #define HEVC_FRAME_FLAG_LONG_REF (1 << 2)
  307. typedef struct HEVCFrame {
  308. AVFrame *frame;
  309. ThreadFrame tf;
  310. MvField *tab_mvf;
  311. RefPicList *refPicList;
  312. RefPicListTab **rpl_tab;
  313. int ctb_count;
  314. int poc;
  315. struct HEVCFrame *collocated_ref;
  316. AVBufferRef *tab_mvf_buf;
  317. AVBufferRef *rpl_tab_buf;
  318. AVBufferRef *rpl_buf;
  319. AVBufferRef *hwaccel_priv_buf;
  320. void *hwaccel_picture_private;
  321. /**
  322. * A sequence counter, so that old frames are output first
  323. * after a POC reset
  324. */
  325. uint16_t sequence;
  326. /**
  327. * A combination of HEVC_FRAME_FLAG_*
  328. */
  329. uint8_t flags;
  330. } HEVCFrame;
  331. struct HEVCContext;
  332. typedef struct HEVCPredContext {
  333. void (*intra_pred[4])(struct HEVCContext *s, int x0, int y0, int c_idx);
  334. void (*pred_planar[4])(uint8_t *src, const uint8_t *top,
  335. const uint8_t *left, ptrdiff_t stride);
  336. void (*pred_dc)(uint8_t *src, const uint8_t *top, const uint8_t *left,
  337. ptrdiff_t stride, int log2_size, int c_idx);
  338. void (*pred_angular[4])(uint8_t *src, const uint8_t *top,
  339. const uint8_t *left, ptrdiff_t stride,
  340. int c_idx, int mode);
  341. } HEVCPredContext;
  342. typedef struct HEVCLocalContext {
  343. DECLARE_ALIGNED(16, int16_t, mc_buffer[(MAX_PB_SIZE + 24) * MAX_PB_SIZE]);
  344. uint8_t cabac_state[HEVC_CONTEXTS];
  345. uint8_t first_qp_group;
  346. GetBitContext gb;
  347. CABACContext cc;
  348. int8_t qp_y;
  349. int8_t curr_qp_y;
  350. TransformUnit tu;
  351. uint8_t ctb_left_flag;
  352. uint8_t ctb_up_flag;
  353. uint8_t ctb_up_right_flag;
  354. uint8_t ctb_up_left_flag;
  355. int start_of_tiles_x;
  356. int end_of_tiles_x;
  357. int end_of_tiles_y;
  358. /* +7 is for subpixel interpolation, *2 for high bit depths */
  359. DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
  360. CodingTree ct;
  361. CodingUnit cu;
  362. PredictionUnit pu;
  363. NeighbourAvailable na;
  364. #define BOUNDARY_LEFT_SLICE (1 << 0)
  365. #define BOUNDARY_LEFT_TILE (1 << 1)
  366. #define BOUNDARY_UPPER_SLICE (1 << 2)
  367. #define BOUNDARY_UPPER_TILE (1 << 3)
  368. /* properties of the boundary of the current CTB for the purposes
  369. * of the deblocking filter */
  370. int boundary_flags;
  371. } HEVCLocalContext;
  372. typedef struct HEVCContext {
  373. const AVClass *c; // needed by private avoptions
  374. AVCodecContext *avctx;
  375. HEVCLocalContext HEVClc;
  376. uint8_t cabac_state[HEVC_CONTEXTS];
  377. /** 1 if the independent slice segment header was successfully parsed */
  378. uint8_t slice_initialized;
  379. AVFrame *frame;
  380. AVFrame *sao_frame;
  381. AVFrame *tmp_frame;
  382. AVFrame *output_frame;
  383. HEVCParamSets ps;
  384. AVBufferPool *tab_mvf_pool;
  385. AVBufferPool *rpl_tab_pool;
  386. ///< candidate references for the current frame
  387. RefPicList rps[5];
  388. SliceHeader sh;
  389. SAOParams *sao;
  390. DBParams *deblock;
  391. enum HEVCNALUnitType nal_unit_type;
  392. int temporal_id; ///< temporal_id_plus1 - 1
  393. HEVCFrame *ref;
  394. HEVCFrame DPB[32];
  395. int poc;
  396. int pocTid0;
  397. int slice_idx; ///< number of the slice being currently decoded
  398. int eos; ///< current packet contains an EOS/EOB NAL
  399. int max_ra;
  400. int bs_width;
  401. int bs_height;
  402. int is_decoded;
  403. HEVCPredContext hpc;
  404. HEVCDSPContext hevcdsp;
  405. VideoDSPContext vdsp;
  406. BswapDSPContext bdsp;
  407. int8_t *qp_y_tab;
  408. uint8_t *horizontal_bs;
  409. uint8_t *vertical_bs;
  410. int32_t *tab_slice_address;
  411. // CU
  412. uint8_t *skip_flag;
  413. uint8_t *tab_ct_depth;
  414. // PU
  415. uint8_t *tab_ipm;
  416. uint8_t *cbf_luma; // cbf_luma of colocated TU
  417. uint8_t *is_pcm;
  418. // CTB-level flags affecting loop filter operation
  419. uint8_t *filter_slice_edges;
  420. /** used on BE to byteswap the lines for checksumming */
  421. uint8_t *checksum_buf;
  422. int checksum_buf_size;
  423. /**
  424. * Sequence counters for decoded and output frames, so that old
  425. * frames are output first after a POC reset
  426. */
  427. uint16_t seq_decode;
  428. uint16_t seq_output;
  429. H2645Packet pkt;
  430. // type of the first VCL NAL of the current frame
  431. enum HEVCNALUnitType first_nal_type;
  432. // for checking the frame checksums
  433. struct AVMD5 *md5_ctx;
  434. uint8_t md5[3][16];
  435. uint8_t is_md5;
  436. uint8_t context_initialized;
  437. uint8_t is_nalff; ///< this flag is != 0 if bitstream is encapsulated
  438. ///< as a format defined in 14496-15
  439. int apply_defdispwin;
  440. int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
  441. int nuh_layer_id;
  442. /** frame packing arrangement variables */
  443. int sei_frame_packing_present;
  444. int frame_packing_arrangement_type;
  445. int content_interpretation_type;
  446. int quincunx_subsampling;
  447. /** display orientation */
  448. int sei_display_orientation_present;
  449. int sei_anticlockwise_rotation;
  450. int sei_hflip, sei_vflip;
  451. } HEVCContext;
  452. int ff_hevc_decode_nal_sei(HEVCContext *s);
  453. /**
  454. * Mark all frames in DPB as unused for reference.
  455. */
  456. void ff_hevc_clear_refs(HEVCContext *s);
  457. /**
  458. * Drop all frames currently in DPB.
  459. */
  460. void ff_hevc_flush_dpb(HEVCContext *s);
  461. /**
  462. * Compute POC of the current frame and return it.
  463. */
  464. int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb);
  465. RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame,
  466. int x0, int y0);
  467. /**
  468. * Construct the reference picture sets for the current frame.
  469. */
  470. int ff_hevc_frame_rps(HEVCContext *s);
  471. /**
  472. * Construct the reference picture list(s) for the current slice.
  473. */
  474. int ff_hevc_slice_rpl(HEVCContext *s);
  475. void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts);
  476. void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts);
  477. int ff_hevc_sao_merge_flag_decode(HEVCContext *s);
  478. int ff_hevc_sao_type_idx_decode(HEVCContext *s);
  479. int ff_hevc_sao_band_position_decode(HEVCContext *s);
  480. int ff_hevc_sao_offset_abs_decode(HEVCContext *s);
  481. int ff_hevc_sao_offset_sign_decode(HEVCContext *s);
  482. int ff_hevc_sao_eo_class_decode(HEVCContext *s);
  483. int ff_hevc_end_of_slice_flag_decode(HEVCContext *s);
  484. int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s);
  485. int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0,
  486. int x_cb, int y_cb);
  487. int ff_hevc_pred_mode_decode(HEVCContext *s);
  488. int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth,
  489. int x0, int y0);
  490. int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size);
  491. int ff_hevc_pcm_flag_decode(HEVCContext *s);
  492. int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s);
  493. int ff_hevc_mpm_idx_decode(HEVCContext *s);
  494. int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s);
  495. int ff_hevc_intra_chroma_pred_mode_decode(HEVCContext *s);
  496. int ff_hevc_merge_idx_decode(HEVCContext *s);
  497. int ff_hevc_merge_flag_decode(HEVCContext *s);
  498. int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH);
  499. int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx);
  500. int ff_hevc_mvp_lx_flag_decode(HEVCContext *s);
  501. int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s);
  502. int ff_hevc_abs_mvd_greater0_flag_decode(HEVCContext *s);
  503. int ff_hevc_abs_mvd_greater1_flag_decode(HEVCContext *s);
  504. int ff_hevc_mvd_decode(HEVCContext *s);
  505. int ff_hevc_mvd_sign_flag_decode(HEVCContext *s);
  506. int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size);
  507. int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth);
  508. int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth);
  509. int ff_hevc_transform_skip_flag_decode(HEVCContext *s, int c_idx);
  510. int ff_hevc_last_significant_coeff_x_prefix_decode(HEVCContext *s, int c_idx,
  511. int log2_size);
  512. int ff_hevc_last_significant_coeff_y_prefix_decode(HEVCContext *s, int c_idx,
  513. int log2_size);
  514. int ff_hevc_last_significant_coeff_suffix_decode(HEVCContext *s,
  515. int last_significant_coeff_prefix);
  516. int ff_hevc_significant_coeff_group_flag_decode(HEVCContext *s, int c_idx,
  517. int ctx_cg);
  518. int ff_hevc_significant_coeff_flag_decode(HEVCContext *s, int c_idx, int x_c,
  519. int y_c, int log2_trafo_size,
  520. int scan_idx, int prev_sig);
  521. int ff_hevc_coeff_abs_level_greater1_flag_decode(HEVCContext *s, int c_idx,
  522. int ctx_set);
  523. int ff_hevc_coeff_abs_level_greater2_flag_decode(HEVCContext *s, int c_idx,
  524. int inc);
  525. int ff_hevc_coeff_abs_level_remaining(HEVCContext *s, int base_level,
  526. int rc_rice_param);
  527. int ff_hevc_coeff_sign_flag(HEVCContext *s, uint8_t nb);
  528. /**
  529. * Get the number of candidate references for the current frame.
  530. */
  531. int ff_hevc_frame_nb_refs(HEVCContext *s);
  532. int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc);
  533. /**
  534. * Find next frame in output order and put a reference to it in frame.
  535. * @return 1 if a frame was output, 0 otherwise
  536. */
  537. int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush);
  538. void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags);
  539. void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
  540. int nPbW, int nPbH);
  541. void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0,
  542. int nPbW, int nPbH, int log2_cb_size,
  543. int part_idx, int merge_idx, MvField *mv);
  544. void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0,
  545. int nPbW, int nPbH, int log2_cb_size,
  546. int part_idx, int merge_idx,
  547. MvField *mv, int mvp_lx_flag, int LX);
  548. void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase,
  549. int log2_cb_size);
  550. void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
  551. int log2_trafo_size);
  552. int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s);
  553. int ff_hevc_cu_qp_delta_abs(HEVCContext *s);
  554. void ff_hevc_hls_filter(HEVCContext *s, int x, int y);
  555. void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size);
  556. void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth);
  557. extern const uint8_t ff_hevc_qpel_extra_before[4];
  558. extern const uint8_t ff_hevc_qpel_extra_after[4];
  559. extern const uint8_t ff_hevc_qpel_extra[4];
  560. #endif /* AVCODEC_HEVCDEC_H */