diff mbox series

[FFmpeg-devel,2/2] avformat/mpegtsenc: first dts check needed

Message ID 1603848684-32691-2-git-send-email-lance.lmwang@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,1/2] avformat/mpegtsenc: first_pts_check -> first_pts_checked | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Lance Wang Oct. 28, 2020, 1:31 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/mpegtsenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Marton Balint Oct. 28, 2020, 8:04 p.m. UTC | #1
On Wed, 28 Oct 2020, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/mpegtsenc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 383181d..acc8c32 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -233,6 +233,7 @@ typedef struct MpegTSWriteStream {
>     int discontinuity;
>     int payload_size;
>     int first_pts_checked; ///< first pts check needed
> +    int first_dts_checked; ///< first dts check needed

You don't need a separete variable for this, you can use 
first_pts_checked for this purpose as well. Obviously its condition should 
be changed to this:

if (!ts_st->first_pts_checked && (pts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE))

You can rename the variable to first_timestamp_checked if you dislike that 
the variable has pts but it is also used for dts.

Regards,
Marton


>     int prev_payload_key;
>     int64_t payload_pts;
>     int64_t payload_dts;
> @@ -1705,6 +1706,12 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
>     }
>     ts_st->first_pts_checked = 1;
> 
> +    if (!ts_st->first_dts_checked && dts == AV_NOPTS_VALUE) {
> +        av_log(s, AV_LOG_ERROR, "first dts value must be set\n");
> +        return AVERROR_INVALIDDATA;
> +    }
> +    ts_st->first_dts_checked = 1;
> +
>     if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
>         const uint8_t *p = buf, *buf_end = p + size;
>         uint32_t state = -1;
> -- 
> 1.8.3.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Lance Wang Oct. 29, 2020, 1:06 a.m. UTC | #2
On Wed, Oct 28, 2020 at 09:04:25PM +0100, Marton Balint wrote:
> 
> 
> On Wed, 28 Oct 2020, lance.lmwang@gmail.com wrote:
> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> > libavformat/mpegtsenc.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> > 
> > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> > index 383181d..acc8c32 100644
> > --- a/libavformat/mpegtsenc.c
> > +++ b/libavformat/mpegtsenc.c
> > @@ -233,6 +233,7 @@ typedef struct MpegTSWriteStream {
> >     int discontinuity;
> >     int payload_size;
> >     int first_pts_checked; ///< first pts check needed
> > +    int first_dts_checked; ///< first dts check needed
> 
> You don't need a separete variable for this, you can use first_pts_checked
> for this purpose as well. Obviously its condition should be changed to this:
> 
> if (!ts_st->first_pts_checked && (pts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE))
> 
> You can rename the variable to first_timestamp_checked if you dislike that
> the variable has pts but it is also used for dts.

Sure, then I prefer to change the variable name to first_timestamp_checked. will
update the patch.

> 
> Regards,
> Marton
> 
> 
> >     int prev_payload_key;
> >     int64_t payload_pts;
> >     int64_t payload_dts;
> > @@ -1705,6 +1706,12 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
> >     }
> >     ts_st->first_pts_checked = 1;
> > 
> > +    if (!ts_st->first_dts_checked && dts == AV_NOPTS_VALUE) {
> > +        av_log(s, AV_LOG_ERROR, "first dts value must be set\n");
> > +        return AVERROR_INVALIDDATA;
> > +    }
> > +    ts_st->first_dts_checked = 1;
> > +
> >     if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
> >         const uint8_t *p = buf, *buf_end = p + size;
> >         uint32_t state = -1;
> > -- 
> > 1.8.3.1
> > 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 383181d..acc8c32 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -233,6 +233,7 @@  typedef struct MpegTSWriteStream {
     int discontinuity;
     int payload_size;
     int first_pts_checked; ///< first pts check needed
+    int first_dts_checked; ///< first dts check needed
     int prev_payload_key;
     int64_t payload_pts;
     int64_t payload_dts;
@@ -1705,6 +1706,12 @@  static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
     }
     ts_st->first_pts_checked = 1;
 
+    if (!ts_st->first_dts_checked && dts == AV_NOPTS_VALUE) {
+        av_log(s, AV_LOG_ERROR, "first dts value must be set\n");
+        return AVERROR_INVALIDDATA;
+    }
+    ts_st->first_dts_checked = 1;
+
     if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
         const uint8_t *p = buf, *buf_end = p + size;
         uint32_t state = -1;