summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_parser.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-19 02:50:06 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-19 03:24:25 +0200
commit54882156dd091ce3113a2ad5d977f93a1acd7907 (patch)
tree839354532d956875a88c989d21f0600354ce0280 /libavcodec/hevc_parser.c
parentbd487645327b207e27aa76b4b30319e1a20d4731 (diff)
downloadffmpeg-54882156dd091ce3113a2ad5d977f93a1acd7907.tar.gz
avcodec/hevc_parser: Treat extradata parsing differently, as it should not contain an AU
Fixes ticket4718 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/hevc_parser.c')
-rw-r--r--libavcodec/hevc_parser.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 8b232440b9..f970de5474 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -115,7 +115,13 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
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 NAL_RASL_R:
+ if (buf == avctx->extradata) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type);
+ return AVERROR_INVALIDDATA;
+ }
+ hevc_parse_slice_header(s, nal, avctx);
+ break;
}
}
@@ -187,6 +193,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
const uint8_t *buf_end = buf + buf_size;
int state = -1, i;
HEVCNAL *nal;
+ int is_global = buf == avctx->extradata;
if (!h->HEVClc)
h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
@@ -266,6 +273,12 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
case NAL_IDR_W_RADL:
case NAL_IDR_N_LP:
case NAL_CRA_NUT:
+
+ if (is_global) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", h->nal_unit_type);
+ return AVERROR_INVALIDDATA;
+ }
+
sh->first_slice_in_pic_flag = get_bits1(gb);
s->picture_structure = h->picture_struct;
s->field_order = h->picture_struct;
@@ -354,7 +367,8 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
buf += consumed;
}
/* didn't find a picture! */
- av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");
+ if (!is_global)
+ av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");
return -1;
}
#endif