summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_parser.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-01-20 00:57:18 -0300
committerJames Almer <jamrial@gmail.com>2018-01-30 12:13:20 -0300
commit222d7055e2dd20eb1381c257d34a50ec4c8dadb0 (patch)
treeeef41da326ef2037df87bd88417aa16770ba185d /libavcodec/hevc_parser.c
parent42323c3e3a600288e4bf1cefe952486ffc29d280 (diff)
avcodec/hevc_parser: use ff_hevc_decode_extradata() to parse extradata
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/hevc_parser.c')
-rw-r--r--libavcodec/hevc_parser.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 88d3d9a22f..a468682ed3 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -24,6 +24,7 @@
#include "golomb.h"
#include "hevc.h"
+#include "hevc_parse.h"
#include "hevc_ps.h"
#include "hevc_sei.h"
#include "h2645_parse.h"
@@ -43,6 +44,8 @@ typedef struct HEVCParserContext {
HEVCSEI sei;
SliceHeader sh;
+ int is_avc;
+ int nal_length_size;
int parsed_extradata;
int poc;
@@ -181,7 +184,6 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
HEVCParserContext *ctx = s->priv_data;
HEVCParamSets *ps = &ctx->ps;
HEVCSEI *sei = &ctx->sei;
- int is_global = buf == avctx->extradata;
int ret, i;
/* set some sane default values */
@@ -191,8 +193,8 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
ff_hevc_reset_sei(sei);
- ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
- AV_CODEC_ID_HEVC, 1);
+ ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, ctx->is_avc,
+ ctx->nal_length_size, AV_CODEC_ID_HEVC, 1);
if (ret < 0)
return ret;
@@ -230,12 +232,6 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
case HEVC_NAL_RADL_R:
case HEVC_NAL_RASL_N:
case HEVC_NAL_RASL_R:
-
- if (is_global) {
- av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type);
- return AVERROR_INVALIDDATA;
- }
-
ret = hevc_parse_slice_header(s, nal, avctx);
if (ret)
return ret;
@@ -243,8 +239,7 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
}
}
/* didn't find a picture! */
- if (!is_global)
- av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n");
+ av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n");
return -1;
}
@@ -301,7 +296,9 @@ static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
ParseContext *pc = &ctx->pc;
if (avctx->extradata && !ctx->parsed_extradata) {
- parse_nal_units(s, avctx->extradata, avctx->extradata_size, avctx);
+ ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size, &ctx->ps, &ctx->sei,
+ &ctx->is_avc, &ctx->nal_length_size, avctx->err_recognition,
+ 1, avctx);
ctx->parsed_extradata = 1;
}