From c359d624d3efc3fd1d83210d78c4152bd329b765 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 21 Aug 2016 17:35:28 +0200 Subject: hevcdec: move decoder-independent declarations into a separate header This way they can be reused by other code without including the whole decoder-specific hevcdec.h Also, add the HEVC_ prefix to them, since similarly named values exist for H.264 as well and are sometimes used in the same code. --- libavcodec/hevc_parser.c | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'libavcodec/hevc_parser.c') diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index b68ceb985e..49e712269b 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" @@ -55,7 +56,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; } @@ -92,25 +93,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: hevc_parse_slice_header(s, nal, avctx); break; + 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: hevc_parse_slice_header(s, nal, avctx); break; } } @@ -138,19 +139,19 @@ 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) { pc->frame_start_found = 1; - s->key_frame = nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT; + s->key_frame = nut >= HEVC_NAL_BLA_W_LP && nut <= HEVC_NAL_CRA_NUT; } else { // First slice of next frame found pc->frame_start_found = 0; return i - 5; @@ -205,7 +206,7 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) state = (state << 8) | buf[i]; if (((state >> 8) & 0xFFFFFF) == START_CODE) { int nut = (state >> 1) & 0x3F; - if (nut >= NAL_VPS && nut <= NAL_PPS) + if (nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_PPS) has_ps = 1; else if (has_ps) return i - 3; -- cgit v1.2.3