aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-12-06 11:04:05 -0300
committerJames Almer <jamrial@gmail.com>2020-12-07 14:22:52 -0300
commit32bbca07d74d2bf9ebf6ff881be20e7e7afded1a (patch)
treeeaa9c07b9b3528f9e35f64d03fa80c71cd4cdf8d
parentfcae745f46840416f448639ec34024b07d653ccd (diff)
downloadffmpeg-32bbca07d74d2bf9ebf6ff881be20e7e7afded1a.tar.gz
avcodec/hevc_sei: split Dynamic HDR10+ SEI parsing into its own function
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/hevc_sei.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 8a29181a31..8af9f9b29d 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -207,6 +207,31 @@ static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, GetBitC
return 0;
}
+static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s,
+ GetBitContext *gb, int size)
+{
+ size_t meta_size;
+ int err;
+ AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
+ if (!metadata)
+ return AVERROR(ENOMEM);
+
+ err = ff_parse_itu_t_t35_to_dynamic_hdr10_plus(gb, metadata);
+ if (err < 0) {
+ av_free(metadata);
+ return err;
+ }
+
+ av_buffer_unref(&s->info);
+ s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
+ if (!s->info) {
+ av_free(metadata);
+ return AVERROR(ENOMEM);
+ }
+
+ return 0;
+}
+
static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitContext *gb,
int size)
{
@@ -239,25 +264,7 @@ static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetBitConte
if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
application_identifier == smpte2094_40_application_identifier) {
- int err = 0;
- size_t meta_size = 0;
- AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
- if (!metadata)
- return AVERROR(ENOMEM);
-
- err = ff_parse_itu_t_t35_to_dynamic_hdr10_plus(gb, metadata);
- if (err < 0) {
- av_free(metadata);
- return err;
- }
-
- av_buffer_unref(&s->dynamic_hdr_plus.info);
- s->dynamic_hdr_plus.info = av_buffer_create((uint8_t *)metadata,
- meta_size, NULL, NULL, 0);
- if (!s->dynamic_hdr_plus.info) {
- av_free(metadata);
- return AVERROR(ENOMEM);
- }
+ return decode_registered_user_data_dynamic_hdr_plus(&s->dynamic_hdr_plus, gb, size);
}
} else {
uint32_t user_identifier = get_bits_long(gb, 32);