diff mbox

[FFmpeg-devel,4/4] lavf/mov: Add support for edit list parsing.

Message ID 1470793702-19747-5-git-send-email-isasi@google.com
State Superseded
Headers show

Commit Message

Sasi Inguva Aug. 10, 2016, 1:48 a.m. UTC
Signed-off-by: Sasi Inguva <isasi@google.com>
---
 libavformat/mov.c                            |  323 ++++++++-
 tests/Makefile                               |    1 +
 tests/fate/mov.mak                           |   28 +
 tests/ref/fate/filter-fps-cfr                |    1 -
 tests/ref/fate/gaplessenc-itunes-to-ipod-aac |   12 +-
 tests/ref/fate/gaplessenc-pcm-to-mov-aac     |   12 +-
 tests/ref/fate/gsm-toast                     | 1000 +++++++++++++-------------
 tests/ref/fate/h264-invalid-ref-mod          |   20 +-
 tests/ref/fate/pcm_s16be-stereo              |    2 +-
 tests/ref/fate/quickdraw                     |   12 +-
 tests/ref/fate/tscc2-mov                     |   20 +-
 tests/ref/lavf-fate/mov_qtrle_mace6          |    2 +-
 12 files changed, 884 insertions(+), 549 deletions(-)
 create mode 100644 tests/fate/mov.mak

Comments

Michael Niedermayer Aug. 10, 2016, 3:23 p.m. UTC | #1
On Tue, Aug 09, 2016 at 06:48:22PM -0700, Sasi Inguva wrote:
> Signed-off-by: Sasi Inguva <isasi@google.com>
> ---
>  libavformat/mov.c                            |  323 ++++++++-
>  tests/Makefile                               |    1 +
>  tests/fate/mov.mak                           |   28 +
>  tests/ref/fate/filter-fps-cfr                |    1 -
>  tests/ref/fate/gaplessenc-itunes-to-ipod-aac |   12 +-
>  tests/ref/fate/gaplessenc-pcm-to-mov-aac     |   12 +-
>  tests/ref/fate/gsm-toast                     | 1000 +++++++++++++-------------
>  tests/ref/fate/h264-invalid-ref-mod          |   20 +-
>  tests/ref/fate/pcm_s16be-stereo              |    2 +-
>  tests/ref/fate/quickdraw                     |   12 +-
>  tests/ref/fate/tscc2-mov                     |   20 +-
>  tests/ref/lavf-fate/mov_qtrle_mace6          |    2 +-
>  12 files changed, 884 insertions(+), 549 deletions(-)
>  create mode 100644 tests/fate/mov.mak

make fate-mov-elist-starts-ctts-2ndsample
TEST    mov-elist-starts-ctts-2ndsample
reference file './tests/ref/fate/mov-elist-starts-ctts-2ndsample' not found

also gcc produces quite a few warnings:

libavformat/isom.c: In function ‘ff_mp4_read_dec_config_descr’:
libavformat/isom.c:482:14: warning: variable ‘v’ set but not used [-Wunused-but-set-variable]
libavformat/mov.c: In function ‘mov_fix_index’:
libavformat/mov.c:2951:16: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:2951:16: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 6 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:2951:16: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 7 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3014:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3014:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3014:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 7 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3021:40: warning: passing argument 2 of ‘add_ctts_entry’ from incompatible pointer type [enabled by default]
libavformat/mov.c:2860:16: note: expected ‘int64_t *’ but argument is of type ‘unsigned int *’
libavformat/mov.c:3025:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3025:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3025:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 6 has type ‘int’ [-Wformat]
libavformat/mov.c:3035:17: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3035:17: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3059:40: warning: passing argument 2 of ‘add_ctts_entry’ from incompatible pointer type [enabled by default]
libavformat/mov.c:2860:16: note: expected ‘int64_t *’ but argument is of type ‘unsigned int *’
libavformat/mov.c:3062:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘int64_t’ [-Wformat]
libavformat/mov.c:3062:32: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘int64_t’ [-Wformat]

[...]
wm4 Sept. 19, 2016, 6:37 p.m. UTC | #2
On Tue,  9 Aug 2016 18:48:22 -0700
Sasi Inguva <isasi-at-google.com@ffmpeg.org> wrote:


> diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
> index aacb058..145bd09 100644
> --- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
> +++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac


> -packet|pts=-1024|dts=-1024|duration=1024
> +packet|pts=0|dts=0|duration=N/A
>  packet|pts=0|dts=0|duration=1024

You've just got to be kidding me. Things wrong here:
- demuxer returns packets with broken timestamps (dts not strictly
  monotonic, decoded pts won't be strictly monotonic either)
- the entirely correct pts is broken and will silently break gapless
  decoding in existing API users (but I guess you don't care and
  neither did whoever pushed this?)
- I know there's supposed to be a "discard frame" flag here (which
  existing API users will ignore, leading to broken decoding and all),
  but it's not tested??? This makes the entire gapless test for
  dumping packet metadata useless, you may as well have deleted the
  tests!

And of course you could just have let the mov demuxer export the edit
list explicitly, and assembled it after decoding. But I guess you
didn't want to deal with that ffmpeg.c garbage dump (and neither did
whoever reviewed/pushed this), so you moved it into the libs as uaual?

This is all very disappointing.
Sasi Inguva Sept. 20, 2016, 1:37 a.m. UTC | #3
I have sent a patch fixing the gapless playback . PTAL. Basically the patch
will make sure that , at least in case of one edit list for audio, the
timestamps provided by the demuxer are strictly monotonically increasing ,
and also that the skip_samples field is correctly set to the edit list
media time, exactly as before the edit list patch.

On Mon, Sep 19, 2016 at 11:37 AM, wm4 <nfxjfg@googlemail.com> wrote:

> On Tue,  9 Aug 2016 18:48:22 -0700
> Sasi Inguva <isasi-at-google.com@ffmpeg.org> wrote:
>
>
> > diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
> b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
> > index aacb058..145bd09 100644
> > --- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
> > +++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
>
>
> > -packet|pts=-1024|dts=-1024|duration=1024
> > +packet|pts=0|dts=0|duration=N/A
> >  packet|pts=0|dts=0|duration=1024
>
> You've just got to be kidding me. Things wrong here:
> - demuxer returns packets with broken timestamps (dts not strictly
>   monotonic, decoded pts won't be strictly monotonic either)
> - the entirely correct pts is broken and will silently break gapless
>   decoding in existing API users (but I guess you don't care and
>   neither did whoever pushed this?)
> - I know there's supposed to be a "discard frame" flag here (which
>   existing API users will ignore, leading to broken decoding and all),
>   but it's not tested??? This makes the entire gapless test for
>   dumping packet metadata useless, you may as well have deleted the
>   tests!
>
> And of course you could just have let the mov demuxer export the edit
> list explicitly, and assembled it after decoding. But I guess you
> didn't want to deal with that ffmpeg.c garbage dump (and neither did
> whoever reviewed/pushed this), so you moved it into the libs as uaual?
>
> This is all very disappointing.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f4c35d7..5a53ee4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2769,6 +2769,312 @@  static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     return pb->eof_reached ? AVERROR_EOF : 0;
 }
 
