Browse Source

avcodec/dynamic_hdr10_plus: don't take a GetBitContext as input argument

Create a local one instead from a byte buffer input argument.
This prevents skipping bytes that may belong to another SEI message.

Signed-off-by: James Almer <jamrial@gmail.com>
tags/n4.4
James Almer 4 years ago
parent
commit
1aa72fe794
3 changed files with 18 additions and 7 deletions
  1. +10
    -3
      libavcodec/dynamic_hdr10_plus.c
  2. +4
    -3
      libavcodec/dynamic_hdr10_plus.h
  3. +4
    -1
      libavcodec/hevc_sei.c

+ 10
- 3
libavcodec/dynamic_hdr10_plus.c View File

@@ -17,6 +17,7 @@
*/ */


#include "dynamic_hdr10_plus.h" #include "dynamic_hdr10_plus.h"
#include "get_bits.h"


static const uint8_t usa_country_code = 0xB5; static const uint8_t usa_country_code = 0xB5;
static const uint16_t smpte_provider_code = 0x003C; static const uint16_t smpte_provider_code = 0x003C;
@@ -30,11 +31,19 @@ static const int32_t knee_point_den = 4095;
static const int32_t bezier_anchor_den = 1023; static const int32_t bezier_anchor_den = 1023;
static const int32_t saturation_weight_den = 8; static const int32_t saturation_weight_den = 8;


int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(GetBitContext *gb, AVDynamicHDRPlus *s)
int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t *data,
int size)
{ {
GetBitContext gbc, *gb = &gbc;
int ret;

if (!s) if (!s)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);


ret = init_get_bits8(gb, data, size);
if (ret < 0)
return ret;

s->application_version = get_bits(gb, 8); s->application_version = get_bits(gb, 8);


if (get_bits_left(gb) < 2) if (get_bits_left(gb) < 2)
@@ -189,7 +198,5 @@ int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(GetBitContext *gb, AVDynamicHDRPlus
} }
} }


skip_bits(gb, get_bits_left(gb));

return 0; return 0;
} }

+ 4
- 3
libavcodec/dynamic_hdr10_plus.h View File

@@ -20,15 +20,16 @@
#define AVCODEC_DYNAMIC_HDR10_PLUS_H #define AVCODEC_DYNAMIC_HDR10_PLUS_H


#include "libavutil/hdr_dynamic_metadata.h" #include "libavutil/hdr_dynamic_metadata.h"
#include "get_bits.h"


/** /**
* Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus). * Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
* @param gb The bit content to be decoded.
* @param s A pointer containing the decoded AVDynamicHDRPlus structure. * @param s A pointer containing the decoded AVDynamicHDRPlus structure.
* @param data The byte array containing the raw ITU-T T.35 data.
* @param size Size of the data array in bytes.
* *
* @return 0 if succeed. Otherwise, returns the appropriate AVERROR. * @return 0 if succeed. Otherwise, returns the appropriate AVERROR.
*/ */
int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(GetBitContext *gb, AVDynamicHDRPlus *s);
int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t *data,
int size);


#endif /* AVCODEC_DYNAMIC_HDR10_PLUS_H */ #endif /* AVCODEC_DYNAMIC_HDR10_PLUS_H */

+ 4
- 1
libavcodec/hevc_sei.c View File

@@ -216,7 +216,8 @@ static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s
if (!metadata) if (!metadata)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);


err = ff_parse_itu_t_t35_to_dynamic_hdr10_plus(gb, metadata);
err = ff_parse_itu_t_t35_to_dynamic_hdr10_plus(metadata,
gb->buffer + get_bits_count(gb) / 8, size);
if (err < 0) { if (err < 0) {
av_free(metadata); av_free(metadata);
return err; return err;
@@ -229,6 +230,8 @@ static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }


skip_bits_long(gb, size * 8);

return 0; return 0;
} }




Loading…
Cancel
Save