diff mbox

[FFmpeg-devel,3/9] avformat/matroskaenc: Use smaller types

Message ID 20191015111737.14246-3-andreas.rheinhardt@gmail.com
State Withdrawn
Headers show

Commit Message

Andreas Rheinhardt Oct. 15, 2019, 11:17 a.m. UTC
Several members of structures denote offsets inside dynamic buffers and
therefore always fit into an int. So it is unnecessary to use an int64_t
for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/matroskaenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

James Almer Oct. 21, 2019, 11:43 p.m. UTC | #1
On 10/15/2019 8:17 AM, Andreas Rheinhardt wrote:
> Several members of structures denote offsets inside dynamic buffers and
> therefore always fit into an int. So it is unnecessary to use an int64_t
> for them.

True, but they are set using avio_tell() and then passed to avio_seek(),
both of which expect int64_t. This change may result in some pedantic
compilers warning about that conversion.

I don't really see the benefit in doing his. The struct size gains are
minimal.

> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/matroskaenc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 63ad6e47b4..e024c58c84 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -95,11 +95,11 @@ typedef struct mkv_track {
>      int             write_dts;
>      int             has_cue;
>      int             sample_rate;
> -    int64_t         sample_rate_offset;
> +    int             sample_rate_offset;
>      int64_t         last_timestamp;
>      int64_t         duration;
> -    int64_t         duration_offset;
> -    int64_t         codecpriv_offset;
> +    int             duration_offset;
> +    int             codecpriv_offset;
>      int64_t         ts_offset;
>  } mkv_track;
>  
> @@ -134,7 +134,7 @@ typedef struct MatroskaMuxContext {
>      AVIOContext     *cluster_bc;
>      int64_t         cluster_pos;        ///< file offset of the current cluster
>      int64_t         cluster_pts;
> -    int64_t         duration_offset;
> +    int             duration_offset;
>      int64_t         duration;
>      mkv_seekhead    *seekhead;
>      mkv_cues        *cues;
>
Andreas Rheinhardt Oct. 21, 2019, 11:45 p.m. UTC | #2
James Almer:
> On 10/15/2019 8:17 AM, Andreas Rheinhardt wrote:
>> Several members of structures denote offsets inside dynamic buffers and
>> therefore always fit into an int. So it is unnecessary to use an int64_t
>> for them.
> 
> True, but they are set using avio_tell() and then passed to avio_seek(),
> both of which expect int64_t. This change may result in some pedantic
> compilers warning about that conversion.
> 
> I don't really see the benefit in doing his. The struct size gains are
> minimal.
> 
Ok, I'll remove it.

- Andreas
Andreas Rheinhardt Oct. 22, 2019, 12:16 a.m. UTC | #3
On Tue, Oct 22, 2019 at 1:46 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> James Almer:
> > On 10/15/2019 8:17 AM, Andreas Rheinhardt wrote:
> >> Several members of structures denote offsets inside dynamic buffers and
> >> therefore always fit into an int. So it is unnecessary to use an int64_t
> >> for them.
> >
> > True, but they are set using avio_tell() and then passed to avio_seek(),
> > both of which expect int64_t. This change may result in some pedantic
> > compilers warning about that conversion.
> >
> > I don't really see the benefit in doing his. The struct size gains are
> > minimal.
> >
> Ok, I'll remove it.
>
> - Andreas
>
> None of the remaining patches need any modifications. So this patch can
just be skipped.

- Andreas
diff mbox

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 63ad6e47b4..e024c58c84 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -95,11 +95,11 @@  typedef struct mkv_track {
     int             write_dts;
     int             has_cue;
     int             sample_rate;
-    int64_t         sample_rate_offset;
+    int             sample_rate_offset;
     int64_t         last_timestamp;
     int64_t         duration;
-    int64_t         duration_offset;
-    int64_t         codecpriv_offset;
+    int             duration_offset;
+    int             codecpriv_offset;
     int64_t         ts_offset;
 } mkv_track;
 
@@ -134,7 +134,7 @@  typedef struct MatroskaMuxContext {
     AVIOContext     *cluster_bc;
     int64_t         cluster_pos;        ///< file offset of the current cluster
     int64_t         cluster_pts;
-    int64_t         duration_offset;
+    int             duration_offset;
     int64_t         duration;
     mkv_seekhead    *seekhead;
     mkv_cues        *cues;