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.

725 lines
19KB

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