[FFmpeg-devel] [PATCH v3 02/18] cbs: Ensure that reference fields always follow the associated pointer

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Oct 8 14:33:00 EEST 2019


Mark Thompson:
> Hvaing these together allows us to find both pointers given the address
> of only one of them.
> ---
>  libavcodec/cbs_av1.h   |  6 +++---
>  libavcodec/cbs_h264.h  | 18 +++++++++---------
>  libavcodec/cbs_h265.h  | 16 ++++++++--------
>  libavcodec/cbs_jpeg.h  |  2 +-
>  libavcodec/cbs_mpeg2.h | 10 +++++-----
>  libavcodec/cbs_vp9.h   |  2 +-
>  6 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
> index 1fb668ada4..a87cbc030b 100644
> --- a/libavcodec/cbs_av1.h
> +++ b/libavcodec/cbs_av1.h
> @@ -284,8 +284,8 @@ typedef struct AV1RawFrameHeader {
>  
>  typedef struct AV1RawTileData {
>      uint8_t     *data;
> -    size_t       data_size;
>      AVBufferRef *data_ref;
> +    size_t       data_size;
>  } AV1RawTileData;
>  
>  typedef struct AV1RawTileGroup {
> @@ -346,8 +346,8 @@ typedef struct AV1RawMetadataITUTT35 {
>      uint8_t itu_t_t35_country_code_extension_byte;
>  
>      uint8_t     *payload;
> -    size_t       payload_size;
>      AVBufferRef *payload_ref;
> +    size_t       payload_size;
>  } AV1RawMetadataITUTT35;
>  
>  typedef struct AV1RawMetadataTimecode {
> @@ -379,8 +379,8 @@ typedef struct AV1RawMetadata {
>  
>  typedef struct AV1RawPadding {
>      uint8_t     *payload;
> -    size_t       payload_size;
>      AVBufferRef *payload_ref;
> +    size_t       payload_size;
>  } AV1RawPadding;
>  
>  
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index 9f7c2a0d30..65659ae52c 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -277,16 +277,16 @@ typedef struct H264RawSEIPanScanRect {
>  typedef struct H264RawSEIUserDataRegistered {
>      uint8_t itu_t_t35_country_code;
>      uint8_t itu_t_t35_country_code_extension_byte;
> -    uint8_t *data;
> -    size_t data_length;
> +    uint8_t     *data;
>      AVBufferRef *data_ref;
> +    size_t       data_length;
>  } H264RawSEIUserDataRegistered;
>  
>  typedef struct H264RawSEIUserDataUnregistered {
>      uint8_t uuid_iso_iec_11578[16];
> -    uint8_t *data;
> -    size_t data_length;
> +    uint8_t     *data;
>      AVBufferRef *data_ref;
> +    size_t       data_length;
>  } H264RawSEIUserDataUnregistered;
>  
>  typedef struct H264RawSEIRecoveryPoint {
> @@ -334,9 +334,9 @@ typedef struct H264RawSEIPayload {
>          H264RawSEIAlternativeTransferCharacteristics
>              alternative_transfer_characteristics;
>          struct {
> -            uint8_t *data;
> -            size_t data_length;
> +            uint8_t     *data;
>              AVBufferRef *data_ref;
> +            size_t       data_length;
>          } other;
>      } payload;
>  } H264RawSEIPayload;
> @@ -429,10 +429,10 @@ typedef struct H264RawSliceHeader {
>  typedef struct H264RawSlice {
>      H264RawSliceHeader header;
>  
> -    uint8_t *data;
> -    size_t   data_size;
> -    int      data_bit_start;
> +    uint8_t     *data;
>      AVBufferRef *data_ref;
> +    size_t       data_size;
> +    int          data_bit_start;
>  } H264RawSlice;
>  
>  typedef struct H264RawFiller {
> diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
> index ad746bf35f..f5eb5af5b2 100644
> --- a/libavcodec/cbs_h265.h
> +++ b/libavcodec/cbs_h265.h
> @@ -184,8 +184,8 @@ typedef struct H265RawVUI {
>  
>  typedef struct H265RawPSExtensionData {
>      uint8_t *data;
> -    size_t bit_length;
>      AVBufferRef *data_ref;
> +    size_t bit_length;
>  } H265RawPSExtensionData;
>  
>  typedef struct H265RawVPS {
> @@ -541,10 +541,10 @@ typedef struct  H265RawSliceHeader {
>  typedef struct H265RawSlice {
>      H265RawSliceHeader header;
>  
> -    uint8_t *data;
> -    size_t   data_size;
> -    int      data_bit_start;
> +    uint8_t     *data;
>      AVBufferRef *data_ref;
> +    size_t       data_size;
> +    int          data_bit_start;
>  } H265RawSlice;
>  
>  
> @@ -600,15 +600,15 @@ typedef struct H265RawSEIUserDataRegistered {
>      uint8_t itu_t_t35_country_code;
>      uint8_t itu_t_t35_country_code_extension_byte;
>      uint8_t     *data;
> -    size_t       data_length;
>      AVBufferRef *data_ref;
> +    size_t       data_length;
>  } H265RawSEIUserDataRegistered;
>  
>  typedef struct H265RawSEIUserDataUnregistered {
>      uint8_t uuid_iso_iec_11578[16];
>      uint8_t     *data;
> -    size_t       data_length;
>      AVBufferRef *data_ref;
> +    size_t       data_length;
>  } H265RawSEIUserDataUnregistered;
>  
>  typedef struct H265RawSEIRecoveryPoint {
> @@ -710,9 +710,9 @@ typedef struct H265RawSEIPayload {
>              alternative_transfer_characteristics;
>          H265RawSEIAlphaChannelInfo alpha_channel_info;
>          struct {
> -            uint8_t *data;
> -            size_t data_length;
> +            uint8_t     *data;
>              AVBufferRef *data_ref;
> +            size_t       data_length;
>          } other;
>      } payload;
>  } H265RawSEIPayload;
> diff --git a/libavcodec/cbs_jpeg.h b/libavcodec/cbs_jpeg.h
> index 913d3f90f6..d51c83845b 100644
> --- a/libavcodec/cbs_jpeg.h
> +++ b/libavcodec/cbs_jpeg.h
> @@ -80,8 +80,8 @@ typedef struct JPEGRawScanHeader {
>  typedef struct JPEGRawScan {
>      JPEGRawScanHeader header;
>      uint8_t          *data;
> -    size_t            data_size;
>      AVBufferRef      *data_ref;
> +    size_t            data_size;
>  } JPEGRawScan;
>  
>  typedef struct JPEGRawQuantisationTable {
> diff --git a/libavcodec/cbs_mpeg2.h b/libavcodec/cbs_mpeg2.h
> index 118e63d804..f21605a40f 100644
> --- a/libavcodec/cbs_mpeg2.h
> +++ b/libavcodec/cbs_mpeg2.h
> @@ -76,9 +76,9 @@ typedef struct MPEG2RawSequenceHeader {
>  typedef struct MPEG2RawUserData {
>      uint8_t user_data_start_code;
>  
> -    uint8_t *user_data;
> -    size_t user_data_length;
> +    uint8_t     *user_data;
>      AVBufferRef *user_data_ref;
> +    size_t       user_data_length;
>  } MPEG2RawUserData;
>  
>  typedef struct MPEG2RawSequenceExtension {
> @@ -206,10 +206,10 @@ typedef struct MPEG2RawSliceHeader {
>  typedef struct MPEG2RawSlice {
>      MPEG2RawSliceHeader header;
>  
> -    uint8_t *data;
> -    size_t   data_size;
> -    int      data_bit_start;
> +    uint8_t     *data;
>      AVBufferRef *data_ref;
> +    size_t       data_size;
> +    int          data_bit_start;
>  } MPEG2RawSlice;
>  
>  typedef struct MPEG2RawSequenceEnd {
> diff --git a/libavcodec/cbs_vp9.h b/libavcodec/cbs_vp9.h
> index 4c9b2f880d..39db41cd6b 100644
> --- a/libavcodec/cbs_vp9.h
> +++ b/libavcodec/cbs_vp9.h
> @@ -165,8 +165,8 @@ typedef struct VP9RawFrame {
>      VP9RawFrameHeader header;
>  
>      uint8_t     *data;
> -    size_t       data_size;
>      AVBufferRef *data_ref;
> +    size_t       data_size;
>  } VP9RawFrame;
>  
>  typedef struct VP9RawSuperframeIndex {
> 
How about adding a new struct that contains a pointer to a data buffer
and an AVBufferRef * for said buffer (and maybe also the size field)?
This should simplify cbs_clone_unit_content. The allocate macros would
have to be changed and also the calls to read/write the actual data,
of course.

- Andreas


More information about the ffmpeg-devel mailing list