diff options
author | Haihao Xiang <haihao.xiang@intel.com> | 2018-05-10 08:47:44 +0300 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2018-05-10 22:36:45 +0300 |
commit | 56ed01169269451b7bb327c6bb250eec36ee3de2 (patch) | |
tree | 87ad7bf0b4a707af59a932e738995e3119989b75 /libavcodec/cbs_h2645.c | |
parent | bed670a1de29b58fcb3fe046562d8bd125b1457f (diff) |
cbs_h265: read/write HEVC PREFIX SEI
Similar to H264, cbs_h265_{read, write}_nal_unit() can handle HEVC
prefix SEI NAL units. Currently mastering display colour volume SEI
message is added only, we may add more SEI message if needed later
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Diffstat (limited to 'libavcodec/cbs_h2645.c')
-rw-r--r-- | libavcodec/cbs_h2645.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 1ce42c6950..dd13d8ab5f 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -29,6 +29,7 @@ #include "h264_sei.h" #include "h2645_parse.h" #include "hevc.h" +#include "hevc_sei.h" static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc, @@ -483,6 +484,26 @@ static void cbs_h265_free_slice(void *unit, uint8_t *content) av_freep(&content); } +static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload) +{ + switch (payload->payload_type) { + case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO: + break; + default: + av_buffer_unref(&payload->payload.other.data_ref); + break; + } +} + +static void cbs_h265_free_sei(void *unit, uint8_t *content) +{ + H265RawSEI *sei = (H265RawSEI*)content; + int i; + for (i = 0; i < sei->payload_count; i++) + cbs_h265_free_sei_payload(&sei->payload[i]); + av_freep(&content); +} + static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const H2645Packet *packet) @@ -986,6 +1007,21 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, } break; + case HEVC_NAL_SEI_PREFIX: + { + err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(H265RawSEI), + &cbs_h265_free_sei); + + if (err < 0) + return err; + + err = cbs_h265_read_sei(ctx, &gbc, unit->content); + + if (err < 0) + return err; + } + break; + default: return AVERROR(ENOSYS); } @@ -1226,6 +1262,15 @@ static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx, } break; + case HEVC_NAL_SEI_PREFIX: + { + err = cbs_h265_write_sei(ctx, pbc, unit->content); + + if (err < 0) + return err; + } + break; + default: av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for " "NAL unit type %"PRIu32".\n", unit->type); |