Merge commit '59e8ec0aa8ab174701d01a3bfe96fedd0b7fcead'
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>
Mon, 16 Nov 2015 16:18:42 +0000 (16:18 +0000)
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>
Mon, 16 Nov 2015 16:19:27 +0000 (16:19 +0000)
All diferences in unit tests have been acounted for.

* commit '59e8ec0aa8ab174701d01a3bfe96fedd0b7fcead':
  movenc: Add an API unit test for fragmenting options/calls

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
1  2 
libavformat/Makefile
libavformat/movenc-test.c
tests/fate/libavformat.mak
tests/ref/fate/movenc
tests/ref/fate/source

diff --combined libavformat/Makefile
@@@ -1,5 -1,3 +1,5 @@@
 +include $(SUBDIR)../config.mak
 +
  NAME = avformat
  
  HEADERS = avformat.h                                                    \
@@@ -14,6 -12,7 +14,6 @@@ OBJS = allformats.o         
         format.o             \
         id3v1.o              \
         id3v2.o              \
 -       log2_tab.o           \
         metadata.o           \
         mux.o                \
         options.o            \
@@@ -55,102 -54,66 +55,102 @@@ OBJS-$(CONFIG_RTPDEC
                                              rtpdec_xiph.o               \
                                              srtp.o
  OBJS-$(CONFIG_RTPENC_CHAIN)              += rtpenc_chain.o rtp.o
 +OBJS-$(CONFIG_SHARED)                    += log2_tab.o golomb_tab.o
  
  # muxers/demuxers
  OBJS-$(CONFIG_A64_MUXER)                 += a64.o rawenc.o
 -OBJS-$(CONFIG_AAC_DEMUXER)               += aacdec.o rawdec.o
 +OBJS-$(CONFIG_AA_DEMUXER)                += aadec.o
 +OBJS-$(CONFIG_AAC_DEMUXER)               += aacdec.o apetag.o img2.o rawdec.o
  OBJS-$(CONFIG_AC3_DEMUXER)               += ac3dec.o rawdec.o
  OBJS-$(CONFIG_AC3_MUXER)                 += rawenc.o
 +OBJS-$(CONFIG_ACM_DEMUXER)               += acm.o rawdec.o
 +OBJS-$(CONFIG_ACT_DEMUXER)               += act.o
 +OBJS-$(CONFIG_ADF_DEMUXER)               += bintext.o sauce.o
 +OBJS-$(CONFIG_ADP_DEMUXER)               += adp.o
 +OBJS-$(CONFIG_ADS_DEMUXER)               += ads.o
  OBJS-$(CONFIG_ADX_DEMUXER)               += adxdec.o
  OBJS-$(CONFIG_ADX_MUXER)                 += rawenc.o
 -OBJS-$(CONFIG_ADTS_MUXER)                += adtsenc.o
 +OBJS-$(CONFIG_ADTS_MUXER)                += adtsenc.o apetag.o img2.o \
 +                                            id3v2enc.o
  OBJS-$(CONFIG_AEA_DEMUXER)               += aea.o pcm.o
 -OBJS-$(CONFIG_AIFF_DEMUXER)              += aiffdec.o pcm.o
 -OBJS-$(CONFIG_AIFF_MUXER)                += aiffenc.o
 +OBJS-$(CONFIG_AFC_DEMUXER)               += afc.o
 +OBJS-$(CONFIG_AIFF_DEMUXER)              += aiffdec.o pcm.o isom.o \
 +                                            mov_chan.o
 +OBJS-$(CONFIG_AIFF_MUXER)                += aiffenc.o isom.o id3v2enc.o
  OBJS-$(CONFIG_AMR_DEMUXER)               += amr.o
  OBJS-$(CONFIG_AMR_MUXER)                 += amr.o
  OBJS-$(CONFIG_ANM_DEMUXER)               += anm.o
  OBJS-$(CONFIG_APC_DEMUXER)               += apc.o
  OBJS-$(CONFIG_APE_DEMUXER)               += ape.o apetag.o img2.o
 -OBJS-$(CONFIG_ASF_DEMUXER)               += asfdec.o asf.o asfcrypt.o \
 +OBJS-$(CONFIG_APNG_DEMUXER)              += apngdec.o
 +OBJS-$(CONFIG_APNG_MUXER)                += apngenc.o
 +OBJS-$(CONFIG_AQTITLE_DEMUXER)           += aqtitledec.o subtitles.o
 +OBJS-$(CONFIG_ASF_DEMUXER)               += asfdec_f.o asf.o asfcrypt.o \
 +                                            avlanguage.o
 +OBJS-$(CONFIG_ASF_O_DEMUXER)             += asfdec_o.o asf.o asfcrypt.o \
                                              avlanguage.o
  OBJS-$(CONFIG_ASF_MUXER)                 += asfenc.o asf.o
 -OBJS-$(CONFIG_ASS_DEMUXER)               += assdec.o
 +OBJS-$(CONFIG_ASS_DEMUXER)               += assdec.o subtitles.o
  OBJS-$(CONFIG_ASS_MUXER)                 += assenc.o
 +OBJS-$(CONFIG_AST_DEMUXER)               += ast.o astdec.o
 +OBJS-$(CONFIG_AST_MUXER)                 += ast.o astenc.o
  OBJS-$(CONFIG_AU_DEMUXER)                += au.o pcm.o
  OBJS-$(CONFIG_AU_MUXER)                  += au.o rawenc.o
  OBJS-$(CONFIG_AVI_DEMUXER)               += avidec.o isom.o
 -OBJS-$(CONFIG_AVI_MUXER)                 += avienc.o
 +OBJS-$(CONFIG_AVI_MUXER)                 += avienc.o mpegtsenc.o avlanguage.o
  OBJS-$(CONFIG_AVISYNTH)                  += avisynth.o
  OBJS-$(CONFIG_AVM2_MUXER)                += swfenc.o swf.o
 +OBJS-$(CONFIG_AVR_DEMUXER)               += avr.o pcm.o
  OBJS-$(CONFIG_AVS_DEMUXER)               += avs.o vocdec.o voc.o
  OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)       += bethsoftvid.o
  OBJS-$(CONFIG_BFI_DEMUXER)               += bfi.o
  OBJS-$(CONFIG_BINK_DEMUXER)              += bink.o
 +OBJS-$(CONFIG_BINTEXT_DEMUXER)           += bintext.o sauce.o
 +OBJS-$(CONFIG_BIT_DEMUXER)               += bit.o
 +OBJS-$(CONFIG_BIT_MUXER)                 += bit.o
  OBJS-$(CONFIG_BMV_DEMUXER)               += bmv.o
 +OBJS-$(CONFIG_BOA_DEMUXER)               += boadec.o
 +OBJS-$(CONFIG_BFSTM_DEMUXER)             += brstm.o
 +OBJS-$(CONFIG_BRSTM_DEMUXER)             += brstm.o
  OBJS-$(CONFIG_C93_DEMUXER)               += c93.o vocdec.o voc.o
  OBJS-$(CONFIG_CAF_DEMUXER)               += cafdec.o caf.o mov.o mov_chan.o \
                                              isom.o replaygain.o
 +OBJS-$(CONFIG_CAF_MUXER)                 += cafenc.o caf.o riff.o isom.o
  OBJS-$(CONFIG_CAVSVIDEO_DEMUXER)         += cavsvideodec.o rawdec.o
  OBJS-$(CONFIG_CAVSVIDEO_MUXER)           += rawenc.o
  OBJS-$(CONFIG_CDG_DEMUXER)               += cdg.o
  OBJS-$(CONFIG_CDXL_DEMUXER)              += cdxl.o
 +OBJS-$(CONFIG_CINE_DEMUXER)              += cinedec.o
 +OBJS-$(CONFIG_CONCAT_DEMUXER)            += concatdec.o
  OBJS-$(CONFIG_CRC_MUXER)                 += crcenc.o
 +OBJS-$(CONFIG_DATA_DEMUXER)              += rawdec.o
 +OBJS-$(CONFIG_DATA_MUXER)                += rawdec.o
  OBJS-$(CONFIG_DASH_MUXER)                += dashenc.o isom.o
  OBJS-$(CONFIG_DAUD_DEMUXER)              += dauddec.o
  OBJS-$(CONFIG_DAUD_MUXER)                += daudenc.o
 +OBJS-$(CONFIG_DCSTR_DEMUXER)             += dcstr.o
  OBJS-$(CONFIG_DFA_DEMUXER)               += dfa.o
  OBJS-$(CONFIG_DIRAC_DEMUXER)             += diracdec.o rawdec.o
  OBJS-$(CONFIG_DIRAC_MUXER)               += rawenc.o
  OBJS-$(CONFIG_DNXHD_DEMUXER)             += dnxhddec.o rawdec.o
  OBJS-$(CONFIG_DNXHD_MUXER)               += rawenc.o
 +OBJS-$(CONFIG_DSF_DEMUXER)               += dsfdec.o
  OBJS-$(CONFIG_DSICIN_DEMUXER)            += dsicin.o
  OBJS-$(CONFIG_DSS_DEMUXER)               += dss.o
 +OBJS-$(CONFIG_DTSHD_DEMUXER)             += dtshddec.o
  OBJS-$(CONFIG_DTS_DEMUXER)               += dtsdec.o rawdec.o
  OBJS-$(CONFIG_DTS_MUXER)                 += rawenc.o
  OBJS-$(CONFIG_DV_DEMUXER)                += dv.o
  OBJS-$(CONFIG_DV_MUXER)                  += dvenc.o
 +OBJS-$(CONFIG_DVBSUB_DEMUXER)            += dvbsub.o
  OBJS-$(CONFIG_DXA_DEMUXER)               += dxa.o
  OBJS-$(CONFIG_EA_CDATA_DEMUXER)          += eacdata.o
  OBJS-$(CONFIG_EA_DEMUXER)                += electronicarts.o
  OBJS-$(CONFIG_EAC3_DEMUXER)              += ac3dec.o rawdec.o
  OBJS-$(CONFIG_EAC3_MUXER)                += rawenc.o
 +OBJS-$(CONFIG_EPAF_DEMUXER)              += epafdec.o pcm.o
 +OBJS-$(CONFIG_FFM_DEMUXER)               += ffmdec.o
 +OBJS-$(CONFIG_FFM_MUXER)                 += ffmenc.o
  OBJS-$(CONFIG_FFMETADATA_DEMUXER)        += ffmetadec.o
  OBJS-$(CONFIG_FFMETADATA_MUXER)          += ffmetaenc.o
  OBJS-$(CONFIG_FILMSTRIP_DEMUXER)         += filmstripdec.o
