diff mbox series

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

Message ID 1603967016-3408-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Headers show
Series Untitled series #2652
Related show

Commit Message

Limin Wang Oct. 29, 2020, 10:23 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

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

Comments

Marton Balint Oct. 30, 2020, 9:18 a.m. UTC | #1
On Thu, 29 Oct 2020, lance.lmwang@gmail.com wrote:

A better commit message would be:
avformat/mpegtsenc: check that not only first pts but also first dts is valid

> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/mpegtsenc.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 383181d..9e105b7 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -232,7 +232,7 @@ typedef struct MpegTSWriteStream {
>     int cc;
>     int discontinuity;
>     int payload_size;
> -    int first_pts_checked; ///< first pts check needed
> +    int first_timestamp_checked; ///< first pts/dts check needed
>     int prev_payload_key;
>     int64_t payload_pts;
>     int64_t payload_dts;
> @@ -1699,11 +1699,11 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
>             dts += delay;
>     }
> 
> -    if (!ts_st->first_pts_checked && pts == AV_NOPTS_VALUE) {
> -        av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
> +    if (!ts_st->first_timestamp_checked && (pts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE)) {
> +        av_log(s, AV_LOG_ERROR, "first pts or dts value must be set\n");

"first pts and dts value must be set\n"

>         return AVERROR_INVALIDDATA;
>     }
> -    ts_st->first_pts_checked = 1;
> +    ts_st->first_timestamp_checked = 1;
>
>     if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
>         const uint8_t *p = buf, *buf_end = p + size;

LGTM otherwise.

Thanks,
Marton
Limin Wang Oct. 30, 2020, 11:08 a.m. UTC | #2
On Fri, Oct 30, 2020 at 10:18:29AM +0100, Marton Balint wrote:
> 
> On Thu, 29 Oct 2020, lance.lmwang@gmail.com wrote:
> 
> A better commit message would be:
> avformat/mpegtsenc: check that not only first pts but also first dts is valid

fix it locally.

> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> > libavformat/mpegtsenc.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> > index 383181d..9e105b7 100644
> > --- a/libavformat/mpegtsenc.c
> > +++ b/libavformat/mpegtsenc.c
> > @@ -232,7 +232,7 @@ typedef struct MpegTSWriteStream {
> >     int cc;
> >     int discontinuity;
> >     int payload_size;
> > -    int first_pts_checked; ///< first pts check needed
> > +    int first_timestamp_checked; ///< first pts/dts check needed
> >     int prev_payload_key;
> >     int64_t payload_pts;
> >     int64_t payload_dts;
> > @@ -1699,11 +1699,11 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
> >             dts += delay;
> >     }
> > 
> > -    if (!ts_st->first_pts_checked && pts == AV_NOPTS_VALUE) {
> > -        av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
> > +    if (!ts_st->first_timestamp_checked && (pts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE)) {
> > +        av_log(s, AV_LOG_ERROR, "first pts or dts value must be set\n");
> 
> "first pts and dts value must be set\n"

fix it locally.

> 
> >         return AVERROR_INVALIDDATA;
> >     }
> > -    ts_st->first_pts_checked = 1;
> > +    ts_st->first_timestamp_checked = 1;
> > 
> >     if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
> >         const uint8_t *p = buf, *buf_end = p + size;
> 
> LGTM otherwise.
> 
> Thanks,
> Marton
> _______________________________________________
> 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..9e105b7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -232,7 +232,7 @@  typedef struct MpegTSWriteStream {
     int cc;
     int discontinuity;
     int payload_size;
-    int first_pts_checked; ///< first pts check needed
+    int first_timestamp_checked; ///< first pts/dts check needed
     int prev_payload_key;
     int64_t payload_pts;
     int64_t payload_dts;
@@ -1699,11 +1699,11 @@  static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
             dts += delay;
     }
 
-    if (!ts_st->first_pts_checked && pts == AV_NOPTS_VALUE) {
-        av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
+    if (!ts_st->first_timestamp_checked && (pts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE)) {
+        av_log(s, AV_LOG_ERROR, "first pts or dts value must be set\n");
         return AVERROR_INVALIDDATA;
     }
-    ts_st->first_pts_checked = 1;
+    ts_st->first_timestamp_checked = 1;
 
     if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
         const uint8_t *p = buf, *buf_end = p + size;