diff mbox

[FFmpeg-devel] avformat: move priv_pts from AVStream to an internal struct

Message ID 20171105180656.4004-1-jamrial@gmail.com
State Accepted
Commit cd1ff3e45d45ce8d733b4acc8e23444c1a227d07
Headers show

Commit Message

James Almer Nov. 5, 2017, 6:06 p.m. UTC
It has no reason to be in a public header, even if defined as private.

Signed-off-by: James Almer <jamrial@gmail.com>
---
To be honest, none of the fields below the "not part of the API" notice
have any reason to be in the public struct, but this one is particularly
pointless and ugly to have there as FFFrac is defined in internal.h

 libavformat/avformat.h |  2 --
 libavformat/internal.h |  2 ++
 libavformat/mux.c      | 18 +++++++++---------
 libavformat/utils.c    |  6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)

Comments

Michael Niedermayer Nov. 6, 2017, 11:43 p.m. UTC | #1
On Sun, Nov 05, 2017 at 03:06:56PM -0300, James Almer wrote:
> It has no reason to be in a public header, even if defined as private.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> To be honest, none of the fields below the "not part of the API" notice
> have any reason to be in the public struct, but this one is particularly
> pointless and ugly to have there as FFFrac is defined in internal.h
> 
>  libavformat/avformat.h |  2 --
>  libavformat/internal.h |  2 ++
>  libavformat/mux.c      | 18 +++++++++---------
>  libavformat/utils.c    |  6 +++---
>  4 files changed, 14 insertions(+), 14 deletions(-)

probably ok

thx

[...]
James Almer Nov. 8, 2017, 2:22 a.m. UTC | #2
On 11/6/2017 8:43 PM, Michael Niedermayer wrote:
> On Sun, Nov 05, 2017 at 03:06:56PM -0300, James Almer wrote:
>> It has no reason to be in a public header, even if defined as private.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> To be honest, none of the fields below the "not part of the API" notice
>> have any reason to be in the public struct, but this one is particularly
>> pointless and ugly to have there as FFFrac is defined in internal.h
>>
>>  libavformat/avformat.h |  2 --
>>  libavformat/internal.h |  2 ++
>>  libavformat/mux.c      | 18 +++++++++---------
>>  libavformat/utils.c    |  6 +++---
>>  4 files changed, 14 insertions(+), 14 deletions(-)
> 
> probably ok
> 
> thx

Pushed, thanks.
diff mbox

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index b36e2a3bd4..c068aa8009 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1200,8 +1200,6 @@  typedef struct AVStream {
      */
     AVRational display_aspect_ratio;
 
-    struct FFFrac *priv_pts;
-
     /**
      * An opaque field for libavformat internal usage.
      * Must not be accessed in any way by callers.
diff --git a/libavformat/internal.h b/libavformat/internal.h
index d136c79bdd..fcd47840a5 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -196,6 +196,8 @@  struct AVStreamInternal {
      * Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
      */
     int need_context_update;
+
+    FFFrac *priv_pts;
 };
 
 #ifdef __GNUC__
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 1445e7dcd6..b1244c67f3 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -432,16 +432,16 @@  static int init_pts(AVFormatContext *s)
             break;
         }
 
-        if (!st->priv_pts)
-            st->priv_pts = av_mallocz(sizeof(*st->priv_pts));
-        if (!st->priv_pts)
+        if (!st->internal->priv_pts)
+            st->internal->priv_pts = av_mallocz(sizeof(*st->internal->priv_pts));
+        if (!st->internal->priv_pts)
             return AVERROR(ENOMEM);
 
         if (den != AV_NOPTS_VALUE) {
             if (den <= 0)
                 return AVERROR_INVALIDDATA;
 
-            frac_init(st->priv_pts, 0, 0, den);
+            frac_init(st->internal->priv_pts, 0, 0, den);
         }
     }
 
@@ -601,7 +601,7 @@  static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
         }
         pkt->dts =
 //        pkt->pts= st->cur_dts;
-            pkt->pts = st->priv_pts->val;
+            pkt->pts = st->internal->priv_pts->val;
     }
 
     //calculate dts from pts
@@ -638,7 +638,7 @@  static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
             av_ts2str(pkt->pts), av_ts2str(pkt->dts));
 
     st->cur_dts = pkt->dts;
-    st->priv_pts->val = pkt->dts;
+    st->internal->priv_pts->val = pkt->dts;
 
     /* update pts */
     switch (st->codecpar->codec_type) {
@@ -650,12 +650,12 @@  static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
         /* HACK/FIXME, we skip the initial 0 size packets as they are most
          * likely equal to the encoder delay, but it would be better if we
          * had the real timestamps from the encoder */
-        if (frame_size >= 0 && (pkt->size || st->priv_pts->num != st->priv_pts->den >> 1 || st->priv_pts->val)) {
-            frac_add(st->priv_pts, (int64_t)st->time_base.den * frame_size);
+        if (frame_size >= 0 && (pkt->size || st->internal->priv_pts->num != st->internal->priv_pts->den >> 1 || st->internal->priv_pts->val)) {
+            frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * frame_size);
         }
         break;
     case AVMEDIA_TYPE_VIDEO:
-        frac_add(st->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
+        frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
         break;
     }
     return 0;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cbfb78bf4d..2b2411ffe7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -123,8 +123,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
 
 int64_t av_stream_get_end_pts(const AVStream *st)
 {
-    if (st->priv_pts) {
-        return st->priv_pts->val;
+    if (st->internal->priv_pts) {
+        return st->internal->priv_pts->val;
     } else
         return AV_NOPTS_VALUE;
 }
@@ -4263,6 +4263,7 @@  static void free_stream(AVStream **pst)
             av_bsf_free(&st->internal->bsfcs[i]);
             av_freep(&st->internal->bsfcs);
         }
+        av_freep(&st->internal->priv_pts);
         av_bsf_free(&st->internal->extract_extradata.bsf);
         av_packet_free(&st->internal->extract_extradata.pkt);
     }
@@ -4282,7 +4283,6 @@  FF_ENABLE_DEPRECATION_WARNINGS
         av_freep(&st->info->duration_error);
     av_freep(&st->info);
     av_freep(&st->recommended_encoder_configuration);
-    av_freep(&st->priv_pts);
 
     av_freep(pst);
 }