Commit f41048f6 authored by James Almer's avatar James Almer

Merge commit '5c2fb561'

* commit '5c2fb561':
  h264: add H264_ prefix to the NAL unit types

Conflicts:
libavcodec/h264_parse.c
libavcodec/h264_parser.c
libavcodec/h264_slice.c
libavcodec/h264dec.c
Merged-by: 's avatarJames Almer <jamrial@gmail.com>
parents 12759cc0 5c2fb561
......@@ -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 */
......@@ -346,12 +346,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, 0);
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)
......
......@@ -106,14 +106,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) {
state += 8;
continue;
}
......@@ -303,10 +303,10 @@ static inline int parse_nal_units(AVCodecParserContext *s,
state = buf[buf_index];
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)
......@@ -332,17 +332,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, 0);
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;
......@@ -350,7 +350,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_long(&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];
......@@ -440,7 +440,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_long(&nal.gb); /* idr_pic_id */
if (sps->poc_type == 0) {
p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
......@@ -469,7 +469,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;
......@@ -637,17 +637,17 @@ static int h264_split(AVCodecContext *avctx,
if ((state & 0xFFFFFF00) != 0x100)
break;
nalu_type = state & 0x1F;
if (nalu_type == NAL_SPS) {
if (nalu_type == H264_NAL_SPS) {
has_sps = 1;
} else if (nalu_type == NAL_PPS)
} else if (nalu_type == H264_NAL_PPS)
has_pps = 1;
/* else if (nalu_type == 0x01 ||
* nalu_type == 0x02 ||
* nalu_type == 0x05) {
* }
*/
else if ((nalu_type != NAL_SEI || has_pps) &&
nalu_type != NAL_AUD && nalu_type != NAL_SPS_EXT &&
else if ((nalu_type != H264_NAL_SEI || has_pps) &&
nalu_type != H264_NAL_AUD && nalu_type != H264_NAL_SPS_EXT &&
nalu_type != 0x0f) {
if (has_sps) {
while (ptr - 4 > buf && ptr[-5] == 0)
......
......@@ -828,7 +828,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;
......
......@@ -1542,7 +1542,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;
......@@ -1605,7 +1605,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_long(&sl->gb); /* idr_pic_id */
if (sps->poc_type == 0) {
......@@ -1758,7 +1758,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
h->current_slice = 0;
if (ret < 0)
return ret;
} else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == NAL_IDR_SLICE) {
} else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == H264_NAL_IDR_SLICE) {
av_log(h, AV_LOG_WARNING, "Broken frame packetizing\n");
ret = ff_h264_field_end(h, h->slice_ctx, 1);
h->current_slice = 0;
......@@ -1788,7 +1788,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
(h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) ||
(h->avctx->skip_frame >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_frame >= AVDISCARD_NONINTRA && sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE && h->sei.recovery_point.recovery_frame_cnt < 0) ||
(h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != H264_NAL_IDR_SLICE && h->sei.recovery_point.recovery_frame_cnt < 0) ||
h->avctx->skip_frame >= AVDISCARD_ALL) {
return SLICE_SKIPED;
}
......@@ -1861,7 +1861,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
h->nal_unit_type != NAL_IDR_SLICE) ||
h->nal_unit_type != H264_NAL_IDR_SLICE) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
......@@ -1938,7 +1938,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],
......
......@@ -674,13 +674,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:
ret = init_get_bits8(&gb, nal->data + 1, (nal->size - 1));
if (ret < 0)
return ret;
......@@ -768,7 +768,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;
again:
......@@ -778,14 +778,14 @@ again:
err = 0;
switch (nal->type) {
case NAL_IDR_SLICE:
case H264_NAL_IDR_SLICE:
if ((nal->data[1] & 0xFC) == 0x98) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
h->next_outputed_poc = INT_MIN;
ret = -1;
goto end;
}
if (nal->type != 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;
......@@ -801,7 +801,7 @@ again:
}
idr_cleared = 1;
h->has_recovery_point = 1;
case NAL_SLICE:
case H264_NAL_SLICE:
sl->gb = nal->gb;
if ((err = ff_h264_decode_slice_header(h, sl, nal)))
......@@ -822,16 +822,16 @@ again:
}
}
h->cur_pic_ptr->f->key_frame |= (nal->type == NAL_IDR_SLICE);
h->cur_pic_ptr->f->key_frame |= (nal->type == H264_NAL_IDR_SLICE);
if (nal->type == NAL_IDR_SLICE ||
if (nal->type == H264_NAL_IDR_SLICE ||
(h->recovery_frame == h->poc.frame_num && nal->ref_idc)) {
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;
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
......@@ -874,12 +874,12 @@ again:
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");
break;
case NAL_SEI:
case H264_NAL_SEI:
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
if (avctx->debug & FF_DEBUG_GREEN_MD)
......@@ -892,7 +892,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
case NAL_SPS: {
case H264_NAL_SPS: {
GetBitContext tmp_gb = nal->gb;
if (ff_h264_decode_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0) >= 0)
break;
......@@ -904,18 +904,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps, 1);
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",
......@@ -1157,7 +1157,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
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) {
av_assert0(buf_index <= buf_size);
goto out;
}
......
......@@ -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)
......
......@@ -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:
......
......@@ -1860,11 +1860,11 @@ static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
break;
--buf;
switch (state & 0x1f) {
case NAL_SPS:
case H264_NAL_SPS:
st->codecpar->profile = buf[1];
e->flags |= 0x40;
break;
case NAL_PPS:
case H264_NAL_PPS:
if (e->flags & 0x40) { // sequence header present
e->flags |= 0x80; // random access
extra_size = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment