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