+/**
+ * Get ith edit list entry (media time, duration).
+ */
+static int get_edit_list_entry(MOVStreamContext *msc,
+                               unsigned int edit_list_index,
+                               int64_t *edit_list_media_time,
+                               int64_t *edit_list_duration,
+                               int64_t global_timescale)
+{
+    if (edit_list_index == msc->elst_count) {
+        return 0;
+    }
+    *edit_list_media_time = msc->elst_data[edit_list_index].time;
+    *edit_list_duration = msc->elst_data[edit_list_index].duration;
+    /* duration is in global timescale units;convert to msc timescale */
+    *edit_list_duration *= msc->time_scale;
+    *edit_list_duration /= global_timescale;
+    return 1;
+}
+
+/**
+ * Find the closest previous keyframe to the timestamp, in e_old index
+ * entries.
+ * Returns the index of the entry in st->index_entries if successful,
+ * else returns -1.
+ */
+static int64_t find_prev_closest_keyframe_index(AVStream *st,
+                                                AVIndexEntry *e_old,
+                                                int nb_old,
+                                                int64_t timestamp,
+                                                int flag)
+{
+    AVIndexEntry *e_keep = st->index_entries;
+    int nb_keep = st->nb_index_entries;
+    int64_t found = -1;
+
+    st->index_entries = e_old;
+    st->nb_index_entries = nb_old;
+    found = av_index_search_timestamp(st, timestamp, flag | AVSEEK_FLAG_BACKWARD);
+
+    /* restore AVStream  state*/
+    st->index_entries = e_keep;
+    st->nb_index_entries = nb_keep;
+    return found;
+}
+
+/**
+ * Add index entry with the given values, to the end of st->index_entries.
+ * Returns the new size st->index_entries if successful, else returns -1.
+ */
+static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
+                               int size, int distance, int flags)
+{
+    AVIndexEntry *entries, *ie;
+    int64_t index = -1;
+    const size_t min_size_needed = (st->nb_index_entries + 1) * sizeof(AVIndexEntry);
+    const size_t requested_size =
+        min_size_needed > st->index_entries_allocated_size ?
+        FFMAX(min_size_needed, 2 * st->index_entries_allocated_size) :
+        min_size_needed;
+
+    if((unsigned)st->nb_index_entries + 1 >= UINT_MAX / sizeof(AVIndexEntry))
+        return -1;
+
+    entries = av_fast_realloc(st->index_entries,
+                              &st->index_entries_allocated_size,
+                              requested_size);
+    if(!entries)
+        return -1;
+
+    st->index_entries= entries;
+
+    index= st->nb_index_entries++;
+    ie= &entries[index];
+    assert(!index || ie[-1].timestamp <= timestamp);
+
+    ie->pos = pos;
+    ie->timestamp = timestamp;
+    ie->min_distance= distance;
+    ie->size= size;
+    ie->flags = flags;
+    return index;
+}
+
+/**
+ * Append a new ctts entry to ctts_data.
+ * Returns the new ctts_count if successful, else returns -1.
+ */
+static int64_t add_ctts_entry(MOVStts** ctts_data, int64_t* ctts_count, unsigned int* allocated_size,
+                          int count, int duration)
+{
+    MOVStts *ctts_buf_new;
+    const size_t min_size_needed = (*ctts_count + 1) * sizeof(MOVStts);
+    const size_t requested_size =
+        min_size_needed > *allocated_size ?
+        FFMAX(min_size_needed, 2 * (*allocated_size)) :
+        min_size_needed;
+
+    if((unsigned)(*ctts_count) + 1 >= UINT_MAX / sizeof(MOVStts))
+        return -1;
+
+    ctts_buf_new = av_fast_realloc(*ctts_data, allocated_size, requested_size);
+
+    if(!ctts_buf_new)
+        return -1;
+
+    *ctts_data = ctts_buf_new;
+
+    ctts_buf_new[*ctts_count].count = count;
+    ctts_buf_new[*ctts_count].duration = duration;
+
+    *ctts_count = (*ctts_count) + 1;
+    return *ctts_count;
+}
+
+/**
+ * Fix st->index_entries, so that it contains only the entries (and the entries
+ * which are needed to decode them) that fall in the edit list time ranges.
+ * Also fixes the timestamps of the index entries to match the timeline
+ * specified the edit lists.
+ */
+static void mov_fix_index(MOVContext *mov, AVStream *st)
+{
+    MOVStreamContext *msc = st->priv_data;
+    AVIndexEntry *e_old = st->index_entries;
+    int nb_old = st->nb_index_entries;
+    const AVIndexEntry *e_old_end = e_old + nb_old;
+    const AVIndexEntry *current = NULL;
+    MOVStts *ctts_data_old = msc->ctts_data;
+    int64_t ctts_index_old = 0;
+    int64_t ctts_sample_old = 0;
+    int64_t ctts_count_old = msc->ctts_count;
+    int64_t edit_list_media_time = 0;
+    int64_t edit_list_duration = 0;
+    int64_t frame_duration = 0;
+    int64_t edit_list_dts_counter = 0;
+    int64_t edit_list_dts_entry_end = 0;
+    int64_t edit_list_start_ctts_sample = 0;
+    int64_t curr_cts;
+    int64_t edit_list_index = 0;
+    int64_t index;
+    int64_t index_ctts_count;
+    int flags;
+    unsigned int ctts_allocated_size = 0;
+    int64_t start_dts = 0;
+    int64_t edit_list_media_time_dts = 0;
+    int64_t edit_list_start_encountered = 0;
+
+
+    if (!msc->elst_data || msc->elst_count <= 0) {
+        return;
+    }
+    // Clean AVStream from traces of old index
+    st->index_entries = NULL;
+    st->index_entries_allocated_size = 0;
+    st->nb_index_entries = 0;
+
+    // Clean ctts fields of MOVStreamContext
+    msc->ctts_data = NULL;
+    msc->ctts_count = 0;
+    msc->ctts_index = 0;
+    msc->ctts_sample = 0;
+
+    // If the dts_shift is positive (in case of negative ctts values in mov),
+    // then negate the DTS by dts_shift
+    if (msc->dts_shift > 0)
+        edit_list_dts_entry_end -= msc->dts_shift;
+
+    // Offset the DTS by ctts[0] to make the PTS of the first frame 0
+    if (ctts_data_old && ctts_count_old > 0) {
+        edit_list_dts_entry_end -= ctts_data_old[0].duration;
+        av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by ctts[%d].duration: %d\n", 0, ctts_data_old[0].duration);
+    }
+
+    start_dts = edit_list_dts_entry_end;
+
+    while (get_edit_list_entry(msc, edit_list_index, &edit_list_media_time,
+                               &edit_list_duration, mov->time_scale)) {
+        av_log(mov->fc, AV_LOG_DEBUG, "Processing st: %d, edit list %lld - media time: %lld, duration: %lld\n",
+               st->index, edit_list_index, edit_list_media_time, edit_list_duration);
+        edit_list_index++;
+        edit_list_dts_counter = edit_list_dts_entry_end;
+        edit_list_dts_entry_end += edit_list_duration;
+        if (edit_list_media_time == -1) {
+            continue;
+        }
+        //find closest previous key frame
+        edit_list_media_time_dts = edit_list_media_time;
+        if (msc->dts_shift > 0) {
+            edit_list_media_time_dts -= msc->dts_shift;
+        }
+
+        // While reordering frame index according to edit list we must handle properly
+        // the scenario when edit list entry starts from none key frame.
+        // We find closest previous key frame and preserve it and consequent frames in index.
+        // All frames which are outside edit list entry time boundaries will be dropped after decoding.
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            // Audio decoders like AAC need need a decoder delay samples previous to the current sample,
+            // to correctly decode this frame. Hence for audio right now, passing through all the samples
+            // to the decoder. We could be more intelligent in setting the index based on the decoder delay
+            // but for most cases which are simple one-edit list files, with edit-list start time as the
+            // encoder delay, it is not necessary.
+            index = 0;
+        } else {
+            index = find_prev_closest_keyframe_index(st, e_old, nb_old, edit_list_media_time_dts, 0);
+        }
+        if (index == -1) {
+            av_log(mov->fc, AV_LOG_ERROR, "Missing key frame while reordering index according to edit list\n");
+            continue;
+        }
+        current = e_old + index;
+
+        ctts_index_old = 0;
+        ctts_sample_old = 0;
+
+        // set ctts_index properly for the found key frame
+        for (index_ctts_count = 0; index_ctts_count < index; index_ctts_count++) {
+            if (ctts_data_old && ctts_index_old < ctts_count_old) {
+                ctts_sample_old++;
+                if (ctts_data_old[ctts_index_old].count == ctts_sample_old) {
+                    ctts_index_old++;
+                    ctts_sample_old = 0;
+                }
+            }
+        }
+
+        edit_list_start_ctts_sample = ctts_sample_old;
+
+        // Iterate over index and arrange it according to edit list
+        edit_list_start_encountered = 0;
+        for (; current < e_old_end; current++, index++) {
+            // check  if frame outside edit list mark it for discard
+            frame_duration = (current + 1 <  e_old_end) ?
+                             ((current + 1)->timestamp - current->timestamp) : edit_list_duration;
+
+            flags = current->flags;
+
+            // frames (pts) before or after edit list
+            curr_cts = current->timestamp + msc->dts_shift;
+
+            if (ctts_data_old && ctts_index_old < ctts_count_old) {
+                av_log(mov->fc, AV_LOG_DEBUG, "shifted frame pts, curr_cts: %lld @ %lld, ctts: %d, ctts_count: %lld\n",
+                       curr_cts, ctts_index_old, ctts_data_old[ctts_index_old].duration, ctts_count_old);
+                curr_cts += ctts_data_old[ctts_index_old].duration;
+                ctts_sample_old++;
+                if (ctts_sample_old == ctts_data_old[ctts_index_old].count) {
+                    if (add_ctts_entry(&msc->ctts_data, &msc->ctts_count,
+                                       &ctts_allocated_size,
+                                       ctts_data_old[ctts_index_old].count - edit_list_start_ctts_sample,
+                                       ctts_data_old[ctts_index_old].duration) == -1) {
+                        av_log(mov->fc, AV_LOG_ERROR, "Cannot add CTTS entry %lld - {%lld, %lld}\n",
+                               ctts_index_old,
+                               ctts_data_old[ctts_index_old].count - edit_list_start_ctts_sample,
+                               ctts_data_old[ctts_index_old].duration);
+                        break;
+                    }
+                    ctts_index_old++;
+                    ctts_sample_old = 0;
+                    edit_list_start_ctts_sample = 0;
+                }
+            }
+            if (curr_cts < edit_list_media_time || curr_cts >= (edit_list_duration + edit_list_media_time)) {
+                flags |= AVINDEX_DISCARD_FRAME;
+                av_log(mov->fc, AV_LOG_DEBUG, "drop a frame at curr_cts: %lld @ %lld\n", curr_cts, index);
+            } else if (edit_list_start_encountered == 0) {
+                edit_list_start_encountered = 1;
+            }
+
+            if (add_index_entry(st, current->pos, edit_list_dts_counter, current->size,
+                                current->min_distance, flags) == -1) {
+                av_log(mov->fc, AV_LOG_ERROR, "Cannot add index entry\n");
+                break;
+            }
+
+            // Only start incrementing DTS in frame_duration amounts, when we encounter a frame in edit list.
+            if (edit_list_start_encountered > 0) {
+                edit_list_dts_counter = edit_list_dts_counter + frame_duration;
+            }
+
+            // Break when found first key frame after edit entry completion
+            if (((curr_cts + frame_duration) >= (edit_list_duration + edit_list_media_time)) &&
+                ((flags & AVINDEX_KEYFRAME) || ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)))) {
+
+                if (ctts_data_old && ctts_sample_old != 0) {
+                    if (add_ctts_entry(&msc->ctts_data, &msc->ctts_count,
+                                       &ctts_allocated_size,
+                                       ctts_sample_old - edit_list_start_ctts_sample,
+                                       ctts_data_old[ctts_index_old].duration) == -1) {
+                        av_log(mov->fc, AV_LOG_ERROR, "Cannot add CTTS entry %lld - {%lld, %d}\n",
+                               ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample,
+                               ctts_data_old[ctts_index_old].duration);
+                        break;
+                    }
+                }
+                break;
+            }
+        }
+    }
+    // Update av stream length
+    st->duration = edit_list_dts_entry_end - start_dts;
+
+    // Free the old index and the old CTTS structures
+    av_free(e_old);
+    av_free(ctts_data_old);
+}
+
 static void mov_build_index(MOVContext *mov, AVStream *st)
 {
     MOVStreamContext *sc = st->priv_data;
@@ -2782,7 +3088,7 @@  static void mov_build_index(MOVContext *mov, AVStream *st)
     uint64_t stream_size = 0;
 
     if (sc->elst_count) {
-        int i, edit_start_index = 0, unsupported = 0;
+        int i, edit_start_index = 0;
         int64_t empty_duration = 0; // empty duration of the first edit list entry
         int64_t start_time = 0; // start time of the media
 
@@ -2795,19 +3101,14 @@  static void mov_build_index(MOVContext *mov, AVStream *st)
                 edit_start_index = 1;
             } else if (i == edit_start_index && e->time >= 0) {
                 start_time = e->time;
-            } else
-                unsupported = 1;
+            }
         }
-        if (unsupported)
-            av_log(mov->fc, AV_LOG_WARNING, "multiple edit list entries, "
-                   "a/v desync might occur, patch welcome\n");
 
         /* adjust first dts according to edit list */
         if ((empty_duration || start_time) && mov->time_scale > 0) {
             if (empty_duration)
                 empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale);
             sc->time_offset = start_time - empty_duration;
