[FFmpeg-cvslog] Merge commit 'f6e2f8a9ffda2247bffba991450990d075ea68e3'
James Almer
git at videolan.org
Thu Mar 23 21:09:09 EET 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Mar 23 15:41:09 2017 -0300| [4a5810b6592db74b9c345ea74c4f08f5f490874c] | committer: James Almer
Merge commit 'f6e2f8a9ffda2247bffba991450990d075ea68e3'
* commit 'f6e2f8a9ffda2247bffba991450990d075ea68e3':
hevcdec: move parameter set parsing into a separate header
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4a5810b6592db74b9c345ea74c4f08f5f490874c
---
libavcodec/hevc.h | 5 +
libavcodec/hevc_ps.c | 14 +-
libavcodec/hevc_ps.h | 347 +++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/hevc_ps_enc.c | 2 +-
libavcodec/hevc_refs.c | 2 +-
libavcodec/hevcdec.c | 2 +-
libavcodec/hevcdec.h | 324 +------------------------------------------
7 files changed, 366 insertions(+), 330 deletions(-)
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index f71cd08..4237b80 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -62,4 +62,9 @@ enum HEVCNALUnitType {
#define HEVC_MAX_SHORT_TERM_RPS_COUNT 64
#define HEVC_MAX_CU_SIZE 128
+#define HEVC_MAX_REFS 16
+#define HEVC_MAX_DPB_SIZE 16 // A.4.1
+
+#define HEVC_MAX_LOG2_CTB_SIZE 6
+
#endif /* AVCODEC_HEVC_H */
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 53ff8b2..287b24e 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -25,8 +25,8 @@
#include "libavutil/imgutils.h"
#include "golomb.h"
-#include "hevcdec.h"
#include "hevc_data.h"
+#include "hevc_ps.h"
static const uint8_t default_scaling_list_intra[] = {
16, 16, 16, 16, 17, 18, 21, 24,
@@ -208,8 +208,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
rps->num_negative_pics = get_ue_golomb_long(gb);
nb_positive_pics = get_ue_golomb_long(gb);
- if (rps->num_negative_pics >= MAX_REFS ||
- nb_positive_pics >= MAX_REFS) {
+ if (rps->num_negative_pics >= HEVC_MAX_REFS ||
+ nb_positive_pics >= HEVC_MAX_REFS) {
av_log(avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n");
return AVERROR_INVALIDDATA;
}
@@ -458,7 +458,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
vps->vps_num_reorder_pics[i] = get_ue_golomb_long(gb);
vps->vps_max_latency_increase[i] = get_ue_golomb_long(gb) - 1;
- if (vps->vps_max_dec_pic_buffering[i] > MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) {
+ if (vps->vps_max_dec_pic_buffering[i] > HEVC_MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) {
av_log(avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n",
vps->vps_max_dec_pic_buffering[i] - 1);
goto err;
@@ -933,7 +933,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->temporal_layer[i].max_dec_pic_buffering = get_ue_golomb_long(gb) + 1;
sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb);
sps->temporal_layer[i].max_latency_increase = get_ue_golomb_long(gb) - 1;
- if (sps->temporal_layer[i].max_dec_pic_buffering > MAX_DPB_SIZE) {
+ if (sps->temporal_layer[i].max_dec_pic_buffering > HEVC_MAX_DPB_SIZE) {
av_log(avctx, AV_LOG_ERROR, "sps_max_dec_pic_buffering_minus1 out of range: %d\n",
sps->temporal_layer[i].max_dec_pic_buffering - 1);
return AVERROR_INVALIDDATA;
@@ -942,7 +942,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
av_log(avctx, AV_LOG_WARNING, "sps_max_num_reorder_pics out of range: %d\n",
sps->temporal_layer[i].num_reorder_pics);
if (avctx->err_recognition & AV_EF_EXPLODE ||
- sps->temporal_layer[i].num_reorder_pics > MAX_DPB_SIZE - 1) {
+ sps->temporal_layer[i].num_reorder_pics > HEVC_MAX_DPB_SIZE - 1) {
return AVERROR_INVALIDDATA;
}
sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[i].num_reorder_pics + 1;
@@ -1123,7 +1123,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->log2_diff_max_min_coding_block_size;
sps->log2_min_pu_size = sps->log2_min_cb_size - 1;
- if (sps->log2_ctb_size > MAX_LOG2_CTB_SIZE) {
+ if (sps->log2_ctb_size > HEVC_MAX_LOG2_CTB_SIZE) {
av_log(avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size);
return AVERROR_INVALIDDATA;
}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
new file mode 100644
index 0000000..b0a17bc
--- /dev/null
+++ b/libavcodec/hevc_ps.h
@@ -0,0 +1,347 @@
+/*
+ * HEVC parameter set parsing
+ *
+ * This file is part of FFmpeg.
+ *
+ * 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.
+ *
+ * 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_HEVC_PS_H
+#define AVCODEC_HEVC_PS_H
+
+#include <stdint.h>
+
+#include "libavutil/buffer.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/rational.h"
+
+#include "avcodec.h"
+#include "get_bits.h"
+#include "hevc.h"
+
+typedef struct ShortTermRPS {
+ unsigned int num_negative_pics;
+ int num_delta_pocs;
+ int rps_idx_num_delta_pocs;
+ int32_t delta_poc[32];
+ uint8_t used[32];
+} ShortTermRPS;
+
+typedef struct HEVCWindow {
+ unsigned int left_offset;
+ unsigned int right_offset;
+ unsigned int top_offset;
+ unsigned int bottom_offset;
+} HEVCWindow;
+
+typedef struct VUI {
+ AVRational sar;
+
+ int overscan_info_present_flag;
+ int overscan_appropriate_flag;
+
+ int video_signal_type_present_flag;
+ int video_format;
+ int video_full_range_flag;
+ int colour_description_present_flag;
+ uint8_t colour_primaries;
+ uint8_t transfer_characteristic;
+ uint8_t matrix_coeffs;
+
+ int chroma_loc_info_present_flag;
+ int chroma_sample_loc_type_top_field;
+ int chroma_sample_loc_type_bottom_field;
+ int neutra_chroma_indication_flag;
+
+ int field_seq_flag;
+ int frame_field_info_present_flag;
+
+ int default_display_window_flag;
+ HEVCWindow def_disp_win;
+
+ int vui_timing_info_present_flag;
+ uint32_t vui_num_units_in_tick;
+ uint32_t vui_time_scale;
+ int vui_poc_proportional_to_timing_flag;
+ int vui_num_ticks_poc_diff_one_minus1;
+ int vui_hrd_parameters_present_flag;
+
+ int bitstream_restriction_flag;
+ int tiles_fixed_structure_flag;
+ int motion_vectors_over_pic_boundaries_flag;
+ int restricted_ref_pic_lists_flag;
+ int min_spatial_segmentation_idc;
+ int max_bytes_per_pic_denom;
+ int max_bits_per_min_cu_denom;
+ int log2_max_mv_length_horizontal;
+ int log2_max_mv_length_vertical;
+} VUI;
+
+typedef struct PTLCommon {
+ uint8_t profile_space;
+ uint8_t tier_flag;
+ uint8_t profile_idc;
+ uint8_t profile_compatibility_flag[32];
+ uint8_t level_idc;
+ uint8_t progressive_source_flag;
+ uint8_t interlaced_source_flag;
+ uint8_t non_packed_constraint_flag;
+ uint8_t frame_only_constraint_flag;
+} PTLCommon;
+
+typedef struct PTL {
+ PTLCommon general_ptl;
+ PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS];
+
+ uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
+ uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
+} PTL;
+
+typedef struct HEVCVPS {
+ uint8_t vps_temporal_id_nesting_flag;
+ int vps_max_layers;
+ int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
+
+ PTL ptl;
+ int vps_sub_layer_ordering_info_present_flag;
+ unsigned int vps_max_dec_pic_buffering[HEVC_MAX_SUB_LAYERS];
+ unsigned int vps_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
+ unsigned int vps_max_latency_increase[HEVC_MAX_SUB_LAYERS];
+ int vps_max_layer_id;
+ int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1
+ uint8_t vps_timing_info_present_flag;
+ uint32_t vps_num_units_in_tick;
+ uint32_t vps_time_scale;
+ uint8_t vps_poc_proportional_to_timing_flag;
+ int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1
+ int vps_num_hrd_parameters;
+
+ uint8_t data[4096];
+ int data_size;
+} HEVCVPS;
+
+typedef struct ScalingList {
+ /* This is a little wasteful, since sizeID 0 only needs 8 coeffs,
+ * and size ID 3 only has 2 arrays, not 6. */
+ uint8_t sl[4][6][64];
+ uint8_t sl_dc[2][6];
+} ScalingList;
+
+typedef struct HEVCSPS {
+ unsigned vps_id;
+ int chroma_format_idc;
+ uint8_t separate_colour_plane_flag;
+
+ ///< output (i.e. cropped) values
+ int output_width, output_height;
+ HEVCWindow output_window;
+
+ HEVCWindow pic_conf_win;
+
+ int bit_depth;
+ int pixel_shift;
+ enum AVPixelFormat pix_fmt;
+
+ unsigned int log2_max_poc_lsb;
+ int pcm_enabled_flag;
+
+ int max_sub_layers;
+ struct {
+ int max_dec_pic_buffering;
+ int num_reorder_pics;
+ int max_latency_increase;
+ } temporal_layer[HEVC_MAX_SUB_LAYERS];
+
+ VUI vui;
+ PTL ptl;
+
+ uint8_t scaling_list_enable_flag;
+ ScalingList scaling_list;
+
+ unsigned int nb_st_rps;
+ ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_RPS_COUNT];
+
+ uint8_t amp_enabled_flag;
+ uint8_t sao_enabled;
+
+ uint8_t long_term_ref_pics_present_flag;
+ uint16_t lt_ref_pic_poc_lsb_sps[32];
+ uint8_t used_by_curr_pic_lt_sps_flag[32];
+ uint8_t num_long_term_ref_pics_sps;
+
+ struct {
+ uint8_t bit_depth;
+ uint8_t bit_depth_chroma;
+ unsigned int log2_min_pcm_cb_size;
+ unsigned int log2_max_pcm_cb_size;
+ uint8_t loop_filter_disable_flag;
+ } pcm;
+ uint8_t sps_temporal_mvp_enabled_flag;
+ uint8_t sps_strong_intra_smoothing_enable_flag;
+
+ unsigned int log2_min_cb_size;
+ unsigned int log2_diff_max_min_coding_block_size;
+ unsigned int log2_min_tb_size;
+ unsigned int log2_max_trafo_size;
+ unsigned int log2_ctb_size;
+ unsigned int log2_min_pu_size;
+
+ int max_transform_hierarchy_depth_inter;
+ int max_transform_hierarchy_depth_intra;
+
+ int transform_skip_rotation_enabled_flag;
+ int transform_skip_context_enabled_flag;
+ int implicit_rdpcm_enabled_flag;
+ int explicit_rdpcm_enabled_flag;
+ int intra_smoothing_disabled_flag;
+ int persistent_rice_adaptation_enabled_flag;
+
+ ///< coded frame dimension in various units
+ int width;
+ int height;
+ int ctb_width;
+ int ctb_height;
+ int ctb_size;
+ int min_cb_width;
+ int min_cb_height;
+ int min_tb_width;
+ int min_tb_height;
+ int min_pu_width;
+ int min_pu_height;
+ int tb_mask;
+
+ int hshift[3];
+ int vshift[3];
+
+ int qp_bd_offset;
+
+ uint8_t data[4096];
+ int data_size;
+} HEVCSPS;
+
+typedef struct HEVCPPS {
+ unsigned int sps_id; ///< seq_parameter_set_id
+
+ uint8_t sign_data_hiding_flag;
+
+ uint8_t cabac_init_present_flag;
+
+ int num_ref_idx_l0_default_active; ///< num_ref_idx_l0_default_active_minus1 + 1
+ int num_ref_idx_l1_default_active; ///< num_ref_idx_l1_default_active_minus1 + 1
+ int pic_init_qp_minus26;
+
+ uint8_t constrained_intra_pred_flag;
+ uint8_t transform_skip_enabled_flag;
+
+ uint8_t cu_qp_delta_enabled_flag;
+ int diff_cu_qp_delta_depth;
+
+ int cb_qp_offset;
+ int cr_qp_offset;
+ uint8_t pic_slice_level_chroma_qp_offsets_present_flag;
+ uint8_t weighted_pred_flag;
+ uint8_t weighted_bipred_flag;
+ uint8_t output_flag_present_flag;
+ uint8_t transquant_bypass_enable_flag;
+
+ uint8_t dependent_slice_segments_enabled_flag;
+ uint8_t tiles_enabled_flag;
+ uint8_t entropy_coding_sync_enabled_flag;
+
+ int num_tile_columns; ///< num_tile_columns_minus1 + 1
+ int num_tile_rows; ///< num_tile_rows_minus1 + 1
+ uint8_t uniform_spacing_flag;
+ uint8_t loop_filter_across_tiles_enabled_flag;
+
+ uint8_t seq_loop_filter_across_slices_enabled_flag;
+
+ uint8_t deblocking_filter_control_present_flag;
+ uint8_t deblocking_filter_override_enabled_flag;
+ uint8_t disable_dbf;
+ int beta_offset; ///< beta_offset_div2 * 2
+ int tc_offset; ///< tc_offset_div2 * 2
+
+ uint8_t scaling_list_data_present_flag;
+ ScalingList scaling_list;
+
+ uint8_t lists_modification_present_flag;
+ int log2_parallel_merge_level; ///< log2_parallel_merge_level_minus2 + 2
+ int num_extra_slice_header_bits;
+ uint8_t slice_header_extension_present_flag;
+ uint8_t log2_max_transform_skip_block_size;
+ uint8_t cross_component_prediction_enabled_flag;
+ uint8_t chroma_qp_offset_list_enabled_flag;
+ uint8_t diff_cu_chroma_qp_offset_depth;
+ uint8_t chroma_qp_offset_list_len_minus1;
+ int8_t cb_qp_offset_list[5];
+ int8_t cr_qp_offset_list[5];
+ uint8_t log2_sao_offset_scale_luma;
+ uint8_t log2_sao_offset_scale_chroma;
+
+ // Inferred parameters
+ unsigned int *column_width; ///< ColumnWidth
+ unsigned int *row_height; ///< RowHeight
+ unsigned int *col_bd; ///< ColBd
+ unsigned int *row_bd; ///< RowBd
+ int *col_idxX;
+
+ int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
+ int *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS
+ int *tile_id; ///< TileId
+ int *tile_pos_rs; ///< TilePosRS
+ int *min_tb_addr_zs; ///< MinTbAddrZS
+ int *min_tb_addr_zs_tab;///< MinTbAddrZS
+
+ uint8_t data[4096];
+ int data_size;
+} HEVCPPS;
+
+typedef struct HEVCParamSets {
+ AVBufferRef *vps_list[HEVC_MAX_VPS_COUNT];
+ AVBufferRef *sps_list[HEVC_MAX_SPS_COUNT];
+ AVBufferRef *pps_list[HEVC_MAX_PPS_COUNT];
+
+ /* currently active parameter sets */
+ const HEVCVPS *vps;
+ const HEVCSPS *sps;
+ const HEVCPPS *pps;
+} HEVCParamSets;
+
+/**
+ * Parse the SPS from the bitstream into the provided HEVCSPS struct.
+ *
+ * @param sps_id the SPS id will be written here
+ * @param apply_defdispwin if set 1, the default display window from the VUI
+ * will be applied to the video dimensions
+ * @param vps_list if non-NULL, this function will validate that the SPS refers
+ * to an existing VPS
+ */
+int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
+ int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
+
+int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps);
+int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps, int apply_defdispwin);
+int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps);
+
+int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
+ ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);
+
+int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
+ uint8_t *buf, int buf_size);
+
+#endif /* AVCODEC_HEVC_PS_H */
diff --git a/libavcodec/hevc_ps_enc.c b/libavcodec/hevc_ps_enc.c
index edff3e7..ea06ec7 100644
--- a/libavcodec/hevc_ps_enc.c
+++ b/libavcodec/hevc_ps_enc.c
@@ -19,7 +19,7 @@
*/
#include "golomb.h"
-#include "hevcdec.h"
+#include "hevc_ps.h"
#include "put_bits.h"
static void write_ptl_layer(PutBitContext *pb, PTLCommon *ptl)
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index db1ac2b..935e388 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -329,7 +329,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
while (rpl_tmp.nb_refs < sh->nb_refs[list_idx]) {
for (i = 0; i < FF_ARRAY_ELEMS(cand_lists); i++) {
RefPicList *rps = &s->rps[cand_lists[i]];
- for (j = 0; j < rps->nb_refs && rpl_tmp.nb_refs < MAX_REFS; j++) {
+ for (j = 0; j < rps->nb_refs && rpl_tmp.nb_refs < HEVC_MAX_REFS; j++) {
rpl_tmp.list[rpl_tmp.nb_refs] = rps->list[j];
rpl_tmp.ref[rpl_tmp.nb_refs] = rps->ref[j];
rpl_tmp.isLongTerm[rpl_tmp.nb_refs] = i == 2;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 257eebc..92897f4 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -620,7 +620,7 @@ static int hls_slice_header(HEVCContext *s)
if (sh->slice_type == B_SLICE)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
- if (sh->nb_refs[L0] > MAX_REFS || sh->nb_refs[L1] > MAX_REFS) {
+ if (sh->nb_refs[L0] > HEVC_MAX_REFS || sh->nb_refs[L1] > HEVC_MAX_REFS) {
av_log(s->avctx, AV_LOG_ERROR, "Too many refs: %d/%d.\n",
sh->nb_refs[L0], sh->nb_refs[L1]);
return AVERROR_INVALIDDATA;
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index bad4fb2..b6391ea 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -35,14 +35,12 @@
#include "hevcpred.h"
#include "h2645_parse.h"
#include "hevc.h"
+#include "hevc_ps.h"
#include "hevcdsp.h"
#include "internal.h"
#include "thread.h"
#include "videodsp.h"
-#define MAX_DPB_SIZE 16 // A.4.1
-#define MAX_REFS 16
-
#define MAX_NB_THREADS 16
#define SHIFT_CTB_WPP 2
@@ -50,7 +48,6 @@
#define MAX_TRANSFORM_DEPTH 5
#define MAX_TB_SIZE 32
-#define MAX_LOG2_CTB_SIZE 6
#define MAX_QP 51
#define DEFAULT_INTRA_TC_OFFSET 2
@@ -236,14 +233,6 @@ enum ScanType {
SCAN_VERT,
};
-typedef struct ShortTermRPS {
- unsigned int num_negative_pics;
- int num_delta_pocs;
- int rps_idx_num_delta_pocs;
- int32_t delta_poc[32];
- uint8_t used[32];
-} ShortTermRPS;
-
typedef struct LongTermRPS {
int poc[32];
uint8_t used[32];
@@ -251,9 +240,9 @@ typedef struct LongTermRPS {
} LongTermRPS;
typedef struct RefPicList {
- struct HEVCFrame *ref[MAX_REFS];
- int list[MAX_REFS];
- int isLongTerm[MAX_REFS];
+ struct HEVCFrame *ref[HEVC_MAX_REFS];
+ int list[HEVC_MAX_REFS];
+ int isLongTerm[HEVC_MAX_REFS];
int nb_refs;
} RefPicList;
@@ -261,286 +250,6 @@ typedef struct RefPicListTab {
RefPicList refPicList[2];
} RefPicListTab;
-typedef struct HEVCWindow {
- unsigned int left_offset;
- unsigned int right_offset;
- unsigned int top_offset;
- unsigned int bottom_offset;
-} HEVCWindow;
-
-typedef struct VUI {
- AVRational sar;
-
- int overscan_info_present_flag;
- int overscan_appropriate_flag;
-
- int video_signal_type_present_flag;
- int video_format;
- int video_full_range_flag;
- int colour_description_present_flag;
- uint8_t colour_primaries;
- uint8_t transfer_characteristic;
- uint8_t matrix_coeffs;
-
- int chroma_loc_info_present_flag;
- int chroma_sample_loc_type_top_field;
- int chroma_sample_loc_type_bottom_field;
- int neutra_chroma_indication_flag;
-
- int field_seq_flag;
- int frame_field_info_present_flag;
-
- int default_display_window_flag;
- HEVCWindow def_disp_win;
-
- int vui_timing_info_present_flag;
- uint32_t vui_num_units_in_tick;
- uint32_t vui_time_scale;
- int vui_poc_proportional_to_timing_flag;
- int vui_num_ticks_poc_diff_one_minus1;
- int vui_hrd_parameters_present_flag;
-
- int bitstream_restriction_flag;
- int tiles_fixed_structure_flag;
- int motion_vectors_over_pic_boundaries_flag;
- int restricted_ref_pic_lists_flag;
- int min_spatial_segmentation_idc;
- int max_bytes_per_pic_denom;
- int max_bits_per_min_cu_denom;
- int log2_max_mv_length_horizontal;
- int log2_max_mv_length_vertical;
-} VUI;
-
-typedef struct PTLCommon {
- uint8_t profile_space;
- uint8_t tier_flag;
- uint8_t profile_idc;
- uint8_t profile_compatibility_flag[32];
- uint8_t level_idc;
- uint8_t progressive_source_flag;
- uint8_t interlaced_source_flag;
- uint8_t non_packed_constraint_flag;
- uint8_t frame_only_constraint_flag;
-} PTLCommon;
-
-typedef struct PTL {
- PTLCommon general_ptl;
- PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS];
-
- uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
- uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
-} PTL;
-
-typedef struct HEVCVPS {
- uint8_t vps_temporal_id_nesting_flag;
- int vps_max_layers;
- int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
-
- PTL ptl;
- int vps_sub_layer_ordering_info_present_flag;
- unsigned int vps_max_dec_pic_buffering[HEVC_MAX_SUB_LAYERS];
- unsigned int vps_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
- unsigned int vps_max_latency_increase[HEVC_MAX_SUB_LAYERS];
- int vps_max_layer_id;
- int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1
- uint8_t vps_timing_info_present_flag;
- uint32_t vps_num_units_in_tick;
- uint32_t vps_time_scale;
- uint8_t vps_poc_proportional_to_timing_flag;
- int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1
- int vps_num_hrd_parameters;
-
- uint8_t data[4096];
- int data_size;
-} HEVCVPS;
-
-typedef struct ScalingList {
- /* This is a little wasteful, since sizeID 0 only needs 8 coeffs,
- * and size ID 3 only has 2 arrays, not 6. */
- uint8_t sl[4][6][64];
- uint8_t sl_dc[2][6];
-} ScalingList;
-
-typedef struct HEVCSPS {
- unsigned vps_id;
- int chroma_format_idc;
- uint8_t separate_colour_plane_flag;
-
- ///< output (i.e. cropped) values
- int output_width, output_height;
- HEVCWindow output_window;
-
- HEVCWindow pic_conf_win;
-
- int bit_depth;
- int pixel_shift;
- enum AVPixelFormat pix_fmt;
-
- unsigned int log2_max_poc_lsb;
- int pcm_enabled_flag;
-
- int max_sub_layers;
- struct {
- int max_dec_pic_buffering;
- int num_reorder_pics;
- int max_latency_increase;
- } temporal_layer[HEVC_MAX_SUB_LAYERS];
-
- VUI vui;
- PTL ptl;
-
- uint8_t scaling_list_enable_flag;
- ScalingList scaling_list;
-
- unsigned int nb_st_rps;
- ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_RPS_COUNT];
-
- uint8_t amp_enabled_flag;
- uint8_t sao_enabled;
-
- uint8_t long_term_ref_pics_present_flag;
- uint16_t lt_ref_pic_poc_lsb_sps[32];
- uint8_t used_by_curr_pic_lt_sps_flag[32];
- uint8_t num_long_term_ref_pics_sps;
-
- struct {
- uint8_t bit_depth;
- uint8_t bit_depth_chroma;
- unsigned int log2_min_pcm_cb_size;
- unsigned int log2_max_pcm_cb_size;
- uint8_t loop_filter_disable_flag;
- } pcm;
- uint8_t sps_temporal_mvp_enabled_flag;
- uint8_t sps_strong_intra_smoothing_enable_flag;
-
- unsigned int log2_min_cb_size;
- unsigned int log2_diff_max_min_coding_block_size;
- unsigned int log2_min_tb_size;
- unsigned int log2_max_trafo_size;
- unsigned int log2_ctb_size;
- unsigned int log2_min_pu_size;
-
- int max_transform_hierarchy_depth_inter;
- int max_transform_hierarchy_depth_intra;
-
- int transform_skip_rotation_enabled_flag;
- int transform_skip_context_enabled_flag;
- int implicit_rdpcm_enabled_flag;
- int explicit_rdpcm_enabled_flag;
- int intra_smoothing_disabled_flag;
- int persistent_rice_adaptation_enabled_flag;
-
- ///< coded frame dimension in various units
- int width;
- int height;
- int ctb_width;
- int ctb_height;
- int ctb_size;
- int min_cb_width;
- int min_cb_height;
- int min_tb_width;
- int min_tb_height;
- int min_pu_width;
- int min_pu_height;
- int tb_mask;
-
- int hshift[3];
- int vshift[3];
-
- int qp_bd_offset;
-
- uint8_t data[4096];
- int data_size;
-} HEVCSPS;
-
-typedef struct HEVCPPS {
- unsigned int sps_id; ///< seq_parameter_set_id
-
- uint8_t sign_data_hiding_flag;
-
- uint8_t cabac_init_present_flag;
-
- int num_ref_idx_l0_default_active; ///< num_ref_idx_l0_default_active_minus1 + 1
- int num_ref_idx_l1_default_active; ///< num_ref_idx_l1_default_active_minus1 + 1
- int pic_init_qp_minus26;
-
- uint8_t constrained_intra_pred_flag;
- uint8_t transform_skip_enabled_flag;
-
- uint8_t cu_qp_delta_enabled_flag;
- int diff_cu_qp_delta_depth;
-
- int cb_qp_offset;
- int cr_qp_offset;
- uint8_t pic_slice_level_chroma_qp_offsets_present_flag;
- uint8_t weighted_pred_flag;
- uint8_t weighted_bipred_flag;
- uint8_t output_flag_present_flag;
- uint8_t transquant_bypass_enable_flag;
-
- uint8_t dependent_slice_segments_enabled_flag;
- uint8_t tiles_enabled_flag;
- uint8_t entropy_coding_sync_enabled_flag;
-
- int num_tile_columns; ///< num_tile_columns_minus1 + 1
- int num_tile_rows; ///< num_tile_rows_minus1 + 1
- uint8_t uniform_spacing_flag;
- uint8_t loop_filter_across_tiles_enabled_flag;
-
- uint8_t seq_loop_filter_across_slices_enabled_flag;
-
- uint8_t deblocking_filter_control_present_flag;
- uint8_t deblocking_filter_override_enabled_flag;
- uint8_t disable_dbf;
- int beta_offset; ///< beta_offset_div2 * 2
- int tc_offset; ///< tc_offset_div2 * 2
-
- uint8_t scaling_list_data_present_flag;
- ScalingList scaling_list;
-
- uint8_t lists_modification_present_flag;
- int log2_parallel_merge_level; ///< log2_parallel_merge_level_minus2 + 2
- int num_extra_slice_header_bits;
- uint8_t slice_header_extension_present_flag;
- uint8_t log2_max_transform_skip_block_size;
- uint8_t cross_component_prediction_enabled_flag;
- uint8_t chroma_qp_offset_list_enabled_flag;
- uint8_t diff_cu_chroma_qp_offset_depth;
- uint8_t chroma_qp_offset_list_len_minus1;
- int8_t cb_qp_offset_list[5];
- int8_t cr_qp_offset_list[5];
- uint8_t log2_sao_offset_scale_luma;
- uint8_t log2_sao_offset_scale_chroma;
-
- // Inferred parameters
- unsigned int *column_width; ///< ColumnWidth
- unsigned int *row_height; ///< RowHeight
- unsigned int *col_bd; ///< ColBd
- unsigned int *row_bd; ///< RowBd
- int *col_idxX;
-
- int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
- int *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS
- int *tile_id; ///< TileId
- int *tile_pos_rs; ///< TilePosRS
- int *min_tb_addr_zs; ///< MinTbAddrZS
- int *min_tb_addr_zs_tab;///< MinTbAddrZS
-
- uint8_t data[4096];
- int data_size;
-} HEVCPPS;
-
-typedef struct HEVCParamSets {
- AVBufferRef *vps_list[HEVC_MAX_VPS_COUNT];
- AVBufferRef *sps_list[HEVC_MAX_SPS_COUNT];
- AVBufferRef *pps_list[HEVC_MAX_PPS_COUNT];
-
- /* currently active parameter sets */
- const HEVCVPS *vps;
- const HEVCSPS *sps;
- const HEVCPPS *pps;
-} HEVCParamSets;
-
typedef struct SliceHeader {
unsigned int pps_id;
@@ -895,27 +604,6 @@ typedef struct HEVCContext {
} HEVCContext;
-int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
- ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);
-
-/**
- * Parse the SPS from the bitstream into the provided HEVCSPS struct.
- *
- * @param sps_id the SPS id will be written here
- * @param apply_defdispwin if set 1, the default display window from the VUI
- * will be applied to the video dimensions
- * @param vps_list if non-NULL, this function will validate that the SPS refers
- * to an existing VPS
- */
-int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
- int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
-
-int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
- HEVCParamSets *ps);
-int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
- HEVCParamSets *ps, int apply_defdispwin);
-int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
- HEVCParamSets *ps);
int ff_hevc_decode_nal_sei(HEVCContext *s);
/**
@@ -1021,10 +709,6 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size);
-
-int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
- uint8_t *buf, int buf_size);
-
/**
* Reset SEI values that are stored on the Context.
* e.g. Caption data that was extracted during NAL
======================================================================
diff --cc libavcodec/hevc_ps.c
index 53ff8b2,6a8cfeb..287b24e
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@@ -24,9 -24,10 +24,9 @@@
*/
#include "libavutil/imgutils.h"
-
#include "golomb.h"
- #include "hevcdec.h"
#include "hevc_data.h"
+ #include "hevc_ps.h"
static const uint8_t default_scaling_list_intra[] = {
16, 16, 16, 16, 17, 18, 21, 24,
@@@ -458,7 -406,7 +458,7 @@@ int ff_hevc_decode_nal_vps(GetBitContex
vps->vps_num_reorder_pics[i] = get_ue_golomb_long(gb);
vps->vps_max_latency_increase[i] = get_ue_golomb_long(gb) - 1;
- if (vps->vps_max_dec_pic_buffering[i] > MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) {
- if (vps->vps_max_dec_pic_buffering[i] > HEVC_MAX_DPB_SIZE) {
++ if (vps->vps_max_dec_pic_buffering[i] > HEVC_MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) {
av_log(avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n",
vps->vps_max_dec_pic_buffering[i] - 1);
goto err;
@@@ -933,17 -794,19 +933,17 @@@ int ff_hevc_parse_sps(HEVCSPS *sps, Get
sps->temporal_layer[i].max_dec_pic_buffering = get_ue_golomb_long(gb) + 1;
sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb);
sps->temporal_layer[i].max_latency_increase = get_ue_golomb_long(gb) - 1;
- if (sps->temporal_layer[i].max_dec_pic_buffering > MAX_DPB_SIZE) {
+ if (sps->temporal_layer[i].max_dec_pic_buffering > HEVC_MAX_DPB_SIZE) {
av_log(avctx, AV_LOG_ERROR, "sps_max_dec_pic_buffering_minus1 out of range: %d\n",
sps->temporal_layer[i].max_dec_pic_buffering - 1);
- ret = AVERROR_INVALIDDATA;
- goto err;
+ return AVERROR_INVALIDDATA;
}
if (sps->temporal_layer[i].num_reorder_pics > sps->temporal_layer[i].max_dec_pic_buffering - 1) {
av_log(avctx, AV_LOG_WARNING, "sps_max_num_reorder_pics out of range: %d\n",
sps->temporal_layer[i].num_reorder_pics);
if (avctx->err_recognition & AV_EF_EXPLODE ||
- sps->temporal_layer[i].num_reorder_pics > MAX_DPB_SIZE - 1) {
+ sps->temporal_layer[i].num_reorder_pics > HEVC_MAX_DPB_SIZE - 1) {
- ret = AVERROR_INVALIDDATA;
- goto err;
+ return AVERROR_INVALIDDATA;
}
sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[i].num_reorder_pics + 1;
}
@@@ -1123,19 -936,6 +1123,19 @@@
sps->log2_diff_max_min_coding_block_size;
sps->log2_min_pu_size = sps->log2_min_cb_size - 1;
- if (sps->log2_ctb_size > MAX_LOG2_CTB_SIZE) {
++ if (sps->log2_ctb_size > HEVC_MAX_LOG2_CTB_SIZE) {
+ av_log(avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size);
+ return AVERROR_INVALIDDATA;
+ }
+ if (sps->log2_ctb_size < 4) {
+ av_log(avctx,
+ AV_LOG_ERROR,
+ "log2_ctb_size %d differs from the bounds of any known profile\n",
+ sps->log2_ctb_size);
+ avpriv_request_sample(avctx, "log2_ctb_size %d", sps->log2_ctb_size);
+ return AVERROR_INVALIDDATA;
+ }
+
sps->ctb_width = (sps->width + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size;
sps->ctb_height = (sps->height + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size;
sps->ctb_size = sps->ctb_width * sps->ctb_height;
diff --cc libavcodec/hevc_ps.h
index 0000000,d95aa51..b0a17bc
mode 000000,100644..100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@@ -1,0 -1,320 +1,347 @@@
+ /*
+ * HEVC parameter set parsing
+ *
- * 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_PS_H
+ #define AVCODEC_HEVC_PS_H
+
+ #include <stdint.h>
+
+ #include "libavutil/buffer.h"
+ #include "libavutil/pixfmt.h"
+ #include "libavutil/rational.h"
+
+ #include "avcodec.h"
+ #include "get_bits.h"
+ #include "hevc.h"
+
+ typedef struct ShortTermRPS {
+ unsigned int num_negative_pics;
+ int num_delta_pocs;
+ int rps_idx_num_delta_pocs;
+ int32_t delta_poc[32];
+ uint8_t used[32];
+ } ShortTermRPS;
+
+ typedef struct HEVCWindow {
+ unsigned int left_offset;
+ unsigned int right_offset;
+ unsigned int top_offset;
+ unsigned int bottom_offset;
+ } HEVCWindow;
+
+ typedef struct VUI {
+ AVRational sar;
+
+ int overscan_info_present_flag;
+ int overscan_appropriate_flag;
+
+ int video_signal_type_present_flag;
+ int video_format;
+ int video_full_range_flag;
+ int colour_description_present_flag;
+ uint8_t colour_primaries;
+ uint8_t transfer_characteristic;
+ uint8_t matrix_coeffs;
+
+ int chroma_loc_info_present_flag;
+ int chroma_sample_loc_type_top_field;
+ int chroma_sample_loc_type_bottom_field;
+ int neutra_chroma_indication_flag;
+
+ int field_seq_flag;
+ int frame_field_info_present_flag;
+
+ int default_display_window_flag;
+ HEVCWindow def_disp_win;
+
+ int vui_timing_info_present_flag;
+ uint32_t vui_num_units_in_tick;
+ uint32_t vui_time_scale;
+ int vui_poc_proportional_to_timing_flag;
+ int vui_num_ticks_poc_diff_one_minus1;
+ int vui_hrd_parameters_present_flag;
+
+ int bitstream_restriction_flag;
+ int tiles_fixed_structure_flag;
+ int motion_vectors_over_pic_boundaries_flag;
+ int restricted_ref_pic_lists_flag;
+ int min_spatial_segmentation_idc;
+ int max_bytes_per_pic_denom;
+ int max_bits_per_min_cu_denom;
+ int log2_max_mv_length_horizontal;
+ int log2_max_mv_length_vertical;
+ } VUI;
+
+ typedef struct PTLCommon {
+ uint8_t profile_space;
+ uint8_t tier_flag;
+ uint8_t profile_idc;
+ uint8_t profile_compatibility_flag[32];
+ uint8_t level_idc;
+ uint8_t progressive_source_flag;
+ uint8_t interlaced_source_flag;
+ uint8_t non_packed_constraint_flag;
+ uint8_t frame_only_constraint_flag;
+ } PTLCommon;
+
+ typedef struct PTL {
+ PTLCommon general_ptl;
+ PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS];
+
+ uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
+ uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
+ } PTL;
+
+ typedef struct HEVCVPS {
+ uint8_t vps_temporal_id_nesting_flag;
+ int vps_max_layers;
+ int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
+
+ PTL ptl;
+ int vps_sub_layer_ordering_info_present_flag;
+ unsigned int vps_max_dec_pic_buffering[HEVC_MAX_SUB_LAYERS];
+ unsigned int vps_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
+ unsigned int vps_max_latency_increase[HEVC_MAX_SUB_LAYERS];
+ int vps_max_layer_id;
+ int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1
+ uint8_t vps_timing_info_present_flag;
+ uint32_t vps_num_units_in_tick;
+ uint32_t vps_time_scale;
+ uint8_t vps_poc_proportional_to_timing_flag;
+ int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1
+ int vps_num_hrd_parameters;
++
++ uint8_t data[4096];
++ int data_size;
+ } HEVCVPS;
+
+ typedef struct ScalingList {
+ /* This is a little wasteful, since sizeID 0 only needs 8 coeffs,
+ * and size ID 3 only has 2 arrays, not 6. */
+ uint8_t sl[4][6][64];
+ uint8_t sl_dc[2][6];
+ } ScalingList;
+
+ typedef struct HEVCSPS {
- int vps_id;
++ unsigned vps_id;
+ int chroma_format_idc;
+ uint8_t separate_colour_plane_flag;
+
+ ///< output (i.e. cropped) values
+ int output_width, output_height;
+ HEVCWindow output_window;
+
+ HEVCWindow pic_conf_win;
+
+ int bit_depth;
+ int pixel_shift;
+ enum AVPixelFormat pix_fmt;
+
+ unsigned int log2_max_poc_lsb;
+ int pcm_enabled_flag;
+
+ int max_sub_layers;
+ struct {
+ int max_dec_pic_buffering;
+ int num_reorder_pics;
+ int max_latency_increase;
+ } temporal_layer[HEVC_MAX_SUB_LAYERS];
+
+ VUI vui;
+ PTL ptl;
+
+ uint8_t scaling_list_enable_flag;
+ ScalingList scaling_list;
+
+ unsigned int nb_st_rps;
+ ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_RPS_COUNT];
+
+ uint8_t amp_enabled_flag;
+ uint8_t sao_enabled;
+
+ uint8_t long_term_ref_pics_present_flag;
+ uint16_t lt_ref_pic_poc_lsb_sps[32];
+ uint8_t used_by_curr_pic_lt_sps_flag[32];
+ uint8_t num_long_term_ref_pics_sps;
+
+ struct {
+ uint8_t bit_depth;
+ uint8_t bit_depth_chroma;
+ unsigned int log2_min_pcm_cb_size;
+ unsigned int log2_max_pcm_cb_size;
+ uint8_t loop_filter_disable_flag;
+ } pcm;
+ uint8_t sps_temporal_mvp_enabled_flag;
+ uint8_t sps_strong_intra_smoothing_enable_flag;
+
+ unsigned int log2_min_cb_size;
+ unsigned int log2_diff_max_min_coding_block_size;
+ unsigned int log2_min_tb_size;
+ unsigned int log2_max_trafo_size;
+ unsigned int log2_ctb_size;
+ unsigned int log2_min_pu_size;
+
+ int max_transform_hierarchy_depth_inter;
+ int max_transform_hierarchy_depth_intra;
+
++ int transform_skip_rotation_enabled_flag;
++ int transform_skip_context_enabled_flag;
++ int implicit_rdpcm_enabled_flag;
++ int explicit_rdpcm_enabled_flag;
++ int intra_smoothing_disabled_flag;
++ int persistent_rice_adaptation_enabled_flag;
++
+ ///< coded frame dimension in various units
+ int width;
+ int height;
+ int ctb_width;
+ int ctb_height;
+ int ctb_size;
+ int min_cb_width;
+ int min_cb_height;
+ int min_tb_width;
+ int min_tb_height;
+ int min_pu_width;
+ int min_pu_height;
++ int tb_mask;
+
+ int hshift[3];
+ int vshift[3];
+
+ int qp_bd_offset;
++
++ uint8_t data[4096];
++ int data_size;
+ } HEVCSPS;
+
+ typedef struct HEVCPPS {
+ unsigned int sps_id; ///< seq_parameter_set_id
+
+ uint8_t sign_data_hiding_flag;
+
+ uint8_t cabac_init_present_flag;
+
+ int num_ref_idx_l0_default_active; ///< num_ref_idx_l0_default_active_minus1 + 1
+ int num_ref_idx_l1_default_active; ///< num_ref_idx_l1_default_active_minus1 + 1
+ int pic_init_qp_minus26;
+
+ uint8_t constrained_intra_pred_flag;
+ uint8_t transform_skip_enabled_flag;
+
+ uint8_t cu_qp_delta_enabled_flag;
+ int diff_cu_qp_delta_depth;
+
+ int cb_qp_offset;
+ int cr_qp_offset;
+ uint8_t pic_slice_level_chroma_qp_offsets_present_flag;
+ uint8_t weighted_pred_flag;
+ uint8_t weighted_bipred_flag;
+ uint8_t output_flag_present_flag;
+ uint8_t transquant_bypass_enable_flag;
+
+ uint8_t dependent_slice_segments_enabled_flag;
+ uint8_t tiles_enabled_flag;
+ uint8_t entropy_coding_sync_enabled_flag;
+
+ int num_tile_columns; ///< num_tile_columns_minus1 + 1
+ int num_tile_rows; ///< num_tile_rows_minus1 + 1
+ uint8_t uniform_spacing_flag;
+ uint8_t loop_filter_across_tiles_enabled_flag;
+
+ uint8_t seq_loop_filter_across_slices_enabled_flag;
+
+ uint8_t deblocking_filter_control_present_flag;
+ uint8_t deblocking_filter_override_enabled_flag;
+ uint8_t disable_dbf;
+ int beta_offset; ///< beta_offset_div2 * 2
+ int tc_offset; ///< tc_offset_div2 * 2
+
+ uint8_t scaling_list_data_present_flag;
+ ScalingList scaling_list;
+
+ uint8_t lists_modification_present_flag;
+ int log2_parallel_merge_level; ///< log2_parallel_merge_level_minus2 + 2
+ int num_extra_slice_header_bits;
+ uint8_t slice_header_extension_present_flag;
++ uint8_t log2_max_transform_skip_block_size;
++ uint8_t cross_component_prediction_enabled_flag;
++ uint8_t chroma_qp_offset_list_enabled_flag;
++ uint8_t diff_cu_chroma_qp_offset_depth;
++ uint8_t chroma_qp_offset_list_len_minus1;
++ int8_t cb_qp_offset_list[5];
++ int8_t cr_qp_offset_list[5];
++ uint8_t log2_sao_offset_scale_luma;
++ uint8_t log2_sao_offset_scale_chroma;
+
+ // Inferred parameters
+ unsigned int *column_width; ///< ColumnWidth
+ unsigned int *row_height; ///< RowHeight
+ unsigned int *col_bd; ///< ColBd
+ unsigned int *row_bd; ///< RowBd
+ int *col_idxX;
+
+ int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
+ int *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS
+ int *tile_id; ///< TileId
+ int *tile_pos_rs; ///< TilePosRS
+ int *min_tb_addr_zs; ///< MinTbAddrZS
++ int *min_tb_addr_zs_tab;///< MinTbAddrZS
++
++ uint8_t data[4096];
++ int data_size;
+ } HEVCPPS;
+
+ typedef struct HEVCParamSets {
+ AVBufferRef *vps_list[HEVC_MAX_VPS_COUNT];
+ AVBufferRef *sps_list[HEVC_MAX_SPS_COUNT];
+ AVBufferRef *pps_list[HEVC_MAX_PPS_COUNT];
+
+ /* currently active parameter sets */
+ const HEVCVPS *vps;
+ const HEVCSPS *sps;
+ const HEVCPPS *pps;
+ } HEVCParamSets;
+
+ /**
+ * Parse the SPS from the bitstream into the provided HEVCSPS struct.
+ *
+ * @param sps_id the SPS id will be written here
+ * @param apply_defdispwin if set 1, the default display window from the VUI
+ * will be applied to the video dimensions
+ * @param vps_list if non-NULL, this function will validate that the SPS refers
+ * to an existing VPS
+ */
+ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
+ int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
+
+ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps);
+ int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps, int apply_defdispwin);
+ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps);
+
+ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
+ ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);
+
+ int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
+ uint8_t *buf, int buf_size);
+
+ #endif /* AVCODEC_HEVC_PS_H */
diff --cc libavcodec/hevcdec.h
index bad4fb2,78080eb..b6391ea
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@@ -32,25 -33,19 +32,22 @@@
#include "bswapdsp.h"
#include "cabac.h"
#include "get_bits.h"
+#include "hevcpred.h"
#include "h2645_parse.h"
#include "hevc.h"
+ #include "hevc_ps.h"
#include "hevcdsp.h"
#include "internal.h"
#include "thread.h"
#include "videodsp.h"
- #define MAX_DPB_SIZE 16 // A.4.1
- #define MAX_REFS 16
-
+#define MAX_NB_THREADS 16
+#define SHIFT_CTB_WPP 2
+
//TODO: check if this is really the maximum
#define MAX_TRANSFORM_DEPTH 5
#define MAX_TB_SIZE 32
- #define MAX_LOG2_CTB_SIZE 6
-#define MAX_PB_SIZE 64
#define MAX_QP 51
#define DEFAULT_INTRA_TC_OFFSET 2
@@@ -880,42 -553,8 +589,21 @@@ typedef struct HEVCContext
int sei_display_orientation_present;
int sei_anticlockwise_rotation;
int sei_hflip, sei_vflip;
+
+ int picture_struct;
+
+ uint8_t* a53_caption;
+ int a53_caption_size;
+
+ /** mastering display */
+ int sei_mastering_display_info_present;
+ uint16_t display_primaries[3][2];
+ uint16_t white_point[2];
+ uint32_t max_mastering_luminance;
+ uint32_t min_mastering_luminance;
+
} HEVCContext;
- int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
- ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);
-
- /**
- * Parse the SPS from the bitstream into the provided HEVCSPS struct.
- *
- * @param sps_id the SPS id will be written here
- * @param apply_defdispwin if set 1, the default display window from the VUI
- * will be applied to the video dimensions
- * @param vps_list if non-NULL, this function will validate that the SPS refers
- * to an existing VPS
- */
- int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
- int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
-
- int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
- HEVCParamSets *ps);
- int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
- HEVCParamSets *ps, int apply_defdispwin);
- int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
- HEVCParamSets *ps);
int ff_hevc_decode_nal_sei(HEVCContext *s);
/**
@@@ -1011,28 -669,10 +699,24 @@@ void ff_hevc_deblocking_boundary_streng
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);
+int ff_hevc_cu_chroma_qp_offset_flag(HEVCContext *s);
+int ff_hevc_cu_chroma_qp_offset_idx(HEVCContext *s);
+void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size);
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_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size);
-
- int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
- uint8_t *buf, int buf_size);
-
-void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth);
+/**
+ * Reset SEI values that are stored on the Context.
+ * e.g. Caption data that was extracted during NAL
+ * parsing.
+ *
+ * @param s HEVCContext.
+ */
+void ff_hevc_reset_sei(HEVCContext *s);
extern const uint8_t ff_hevc_qpel_extra_before[4];
extern const uint8_t ff_hevc_qpel_extra_after[4];
More information about the ffmpeg-cvslog
mailing list