Re: [FFmpeg-devel] [PATCH] avformat/movenc: Make the packet check more tolerant

2016-09-16 Thread Michael Niedermayer
On Fri, Sep 16, 2016 at 11:45:54AM +0200, Paul B Mahol wrote:
> On 9/16/16, Michael Niedermayer  wrote:
> > Depends-on "avformat/movenc: Check packet in mov_write_single_packet() too"
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/movenc.c | 31 ---
> >  1 file changed, 16 insertions(+), 15 deletions(-)
> >
> 
> lgtm

applied

thx

[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/movenc: Make the packet check more tolerant

2016-09-16 Thread Paul B Mahol
On 9/16/16, Michael Niedermayer  wrote:
> Depends-on "avformat/movenc: Check packet in mov_write_single_packet() too"
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/movenc.c | 31 ---
>  1 file changed, 16 insertions(+), 15 deletions(-)
>

lgtm
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/movenc: Make the packet check more tolerant

2016-09-15 Thread Michael Niedermayer
Depends-on "avformat/movenc: Check packet in mov_write_single_packet() too"
Signed-off-by: Michael Niedermayer 
---
 libavformat/movenc.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b704f49..aa4a076 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4666,25 +4666,26 @@ static int check_pkt(AVFormatContext *s, AVPacket *pkt)
 {
 MOVMuxContext *mov = s->priv_data;
 MOVTrack *trk = >tracks[pkt->stream_index];
+int64_t ref;
+uint64_t duration;
 
 if (trk->entry) {
-int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts;
-if (duration < 0 || duration > INT_MAX) {
-av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" 
/ timestamp: %"PRId64" is out of range for mov/mp4 format\n",
-duration, pkt->dts
-);
-
-pkt->dts = trk->cluster[trk->entry - 1].dts + 1;
-pkt->pts = AV_NOPTS_VALUE;
-}
-} else if (pkt->dts <= INT_MIN || pkt->dts >= INT_MAX) {
-av_log(s, AV_LOG_ERROR, "Application provided initial timestamp: 
%"PRId64" is out of range for mov/mp4 format\n",
-pkt->dts
-);
+ref = trk->cluster[trk->entry - 1].dts;
+} else if (trk->start_dts != AV_NOPTS_VALUE) {
+ref = trk->start_dts + trk->track_duration;
+} else
+ref = pkt->dts; // Skip tests for the first packet
 
-pkt->dts = 0;
-pkt->pts = AV_NOPTS_VALUE;
+duration = pkt->dts - ref;
+if (pkt->dts < ref || duration >= INT_MAX) {
+av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / 
timestamp: %"PRId64" is out of range for mov/mp4 format\n",
+duration, pkt->dts
+);
+
+pkt->dts = ref + 1;
+pkt->pts = AV_NOPTS_VALUE;
 }
+
 if (pkt->duration < 0 || pkt->duration > INT_MAX) {
 av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is 
invalid\n", pkt->duration);
 return AVERROR(EINVAL);
-- 
2.9.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel