[FFmpeg-cvslog] avcodec/hevc_parse: decode SEI message NALUs in extradata

James Almer git at videolan.org
Fri May 5 23:53:21 EEST 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Apr 30 13:05:52 2017 -0300| [6a72578cc21ec608f3c2d8a8e5904e93284b3277] | committer: 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: Hendrik Leppkes <h.leppkes at gmail.com>
Reviewed-by: Aaron Levinson <alevinsn at aracnet.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a72578cc21ec608f3c2d8a8e5904e93284b3277
---

 libavcodec/Makefile        |  6 +++---
 libavcodec/hevc_parse.c    | 21 ++++++++++++++-------
 libavcodec/hevc_parse.h    |  9 ++++++---
 libavcodec/hevcdec.c       |  2 +-
 libavcodec/mediacodecdec.c |  4 +++-
 5 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 79a18e0505..b5c8cc1f98 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -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 \
diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
index ee4cd54d3e..1122a60af3 100644
--- a/libavcodec/hevc_parse.c
+++ b/libavcodec/hevc_parse.c
@@ -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;
diff --git a/libavcodec/hevc_parse.h b/libavcodec/hevc_parse.h
index 8aa46a290a..02e1d5b324 100644
--- a/libavcodec/hevc_parse.h
+++ b/libavcodec/hevc_parse.h
@@ -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 */
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 8f235b0be1..ee001fd9f2 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -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)
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 6fd0db2fa5..ccfcb4b9ce 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -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;
     }



More information about the ffmpeg-cvslog mailing list