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.

659 lines
18KB

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