-            current_dts = -sc->time_offset;
             if (sc->ctts_count>0 && sc->stts_count>0 &&
                 sc->ctts_data[0].duration / FFMAX(sc->stts_data[0].duration, 1) > 16) {
                 /* more than 16 frames delay, dts are likely wrong
@@ -2817,7 +3118,7 @@  static void mov_build_index(MOVContext *mov, AVStream *st)
             }
         }
 
-        if (!unsupported && st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)
+        if (st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)
             sc->start_pad = start_time;
     }
 
@@ -3051,6 +3352,9 @@  static void mov_build_index(MOVContext *mov, AVStream *st)
             }
         }
     }
+
+    // Fix index according to edit lists.
+    mov_fix_index(mov, st);
 }
 
 static int test_same_origin(const char *src, const char *ref) {
@@ -5349,6 +5653,9 @@  static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = sc->ffindex;
     pkt->dts = sample->timestamp;
+    if (sample->flags & AVINDEX_DISCARD_FRAME) {
+        pkt->flags |= AV_PKT_FLAG_DISCARD;
+    }
     if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
         pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;
         /* update ctts context */
diff --git a/tests/Makefile b/tests/Makefile
index 895944d..e191470 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -148,6 +148,7 @@  include $(SRC_PATH)/tests/fate/lossless-video.mak
 include $(SRC_PATH)/tests/fate/matroska.mak
 include $(SRC_PATH)/tests/fate/microsoft.mak
 include $(SRC_PATH)/tests/fate/monkeysaudio.mak
+include $(SRC_PATH)/tests/fate/mov.mak
 include $(SRC_PATH)/tests/fate/mp3.mak
 include $(SRC_PATH)/tests/fate/mpc.mak
 include $(SRC_PATH)/tests/fate/mpeg4.mak
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
new file mode 100644
index 0000000..5b3a187
--- /dev/null
+++ b/tests/fate/mov.mak
@@ -0,0 +1,28 @@ 
+FATE_MOV = fate-mov-3elist \
+	   fate-mov-3elist-1ctts \
+	   fate-mov-1elist-1ctts \
+	   fate-mov-1elist-noctts \
+	   fate-mov-elist-starts-ctts-2ndsample \
+	   fate-mov-1elist-ends-last-bframe \
+	   fate-mov-2elist-elist1-ends-bframe
+
+FATE_SAMPLES_AVCONV += $(FATE_MOV)
+
+fate-mov: $(FATE_MOV)
+
+# Make sure we handle edit lists correctly in normal cases.
+fate-mov-1elist-noctts: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-1elist-noctts.mov
+fate-mov-1elist-1ctts: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-1elist-1ctts.mov
+fate-mov-3elist: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-3elist.mov
+fate-mov-3elist-1ctts: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-3elist-1ctts.mov
+
+# Makes sure that the CTTS is also modified when we fix avindex in mov.c while parsing edit lists.
+fate-mov-elist-starts-ctts-2ndsample: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-elist-starts-ctts-2ndsample.mov
+
+# Makes sure that we handle edit lists ending on a B-frame correctly.
+# The last frame in decoding order which is B-frame should be output, but the last but-one P-frame shouldn't be
+# output.
+fate-mov-1elist-ends-last-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-1elist-ends-last-bframe.mov
+
+# Makes sure that we handle timestamps of packets in case of multiple edit lists with one of them ending on a B-frame correctly.
+fate-mov-2elist-elist1-ends-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-2elist-elist1-ends-bframe.mov
\ No newline at end of file
diff --git a/tests/ref/fate/filter-fps-cfr b/tests/ref/fate/filter-fps-cfr
index fa71b59..242fb04 100644
--- a/tests/ref/fate/filter-fps-cfr
+++ b/tests/ref/fate/filter-fps-cfr
@@ -91,4 +91,3 @@ 
 0,         85,         85,        1,    30576, 0xd4150aad
 0,         86,         86,        1,    30576, 0xd4150aad
 0,         87,         87,        1,    30576, 0xd4150aad
-0,         88,         88,        1,    30576, 0xd4150aad
diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
index aacb058..145bd09 100644
--- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
+++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
@@ -1,13 +1,13 @@ 
 [STREAM]
 index=0
-start_pts=0
-duration_ts=104384
+start_pts=1024
+duration_ts=103326
 [/STREAM]
 [FORMAT]
-start_time=0.000000
+start_time=0.023220
 duration=2.367000
 [/FORMAT]
-packet|pts=-1024|dts=-1024|duration=1024
+packet|pts=0|dts=0|duration=N/A
 packet|pts=0|dts=0|duration=1024
 packet|pts=1024|dts=1024|duration=1024
 packet|pts=2048|dts=2048|duration=1024
@@ -22,7 +22,7 @@  packet|pts=98304|dts=98304|duration=1024
 packet|pts=99328|dts=99328|duration=1024
 packet|pts=100352|dts=100352|duration=1024
 packet|pts=101376|dts=101376|duration=1024
-packet|pts=102400|dts=102400|duration=1984
+packet|pts=102400|dts=102400|duration=926
 stream|nb_read_packets=102
 frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
@@ -39,5 +39,5 @@  frame|pkt_pts=98304|pkt_dts=98304|best_effort_timestamp=98304|pkt_duration=1024|
 frame|pkt_pts=99328|pkt_dts=99328|best_effort_timestamp=99328|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=100352|pkt_dts=100352|best_effort_timestamp=100352|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=101376|pkt_dts=101376|best_effort_timestamp=101376|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=102400|pkt_dts=102400|best_effort_timestamp=102400|pkt_duration=1984|nb_samples=1024
+frame|pkt_pts=102400|pkt_dts=102400|best_effort_timestamp=102400|pkt_duration=926|nb_samples=1024
 stream|nb_read_frames=101
diff --git a/tests/ref/fate/gaplessenc-pcm-to-mov-aac b/tests/ref/fate/gaplessenc-pcm-to-mov-aac
index 05dff6e..e99c786 100644
--- a/tests/ref/fate/gaplessenc-pcm-to-mov-aac
+++ b/tests/ref/fate/gaplessenc-pcm-to-mov-aac
@@ -1,13 +1,13 @@ 
 [STREAM]
 index=0
-start_pts=0
-duration_ts=530224
+start_pts=1024
+duration_ts=529200
 [/STREAM]
 [FORMAT]
-start_time=0.000000
+start_time=0.023220
 duration=12.024000
 [/FORMAT]
-packet|pts=-1024|dts=-1024|duration=1024
+packet|pts=0|dts=0|duration=N/A
 packet|pts=0|dts=0|duration=1024
 packet|pts=1024|dts=1024|duration=1024
 packet|pts=2048|dts=2048|duration=1024
@@ -22,7 +22,7 @@  packet|pts=524288|dts=524288|duration=1024
 packet|pts=525312|dts=525312|duration=1024
 packet|pts=526336|dts=526336|duration=1024
 packet|pts=527360|dts=527360|duration=1024
-packet|pts=528384|dts=528384|duration=1840
+packet|pts=528384|dts=528384|duration=816
 stream|nb_read_packets=518
 frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
@@ -39,5 +39,5 @@  frame|pkt_pts=524288|pkt_dts=524288|best_effort_timestamp=524288|pkt_duration=10
 frame|pkt_pts=525312|pkt_dts=525312|best_effort_timestamp=525312|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=526336|pkt_dts=526336|best_effort_timestamp=526336|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=527360|pkt_dts=527360|best_effort_timestamp=527360|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=528384|pkt_dts=528384|best_effort_timestamp=528384|pkt_duration=1840|nb_samples=1024
+frame|pkt_pts=528384|pkt_dts=528384|best_effort_timestamp=528384|pkt_duration=816|nb_samples=1024
 stream|nb_read_frames=517
diff --git a/tests/ref/fate/gsm-toast b/tests/ref/fate/gsm-toast
index ebbfbbf..33bd18e 100644
--- a/tests/ref/fate/gsm-toast
+++ b/tests/ref/fate/gsm-toast
@@ -3,503 +3,503 @@ 
 #codec_id 0: pcm_s16le
 #sample_rate 0: 8000
 #channel_layout 0: 4
-0,          0,          0,      160,      320, 0x4c32ab06
-0,        160,        160,      160,      320, 0x2052a4e7
-0,        320,        320,      160,      320, 0xe9aeafca
-0,        480,        480,      160,      320, 0xde83b450
-0,        640,        640,      160,      320, 0x06a6a80e
-0,        800,        800,      160,      320, 0xf6aeb1e2
-0,        960,        960,      160,      320, 0x2623b40c
-0,       1120,       1120,      160,      320, 0x8ec69f25
-0,       1280,       1280,      160,      320, 0xddaaac88
-0,       1440,       1440,      160,      320, 0x9e60b713
-0,       1600,       1600,      160,      320, 0xb738ab30
-0,       1760,       1760,      160,      320, 0xdb4bbb92
-0,       1920,       1920,      160,      320, 0x0370ae8b
-0,       2080,       2080,      160,      320, 0xb611a3fb
-0,       2240,       2240,      160,      320, 0x07ee8e3b
-0,       2400,       2400,      160,      320, 0xdb1ec628
-0,       2560,       2560,      160,      320, 0xd5f1bda2
-0,       2720,       2720,      160,      320, 0xcabb9a9c
-0,       2880,       2880,      160,      320, 0x16c8ad61
-0,       3040,       3040,      160,      320, 0xf76fc25e
-0,       3200,       3200,      160,      320, 0x7118a10d
-0,       3360,       3360,      160,      320, 0x29f9a0db
-0,       3520,       3520,      160,      320, 0x41f2a4ef
-0,       3680,       3680,      160,      320, 0x36dfb231
-0,       3840,       3840,      160,      320, 0xc5399eda
-0,       4000,       4000,      160,      320, 0x17d4b9e0
-0,       4160,       4160,      160,      320, 0x2b5797ac
-0,       4320,       4320,      160,      320, 0x0128c5e7
-0,       4480,       4480,      160,      320, 0xf4f38037
-0,       4640,       4640,      160,      320, 0x77d6b5f2
-0,       4800,       4800,      160,      320, 0xd94a93e0
-0,       4960,       4960,      160,      320, 0x968daae3
-0,       5120,       5120,      160,      320, 0xda5ba0ec
-0,       5280,       5280,      160,      320, 0x316da1ec
-0,       5440,       5440,      160,      320, 0x3a35b2d2
-0,       5600,       5600,      160,      320, 0xca0b988f
-0,       5760,       5760,      160,      320, 0x1295b0b1
-0,       5920,       5920,      160,      320, 0xe121ae72
-0,       6080,       6080,      160,      320, 0x7da7ad43
-0,       6240,       6240,      160,      320, 0x96a49cfe
-0,       6400,       6400,      160,      320, 0x70c2b1de
-0,       6560,       6560,      160,      320, 0x668d88c0
-0,       6720,       6720,      160,      320, 0x5460b5a8
-0,       6880,       6880,      160,      320, 0x6ac78eab
-0,       7040,       7040,      160,      320, 0x0d8dab87
-0,       7200,       7200,      160,      320, 0xe2be94af
-0,       7360,       7360,      160,      320, 0x3487acdc
-0,       7520,       7520,      160,      320, 0x5048955a
-0,       7680,       7680,      160,      320, 0x2ef4ae0d
-0,       7840,       7840,      160,      320, 0xc765b773
-0,       8000,       8000,      160,      320, 0xad96a486
-0,       8160,       8160,      160,      320, 0xb9fdbf1f
-0,       8320,       8320,      160,      320, 0xf26c9ecf
-0,       8480,       8480,      160,      320, 0xbcadb535
-0,       8640,       8640,      160,      320, 0xa8c897bc
-0,       8800,       8800,      160,      320, 0xaa58b520
-0,       8960,       8960,      160,      320, 0xcb48a716
-0,       9120,       9120,      160,      320, 0x4d5da564
-0,       9280,       9280,      160,      320, 0x9809ae28
-0,       9440,       9440,      160,      320, 0x5baeb1e4
-0,       9600,       9600,      160,      320, 0x6a719b63
-0,       9760,       9760,      160,      320, 0xc27d92f0
-0,       9920,       9920,      160,      320, 0x0e9b9fe9
-0,      10080,      10080,      160,      320, 0xbf9d9bf7
-0,      10240,      10240,      160,      320, 0xf35aa64d
-0,      10400,      10400,      160,      320, 0x26449ce8
-0,      10560,      10560,      160,      320, 0x58f4a997
-0,      10720,      10720,      160,      320, 0x155da289
-0,      10880,      10880,      160,      320, 0x63b19a5c
-0,      11040,      11040,      160,      320, 0xe01aad38
-0,      11200,      11200,      160,      320, 0x4e0f9c43
-0,      11360,      11360,      160,      320, 0x9447a284
-0,      11520,      11520,      160,      320, 0xdb36a433
-0,      11680,      11680,      160,      320, 0x799a9b2c
-0,      11840,      11840,      160,      320, 0x1526a162
-0,      12000,      12000,      160,      320, 0x0a4ea140
-0,      12160,      12160,      160,      320, 0xb08f9ed7
-0,      12320,      12320,      160,      320, 0x221bab76
-0,      12480,      12480,      160,      320, 0x4befacf0
-0,      12640,      12640,      160,      320, 0xac489509
-0,      12800,      12800,      160,      320, 0x57a1a5b4
-0,      12960,      12960,      160,      320, 0x81e8ab97
-0,      13120,      13120,      160,      320, 0xc6ada4d6
-0,      13280,      13280,      160,      320, 0x12489975
-0,      13440,      13440,      160,      320, 0x1da59ba9
-0,      13600,      13600,      160,      320, 0xf225ac62
-0,      13760,      13760,      160,      320, 0x8c8e9eab
-0,      13920,      13920,      160,      320, 0x10599dec
-0,      14080,      14080,      160,      320, 0x06c39fa5
-0,      14240,      14240,      160,      320, 0xb0efa3c4
-0,      14400,      14400,      160,      320, 0x72caadab
-0,      14560,      14560,      160,      320, 0xe4619ff0
-0,      14720,      14720,      160,      320, 0x49bca017
-0,      14880,      14880,      160,      320, 0x413f9fbe
-0,      15040,      15040,      160,      320, 0x6eaed0ee
-0,      15200,      15200,      160,      320, 0x27e4b1eb
-0,      15360,      15360,      160,      320, 0x8c42a30f
-0,      15520,      15520,      160,      320, 0x0afaa0f4
-0,      15680,      15680,      160,      320, 0x0f74b76b
-0,      15840,      15840,      160,      320, 0xa9a2b9d5
-0,      16000,      16000,      160,      320, 0xde2a8712
-0,      16160,      16160,      160,      320, 0xcfc8b3a2
-0,      16320,      16320,      160,      320, 0x768cadce
-0,      16480,      16480,      160,      320, 0x3a8a97f1
-0,      16640,      16640,      160,      320, 0x502fa59b
-0,      16800,      16800,      160,      320, 0x4c3e9b0f
-0,      16960,      16960,      160,      320, 0x1cd2b111
-0,      17120,      17120,      160,      320, 0xa845a5a3
-0,      17280,      17280,      160,      320, 0xa6b8b982
-0,      17440,      17440,      160,      320, 0x4d5caab9
-0,      17600,      17600,      160,      320, 0x7993b604
-0,      17760,      17760,      160,      320, 0x8d19b37b
-0,      17920,      17920,      160,      320, 0xbe48adb6
-0,      18080,      18080,      160,      320, 0x7d68ab8e
-0,      18240,      18240,      160,      320, 0xbfffb0e2
-0,      18400,      18400,      160,      320, 0x90b5b7e3
-0,      18560,      18560,      160,      320, 0x9fa1b016
-0,      18720,      18720,      160,      320, 0x70abafc9
-0,      18880,      18880,      160,      320, 0x82cfad9c
-0,      19040,      19040,      160,      320, 0x05f6aa2c
-0,      19200,      19200,      160,      320, 0x511cbb5b
-0,      19360,      19360,      160,      320, 0xd27caaa6
-0,      19520,      19520,      160,      320, 0x781ca481
-0,      19680,      19680,      160,      320, 0x12e9ad1a
-0,      19840,      19840,      160,      320, 0xe46b989d
-0,      20000,      20000,      160,      320, 0x76dbb0a7
-0,      20160,      20160,      160,      320, 0x10eba486
-0,      20320,      20320,      160,      320, 0x2269a7c8
-0,      20480,      20480,      160,      320, 0x084a9c7e
-0,      20640,      20640,      160,      320, 0x84eda891
-0,      20800,      20800,      160,      320, 0x2ef9a639
-0,      20960,      20960,      160,      320, 0x8bb2a0dd
-0,      21120,      21120,      160,      320, 0x47e5a169
-0,      21280,      21280,      160,      320, 0x98faae42
-0,      21440,      21440,      160,      320, 0x81d2aba4
-0,      21600,      21600,      160,      320, 0x5af8bb33
-0,      21760,      21760,      160,      320, 0x331e8d9f
-0,      21920,      21920,      160,      320, 0xd9b0c09a
-0,      22080,      22080,      160,      320, 0xbaf9bfcf
-0,      22240,      22240,      160,      320, 0x54e89ab5
-0,      22400,      22400,      160,      320, 0x1d62c1d2
-0,      22560,      22560,      160,      320, 0xead6b436
-0,      22720,      22720,      160,      320, 0x465f98bc
-0,      22880,      22880,      160,      320, 0xe707a346
-0,      23040,      23040,      160,      320, 0xf66cb1c2
-0,      23200,      23200,      160,      320, 0xcfc89ae6
-0,      23360,      23360,      160,      320, 0x0b10b796
-0,      23520,      23520,      160,      320, 0xb29caf2c
-0,      23680,      23680,      160,      320, 0x0284a9d1
-0,      23840,      23840,      160,      320, 0xb966b5fc
-0,      24000,      24000,      160,      320, 0x2defa630
-0,      24160,      24160,      160,      320, 0xcdcd8ef3
-0,      24320,      24320,      160,      320, 0xa81bba2b
-0,      24480,      24480,      160,      320, 0x6bc0aeb1
-0,      24640,      24640,      160,      320, 0x38d8ac82
-0,      24800,      24800,      160,      320, 0xeb66a865
-0,      24960,      24960,      160,      320, 0x4fff9cd9
-0,      25120,      25120,      160,      320, 0x6819a19b
-0,      25280,      25280,      160,      320, 0xfd7c93ce
-0,      25440,      25440,      160,      320, 0xa7419f63
-0,      25600,      25600,      160,      320, 0x572caacb
-0,      25760,      25760,      160,      320, 0x918fb1de
-0,      25920,      25920,      160,      320, 0x0088a675
-0,      26080,      26080,      160,      320, 0x19229cf7
-0,      26240,      26240,      160,      320, 0x827ea812
-0,      26400,      26400,      160,      320, 0x6c258ef7
-0,      26560,      26560,      160,      320, 0x6a89b8fe
-0,      26720,      26720,      160,      320, 0x166c9ce0
-0,      26880,      26880,      160,      320, 0x68b39db7
-0,      27040,      27040,      160,      320, 0x3d5aa8ec
-0,      27200,      27200,      160,      320, 0x25e09ff3
-0,      27360,      27360,      160,      320, 0x759aa4ce
-0,      27520,      27520,      160,      320, 0xe5aab0ea
-0,      27680,      27680,      160,      320, 0xf0359e9a
-0,      27840,      27840,      160,      320, 0x51199fff
-0,      28000,      28000,      160,      320, 0xb04aa236
-0,      28160,      28160,      160,      320, 0xe09da0e3
-0,      28320,      28320,      160,      320, 0x144f98a9
-0,      28480,      28480,      160,      320, 0x0b4e9f8d
-0,      28640,      28640,      160,      320, 0xbb69a090
-0,      28800,      28800,      160,      320, 0xec6e9b5b
-0,      28960,      28960,      160,      320, 0x4f86a477
-0,      29120,      29120,      160,      320, 0x4a179d04
-0,      29280,      29280,      160,      320, 0x9682a375
-0,      29440,      29440,      160,      320, 0x3c6ba55e
-0,      29600,      29600,      160,      320, 0x50c0ab50
-0,      29760,      29760,      160,      320, 0xe58ea907
-0,      29920,      29920,      160,      320, 0xc5eaa021
-0,      30080,      30080,      160,      320, 0x38859f01
-0,      30240,      30240,      160,      320, 0x73f8a540
-0,      30400,      30400,      160,      320, 0x395da234
-0,      30560,      30560,      160,      320, 0x7f50b144
-0,      30720,      30720,      160,      320, 0x45568ceb
-0,      30880,      30880,      160,      320, 0xd0508dec
-0,      31040,      31040,      160,      320, 0x60aba7e4
-0,      31200,      31200,      160,      320, 0x4b24b15f
-0,      31360,      31360,      160,      320, 0xbfc9afd6
-0,      31520,      31520,      160,      320, 0xf0f2ad49
-0,      31680,      31680,      160,      320, 0xeea0a426
-0,      31840,      31840,      160,      320, 0xff07a7c9
-0,      32000,      32000,      160,      320, 0xce1fc788
-0,      32160,      32160,      160,      320, 0xc074ae9b
-0,      32320,      32320,      160,      320, 0x51649696
-0,      32480,      32480,      160,      320, 0x24399744
-0,      32640,      32640,      160,      320, 0xfb0eb920
-0,      32800,      32800,      160,      320, 0x3bf8af5c
-0,      32960,      32960,      160,      320, 0xeab69ee0
-0,      33120,      33120,      160,      320, 0x182696bb
-0,      33280,      33280,      160,      320, 0x36e6af72
-0,      33440,      33440,      160,      320, 0x48cc9ecc
-0,      33600,      33600,      160,      320, 0xfb3ca7b8
-0,      33760,      33760,      160,      320, 0xe01aa4b4
-0,      33920,      33920,      160,      320, 0x5c6dac8c
-0,      34080,      34080,      160,      320, 0x072fbd93
-0,      34240,      34240,      160,      320, 0xc8899ccc
-0,      34400,      34400,      160,      320, 0xdcc990ac
-0,      34560,      34560,      160,      320, 0x28e0a9d0
-0,      34720,      34720,      160,      320, 0x0cdbaa11
-0,      34880,      34880,      160,      320, 0x8f4ca093
-0,      35040,      35040,      160,      320, 0x7ee79ea9
-0,      35200,      35200,      160,      320, 0xa762b695
-0,      35360,      35360,      160,      320, 0x9af0b5da
-0,      35520,      35520,      160,      320, 0x1f2cb0e7
-0,      35680,      35680,      160,      320, 0x6029b8bb
-0,      35840,      35840,      160,      320, 0xf2f7acec
-0,      36000,      36000,      160,      320, 0xb3e5b5be
-0,      36160,      36160,      160,      320, 0x266ba8a6
-0,      36320,      36320,      160,      320, 0x4ff59296
-0,      36480,      36480,      160,      320, 0x11d1b9ac
-0,      36640,      36640,      160,      320, 0x749197f7
-0,      36800,      36800,      160,      320, 0x8192b517
-0,      36960,      36960,      160,      320, 0xde129dbe
-0,      37120,      37120,      160,      320, 0x85e4a096
-0,      37280,      37280,      160,      320, 0xdebf9182
-0,      37440,      37440,      160,      320, 0x7a4ba0bf
-0,      37600,      37600,      160,      320, 0x55fe9fcd
-0,      37760,      37760,      160,      320, 0xd242adec
-0,      37920,      37920,      160,      320, 0xeaf5b159
-0,      38080,      38080,      160,      320, 0xfcb1a571
-0,      38240,      38240,      160,      320, 0x62fabda0
-0,      38400,      38400,      160,      320, 0x45a9abcc
-0,      38560,      38560,      160,      320, 0x07af974b
-0,      38720,      38720,      160,      320, 0xc2a0b4fd
-0,      38880,      38880,      160,      320, 0xc30abccd
-0,      39040,      39040,      160,      320, 0xd33ca61c
-0,      39200,      39200,      160,      320, 0x3c33d11a
-0,      39360,      39360,      160,      320, 0x9c2ca0ac
-0,      39520,      39520,      160,      320, 0xa5d69777
-0,      39680,      39680,      160,      320, 0xb7d2c6b8
-0,      39840,      39840,      160,      320, 0x34bbaab9
-0,      40000,      40000,      160,      320, 0x3e7baccb
-0,      40160,      40160,      160,      320, 0x92c6b7e6
-0,      40320,      40320,      160,      320, 0xc810a18a
-0,      40480,      40480,      160,      320, 0x06a09f56
-0,      40640,      40640,      160,      320, 0x8804a504
-0,      40800,      40800,      160,      320, 0x783ba7d5
-0,      40960,      40960,      160,      320, 0x24dcada6
-0,      41120,      41120,      160,      320, 0x4af796be
-0,      41280,      41280,      160,      320, 0x1454b19c
-0,      41440,      41440,      160,      320, 0x0ad0a56e
-0,      41600,      41600,      160,      320, 0x8944a44e
-0,      41760,      41760,      160,      320, 0x31069ebd
-0,      41920,      41920,      160,      320, 0x19cb9812
-0,      42080,      42080,      160,      320, 0xac75abe2
-0,      42240,      42240,      160,      320, 0x0162a200
-0,      42400,      42400,      160,      320, 0xa2d7a4b2
-0,      42560,      42560,      160,      320, 0x078ca611
-0,      42720,      42720,      160,      320, 0x0ec39b40
-0,      42880,      42880,      160,      320, 0xe8f794b2
-0,      43040,      43040,      160,      320, 0xc2cfb258
-0,      43200,      43200,      160,      320, 0xe4759061
-0,      43360,      43360,      160,      320, 0xb1b6aea4
-0,      43520,      43520,      160,      320, 0x9bfb96df
-0,      43680,      43680,      160,      320, 0xcc61b5d3
-0,      43840,      43840,      160,      320, 0xd14e8df9
-0,      44000,      44000,      160,      320, 0xd9d5bbf5
-0,      44160,      44160,      160,      320, 0x4d9fa9b0
-0,      44320,      44320,      160,      320, 0xf606abfc
-0,      44480,      44480,      160,      320, 0x720baa19
-0,      44640,      44640,      160,      320, 0x7f7cac49
-0,      44800,      44800,      160,      320, 0xceab9b54
-0,      44960,      44960,      160,      320, 0x645fa70a
-0,      45120,      45120,      160,      320, 0xa081a40f
-0,      45280,      45280,      160,      320, 0x21d78f8c
-0,      45440,      45440,      160,      320, 0xedf3abc6
-0,      45600,      45600,      160,      320, 0x17679637
-0,      45760,      45760,      160,      320, 0x1cb1ae04
-0,      45920,      45920,      160,      320, 0x17cd9f62
-0,      46080,      46080,      160,      320, 0xf4bca3ab
-0,      46240,      46240,      160,      320, 0xb3bd9152
-0,      46400,      46400,      160,      320, 0x4e1e9825
-0,      46560,      46560,      160,      320, 0x037e9a56
-0,      46720,      46720,      160,      320, 0xd7589fcc
-0,      46880,      46880,      160,      320, 0x5f949e90
-0,      47040,      47040,      160,      320, 0xe133a495
-0,      47200,      47200,      160,      320, 0x7cb7a52c
-0,      47360,      47360,      160,      320, 0xb8b29d95
-0,      47520,      47520,      160,      320, 0x01bca472
-0,      47680,      47680,      160,      320, 0xbcc69895
-0,      47840,      47840,      160,      320, 0xabffa0ee
-0,      48000,      48000,      160,      320, 0xe6629eca
-0,      48160,      48160,      160,      320, 0x572da7cd
-0,      48320,      48320,      160,      320, 0x3017972d
-0,      48480,      48480,      160,      320, 0xac4e9c78
-0,      48640,      48640,      160,      320, 0x112f9c45
-0,      48800,      48800,      160,      320, 0x05e9a64d
-0,      48960,      48960,      160,      320, 0x8f7394d4
-0,      49120,      49120,      160,      320, 0xbaeea07e
-0,      49280,      49280,      160,      320, 0xd757c00e
-0,      49440,      49440,      160,      320, 0x8aa09783
-0,      49600,      49600,      160,      320, 0x31d4ae7a
-0,      49760,      49760,      160,      320, 0x221493e8
-0,      49920,      49920,      160,      320, 0x92f4a3a7
-0,      50080,      50080,      160,      320, 0xbd5bafd9
-0,      50240,      50240,      160,      320, 0x1895b760
-0,      50400,      50400,      160,      320, 0x7a4eacdd
-0,      50560,      50560,      160,      320, 0xc9f7a1c3
-0,      50720,      50720,      160,      320, 0xd750be06
-0,      50880,      50880,      160,      320, 0x641d9a6f
-0,      51040,      51040,      160,      320, 0x70d6b6ff
-0,      51200,      51200,      160,      320, 0x1fd3a546
-0,      51360,      51360,      160,      320, 0x72cfaabe
-0,      51520,      51520,      160,      320, 0x2e61b6ce
-0,      51680,      51680,      160,      320, 0x4813a091
-0,      51840,      51840,      160,      320, 0xbfe7bc0f
-0,      52000,      52000,      160,      320, 0x8c759c1f
-0,      52160,      52160,      160,      320, 0xf4c1c952
-0,      52320,      52320,      160,      320, 0x00fdaa79
-0,      52480,      52480,      160,      320, 0x2ffda252
-0,      52640,      52640,      160,      320, 0x841aa523
-0,      52800,      52800,      160,      320, 0x8c079e5e
-0,      52960,      52960,      160,      320, 0x96e9a83f
-0,      53120,      53120,      160,      320, 0x5926a639
-0,      53280,      53280,      160,      320, 0x02e1a07b
-0,      53440,      53440,      160,      320, 0x2972a999
-0,      53600,      53600,      160,      320, 0x30c89c62
-0,      53760,      53760,      160,      320, 0x83f5a263
-0,      53920,      53920,      160,      320, 0xa3909667
-0,      54080,      54080,      160,      320, 0xd5309fd4
-0,      54240,      54240,      160,      320, 0x3154a571
-0,      54400,      54400,      160,      320, 0x51039a5e
-0,      54560,      54560,      160,      320, 0xf167a344
-0,      54720,      54720,      160,      320, 0x8e709d7d
-0,      54880,      54880,      160,      320, 0x936fa0fd
-0,      55040,      55040,      160,      320, 0x024b9e3c
-0,      55200,      55200,      160,      320, 0x2ea1aa75
-0,      55360,      55360,      160,      320, 0x33f0a2bb
-0,      55520,      55520,      160,      320, 0xbf079d2d
-0,      55680,      55680,      160,      320, 0x847ba2c8
-0,      55840,      55840,      160,      320, 0x37e1a767
-0,      56000,      56000,      160,      320, 0xb607acbb
-0,      56160,      56160,      160,      320, 0x1288ac6d
-0,      56320,      56320,      160,      320, 0xf60e98b3
-0,      56480,      56480,      160,      320, 0xc6b5abdd
-0,      56640,      56640,      160,      320, 0x7feaa710
-0,      56800,      56800,      160,      320, 0x77329fcd
-0,      56960,      56960,      160,      320, 0x91a6a715
-0,      57120,      57120,      160,      320, 0xd0e99f24
-0,      57280,      57280,      160,      320, 0x07089f61
-0,      57440,      57440,      160,      320, 0x2bbda900
-0,      57600,      57600,      160,      320, 0xad3da0d5
-0,      57760,      57760,      160,      320, 0x997ba6d2
-0,      57920,      57920,      160,      320, 0xb15b9dcb
-0,      58080,      58080,      160,      320, 0x17cea82f
-0,      58240,      58240,      160,      320, 0xab51a73e
-0,      58400,      58400,      160,      320, 0x77a1abd6
-0,      58560,      58560,      160,      320, 0x0bddacad
-0,      58720,      58720,      160,      320, 0x43b3bdc4
-0,      58880,      58880,      160,      320, 0xefe0a9ba
-0,      59040,      59040,      160,      320, 0x8eb4bc2f
-0,      59200,      59200,      160,      320, 0x39cdc190
-0,      59360,      59360,      160,      320, 0x1ef3baff
-0,      59520,      59520,      160,      320, 0x1a6ab7e2
-0,      59680,      59680,      160,      320, 0x444ccc69
-0,      59840,      59840,      160,      320, 0x05ebb598
-0,      60000,      60000,      160,      320, 0x4ac5b0ad
-0,      60160,      60160,      160,      320, 0x0ee5ba52
-0,      60320,      60320,      160,      320, 0x501d9fa0
-0,      60480,      60480,      160,      320, 0x2038a9f4
-0,      60640,      60640,      160,      320, 0xa61cb8b3
-0,      60800,      60800,      160,      320, 0xdd009777
-0,      60960,      60960,      160,      320, 0x2a2db86d
-0,      61120,      61120,      160,      320, 0xe9bab3bc
-0,      61280,      61280,      160,      320, 0xf7f8a056
-0,      61440,      61440,      160,      320, 0x514caf14
-0,      61600,      61600,      160,      320, 0xa220b149
-0,      61760,      61760,      160,      320, 0xbf7ea183
-0,      61920,      61920,      160,      320, 0x1d8dc5c6
-0,      62080,      62080,      160,      320, 0x9182a8ea
-0,      62240,      62240,      160,      320, 0x31eba026
-0,      62400,      62400,      160,      320, 0xcfbcc3df
-0,      62560,      62560,      160,      320, 0x3d8cb7ae
-0,      62720,      62720,      160,      320, 0xbe39aec0
-0,      62880,      62880,      160,      320, 0xd236bf71
-0,      63040,      63040,      160,      320, 0x9377b0b2
-0,      63200,      63200,      160,      320, 0xb5e6b2df
-0,      63360,      63360,      160,      320, 0xa3b9bbce
-0,      63520,      63520,      160,      320, 0xa7bda251
-0,      63680,      63680,      160,      320, 0xbf9ab162
-0,      63840,      63840,      160,      320, 0x6928b9cb
-0,      64000,      64000,      160,      320, 0xf5cca209
-0,      64160,      64160,      160,      320, 0xfdf4afad
-0,      64320,      64320,      160,      320, 0xe7e7c216
-0,      64480,      64480,      160,      320, 0x0c5797c6
-0,      64640,      64640,      160,      320, 0x66c1a9ca
-0,      64800,      64800,      160,      320, 0x6b5ca48d
-0,      64960,      64960,      160,      320, 0xec04968a
-0,      65120,      65120,      160,      320, 0xaaada691
-0,      65280,      65280,      160,      320, 0x77c3a624
-0,      65440,      65440,      160,      320, 0xaed9a5d5
-0,      65600,      65600,      160,      320, 0x360fac41
-0,      65760,      65760,      160,      320, 0xa05ea727
-0,      65920,      65920,      160,      320, 0x9f7b9f83
-0,      66080,      66080,      160,      320, 0x474bc4c2
-0,      66240,      66240,      160,      320, 0xb6078d3b
-0,      66400,      66400,      160,      320, 0x8e15a8f9
-0,      66560,      66560,      160,      320, 0x7dc7d4a8
-0,      66720,      66720,      160,      320, 0x55ceab6b
-0,      66880,      66880,      160,      320, 0x982cc94f
-0,      67040,      67040,      160,      320, 0x6153948f
-0,      67200,      67200,      160,      320, 0x5338c621
-0,      67360,      67360,      160,      320, 0x2e2db6e8
-0,      67520,      67520,      160,      320, 0x28e3a9c3
-0,      67680,      67680,      160,      320, 0x74d7b435
-0,      67840,      67840,      160,      320, 0xcf17a10c
-0,      68000,      68000,      160,      320, 0xf1f9ac8c
-0,      68160,      68160,      160,      320, 0x35e0b480
-0,      68320,      68320,      160,      320, 0x5e60b3a4
-0,      68480,      68480,      160,      320, 0x20579b26
-0,      68640,      68640,      160,      320, 0x3e27b89b
-0,      68800,      68800,      160,      320, 0x02e4af94
-0,      68960,      68960,      160,      320, 0x6d6897f1
-0,      69120,      69120,      160,      320, 0x1582b267
-0,      69280,      69280,      160,      320, 0x33ba9eb3
-0,      69440,      69440,      160,      320, 0xb6acad7d
-0,      69600,      69600,      160,      320, 0x1969a6c2
-0,      69760,      69760,      160,      320, 0x363fa350
-0,      69920,      69920,      160,      320, 0xae50bf65
-0,      70080,      70080,      160,      320, 0x0877a50f
-0,      70240,      70240,      160,      320, 0x66e2a42f
-0,      70400,      70400,      160,      320, 0x0b0abcb3
-0,      70560,      70560,      160,      320, 0x23a9afaa
-0,      70720,      70720,      160,      320, 0xc3729b40
-0,      70880,      70880,      160,      320, 0xdd3fc7e2
-0,      71040,      71040,      160,      320, 0x7e0494af
-0,      71200,      71200,      160,      320, 0xcbd096fb
-0,      71360,      71360,      160,      320, 0x5d71b303
-0,      71520,      71520,      160,      320, 0xeedca04a
-0,      71680,      71680,      160,      320, 0x2836a47d
-0,      71840,      71840,      160,      320, 0x7237c2a0
-0,      72000,      72000,      160,      320, 0x7c009bc0
-0,      72160,      72160,      160,      320, 0xc9dcb366
-0,      72320,      72320,      160,      320, 0x4993aac8
-0,      72480,      72480,      160,      320, 0x05ec9954
-0,      72640,      72640,      160,      320, 0xa955bd5c
-0,      72800,      72800,      160,      320, 0x9018aea3
-0,      72960,      72960,      160,      320, 0x780cca52
-0,      73120,      73120,      160,      320, 0x9b8f95f6
-0,      73280,      73280,      160,      320, 0xcd7bb178
-0,      73440,      73440,      160,      320, 0xfec6b443
-0,      73600,      73600,      160,      320, 0xe214abb6
-0,      73760,      73760,      160,      320, 0xdcbebb38
-0,      73920,      73920,      160,      320, 0xe683a30d
-0,      74080,      74080,      160,      320, 0xe4cdb197
-0,      74240,      74240,      160,      320, 0xa426c432
-0,      74400,      74400,      160,      320, 0x761ba6cc
-0,      74560,      74560,      160,      320, 0xcc9aa6aa
-0,      74720,      74720,      160,      320, 0x742bd03d
-0,      74880,      74880,      160,      320, 0x61d9a511
-0,      75040,      75040,      160,      320, 0x3021a4dd
-0,      75200,      75200,      160,      320, 0x6970bbc0
-0,      75360,      75360,      160,      320, 0x76f5a037
-0,      75520,      75520,      160,      320, 0x758d91f2
-0,      75680,      75680,      160,      320, 0xe854a2f1
-0,      75840,      75840,      160,      320, 0xf994a6f8
-0,      76000,      76000,      160,      320, 0x31ebaf40
-0,      76160,      76160,      160,      320, 0x24699970
-0,      76320,      76320,      160,      320, 0x37dda53e
-0,      76480,      76480,      160,      320, 0xa857a752
-0,      76640,      76640,      160,      320, 0xc483ad1d
-0,      76800,      76800,      160,      320, 0x5966add9
-0,      76960,      76960,      160,      320, 0x4dbab89c
-0,      77120,      77120,      160,      320, 0x2f0bb0e6
-0,      77280,      77280,      160,      320, 0x913aaa88
-0,      77440,      77440,      160,      320, 0x245dc1c3
-0,      77600,      77600,      160,      320, 0xb085c5ad
-0,      77760,      77760,      160,      320, 0x9cf1b0fa
-0,      77920,      77920,      160,      320, 0x6887b543
-0,      78080,      78080,      160,      320, 0xcad69feb
-0,      78240,      78240,      160,      320, 0xc12a8ddb
-0,      78400,      78400,      160,      320, 0x01d1bc5a
-0,      78560,      78560,      160,      320, 0x3018b7e8
-0,      78720,      78720,      160,      320, 0x6431b0ef
-0,      78880,      78880,      160,      320, 0x3a53998e
-0,      79040,      79040,      160,      320, 0x1c80a6c6
-0,      79200,      79200,      160,      320, 0x6639adc5
-0,      79360,      79360,      160,      320, 0x92489f9a
-0,      79520,      79520,      160,      320, 0x8cafad00
-0,      79680,      79680,      160,      320, 0xca0392e1
-0,      79840,      79840,      160,      320, 0x30a9ae88
+0,          0,          0,      160,      320, 0x2052a4e7
+0,        160,        160,      160,      320, 0xe9aeafca
+0,        320,        320,      160,      320, 0xde83b450
+0,        480,        480,      160,      320, 0x06a6a80e
+0,        640,        640,      160,      320, 0xf6aeb1e2
+0,        800,        800,      160,      320, 0x2623b40c
+0,        960,        960,      160,      320, 0x8ec69f25
+0,       1120,       1120,      160,      320, 0xddaaac88
+0,       1280,       1280,      160,      320, 0x9e60b713
+0,       1440,       1440,      160,      320, 0xb738ab30
+0,       1600,       1600,      160,      320, 0xdb4bbb92
+0,       1760,       1760,      160,      320, 0x0370ae8b
+0,       1920,       1920,      160,      320, 0xb611a3fb
+0,       2080,       2080,      160,      320, 0x07ee8e3b
+0,       2240,       2240,      160,      320, 0xdb1ec628
+0,       2400,       2400,      160,      320, 0xd5f1bda2
+0,       2560,       2560,      160,      320, 0xcabb9a9c
+0,       2720,       2720,      160,      320, 0x16c8ad61
+0,       2880,       2880,      160,      320, 0xf76fc25e
+0,       3040,       3040,      160,      320, 0x7118a10d
+0,       3200,       3200,      160,      320, 0x29f9a0db
+0,       3360,       3360,      160,      320, 0x41f2a4ef
+0,       3520,       3520,      160,      320, 0x36dfb231
+0,       3680,       3680,      160,      320, 0xc5399eda
+0,       3840,       3840,      160,      320, 0x17d4b9e0
+0,       4000,       4000,      160,      320, 0x2b5797ac
+0,       4160,       4160,      160,      320, 0x0128c5e7
+0,       4320,       4320,      160,      320, 0xf4f38037
+0,       4480,       4480,      160,      320, 0x77d6b5f2
+0,       4640,       4640,      160,      320, 0xd94a93e0
+0,       4800,       4800,      160,      320, 0x968daae3
+0,       4960,       4960,      160,      320, 0xda5ba0ec
+0,       5120,       5120,      160,      320, 0x316da1ec
+0,       5280,       5280,      160,      320, 0x3a35b2d2
+0,       5440,       5440,      160,      320, 0xca0b988f
+0,       5600,       5600,      160,      320, 0x1295b0b1
+0,       5760,       5760,      160,      320, 0xe121ae72
+0,       5920,       5920,      160,      320, 0x7da7ad43
+0,       6080,       6080,      160,      320, 0x96a49cfe
+0,       6240,       6240,      160,      320, 0x70c2b1de
+0,       6400,       6400,      160,      320, 0x668d88c0
+0,       6560,       6560,      160,      320, 0x5460b5a8
+0,       6720,       6720,      160,      320, 0x6ac78eab
+0,       6880,       6880,      160,      320, 0x0d8dab87
+0,       7040,       7040,      160,      320, 0xe2be94af
+0,       7200,       7200,      160,      320, 0x3487acdc
+0,       7360,       7360,      160,      320, 0x5048955a
+0,       7520,       7520,      160,      320, 0x2ef4ae0d
+0,       7680,       7680,      160,      320, 0xc765b773
+0,       7840,       7840,      160,      320, 0xad96a486
+0,       8000,       8000,      160,      320, 0xb9fdbf1f
+0,       8160,       8160,      160,      320, 0xf26c9ecf
+0,       8320,       8320,      160,      320, 0xbcadb535
+0,       8480,       8480,      160,      320, 0xa8c897bc
+0,       8640,       8640,      160,      320, 0xaa58b520
+0,       8800,       8800,      160,      320, 0xcb48a716
+0,       8960,       8960,      160,      320, 0x4d5da564
+0,       9120,       9120,      160,      320, 0x9809ae28
+0,       9280,       9280,      160,      320, 0x5baeb1e4
+0,       9440,       9440,      160,      320, 0x6a719b63
+0,       9600,       9600,      160,      320, 0xc27d92f0
+0,       9760,       9760,      160,      320, 0x0e9b9fe9
+0,       9920,       9920,      160,      320, 0xbf9d9bf7
+0,      10080,      10080,      160,      320, 0xf35aa64d
+0,      10240,      10240,      160,      320, 0x26449ce8
+0,      10400,      10400,      160,      320, 0x58f4a997
+0,      10560,      10560,      160,      320, 0x155da289
+0,      10720,      10720,      160,      320, 0x63b19a5c
+0,      10880,      10880,      160,      320, 0xe01aad38
+0,      11040,      11040,      160,      320, 0x4e0f9c43
+0,      11200,      11200,      160,      320, 0x9447a284
+0,      11360,      11360,      160,      320, 0xdb36a433
+0,      11520,      11520,      160,      320, 0x799a9b2c
+0,      11680,      11680,      160,      320, 0x1526a162
+0,      11840,      11840,      160,      320, 0x0a4ea140
+0,      12000,      12000,      160,      320, 0xb08f9ed7
+0,      12160,      12160,      160,      320, 0x221bab76
+0,      12320,      12320,      160,      320, 0x4befacf0
+0,      12480,      12480,      160,      320, 0xac489509
+0,      12640,      12640,      160,      320, 0x57a1a5b4
+0,      12800,      12800,      160,      320, 0x81e8ab97
+0,      12960,      12960,      160,      320, 0xc6ada4d6
+0,      13120,      13120,      160,      320, 0x12489975
+0,      13280,      13280,      160,      320, 0x1da59ba9
+0,      13440,      13440,      160,      320, 0xf225ac62
+0,      13600,      13600,      160,      320, 0x8c8e9eab
+0,      13760,      13760,      160,      320, 0x10599dec
+0,      13920,      13920,      160,      320, 0x06c39fa5
+0,      14080,      14080,      160,      320, 0xb0efa3c4
+0,      14240,      14240,      160,      320, 0x72caadab
+0,      14400,      14400,      160,      320, 0xe4619ff0
+0,      14560,      14560,      160,      320, 0x49bca017
+0,      14720,      14720,      160,      320, 0x413f9fbe
+0,      14880,      14880,      160,      320, 0x6eaed0ee
+0,      15040,      15040,      160,      320, 0x27e4b1eb
+0,      15200,      15200,      160,      320, 0x8c42a30f
+0,      15360,      15360,      160,      320, 0x0afaa0f4
+0,      15520,      15520,      160,      320, 0x0f74b76b
+0,      15680,      15680,      160,      320, 0xa9a2b9d5
+0,      15840,      15840,      160,      320, 0xde2a8712
+0,      16000,      16000,      160,      320, 0xcfc8b3a2
+0,      16160,      16160,      160,      320, 0x768cadce
+0,      16320,      16320,      160,      320, 0x3a8a97f1
+0,      16480,      16480,      160,      320, 0x502fa59b
+0,      16640,      16640,      160,      320, 0x4c3e9b0f
+0,      16800,      16800,      160,      320, 0x1cd2b111
+0,      16960,      16960,      160,      320, 0xa845a5a3
+0,      17120,      17120,      160,      320, 0xa6b8b982
+0,      17280,      17280,      160,      320, 0x4d5caab9
+0,      17440,      17440,      160,      320, 0x7993b604
+0,      17600,      17600,      160,      320, 0x8d19b37b
+0,      17760,      17760,      160,      320, 0xbe48adb6
+0,      17920,      17920,      160,      320, 0x7d68ab8e
+0,      18080,      18080,      160,      320, 0xbfffb0e2
+0,      18240,      18240,      160,      320, 0x90b5b7e3
+0,      18400,      18400,      160,      320, 0x9fa1b016
+0,      18560,      18560,      160,      320, 0x70abafc9
+0,      18720,      18720,      160,      320, 0x82cfad9c
+0,      18880,      18880,      160,      320, 0x05f6aa2c
+0,      19040,      19040,      160,      320, 0x511cbb5b
+0,      19200,      19200,      160,      320, 0xd27caaa6
+0,      19360,      19360,      160,      320, 0x781ca481
+0,      19520,      19520,      160,      320, 0x12e9ad1a
+0,      19680,      19680,      160,      320, 0xe46b989d
+0,      19840,      19840,      160,      320, 0x76dbb0a7
+0,      20000,      20000,      160,      320, 0x10eba486
+0,      20160,      20160,      160,      320, 0x2269a7c8
+0,      20320,      20320,      160,      320, 0x084a9c7e
+0,      20480,      20480,      160,      320, 0x84eda891
+0,      20640,      20640,      160,      320, 0x2ef9a639
+0,      20800,      20800,      160,      320, 0x8bb2a0dd
+0,      20960,      20960,      160,      320, 0x47e5a169
+0,      21120,      21120,      160,      320, 0x98faae42
+0,      21280,      21280,      160,      320, 0x81d2aba4
+0,      21440,      21440,      160,      320, 0x5af8bb33
+0,      21600,      21600,      160,      320, 0x331e8d9f
+0,      21760,      21760,      160,      320, 0xd9b0c09a
+0,      21920,      21920,      160,      320, 0xbaf9bfcf
+0,      22080,      22080,      160,      320, 0x54e89ab5
+0,      22240,      22240,      160,      320, 0x1d62c1d2
+0,      22400,      22400,      160,      320, 0xead6b436
+0,      22560,      22560,      160,      320, 0x465f98bc
+0,      22720,      22720,      160,      320, 0xe707a346
+0,      22880,      22880,      160,      320, 0xf66cb1c2
+0,      23040,      23040,      160,      320, 0xcfc89ae6
+0,      23200,      23200,      160,      320, 0x0b10b796
+0,      23360,      23360,      160,      320, 0xb29caf2c
+0,      23520,      23520,      160,      320, 0x0284a9d1
+0,      23680,      23680,      160,      320, 0xb966b5fc
+0,      23840,      23840,      160,      320, 0x2defa630
+0,      24000,      24000,      160,      320, 0xcdcd8ef3
+0,      24160,      24160,      160,      320, 0xa81bba2b
+0,      24320,      24320,      160,      320, 0x6bc0aeb1
+0,      24480,      24480,      160,      320, 0x38d8ac82
+0,      24640,      24640,      160,      320, 0xeb66a865
+0,      24800,      24800,      160,      320, 0x4fff9cd9
+0,      24960,      24960,      160,      320, 0x6819a19b
+0,      25120,      25120,      160,      320, 0xfd7c93ce
+0,      25280,      25280,      160,      320, 0xa7419f63
+0,      25440,      25440,      160,      320, 0x572caacb
+0,      25600,      25600,      160,      320, 0x918fb1de
+0,      25760,      25760,      160,      320, 0x0088a675
+0,      25920,      25920,      160,      320, 0x19229cf7
+0,      26080,      26080,      160,      320, 0x827ea812
+0,      26240,      26240,      160,      320, 0x6c258ef7
+0,      26400,      26400,      160,      320, 0x6a89b8fe
+0,      26560,      26560,      160,      320, 0x166c9ce0
+0,      26720,      26720,      160,      320, 0x68b39db7
+0,      26880,      26880,      160,      320, 0x3d5aa8ec
+0,      27040,      27040,      160,      320, 0x25e09ff3
+0,      27200,      27200,      160,      320, 0x759aa4ce
+0,      27360,      27360,      160,      320, 0xe5aab0ea
+0,      27520,      27520,      160,      320, 0xf0359e9a
+0,      27680,      27680,      160,      320, 0x51199fff
+0,      27840,      27840,      160,      320, 0xb04aa236
+0,      28000,      28000,      160,      320, 0xe09da0e3
+0,      28160,      28160,      160,      320, 0x144f98a9
+0,      28320,      28320,      160,      320, 0x0b4e9f8d
+0,      28480,      28480,      160,      320, 0xbb69a090
+0,      28640,      28640,      160,      320, 0xec6e9b5b
+0,      28800,      28800,      160,      320, 0x4f86a477
+0,      28960,      28960,      160,      320, 0x4a179d04
+0,      29120,      29120,      160,      320, 0x9682a375
+0,      29280,      29280,      160,      320, 0x3c6ba55e
+0,      29440,      29440,      160,      320, 0x50c0ab50
+0,      29600,      29600,      160,      320, 0xe58ea907
+0,      29760,      29760,      160,      320, 0xc5eaa021
+0,      29920,      29920,      160,      320, 0x38859f01
+0,      30080,      30080,      160,      320, 0x73f8a540
+0,      30240,      30240,      160,      320, 0x395da234
+0,      30400,      30400,      160,      320, 0x7f50b144
+0,      30560,      30560,      160,      320, 0x45568ceb
+0,      30720,      30720,      160,      320, 0xd0508dec
+0,      30880,      30880,      160,      320, 0x60aba7e4
+0,      31040,      31040,      160,      320, 0x4b24b15f
+0,      31200,      31200,      160,      320, 0xbfc9afd6
+0,      31360,      31360,      160,      320, 0xf0f2ad49
+0,      31520,      31520,      160,      320, 0xeea0a426
+0,      31680,      31680,      160,      320, 0xff07a7c9
+0,      31840,      31840,      160,      320, 0xce1fc788
+0,      32000,      32000,      160,      320, 0xc074ae9b
+0,      32160,      32160,      160,      320, 0x51649696
+0,      32320,      32320,      160,      320, 0x24399744
+0,      32480,      32480,      160,      320, 0xfb0eb920
+0,      32640,      32640,      160,      320, 0x3bf8af5c
+0,      32800,      32800,      160,      320, 0xeab69ee0
+0,      32960,      32960,      160,      320, 0x182696bb
+0,      33120,      33120,      160,      320, 0x36e6af72
+0,      33280,      33280,      160,      320, 0x48cc9ecc
+0,      33440,      33440,      160,      320, 0xfb3ca7b8
+0,      33600,      33600,      160,      320, 0xe01aa4b4
+0,      33760,      33760,      160,      320, 0x5c6dac8c
+0,      33920,      33920,      160,      320, 0x072fbd93
+0,      34080,      34080,      160,      320, 0xc8899ccc
+0,      34240,      34240,      160,      320, 0xdcc990ac
+0,      34400,      34400,      160,      320, 0x28e0a9d0
+0,      34560,      34560,      160,      320, 0x0cdbaa11
+0,      34720,      34720,      160,      320, 0x8f4ca093
+0,      34880,      34880,      160,      320, 0x7ee79ea9
+0,      35040,      35040,      160,      320, 0xa762b695
+0,      35200,      35200,      160,      320, 0x9af0b5da
+0,      35360,      35360,      160,      320, 0x1f2cb0e7
+0,      35520,      35520,      160,      320, 0x6029b8bb
+0,      35680,      35680,      160,      320, 0xf2f7acec
+0,      35840,      35840,      160,      320, 0xb3e5b5be
+0,      36000,      36000,      160,      320, 0x266ba8a6
+0,      36160,      36160,      160,      320, 0x4ff59296
+0,      36320,      36320,      160,      320, 0x11d1b9ac
+0,      36480,      36480,      160,      320, 0x749197f7
+0,      36640,      36640,      160,      320, 0x8192b517
+0,      36800,      36800,      160,      320, 0xde129dbe
+0,      36960,      36960,      160,      320, 0x85e4a096
+0,      37120,      37120,      160,      320, 0xdebf9182
+0,      37280,      37280,      160,      320, 0x7a4ba0bf
+0,      37440,      37440,      160,      320, 0x55fe9fcd
+0,      37600,      37600,      160,      320, 0xd242adec
+0,      37760,      37760,      160,      320, 0xeaf5b159
+0,      37920,      37920,      160,      320, 0xfcb1a571
+0,      38080,      38080,      160,      320, 0x62fabda0
+0,      38240,      38240,      160,      320, 0x45a9abcc
+0,      38400,      38400,      160,      320, 0x07af974b
+0,      38560,      38560,      160,      320, 0xc2a0b4fd
+0,      38720,      38720,      160,      320, 0xc30abccd
+0,      38880,      38880,      160,      320, 0xd33ca61c
+0,      39040,      39040,      160,      320, 0x3c33d11a
+0,      39200,      39200,      160,      320, 0x9c2ca0ac
+0,      39360,      39360,      160,      320, 0xa5d69777
+0,      39520,      39520,      160,      320, 0xb7d2c6b8
+0,      39680,      39680,      160,      320, 0x34bbaab9
+0,      39840,      39840,      160,      320, 0x3e7baccb
+0,      40000,      40000,      160,      320, 0x92c6b7e6
+0,      40160,      40160,      160,      320, 0xc810a18a
+0,      40320,      40320,      160,      320, 0x06a09f56
+0,      40480,      40480,      160,      320, 0x8804a504
+0,      40640,      40640,      160,      320, 0x783ba7d5
+0,      40800,      40800,      160,      320, 0x24dcada6
+0,      40960,      40960,      160,      320, 0x4af796be
+0,      41120,      41120,      160,      320, 0x1454b19c
+0,      41280,      41280,      160,      320, 0x0ad0a56e
+0,      41440,      41440,      160,      320, 0x8944a44e
+0,      41600,      41600,      160,      320, 0x31069ebd
+0,      41760,      41760,      160,      320, 0x19cb9812
+0,      41920,      41920,      160,      320, 0xac75abe2
+0,      42080,      42080,      160,      320, 0x0162a200
+0,      42240,      42240,      160,      320, 0xa2d7a4b2
+0,      42400,      42400,      160,      320, 0x078ca611
+0,      42560,      42560,      160,      320, 0x0ec39b40
+0,      42720,      42720,      160,      320, 0xe8f794b2
+0,      42880,      42880,      160,      320, 0xc2cfb258
+0,      43040,      43040,      160,      320, 0xe4759061
+0,      43200,      43200,      160,      320, 0xb1b6aea4
+0,      43360,      43360,      160,      320, 0x9bfb96df
+0,      43520,      43520,      160,      320, 0xcc61b5d3
+0,      43680,      43680,      160,      320, 0xd14e8df9
+0,      43840,      43840,      160,      320, 0xd9d5bbf5
+0,      44000,      44000,      160,      320, 0x4d9fa9b0
+0,      44160,      44160,      160,      320, 0xf606abfc
+0,      44320,      44320,      160,      320, 0x720baa19
+0,      44480,      44480,      160,      320, 0x7f7cac49
+0,      44640,      44640,      160,      320, 0xceab9b54
+0,      44800,      44800,      160,      320, 0x645fa70a
+0,      44960,      44960,      160,      320, 0xa081a40f
+0,      45120,      45120,      160,      320, 0x21d78f8c
+0,      45280,      45280,      160,      320, 0xedf3abc6
+0,      45440,      45440,      160,      320, 0x17679637
+0,      45600,      45600,      160,      320, 0x1cb1ae04
+0,      45760,      45760,      160,      320, 0x17cd9f62
+0,      45920,      45920,      160,      320, 0xf4bca3ab
+0,      46080,      46080,      160,      320, 0xb3bd9152
+0,      46240,      46240,      160,      320, 0x4e1e9825
+0,      46400,      46400,      160,      320, 0x037e9a56
+0,      46560,      46560,      160,      320, 0xd7589fcc
+0,      46720,      46720,      160,      320, 0x5f949e90
+0,      46880,      46880,      160,      320, 0xe133a495
+0,      47040,      47040,      160,      320, 0x7cb7a52c
+0,      47200,      47200,      160,      320, 0xb8b29d95
+0,      47360,      47360,      160,      320, 0x01bca472
+0,      47520,      47520,      160,      320, 0xbcc69895
+0,      47680,      47680,      160,      320, 0xabffa0ee
+0,      47840,      47840,      160,      320, 0xe6629eca
+0,      48000,      48000,      160,      320, 0x572da7cd
+0,      48160,      48160,      160,      320, 0x3017972d
+0,      48320,      48320,      160,      320, 0xac4e9c78
+0,      48480,      48480,      160,      320, 0x112f9c45
+0,      48640,      48640,      160,      320, 0x05e9a64d
+0,      48800,      48800,      160,      320, 0x8f7394d4
+0,      48960,      48960,      160,      320, 0xbaeea07e
+0,      49120,      49120,      160,      320, 0xd757c00e
+0,      49280,      49280,      160,      320, 0x8aa09783
+0,      49440,      49440,      160,      320, 0x31d4ae7a
+0,      49600,      49600,      160,      320, 0x221493e8
+0,      49760,      49760,      160,      320, 0x92f4a3a7
+0,      49920,      49920,      160,      320, 0xbd5bafd9
+0,      50080,      50080,      160,      320, 0x1895b760
+0,      50240,      50240,      160,      320, 0x7a4eacdd
+0,      50400,      50400,      160,      320, 0xc9f7a1c3
+0,      50560,      50560,      160,      320, 0xd750be06
+0,      50720,      50720,      160,      320, 0x641d9a6f
+0,      50880,      50880,      160,      320, 0x70d6b6ff
+0,      51040,      51040,      160,      320, 0x1fd3a546
+0,      51200,      51200,      160,      320, 0x72cfaabe
+0,      51360,      51360,      160,      320, 0x2e61b6ce
+0,      51520,      51520,      160,      320, 0x4813a091
+0,      51680,      51680,      160,      320, 0xbfe7bc0f
+0,      51840,      51840,      160,      320, 0x8c759c1f
+0,      52000,      52000,      160,      320, 0xf4c1c952
+0,      52160,      52160,      160,      320, 0x00fdaa79
+0,      52320,      52320,      160,      320, 0x2ffda252
+0,      52480,      52480,      160,      320, 0x841aa523
+0,      52640,      52640,      160,      320, 0x8c079e5e
+0,      52800,      52800,      160,      320, 0x96e9a83f
+0,      52960,      52960,      160,      320, 0x5926a639
+0,      53120,      53120,      160,      320, 0x02e1a07b
+0,      53280,      53280,      160,      320, 0x2972a999
+0,      53440,      53440,      160,      320, 0x30c89c62
+0,      53600,      53600,      160,      320, 0x83f5a263
+0,      53760,      53760,      160,      320, 0xa3909667
+0,      53920,      53920,      160,      320, 0xd5309fd4
+0,      54080,      54080,      160,      320, 0x3154a571
+0,      54240,      54240,      160,      320, 0x51039a5e
+0,      54400,      54400,      160,      320, 0xf167a344
+0,      54560,      54560,      160,      320, 0x8e709d7d
+0,      54720,      54720,      160,      320, 0x936fa0fd
+0,      54880,      54880,      160,      320, 0x024b9e3c
+0,      55040,      55040,      160,      320, 0x2ea1aa75
+0,      55200,      55200,      160,      320, 0x33f0a2bb
+0,      55360,      55360,      160,      320, 0xbf079d2d
+0,      55520,      55520,      160,      320, 0x847ba2c8
+0,      55680,      55680,      160,      320, 0x37e1a767
+0,      55840,      55840,      160,      320, 0xb607acbb
+0,      56000,      56000,      160,      320, 0x1288ac6d
+0,      56160,      56160,      160,      320, 0xf60e98b3
+0,      56320,      56320,      160,      320, 0xc6b5abdd
+0,      56480,      56480,      160,      320, 0x7feaa710
+0,      56640,      56640,      160,      320, 0x77329fcd
+0,      56800,      56800,      160,      320, 0x91a6a715
+0,      56960,      56960,      160,      320, 0xd0e99f24
+0,      57120,      57120,      160,      320, 0x07089f61
+0,      57280,      57280,      160,      320, 0x2bbda900
+0,      57440,      57440,      160,      320, 0xad3da0d5
+0,      57600,      57600,      160,      320, 0x997ba6d2
+0,      57760,      57760,      160,      320, 0xb15b9dcb
+0,      57920,      57920,      160,      320, 0x17cea82f
+0,      58080,      58080,      160,      320, 0xab51a73e
+0,      58240,      58240,      160,      320, 0x77a1abd6
+0,      58400,      58400,      160,      320, 0x0bddacad
+0,      58560,      58560,      160,      320, 0x43b3bdc4
+0,      58720,      58720,      160,      320, 0xefe0a9ba
+0,      58880,      58880,      160,      320, 0x8eb4bc2f
+0,      59040,      59040,      160,      320, 0x39cdc190
+0,      59200,      59200,      160,      320, 0x1ef3baff
+0,      59360,      59360,      160,      320, 0x1a6ab7e2
+0,      59520,      59520,      160,      320, 0x444ccc69
+0,      59680,      59680,      160,      320, 0x05ebb598
+0,      59840,      59840,      160,      320, 0x4ac5b0ad
+0,      60000,      60000,      160,      320, 0x0ee5ba52
+0,      60160,      60160,      160,      320, 0x501d9fa0
+0,      60320,      60320,      160,      320, 0x2038a9f4
+0,      60480,      60480,      160,      320, 0xa61cb8b3
+0,      60640,      60640,      160,      320, 0xdd009777
+0,      60800,      60800,      160,      320, 0x2a2db86d
+0,      60960,      60960,      160,      320, 0xe9bab3bc
+0,      61120,      61120,      160,      320, 0xf7f8a056
+0,      61280,      61280,      160,      320, 0x514caf14
+0,      61440,      61440,      160,      320, 0xa220b149
+0,      61600,      61600,      160,      320, 0xbf7ea183
+0,      61760,      61760,      160,      320, 0x1d8dc5c6
+0,      61920,      61920,      160,      320, 0x9182a8ea
+0,      62080,      62080,      160,      320, 0x31eba026
+0,      62240,      62240,      160,      320, 0xcfbcc3df
+0,      62400,      62400,      160,      320, 0x3d8cb7ae
+0,      62560,      62560,      160,      320, 0xbe39aec0
+0,      62720,      62720,      160,      320, 0xd236bf71
+0,      62880,      62880,      160,      320, 0x9377b0b2
+0,      63040,      63040,      160,      320, 0xb5e6b2df
+0,      63200,      63200,      160,      320, 0xa3b9bbce
+0,      63360,      63360,      160,      320, 0xa7bda251
+0,      63520,      63520,      160,      320, 0xbf9ab162
+0,      63680,      63680,      160,      320, 0x6928b9cb
+0,      63840,      63840,      160,      320, 0xf5cca209
+0,      64000,      64000,      160,      320, 0xfdf4afad
+0,      64160,      64160,      160,      320, 0xe7e7c216
+0,      64320,      64320,      160,      320, 0x0c5797c6
+0,      64480,      64480,      160,      320, 0x66c1a9ca
+0,      64640,      64640,      160,      320, 0x6b5ca48d
+0,      64800,      64800,      160,      320, 0xec04968a
+0,      64960,      64960,      160,      320, 0xaaada691
+0,      65120,      65120,      160,      320, 0x77c3a624
+0,      65280,      65280,      160,      320, 0xaed9a5d5
+0,      65440,      65440,      160,      320, 0x360fac41
+0,      65600,      65600,      160,      320, 0xa05ea727
+0,      65760,      65760,      160,      320, 0x9f7b9f83
+0,      65920,      65920,      160,      320, 0x474bc4c2
+0,      66080,      66080,      160,      320, 0xb6078d3b
+0,      66240,      66240,      160,      320, 0x8e15a8f9
+0,      66400,      66400,      160,      320, 0x7dc7d4a8
+0,      66560,      66560,      160,      320, 0x55ceab6b
+0,      66720,      66720,      160,      320, 0x982cc94f
+0,      66880,      66880,      160,      320, 0x6153948f
+0,      67040,      67040,      160,      320, 0x5338c621
+0,      67200,      67200,      160,      320, 0x2e2db6e8
+0,      67360,      67360,      160,      320, 0x28e3a9c3
+0,      67520,      67520,      160,      320, 0x74d7b435
+0,      67680,      67680,      160,      320, 0xcf17a10c
+0,      67840,      67840,      160,      320, 0xf1f9ac8c
+0,      68000,      68000,      160,      320, 0x35e0b480
+0,      68160,      68160,      160,      320, 0x5e60b3a4
+0,      68320,      68320,      160,      320, 0x20579b26
+0,      68480,      68480,      160,      320, 0x3e27b89b
+0,      68640,      68640,      160,      320, 0x02e4af94
+0,      68800,      68800,      160,      320, 0x6d6897f1
+0,      68960,      68960,      160,      320, 0x1582b267
+0,      69120,      69120,      160,      320, 0x33ba9eb3
+0,      69280,      69280,      160,      320, 0xb6acad7d
+0,      69440,      69440,      160,      320, 0x1969a6c2
+0,      69600,      69600,      160,      320, 0x363fa350
+0,      69760,      69760,      160,      320, 0xae50bf65
+0,      69920,      69920,      160,      320, 0x0877a50f
+0,      70080,      70080,      160,      320, 0x66e2a42f
+0,      70240,      70240,      160,      320, 0x0b0abcb3
+0,      70400,      70400,      160,      320, 0x23a9afaa
+0,      70560,      70560,      160,      320, 0xc3729b40
+0,      70720,      70720,      160,      320, 0xdd3fc7e2
+0,      70880,      70880,      160,      320, 0x7e0494af
+0,      71040,      71040,      160,      320, 0xcbd096fb
+0,      71200,      71200,      160,      320, 0x5d71b303
+0,      71360,      71360,      160,      320, 0xeedca04a
+0,      71520,      71520,      160,      320, 0x2836a47d
+0,      71680,      71680,      160,      320, 0x7237c2a0
+0,      71840,      71840,      160,      320, 0x7c009bc0
+0,      72000,      72000,      160,      320, 0xc9dcb366
+0,      72160,      72160,      160,      320, 0x4993aac8
+0,      72320,      72320,      160,      320, 0x05ec9954
+0,      72480,      72480,      160,      320, 0xa955bd5c
+0,      72640,      72640,      160,      320, 0x9018aea3
+0,      72800,      72800,      160,      320, 0x780cca52
+0,      72960,      72960,      160,      320, 0x9b8f95f6
+0,      73120,      73120,      160,      320, 0xcd7bb178
+0,      73280,      73280,      160,      320, 0xfec6b443
+0,      73440,      73440,      160,      320, 0xe214abb6
+0,      73600,      73600,      160,      320, 0xdcbebb38
+0,      73760,      73760,      160,      320, 0xe683a30d
+0,      73920,      73920,      160,      320, 0xe4cdb197
+0,      74080,      74080,      160,      320, 0xa426c432
+0,      74240,      74240,      160,      320, 0x761ba6cc
+0,      74400,      74400,      160,      320, 0xcc9aa6aa
+0,      74560,      74560,      160,      320, 0x742bd03d
+0,      74720,      74720,      160,      320, 0x61d9a511
+0,      74880,      74880,      160,      320, 0x3021a4dd
+0,      75040,      75040,      160,      320, 0x6970bbc0
+0,      75200,      75200,      160,      320, 0x76f5a037
+0,      75360,      75360,      160,      320, 0x758d91f2
+0,      75520,      75520,      160,      320, 0xe854a2f1
+0,      75680,      75680,      160,      320, 0xf994a6f8
+0,      75840,      75840,      160,      320, 0x31ebaf40
+0,      76000,      76000,      160,      320, 0x24699970
+0,      76160,      76160,      160,      320, 0x37dda53e
+0,      76320,      76320,      160,      320, 0xa857a752
+0,      76480,      76480,      160,      320, 0xc483ad1d
+0,      76640,      76640,      160,      320, 0x5966add9
+0,      76800,      76800,      160,      320, 0x4dbab89c
+0,      76960,      76960,      160,      320, 0x2f0bb0e6
+0,      77120,      77120,      160,      320, 0x913aaa88
+0,      77280,      77280,      160,      320, 0x245dc1c3
+0,      77440,      77440,      160,      320, 0xb085c5ad
+0,      77600,      77600,      160,      320, 0x9cf1b0fa
+0,      77760,      77760,      160,      320, 0x6887b543
+0,      77920,      77920,      160,      320, 0xcad69feb
+0,      78080,      78080,      160,      320, 0xc12a8ddb
+0,      78240,      78240,      160,      320, 0x01d1bc5a
+0,      78400,      78400,      160,      320, 0x3018b7e8
+0,      78560,      78560,      160,      320, 0x6431b0ef
+0,      78720,      78720,      160,      320, 0x3a53998e
+0,      78880,      78880,      160,      320, 0x1c80a6c6
+0,      79040,      79040,      160,      320, 0x6639adc5
+0,      79200,      79200,      160,      320, 0x92489f9a
+0,      79360,      79360,      160,      320, 0x8cafad00
+0,      79520,      79520,      160,      320, 0xca0392e1
+0,      79680,      79680,      160,      320, 0x30a9ae88
+0,      79840,      79840,      160,      320, 0xc54ca946
diff --git a/tests/ref/fate/h264-invalid-ref-mod b/tests/ref/fate/h264-invalid-ref-mod
index 09271fe..8c4af67 100644
--- a/tests/ref/fate/h264-invalid-ref-mod
+++ b/tests/ref/fate/h264-invalid-ref-mod
@@ -3,13 +3,13 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 1920x1080
 #sar 0: 1/1
-0,          1,          1,        1,  6220800, 0x89daa15e
-0,          2,          2,        1,  6220800, 0xcf52e254
-0,          3,          3,        1,  6220800, 0x91132c13
-0,          4,          4,        1,  6220800, 0x37b8be91
-0,          5,          5,        1,  6220800, 0x2b09bafa
-0,          6,          6,        1,  6220800, 0x06d79d8d
-0,          7,          7,        1,  6220800, 0x8e793c1d
-0,          8,          8,        1,  6220800, 0xea0fd885
-0,          9,          9,        1,  6220800, 0x7786a2ad
-0,         10,         10,        1,  6220800, 0xed4f9dd9
+0,          0,          0,        1,  6220800, 0x89daa15e
+0,          1,          1,        1,  6220800, 0xcf52e254
+0,          2,          2,        1,  6220800, 0x91132c13
+0,          3,          3,        1,  6220800, 0x37b8be91
+0,          4,          4,        1,  6220800, 0x2b09bafa
+0,          5,          5,        1,  6220800, 0x06d79d8d
+0,          6,          6,        1,  6220800, 0x8e793c1d
+0,          7,          7,        1,  6220800, 0xea0fd885
+0,          8,          8,        1,  6220800, 0x7786a2ad
+0,          9,          9,        1,  6220800, 0xed4f9dd9
\ No newline at end of file
diff --git a/tests/ref/fate/pcm_s16be-stereo b/tests/ref/fate/pcm_s16be-stereo
index 2500ba2..6d29a67 100644
--- a/tests/ref/fate/pcm_s16be-stereo
+++ b/tests/ref/fate/pcm_s16be-stereo
@@ -1 +1 @@ 
-f0c0fd7615cdef66fa72f5816632ca9b
+759cf5d12a4b2fb653e61f5219331f14
diff --git a/tests/ref/fate/quickdraw b/tests/ref/fate/quickdraw
index c3bb0a5..5746929 100644
--- a/tests/ref/fate/quickdraw
+++ b/tests/ref/fate/quickdraw
@@ -4,4 +4,14 @@ 
 #dimensions 0: 640x480
 #sar 0: 0/1
 0,          0,          0,        1,   921600, 0xc0e68764
-0,          2,          2,        1,   921600, 0x01a16629
+0,          1,          1,        1,   921600, 0xc0e68764
+0,          2,          2,        1,   921600, 0xc0e68764
+0,          3,          3,        1,   921600, 0xc0e68764
+0,          4,          4,        1,   921600, 0xc0e68764
+0,          5,          5,        1,   921600, 0xc0e68764
+0,          7,          7,        1,   921600, 0x01a16629
+0,          9,          9,        1,   921600, 0x01a16629
+0,         10,         10,        1,   921600, 0x01a16629
+0,         11,         11,        1,   921600, 0x01a16629
+0,         12,         12,        1,   921600, 0x01a16629
+0,         13,         13,        1,   921600, 0x01a16629
diff --git a/tests/ref/fate/tscc2-mov b/tests/ref/fate/tscc2-mov
index 8714a87..679f5bb 100644
--- a/tests/ref/fate/tscc2-mov
+++ b/tests/ref/fate/tscc2-mov
@@ -3,18 +3,8 @@ 
 #codec_id 0: rawvideo
 #dimensions 0: 892x441
 #sar 0: 0/1
-0,          0,          0,        1,  1180116, 0x01d01336
-0,          1,          1,        1,  1180116, 0x01d01336
-0,          2,          2,        1,  1180116, 0x01d01336
-0,          3,          3,        1,  1180116, 0x01d01336
-0,          4,          4,        1,  1180116, 0x01d01336
-0,          5,          5,        1,  1180116, 0x01d01336
-0,          6,          6,        1,  1180116, 0x01d01336
-0,          7,          7,        1,  1180116, 0x01d01336
-0,          8,          8,        1,  1180116, 0x01d01336
-0,          9,          9,        1,  1180116, 0x01d01336
-0,         10,         10,        1,  1180116, 0x056fdadd
-0,         11,         11,        1,  1180116, 0x6f73e080
-0,         12,         12,        1,  1180116, 0x5244d9e5
-0,         13,         13,        1,  1180116, 0x629bf10f
-0,         14,         14,        1,  1180116, 0x97c726cb
+0,          0,          0,        1,  1180116, 0x056fdadd
+0,          1,          1,        1,  1180116, 0x6f73e080
+0,          2,          2,        1,  1180116, 0x5244d9e5
+0,          3,          3,        1,  1180116, 0x629bf10f
+0,          4,          4,        1,  1180116, 0x97c726cb
diff --git a/tests/ref/lavf-fate/mov_qtrle_mace6 b/tests/ref/lavf-fate/mov_qtrle_mace6
index b6ecea5..30c705e 100644
--- a/tests/ref/lavf-fate/mov_qtrle_mace6
+++ b/tests/ref/lavf-fate/mov_qtrle_mace6
@@ -1,3 +1,3 @@ 
-db3e70328340fcb3cd0e06c215fadaa3 *./tests/data/lavf-fate/lavf.mov
+dcc9c4c182a5809dee9a9366f4533797 *./tests/data/lavf-fate/lavf.mov
 1270387 ./tests/data/lavf-fate/lavf.mov
 ./tests/data/lavf-fate/lavf.mov CRC=0x5ec66f68