summaryrefslogtreecommitdiffstats
path: root/libavcodec/extract_extradata_bsf.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-03-24 22:37:34 -0300
committerJames Almer <jamrial@gmail.com>2017-04-01 17:59:06 -0300
commitcbd25029399873ef6ff2c7344efbfb0c74b12e37 (patch)
tree61509e27e8ccdc329e96ab2ff15f95106c666c16 /libavcodec/extract_extradata_bsf.c
parent23ae3cc822915ede2bb4e85047ab46cc5bc71268 (diff)
downloadffmpeg-streaming-cbd25029399873ef6ff2c7344efbfb0c74b12e37.zip
ffmpeg-streaming-cbd25029399873ef6ff2c7344efbfb0c74b12e37.tar.gz
avcodec/extract_extradata_bsf: make sure all parameter set NAL units were found for h264/hevc
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/extract_extradata_bsf.c')
-rw-r--r--libavcodec/extract_extradata_bsf.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index 1e92f8e..4cd0ca1 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -65,7 +65,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
int extradata_size = 0;
const int *extradata_nal_types;
int nb_extradata_nal_types;
- int i, ret = 0;
+ int i, has_sps = 0, has_vps = 0, ret = 0;
if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
extradata_nal_types = extradata_nal_types_hevc;
@@ -82,11 +82,20 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
for (i = 0; i < h2645_pkt.nb_nals; i++) {
H2645NAL *nal = &h2645_pkt.nals[i];
- if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type))
+ if (val_in_array(extradata_nal_types, nb_extradata_nal_types, nal->type)) {
extradata_size += nal->raw_size + 3;
+ if (ctx->par_in->codec_id == AV_CODEC_ID_HEVC) {
+ if (nal->type == HEVC_NAL_SPS) has_sps = 1;
+ if (nal->type == HEVC_NAL_VPS) has_vps = 1;
+ } else {
+ if (nal->type == H264_NAL_SPS) has_sps = 1;
+ }
+ }
}
- if (extradata_size) {
+ if (extradata_size &&
+ ((ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) ||
+ (ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) {
AVBufferRef *filtered_buf;
uint8_t *extradata, *filtered_data;
OpenPOWER on IntegriCloud