Re: [FFmpeg-devel] [PATCH] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-30 Thread fumoboy007
Oops. Will fix.

> On Apr 30, 2019, at 10:58 AM, Michael Niedermayer  
> wrote:
> breaks "make fate"
> 
> make: *** [fate-filter-fps-cfr] Error 1
> make: *** [fate-filter-fps-r] Error 1
> make: *** [fate-filter-fps] Error 1
> make: *** [fate-copy-trac236] Error 1
> make: *** [fate-gaplessenc-itunes-to-ipod-aac] Error 1
> make: *** [fate-mov-zombie] Error 1
> make: *** [fate-mov-aac-2048-priming] Error 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-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-30 Thread Michael Niedermayer
On Mon, Apr 29, 2019 at 03:50:27PM -0700, fumoboy007 wrote:
> Fixes #7855 (“Last subtitle in MP4 is displayed forever”).
> ---
>  libavformat/isom.h |   3 +
>  libavformat/mov.c  | 158 +
>  2 files changed, 135 insertions(+), 26 deletions(-)

breaks "make fate"

make: *** [fate-filter-fps-cfr] Error 1
make: *** [fate-filter-fps-r] Error 1
make: *** [fate-filter-fps] Error 1
make: *** [fate-copy-trac236] Error 1
make: *** [fate-gaplessenc-itunes-to-ipod-aac] Error 1
make: *** [fate-mov-zombie] Error 1
make: *** [fate-mov-aac-2048-priming] Error 1

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-29 Thread fumoboy007
Fixes #7855 (“Last subtitle in MP4 is displayed forever”).
---
 libavformat/isom.h |   3 +
 libavformat/mov.c  | 158 +
 2 files changed, 135 insertions(+), 26 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 69452cae8e..b83744ba09 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -162,6 +162,7 @@ typedef struct MOVStreamContext {
 unsigned int chunk_count;
 int64_t *chunk_offsets;
 unsigned int stts_count;
+unsigned int stts_allocated_size;
 MOVStts *stts_data;
 unsigned int ctts_count;
 unsigned int ctts_allocated_size;
@@ -174,6 +175,8 @@ typedef struct MOVStreamContext {
 unsigned *stps_data;  ///< partial sync sample for mpeg-2 open gop
 MOVElst *elst_data;
 unsigned int elst_count;
+int stts_index;
+int stts_sample;
 int ctts_index;
 int ctts_sample;
 unsigned int sample_size; ///< may contain value calculated from stsd or 
value from stsz atom
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d0347b2970..3d5f5f7ab0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2886,7 +2886,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 {
 AVStream *st;
 MOVStreamContext *sc;
-unsigned int i, entries, alloc_size = 0;
+unsigned int i, entries = 0;
 int64_t duration=0;
 int64_t total_sample_count=0;
 
@@ -2913,7 +2913,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 int sample_duration;
 unsigned int sample_count;
 unsigned int min_entries = FFMIN(FFMAX(i + 1, 1024 * 1024), entries);
-MOVStts *stts_data = av_fast_realloc(sc->stts_data, _size,
+MOVStts *stts_data = av_fast_realloc(sc->stts_data, 
>stts_allocated_size,
  min_entries * 
sizeof(*sc->stts_data));
 if (!stts_data) {
 av_freep(>stts_data);
@@ -3130,11 +3130,15 @@ static int get_edit_list_entry(MOVContext *mov,
 static int find_prev_closest_index(AVStream *st,
AVIndexEntry *e_old,
int nb_old,
+   MOVStts* stts_data,
+   int64_t stts_count,
MOVStts* ctts_data,
int64_t ctts_count,
int64_t timestamp_pts,
int flag,
int64_t* index,
+   int64_t* stts_index,
+   int64_t* stts_sample,
int64_t* ctts_index,
int64_t* ctts_sample)
 {
@@ -3176,6 +3180,15 @@ static int find_prev_closest_index(AVStream *st,
 // Find out the ctts_index for the found frame.
 *ctts_index = 0;
 *ctts_sample = 0;
+
+if (stts_data) {
+av_assert0(stts_index);
+av_assert0(stts_sample);
+
+*stts_index = 0;
+*stts_sample = 0;
+}
+
 for (index_ctts_count = 0; index_ctts_count < *index; 
index_ctts_count++) {
 if (*ctts_index < ctts_count) {
 (*ctts_sample)++;
@@ -3184,6 +3197,13 @@ static int find_prev_closest_index(AVStream *st,
 *ctts_sample = 0;
 }
 }
+if (stts_data && *stts_index < stts_count) {
+(*stts_sample)++;
+if (*stts_sample == stts_data[*stts_index].count) {
+(*stts_index)++;
+*stts_sample = 0;
+}
+}
 }
 
 while (*index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < 
ctts_count) {
@@ -3203,6 +3223,16 @@ static int find_prev_closest_index(AVStream *st,
 } else {
 (*ctts_sample)--;
 }
+if (stts_data) {
+if (*stts_sample == 0) {
+(*stts_index)--;
+if (*stts_index >= 0) {
+*stts_sample = stts_data[*stts_index].count - 1;
+}
+} else {
+(*stts_sample)--;
+}
+}
 }
 }
 
@@ -3275,34 +3305,44 @@ static void fix_index_entry_timestamps(AVStream* st, 
int end_index, int64_t end_
 }
 
 /**
- * Append a new ctts entry to ctts_data.
- * Returns the new ctts_count if successful, else returns -1.
+ * Append a new stts entry to stts_data.
+ * Returns the new stts_count if successful, else returns -1.
  */
-static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, 
unsigned int* allocated_size,
+static int64_t add_stts_entry(MOVStts** stts_data, unsigned int* stts_count, 
unsigned int* allocated_size,
   int count, int duration)
 {
-MOVStts *ctts_buf_new;
-