@@@ -164,23 -127,17 +164,23 @@@ OBJS-$(CONFIG_FLAC_MUXER
                                              vorbiscomment.o
  OBJS-$(CONFIG_FLIC_DEMUXER)              += flic.o
  OBJS-$(CONFIG_FLV_DEMUXER)               += flvdec.o
 +OBJS-$(CONFIG_LIVE_FLV_DEMUXER)          += flvdec.o
  OBJS-$(CONFIG_FLV_MUXER)                 += flvenc.o avc.o
  OBJS-$(CONFIG_FOURXM_DEMUXER)            += 4xm.o
  OBJS-$(CONFIG_FRAMECRC_MUXER)            += framecrcenc.o framehash.o
  OBJS-$(CONFIG_FRAMEMD5_MUXER)            += md5enc.o framehash.o
 +OBJS-$(CONFIG_FRM_DEMUXER)               += frmdec.o
  OBJS-$(CONFIG_GIF_MUXER)                 += gif.o
 +OBJS-$(CONFIG_GIF_DEMUXER)               += gifdec.o
  OBJS-$(CONFIG_GSM_DEMUXER)               += gsmdec.o
  OBJS-$(CONFIG_GXF_DEMUXER)               += gxf.o
  OBJS-$(CONFIG_GXF_MUXER)                 += gxfenc.o audiointerleave.o
  OBJS-$(CONFIG_G722_DEMUXER)              += g722.o rawdec.o
  OBJS-$(CONFIG_G722_MUXER)                += rawenc.o
  OBJS-$(CONFIG_G723_1_DEMUXER)            += g723_1.o
 +OBJS-$(CONFIG_G723_1_MUXER)              += rawenc.o
 +OBJS-$(CONFIG_G729_DEMUXER)              += g729dec.o
 +OBJS-$(CONFIG_GENH_DEMUXER)              += genh.o
  OBJS-$(CONFIG_H261_DEMUXER)              += h261dec.o rawdec.o
  OBJS-$(CONFIG_H261_MUXER)                += rawenc.o
  OBJS-$(CONFIG_H263_DEMUXER)              += h263dec.o rawdec.o
@@@ -193,10 -150,7 +193,10 @@@ OBJS-$(CONFIG_HEVC_MUXER
  OBJS-$(CONFIG_HLS_DEMUXER)               += hls.o
  OBJS-$(CONFIG_HLS_MUXER)                 += hlsenc.o
  OBJS-$(CONFIG_HNM_DEMUXER)               += hnm.o
 +OBJS-$(CONFIG_ICO_DEMUXER)               += icodec.o
 +OBJS-$(CONFIG_ICO_MUXER)                 += icoenc.o
  OBJS-$(CONFIG_IDCIN_DEMUXER)             += idcin.o
 +OBJS-$(CONFIG_IDF_DEMUXER)               += bintext.o sauce.o
  OBJS-$(CONFIG_IFF_DEMUXER)               += iff.o
  OBJS-$(CONFIG_ILBC_DEMUXER)              += ilbc.o
  OBJS-$(CONFIG_ILBC_MUXER)                += ilbc.o
@@@ -204,65 -158,37 +204,65 @@@ OBJS-$(CONFIG_IMAGE2_DEMUXER
  OBJS-$(CONFIG_IMAGE2_MUXER)              += img2enc.o img2.o
  OBJS-$(CONFIG_IMAGE2PIPE_DEMUXER)        += img2dec.o img2.o
  OBJS-$(CONFIG_IMAGE2PIPE_MUXER)          += img2enc.o img2.o
 +OBJS-$(CONFIG_IMAGE2_ALIAS_PIX_DEMUXER)  += img2_alias_pix.o
 +OBJS-$(CONFIG_IMAGE2_BRENDER_PIX_DEMUXER) += img2_brender_pix.o
 +OBJS-$(CONFIG_IMAGE_BMP_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_DDS_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_DPX_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_EXR_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_J2K_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_JPEG_PIPE_DEMUXER)    += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER)  += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_PICTOR_PIPE_DEMUXER)  += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_PNG_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER)   += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER)     += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_TIFF_PIPE_DEMUXER)    += img2dec.o img2.o
 +OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER)    += img2dec.o img2.o
  OBJS-$(CONFIG_INGENIENT_DEMUXER)         += ingenientdec.o rawdec.o
  OBJS-$(CONFIG_IPMOVIE_DEMUXER)           += ipmovie.o
 +OBJS-$(CONFIG_IRCAM_DEMUXER)             += ircamdec.o ircam.o pcm.o
 +OBJS-$(CONFIG_IRCAM_MUXER)               += ircamenc.o ircam.o rawenc.o
  OBJS-$(CONFIG_ISS_DEMUXER)               += iss.o
  OBJS-$(CONFIG_IV8_DEMUXER)               += iv8.o
  OBJS-$(CONFIG_IVF_DEMUXER)               += ivfdec.o
  OBJS-$(CONFIG_IVF_MUXER)                 += ivfenc.o
 +OBJS-$(CONFIG_JACOSUB_DEMUXER)           += jacosubdec.o subtitles.o
 +OBJS-$(CONFIG_JACOSUB_MUXER)             += jacosubenc.o rawenc.o
  OBJS-$(CONFIG_JV_DEMUXER)                += jvdec.o
 -OBJS-$(CONFIG_LATM_DEMUXER)              += rawdec.o
 -OBJS-$(CONFIG_LATM_MUXER)                += latmenc.o
 +OBJS-$(CONFIG_LATM_MUXER)                += latmenc.o rawenc.o
  OBJS-$(CONFIG_LMLM4_DEMUXER)             += lmlm4.o
 +OBJS-$(CONFIG_LOAS_DEMUXER)              += loasdec.o rawdec.o
 +OBJS-$(CONFIG_LRC_DEMUXER)               += lrcdec.o lrc.o subtitles.o
 +OBJS-$(CONFIG_LRC_MUXER)                 += lrcenc.o lrc.o
 +OBJS-$(CONFIG_LVF_DEMUXER)               += lvfdec.o
  OBJS-$(CONFIG_LXF_DEMUXER)               += lxfdec.o
  OBJS-$(CONFIG_M4V_DEMUXER)               += m4vdec.o rawdec.o
  OBJS-$(CONFIG_M4V_MUXER)                 += rawenc.o
  OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o matroska.o  \
 -                                            isom.o rmsipr.o \
 +                                            isom.o rmsipr.o flac_picture.o \
                                              oggparsevorbis.o vorbiscomment.o \
                                              flac_picture.o replaygain.o
  OBJS-$(CONFIG_MATROSKA_MUXER)            += matroskaenc.o matroska.o \
                                              isom.o avc.o hevc.o \
 -                                            flacenc_header.o avlanguage.o vorbiscomment.o wv.o
 +                                            flacenc_header.o avlanguage.o vorbiscomment.o wv.o \
 +                                            webmdashenc.o webm_chunk.o
  OBJS-$(CONFIG_MD5_MUXER)                 += md5enc.o
 +OBJS-$(CONFIG_MGSTS_DEMUXER)             += mgsts.o
 +OBJS-$(CONFIG_MICRODVD_DEMUXER)          += microdvddec.o subtitles.o
 +OBJS-$(CONFIG_MICRODVD_MUXER)            += microdvdenc.o
  OBJS-$(CONFIG_MJPEG_DEMUXER)             += rawdec.o
  OBJS-$(CONFIG_MJPEG_MUXER)               += rawenc.o
 -OBJS-$(CONFIG_MLP_DEMUXER)               += rawdec.o
 +OBJS-$(CONFIG_MLP_DEMUXER)               += rawdec.o mlpdec.o
  OBJS-$(CONFIG_MLP_MUXER)                 += rawenc.o
 +OBJS-$(CONFIG_MLV_DEMUXER)               += mlvdec.o riffdec.o
  OBJS-$(CONFIG_MM_DEMUXER)                += mm.o
 -OBJS-$(CONFIG_MMF_DEMUXER)               += mmf.o pcm.o
 -OBJS-$(CONFIG_MMF_MUXER)                 += mmf.o
 +OBJS-$(CONFIG_MMF_DEMUXER)               += mmf.o
 +OBJS-$(CONFIG_MMF_MUXER)                 += mmf.o rawenc.o
  OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o isom.o mov_chan.o replaygain.o
  OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o isom.o avc.o hevc.o \
 -                                            movenchint.o mov_chan.o
 +                                            movenchint.o mov_chan.o rtp.o
  OBJS-$(CONFIG_MP2_MUXER)                 += mp3enc.o rawenc.o id3v2enc.o
  OBJS-$(CONFIG_MP3_DEMUXER)               += mp3dec.o replaygain.o
  OBJS-$(CONFIG_MP3_MUXER)                 += mp3enc.o rawenc.o id3v2enc.o
