1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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: Hendrik Leppkes <h.leppkes@gmail.com>
Reviewed-by: Aaron Levinson <alevinsn@aracnet.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2017-04-30 13:05:52 -03:00
parent bf1e3be5a3
commit 6a72578cc2
5 changed files with 27 additions and 15 deletions

View File

@ -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_H264PRED) += h264pred.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_HUFFMAN) += huffman.o
OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
@ -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_HAP_DECODER) += hapdec.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 \
hevcdsp.o hevc_filter.o hevc_data.o
OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o
@ -952,7 +952,7 @@ OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
OBJS-$(CONFIG_H263_PARSER) += h263_parser.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_MLP_PARSER) += mlp_parser.o mlp.o
OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \

View File

@ -22,8 +22,8 @@
#include "hevc_parse.h"
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,
int apply_defdispwin, void *logctx)
HEVCSEIContext *sei, int is_nalff, int nal_length_size,
int err_recognition, int apply_defdispwin, void *logctx)
{
int i;
int ret = 0;
@ -54,6 +54,12 @@ static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets
if (ret < 0)
goto done;
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:
av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n", nal->type);
break;
@ -69,8 +75,8 @@ done:
}
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
int *is_nalff, int *nal_length_size, int err_recognition,
int apply_defdispwin, void *logctx)
HEVCSEIContext *sei, int *is_nalff, int *nal_length_size,
int err_recognition, int apply_defdispwin, void *logctx)
{
int ret = 0;
GetByteContext gb;
@ -108,8 +114,9 @@ int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps,
return AVERROR_INVALIDDATA;
}
ret = hevc_decode_nal_units(gb.buffer, nalsize, ps, *is_nalff, *nal_length_size,
err_recognition, apply_defdispwin, logctx);
ret = hevc_decode_nal_units(gb.buffer, nalsize, ps, sei, *is_nalff,
*nal_length_size, err_recognition, apply_defdispwin,
logctx);
if (ret < 0) {
av_log(logctx, AV_LOG_ERROR,
"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,
*nal_length_size = nal_len_size;
} else {
*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);
if (ret < 0)
return ret;

View File

@ -24,10 +24,13 @@
#ifndef 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 *is_nalff, int *nal_length_size, int err_recognition,
int apply_defdispwin, void *logctx);
HEVCSEIContext *sei, int *is_nalff, int *nal_length_size,
int err_recognition, int apply_defdispwin, void *logctx);
#endif /* AVCODEC_HEVC_PARSE_H */

View File

@ -3005,7 +3005,7 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length)
{
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->apply_defdispwin, s->avctx);
if (ret < 0)

View File

@ -185,6 +185,7 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
int ret;
HEVCParamSets ps;
HEVCSEIContext sei;
const HEVCVPS *vps = NULL;
const HEVCPPS *pps = NULL;
@ -200,9 +201,10 @@ static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
int pps_data_size = 0;
memset(&ps, 0, sizeof(ps));
memset(&sei, 0, sizeof(sei));
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) {
goto done;
}