diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4734a70..b0345b6 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2320,6 +2320,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
         uint32_t discard_padding = 0;
         uint8_t skip_reason = 0;
         uint8_t discard_reason = 0;
+        int demuxer_skip_samples = 0;
         // copy to ensure we do not change avpkt
         AVPacket tmp = *avpkt;
         int did_split = av_packet_split_side_data(&tmp);
@@ -2327,6 +2328,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
         if (ret < 0)
             goto fail;
 
+        demuxer_skip_samples = avctx->internal->skip_samples;
         avctx->internal->pkt = &tmp;
         if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
             ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, &tmp);
@@ -2353,6 +2355,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
 
 
         if (frame->flags & AV_FRAME_FLAG_DISCARD) {
+            // If using discard frame flag, ignore skip_samples set by the decoder.
+            avctx->internal->skip_samples = demuxer_skip_samples;
             *got_frame_ptr = 0;
         }
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6e80b93..b84d9c0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -34,6 +34,7 @@
 #include "libavutil/intfloat.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/time_internal.h"
+#include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/dict.h"
 #include "libavutil/display.h"
@@ -2756,6 +2757,348 @@ 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(const 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 */
+    if (global_timescale == 0) {
+      avpriv_request_sample(msc, "Support for mvhd.timescale = 0 with editlists");
+      return 0;
+    }
+    *edit_list_duration = av_rescale(*edit_list_duration, msc->time_scale,
+                                     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.
+ *
+ * This function is similar to ff_add_index_entry in libavformat/utils.c
+ * except that here we are always unconditionally adding an index entry to
+ * the end, instead of searching the entries list and skipping the add if
+ * there is an existing entry with the same timestamp.
+ * This is needed because the mov_fix_index calls this func with the same
+ * unincremented timestamp for successive discarded frames.
+ */
+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);
+
+    // Double the allocation each time, to lower memory fragmentation.
+    // Another difference from ff_add_index_entry function.
+    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];
+
+    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, unsigned int* 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;
+    int64_t search_timestamp = 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 %"PRId64" - media time: %"PRId64", duration: %"PRId64"\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;
+        }
+
+        // If we encounter a non-negative edit list reset the skip_samples/start_pad fields and set them
+        // according to the edit list below.
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            st->skip_samples = msc->start_pad = 0;
+        }
+
+        //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.
+        search_timestamp = edit_list_media_time_dts;
+        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 we seek to a frame 1 sec. before the
+            // edit_list_media_time to cover the decoder delay.
+            search_timestamp = FFMAX(search_timestamp - mov->time_scale, e_old[0].timestamp);
+        }
+
+        index = find_prev_closest_keyframe_index(st, e_old, nb_old, search_timestamp, 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: %"PRId64" @ %"PRId64", ctts: %d, ctts_count: %"PRId64"\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 %"PRId64" - {%"PRId64", %d}\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)) {
+                if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && curr_cts < edit_list_media_time &&
+                    curr_cts + frame_duration > edit_list_media_time &&
+                    st->skip_samples == 0 && msc->start_pad == 0) {
+                    st->skip_samples = msc->start_pad = edit_list_media_time - curr_cts;
+
+                    // Shift the index entry timestamp by skip_samples to be correct.
+                    edit_list_dts_counter -= st->skip_samples;
+                    if (edit_list_start_encountered == 0)  {
+                      edit_list_start_encountered = 1;
+                    }
+
+                    av_log(mov->fc, AV_LOG_DEBUG, "skip %d audio samples from curr_cts: %"PRId64"\n", st->skip_samples, curr_cts);
+                } else {
+                    flags |= AVINDEX_DISCARD_FRAME;
+                    av_log(mov->fc, AV_LOG_DEBUG, "drop a frame at curr_cts: %"PRId64" @ %"PRId64"\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 %"PRId64" - {%"PRId64", %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;
@@ -2769,7 +3112,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
 
@@ -2782,23 +3125,15 @@ 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 (!unsupported && st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)
-            sc->start_pad = start_time;
     }
 
     /* only use old uncompressed audio chunk demuxing when stts specifies it */
@@ -3031,6 +3366,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) {
@@ -5330,6 +5668,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 0848766..8e810ff 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -149,6 +149,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..4b5885b
--- /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
diff --git a/tests/ref/fate/copy-trac236 b/tests/ref/fate/copy-trac236
index 439b980..167446c 100644
--- a/tests/ref/fate/copy-trac236
+++ b/tests/ref/fate/copy-trac236
@@ -1,5 +1,5 @@
-9b95afdb39b426a33bc962889f820aed *tests/data/fate/copy-trac236.mov
-630802 tests/data/fate/copy-trac236.mov
+d6e3d97b522ce881ed29c5da74cc7e63 *tests/data/fate/copy-trac236.mov
+630810 tests/data/fate/copy-trac236.mov
 #tb 0: 100/2997
 #media_type 0: video
 #codec_id 0: rawvideo
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..043c085 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
+duration_ts=103326
 [/STREAM]
 [FORMAT]
 start_time=0.000000
 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..8b7e3f6 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
+duration_ts=529200
 [/STREAM]
 [FORMAT]
 start_time=0.000000
 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..46aab79 100644
--- a/tests/ref/fate/gsm-toast
+++ b/tests/ref/fate/gsm-toast
@@ -3,503 +3,504 @@
 #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,       64,      128, 0x3ef33f6f
+0,         64,         64,      160,      320, 0x2052a4e7
+0,        224,        224,      160,      320, 0xe9aeafca
+0,        384,        384,      160,      320, 0xde83b450
+0,        544,        544,      160,      320, 0x06a6a80e
+0,        704,        704,      160,      320, 0xf6aeb1e2
+0,        864,        864,      160,      320, 0x2623b40c
+0,       1024,       1024,      160,      320, 0x8ec69f25
+0,       1184,       1184,      160,      320, 0xddaaac88
+0,       1344,       1344,      160,      320, 0x9e60b713
+0,       1504,       1504,      160,      320, 0xb738ab30
+0,       1664,       1664,      160,      320, 0xdb4bbb92
+0,       1824,       1824,      160,      320, 0x0370ae8b
+0,       1984,       1984,      160,      320, 0xb611a3fb
+0,       2144,       2144,      160,      320, 0x07ee8e3b
+0,       2304,       2304,      160,      320, 0xdb1ec628
+0,       2464,       2464,      160,      320, 0xd5f1bda2
+0,       2624,       2624,      160,      320, 0xcabb9a9c
+0,       2784,       2784,      160,      320, 0x16c8ad61
+0,       2944,       2944,      160,      320, 0xf76fc25e
+0,       3104,       3104,      160,      320, 0x7118a10d
+0,       3264,       3264,      160,      320, 0x29f9a0db
+0,       3424,       3424,      160,      320, 0x41f2a4ef
+0,       3584,       3584,      160,      320, 0x36dfb231
+0,       3744,       3744,      160,      320, 0xc5399eda
+0,       3904,       3904,      160,      320, 0x17d4b9e0
+0,       4064,       4064,      160,      320, 0x2b5797ac
+0,       4224,       4224,      160,      320, 0x0128c5e7
+0,       4384,       4384,      160,      320, 0xf4f38037
+0,       4544,       4544,      160,      320, 0x77d6b5f2
+0,       4704,       4704,      160,      320, 0xd94a93e0
+0,       4864,       4864,      160,      320, 0x968daae3
+0,       5024,       5024,      160,      320, 0xda5ba0ec
+0,       5184,       5184,      160,      320, 0x316da1ec
+0,       5344,       5344,      160,      320, 0x3a35b2d2
+0,       5504,       5504,      160,      320, 0xca0b988f
+0,       5664,       5664,      160,      320, 0x1295b0b1
+0,       5824,       5824,      160,      320, 0xe121ae72
+0,       5984,       5984,      160,      320, 0x7da7ad43
+0,       6144,       6144,      160,      320, 0x96a49cfe
+0,       6304,       6304,      160,      320, 0x70c2b1de
+0,       6464,       6464,      160,      320, 0x668d88c0
+0,       6624,       6624,      160,      320, 0x5460b5a8
+0,       6784,       6784,      160,      320, 0x6ac78eab
+0,       6944,       6944,      160,      320, 0x0d8dab87
+0,       7104,       7104,      160,      320, 0xe2be94af
+0,       7264,       7264,      160,      320, 0x3487acdc
+0,       7424,       7424,      160,      320, 0x5048955a
+0,       7584,       7584,      160,      320, 0x2ef4ae0d
+0,       7744,       7744,      160,      320, 0xc765b773
+0,       7904,       7904,      160,      320, 0xad96a486
+0,       8064,       8064,      160,      320, 0xb9fdbf1f
+0,       8224,       8224,      160,      320, 0xf26c9ecf
+0,       8384,       8384,      160,      320, 0xbcadb535
+0,       8544,       8544,      160,      320, 0xa8c897bc
+0,       8704,       8704,      160,      320, 0xaa58b520
+0,       8864,       8864,      160,      320, 0xcb48a716
+0,       9024,       9024,      160,      320, 0x4d5da564
+0,       9184,       9184,      160,      320, 0x9809ae28
+0,       9344,       9344,      160,      320, 0x5baeb1e4
+0,       9504,       9504,      160,      320, 0x6a719b63
+0,       9664,       9664,      160,      320, 0xc27d92f0
+0,       9824,       9824,      160,      320, 0x0e9b9fe9
+0,       9984,       9984,      160,      320, 0xbf9d9bf7
+0,      10144,      10144,      160,      320, 0xf35aa64d
+0,      10304,      10304,      160,      320, 0x26449ce8
+0,      10464,      10464,      160,      320, 0x58f4a997
+0,      10624,      10624,      160,      320, 0x155da289
+0,      10784,      10784,      160,      320, 0x63b19a5c
+0,      10944,      10944,      160,      320, 0xe01aad38
+0,      11104,      11104,      160,      320, 0x4e0f9c43
+0,      11264,      11264,      160,      320, 0x9447a284
+0,      11424,      11424,      160,      320, 0xdb36a433
+0,      11584,      11584,      160,      320, 0x799a9b2c
+0,      11744,      11744,      160,      320, 0x1526a162
+0,      11904,      11904,      160,      320, 0x0a4ea140
+0,      12064,      12064,      160,      320, 0xb08f9ed7
+0,      12224,      12224,      160,      320, 0x221bab76
+0,      12384,      12384,      160,      320, 0x4befacf0
+0,      12544,      12544,      160,      320, 0xac489509
+0,      12704,      12704,      160,      320, 0x57a1a5b4
+0,      12864,      12864,      160,      320, 0x81e8ab97
+0,      13024,      13024,      160,      320, 0xc6ada4d6
+0,      13184,      13184,      160,      320, 0x12489975
+0,      13344,      13344,      160,      320, 0x1da59ba9
+0,      13504,      13504,      160,      320, 0xf225ac62
+0,      13664,      13664,      160,      320, 0x8c8e9eab
+0,      13824,      13824,      160,      320, 0x10599dec
+0,      13984,      13984,      160,      320, 0x06c39fa5
+0,      14144,      14144,      160,      320, 0xb0efa3c4
+0,      14304,      14304,      160,      320, 0x72caadab
+0,      14464,      14464,      160,      320, 0xe4619ff0
+0,      14624,      14624,      160,      320, 0x49bca017
+0,      14784,      14784,      160,      320, 0x413f9fbe
+0,      14944,      14944,      160,      320, 0x6eaed0ee
+0,      15104,      15104,      160,      320, 0x27e4b1eb
+0,      15264,      15264,      160,      320, 0x8c42a30f
+0,      15424,      15424,      160,      320, 0x0afaa0f4
+0,      15584,      15584,      160,      320, 0x0f74b76b
+0,      15744,      15744,      160,      320, 0xa9a2b9d5
+0,      15904,      15904,      160,      320, 0xde2a8712
+0,      16064,      16064,      160,      320, 0xcfc8b3a2
+0,      16224,      16224,      160,      320, 0x768cadce
+0,      16384,      16384,      160,      320, 0x3a8a97f1
+0,      16544,      16544,      160,      320, 0x502fa59b
+0,      16704,      16704,      160,      320, 0x4c3e9b0f
+0,      16864,      16864,      160,      320, 0x1cd2b111
+0,      17024,      17024,      160,      320, 0xa845a5a3
+0,      17184,      17184,      160,      320, 0xa6b8b982
+0,      17344,      17344,      160,      320, 0x4d5caab9
+0,      17504,      17504,      160,      320, 0x7993b604
+0,      17664,      17664,      160,      320, 0x8d19b37b
+0,      17824,      17824,      160,      320, 0xbe48adb6
+0,      17984,      17984,      160,      320, 0x7d68ab8e
+0,      18144,      18144,      160,      320, 0xbfffb0e2
+0,      18304,      18304,      160,      320, 0x90b5b7e3
+0,      18464,      18464,      160,      320, 0x9fa1b016
+0,      18624,      18624,      160,      320, 0x70abafc9
+0,      18784,      18784,      160,      320, 0x82cfad9c
+0,      18944,      18944,      160,      320, 0x05f6aa2c
+0,      19104,      19104,      160,      320, 0x511cbb5b
+0,      19264,      19264,      160,      320, 0xd27caaa6
+0,      19424,      19424,      160,      320, 0x781ca481
+0,      19584,      19584,      160,      320, 0x12e9ad1a
+0,      19744,      19744,      160,      320, 0xe46b989d
+0,      19904,      19904,      160,      320, 0x76dbb0a7
+0,      20064,      20064,      160,      320, 0x10eba486
+0,      20224,      20224,      160,      320, 0x2269a7c8
+0,      20384,      20384,      160,      320, 0x084a9c7e
+0,      20544,      20544,      160,      320, 0x84eda891
+0,      20704,      20704,      160,      320, 0x2ef9a639
+0,      20864,      20864,      160,      320, 0x8bb2a0dd
+0,      21024,      21024,      160,      320, 0x47e5a169
+0,      21184,      21184,      160,      320, 0x98faae42
+0,      21344,      21344,      160,      320, 0x81d2aba4
+0,      21504,      21504,      160,      320, 0x5af8bb33
+0,      21664,      21664,      160,      320, 0x331e8d9f
+0,      21824,      21824,      160,      320, 0xd9b0c09a
+0,      21984,      21984,      160,      320, 0xbaf9bfcf
+0,      22144,      22144,      160,      320, 0x54e89ab5
+0,      22304,      22304,      160,      320, 0x1d62c1d2
+0,      22464,      22464,      160,      320, 0xead6b436
+0,      22624,      22624,      160,      320, 0x465f98bc
+0,      22784,      22784,      160,      320, 0xe707a346
+0,      22944,      22944,      160,      320, 0xf66cb1c2
+0,      23104,      23104,      160,      320, 0xcfc89ae6
+0,      23264,      23264,      160,      320, 0x0b10b796
+0,      23424,      23424,      160,      320, 0xb29caf2c
+0,      23584,      23584,      160,      320, 0x0284a9d1
+0,      23744,      23744,      160,      320, 0xb966b5fc
+0,      23904,      23904,      160,      320, 0x2defa630
+0,      24064,      24064,      160,      320, 0xcdcd8ef3
+0,      24224,      24224,      160,      320, 0xa81bba2b
+0,      24384,      24384,      160,      320, 0x6bc0aeb1
+0,      24544,      24544,      160,      320, 0x38d8ac82
+0,      24704,      24704,      160,      320, 0xeb66a865
+0,      24864,      24864,      160,      320, 0x4fff9cd9
+0,      25024,      25024,      160,      320, 0x6819a19b
+0,      25184,      25184,      160,      320, 0xfd7c93ce
+0,      25344,      25344,      160,      320, 0xa7419f63
+0,      25504,      25504,      160,      320, 0x572caacb
+0,      25664,      25664,      160,      320, 0x918fb1de
+0,      25824,      25824,      160,      320, 0x0088a675
+0,      25984,      25984,      160,      320, 0x19229cf7
+0,      26144,      26144,      160,      320, 0x827ea812
+0,      26304,      26304,      160,      320, 0x6c258ef7
+0,      26464,      26464,      160,      320, 0x6a89b8fe
+0,      26624,      26624,      160,      320, 0x166c9ce0
+0,      26784,      26784,      160,      320, 0x68b39db7
+0,      26944,      26944,      160,      320, 0x3d5aa8ec
+0,      27104,      27104,      160,      320, 0x25e09ff3
+0,      27264,      27264,      160,      320, 0x759aa4ce
+0,      27424,      27424,      160,      320, 0xe5aab0ea
+0,      27584,      27584,      160,      320, 0xf0359e9a
+0,      27744,      27744,      160,      320, 0x51199fff
+0,      27904,      27904,      160,      320, 0xb04aa236
+0,      28064,      28064,      160,      320, 0xe09da0e3
+0,      28224,      28224,      160,      320, 0x144f98a9
+0,      28384,      28384,      160,      320, 0x0b4e9f8d
+0,      28544,      28544,      160,      320, 0xbb69a090
+0,      28704,      28704,      160,      320, 0xec6e9b5b
+0,      28864,      28864,      160,      320, 0x4f86a477
+0,      29024,      29024,      160,      320, 0x4a179d04
+0,      29184,      29184,      160,      320, 0x9682a375
+0,      29344,      29344,      160,      320, 0x3c6ba55e
+0,      29504,      29504,      160,      320, 0x50c0ab50
+0,      29664,      29664,      160,      320, 0xe58ea907
+0,      29824,      29824,      160,      320, 0xc5eaa021
+0,      29984,      29984,      160,      320, 0x38859f01
+0,      30144,      30144,      160,      320, 0x73f8a540
+0,      30304,      30304,      160,      320, 0x395da234
+0,      30464,      30464,      160,      320, 0x7f50b144
+0,      30624,      30624,      160,      320, 0x45568ceb
+0,      30784,      30784,      160,      320, 0xd0508dec
+0,      30944,      30944,      160,      320, 0x60aba7e4
+0,      31104,      31104,      160,      320, 0x4b24b15f
+0,      31264,      31264,      160,      320, 0xbfc9afd6
+0,      31424,      31424,      160,      320, 0xf0f2ad49
+0,      31584,      31584,      160,      320, 0xeea0a426
+0,      31744,      31744,      160,      320, 0xff07a7c9
+0,      31904,      31904,      160,      320, 0xce1fc788
+0,      32064,      32064,      160,      320, 0xc074ae9b
+0,      32224,      32224,      160,      320, 0x51649696
+0,      32384,      32384,      160,      320, 0x24399744
+0,      32544,      32544,      160,      320, 0xfb0eb920
+0,      32704,      32704,      160,      320, 0x3bf8af5c
+0,      32864,      32864,      160,      320, 0xeab69ee0
+0,      33024,      33024,      160,      320, 0x182696bb
+0,      33184,      33184,      160,      320, 0x36e6af72
+0,      33344,      33344,      160,      320, 0x48cc9ecc
+0,      33504,      33504,      160,      320, 0xfb3ca7b8
+0,      33664,      33664,      160,      320, 0xe01aa4b4
+0,      33824,      33824,      160,      320, 0x5c6dac8c
+0,      33984,      33984,      160,      320, 0x072fbd93
+0,      34144,      34144,      160,      320, 0xc8899ccc
+0,      34304,      34304,      160,      320, 0xdcc990ac
+0,      34464,      34464,      160,      320, 0x28e0a9d0
+0,      34624,      34624,      160,      320, 0x0cdbaa11
+0,      34784,      34784,      160,      320, 0x8f4ca093
+0,      34944,      34944,      160,      320, 0x7ee79ea9
+0,      35104,      35104,      160,      320, 0xa762b695
+0,      35264,      35264,      160,      320, 0x9af0b5da
+0,      35424,      35424,      160,      320, 0x1f2cb0e7
+0,      35584,      35584,      160,      320, 0x6029b8bb
+0,      35744,      35744,      160,      320, 0xf2f7acec
+0,      35904,      35904,      160,      320, 0xb3e5b5be
+0,      36064,      36064,      160,      320, 0x266ba8a6
+0,      36224,      36224,      160,      320, 0x4ff59296
+0,      36384,      36384,      160,      320, 0x11d1b9ac
+0,      36544,      36544,      160,      320, 0x749197f7
+0,      36704,      36704,      160,      320, 0x8192b517
+0,      36864,      36864,      160,      320, 0xde129dbe
+0,      37024,      37024,      160,      320, 0x85e4a096
+0,      37184,      37184,      160,      320, 0xdebf9182
+0,      37344,      37344,      160,      320, 0x7a4ba0bf
+0,      37504,      37504,      160,      320, 0x55fe9fcd
+0,      37664,      37664,      160,      320, 0xd242adec
+0,      37824,      37824,      160,      320, 0xeaf5b159
+0,      37984,      37984,      160,      320, 0xfcb1a571
+0,      38144,      38144,      160,      320, 0x62fabda0
+0,      38304,      38304,      160,      320, 0x45a9abcc
+0,      38464,      38464,      160,      320, 0x07af974b
+0,      38624,      38624,      160,      320, 0xc2a0b4fd
+0,      38784,      38784,      160,      320, 0xc30abccd
+0,      38944,      38944,      160,      320, 0xd33ca61c
+0,      39104,      39104,      160,      320, 0x3c33d11a
+0,      39264,      39264,      160,      320, 0x9c2ca0ac
+0,      39424,      39424,      160,      320, 0xa5d69777
+0,      39584,      39584,      160,      320, 0xb7d2c6b8
+0,      39744,      39744,      160,      320, 0x34bbaab9
+0,      39904,      39904,      160,      320, 0x3e7baccb
+0,      40064,      40064,      160,      320, 0x92c6b7e6
+0,      40224,      40224,      160,      320, 0xc810a18a
+0,      40384,      40384,      160,      320, 0x06a09f56
+0,      40544,      40544,      160,      320, 0x8804a504
+0,      40704,      40704,      160,      320, 0x783ba7d5
+0,      40864,      40864,      160,      320, 0x24dcada6
+0,      41024,      41024,      160,      320, 0x4af796be
+0,      41184,      41184,      160,      320, 0x1454b19c
+0,      41344,      41344,      160,      320, 0x0ad0a56e
+0,      41504,      41504,      160,      320, 0x8944a44e
+0,      41664,      41664,      160,      320, 0x31069ebd
+0,      41824,      41824,      160,      320, 0x19cb9812
+0,      41984,      41984,      160,      320, 0xac75abe2
+0,      42144,      42144,      160,      320, 0x0162a200
+0,      42304,      42304,      160,      320, 0xa2d7a4b2
+0,      42464,      42464,      160,      320, 0x078ca611
+0,      42624,      42624,      160,      320, 0x0ec39b40
+0,      42784,      42784,      160,      320, 0xe8f794b2
+0,      42944,      42944,      160,      320, 0xc2cfb258
+0,      43104,      43104,      160,      320, 0xe4759061
+0,      43264,      43264,      160,      320, 0xb1b6aea4
+0,      43424,      43424,      160,      320, 0x9bfb96df
+0,      43584,      43584,      160,      320, 0xcc61b5d3
+0,      43744,      43744,      160,      320, 0xd14e8df9
+0,      43904,      43904,      160,      320, 0xd9d5bbf5
+0,      44064,      44064,      160,      320, 0x4d9fa9b0
+0,      44224,      44224,      160,      320, 0xf606abfc
+0,      44384,      44384,      160,      320, 0x720baa19
+0,      44544,      44544,      160,      320, 0x7f7cac49
+0,      44704,      44704,      160,      320, 0xceab9b54
+0,      44864,      44864,      160,      320, 0x645fa70a
+0,      45024,      45024,      160,      320, 0xa081a40f
+0,      45184,      45184,      160,      320, 0x21d78f8c
+0,      45344,      45344,      160,      320, 0xedf3abc6
+0,      45504,      45504,      160,      320, 0x17679637
+0,      45664,      45664,      160,      320, 0x1cb1ae04
+0,      45824,      45824,      160,      320, 0x17cd9f62
+0,      45984,      45984,      160,      320, 0xf4bca3ab
+0,      46144,      46144,      160,      320, 0xb3bd9152
+0,      46304,      46304,      160,      320, 0x4e1e9825
+0,      46464,      46464,      160,      320, 0x037e9a56
+0,      46624,      46624,      160,      320, 0xd7589fcc
+0,      46784,      46784,      160,      320, 0x5f949e90
+0,      46944,      46944,      160,      320, 0xe133a495
+0,      47104,      47104,      160,      320, 0x7cb7a52c
+0,      47264,      47264,      160,      320, 0xb8b29d95
+0,      47424,      47424,      160,      320, 0x01bca472
+0,      47584,      47584,      160,      320, 0xbcc69895
+0,      47744,      47744,      160,      320, 0xabffa0ee
+0,      47904,      47904,      160,      320, 0xe6629eca
+0,      48064,      48064,      160,      320, 0x572da7cd
+0,      48224,      48224,      160,      320, 0x3017972d
+0,      48384,      48384,      160,      320, 0xac4e9c78
+0,      48544,      48544,      160,      320, 0x112f9c45
+0,      48704,      48704,      160,      320, 0x05e9a64d
+0,      48864,      48864,      160,      320, 0x8f7394d4
+0,      49024,      49024,      160,      320, 0xbaeea07e
+0,      49184,      49184,      160,      320, 0xd757c00e
+0,      49344,      49344,      160,      320, 0x8aa09783
+0,      49504,      49504,      160,      320, 0x31d4ae7a
+0,      49664,      49664,      160,      320, 0x221493e8
+0,      49824,      49824,      160,      320, 0x92f4a3a7
+0,      49984,      49984,      160,      320, 0xbd5bafd9
+0,      50144,      50144,      160,      320, 0x1895b760
+0,      50304,      50304,      160,      320, 0x7a4eacdd
+0,      50464,      50464,      160,      320, 0xc9f7a1c3
+0,      50624,      50624,      160,      320, 0xd750be06
+0,      50784,      50784,      160,      320, 0x641d9a6f
+0,      50944,      50944,      160,      320, 0x70d6b6ff
+0,      51104,      51104,      160,      320, 0x1fd3a546
+0,      51264,      51264,      160,      320, 0x72cfaabe
+0,      51424,      51424,      160,      320, 0x2e61b6ce
+0,      51584,      51584,      160,      320, 0x4813a091
+0,      51744,      51744,      160,      320, 0xbfe7bc0f
+0,      51904,      51904,      160,      320, 0x8c759c1f
+0,      52064,      52064,      160,      320, 0xf4c1c952
+0,      52224,      52224,      160,      320, 0x00fdaa79
+0,      52384,      52384,      160,      320, 0x2ffda252
+0,      52544,      52544,      160,      320, 0x841aa523
+0,      52704,      52704,      160,      320, 0x8c079e5e
+0,      52864,      52864,      160,      320, 0x96e9a83f
+0,      53024,      53024,      160,      320, 0x5926a639
+0,      53184,      53184,      160,      320, 0x02e1a07b
+0,      53344,      53344,      160,      320, 0x2972a999
+0,      53504,      53504,      160,      320, 0x30c89c62
+0,      53664,      53664,      160,      320, 0x83f5a263
+0,      53824,      53824,      160,      320, 0xa3909667
+0,      53984,      53984,      160,      320, 0xd5309fd4
+0,      54144,      54144,      160,      320, 0x3154a571
+0,      54304,      54304,      160,      320, 0x51039a5e
+0,      54464,      54464,      160,      320, 0xf167a344
+0,      54624,      54624,      160,      320, 0x8e709d7d
+0,      54784,      54784,      160,      320, 0x936fa0fd
+0,      54944,      54944,      160,      320, 0x024b9e3c
+0,      55104,      55104,      160,      320, 0x2ea1aa75
+0,      55264,      55264,      160,      320, 0x33f0a2bb
+0,      55424,      55424,      160,      320, 0xbf079d2d
+0,      55584,      55584,      160,      320, 0x847ba2c8
+0,      55744,      55744,      160,      320, 0x37e1a767
+0,      55904,      55904,      160,      320, 0xb607acbb
+0,      56064,      56064,      160,      320, 0x1288ac6d
+0,      56224,      56224,      160,      320, 0xf60e98b3
+0,      56384,      56384,      160,      320, 0xc6b5abdd
+0,      56544,      56544,      160,      320, 0x7feaa710
+0,      56704,      56704,      160,      320, 0x77329fcd
+0,      56864,      56864,      160,      320, 0x91a6a715
+0,      57024,      57024,      160,      320, 0xd0e99f24
+0,      57184,      57184,      160,      320, 0x07089f61
+0,      57344,      57344,      160,      320, 0x2bbda900
+0,      57504,      57504,      160,      320, 0xad3da0d5
+0,      57664,      57664,      160,      320, 0x997ba6d2
+0,      57824,      57824,      160,      320, 0xb15b9dcb
+0,      57984,      57984,      160,      320, 0x17cea82f
+0,      58144,      58144,      160,      320, 0xab51a73e
+0,      58304,      58304,      160,      320, 0x77a1abd6
+0,      58464,      58464,      160,      320, 0x0bddacad
+0,      58624,      58624,      160,      320, 0x43b3bdc4
+0,      58784,      58784,      160,      320, 0xefe0a9ba
+0,      58944,      58944,      160,      320, 0x8eb4bc2f
+0,      59104,      59104,      160,      320, 0x39cdc190
+0,      59264,      59264,      160,      320, 0x1ef3baff
+0,      59424,      59424,      160,      320, 0x1a6ab7e2
+0,      59584,      59584,      160,      320, 0x444ccc69
+0,      59744,      59744,      160,      320, 0x05ebb598
+0,      59904,      59904,      160,      320, 0x4ac5b0ad
+0,      60064,      60064,      160,      320, 0x0ee5ba52
+0,      60224,      60224,      160,      320, 0x501d9fa0
+0,      60384,      60384,      160,      320, 0x2038a9f4
+0,      60544,      60544,      160,      320, 0xa61cb8b3
+0,      60704,      60704,      160,      320, 0xdd009777
+0,      60864,      60864,      160,      320, 0x2a2db86d
+0,      61024,      61024,      160,      320, 0xe9bab3bc
+0,      61184,      61184,      160,      320, 0xf7f8a056
+0,      61344,      61344,      160,      320, 0x514caf14
+0,      61504,      61504,      160,      320, 0xa220b149
+0,      61664,      61664,      160,      320, 0xbf7ea183
+0,      61824,      61824,      160,      320, 0x1d8dc5c6
+0,      61984,      61984,      160,      320, 0x9182a8ea
+0,      62144,      62144,      160,      320, 0x31eba026
+0,      62304,      62304,      160,      320, 0xcfbcc3df
+0,      62464,      62464,      160,      320, 0x3d8cb7ae
+0,      62624,      62624,      160,      320, 0xbe39aec0
+0,      62784,      62784,      160,      320, 0xd236bf71
+0,      62944,      62944,      160,      320, 0x9377b0b2
+0,      63104,      63104,      160,      320, 0xb5e6b2df
+0,      63264,      63264,      160,      320, 0xa3b9bbce
+0,      63424,      63424,      160,      320, 0xa7bda251
+0,      63584,      63584,      160,      320, 0xbf9ab162
+0,      63744,      63744,      160,      320, 0x6928b9cb
+0,      63904,      63904,      160,      320, 0xf5cca209
+0,      64064,      64064,      160,      320, 0xfdf4afad
+0,      64224,      64224,      160,      320, 0xe7e7c216
+0,      64384,      64384,      160,      320, 0x0c5797c6
+0,      64544,      64544,      160,      320, 0x66c1a9ca
+0,      64704,      64704,      160,      320, 0x6b5ca48d
+0,      64864,      64864,      160,      320, 0xec04968a
+0,      65024,      65024,      160,      320, 0xaaada691
+0,      65184,      65184,      160,      320, 0x77c3a624
+0,      65344,      65344,      160,      320, 0xaed9a5d5
+0,      65504,      65504,      160,      320, 0x360fac41
+0,      65664,      65664,      160,      320, 0xa05ea727
+0,      65824,      65824,      160,      320, 0x9f7b9f83
+0,      65984,      65984,      160,      320, 0x474bc4c2
+0,      66144,      66144,      160,      320, 0xb6078d3b
+0,      66304,      66304,      160,      320, 0x8e15a8f9
+0,      66464,      66464,      160,      320, 0x7dc7d4a8
+0,      66624,      66624,      160,      320, 0x55ceab6b
+0,      66784,      66784,      160,      320, 0x982cc94f
+0,      66944,      66944,      160,      320, 0x6153948f
+0,      67104,      67104,      160,      320, 0x5338c621
+0,      67264,      67264,      160,      320, 0x2e2db6e8
+0,      67424,      67424,      160,      320, 0x28e3a9c3
+0,      67584,      67584,      160,      320, 0x74d7b435
+0,      67744,      67744,      160,      320, 0xcf17a10c
+0,      67904,      67904,      160,      320, 0xf1f9ac8c
+0,      68064,      68064,      160,      320, 0x35e0b480
+0,      68224,      68224,      160,      320, 0x5e60b3a4
+0,      68384,      68384,      160,      320, 0x20579b26
+0,      68544,      68544,      160,      320, 0x3e27b89b
+0,      68704,      68704,      160,      320, 0x02e4af94
+0,      68864,      68864,      160,      320, 0x6d6897f1
+0,      69024,      69024,      160,      320, 0x1582b267
+0,      69184,      69184,      160,      320, 0x33ba9eb3
+0,      69344,      69344,      160,      320, 0xb6acad7d
+0,      69504,      69504,      160,      320, 0x1969a6c2
+0,      69664,      69664,      160,      320, 0x363fa350
+0,      69824,      69824,      160,      320, 0xae50bf65
+0,      69984,      69984,      160,      320, 0x0877a50f
+0,      70144,      70144,      160,      320, 0x66e2a42f
+0,      70304,      70304,      160,      320, 0x0b0abcb3
+0,      70464,      70464,      160,      320, 0x23a9afaa
+0,      70624,      70624,      160,      320, 0xc3729b40
+0,      70784,      70784,      160,      320, 0xdd3fc7e2
+0,      70944,      70944,      160,      320, 0x7e0494af
+0,      71104,      71104,      160,      320, 0xcbd096fb
+0,      71264,      71264,      160,      320, 0x5d71b303
+0,      71424,      71424,      160,      320, 0xeedca04a
+0,      71584,      71584,      160,      320, 0x2836a47d
+0,      71744,      71744,      160,      320, 0x7237c2a0
+0,      71904,      71904,      160,      320, 0x7c009bc0
+0,      72064,      72064,      160,      320, 0xc9dcb366
+0,      72224,      72224,      160,      320, 0x4993aac8
+0,      72384,      72384,      160,      320, 0x05ec9954
+0,      72544,      72544,      160,      320, 0xa955bd5c
+0,      72704,      72704,      160,      320, 0x9018aea3
+0,      72864,      72864,      160,      320, 0x780cca52
+0,      73024,      73024,      160,      320, 0x9b8f95f6
+0,      73184,      73184,      160,      320, 0xcd7bb178
+0,      73344,      73344,      160,      320, 0xfec6b443
+0,      73504,      73504,      160,      320, 0xe214abb6
+0,      73664,      73664,      160,      320, 0xdcbebb38
+0,      73824,      73824,      160,      320, 0xe683a30d
+0,      73984,      73984,      160,      320, 0xe4cdb197
+0,      74144,      74144,      160,      320, 0xa426c432
+0,      74304,      74304,      160,      320, 0x761ba6cc
+0,      74464,      74464,      160,      320, 0xcc9aa6aa
+0,      74624,      74624,      160,      320, 0x742bd03d
+0,      74784,      74784,      160,      320, 0x61d9a511
+0,      74944,      74944,      160,      320, 0x3021a4dd
+0,      75104,      75104,      160,      320, 0x6970bbc0
+0,      75264,      75264,      160,      320, 0x76f5a037
+0,      75424,      75424,      160,      320, 0x758d91f2
+0,      75584,      75584,      160,      320, 0xe854a2f1
+0,      75744,      75744,      160,      320, 0xf994a6f8
+0,      75904,      75904,      160,      320, 0x31ebaf40
+0,      76064,      76064,      160,      320, 0x24699970
+0,      76224,      76224,      160,      320, 0x37dda53e
+0,      76384,      76384,      160,      320, 0xa857a752
+0,      76544,      76544,      160,      320, 0xc483ad1d
+0,      76704,      76704,      160,      320, 0x5966add9
+0,      76864,      76864,      160,      320, 0x4dbab89c
+0,      77024,      77024,      160,      320, 0x2f0bb0e6
+0,      77184,      77184,      160,      320, 0x913aaa88
+0,      77344,      77344,      160,      320, 0x245dc1c3
+0,      77504,      77504,      160,      320, 0xb085c5ad
+0,      77664,      77664,      160,      320, 0x9cf1b0fa
+0,      77824,      77824,      160,      320, 0x6887b543
+0,      77984,      77984,      160,      320, 0xcad69feb
+0,      78144,      78144,      160,      320, 0xc12a8ddb
+0,      78304,      78304,      160,      320, 0x01d1bc5a
+0,      78464,      78464,      160,      320, 0x3018b7e8
+0,      78624,      78624,      160,      320, 0x6431b0ef
+0,      78784,      78784,      160,      320, 0x3a53998e
+0,      78944,      78944,      160,      320, 0x1c80a6c6
+0,      79104,      79104,      160,      320, 0x6639adc5
+0,      79264,      79264,      160,      320, 0x92489f9a
+0,      79424,      79424,      160,      320, 0x8cafad00
+0,      79584,      79584,      160,      320, 0xca0392e1
+0,      79744,      79744,      160,      320, 0x30a9ae88
+0,      79904,      79904,       96,      192, 0x68b76a75
diff --git a/tests/ref/fate/h264-invalid-ref-mod b/tests/ref/fate/h264-invalid-ref-mod
index 09271fe..520cb10 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
diff --git a/tests/ref/fate/mov-1elist-1ctts b/tests/ref/fate/mov-1elist-1ctts
new file mode 100644
index 0000000..379d47a
--- /dev/null
+++ b/tests/ref/fate/mov-1elist-1ctts
@@ -0,0 +1,57 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, 3dd21395fc5d3429f9b08492f47af093
+0,          1,          1,        1,   460800, 117009cceecc160c385dac3d344505c9
+0,          2,          2,        1,   460800, c093aa6e8747287cfeb758f2da7476d1
+0,          3,          3,        1,   460800, 6b7c94a3363f3381f7f930ac02b0c975
+0,          4,          4,        1,   460800, 87c3824a0ef3566f1a384c3c3e2b0d96
+0,          5,          5,        1,   460800, 3de48f3009a159e4737b5993102266de
+0,          6,          6,        1,   460800, 2be0ed1afe921093645af2ff917281ab
+0,          7,          7,        1,   460800, a89170c8413305fdba8d413a5080e57a
+0,          8,          8,        1,   460800, 5a3be131222c223ef8eccd9636330839
+0,          9,          9,        1,   460800, 01068b423526481b9732214c16b9e229
+0,         10,         10,        1,   460800, f9ea60560154e82d77e2661c34dca143
+0,         11,         11,        1,   460800, d77f5b82e34ea5a450076a85141a5618
+0,         12,         12,        1,   460800, 91ff4efcfc3a2301fb2329139e0e71a2
+0,         13,         13,        1,   460800, af8d914008f5f64f2ec1fadfae8bc697
+0,         14,         14,        1,   460800, abb2c4fd1f1ce3c449236da246b62bef
+0,         15,         15,        1,   460800, 66b0558f03dd5a472836fea045dd06ea
+0,         16,         16,        1,   460800, 224207d3e5b93fc4e8c71b782aabca51
+0,         17,         17,        1,   460800, ef975cfa7bc4de88f1333eb301f7ebdd
+0,         18,         18,        1,   460800, d75bf790003d2b1ee56bea0cef068e8e
+0,         19,         19,        1,   460800, d7a16935d7f808cca046db971e5b612a
+0,         20,         20,        1,   460800, f49d06ca4995c267fdc8c674c992cdd1
+0,         21,         21,        1,   460800, f53fd634154dec26ec85b6bef01ba890
+0,         22,         22,        1,   460800, d2d36371e50ace43ae4d2bab092a24c3
+0,         23,         23,        1,   460800, a4c08f4979e7dc914d69a170e198656c
+0,         24,         24,        1,   460800, 0d128e33f156fcc228d92117d56a5f93
+0,         25,         25,        1,   460800, 52fb8fc75c848ed9bc61d5129473f3fb
+0,         26,         26,        1,   460800, 5517f79d2ccb4fc93ede061bfcd632ea
+0,         27,         27,        1,   460800, c24fea9e8d02240328de3cb520904a6b
+0,         28,         28,        1,   460800, 0cbe46a4b91a0bd235d5e74084058e61
+0,         29,         29,        1,   460800, 355b17c2feb6b809c95bb71b333a670d
+0,         30,         30,        1,   460800, 063643ba941293ba95e024da202267cb
+0,         31,         31,        1,   460800, 8b31727d492fa9b25e025a1f45425b16
+0,         32,         32,        1,   460800, 45c5901c24d2ae2304b3e82c075a96bf
+0,         33,         33,        1,   460800, b7d4449d0e2157093727cb0f00648751
+0,         34,         34,        1,   460800, 167642e702f645853c974531853987f8
+0,         35,         35,        1,   460800, 2eb4596d675f099bab6c3b40ce30fd88
+0,         36,         36,        1,   460800, 8dd1aec35b92610cb22bedd3c54cb26a
+0,         37,         37,        1,   460800, 8eacf32e58d9a731467aba0f61d9e60f
+0,         38,         38,        1,   460800, 6a735f86d18ebe265894f633071a25d7
+0,         39,         39,        1,   460800, 843b0c938845b72e1c23bc39f7479cba
+0,         40,         40,        1,   460800, ca2099b43141cb9131505ab40ac3959f
+0,         41,         41,        1,   460800, e65322e1929def11f9985683365ab6bf
+0,         42,         42,        1,   460800, 565410a8c2f4b50a192f9590e6ab32c0
+0,         43,         43,        1,   460800, fa9a8ac625854cc279a07766ddad6e6f
+0,         44,         44,        1,   460800, a46ac62886c48edef3dc58de34a2a004
+0,         45,         45,        1,   460800, 414e01b6c24e71efc9c58f65dc0f4aca
+0,         46,         46,        1,   460800, e0501b903f21b490da049e51e7a02bae
+0,         47,         47,        1,   460800, 48b30eec1e9d862ee54b136045e1d90f
diff --git a/tests/ref/fate/mov-1elist-ends-last-bframe b/tests/ref/fate/mov-1elist-ends-last-bframe
new file mode 100644
index 0000000..4f8f1ae
--- /dev/null
+++ b/tests/ref/fate/mov-1elist-ends-last-bframe
@@ -0,0 +1,56 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, b3d774603a22dbf9e952465c0d295166
+0,          1,          1,        1,   460800, d8f88e4269888dfadeb15bec662a3851
+0,          2,          2,        1,   460800, 6d6e686070143f797f8f1eca43d9cf28
+0,          3,          3,        1,   460800, a934f883968e71f22df044f043e61b14
+0,          4,          4,        1,   460800, 83dc65c7703f43ce97c87eea7191f69e
+0,          5,          5,        1,   460800, d633ab0dba64277b104ff5c2e1983424
+0,          6,          6,        1,   460800, 6c7d2c7481bd11584d68dbb9262d8351
+0,          7,          7,        1,   460800, 59b0bbc661b79ba82d726ca4d28255f2
+0,          8,          8,        1,   460800, 821cd7ca0adc4d6a3f10419b6c4283a6
+0,          9,          9,        1,   460800, 4655b1d6e8237b2e880f5b4140f7cf08
+0,         10,         10,        1,   460800, 264858653f9ac0623ffc87ca5e4c9939
+0,         11,         11,        1,   460800, b7129e91b9a6b4f8582747f12cafa52e
+0,         12,         12,        1,   460800, 1f6596fba655e213fd5c2ea99a891138
+0,         13,         13,        1,   460800, c8d67dc8fa8bdca263060ae542e55278
+0,         14,         14,        1,   460800, 57aa680b64b140eaeaa7f4250c12b59e
+0,         15,         15,        1,   460800, b87e8a9c0701cd8811dd38292b9994f7
+0,         16,         16,        1,   460800, 2427eb2900c8e18da0f36e47799a5ed8
+0,         17,         17,        1,   460800, 710a727a7ba51bc2938ca83376c6edd6
+0,         18,         18,        1,   460800, 44d5ce80804d9ca470f9e5348c66e9b3
+0,         19,         19,        1,   460800, 448e1fc3af42c4143e5fc4120090cdd6
+0,         20,         20,        1,   460800, 7c2c4c61843cfdd033b8fa295766a524
+0,         21,         21,        1,   460800, 20a197cb4e20857e135d4c10945987f6
+0,         22,         22,        1,   460800, 7534b00e60f6920da7b767aef0876e65
+0,         23,         23,        1,   460800, b88cedb84145f07226d5573aa57a1cce
+0,         24,         24,        1,   460800, 620751271985df3728b6dbc627974183
+0,         25,         25,        1,   460800, 643719b26ac93f93d1674fee97c58a35
+0,         26,         26,        1,   460800, 5d3f8fa9abab0256afbf4285cd337804
+0,         27,         27,        1,   460800, a6c302c54c6481088f9c27189ecda5a8
+0,         28,         28,        1,   460800, 2851ad86c15a1dc7b6d4a0fe8f15de8f
+0,         29,         29,        1,   460800, 42157005018908c810b1840856778482
+0,         30,         30,        1,   460800, 2541042038568329922fd6f7187aad49
+0,         31,         31,        1,   460800, 855b9ecfa9da66ef5971fcea7e515890
+0,         32,         32,        1,   460800, 85df610183efce5de91946cb909019c9
+0,         33,         33,        1,   460800, 369bce83d8aa0ac3cfb853b7e2886896
+0,         34,         34,        1,   460800, b428e7b294e5ac0d316971e02a25b12a
+0,         35,         35,        1,   460800, aa66321995b890e8dbd0d7b188ecb19c
+0,         36,         36,        1,   460800, 1533e3c85fd9d1f6710442653b936ef0
+0,         37,         37,        1,   460800, 99f3d38c95f1e4c0b442007a466f77cb
+0,         38,         38,        1,   460800, 30e007d8a4c0f0cfa22c8b6051980b59
+0,         39,         39,        1,   460800, fef21426b54048af617211234ee9b602
+0,         40,         40,        1,   460800, ff9a482c793a8e9950c0aa7e2845ca0e
+0,         41,         41,        1,   460800, ac0bb586786c35a51bdb6a5514ff54b9
+0,         42,         42,        1,   460800, bb008ec74fe642d6350bb1b4c922a6b0
+0,         43,         43,        1,   460800, 3e4255d1e817b9c6fa2cfbb0f198069d
+0,         44,         44,        1,   460800, 0fe04242f0441fa5c90e69ca015f4b2d
+0,         45,         45,        1,   460800, f14c12ec008a56c9aa99ef1be857ad23
+0,         46,         46,        1,   460800, 43ac558397b699ac82f7e12810c7ade9
diff --git a/tests/ref/fate/mov-1elist-noctts b/tests/ref/fate/mov-1elist-noctts
new file mode 100644
index 0000000..379d47a
--- /dev/null
+++ b/tests/ref/fate/mov-1elist-noctts
@@ -0,0 +1,57 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, 3dd21395fc5d3429f9b08492f47af093
+0,          1,          1,        1,   460800, 117009cceecc160c385dac3d344505c9
+0,          2,          2,        1,   460800, c093aa6e8747287cfeb758f2da7476d1
+0,          3,          3,        1,   460800, 6b7c94a3363f3381f7f930ac02b0c975
+0,          4,          4,        1,   460800, 87c3824a0ef3566f1a384c3c3e2b0d96
+0,          5,          5,        1,   460800, 3de48f3009a159e4737b5993102266de
+0,          6,          6,        1,   460800, 2be0ed1afe921093645af2ff917281ab
+0,          7,          7,        1,   460800, a89170c8413305fdba8d413a5080e57a
+0,          8,          8,        1,   460800, 5a3be131222c223ef8eccd9636330839
+0,          9,          9,        1,   460800, 01068b423526481b9732214c16b9e229
+0,         10,         10,        1,   460800, f9ea60560154e82d77e2661c34dca143
+0,         11,         11,        1,   460800, d77f5b82e34ea5a450076a85141a5618
+0,         12,         12,        1,   460800, 91ff4efcfc3a2301fb2329139e0e71a2
+0,         13,         13,        1,   460800, af8d914008f5f64f2ec1fadfae8bc697
+0,         14,         14,        1,   460800, abb2c4fd1f1ce3c449236da246b62bef
+0,         15,         15,        1,   460800, 66b0558f03dd5a472836fea045dd06ea
+0,         16,         16,        1,   460800, 224207d3e5b93fc4e8c71b782aabca51
+0,         17,         17,        1,   460800, ef975cfa7bc4de88f1333eb301f7ebdd
+0,         18,         18,        1,   460800, d75bf790003d2b1ee56bea0cef068e8e
+0,         19,         19,        1,   460800, d7a16935d7f808cca046db971e5b612a
+0,         20,         20,        1,   460800, f49d06ca4995c267fdc8c674c992cdd1
+0,         21,         21,        1,   460800, f53fd634154dec26ec85b6bef01ba890
+0,         22,         22,        1,   460800, d2d36371e50ace43ae4d2bab092a24c3
+0,         23,         23,        1,   460800, a4c08f4979e7dc914d69a170e198656c
+0,         24,         24,        1,   460800, 0d128e33f156fcc228d92117d56a5f93
+0,         25,         25,        1,   460800, 52fb8fc75c848ed9bc61d5129473f3fb
+0,         26,         26,        1,   460800, 5517f79d2ccb4fc93ede061bfcd632ea
+0,         27,         27,        1,   460800, c24fea9e8d02240328de3cb520904a6b
+0,         28,         28,        1,   460800, 0cbe46a4b91a0bd235d5e74084058e61
+0,         29,         29,        1,   460800, 355b17c2feb6b809c95bb71b333a670d
+0,         30,         30,        1,   460800, 063643ba941293ba95e024da202267cb
+0,         31,         31,        1,   460800, 8b31727d492fa9b25e025a1f45425b16
+0,         32,         32,        1,   460800, 45c5901c24d2ae2304b3e82c075a96bf
+0,         33,         33,        1,   460800, b7d4449d0e2157093727cb0f00648751
+0,         34,         34,        1,   460800, 167642e702f645853c974531853987f8
+0,         35,         35,        1,   460800, 2eb4596d675f099bab6c3b40ce30fd88
+0,         36,         36,        1,   460800, 8dd1aec35b92610cb22bedd3c54cb26a
+0,         37,         37,        1,   460800, 8eacf32e58d9a731467aba0f61d9e60f
+0,         38,         38,        1,   460800, 6a735f86d18ebe265894f633071a25d7
+0,         39,         39,        1,   460800, 843b0c938845b72e1c23bc39f7479cba
+0,         40,         40,        1,   460800, ca2099b43141cb9131505ab40ac3959f
+0,         41,         41,        1,   460800, e65322e1929def11f9985683365ab6bf
+0,         42,         42,        1,   460800, 565410a8c2f4b50a192f9590e6ab32c0
+0,         43,         43,        1,   460800, fa9a8ac625854cc279a07766ddad6e6f
+0,         44,         44,        1,   460800, a46ac62886c48edef3dc58de34a2a004
+0,         45,         45,        1,   460800, 414e01b6c24e71efc9c58f65dc0f4aca
+0,         46,         46,        1,   460800, e0501b903f21b490da049e51e7a02bae
+0,         47,         47,        1,   460800, 48b30eec1e9d862ee54b136045e1d90f
diff --git a/tests/ref/fate/mov-2elist-elist1-ends-bframe b/tests/ref/fate/mov-2elist-elist1-ends-bframe
new file mode 100644
index 0000000..76296ca
--- /dev/null
+++ b/tests/ref/fate/mov-2elist-elist1-ends-bframe
@@ -0,0 +1,51 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, b3d774603a22dbf9e952465c0d295166
+0,          1,          1,        1,   460800, d8f88e4269888dfadeb15bec662a3851
+0,          2,          2,        1,   460800, 6d6e686070143f797f8f1eca43d9cf28
+0,          3,          3,        1,   460800, a934f883968e71f22df044f043e61b14
+0,          4,          4,        1,   460800, 83dc65c7703f43ce97c87eea7191f69e
+0,          5,          5,        1,   460800, d633ab0dba64277b104ff5c2e1983424
+0,          6,          6,        1,   460800, 6c7d2c7481bd11584d68dbb9262d8351
+0,          7,          7,        1,   460800, 59b0bbc661b79ba82d726ca4d28255f2
+0,          8,          8,        1,   460800, 821cd7ca0adc4d6a3f10419b6c4283a6
+0,          9,          9,        1,   460800, 4655b1d6e8237b2e880f5b4140f7cf08
+0,         10,         10,        1,   460800, 264858653f9ac0623ffc87ca5e4c9939
+0,         11,         11,        1,   460800, b7129e91b9a6b4f8582747f12cafa52e
+0,         12,         12,        1,   460800, 1f6596fba655e213fd5c2ea99a891138
+0,         13,         13,        1,   460800, c8d67dc8fa8bdca263060ae542e55278
+0,         14,         14,        1,   460800, 57aa680b64b140eaeaa7f4250c12b59e
+0,         15,         15,        1,   460800, b87e8a9c0701cd8811dd38292b9994f7
+0,         16,         16,        1,   460800, 2427eb2900c8e18da0f36e47799a5ed8
+0,         17,         17,        1,   460800, 710a727a7ba51bc2938ca83376c6edd6
+0,         18,         18,        1,   460800, 620751271985df3728b6dbc627974183
+0,         19,         19,        1,   460800, 643719b26ac93f93d1674fee97c58a35
+0,         20,         20,        1,   460800, 5d3f8fa9abab0256afbf4285cd337804
+0,         21,         21,        1,   460800, a6c302c54c6481088f9c27189ecda5a8
+0,         22,         22,        1,   460800, 2851ad86c15a1dc7b6d4a0fe8f15de8f
+0,         23,         23,        1,   460800, 42157005018908c810b1840856778482
+0,         24,         24,        1,   460800, 2541042038568329922fd6f7187aad49
+0,         25,         25,        1,   460800, 855b9ecfa9da66ef5971fcea7e515890
+0,         26,         26,        1,   460800, 85df610183efce5de91946cb909019c9
+0,         27,         27,        1,   460800, 369bce83d8aa0ac3cfb853b7e2886896
+0,         28,         28,        1,   460800, b428e7b294e5ac0d316971e02a25b12a
+0,         29,         29,        1,   460800, aa66321995b890e8dbd0d7b188ecb19c
+0,         30,         30,        1,   460800, 1533e3c85fd9d1f6710442653b936ef0
+0,         31,         31,        1,   460800, 99f3d38c95f1e4c0b442007a466f77cb
+0,         32,         32,        1,   460800, 30e007d8a4c0f0cfa22c8b6051980b59
+0,         33,         33,        1,   460800, fef21426b54048af617211234ee9b602
+0,         34,         34,        1,   460800, ff9a482c793a8e9950c0aa7e2845ca0e
+0,         35,         35,        1,   460800, ac0bb586786c35a51bdb6a5514ff54b9
+0,         36,         36,        1,   460800, bb008ec74fe642d6350bb1b4c922a6b0
+0,         37,         37,        1,   460800, 3e4255d1e817b9c6fa2cfbb0f198069d
+0,         38,         38,        1,   460800, 0fe04242f0441fa5c90e69ca015f4b2d
+0,         39,         39,        1,   460800, f14c12ec008a56c9aa99ef1be857ad23
+0,         40,         40,        1,   460800, 43ac558397b699ac82f7e12810c7ade9
+0,         41,         41,        1,   460800, 35431eb1a8be4f05d08d23380655178c
diff --git a/tests/ref/fate/mov-3elist b/tests/ref/fate/mov-3elist
new file mode 100644
index 0000000..daf4927
--- /dev/null
+++ b/tests/ref/fate/mov-3elist
@@ -0,0 +1,57 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, 80fbbdec589e15e6c493b44d243f92a9
+0,          1,          1,        1,   460800, f4b23293bb2ecf69cc3570853d8c56a1
+0,          2,          2,        1,   460800, 0c03ce2c1c6ec405d7455465ecd559a3
+0,          3,          3,        1,   460800, 7921791695537fba2c3c123da4834cb9
+0,          4,          4,        1,   460800, 30c8e2903a561b84d4cbaf95c668d236
+0,          5,          5,        1,   460800, 7ff42e998217c17592ddf6b584f26cef
+0,          6,          6,        1,   460800, 5e402c48bf097db2d31b82bb4194a382
+0,          7,          7,        1,   460800, 824c49e92c8ae6d99a0207b514dd756c
+0,          8,          8,        1,   460800, 24f189216a1d9cf2313b2d6dbe3dbdd3
+0,          9,          9,        1,   460800, 519179a8e74275d26b183374637e003f
+0,         10,         10,        1,   460800, f18331ddcef0adf5b069bfa98baf8db4
+0,         11,         11,        1,   460800, 081f61688690d47dbdddd5384e5d5a70
+0,         12,         12,        1,   460800, 90dbf019b9035433371a8df41a9268b7
+0,         13,         13,        1,   460800, bb5adfb9c66732898b34186eca1667ba
+0,         14,         14,        1,   460800, cc08cfd64f37783ecddaf143f6ad78bc
+0,         15,         15,        1,   460800, b8ae21d024fe4df903d56f4521993c72
+0,         16,         16,        1,   460800, b45a99907f045dcadf0a2befc11555e3
+0,         17,         17,        1,   460800, 603ba935845e65ab6cccbbec88bbf60d
+0,         18,         18,        1,   460800, df80c8d3e6a77258a306903f17995a18
+0,         19,         19,        1,   460800, 4b7e90c0a5fd0e0cd958d47f0afac636
+0,         20,         20,        1,   460800, 9feb6e36182f1745be6387edea240eb6
+0,         21,         21,        1,   460800, 86e6de4bd0a5ff7558f4cf6c1ec3930d
+0,         22,         22,        1,   460800, 726b69df77edbe7b503d4698656d1320
+0,         23,         23,        1,   460800, d282fb7a953ac205b0a43d00c2d60a33
+0,         24,         24,        1,   460800, eece3daa70cc20208dd75d91ac84c8fd
+0,         25,         25,        1,   460800, c86d23e73bcce351fc315fb1f13348da
+0,         26,         26,        1,   460800, 93497b4f7c5ad9d61212239b7c9d2770
+0,         27,         27,        1,   460800, eb217d2c12de67903835a8c58f620488
+0,         28,         28,        1,   460800, d966480867bb54c8cd044f18388ed486
+0,         29,         29,        1,   460800, 3ea6207942b3181fdd8e8aa6cae1062a
+0,         30,         30,        1,   460800, 2620df54aca086ec0fb9527c6e6f5135
+0,         31,         31,        1,   460800, 43bb7320f0bb583188dc965ddbfade90
+0,         32,         32,        1,   460800, 0cddaa04645f804e02f65b0836412113
+0,         33,         33,        1,   460800, 83b2dc95807289d7f4a4632bf18c2e97
+0,         34,         34,        1,   460800, 98134d0e41e6dd12827049ccf33b4669
+0,         35,         35,        1,   460800, 56f55631731fa39c7acbab0afeb2eb1b
+0,         36,         36,        1,   460800, 379c1105be09d836a515dc909455ddf4
+0,         37,         37,        1,   460800, 1df87c47e9d98731faf1c3885b77e5da
+0,         38,         38,        1,   460800, 9a8734bcbfdb4d97e530683b8b556a26
+0,         39,         39,        1,   460800, c7a7990d0cddc5adfbe27da7a42e025e
+0,         40,         40,        1,   460800, 0c81e46011e03be410feaf056207fd55
+0,         41,         41,        1,   460800, ca76e4e63016ff29d8aeeb9cb053bb6c
+0,         42,         42,        1,   460800, cebfbe299c17c1f8fc1e6b189555c3c2
+0,         43,         43,        1,   460800, 4f002c5feca5e75f07089e0df47507dd
+0,         44,         44,        1,   460800, c5fd83fc4a745abee9b3d9a6eec9dd3e
+0,         45,         45,        1,   460800, 57d9bad9b45aa2746de5d8bdc2c24969
+0,         46,         46,        1,   460800, 9831673ad7dec167af4a959f64258949
+0,         47,         47,        1,   460800, 77a1cb208f70f51bcb01e28d8cba73b4
diff --git a/tests/ref/fate/mov-3elist-1ctts b/tests/ref/fate/mov-3elist-1ctts
new file mode 100644
index 0000000..379d47a
--- /dev/null
+++ b/tests/ref/fate/mov-3elist-1ctts
@@ -0,0 +1,57 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, 3dd21395fc5d3429f9b08492f47af093
+0,          1,          1,        1,   460800, 117009cceecc160c385dac3d344505c9
+0,          2,          2,        1,   460800, c093aa6e8747287cfeb758f2da7476d1
+0,          3,          3,        1,   460800, 6b7c94a3363f3381f7f930ac02b0c975
+0,          4,          4,        1,   460800, 87c3824a0ef3566f1a384c3c3e2b0d96
+0,          5,          5,        1,   460800, 3de48f3009a159e4737b5993102266de
+0,          6,          6,        1,   460800, 2be0ed1afe921093645af2ff917281ab
+0,          7,          7,        1,   460800, a89170c8413305fdba8d413a5080e57a
+0,          8,          8,        1,   460800, 5a3be131222c223ef8eccd9636330839
+0,          9,          9,        1,   460800, 01068b423526481b9732214c16b9e229
+0,         10,         10,        1,   460800, f9ea60560154e82d77e2661c34dca143
+0,         11,         11,        1,   460800, d77f5b82e34ea5a450076a85141a5618
+0,         12,         12,        1,   460800, 91ff4efcfc3a2301fb2329139e0e71a2
+0,         13,         13,        1,   460800, af8d914008f5f64f2ec1fadfae8bc697
+0,         14,         14,        1,   460800, abb2c4fd1f1ce3c449236da246b62bef
+0,         15,         15,        1,   460800, 66b0558f03dd5a472836fea045dd06ea
+0,         16,         16,        1,   460800, 224207d3e5b93fc4e8c71b782aabca51
+0,         17,         17,        1,   460800, ef975cfa7bc4de88f1333eb301f7ebdd
+0,         18,         18,        1,   460800, d75bf790003d2b1ee56bea0cef068e8e
+0,         19,         19,        1,   460800, d7a16935d7f808cca046db971e5b612a
+0,         20,         20,        1,   460800, f49d06ca4995c267fdc8c674c992cdd1
+0,         21,         21,        1,   460800, f53fd634154dec26ec85b6bef01ba890
+0,         22,         22,        1,   460800, d2d36371e50ace43ae4d2bab092a24c3
+0,         23,         23,        1,   460800, a4c08f4979e7dc914d69a170e198656c
+0,         24,         24,        1,   460800, 0d128e33f156fcc228d92117d56a5f93
+0,         25,         25,        1,   460800, 52fb8fc75c848ed9bc61d5129473f3fb
+0,         26,         26,        1,   460800, 5517f79d2ccb4fc93ede061bfcd632ea
+0,         27,         27,        1,   460800, c24fea9e8d02240328de3cb520904a6b
+0,         28,         28,        1,   460800, 0cbe46a4b91a0bd235d5e74084058e61
+0,         29,         29,        1,   460800, 355b17c2feb6b809c95bb71b333a670d
+0,         30,         30,        1,   460800, 063643ba941293ba95e024da202267cb
+0,         31,         31,        1,   460800, 8b31727d492fa9b25e025a1f45425b16
+0,         32,         32,        1,   460800, 45c5901c24d2ae2304b3e82c075a96bf
+0,         33,         33,        1,   460800, b7d4449d0e2157093727cb0f00648751
+0,         34,         34,        1,   460800, 167642e702f645853c974531853987f8
+0,         35,         35,        1,   460800, 2eb4596d675f099bab6c3b40ce30fd88
+0,         36,         36,        1,   460800, 8dd1aec35b92610cb22bedd3c54cb26a
+0,         37,         37,        1,   460800, 8eacf32e58d9a731467aba0f61d9e60f
+0,         38,         38,        1,   460800, 6a735f86d18ebe265894f633071a25d7
+0,         39,         39,        1,   460800, 843b0c938845b72e1c23bc39f7479cba
+0,         40,         40,        1,   460800, ca2099b43141cb9131505ab40ac3959f
+0,         41,         41,        1,   460800, e65322e1929def11f9985683365ab6bf
+0,         42,         42,        1,   460800, 565410a8c2f4b50a192f9590e6ab32c0
+0,         43,         43,        1,   460800, fa9a8ac625854cc279a07766ddad6e6f
+0,         44,         44,        1,   460800, a46ac62886c48edef3dc58de34a2a004
+0,         45,         45,        1,   460800, 414e01b6c24e71efc9c58f65dc0f4aca
+0,         46,         46,        1,   460800, e0501b903f21b490da049e51e7a02bae
+0,         47,         47,        1,   460800, 48b30eec1e9d862ee54b136045e1d90f
diff --git a/tests/ref/fate/mov-elist-starts-ctts-2ndsample b/tests/ref/fate/mov-elist-starts-ctts-2ndsample
new file mode 100644
index 0000000..1287a40
--- /dev/null
+++ b/tests/ref/fate/mov-elist-starts-ctts-2ndsample
@@ -0,0 +1,57 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/24
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 0/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   460800, e2ec4074e83dd4f9188915b6b08aa3a2
+0,          1,          1,        1,   460800, 9ed1ba935bc22ef03e6f8fd5b0b37ee6
+0,          2,          2,        1,   460800, 3f1c536514750de86571122046b5858f
+0,          3,          3,        1,   460800, 4f7943cb6f7966d19d344081b0db0d71
+0,          4,          4,        1,   460800, 0661f34eb45398f8cd158b5a1637bd96
+0,          5,          5,        1,   460800, 177620fa17c4d6fddad1d31c1605e46e
+0,          6,          6,        1,   460800, 8e22cde58a50e0279be01c23dfd7c032
+0,          7,          7,        1,   460800, 8c74c4d8ceee929fded82eeb7a0a7c29
+0,          8,          8,        1,   460800, a50d00a8868f0722be55fa5953bc6ebf
+0,          9,          9,        1,   460800, f791233c8904da4e267bf7bcf5d6201e
+0,         10,         10,        1,   460800, 4ff703ef573eb8e88639d3c700645bf8
+0,         11,         11,        1,   460800, fd4c98487779aa7783e9fb3e874f9c8b
+0,         12,         12,        1,   460800, e11fbc6c36ad086ea6e611ddd28b211c
+0,         13,         13,        1,   460800, a63b8af666ee30a243cf9ea0d49834b5
+0,         14,         14,        1,   460800, 1cec6499bfaf054bf581efdab72f5799
+0,         15,         15,        1,   460800, 5cb8ea5a7158cac1112fc6453b2a577f
+0,         16,         16,        1,   460800, 2df256cb311f97f4648cdeee41ba20d1
+0,         17,         17,        1,   460800, afb2c133204a99fe434767340f50c2b9
+0,         18,         18,        1,   460800, 27c802932fa873af8663a6b8733391d7
+0,         19,         19,        1,   460800, c53872c43baf56d496811d2809ebcd9b
+0,         20,         20,        1,   460800, d3ca26ecb6bec6bfa508f07e2a66fa3a
+0,         21,         21,        1,   460800, 2d44e18ccf734fe0ed98a7ce1e361fe7
+0,         22,         22,        1,   460800, ac4078b5426e4664029923ccf6ea3377
+0,         23,         23,        1,   460800, 60d4460a8b97e58e72c12d0c7334b4e4
+0,         24,         24,        1,   460800, 95bceab68b4ecf5df261ff9d3743041a
+0,         25,         25,        1,   460800, 0b80ad5bf2afbfbe512b83af797afd84
+0,         26,         26,        1,   460800, fbc70468f9331a0538e8c09ec3ead20e
+0,         27,         27,        1,   460800, de0578b4a114235250b7e93e9f9bf6de
+0,         28,         28,        1,   460800, 72f50490650b718e394822f8873ad071
+0,         29,         29,        1,   460800, b26594051d313892823eef711a08dc00
+0,         30,         30,        1,   460800, 1122641658f6b433e82080e092fe6943
+0,         31,         31,        1,   460800, aae4ddc51bcbdf9428f68069f5881090
+0,         32,         32,        1,   460800, 018047addf7fd2ef4f1d231d69187bf5
+0,         33,         33,        1,   460800, bd03ace29c974b64e2a7a4cc815ec582
+0,         34,         34,        1,   460800, 7fddacb17f01d8facfb09df44ff8bdfd
+0,         35,         35,        1,   460800, e8d84d6b3406404900b8342183f6ada7
+0,         36,         36,        1,   460800, 5b24faed4fdd21bf9a1218658a113009
+0,         37,         37,        1,   460800, 8d82775c56b6b0ab31db0c522999b0a1
+0,         38,         38,        1,   460800, 282e5e03295c80b2a7b472b82c57483d
+0,         39,         39,        1,   460800, 0ad41f5975c2466fc3166ea20bde6842
+0,         40,         40,        1,   460800, 1439ad336ceafda0ad62355a7d0b6e50
+0,         41,         41,        1,   460800, d3a97471ad64ac2378591d4f6eadba1c
+0,         42,         42,        1,   460800, a40c32a1e589b103f639f2068b71bf02
+0,         43,         43,        1,   460800, a339b2bedc7ef46961f8502089abfb87
+0,         44,         44,        1,   460800, 2ccde43c94259682ea72188b08489e92
+0,         45,         45,        1,   460800, fc47cca1f029d44ec92d95853e9c46b4
+0,         46,         46,        1,   460800, 6c4d3b63dc1d4291ec88a4bb8c35aecd
+0,         47,         47,        1,   460800, 7a9be67aca439dd2a7ff17447b478974
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
