int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
{
static const int8_t top[4] = { LEFT_DC_PRED8x8, 1, -1, -1 };
- static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
+ static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
if (mode > 3U) {
av_log(h->avctx, AV_LOG_ERROR,
first_mb_in_slice = get_ue_golomb_long(&h->gb);
if (first_mb_in_slice == 0) { // FIXME better field boundary detection
- if (h0->current_slice && FIELD_PICTURE(h)) {
+ if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
field_end(h, 1);
}
h->slice_type = slice_type;
h->slice_type_nos = slice_type & 3;
+ if (h->nal_unit_type == NAL_IDR_SLICE &&
+ h->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;
+ }
+
// to make a few old functions happy, it's wrong though
h->pict_type = h->slice_type;
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
ret = h264_frame_start(h);
- if (ret < 0)
+ if (ret < 0) {
+ h0->first_field = 0;
return ret;
+ }
+
h->prev_frame_num++;
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->prev_frame_num;
context_count = 0;
}
- if (err < 0)
+ if (err < 0) {
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
- else if (err == 1) {
+ h->ref_count[0] = h->ref_count[1] = h->list_count = 0;
+ } else if (err == 1) {
/* Slice could not be decoded in parallel mode, copy down
* NAL unit stuff to context 0 and restart. Note that
* rbsp_buffer is not transferred, but since we no longer