@@@ -281,9 -207,6 +281,9 @@@ OBJS-$(CONFIG_MPEGTS_MUXER
  OBJS-$(CONFIG_MPEGVIDEO_DEMUXER)         += mpegvideodec.o rawdec.o
  OBJS-$(CONFIG_MPJPEG_DEMUXER)            += mpjpegdec.o
  OBJS-$(CONFIG_MPJPEG_MUXER)              += mpjpeg.o
 +OBJS-$(CONFIG_MPL2_DEMUXER)              += mpl2dec.o subtitles.o
 +OBJS-$(CONFIG_MSF_DEMUXER)               += msf.o
 +OBJS-$(CONFIG_MPSUB_DEMUXER)             += mpsubdec.o subtitles.o
  OBJS-$(CONFIG_MSNWC_TCP_DEMUXER)         += msnwc_tcp.o
  OBJS-$(CONFIG_MTV_DEMUXER)               += mtv.o
  OBJS-$(CONFIG_MV_DEMUXER)                += mvdec.o
@@@ -292,15 -215,13 +292,15 @@@ OBJS-$(CONFIG_MXF_DEMUXER
  OBJS-$(CONFIG_MXF_MUXER)                 += mxfenc.o mxf.o audiointerleave.o
  OBJS-$(CONFIG_MXG_DEMUXER)               += mxg.o
  OBJS-$(CONFIG_NC_DEMUXER)                += ncdec.o
 +OBJS-$(CONFIG_NISTSPHERE_DEMUXER)        += nistspheredec.o pcm.o
  OBJS-$(CONFIG_NSV_DEMUXER)               += nsvdec.o
  OBJS-$(CONFIG_NULL_MUXER)                += nullenc.o
 -OBJS-$(CONFIG_NUT_DEMUXER)               += nutdec.o nut.o
 +OBJS-$(CONFIG_NUT_DEMUXER)               += nutdec.o nut.o isom.o
  OBJS-$(CONFIG_NUT_MUXER)                 += nutenc.o nut.o
  OBJS-$(CONFIG_NUV_DEMUXER)               += nuv.o
  OBJS-$(CONFIG_OGG_DEMUXER)               += oggdec.o         \
                                              oggparsecelt.o   \
 +                                            oggparsedaala.o  \
                                              oggparsedirac.o  \
                                              oggparseflac.o   \
                                              oggparseogm.o    \
                                              replaygain.o     \
                                              vorbiscomment.o  \
                                              flac_picture.o
 +OBJS-$(CONFIG_OGA_MUXER)                 += oggenc.o \
 +                                            vorbiscomment.o
  OBJS-$(CONFIG_OGG_MUXER)                 += oggenc.o \
                                              vorbiscomment.o
  OBJS-$(CONFIG_OMA_DEMUXER)               += omadec.o pcm.o oma.o
  OBJS-$(CONFIG_OMA_MUXER)                 += omaenc.o rawenc.o oma.o id3v2enc.o
 +OBJS-$(CONFIG_OPUS_MUXER)                += oggenc.o \
 +                                            vorbiscomment.o
  OBJS-$(CONFIG_PAF_DEMUXER)               += paf.o
  OBJS-$(CONFIG_PCM_ALAW_DEMUXER)          += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_ALAW_MUXER)            += pcmenc.o rawenc.o
@@@ -362,22 -279,17 +362,22 @@@ OBJS-$(CONFIG_PCM_U32LE_DEMUXER
  OBJS-$(CONFIG_PCM_U32LE_MUXER)           += pcmenc.o rawenc.o
  OBJS-$(CONFIG_PCM_U8_DEMUXER)            += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U8_MUXER)              += pcmenc.o rawenc.o
 +OBJS-$(CONFIG_PJS_DEMUXER)               += pjsdec.o subtitles.o
  OBJS-$(CONFIG_PMP_DEMUXER)               += pmpdec.o
  OBJS-$(CONFIG_PVA_DEMUXER)               += pva.o
 +OBJS-$(CONFIG_PVF_DEMUXER)               += pvfdec.o pcm.o
  OBJS-$(CONFIG_QCP_DEMUXER)               += qcp.o
  OBJS-$(CONFIG_R3D_DEMUXER)               += r3d.o
  OBJS-$(CONFIG_RAWVIDEO_DEMUXER)          += rawvideodec.o
  OBJS-$(CONFIG_RAWVIDEO_MUXER)            += rawenc.o
 +OBJS-$(CONFIG_REALTEXT_DEMUXER)          += realtextdec.o subtitles.o
 +OBJS-$(CONFIG_REDSPARK_DEMUXER)          += redspark.o
  OBJS-$(CONFIG_RL2_DEMUXER)               += rl2.o
  OBJS-$(CONFIG_RM_DEMUXER)                += rmdec.o rm.o rmsipr.o
  OBJS-$(CONFIG_RM_MUXER)                  += rmenc.o rm.o
  OBJS-$(CONFIG_ROQ_DEMUXER)               += idroqdec.o
  OBJS-$(CONFIG_ROQ_MUXER)                 += idroqenc.o rawenc.o
 +OBJS-$(CONFIG_RSD_DEMUXER)               += rsd.o
  OBJS-$(CONFIG_RSO_DEMUXER)               += rsodec.o rso.o pcm.o
  OBJS-$(CONFIG_RSO_MUXER)                 += rsoenc.o rso.o
  OBJS-$(CONFIG_RPL_DEMUXER)               += rpl.o
@@@ -400,17 -312,13 +400,17 @@@ OBJS-$(CONFIG_RTSP_DEMUXER
                                              urldecode.o
  OBJS-$(CONFIG_RTSP_MUXER)                += rtsp.o rtspenc.o httpauth.o \
                                              urldecode.o
 +OBJS-$(CONFIG_SAMI_DEMUXER)              += samidec.o subtitles.o
  OBJS-$(CONFIG_SAP_DEMUXER)               += sapdec.o
  OBJS-$(CONFIG_SAP_MUXER)                 += sapenc.o
 +OBJS-$(CONFIG_SBG_DEMUXER)               += sbgdec.o
  OBJS-$(CONFIG_SDP_DEMUXER)               += rtsp.o
 +OBJS-$(CONFIG_SDR2_DEMUXER)              += sdr2.o
  OBJS-$(CONFIG_SEGAFILM_DEMUXER)          += segafilm.o
  OBJS-$(CONFIG_SEGMENT_MUXER)             += segment.o
 -OBJS-$(CONFIG_SHORTEN_DEMUXER)           += rawdec.o
 +OBJS-$(CONFIG_SHORTEN_DEMUXER)           += shortendec.o rawdec.o
  OBJS-$(CONFIG_SIFF_DEMUXER)              += siff.o
 +OBJS-$(CONFIG_SINGLEJPEG_MUXER)          += rawenc.o
  OBJS-$(CONFIG_SMACKER_DEMUXER)           += smacker.o
  OBJS-$(CONFIG_SMJPEG_DEMUXER)            += smjpegdec.o smjpeg.o
  OBJS-$(CONFIG_SMJPEG_MUXER)              += smjpegenc.o smjpeg.o
@@@ -418,109 -326,61 +418,109 @@@ OBJS-$(CONFIG_SMOOTHSTREAMING_MUXER
  OBJS-$(CONFIG_SMUSH_DEMUXER)             += smush.o
  OBJS-$(CONFIG_SOL_DEMUXER)               += sol.o pcm.o
  OBJS-$(CONFIG_SOX_DEMUXER)               += soxdec.o pcm.o
 -OBJS-$(CONFIG_SOX_MUXER)                 += soxenc.o
 +OBJS-$(CONFIG_SOX_MUXER)                 += soxenc.o rawenc.o
  OBJS-$(CONFIG_SPDIF_DEMUXER)             += spdif.o spdifdec.o
  OBJS-$(CONFIG_SPDIF_MUXER)               += spdif.o spdifenc.o
 -OBJS-$(CONFIG_SRT_DEMUXER)               += srtdec.o
 -OBJS-$(CONFIG_SRT_MUXER)                 += rawenc.o
 +OBJS-$(CONFIG_SPEEX_MUXER)               += oggenc.o \
 +                                            vorbiscomment.o
 +OBJS-$(CONFIG_SRT_DEMUXER)               += srtdec.o subtitles.o
 +OBJS-$(CONFIG_SRT_MUXER)                 += srtenc.o
 +OBJS-$(CONFIG_STL_DEMUXER)               += stldec.o subtitles.o
  OBJS-$(CONFIG_STR_DEMUXER)               += psxstr.o
 +OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)        += subviewer1dec.o subtitles.o
 +OBJS-$(CONFIG_SUBVIEWER_DEMUXER)         += subviewerdec.o subtitles.o
 +OBJS-$(CONFIG_SUP_DEMUXER)               += supdec.o
 +OBJS-$(CONFIG_SVAG_DEMUXER)              += svag.o
  OBJS-$(CONFIG_SWF_DEMUXER)               += swfdec.o swf.o
  OBJS-$(CONFIG_SWF_MUXER)                 += swfenc.o swf.o
  OBJS-$(CONFIG_TAK_DEMUXER)               += takdec.o apetag.o img2.o rawdec.o
 +OBJS-$(CONFIG_TEDCAPTIONS_DEMUXER)       += tedcaptionsdec.o subtitles.o
 +OBJS-$(CONFIG_TEE_MUXER)                 += tee.o
  OBJS-$(CONFIG_THP_DEMUXER)               += thp.o
 +OBJS-$(CONFIG_THREEDOSTR_DEMUXER)        += 3dostr.o
  OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER)        += tiertexseq.o
 +OBJS-$(CONFIG_MKVTIMESTAMP_V2_MUXER)     += mkvtimestamp_v2.o
  OBJS-$(CONFIG_TMV_DEMUXER)               += tmv.o
 -OBJS-$(CONFIG_TRUEHD_DEMUXER)            += rawdec.o
 +OBJS-$(CONFIG_TRUEHD_DEMUXER)            += rawdec.o mlpdec.o
  OBJS-$(CONFIG_TRUEHD_MUXER)              += rawenc.o
 -OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o
 +OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o apetag.o img2.o
  OBJS-$(CONFIG_TTY_DEMUXER)               += tty.o sauce.o
  OBJS-$(CONFIG_TXD_DEMUXER)               += txd.o
 -OBJS-$(CONFIG_VC1_DEMUXER)               += rawdec.o
 +OBJS-$(CONFIG_UNCODEDFRAMECRC_MUXER)     += uncodedframecrcenc.o framehash.o
 +OBJS-$(CONFIG_V210_DEMUXER)              += v210.o
 +OBJS-$(CONFIG_V210X_DEMUXER)             += v210.o
 +OBJS-$(CONFIG_VAG_DEMUXER)               += vag.o
 +OBJS-$(CONFIG_VC1_DEMUXER)               += rawdec.o vc1dec.o
 +OBJS-$(CONFIG_VC1_MUXER)                 += rawenc.o
  OBJS-$(CONFIG_VC1T_DEMUXER)              += vc1test.o
  OBJS-$(CONFIG_VC1T_MUXER)                += vc1testenc.o
 +OBJS-$(CONFIG_VIVO_DEMUXER)              += vivo.o
  OBJS-$(CONFIG_VMD_DEMUXER)               += sierravmd.o
 +OBJS-$(CONFIG_VOBSUB_DEMUXER)            += subtitles.o # mpeg demuxer is in the dependencies
  OBJS-$(CONFIG_VOC_DEMUXER)               += vocdec.o voc.o
  OBJS-$(CONFIG_VOC_MUXER)                 += vocenc.o voc.o
 +OBJS-$(CONFIG_VPLAYER_DEMUXER)           += vplayerdec.o subtitles.o
  OBJS-$(CONFIG_VQF_DEMUXER)               += vqf.o
 -OBJS-$(CONFIG_W64_DEMUXER)               += wavdec.o pcm.o
 +OBJS-$(CONFIG_W64_DEMUXER)               += wavdec.o w64.o pcm.o
 +OBJS-$(CONFIG_W64_MUXER)                 += wavenc.o w64.o
  OBJS-$(CONFIG_WAV_DEMUXER)               += wavdec.o pcm.o
  OBJS-$(CONFIG_WAV_MUXER)                 += wavenc.o
  OBJS-$(CONFIG_WC3_DEMUXER)               += wc3movie.o
  OBJS-$(CONFIG_WEBM_MUXER)                += matroskaenc.o matroska.o \
                                              isom.o avc.o hevc.o \
                                              flacenc_header.o avlanguage.o \
 -                                            wv.o vorbiscomment.o
 +                                            wv.o vorbiscomment.o \
 +                                            webmdashenc.o webm_chunk.o
 +OBJS-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER)+= matroskadec.o matroska.o  \
 +                                            isom.o rmsipr.o flac_picture.o \
 +                                            oggparsevorbis.o vorbiscomment.o \
 +                                            flac_picture.o replaygain.o
 +OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o matroska.o
 +OBJS-$(CONFIG_WEBM_CHUNK_MUXER)          += webm_chunk.o matroska.o
 +OBJS-$(CONFIG_WEBP_MUXER)                += webpenc.o
 +OBJS-$(CONFIG_WEBVTT_DEMUXER)            += webvttdec.o subtitles.o
 +OBJS-$(CONFIG_WEBVTT_MUXER)              += webvttenc.o
  OBJS-$(CONFIG_WSAUD_DEMUXER)             += westwood_aud.o
  OBJS-$(CONFIG_WSVQA_DEMUXER)             += westwood_vqa.o
 -OBJS-$(CONFIG_WTV_DEMUXER)               += wtv.o asfdec.o asf.o asfcrypt.o \
 +OBJS-$(CONFIG_WTV_DEMUXER)               += wtvdec.o wtv_common.o asf.o \
                                              avlanguage.o mpegts.o isom.o
 +OBJS-$(CONFIG_WTV_MUXER)                 += wtvenc.o wtv_common.o \
 +                                            mpegtsenc.o asf.o
  OBJS-$(CONFIG_WV_DEMUXER)                += wvdec.o wv.o apetag.o img2.o
 +OBJS-$(CONFIG_WVE_DEMUXER)               += wvedec.o pcm.o
  OBJS-$(CONFIG_WV_MUXER)                  += wvenc.o wv.o apetag.o img2.o
  OBJS-$(CONFIG_XA_DEMUXER)                += xa.o
 +OBJS-$(CONFIG_XBIN_DEMUXER)              += bintext.o sauce.o
  OBJS-$(CONFIG_XMV_DEMUXER)               += xmv.o
 +OBJS-$(CONFIG_XVAG_DEMUXER)              += xvag.o
  OBJS-$(CONFIG_XWMA_DEMUXER)              += xwma.o
  OBJS-$(CONFIG_YOP_DEMUXER)               += yop.o
  OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER)        += yuv4mpegenc.o
  OBJS-$(CONFIG_YUV4MPEGPIPE_DEMUXER)      += yuv4mpegdec.o
  
  # external libraries
 +OBJS-$(CONFIG_CHROMAPRINT_MUXER)         += chromaprint.o
 +OBJS-$(CONFIG_LIBGME_DEMUXER)            += libgme.o
 +OBJS-$(CONFIG_LIBMODPLUG_DEMUXER)        += libmodplug.o
 +OBJS-$(CONFIG_LIBNUT_DEMUXER)            += libnut.o
 +OBJS-$(CONFIG_LIBNUT_MUXER)              += libnut.o
 +OBJS-$(CONFIG_LIBQUVI_DEMUXER)           += libquvi.o
  OBJS-$(CONFIG_LIBRTMP)                   += librtmp.o
 +OBJS-$(CONFIG_LIBSSH_PROTOCOL)           += libssh.o
 +OBJS-$(CONFIG_LIBSMBCLIENT_PROTOCOL)     += libsmbclient.o
  
  # protocols I/O
 +OBJS-$(CONFIG_ASYNC_PROTOCOL)            += async.o
  OBJS-$(CONFIG_APPLEHTTP_PROTOCOL)        += hlsproto.o
 +OBJS-$(CONFIG_BLURAY_PROTOCOL)           += bluray.o
 +OBJS-$(CONFIG_CACHE_PROTOCOL)            += cache.o
  OBJS-$(CONFIG_CONCAT_PROTOCOL)           += concat.o
  OBJS-$(CONFIG_CRYPTO_PROTOCOL)           += crypto.o
 +OBJS-$(CONFIG_DATA_PROTOCOL)             += data_uri.o
  OBJS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)      += rtmpcrypt.o rtmpdh.o
  OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL)       += rtmphttp.o
  OBJS-$(CONFIG_FILE_PROTOCOL)             += file.o
 +OBJS-$(CONFIG_FTP_PROTOCOL)              += ftp.o
  OBJS-$(CONFIG_GOPHER_PROTOCOL)           += gopher.o
  OBJS-$(CONFIG_HLS_PROTOCOL)              += hlsproto.o
  OBJS-$(CONFIG_HTTP_PROTOCOL)             += http.o httpauth.o urldecode.o
