diff mbox series

[FFmpeg-devel,2/3] avformat/matroskaenc: Remove pointless casts

Message ID 20200522012431.29918-2-andreas.rheinhardt@gmail.com
State Accepted
Commit 72baae1395deefa64e06b6c1a88de04082695a57
Headers show
Series [FFmpeg-devel,1/3] avformat/matroskaenc: Don't use stream side-data size
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 22, 2020, 1:24 a.m. UTC
by using a const void * pointer as an intermediate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Why is the side-data API (both the packet as well as the stream one)
actually based around uint8_t * and not pointers to void despite
side-data being mostly structures and not just buffers?

 libavformat/matroskaenc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

James Almer May 22, 2020, 3:41 a.m. UTC | #1
On 5/21/2020 10:24 PM, Andreas Rheinhardt wrote:
> by using a const void * pointer as an intermediate.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> Why is the side-data API (both the packet as well as the stream one)
> actually based around uint8_t * and not pointers to void despite
> side-data being mostly structures and not just buffers?

uint8_t* is ubiquitous in the codebase for pointers to allocated data.
And if you look at the early side data types (palette, new extradata),
it's not surprising they were defined this way (Assuming these functions
are as old as the very first side data types).

> 
>  libavformat/matroskaenc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index f5968c17b4..9ad590cb93 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -836,7 +836,7 @@ static void mkv_write_video_color(AVIOContext *pb, const AVStream *st,
>      uint8_t colour[(2 + 1 + 8) * 18 + (2 + 1) + 1];
>      AVIOContext buf, *dyn_cp = &buf;
>      int colorinfo_size;
> -    const uint8_t *side_data;
> +    const void *side_data;
>  
>      ffio_init_context(dyn_cp, colour, sizeof(colour), 1, NULL, NULL, NULL, NULL);
>  
> @@ -869,8 +869,7 @@ static void mkv_write_video_color(AVIOContext *pb, const AVStream *st,
>      side_data = av_stream_get_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
>                                          NULL);
>      if (side_data) {
> -        const AVContentLightMetadata *metadata =
> -            (const AVContentLightMetadata*)side_data;
> +        const AVContentLightMetadata *metadata = side_data;
>          put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORMAXCLL,  metadata->MaxCLL);
>          put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORMAXFALL, metadata->MaxFALL);
>      }
> @@ -880,8 +879,7 @@ static void mkv_write_video_color(AVIOContext *pb, const AVStream *st,
>      if (side_data) {
>          ebml_master meta_element = start_ebml_master(
>              dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 10 * (2 + 1 + 8));
> -        const AVMasteringDisplayMetadata *metadata =
> -            (const AVMasteringDisplayMetadata*)side_data;
> +        const AVMasteringDisplayMetadata *metadata = side_data;
>          if (metadata->has_primaries) {
>              put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOCOLOR_RX,
>                             av_q2d(metadata->display_primaries[0][0]));
>
diff mbox series

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f5968c17b4..9ad590cb93 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -836,7 +836,7 @@  static void mkv_write_video_color(AVIOContext *pb, const AVStream *st,
     uint8_t colour[(2 + 1 + 8) * 18 + (2 + 1) + 1];
     AVIOContext buf, *dyn_cp = &buf;
     int colorinfo_size;
-    const uint8_t *side_data;
+    const void *side_data;
 
     ffio_init_context(dyn_cp, colour, sizeof(colour), 1, NULL, NULL, NULL, NULL);
 
@@ -869,8 +869,7 @@  static void mkv_write_video_color(AVIOContext *pb, const AVStream *st,
     side_data = av_stream_get_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
                                         NULL);
     if (side_data) {
-        const AVContentLightMetadata *metadata =
-            (const AVContentLightMetadata*)side_data;
+        const AVContentLightMetadata *metadata = side_data;
         put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORMAXCLL,  metadata->MaxCLL);
         put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORMAXFALL, metadata->MaxFALL);
     }
@@ -880,8 +879,7 @@  static void mkv_write_video_color(AVIOContext *pb, const AVStream *st,
     if (side_data) {
         ebml_master meta_element = start_ebml_master(
             dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 10 * (2 + 1 + 8));
-        const AVMasteringDisplayMetadata *metadata =
-            (const AVMasteringDisplayMetadata*)side_data;
+        const AVMasteringDisplayMetadata *metadata = side_data;
         if (metadata->has_primaries) {
             put_ebml_float(dyn_cp, MATROSKA_ID_VIDEOCOLOR_RX,
                            av_q2d(metadata->display_primaries[0][0]));