Commit 6a72578c authored by James Almer's avatar James Almer

avcodec/hevc_parse: decode SEI message NALUs in extradata

They may be available in hvcc style extradata.

Based on a patch by Hendrik Leppkes.
Reviewed-by: 's avatarHendrik Leppkes <h.leppkes@gmail.com>
Reviewed-by: 's avatarAaron Levinson <alevinsn@aracnet.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent bf1e3be5
...@@ -79,7 +79,7 @@ OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o ...@@ -79,7 +79,7 @@ OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o
OBJS-$(CONFIG_H264PRED) += h264pred.o OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o OBJS-$(CONFIG_H264QPEL) += h264qpel.o
OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_sei.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o OBJS-$(CONFIG_HUFFMAN) += huffman.o
OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
...@@ -337,7 +337,7 @@ OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o vaapi_encode_h26x. ...@@ -337,7 +337,7 @@ OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o vaapi_encode_h26x.
OBJS-$(CONFIG_H264_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o OBJS-$(CONFIG_H264_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o
OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o
OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o hevc_sei.o \ OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \
hevc_cabac.o hevc_refs.o hevcpred.o \ hevc_cabac.o hevc_refs.o hevcpred.o \
hevcdsp.o hevc_filter.o hevc_data.o hevcdsp.o hevc_filter.o hevc_data.o
OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o
...@@ -952,7 +952,7 @@ OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o ...@@ -952,7 +952,7 @@ OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
OBJS-$(CONFIG_H263_PARSER) += h263_parser.o OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o hevc_sei.o OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o
OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o
OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "hevc_parse.h" #include "hevc_parse.h"
static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps, static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets *ps,
int is_nalff, int nal_length_size, int err_recognition, HEVCSEIContext *sei, int is_nalff, int nal_length_size,
int apply_defdispwin, void *logctx) int err_recognition, int apply_defdispwin, void *logctx)
{ {
int i; int i;
int ret = 0; int ret = 0;
...@@ -54,6 +54,12 @@ static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets ...@@ -54,6 +54,12 @@ static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets
if (ret < 0) if (ret < 0)
goto done; goto done;
break; break;
case HEVC_NAL_SEI_PREFIX:
case HEVC_NAL_SEI_SUFFIX:
ret = ff_hevc_decode_nal_sei(&nal->gb, logctx, sei, ps, nal->type);
if (ret < 0)
goto done;
break;
default: default:
av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type); av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type);
break; break;
...@@ -69,8 +75,8 @@ done: ...@@ -69,8 +75,8 @@ done:
} }
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
int *is_nalff, int *nal_length_size, int err_recognition, HEVCSEIContext *sei, int *is_nalff, int *nal_length_size,
int apply_defdispwin, void *logctx) int err_recognition, int apply_defdispwin, void *logctx)
{ {
int ret = 0; int ret = 0;
GetByteContext gb; GetByteContext gb;
...@@ -108,8 +114,9 @@ int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, ...@@ -108,8 +114,9 @@ int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
ret = hevc_decode_nal_units(gb.buffer, nalsize, ps, *is_nalff, *nal_length_size, ret = hevc_decode_nal_units(gb.buffer, nalsize, ps, sei, *is_nalff,
err_recognition, apply_defdispwin, logctx); *nal_length_size, err_recognition, apply_defdispwin,
logctx);
if (ret < 0) { if (ret < 0) {
av_log(logctx, AV_LOG_ERROR, av_log(logctx, AV_LOG_ERROR,
"Decoding nal unit %d %d from hvcC failed\n", "Decoding nal unit %d %d from hvcC failed\n",
...@@ -125,7 +132,7 @@ int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, ...@@ -125,7 +132,7 @@ int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
*nal_length_size = nal_len_size; *nal_length_size = nal_len_size;
} else { } else {
*is_nalff = 0; *is_nalff = 0;
ret = hevc_decode_nal_units(data, size, ps, *is_nalff, *nal_length_size, ret = hevc_decode_nal_units(data, size, ps, sei, *is_nalff, *nal_length_size,
err_recognition, apply_defdispwin, logctx); err_recognition, apply_defdispwin, logctx);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -24,10 +24,13 @@ ...@@ -24,10 +24,13 @@
#ifndef AVCODEC_HEVC_PARSE_H #ifndef AVCODEC_HEVC_PARSE_H
#define AVCODEC_HEVC_PARSE_H #define AVCODEC_HEVC_PARSE_H
#include "hevcdec.h" #include <stdint.h>
#include "hevc_ps.h"
#include "hevc_sei.h"
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
int *is_nalff, int *nal_length_size, int err_recognition, HEVCSEIContext *sei, int *is_nalff, int *nal_length_size,
int apply_defdispwin, void *logctx); int err_recognition, int apply_defdispwin, void *logctx);
#endif /* AVCODEC_HEVC_PARSE_H */ #endif /* AVCODEC_HEVC_PARSE_H */
...@@ -3005,7 +3005,7 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length) ...@@ -3005,7 +3005,7 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
{ {
int ret, i; int ret, i;
ret = ff_hevc_decode_extradata(buf, length, &s->ps, &s->is_nalff, ret = ff_hevc_decode_extradata(buf, length, &s->ps, &s->sei, &s->is_nalff,
&s->nal_length_size, s->avctx->err_recognition, &s->nal_length_size, s->avctx->err_recognition,
s->apply_defdispwin, s->avctx); s->apply_defdispwin, s->avctx);
if (ret < 0) if (ret < 0)
......
...@@ -185,6 +185,7 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format) ...@@ -185,6 +185,7 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
int ret; int ret;
HEVCParamSets ps; HEVCParamSets ps;
HEVCSEIContext sei;
const HEVCVPS *vps = NULL; const HEVCVPS *vps = NULL;
const HEVCPPS *pps = NULL; const HEVCPPS *pps = NULL;
...@@ -200,9 +201,10 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format) ...@@ -200,9 +201,10 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
int pps_data_size = 0; int pps_data_size = 0;
memset(&ps, 0, sizeof(ps)); memset(&ps, 0, sizeof(ps));
memset(&sei, 0, sizeof(sei));
ret = ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size, ret = ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size,
&ps, &is_nalff, &nal_length_size, 0, 1, avctx); &ps, &sei, &is_nalff, &nal_length_size, 0, 1, avctx);
if (ret < 0) { if (ret < 0) {
goto done; goto done;
} }
......
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