From 5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 18 May 2016 10:36:33 +0200 Subject: h264: add H264_ prefix to the NAL unit types This will prevent conflicts e.g. in code that deals with both h264 and hevc. --- libavcodec/h264.h | 28 +++++++++++------------ libavcodec/h264_parse.c | 4 ++-- libavcodec/h264_parser.c | 28 +++++++++++------------ libavcodec/h264_refs.c | 2 +- libavcodec/h264_slice.c | 6 ++--- libavcodec/h264dec.c | 50 +++++++++++++++++++++--------------------- libavcodec/omx.c | 2 +- libavcodec/vaapi_encode_h264.c | 10 ++++----- 8 files changed, 65 insertions(+), 65 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 6a9b496bea..eb3805c067 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -28,20 +28,20 @@ /* NAL unit types */ enum { - NAL_SLICE = 1, - NAL_DPA = 2, - NAL_DPB = 3, - NAL_DPC = 4, - NAL_IDR_SLICE = 5, - NAL_SEI = 6, - NAL_SPS = 7, - NAL_PPS = 8, - NAL_AUD = 9, - NAL_END_SEQUENCE = 10, - NAL_END_STREAM = 11, - NAL_FILLER_DATA = 12, - NAL_SPS_EXT = 13, - NAL_AUXILIARY_SLICE = 19, + H264_NAL_SLICE = 1, + H264_NAL_DPA = 2, + H264_NAL_DPB = 3, + H264_NAL_DPC = 4, + H264_NAL_IDR_SLICE = 5, + H264_NAL_SEI = 6, + H264_NAL_SPS = 7, + H264_NAL_PPS = 8, + H264_NAL_AUD = 9, + H264_NAL_END_SEQUENCE = 10, + H264_NAL_END_STREAM = 11, + H264_NAL_FILLER_DATA = 12, + H264_NAL_SPS_EXT = 13, + H264_NAL_AUXILIARY_SLICE = 19, }; #endif /* AVCODEC_H264_H */ diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index 0aa6f09b72..d694558ecc 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -330,12 +330,12 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps, for (i = 0; i < pkt.nb_nals; i++) { H2645NAL *nal = &pkt.nals[i]; switch (nal->type) { - case NAL_SPS: + case H264_NAL_SPS: ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps); if (ret < 0) goto fail; break; - case NAL_PPS: + case H264_NAL_PPS: ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps, nal->size_bits); if (ret < 0) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index 00db1d8361..b4da123e94 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -83,14 +83,14 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf, state >>= 1; // 2->1, 1->0, 0->0 } else if (state <= 5) { int nalu_type = buf[i] & 0x1F; - if (nalu_type == NAL_SEI || nalu_type == NAL_SPS || - nalu_type == NAL_PPS || nalu_type == NAL_AUD) { + if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS || + nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) { if (pc->frame_start_found) { i++; goto found; } - } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA || - nalu_type == NAL_IDR_SLICE) { + } else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA || + nalu_type == H264_NAL_IDR_SLICE) { if (pc->frame_start_found) { state += 8; continue; @@ -234,10 +234,10 @@ static inline int parse_nal_units(AVCodecParserContext *s, --buf; src_length = buf_end - buf; switch (state & 0x1f) { - case NAL_SLICE: - case NAL_IDR_SLICE: + case H264_NAL_SLICE: + case H264_NAL_IDR_SLICE: // Do not walk the whole buffer just to decode slice header - if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) { + if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) { /* IDR or disposable slice * No need to decode many bytes because MMCOs shall not be present. */ if (src_length > 60) @@ -262,17 +262,17 @@ static inline int parse_nal_units(AVCodecParserContext *s, nal.type = get_bits(&nal.gb, 5); switch (nal.type) { - case NAL_SPS: + case H264_NAL_SPS: ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps); break; - case NAL_PPS: + case H264_NAL_PPS: ff_h264_decode_picture_parameter_set(&nal.gb, avctx, &p->ps, nal.size_bits); break; - case NAL_SEI: + case H264_NAL_SEI: ff_h264_sei_decode(&p->sei, &nal.gb, &p->ps, avctx); break; - case NAL_IDR_SLICE: + case H264_NAL_IDR_SLICE: s->key_frame = 1; p->poc.prev_frame_num = 0; @@ -280,7 +280,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, p->poc.prev_poc_msb = p->poc.prev_poc_lsb = 0; /* fall through */ - case NAL_SLICE: + case H264_NAL_SLICE: get_ue_golomb(&nal.gb); // skip first_mb_in_slice slice_type = get_ue_golomb_31(&nal.gb); s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5]; @@ -353,7 +353,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, } } - if (nal.type == NAL_IDR_SLICE) + if (nal.type == H264_NAL_IDR_SLICE) get_ue_golomb(&nal.gb); /* idr_pic_id */ if (sps->poc_type == 0) { p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb); @@ -382,7 +382,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, * FIXME: MMCO_RESET could appear in non-first slice. * Maybe, we should parse all undisposable non-IDR slice of this * picture until encountering MMCO_RESET in a slice of it. */ - if (nal.ref_idc && nal.type != NAL_IDR_SLICE) { + if (nal.ref_idc && nal.type != H264_NAL_IDR_SLICE) { got_reset = scan_mmco_reset(s, &nal.gb, avctx); if (got_reset < 0) goto fail; diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index 4172fbdaa3..2077847c19 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -735,7 +735,7 @@ int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl, MMCO *mmco = sl->mmco; int nb_mmco = 0; - if (h->nal_unit_type == NAL_IDR_SLICE) { // FIXME fields + if (h->nal_unit_type == H264_NAL_IDR_SLICE) { // FIXME fields skip_bits1(gb); // broken_link if (get_bits1(gb)) { mmco[0].opcode = MMCO_LONG; diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index f07f37e2d1..376be278a1 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1374,7 +1374,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->slice_type = slice_type; sl->slice_type_nos = slice_type & 3; - if (nal->type == NAL_IDR_SLICE && + if (nal->type == H264_NAL_IDR_SLICE && sl->slice_type_nos != AV_PICTURE_TYPE_I) { av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n"); return AVERROR_INVALIDDATA; @@ -1427,7 +1427,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->max_pic_num = 1 << (sps->log2_max_frame_num + 1); } - if (nal->type == NAL_IDR_SLICE) + if (nal->type == H264_NAL_IDR_SLICE) get_ue_golomb(&sl->gb); /* idr_pic_id */ if (sps->poc_type == 0) { @@ -1701,7 +1701,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, sl->mb_y * h->mb_width + sl->mb_x, av_get_picture_type_char(sl->slice_type), sl->slice_type_fixed ? " fix" : "", - nal->type == NAL_IDR_SLICE ? " IDR" : "", + nal->type == H264_NAL_IDR_SLICE ? " IDR" : "", h->poc.frame_num, h->cur_pic_ptr->field_poc[0], h->cur_pic_ptr->field_poc[1], diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index b4b78bd48a..52cb9ae02d 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -639,13 +639,13 @@ static int get_last_needed_nal(H264Context *h) * which splits NALs strangely if so, when frame threading we * can't start the next thread until we've read all of them */ switch (nal->type) { - case NAL_SPS: - case NAL_PPS: + case H264_NAL_SPS: + case H264_NAL_PPS: nals_needed = i; break; - case NAL_DPA: - case NAL_IDR_SLICE: - case NAL_SLICE: + case H264_NAL_DPA: + case H264_NAL_IDR_SLICE: + case H264_NAL_SLICE: init_get_bits(&gb, nal->data + 1, (nal->size - 1) * 8); if (!get_ue_golomb(&gb)) nals_needed = i; @@ -686,7 +686,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) int err; if (avctx->skip_frame >= AVDISCARD_NONREF && - nal->ref_idc == 0 && nal->type != NAL_SEI) + nal->ref_idc == 0 && nal->type != H264_NAL_SEI) continue; // FIXME these should stop being context-global variables @@ -695,15 +695,15 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) err = 0; switch (nal->type) { - case NAL_IDR_SLICE: - if (nal->type != NAL_IDR_SLICE) { + case H264_NAL_IDR_SLICE: + if (nal->type != H264_NAL_IDR_SLICE) { av_log(h->avctx, AV_LOG_ERROR, "Invalid mix of idr and non-idr slices\n"); ret = -1; goto end; } idr(h); // FIXME ensure we don't lose some frames if there is reordering - case NAL_SLICE: + case H264_NAL_SLICE: sl->gb = nal->gb; if ((err = ff_h264_decode_slice_header(h, sl, nal))) @@ -715,15 +715,15 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) } h->cur_pic_ptr->f->key_frame |= - (nal->type == NAL_IDR_SLICE) || (h->sei.recovery_point.recovery_frame_cnt >= 0); + (nal->type == H264_NAL_IDR_SLICE) || (h->sei.recovery_point.recovery_frame_cnt >= 0); - if (nal->type == NAL_IDR_SLICE || h->recovery_frame == h->poc.frame_num) { + if (nal->type == H264_NAL_IDR_SLICE || h->recovery_frame == h->poc.frame_num) { h->recovery_frame = -1; h->cur_pic_ptr->recovered = 1; } // If we have an IDR, all frames after it in decoded order are // "recovered". - if (nal->type == NAL_IDR_SLICE) + if (nal->type == H264_NAL_IDR_SLICE) h->frame_recovered |= FRAME_RECOVERED_IDR; h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR); @@ -751,35 +751,35 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) context_count++; } break; - case NAL_DPA: - case NAL_DPB: - case NAL_DPC: + case H264_NAL_DPA: + case H264_NAL_DPB: + case H264_NAL_DPC: avpriv_request_sample(avctx, "data partitioning"); ret = AVERROR(ENOSYS); goto end; break; - case NAL_SEI: + case H264_NAL_SEI: ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) goto end; break; - case NAL_SPS: + case H264_NAL_SPS: ret = ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) goto end; break; - case NAL_PPS: + case H264_NAL_PPS: ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps, nal->size_bits); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) goto end; break; - case NAL_AUD: - case NAL_END_SEQUENCE: - case NAL_END_STREAM: - case NAL_FILLER_DATA: - case NAL_SPS_EXT: - case NAL_AUXILIARY_SLICE: + case H264_NAL_AUD: + case H264_NAL_END_SEQUENCE: + case H264_NAL_END_STREAM: + case H264_NAL_FILLER_DATA: + case H264_NAL_SPS_EXT: + case H264_NAL_AUXILIARY_SLICE: break; default: av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n", @@ -912,7 +912,7 @@ out: if (buf_index < 0) return AVERROR_INVALIDDATA; - if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) { + if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) { buf_size = 0; goto out; } diff --git a/libavcodec/omx.c b/libavcodec/omx.c index 961ff86764..63c7f5b422 100644 --- a/libavcodec/omx.c +++ b/libavcodec/omx.c @@ -703,7 +703,7 @@ static av_cold int omx_encode_init(AVCodecContext *avctx) nals[avctx->extradata[i + 4] & 0x1f]++; } } - if (nals[NAL_SPS] && nals[NAL_PPS]) + if (nals[H264_NAL_SPS] && nals[H264_NAL_PPS]) break; } else { if (avctx->extradata_size > 0) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index a2889806f9..5bd56057cd 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -283,7 +283,7 @@ static void vaapi_encode_h264_write_sps(PutBitContext *pbc, VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params; int i; - vaapi_encode_h264_write_nal_header(pbc, NAL_SPS, 3); + vaapi_encode_h264_write_nal_header(pbc, H264_NAL_SPS, 3); u(8, mseq_var(profile_idc)); u(1, mseq_var(constraint_set0_flag)); @@ -368,7 +368,7 @@ static void vaapi_encode_h264_write_pps(PutBitContext *pbc, VAAPIEncodeH264Context *priv = ctx->priv_data; VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params; - vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3); + vaapi_encode_h264_write_nal_header(pbc, H264_NAL_PPS, 3); ue(vpic_var(pic_parameter_set_id)); ue(vpic_var(seq_parameter_set_id)); @@ -642,7 +642,7 @@ static void vaapi_encode_h264_write_sei(PutBitContext *pbc, VAAPIEncodeContext *ctx, VAAPIEncodePicture *pic) = NULL; - vaapi_encode_h264_write_nal_header(pbc, NAL_SEI, 0); + vaapi_encode_h264_write_nal_header(pbc, H264_NAL_SEI, 0); for (payload_type = 0; payload_type < 64; payload_type++) { switch (payload_type) { @@ -1010,9 +1010,9 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx, mslice = &pslice->misc_slice_params; if (pic->type == PICTURE_TYPE_IDR) - mslice->nal_unit_type = NAL_IDR_SLICE; + mslice->nal_unit_type = H264_NAL_IDR_SLICE; else - mslice->nal_unit_type = NAL_SLICE; + mslice->nal_unit_type = H264_NAL_SLICE; switch (pic->type) { case PICTURE_TYPE_IDR: -- cgit v1.2.3