diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c index c14c4152c0..b0d9ff66f0 100644 --- a/libavcodec/h2645_parse.c +++ b/libavcodec/h2645_parse.c @@ -26,7 +26,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" -#include "hevcdec.h" +#include "hevc.h" #include "h2645_parse.h" int ff_h2645_extract_rbsp(const uint8_t *src, int length, @@ -150,31 +150,31 @@ nsc: static const char *nal_unit_name(int nal_type) { switch(nal_type) { - case NAL_TRAIL_N : return "TRAIL_N"; - case NAL_TRAIL_R : return "TRAIL_R"; - case NAL_TSA_N : return "TSA_N"; - case NAL_TSA_R : return "TSA_R"; - case NAL_STSA_N : return "STSA_N"; - case NAL_STSA_R : return "STSA_R"; - case NAL_RADL_N : return "RADL_N"; - case NAL_RADL_R : return "RADL_R"; - case NAL_RASL_N : return "RASL_N"; - case NAL_RASL_R : return "RASL_R"; - case NAL_BLA_W_LP : return "BLA_W_LP"; - case NAL_BLA_W_RADL : return "BLA_W_RADL"; - case NAL_BLA_N_LP : return "BLA_N_LP"; - case NAL_IDR_W_RADL : return "IDR_W_RADL"; - case NAL_IDR_N_LP : return "IDR_N_LP"; - case NAL_CRA_NUT : return "CRA_NUT"; - case NAL_VPS : return "VPS"; - case NAL_SPS : return "SPS"; - case NAL_PPS : return "PPS"; - case NAL_AUD : return "AUD"; - case NAL_EOS_NUT : return "EOS_NUT"; - case NAL_EOB_NUT : return "EOB_NUT"; - case NAL_FD_NUT : return "FD_NUT"; - case NAL_SEI_PREFIX : return "SEI_PREFIX"; - case NAL_SEI_SUFFIX : return "SEI_SUFFIX"; + case HEVC_NAL_TRAIL_N : return "TRAIL_N"; + case HEVC_NAL_TRAIL_R : return "TRAIL_R"; + case HEVC_NAL_TSA_N : return "TSA_N"; + case HEVC_NAL_TSA_R : return "TSA_R"; + case HEVC_NAL_STSA_N : return "STSA_N"; + case HEVC_NAL_STSA_R : return "STSA_R"; + case HEVC_NAL_RADL_N : return "RADL_N"; + case HEVC_NAL_RADL_R : return "RADL_R"; + case HEVC_NAL_RASL_N : return "RASL_N"; + case HEVC_NAL_RASL_R : return "RASL_R"; + case HEVC_NAL_BLA_W_LP : return "BLA_W_LP"; + case HEVC_NAL_BLA_W_RADL : return "BLA_W_RADL"; + case HEVC_NAL_BLA_N_LP : return "BLA_N_LP"; + case HEVC_NAL_IDR_W_RADL : return "IDR_W_RADL"; + case HEVC_NAL_IDR_N_LP : return "IDR_N_LP"; + case HEVC_NAL_CRA_NUT : return "CRA_NUT"; + case HEVC_NAL_VPS : return "VPS"; + case HEVC_NAL_SPS : return "SPS"; + case HEVC_NAL_PPS : return "PPS"; + case HEVC_NAL_AUD : return "AUD"; + case HEVC_NAL_EOS_NUT : return "EOS_NUT"; + case HEVC_NAL_EOB_NUT : return "EOB_NUT"; + case HEVC_NAL_FD_NUT : return "FD_NUT"; + case HEVC_NAL_SEI_PREFIX : return "SEI_PREFIX"; + case HEVC_NAL_SEI_SUFFIX : return "SEI_SUFFIX"; default : return "?"; } } diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c index 9002a98c4f..09bce5b34c 100644 --- a/libavcodec/hevc_mp4toannexb_bsf.c +++ b/libavcodec/hevc_mp4toannexb_bsf.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "bsf.h" #include "bytestream.h" -#include "hevcdec.h" +#include "hevc.h" #define MIN_HEVCC_LENGTH 23 @@ -55,8 +55,8 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) int type = bytestream2_get_byte(&gb) & 0x3f; int cnt = bytestream2_get_be16(&gb); - if (!(type == NAL_VPS || type == NAL_SPS || type == NAL_PPS || - type == NAL_SEI_PREFIX || type == NAL_SEI_SUFFIX)) { + if (!(type == HEVC_NAL_VPS || type == HEVC_NAL_SPS || type == HEVC_NAL_PPS || + type == HEVC_NAL_SEI_PREFIX || type == HEVC_NAL_SEI_SUFFIX)) { av_log(ctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n", type); ret = AVERROR_INVALIDDATA; diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c index d6bf872303..6c1138e015 100644 --- a/libavcodec/hevc_parse.c +++ b/libavcodec/hevc_parse.c @@ -18,7 +18,7 @@ #include "bytestream.h" #include "h2645_parse.h" -#include "hevcdec.h" +#include "hevc.h" #include "hevc_parse.h" static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps, @@ -38,25 +38,25 @@ static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets /* ignore everything except parameter sets and VCL NALUs */ switch (nal->type) { - case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break; - case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break; - case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break; - case NAL_TRAIL_R: - case NAL_TRAIL_N: - case NAL_TSA_N: - case NAL_TSA_R: - case NAL_STSA_N: - case NAL_STSA_R: - case NAL_BLA_W_LP: - case NAL_BLA_W_RADL: - case NAL_BLA_N_LP: - case NAL_IDR_W_RADL: - case NAL_IDR_N_LP: - case NAL_CRA_NUT: - case NAL_RADL_N: - case NAL_RADL_R: - case NAL_RASL_N: - case NAL_RASL_R: + case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps); break; + case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break; + case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps); break; + case HEVC_NAL_TRAIL_R: + case HEVC_NAL_TRAIL_N: + case HEVC_NAL_TSA_N: + case HEVC_NAL_TSA_R: + case HEVC_NAL_STSA_N: + case HEVC_NAL_STSA_R: + case HEVC_NAL_BLA_W_LP: + case HEVC_NAL_BLA_W_RADL: + case HEVC_NAL_BLA_N_LP: + case HEVC_NAL_IDR_W_RADL: + case HEVC_NAL_IDR_N_LP: + case HEVC_NAL_CRA_NUT: + case HEVC_NAL_RADL_N: + case HEVC_NAL_RADL_R: + case HEVC_NAL_RASL_N: + case HEVC_NAL_RASL_R: av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type); ret = AVERROR_INVALIDDATA; goto done; diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index 22a9623601..2a5190dcb8 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "golomb.h" +#include "hevc.h" #include "hevcdec.h" #include "h2645_parse.h" #include "parser.h" @@ -62,7 +63,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, get_bits1(gb); // no output of prior pics pps_id = get_ue_golomb_long(gb); - if (pps_id >= MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) { + if (pps_id >= HEVC_MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) { av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); return AVERROR_INVALIDDATA; } @@ -99,25 +100,25 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, /* ignore everything except parameter sets and VCL NALUs */ switch (nal->type) { - case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break; - case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break; - case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break; - case NAL_TRAIL_R: - case NAL_TRAIL_N: - case NAL_TSA_N: - case NAL_TSA_R: - case NAL_STSA_N: - case NAL_STSA_R: - case NAL_BLA_W_LP: - case NAL_BLA_W_RADL: - case NAL_BLA_N_LP: - case NAL_IDR_W_RADL: - case NAL_IDR_N_LP: - case NAL_CRA_NUT: - case NAL_RADL_N: - case NAL_RADL_R: - case NAL_RASL_N: - case NAL_RASL_R: + case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps); break; + case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 1); break; + case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps); break; + case HEVC_NAL_TRAIL_R: + case HEVC_NAL_TRAIL_N: + case HEVC_NAL_TSA_N: + case HEVC_NAL_TSA_R: + case HEVC_NAL_STSA_N: + case HEVC_NAL_STSA_R: + case HEVC_NAL_BLA_W_LP: + case HEVC_NAL_BLA_W_RADL: + case HEVC_NAL_BLA_N_LP: + case HEVC_NAL_IDR_W_RADL: + case HEVC_NAL_IDR_N_LP: + case HEVC_NAL_CRA_NUT: + case HEVC_NAL_RADL_N: + case HEVC_NAL_RADL_R: + case HEVC_NAL_RASL_N: + case HEVC_NAL_RASL_R: if (buf == avctx->extradata) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type); return AVERROR_INVALIDDATA; @@ -151,14 +152,14 @@ static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, nut = (pc->state64 >> 2 * 8 + 1) & 0x3F; // Beginning of access unit - if ((nut >= NAL_VPS && nut <= NAL_AUD) || nut == NAL_SEI_PREFIX || + if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_AUD) || nut == HEVC_NAL_SEI_PREFIX || (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) { if (pc->frame_start_found) { pc->frame_start_found = 0; return i - 5; } - } else if (nut <= NAL_RASL_R || - (nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT)) { + } else if (nut <= HEVC_NAL_RASL_R || + (nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT)) { int first_slice_segment_in_pic_flag = buf[i] >> 7; if (first_slice_segment_in_pic_flag) { if (!pc->frame_start_found) { @@ -238,7 +239,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, h->nal_unit_type = (*buf >> 1) & 0x3f; h->temporal_id = (*(buf + 1) & 0x07) - 1; - if (h->nal_unit_type <= NAL_CRA_NUT) { + if (h->nal_unit_type <= HEVC_NAL_CRA_NUT) { // Do not walk the whole buffer just to decode slice segment header if (src_length > 20) src_length = 20; @@ -253,35 +254,35 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, return ret; switch (h->nal_unit_type) { - case NAL_VPS: + case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(gb, avctx, ps); break; - case NAL_SPS: + case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(gb, avctx, ps, 1); break; - case NAL_PPS: + case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(gb, avctx, ps); break; - case NAL_SEI_PREFIX: - case NAL_SEI_SUFFIX: + case HEVC_NAL_SEI_PREFIX: + case HEVC_NAL_SEI_SUFFIX: ff_hevc_decode_nal_sei(h); break; - case NAL_TRAIL_N: - case NAL_TRAIL_R: - case NAL_TSA_N: - case NAL_TSA_R: - case NAL_STSA_N: - case NAL_STSA_R: - case NAL_RADL_N: - case NAL_RADL_R: - case NAL_RASL_N: - case NAL_RASL_R: - case NAL_BLA_W_LP: - case NAL_BLA_W_RADL: - case NAL_BLA_N_LP: - case NAL_IDR_W_RADL: - case NAL_IDR_N_LP: - case NAL_CRA_NUT: + case HEVC_NAL_TRAIL_N: + case HEVC_NAL_TRAIL_R: + case HEVC_NAL_TSA_N: + case HEVC_NAL_TSA_R: + case HEVC_NAL_STSA_N: + case HEVC_NAL_STSA_R: + case HEVC_NAL_RADL_N: + case HEVC_NAL_RADL_R: + case HEVC_NAL_RASL_N: + case HEVC_NAL_RASL_R: + case HEVC_NAL_BLA_W_LP: + case HEVC_NAL_BLA_W_RADL: + case HEVC_NAL_BLA_N_LP: + case HEVC_NAL_IDR_W_RADL: + case HEVC_NAL_IDR_N_LP: + case HEVC_NAL_CRA_NUT: if (is_global) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type); @@ -298,13 +299,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, } sh->pps_id = get_ue_golomb(gb); - if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { + if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) { av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data; - if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { + if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) { av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id); return AVERROR_INVALIDDATA; } @@ -382,13 +383,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, s->output_picture_number = h->poc = 0; if (h->temporal_id == 0 && - h->nal_unit_type != NAL_TRAIL_N && - h->nal_unit_type != NAL_TSA_N && - h->nal_unit_type != NAL_STSA_N && - h->nal_unit_type != NAL_RADL_N && - h->nal_unit_type != NAL_RASL_N && - h->nal_unit_type != NAL_RADL_R && - h->nal_unit_type != NAL_RASL_R) + h->nal_unit_type != HEVC_NAL_TRAIL_N && + h->nal_unit_type != HEVC_NAL_TSA_N && + h->nal_unit_type != HEVC_NAL_STSA_N && + h->nal_unit_type != HEVC_NAL_RADL_N && + h->nal_unit_type != HEVC_NAL_RASL_N && + h->nal_unit_type != HEVC_NAL_RADL_R && + h->nal_unit_type != HEVC_NAL_RASL_R) h->pocTid0 = h->poc; return 0; /* no need to evaluate the rest */ @@ -449,14 +450,14 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) if ((state >> 8) != START_CODE) break; nut = (state >> 1) & 0x3F; - if (nut == NAL_VPS) + if (nut == HEVC_NAL_VPS) has_vps = 1; - else if (nut == NAL_SPS) + else if (nut == HEVC_NAL_SPS) has_sps = 1; - else if (nut == NAL_PPS) + else if (nut == HEVC_NAL_PPS) has_pps = 1; - else if ((nut != NAL_SEI_PREFIX || has_pps) && - nut != NAL_AUD) { + else if ((nut != HEVC_NAL_SEI_PREFIX || has_pps) && + nut != HEVC_NAL_AUD) { if (has_vps && has_sps) { while (ptr - 4 > buf && ptr[-5] == 0) ptr--; diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 4a3091ca7b..f9f04a5388 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -421,7 +421,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, memcpy(vps->data, gb->buffer, vps->data_size); vps_id = get_bits(gb, 4); - if (vps_id >= MAX_VPS_COUNT) { + if (vps_id >= HEVC_MAX_VPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id); goto err; } @@ -440,7 +440,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, goto err; } - if (vps->vps_max_sub_layers > MAX_SUB_LAYERS) { + if (vps->vps_max_sub_layers > HEVC_MAX_SUB_LAYERS) { av_log(avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n", vps->vps_max_sub_layers); goto err; @@ -833,7 +833,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, // Coded parameters sps->vps_id = get_bits(gb, 4); - if (sps->vps_id >= MAX_VPS_COUNT) { + if (sps->vps_id >= HEVC_MAX_VPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id); return AVERROR_INVALIDDATA; } @@ -845,7 +845,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } sps->max_sub_layers = get_bits(gb, 3) + 1; - if (sps->max_sub_layers > MAX_SUB_LAYERS) { + if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) { av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n", sps->max_sub_layers); return AVERROR_INVALIDDATA; @@ -857,7 +857,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return ret; *sps_id = get_ue_golomb_long(gb); - if (*sps_id >= MAX_SPS_COUNT) { + if (*sps_id >= HEVC_MAX_SPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", *sps_id); return AVERROR_INVALIDDATA; } @@ -1018,7 +1018,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, } sps->nb_st_rps = get_ue_golomb_long(gb); - if (sps->nb_st_rps > MAX_SHORT_TERM_RPS_COUNT) { + if (sps->nb_st_rps > HEVC_MAX_SHORT_TERM_RPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n", sps->nb_st_rps); return AVERROR_INVALIDDATA; @@ -1470,13 +1470,13 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, // Coded parameters pps_id = get_ue_golomb_long(gb); - if (pps_id >= MAX_PPS_COUNT) { + if (pps_id >= HEVC_MAX_PPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); ret = AVERROR_INVALIDDATA; goto err; } pps->sps_id = get_ue_golomb_long(gb); - if (pps->sps_id >= MAX_SPS_COUNT) { + if (pps->sps_id >= HEVC_MAX_SPS_COUNT) { av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index aa1162735c..db1ac2bf90 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -26,6 +26,7 @@ #include "internal.h" #include "thread.h" +#include "hevc.h" #include "hevcdec.h" void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) @@ -386,7 +387,7 @@ static HEVCFrame *find_ref_idx(HEVCContext *s, int poc) } } - if (s->nal_unit_type != NAL_CRA_NUT && !IS_BLA(s)) + if (s->nal_unit_type != HEVC_NAL_CRA_NUT && !IS_BLA(s)) av_log(s->avctx, AV_LOG_ERROR, "Could not find ref with POC %d\n", poc); return NULL; @@ -530,9 +531,9 @@ int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb) poc_msb = prev_poc_msb; // For BLA picture types, POCmsb is set to 0. - if (s->nal_unit_type == NAL_BLA_W_LP || - s->nal_unit_type == NAL_BLA_W_RADL || - s->nal_unit_type == NAL_BLA_N_LP) + if (s->nal_unit_type == HEVC_NAL_BLA_W_LP || + s->nal_unit_type == HEVC_NAL_BLA_W_RADL || + s->nal_unit_type == HEVC_NAL_BLA_N_LP) poc_msb = 0; return poc_msb + poc_lsb; diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index bb4414402d..a4b93c2b3f 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -272,7 +272,7 @@ static int active_parameter_sets(HEVCContext *s) } active_seq_parameter_set_id = get_ue_golomb_long(gb); - if (active_seq_parameter_set_id >= MAX_SPS_COUNT) { + if (active_seq_parameter_set_id >= HEVC_MAX_SPS_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "active_parameter_set_id %d invalid\n", active_seq_parameter_set_id); return AVERROR_INVALIDDATA; } @@ -349,7 +349,7 @@ static int decode_nal_sei_message(HEVCContext *s) byte = get_bits(gb, 8); payload_size += byte; } - if (s->nal_unit_type == NAL_SEI_PREFIX) { + if (s->nal_unit_type == HEVC_NAL_SEI_PREFIX) { return decode_nal_sei_prefix(s, payload_type, payload_size); } else { /* nal_unit_type == NAL_SEI_SUFFIX */ return decode_nal_sei_suffix(s, payload_type, payload_size); diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 8893648e0a..aa54142da2 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -37,6 +37,7 @@ #include "bytestream.h" #include "cabac_functions.h" #include "golomb.h" +#include "hevc.h" #include "hevcdec.h" #include "profiles.h" @@ -443,7 +444,7 @@ static int hls_slice_header(HEVCContext *s) sh->no_output_of_prior_pics_flag = get_bits1(gb); sh->pps_id = get_ue_golomb_long(gb); - if (sh->pps_id >= MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { + if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } @@ -453,13 +454,13 @@ static int hls_slice_header(HEVCContext *s) return AVERROR_INVALIDDATA; } s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data; - if (s->nal_unit_type == NAL_CRA_NUT && s->last_eos == 1) + if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) sh->no_output_of_prior_pics_flag = 1; if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { const HEVCSPS* last_sps = s->ps.sps; s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; - if (last_sps && IS_IRAP(s) && s->nal_unit_type != NAL_CRA_NUT) { + if (last_sps && IS_IRAP(s) && s->nal_unit_type != HEVC_NAL_CRA_NUT) { if (s->ps.sps->width != last_sps->width || s->ps.sps->height != last_sps->height || s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering != last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering) @@ -584,13 +585,13 @@ static int hls_slice_header(HEVCContext *s) /* 8.3.1 */ if (s->temporal_id == 0 && - s->nal_unit_type != NAL_TRAIL_N && - s->nal_unit_type != NAL_TSA_N && - s->nal_unit_type != NAL_STSA_N && - s->nal_unit_type != NAL_RADL_N && - s->nal_unit_type != NAL_RADL_R && - s->nal_unit_type != NAL_RASL_N && - s->nal_unit_type != NAL_RASL_R) + s->nal_unit_type != HEVC_NAL_TRAIL_N && + s->nal_unit_type != HEVC_NAL_TSA_N && + s->nal_unit_type != HEVC_NAL_STSA_N && + s->nal_unit_type != HEVC_NAL_RADL_N && + s->nal_unit_type != HEVC_NAL_RADL_R && + s->nal_unit_type != HEVC_NAL_RASL_N && + s->nal_unit_type != HEVC_NAL_RASL_R) s->pocTid0 = s->poc; if (s->ps.sps->sao_enabled) { @@ -824,7 +825,7 @@ static int hls_slice_header(HEVCContext *s) s->HEVClc->tu.cu_qp_offset_cb = 0; s->HEVClc->tu.cu_qp_offset_cr = 0; - s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == NAL_CRA_NUT && s->last_eos); + s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos); return 0; } @@ -2727,50 +2728,50 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) s->temporal_id = nal->temporal_id; switch (s->nal_unit_type) { - case NAL_VPS: + case HEVC_NAL_VPS: ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps); if (ret < 0) goto fail; break; - case NAL_SPS: + case HEVC_NAL_SPS: ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps, s->apply_defdispwin); if (ret < 0) goto fail; break; - case NAL_PPS: + case HEVC_NAL_PPS: ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps); if (ret < 0) goto fail; break; - case NAL_SEI_PREFIX: - case NAL_SEI_SUFFIX: + case HEVC_NAL_SEI_PREFIX: + case HEVC_NAL_SEI_SUFFIX: ret = ff_hevc_decode_nal_sei(s); if (ret < 0) goto fail; break; - case NAL_TRAIL_R: - case NAL_TRAIL_N: - case NAL_TSA_N: - case NAL_TSA_R: - case NAL_STSA_N: - case NAL_STSA_R: - case NAL_BLA_W_LP: - case NAL_BLA_W_RADL: - case NAL_BLA_N_LP: - case NAL_IDR_W_RADL: - case NAL_IDR_N_LP: - case NAL_CRA_NUT: - case NAL_RADL_N: - case NAL_RADL_R: - case NAL_RASL_N: - case NAL_RASL_R: + case HEVC_NAL_TRAIL_R: + case HEVC_NAL_TRAIL_N: + case HEVC_NAL_TSA_N: + case HEVC_NAL_TSA_R: + case HEVC_NAL_STSA_N: + case HEVC_NAL_STSA_R: + case HEVC_NAL_BLA_W_LP: + case HEVC_NAL_BLA_W_RADL: + case HEVC_NAL_BLA_N_LP: + case HEVC_NAL_IDR_W_RADL: + case HEVC_NAL_IDR_N_LP: + case HEVC_NAL_CRA_NUT: + case HEVC_NAL_RADL_N: + case HEVC_NAL_RADL_R: + case HEVC_NAL_RASL_N: + case HEVC_NAL_RASL_R: ret = hls_slice_header(s); if (ret < 0) return ret; if (s->max_ra == INT_MAX) { - if (s->nal_unit_type == NAL_CRA_NUT || IS_BLA(s)) { + if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) { s->max_ra = s->poc; } else { if (IS_IDR(s)) @@ -2778,12 +2779,12 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) } } - if ((s->nal_unit_type == NAL_RASL_R || s->nal_unit_type == NAL_RASL_N) && + if ((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == HEVC_NAL_RASL_N) && s->poc <= s->max_ra) { s->is_decoded = 0; break; } else { - if (s->nal_unit_type == NAL_RASL_R && s->poc > s->max_ra) + if (s->nal_unit_type == HEVC_NAL_RASL_R && s->poc > s->max_ra) s->max_ra = INT_MIN; } @@ -2838,13 +2839,13 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) } } break; - case NAL_EOS_NUT: - case NAL_EOB_NUT: + case HEVC_NAL_EOS_NUT: + case HEVC_NAL_EOB_NUT: s->seq_decode = (s->seq_decode + 1) & 0xff; s->max_ra = INT_MAX; break; - case NAL_AUD: - case NAL_FD_NUT: + case HEVC_NAL_AUD: + case HEVC_NAL_FD_NUT: break; default: av_log(s->avctx, AV_LOG_INFO, @@ -2877,8 +2878,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) } for (i = 0; i < s->pkt.nb_nals; i++) { - if (s->pkt.nals[i].type == NAL_EOB_NUT || - s->pkt.nals[i].type == NAL_EOS_NUT) + if (s->pkt.nals[i].type == HEVC_NAL_EOB_NUT || + s->pkt.nals[i].type == HEVC_NAL_EOS_NUT) s->eos = 1; } diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 519c7a634c..0866461c00 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -34,6 +34,7 @@ #include "get_bits.h" #include "hevcpred.h" #include "h2645_parse.h" +#include "hevc.h" #include "hevcdsp.h" #include "internal.h" #include "thread.h" @@ -45,16 +46,6 @@ #define MAX_NB_THREADS 16 #define SHIFT_CTB_WPP 2 -/** - * 7.4.2.1 - */ -#define MAX_SUB_LAYERS 7 -#define MAX_VPS_COUNT 16 -#define MAX_SPS_COUNT 32 -#define MAX_PPS_COUNT 256 -#define MAX_SHORT_TERM_RPS_COUNT 64 -#define MAX_CU_SIZE 128 - //TODO: check if this is really the maximum #define MAX_TRANSFORM_DEPTH 5 @@ -85,42 +76,11 @@ #define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)]) #define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)]) -#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_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || (s)->nal_unit_type == HEVC_NAL_IDR_N_LP) +#define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || (s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \ + (s)->nal_unit_type == HEVC_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 - */ -enum NALUnitType { - NAL_TRAIL_N = 0, - NAL_TRAIL_R = 1, - NAL_TSA_N = 2, - NAL_TSA_R = 3, - NAL_STSA_N = 4, - NAL_STSA_R = 5, - NAL_RADL_N = 6, - NAL_RADL_R = 7, - NAL_RASL_N = 8, - NAL_RASL_R = 9, - NAL_BLA_W_LP = 16, - NAL_BLA_W_RADL = 17, - NAL_BLA_N_LP = 18, - NAL_IDR_W_RADL = 19, - NAL_IDR_N_LP = 20, - NAL_CRA_NUT = 21, - NAL_VPS = 32, - NAL_SPS = 33, - NAL_PPS = 34, - NAL_AUD = 35, - NAL_EOS_NUT = 36, - NAL_EOB_NUT = 37, - NAL_FD_NUT = 38, - NAL_SEI_PREFIX = 39, - NAL_SEI_SUFFIX = 40, -}; - enum RPSType { ST_CURR_BEF = 0, ST_CURR_AFT, @@ -365,10 +325,10 @@ typedef struct PTLCommon { typedef struct PTL { PTLCommon general_ptl; - PTLCommon sub_layer_ptl[MAX_SUB_LAYERS]; + PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS]; - uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS]; - uint8_t sub_layer_level_present_flag[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 { @@ -378,9 +338,9 @@ typedef struct HEVCVPS { PTL ptl; int vps_sub_layer_ordering_info_present_flag; - unsigned int vps_max_dec_pic_buffering[MAX_SUB_LAYERS]; - unsigned int vps_num_reorder_pics[MAX_SUB_LAYERS]; - unsigned int vps_max_latency_increase[MAX_SUB_LAYERS]; + 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; @@ -424,7 +384,7 @@ typedef struct HEVCSPS { int max_dec_pic_buffering; int num_reorder_pics; int max_latency_increase; - } temporal_layer[MAX_SUB_LAYERS]; + } temporal_layer[HEVC_MAX_SUB_LAYERS]; VUI vui; PTL ptl; @@ -433,7 +393,7 @@ typedef struct HEVCSPS { ScalingList scaling_list; unsigned int nb_st_rps; - ShortTermRPS st_rps[MAX_SHORT_TERM_RPS_COUNT]; + ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_RPS_COUNT]; uint8_t amp_enabled_flag; uint8_t sao_enabled; @@ -571,9 +531,9 @@ typedef struct HEVCPPS { } HEVCPPS; typedef struct HEVCParamSets { - AVBufferRef *vps_list[MAX_VPS_COUNT]; - AVBufferRef *sps_list[MAX_SPS_COUNT]; - AVBufferRef *pps_list[MAX_PPS_COUNT]; + 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; @@ -837,7 +797,7 @@ typedef struct HEVCContext { SliceHeader sh; SAOParams *sao; DBParams *deblock; - enum NALUnitType nal_unit_type; + enum HEVCNALUnitType nal_unit_type; int temporal_id; ///< temporal_id_plus1 - 1 HEVCFrame *ref; HEVCFrame DPB[32]; @@ -893,7 +853,7 @@ typedef struct HEVCContext { H2645Packet pkt; // type of the first VCL NAL of the current frame - enum NALUnitType first_nal_type; + enum HEVCNALUnitType first_nal_type; // for checking the frame checksums struct AVMD5 *md5_ctx; diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 3ada3fa698..79a51ec684 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -207,14 +207,14 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format) goto done; } - for (i = 0; i < MAX_VPS_COUNT; i++) { + for (i = 0; i < HEVC_MAX_VPS_COUNT; i++) { if (ps.vps_list[i]) { vps = (const HEVCVPS*)ps.vps_list[i]->data; break; } } - for (i = 0; i < MAX_PPS_COUNT; i++) { + for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) { if (ps.pps_list[i]) { pps = (const HEVCPPS*)ps.pps_list[i]->data; break; diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 8b63bdc7f5..7d4d55bb61 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "bytestream.h" #include "get_bits.h" +#include "hevc.h" #include "hevcdec.h" #include "h2645_parse.h" #include "internal.h" @@ -83,7 +84,7 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) get_bits(&gb, 1); type = get_bits(&gb, 6); - if (type != NAL_SPS) { + if (type != HEVC_NAL_SPS) { av_log(avctx, AV_LOG_ERROR, "Unexpected NAL type in the extradata: %d\n", type); av_freep(&sps_nal.rbsp_buffer); @@ -103,7 +104,7 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) vps.vps_max_sub_layers = sps.max_sub_layers; memcpy(&vps.ptl, &sps.ptl, sizeof(vps.ptl)); vps.vps_sub_layer_ordering_info_present_flag = 1; - for (i = 0; i < MAX_SUB_LAYERS; i++) { + for (i = 0; i < HEVC_MAX_SUB_LAYERS; i++) { vps.vps_max_dec_pic_buffering[i] = sps.temporal_layer[i].max_dec_pic_buffering; vps.vps_num_reorder_pics[i] = sps.temporal_layer[i].num_reorder_pics; vps.vps_max_latency_increase[i] = sps.temporal_layer[i].max_latency_increase; @@ -127,9 +128,9 @@ static int generate_fake_vps(QSVEncContext *q, AVCodecContext *avctx) bytestream2_init(&gbc, vps_rbsp_buf, ret); bytestream2_init_writer(&pbc, vps_buf, sizeof(vps_buf)); - bytestream2_put_be32(&pbc, 1); // startcode - bytestream2_put_byte(&pbc, NAL_VPS << 1); // NAL - bytestream2_put_byte(&pbc, 1); // header + bytestream2_put_be32(&pbc, 1); // startcode + bytestream2_put_byte(&pbc, HEVC_NAL_VPS << 1); // NAL + bytestream2_put_byte(&pbc, 1); // header while (bytestream2_get_bytes_left(&gbc)) { uint32_t b = bytestream2_peek_be24(&gbc); diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 1332c282cc..bd327ff235 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -25,7 +25,7 @@ #include "libavutil/pixfmt.h" #include "avcodec.h" -#include "hevcdec.h" +#include "hevc.h" #include "internal.h" #include "put_bits.h" #include "vaapi_encode.h" @@ -275,7 +275,7 @@ static void vaapi_encode_h265_write_vps(PutBitContext *pbc, VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params; int i, j; - vaapi_encode_h265_write_nal_unit_header(pbc, NAL_VPS); + vaapi_encode_h265_write_nal_unit_header(pbc, HEVC_NAL_VPS); u(4, mseq->video_parameter_set_id, vps_video_parameter_set_id); @@ -395,7 +395,7 @@ static void vaapi_encode_h265_write_sps(PutBitContext *pbc, VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params; int i; - vaapi_encode_h265_write_nal_unit_header(pbc, NAL_SPS); + vaapi_encode_h265_write_nal_unit_header(pbc, HEVC_NAL_SPS); u(4, mseq->video_parameter_set_id, sps_video_parameter_set_id); @@ -491,7 +491,7 @@ static void vaapi_encode_h265_write_pps(PutBitContext *pbc, VAAPIEncodeH265MiscSequenceParams *mseq = &priv->misc_sequence_params; int i; - vaapi_encode_h265_write_nal_unit_header(pbc, NAL_PPS); + vaapi_encode_h265_write_nal_unit_header(pbc, HEVC_NAL_PPS); ue(vpic->slice_pic_parameter_set_id, pps_pic_parameter_set_id); ue(mseq->seq_parameter_set_id, pps_seq_parameter_set_id); @@ -576,7 +576,7 @@ static void vaapi_encode_h265_write_slice_header2(PutBitContext *pbc, vaapi_encode_h265_write_nal_unit_header(pbc, vpic->nal_unit_type); u(1, mslice_var(first_slice_segment_in_pic_flag)); - if (vpic->nal_unit_type >= NAL_BLA_W_LP && + if (vpic->nal_unit_type >= HEVC_NAL_BLA_W_LP && vpic->nal_unit_type <= 23) u(1, mslice_var(no_output_of_prior_pics_flag)); @@ -597,8 +597,8 @@ static void vaapi_encode_h265_write_slice_header2(PutBitContext *pbc, u(1, 1, pic_output_flag); if (vseq->seq_fields.bits.separate_colour_plane_flag) u(2, vslice_field(colour_plane_id)); - if (vpic->nal_unit_type != NAL_IDR_W_RADL && - vpic->nal_unit_type != NAL_IDR_N_LP) { + if (vpic->nal_unit_type != HEVC_NAL_IDR_W_RADL && + vpic->nal_unit_type != HEVC_NAL_IDR_N_LP) { u(4 + mseq->log2_max_pic_order_cnt_lsb_minus4, (pslice->pic_order_cnt & ((1 << (mseq->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1)), @@ -998,25 +998,25 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, switch (pic->type) { case PICTURE_TYPE_IDR: - vpic->nal_unit_type = NAL_IDR_W_RADL; + vpic->nal_unit_type = HEVC_NAL_IDR_W_RADL; vpic->pic_fields.bits.idr_pic_flag = 1; vpic->pic_fields.bits.coding_type = 1; vpic->pic_fields.bits.reference_pic_flag = 1; break; case PICTURE_TYPE_I: - vpic->nal_unit_type = NAL_TRAIL_R; + vpic->nal_unit_type = HEVC_NAL_TRAIL_R; vpic->pic_fields.bits.idr_pic_flag = 0; vpic->pic_fields.bits.coding_type = 1; vpic->pic_fields.bits.reference_pic_flag = 1; break; case PICTURE_TYPE_P: - vpic->nal_unit_type = NAL_TRAIL_R; + vpic->nal_unit_type = HEVC_NAL_TRAIL_R; vpic->pic_fields.bits.idr_pic_flag = 0; vpic->pic_fields.bits.coding_type = 2; vpic->pic_fields.bits.reference_pic_flag = 1; break; case PICTURE_TYPE_B: - vpic->nal_unit_type = NAL_TRAIL_R; + vpic->nal_unit_type = HEVC_NAL_TRAIL_R; vpic->pic_fields.bits.idr_pic_flag = 0; vpic->pic_fields.bits.coding_type = 3; vpic->pic_fields.bits.reference_pic_flag = 0; diff --git a/libavformat/hevc.c b/libavformat/hevc.c index f3e283c98d..1a2d6cdd2b 100644 --- a/libavformat/hevc.c +++ b/libavformat/hevc.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavcodec/avcodec.h" #include "libavcodec/get_bits.h" #include "libavcodec/golomb.h" -#include "libavcodec/hevcdec.h" +#include "libavcodec/hevc.h" #include "libavutil/intreadwrite.h" #include "avc.h" #include "avio.h" @@ -127,8 +128,8 @@ static void hvcc_parse_ptl(GetBitContext *gb, { unsigned int i; HVCCProfileTierLevel general_ptl; - uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS]; - uint8_t sub_layer_level_present_flag[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]; general_ptl.profile_space = get_bits(gb, 2); general_ptl.tier_flag = get_bits1(gb); @@ -416,7 +417,7 @@ static void skip_scaling_list_data(GetBitContext *gb) static int parse_rps(GetBitContext *gb, unsigned int rps_idx, unsigned int num_rps, - unsigned int num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT]) + unsigned int num_delta_pocs[HEVC_MAX_SHORT_TERM_RPS_COUNT]) { unsigned int i; @@ -485,7 +486,7 @@ static int hvcc_parse_sps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc) { unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4; - unsigned int num_short_term_ref_pic_sets, num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT]; + unsigned int num_short_term_ref_pic_sets, num_delta_pocs[HEVC_MAX_SHORT_TERM_RPS_COUNT]; skip_bits(gb, 4); // sps_video_parameter_set_id @@ -555,7 +556,7 @@ static int hvcc_parse_sps(GetBitContext *gb, } num_short_term_ref_pic_sets = get_ue_golomb_long(gb); - if (num_short_term_ref_pic_sets > MAX_SHORT_TERM_RPS_COUNT) + if (num_short_term_ref_pic_sets > HEVC_MAX_SHORT_TERM_RPS_COUNT) return AVERROR_INVALIDDATA; for (i = 0; i < num_short_term_ref_pic_sets; i++) { @@ -734,7 +735,7 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, * for all other arrays. When the sample entry name is ‘hev1’, the default * value of array_completeness is 0 for all arrays. */ - if (nal_type == NAL_VPS || nal_type == NAL_SPS || nal_type == NAL_PPS) + if (nal_type == HEVC_NAL_VPS || nal_type == HEVC_NAL_SPS || nal_type == HEVC_NAL_PPS) array->array_completeness = ps_array_completeness; return 0; @@ -768,20 +769,20 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, * and non-declarative SEI messages discarded? */ switch (nal_type) { - case NAL_VPS: - case NAL_SPS: - case NAL_PPS: - case NAL_SEI_PREFIX: - case NAL_SEI_SUFFIX: + case HEVC_NAL_VPS: + case HEVC_NAL_SPS: + case HEVC_NAL_PPS: + case HEVC_NAL_SEI_PREFIX: + case HEVC_NAL_SEI_SUFFIX: ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type, ps_array_completeness, hvcc); if (ret < 0) goto end; - else if (nal_type == NAL_VPS) + else if (nal_type == HEVC_NAL_VPS) ret = hvcc_parse_vps(&gbc, hvcc); - else if (nal_type == NAL_SPS) + else if (nal_type == HEVC_NAL_SPS) ret = hvcc_parse_sps(&gbc, hvcc); - else if (nal_type == NAL_PPS) + else if (nal_type == HEVC_NAL_PPS) ret = hvcc_parse_pps(&gbc, hvcc); if (ret < 0) goto end; @@ -915,21 +916,21 @@ static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc) */ for (i = 0; i < hvcc->numOfArrays; i++) switch (hvcc->array[i].NAL_unit_type) { - case NAL_VPS: + case HEVC_NAL_VPS: vps_count += hvcc->array[i].numNalus; break; - case NAL_SPS: + case HEVC_NAL_SPS: sps_count += hvcc->array[i].numNalus; break; - case NAL_PPS: + case HEVC_NAL_PPS: pps_count += hvcc->array[i].numNalus; break; default: break; } - if (!vps_count || vps_count > MAX_VPS_COUNT || - !sps_count || sps_count > MAX_SPS_COUNT || - !pps_count || pps_count > MAX_PPS_COUNT) + if (!vps_count || vps_count > HEVC_MAX_VPS_COUNT || + !sps_count || sps_count > HEVC_MAX_SPS_COUNT || + !pps_count || pps_count > HEVC_MAX_PPS_COUNT) return AVERROR_INVALIDDATA; /* unsigned int(8) configurationVersion = 1; */ @@ -1052,9 +1053,9 @@ int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, buf += 4; switch (type) { - case NAL_VPS: - case NAL_SPS: - case NAL_PPS: + case HEVC_NAL_VPS: + case HEVC_NAL_SPS: + case HEVC_NAL_PPS: num_ps++; break; default: @@ -1127,11 +1128,11 @@ int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, buf += 4; switch (type) { - case NAL_VPS: - case NAL_SPS: - case NAL_PPS: - case NAL_SEI_PREFIX: - case NAL_SEI_SUFFIX: + case HEVC_NAL_VPS: + case HEVC_NAL_SPS: + case HEVC_NAL_PPS: + case HEVC_NAL_SEI_PREFIX: + case HEVC_NAL_SEI_SUFFIX: ret = hvcc_add_nal_unit(buf, len, ps_array_completeness, &hvcc); if (ret < 0) goto end; diff --git a/libavformat/hevcdec.c b/libavformat/hevcdec.c index 28500fb649..aaab0ffa2f 100644 --- a/libavformat/hevcdec.c +++ b/libavformat/hevcdec.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcodec/hevcdec.h" +#include "libavcodec/hevc.h" #include "avformat.h" #include "rawdec.h" @@ -43,15 +43,15 @@ static int hevc_probe(AVProbeData *p) return 0; switch (type) { - case NAL_VPS: vps++; break; - case NAL_SPS: sps++; break; - case NAL_PPS: pps++; break; - case NAL_BLA_N_LP: - case NAL_BLA_W_LP: - case NAL_BLA_W_RADL: - case NAL_CRA_NUT: - case NAL_IDR_N_LP: - case NAL_IDR_W_RADL: irap++; break; + case HEVC_NAL_VPS: vps++; break; + case HEVC_NAL_SPS: sps++; break; + case HEVC_NAL_PPS: pps++; break; + case HEVC_NAL_BLA_N_LP: + case HEVC_NAL_BLA_W_LP: + case HEVC_NAL_BLA_W_RADL: + case HEVC_NAL_CRA_NUT: + case HEVC_NAL_IDR_N_LP: + case HEVC_NAL_IDR_W_RADL: irap++; break; } } }