diff options
Diffstat (limited to 'libavcodec/hevc.h')
-rw-r--r-- | libavcodec/hevc.h | 128 |
1 files changed, 67 insertions, 61 deletions
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h index ebe978b329..9b4ed33a60 100644 --- a/libavcodec/hevc.h +++ b/libavcodec/hevc.h @@ -3,29 +3,26 @@ * * Copyright (C) 2012 - 2013 Guillaume Martres * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_HEVC_H #define AVCODEC_HEVC_H -#include <stddef.h> -#include <stdint.h> - #include "libavutil/buffer.h" #include "libavutil/md5.h" @@ -33,6 +30,7 @@ #include "cabac.h" #include "dsputil.h" #include "get_bits.h" +#include "hevcpred.h" #include "hevcdsp.h" #include "internal.h" #include "thread.h" @@ -41,6 +39,9 @@ #define MAX_DPB_SIZE 16 // A.4.1 #define MAX_REFS 16 +#define MAX_NB_THREADS 16 +#define SHIFT_CTB_WPP 2 + /** * 7.4.2.1 */ @@ -70,6 +71,9 @@ #define EPEL_EXTRA_BEFORE 1 #define EPEL_EXTRA_AFTER 2 #define EPEL_EXTRA 3 +#define QPEL_EXTRA_BEFORE 3 +#define QPEL_EXTRA_AFTER 4 +#define QPEL_EXTRA 7 #define EDGE_EMU_BUFFER_STRIDE 80 @@ -80,13 +84,10 @@ #define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)]) #define SAMPLE_CBF(tab, x, y) ((tab)[((y) & ((1<<log2_trafo_size)-1)) * MAX_CU_SIZE + ((x) & ((1<<log2_trafo_size)-1))]) -#define IS_IDR(s) (s->nal_unit_type == NAL_IDR_W_RADL || s->nal_unit_type == NAL_IDR_N_LP) -#define IS_BLA(s) (s->nal_unit_type == NAL_BLA_W_RADL || s->nal_unit_type == NAL_BLA_W_LP || \ - s->nal_unit_type == NAL_BLA_N_LP) -#define IS_IRAP(s) (s->nal_unit_type >= 16 && s->nal_unit_type <= 23) - -#define FFUDIV(a,b) (((a) > 0 ? (a) : (a) - (b) + 1) / (b)) -#define FFUMOD(a,b) ((a) - (b) * FFUDIV(a,b)) +#define IS_IDR(s) ((s)->nal_unit_type == NAL_IDR_W_RADL || (s)->nal_unit_type == NAL_IDR_N_LP) +#define IS_BLA(s) ((s)->nal_unit_type == NAL_BLA_W_RADL || (s)->nal_unit_type == NAL_BLA_W_LP || \ + (s)->nal_unit_type == NAL_BLA_N_LP) +#define IS_IRAP(s) ((s)->nal_unit_type >= 16 && (s)->nal_unit_type <= 23) /** * Table 7-3: NAL unit type codes @@ -203,6 +204,13 @@ enum InterPredIdc { PRED_BI, }; +enum PredFlag { + PF_INTRA = 0, + PF_L0, + PF_L1, + PF_BI, +}; + enum IntraPredMode { INTRA_PLANAR = 0, INTRA_DC, @@ -382,7 +390,7 @@ typedef struct ScalingList { } ScalingList; typedef struct HEVCSPS { - int vps_id; + unsigned vps_id; int chroma_format_idc; uint8_t separate_colour_plane_flag; @@ -575,6 +583,9 @@ typedef struct SliceHeader { unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand + int *entry_point_offset; + int * offset; + int * size; int num_entry_point_offsets; int8_t slice_qp; @@ -625,8 +636,7 @@ typedef struct Mv { typedef struct MvField { Mv mv[2]; int8_t ref_idx[2]; - int8_t pred_flag[2]; - uint8_t is_intra; + int8_t pred_flag; } MvField; typedef struct NeighbourAvailable { @@ -709,20 +719,6 @@ typedef struct HEVCNAL { const uint8_t *data; } HEVCNAL; -struct HEVCContext; - -typedef struct HEVCPredContext { - void (*intra_pred[4])(struct HEVCContext *s, int x0, int y0, int c_idx); - - void (*pred_planar[4])(uint8_t *src, const uint8_t *top, - const uint8_t *left, ptrdiff_t stride); - void (*pred_dc)(uint8_t *src, const uint8_t *top, const uint8_t *left, - ptrdiff_t stride, int log2_size, int c_idx); - void (*pred_angular[4])(uint8_t *src, const uint8_t *top, - const uint8_t *left, ptrdiff_t stride, - int c_idx, int mode); -} HEVCPredContext; - typedef struct HEVCLocalContext { DECLARE_ALIGNED(16, int16_t, mc_buffer[(MAX_PB_SIZE + 7) * MAX_PB_SIZE]); uint8_t cabac_state[HEVC_CONTEXTS]; @@ -736,17 +732,20 @@ typedef struct HEVCLocalContext { int8_t qp_y; int8_t curr_qp_y; + int qPy_pred; + TransformUnit tu; uint8_t ctb_left_flag; uint8_t ctb_up_flag; uint8_t ctb_up_right_flag; uint8_t ctb_up_left_flag; - int start_of_tiles_x; int end_of_tiles_x; int end_of_tiles_y; /* +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]; + DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer2)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2]; + CodingTree ct; CodingUnit cu; PredictionUnit pu; @@ -760,9 +759,18 @@ typedef struct HEVCContext { const AVClass *c; // needed by private avoptions AVCodecContext *avctx; - HEVCLocalContext HEVClc; + struct HEVCContext *sList[MAX_NB_THREADS]; - uint8_t cabac_state[HEVC_CONTEXTS]; + HEVCLocalContext *HEVClcList[MAX_NB_THREADS]; + HEVCLocalContext *HEVClc; + + uint8_t threads_type; + uint8_t threads_number; + + int width; + int height; + + uint8_t *cabac_state; /** 1 if the independent slice segment header was successfully parsed */ uint8_t slice_initialized; @@ -796,6 +804,7 @@ typedef struct HEVCContext { int pocTid0; int slice_idx; ///< number of the slice being currently decoded int eos; ///< current packet contains an EOS/EOB NAL + int last_eos; ///< last packet contains an EOS/EOB NAL int max_ra; int bs_width; int bs_height; @@ -836,6 +845,18 @@ typedef struct HEVCContext { uint16_t seq_decode; uint16_t seq_output; + int enable_parallel_tiles; + int wpp_err; + int skipped_bytes; + int *skipped_bytes_pos; + int skipped_bytes_pos_size; + + int *skipped_bytes_nal; + int **skipped_bytes_pos_nal; + int *skipped_bytes_pos_size_nal; + + const uint8_t *data; + HEVCNAL *nals; int nb_nals; int nals_allocated; @@ -852,6 +873,8 @@ typedef struct HEVCContext { ///< as a format defined in 14496-15 int apply_defdispwin; + int active_seq_parameter_set_id; + int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) int nuh_layer_id; @@ -860,6 +883,8 @@ typedef struct HEVCContext { int frame_packing_arrangement_type; int content_interpretation_type; int quincunx_subsampling; + + int picture_struct; } HEVCContext; int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, @@ -869,6 +894,9 @@ int ff_hevc_decode_nal_sps(HEVCContext *s); int ff_hevc_decode_nal_pps(HEVCContext *s); int ff_hevc_decode_nal_sei(HEVCContext *s); +int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length, + HEVCNAL *nal); + /** * Mark all frames in DPB as unused for reference. */ @@ -924,32 +952,10 @@ 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_abs_mvd_greater0_flag_decode(HEVCContext *s); -int ff_hevc_abs_mvd_greater1_flag_decode(HEVCContext *s); -int ff_hevc_mvd_decode(HEVCContext *s); -int ff_hevc_mvd_sign_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); int ff_hevc_transform_skip_flag_decode(HEVCContext *s, int c_idx); -int ff_hevc_last_significant_coeff_x_prefix_decode(HEVCContext *s, int c_idx, - int log2_size); -int ff_hevc_last_significant_coeff_y_prefix_decode(HEVCContext *s, int c_idx, - int log2_size); -int ff_hevc_last_significant_coeff_suffix_decode(HEVCContext *s, - int last_significant_coeff_prefix); -int ff_hevc_significant_coeff_group_flag_decode(HEVCContext *s, int c_idx, - int ctx_cg); -int ff_hevc_significant_coeff_flag_decode(HEVCContext *s, int c_idx, int x_c, - int y_c, int log2_trafo_size, - int scan_idx, int prev_sig); -int ff_hevc_coeff_abs_level_greater1_flag_decode(HEVCContext *s, int c_idx, - int ctx_set); -int ff_hevc_coeff_abs_level_greater2_flag_decode(HEVCContext *s, int c_idx, - int inc); -int ff_hevc_coeff_abs_level_remaining(HEVCContext *s, int base_level, - int rc_rice_param); -int ff_hevc_coeff_sign_flag(HEVCContext *s, uint8_t nb); /** * Get the number of candidate references for the current frame. @@ -978,17 +984,17 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size); void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, - int log2_trafo_size, - int slice_or_tiles_up_boundary, - int slice_or_tiles_left_boundary); + int log2_trafo_size); int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s); int ff_hevc_cu_qp_delta_abs(HEVCContext *s); void ff_hevc_hls_filter(HEVCContext *s, int x, int y); void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size); +void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, + int log2_trafo_size, enum ScanType scan_idx, + int c_idx); -void ff_hevc_pps_free(HEVCPPS **ppps); +void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size); -void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth); extern const uint8_t ff_hevc_qpel_extra_before[4]; extern const uint8_t ff_hevc_qpel_extra_after[4]; |