@@@ -540,32 -400,22 +540,33 @@@ OBJS-$(CONFIG_RTMPTS_PROTOCOL
  OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
  OBJS-$(CONFIG_SCTP_PROTOCOL)             += sctp.o
  OBJS-$(CONFIG_SRTP_PROTOCOL)             += srtpproto.o srtp.o
 +OBJS-$(CONFIG_SUBFILE_PROTOCOL)          += subfile.o
  OBJS-$(CONFIG_TCP_PROTOCOL)              += tcp.o
  OBJS-$(CONFIG_TLS_GNUTLS_PROTOCOL)       += tls_gnutls.o tls.o
  OBJS-$(CONFIG_TLS_OPENSSL_PROTOCOL)      += tls_openssl.o tls.o
 +OBJS-$(CONFIG_TLS_SCHANNEL_PROTOCOL)     += tls_schannel.o tls.o
 +OBJS-$(CONFIG_TLS_SECURETRANSPORT_PROTOCOL) += tls_securetransport.o tls.o
  OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
 +OBJS-$(CONFIG_UDPLITE_PROTOCOL)          += udp.o
  OBJS-$(CONFIG_UNIX_PROTOCOL)             += unix.o
  
  OBJS-$(HAVE_LIBC_MSVCRT)                 += file_open.o
  
 +# libavdevice dependencies
 +OBJS-$(CONFIG_IEC61883_INDEV)            += dv.o
 +
 +# Windows resource file
 +SLIBOBJS-$(HAVE_GNU_WINDRES)             += avformatres.o
 +
  SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
  SKIPHEADERS-$(CONFIG_NETWORK)            += network.h rtsp.h
  
 -TESTPROGS = seek                                                        \
 +TESTPROGS = async                                                       \
 +            seek                                                        \
              srtp                                                        \
              url                                                         \
  
+ TESTPROGS-$(CONFIG_MOV_MUXER)            += movenc
  TESTPROGS-$(CONFIG_NETWORK)              += noproxy
  TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
  
@@@ -573,5 -423,4 +574,5 @@@ TOOLS     = avioca
              ismindex                                                    \
              pktdumper                                                   \
              probetest                                                   \
 +            seek_print                                                  \
              sidxindex                                                   \
index 0000000,20043b2..79bfb2a
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,588 +1,592 @@@
+ /*
+  * Copyright (c) 2015 Martin Storsjo
+  *
+  * This file is part of Libav.
+  *
+  * Libav is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
+  * Libav is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with Libav; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #include "config.h"
+ #include "libavutil/intreadwrite.h"
+ #include "libavutil/mathematics.h"
+ #include "libavutil/md5.h"
+ #include "avformat.h"
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+ #if !HAVE_GETOPT
+ #include "compat/getopt.c"
+ #endif
+ #define HASH_SIZE 16
+ static const uint8_t h264_extradata[] = {
+     0x01, 0x4d, 0x40, 0x1e, 0xff, 0xe1, 0x00, 0x02, 0x67, 0x4d, 0x01, 0x00, 0x02, 0x68, 0xef
+ };
+ static const uint8_t aac_extradata[] = {
+     0x12, 0x10
+ };
+ const char *format = "mp4";
+ AVFormatContext *ctx;
+ uint8_t iobuf[32768];
+ AVDictionary *opts;
+ int write_file;
+ const char *cur_name;
+ FILE* out;
+ int out_size;
+ struct AVMD5* md5;
+ uint8_t hash[HASH_SIZE];
+ AVStream *video_st, *audio_st;
+ int64_t audio_dts, video_dts;
+ int bframes;
+ int duration;
+ int audio_duration;
+ int frames;
+ int gop_size;
+ int64_t next_p_pts;
+ enum AVPictureType last_picture;
+ int skip_write;
+ int skip_write_audio;
+ int clear_duration;
+ int num_warnings;
+ int check_faults;
+ static void count_warnings(void *avcl, int level, const char *fmt, va_list vl)
+ {
+     if (level == AV_LOG_WARNING)
+         num_warnings++;
+ }
+ static void init_count_warnings(void)
+ {
+     av_log_set_callback(count_warnings);
+     num_warnings = 0;
+ }
+ static void reset_count_warnings(void)
+ {
+     av_log_set_callback(av_log_default_callback);
+ }
+ static int io_write(void *opaque, uint8_t *buf, int size)
+ {
+     out_size += size;
+     av_md5_update(md5, buf, size);
+     if (out)
+         fwrite(buf, 1, size, out);
+     return size;
+ }
+ static void init_out(const char *name)
+ {
+     char buf[100];
+     cur_name = name;
+     snprintf(buf, sizeof(buf), "%s.%s", cur_name, format);
+     av_md5_init(md5);
+     if (write_file) {
+         out = fopen(buf, "wb");
+         if (!out)
+             perror(buf);
+     }
+     out_size = 0;
+ }
+ static void close_out(void)
+ {
+     int i;
+     av_md5_final(md5, hash);
+     for (i = 0; i < HASH_SIZE; i++)
+         printf("%02x", hash[i]);
+     printf(" %d %s\n", out_size, cur_name);
+     if (out)
+         fclose(out);
+     out = NULL;
+ }
+ static void check_func(int value, int line, const char *msg, ...)
+ {
+     if (!value) {
+         va_list ap;
+         va_start(ap, msg);
+         printf("%d: ", line);
+         vprintf(msg, ap);
+         printf("\n");
+         check_faults++;
+     }
+ }
+ #define check(value, ...) check_func(value, __LINE__, __VA_ARGS__)
+ static void init_fps(int bf, int audio_preroll, int fps)
+ {
+     AVStream *st;
+     ctx = avformat_alloc_context();
+     if (!ctx)
+         exit(1);
+     ctx->oformat = av_guess_format(format, NULL, NULL);
+     if (!ctx->oformat)
+         exit(1);
+     ctx->pb = avio_alloc_context(iobuf, sizeof(iobuf), AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL);
+     if (!ctx->pb)
+         exit(1);
+     ctx->flags |= AVFMT_FLAG_BITEXACT;
+     st = avformat_new_stream(ctx, NULL);
+     if (!st)
+         exit(1);
+     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+     st->codec->codec_id = AV_CODEC_ID_H264;
+     st->codec->width = 640;
+     st->codec->height = 480;
+     st->time_base.num = 1;
+     st->time_base.den = 30;
+     st->codec->extradata_size = sizeof(h264_extradata);
+     st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+     if (!st->codec->extradata)
+         exit(1);
+     memcpy(st->codec->extradata, h264_extradata, sizeof(h264_extradata));
+     st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+     video_st = st;
+     st = avformat_new_stream(ctx, NULL);
+     if (!st)
+         exit(1);
+     st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+     st->codec->codec_id = AV_CODEC_ID_AAC;
+     st->codec->sample_rate = 44100;
+     st->codec->channels = 2;
+     st->time_base.num = 1;
+     st->time_base.den = 44100;
+     st->codec->extradata_size = sizeof(aac_extradata);
+     st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+     if (!st->codec->extradata)
+         exit(1);
+     memcpy(st->codec->extradata, aac_extradata, sizeof(aac_extradata));
+     st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+     audio_st = st;
+     if (avformat_write_header(ctx, &opts) < 0)
+         exit(1);
+     av_dict_free(&opts);
+     frames = 0;
+     gop_size = 30;
+     duration = video_st->time_base.den / fps;
+     audio_duration = 1024 * audio_st->time_base.den / audio_st->codec->sample_rate;
+     if (audio_preroll)
+         audio_preroll = 2048 * audio_st->time_base.den / audio_st->codec->sample_rate;
+     bframes = bf;
+     video_dts = bframes ? -duration : 0;
+     audio_dts = -audio_preroll;
+ }
+ static void init(int bf, int audio_preroll)
+ {
+     init_fps(bf, audio_preroll, 30);
+ }
+ static void mux_frames(int n)
+ {
+     int end_frames = frames + n;
+     while (1) {
+         AVPacket pkt;
+         uint8_t pktdata[4];
+         av_init_packet(&pkt);
+         if (av_compare_ts(audio_dts, audio_st->time_base, video_dts, video_st->time_base) < 0) {
+             pkt.dts = pkt.pts = audio_dts;
+             pkt.stream_index = 1;
+             pkt.duration = audio_duration;
+             audio_dts += audio_duration;
+         } else {
+             if (frames == end_frames)
+                 break;
+             pkt.dts = video_dts;
+             pkt.stream_index = 0;
+             pkt.duration = duration;
+             if ((frames % gop_size) == 0) {
+                 pkt.flags |= AV_PKT_FLAG_KEY;
+                 last_picture = AV_PICTURE_TYPE_I;
+                 pkt.pts = pkt.dts + duration;
+                 video_dts = pkt.pts;
+             } else {
+                 if (last_picture == AV_PICTURE_TYPE_P) {
+                     last_picture = AV_PICTURE_TYPE_B;
+                     pkt.pts = pkt.dts;
+                     video_dts = next_p_pts;
+                 } else {
+                     last_picture = AV_PICTURE_TYPE_P;
+                     if (((frames + 1) % gop_size) == 0) {
+                         pkt.pts = pkt.dts + duration;
+                         video_dts = pkt.pts;
+                     } else {
+                         next_p_pts = pkt.pts = pkt.dts + 2 * duration;
+                         video_dts += duration;
+                     }
+                 }
+             }
+             if (!bframes)
+                 pkt.pts = pkt.dts;
+             frames++;
+         }
+         if (clear_duration)
+             pkt.duration = 0;
+         AV_WB32(pktdata, pkt.pts);
+         pkt.data = pktdata;
+         pkt.size = 4;
+         if (skip_write)
+             continue;
+         if (skip_write_audio && pkt.stream_index == 1)
+             continue;
+         av_write_frame(ctx, &pkt);
+     }
+ }
+ static void mux_gops(int n)
+ {
+     mux_frames(gop_size * n);
+ }
+ static void skip_gops(int n)
+ {
+     skip_write = 1;
+     mux_gops(n);
+     skip_write = 0;
+ }
+ static void finish(void)
+ {
+     av_write_trailer(ctx);
+     av_free(ctx->pb);
+     avformat_free_context(ctx);
+     ctx = NULL;
+ }
+ static void help(void)
+ {
+     printf("movenc-test [-w]\n"
+            "-w          write output into files\n");
+ }
+ int main(int argc, char **argv)
+ {
+     int c;
+     uint8_t header[HASH_SIZE];
+     uint8_t content[HASH_SIZE];
+     int empty_moov_pos;
+     int prev_pos;
+     for (;;) {
+         c = getopt(argc, argv, "wh");
+         if (c == -1)
+             break;
+         switch (c) {
+         case 'w':
+             write_file = 1;
+             break;
+         default:
+         case 'h':
+             help();
+             return 0;
+         }
+     }
+     av_register_all();
+     md5 = av_md5_alloc();
+     if (!md5)
+         return 1;
+     // Write a fragmented file with an initial moov that actually contains some
+     // samples. One moov+mdat with 1 second of data and one moof+mdat with 1
+     // second of data.
+     init_out("non-empty-moov");
+     av_dict_set(&opts, "movflags", "frag_keyframe", 0);
+     init(0, 0);
+     mux_gops(2);
+     finish();
+     close_out();
+     // Write a similar file, but with b-frames and audio preroll, handled
+     // via an edit list.
+     init_out("non-empty-moov-elst");
+     av_dict_set(&opts, "movflags", "frag_keyframe", 0);
+     av_dict_set(&opts, "use_editlist", "1", 0);
+     init(1, 1);
+     mux_gops(2);
+     finish();
+     close_out();
+     // Use b-frames but no audio-preroll, but without an edit list.
+     // Due to avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO, the dts
+     // of the first audio packet is > 0, but it is set to zero since edit
+     // lists aren't used, increasing the duration of the first packet instead.
+     init_out("non-empty-moov-no-elst");
+     av_dict_set(&opts, "movflags", "frag_keyframe", 0);
+     av_dict_set(&opts, "use_editlist", "0", 0);
+     init(1, 0);
+     mux_gops(2);
+     finish();
+     close_out();
+     format = "ismv";
+     // Write an ISMV, with b-frames and audio preroll.
+     init_out("ismv");
+     av_dict_set(&opts, "movflags", "frag_keyframe", 0);
+     init(1, 1);
+     mux_gops(2);
+     finish();
+     close_out();
+     format = "mp4";
+     // An initial moov that doesn't contain any samples, followed by two
+     // moof+mdat pairs.
+     init_out("empty-moov");
+     av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
++    av_dict_set(&opts, "use_editlist", "0", 0);
+     init(0, 0);
+     mux_gops(2);
+     finish();
+     close_out();
+     memcpy(content, hash, HASH_SIZE);
+     // Similar to the previous one, but with input that doesn't start at
+     // pts/dts 0. avoid_negative_ts behaves in the same way as
+     // in non-empty-moov-no-elst above.
+     init_out("empty-moov-no-elst");
+     av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
+     init(1, 0);
+     mux_gops(2);
+     finish();
+     close_out();
+     // Same as the previous one, but disable avoid_negative_ts (which
+     // would require using an edit list, but with empty_moov, one can't
+     // write a sensible edit list, when the start timestamps aren't known).
+     // This should trigger a warning - we check that the warning is produced.
+     init_count_warnings();
+     init_out("empty-moov-no-elst-no-adjust");
+     av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
+     av_dict_set(&opts, "avoid_negative_ts", "0", 0);
+     init(1, 0);
+     mux_gops(2);
+     finish();
+     close_out();
+     reset_count_warnings();
+     check(num_warnings > 0, "No warnings printed for unhandled start offset");
+     // Verify that delay_moov produces the same as empty_moov for
+     // simple input
+     init_out("delay-moov");
+     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
++    av_dict_set(&opts, "use_editlist", "0", 0);
+     init(0, 0);
+     mux_gops(2);
+     finish();
+     close_out();
+     check(!memcmp(hash, content, HASH_SIZE), "delay_moov differs from empty_moov");
+     // Test writing content that requires an edit list using delay_moov
+     init_out("delay-moov-elst");
+     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
+     init(1, 1);
+     mux_gops(2);
+     finish();
+     close_out();
+     // Test writing a file with one track lacking packets, with delay_moov.
+     skip_write_audio = 1;
+     init_out("delay-moov-empty-track");
+     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
+     init(0, 0);
+     mux_gops(2);
+     // The automatic flushing shouldn't output anything, since we're still
+     // waiting for data for some tracks
+     check(out_size == 0, "delay_moov flushed prematurely");
+     // When closed (or manually flushed), all the written data should still
+     // be output.
+     finish();
+     close_out();
+     check(out_size > 0, "delay_moov didn't output anything");
+     // Check that manually flushing still outputs things as expected. This
+     // produces two fragments, while the one above produces only one.
+     init_out("delay-moov-empty-track-flush");
+     av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0);
+     init(0, 0);
+     mux_gops(1);
+     av_write_frame(ctx, NULL); // Force writing the moov
+     check(out_size > 0, "No moov written");
+     av_write_frame(ctx, NULL);
+     mux_gops(1);
+     av_write_frame(ctx, NULL);
+     finish();
+     close_out();
+     skip_write_audio = 0;
+     // Verify that the header written by delay_moov when manually flushed
+     // is identical to the one by empty_moov.
+     init_out("empty-moov-header");
+     av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
++    av_dict_set(&opts, "use_editlist", "0", 0);
+     init(0, 0);
+     close_out();
+     memcpy(header, hash, HASH_SIZE);
+     init_out("empty-moov-content");
+     mux_gops(2);
+     // Written 2 seconds of content, with an automatic flush after 1 second.
+     check(out_size > 0, "No automatic flush?");
+     empty_moov_pos = prev_pos = out_size;
+     // Manually flush the second fragment
+     av_write_frame(ctx, NULL);
+     check(out_size > prev_pos, "No second fragment flushed?");
+     prev_pos = out_size;
+     // Check that an extra flush doesn't output any more data
+     av_write_frame(ctx, NULL);
+     check(out_size == prev_pos, "More data written?");
+     close_out();
+     memcpy(content, hash, HASH_SIZE);
+     // Ignore the trailer written here
+     finish();
+     init_out("delay-moov-header");
+     av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0);
++    av_dict_set(&opts, "use_editlist", "0", 0);
+     init(0, 0);
+     check(out_size == 0, "Output written during init with delay_moov");
+     mux_gops(1); // Write 1 second of content
+     av_write_frame(ctx, NULL); // Force writing the moov
+     close_out();
+     check(!memcmp(hash, header, HASH_SIZE), "delay_moov header differs from empty_moov");
+     init_out("delay-moov-content");
+     av_write_frame(ctx, NULL); // Flush the first fragment
+     check(out_size == empty_moov_pos, "Manually flushed content differs from automatically flushed, %d vs %d", out_size, empty_moov_pos);
+     mux_gops(1); // Write the rest of the content
+     av_write_frame(ctx, NULL); // Flush the second fragment
+     close_out();
+     check(!memcmp(hash, content, HASH_SIZE), "delay_moov content differs from empty_moov");
+     finish();
+     // Verify that we can produce an identical second fragment without
+     // writing the first one. First write the reference fragments that
+     // we want to reproduce.
+     av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash", 0);
+     init(0, 0);
+     mux_gops(1);
+     av_write_frame(ctx, NULL); // Output the first fragment
+     init_out("empty-moov-second-frag");
+     mux_gops(1);
+     av_write_frame(ctx, NULL); // Output the second fragment
+     close_out();
+     memcpy(content, hash, HASH_SIZE);
+     finish();
+     // Produce the same second fragment without actually writing the first
+     // one before.
+     av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0);
+     av_dict_set(&opts, "fragment_index", "2", 0);
+     av_dict_set(&opts, "avoid_negative_ts", "0", 0);
+     av_dict_set(&opts, "use_editlist", "0", 0);
+     init(0, 0);
+     skip_gops(1);
+     init_out("empty-moov-second-frag-discont");
+     mux_gops(1);
+     av_write_frame(ctx, NULL); // Output the second fragment
+     close_out();
+     check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
+     finish();
+     // Produce the same thing by using delay_moov, which requires a slightly
+     // different call sequence.
+     av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
+     av_dict_set(&opts, "fragment_index", "2", 0);
+     init(0, 0);
+     skip_gops(1);
+     mux_gops(1);
+     av_write_frame(ctx, NULL); // Output the moov
+     init_out("delay-moov-second-frag-discont");
+     av_write_frame(ctx, NULL); // Output the second fragment
+     close_out();
+     check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
+     finish();
+     // Test VFR content, with sidx atoms (which declare the pts duration
+     // of a fragment, forcing overriding the start pts of the next one).
+     // Here, the fragment duration in pts is significantly different from
+     // the duration in dts. The video stream starts at dts=-10,pts=0, and
+     // the second fragment starts at dts=155,pts=156. The trun duration sum
+     // of the first fragment is 165, which also is written as
+     // baseMediaDecodeTime in the tfdt in the second fragment. The sidx for
+     // the first fragment says earliest_presentation_time = 0 and
+     // subsegment_duration = 156, which also matches the sidx in the second
+     // fragment. For the audio stream, the pts and dts durations also don't
+     // match - the input stream starts at pts=-2048, but that part is excluded
+     // by the edit list.
+     init_out("vfr");
+     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
+     init_fps(1, 1, 3);
+     mux_frames(gop_size/2);
+     duration /= 10;
+     mux_frames(gop_size/2);
+     mux_gops(1);
+     finish();
+     close_out();
+     // Test VFR content, with cleared duration fields. In these cases,
+     // the muxer must guess the duration of the last packet of each
+     // fragment. As long as the framerate doesn't vary (too much) at the
+     // fragment edge, it works just fine. Additionally, when automatically
+     // cutting fragments, the muxer already know the timestamps of the next
+     // packet for one stream (in most cases the video stream), avoiding
+     // having to use guesses for that one.
+     init_count_warnings();
+     clear_duration = 1;
+     init_out("vfr-noduration");
+     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
+     init_fps(1, 1, 3);
+     mux_frames(gop_size/2);
+     duration /= 10;
+     mux_frames(gop_size/2);
+     mux_gops(1);
+     finish();
+     close_out();
+     clear_duration = 0;
+     reset_count_warnings();
+     check(num_warnings > 0, "No warnings printed for filled in durations");
+     av_free(md5);
+     return check_faults > 0 ? 1 : 0;
+ }
@@@ -1,7 -1,3 +1,7 @@@
 +FATE_LIBAVFORMAT-$(HAVE_PTHREADS) += fate-async
 +fate-async: libavformat/async-test$(EXESUF)
 +fate-async: CMD = run libavformat/async-test
 +
  FATE_LIBAVFORMAT-$(CONFIG_NETWORK) += fate-noproxy
  fate-noproxy: libavformat/noproxy-test$(EXESUF)
  fate-noproxy: CMD = run libavformat/noproxy-test
@@@ -18,5 -14,9 +18,9 @@@ FATE_LIBAVFORMAT-yes += fate-ur
  fate-url: libavformat/url-test$(EXESUF)
  fate-url: CMD = run libavformat/url-test
  
+ FATE_LIBAVFORMAT-$(CONFIG_MOV_MUXER) += fate-movenc
+ fate-movenc: libavformat/movenc-test$(EXESUF)
+ fate-movenc: CMD = run libavformat/movenc-test
  FATE-$(CONFIG_AVFORMAT) += $(FATE_LIBAVFORMAT-yes)
  fate-libavformat: $(FATE_LIBAVFORMAT)
diff --combined tests/ref/fate/movenc
index 0000000,929f146..e2fd059
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,20 +1,20 @@@
 -4e7e78793cdda3c9ed28fbf47df39c43 2449 non-empty-moov
 -5b825dc829f35c9d5b76834c378276d7 2897 non-empty-moov-elst
 -0fd659671dec7d05cfa533a4579b1d6d 2817 non-empty-moov-no-elst
 -890ad73874bff5aefbd549bc75a15b8e 9139 ismv
 -aa6f42a0546a27f7047f1cff812a552f 2327 empty-moov
 -9a439649d13cdcddf6179234fe3d8a8e 2727 empty-moov-no-elst
 -2451cb44e678845ed26e014e1affe5e8 2559 empty-moov-no-elst-no-adjust
 -aa6f42a0546a27f7047f1cff812a552f 2327 delay-moov
 -09354eac8e7a48216d535df8a88db5ca 2639 delay-moov-elst
 -5c2a209249df8c7e3d55418da2ebe5cf 1846 delay-moov-empty-track
 -89e03fa0c53e4a89b7fbb1df9f93774f 1749 delay-moov-empty-track-flush
 -f8f6bf271a512bff1edba1d930172829 1183 empty-moov-header
 -f12baf7c4269695817337192c7069328 996 empty-moov-content
 -f8f6bf271a512bff1edba1d930172829 1183 delay-moov-header
 -f12baf7c4269695817337192c7069328 996 delay-moov-content
 -76e1081bbab7541eadcaf4b19d37eff6 584 empty-moov-second-frag
 -76e1081bbab7541eadcaf4b19d37eff6 584 empty-moov-second-frag-discont
 -76e1081bbab7541eadcaf4b19d37eff6 584 delay-moov-second-frag-discont
 -4407220c69fb6d96fd3f4daea05140c3 3647 vfr
 -4407220c69fb6d96fd3f4daea05140c3 3647 vfr-noduration
++167647a7019bb1f134329b22bd4ddcdf 2681 non-empty-moov
++8a7595021c11a848ac20ec4f77c9d0bf 3113 non-empty-moov-elst
++f9d6b8fce9404a8d2a947badcf65fba6 3049 non-empty-moov-no-elst
++d43b8a181c074d94f152e6f03f83abb2 9115 ismv
++204d141d70e4801333ab516bb9e1d3fc 2303 empty-moov
++5af446fd5e0a7978e8dff9511938ddab 2703 empty-moov-no-elst
++ad43cfb415822a0d70db0f11a87ced66 2535 empty-moov-no-elst-no-adjust
++204d141d70e4801333ab516bb9e1d3fc 2303 delay-moov
++0cf964a5e0908cfb3a023d5c48776ac6 2607 delay-moov-elst
++9a6a892af043f1d77b2f5ee6deaadcd7 1858 delay-moov-empty-track
++7453fb089ad8799669259cbf559bdb37 1761 delay-moov-empty-track-flush
++39d798aa11a265c7906f9e11d4f303c0 1159 empty-moov-header
++473d94ed152c332015f7e1d327fa855d 996 empty-moov-content
++39d798aa11a265c7906f9e11d4f303c0 1159 delay-moov-header
++473d94ed152c332015f7e1d327fa855d 996 delay-moov-content
++64e38d416e9344c8046e37426cdf2807 584 empty-moov-second-frag
++64e38d416e9344c8046e37426cdf2807 584 empty-moov-second-frag-discont
++64e38d416e9344c8046e37426cdf2807 584 delay-moov-second-frag-discont
++da0d89d03fa601b40f6a653c8314e333 3615 vfr
++da0d89d03fa601b40f6a653c8314e333 3615 vfr-noduration
diff --combined tests/ref/fate/source
index 450e064,0000000..00bfc98
mode 100644,000000..100644
--- /dev/null
@@@ -1,19 -1,0 +1,20 @@@
 +Files without standard license headers:
 +cmdutils_common_opts.h
 +compat/avisynth/windowsPorts/basicDataTypeConversions.h
 +compat/avisynth/windowsPorts/windows2linux.h
 +libavcodec/file_open.c
 +libavcodec/interplayacm.c
 +libavcodec/log2_tab.c
 +libavcodec/mathops.c
 +libavcodec/reverse.c
 +libavdevice/file_open.c
 +libavfilter/log2_tab.c
 +libavformat/file_open.c
 +libavformat/golomb_tab.c
 +libavformat/log2_tab.c
++libavformat/movenc-test.c
 +libavutil/x86_cpu.h
 +libswresample/log2_tab.c
 +libswscale/log2_tab.c
 +tools/uncoded_frame.c
 +tools/yuvcmp.c