ffmpeg 3.4.1, add libopus, openexr probe tweak, rel path for filelist, avg_frame_rate...
authorGood Guy <[email protected]>
Tue, 19 Dec 2017 23:37:52 +0000 (16:37 -0700)
committerGood Guy <[email protected]>
Tue, 19 Dec 2017 23:37:52 +0000 (16:37 -0700)
20 files changed:
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/cinelerra/filelist.C
cinelerra-5.1/cinelerra/preferences.C
cinelerra-5.1/configure.ac
cinelerra-5.1/ffmpeg/plugin.opts
cinelerra-5.1/thirdparty/Makefile
cinelerra-5.1/thirdparty/downloads.txt
cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch1 [deleted file]
cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch2 [deleted file]
cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch4 [deleted file]
cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch5 [deleted file]
cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.tar.xz [deleted file]
cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch1 [new file with mode: 0644]
cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch2 [new file with mode: 0644]
cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch3 [new file with mode: 0644]
cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.tar.xz [new file with mode: 0644]
cinelerra-5.1/thirdparty/src/ffmpeg.git.patch1
cinelerra-5.1/thirdparty/src/ffmpeg.git.patch2
cinelerra-5.1/thirdparty/src/ffmpeg.git.patch3
cinelerra-5.1/thirdparty/src/opus-1.2.1.tar.xz [new file with mode: 0644]

index fc3726e222487fece097b629c66b06fb412edac7..66003120eebb2e663947902dacedda0a295f50c7 100644 (file)
@@ -1986,6 +1986,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                                break;
                        }
                        ctx->time_base = (AVRational) { frame_rate.den, frame_rate.num };
+                       st->avg_frame_rate = frame_rate;
                        st->time_base = ctx->time_base;
                        vid->writing = -1;
                        vid->interlaced = asset->interlace_mode == ILACE_MODE_TOP_FIRST ||
index f44d11a8711f196a4eb554b60f6262e99167bacb..b98864f98fcb1ca2ce2561f33a9ce31e1982b23f 100644 (file)
@@ -181,34 +181,29 @@ int FileList::write_list_header()
        FILE *stream = fopen(asset->path, "w");
        if( !stream ) return 1;
 // Use sprintf instead of fprintf for VFS.
-       char string[BCTEXTLEN];
-       sprintf(string, "%s\n", list_prefix);
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "# First line is always %s\n", list_prefix);
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "# Frame rate:\n");
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "%f\n", asset->frame_rate);
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "# Width:\n");
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "%d\n", asset->width);
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "# Height:\n");
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "%d\n", asset->height);
-       fwrite(string, strlen(string), 1, stream);
-       sprintf(string, "# List of image files follows\n");
-       fwrite(string, strlen(string), 1, stream);
-
-       for(int i = 0; i < path_list.total; i++)
-       {
+       fprintf(stream, "%s\n", list_prefix);
+       fprintf(stream, "# First line is always %s\n", list_prefix);
+       fprintf(stream, "# Frame rate:\n");
+       fprintf(stream, "%f\n", asset->frame_rate);
+       fprintf(stream, "# Width:\n");
+       fprintf(stream, "%d\n", asset->width);
+       fprintf(stream, "# Height:\n");
+       fprintf(stream, "%d\n", asset->height);
+       fprintf(stream, "# List of image files follows\n");
+
+       char *cp = strrchr(asset->path, '/');
+       int dir_len = !cp ? 0 : cp - asset->path;
+
+       for(int i = 0; i < path_list.total; i++) {
+               const char *path = path_list.values[i];
 // Fix path for VFS but leave leading slash
-               if(!strncmp(path_list.values[i], RENDERFARM_FS_PREFIX, strlen(RENDERFARM_FS_PREFIX)))
-                       sprintf(string, "%s\n", path_list.values[i] + strlen(RENDERFARM_FS_PREFIX));
-               else
-                       sprintf(string, "%s\n", path_list.values[i]);
-               fwrite(string, strlen(string), 1, stream);
+               if( !strncmp(path, RENDERFARM_FS_PREFIX, strlen(RENDERFARM_FS_PREFIX)) )
+                       path += strlen(RENDERFARM_FS_PREFIX);
+// ./path for relative list access
+               else if( dir_len > 0 && !strncmp(path, asset->path, dir_len) ) {
+                       fprintf(stream, ".");  path += dir_len;
+               }
+               fprintf(stream, "%s\n", path);
        }
        fclose(stream);
        return 0;
@@ -244,15 +239,23 @@ int FileList::read_list_header()
        asset->audio_data = 0;
        asset->video_data = 1;
 
-// Get all the paths
+       char prefix[BCTEXTLEN], *bp = prefix, *cp = strrchr(asset->path, '/');
+       for( int i=0, n=!cp ? 0 : cp-asset->path; i<n; ++i ) *bp++ = asset->path[i];
+       *bp = 0;
+
+// Get all the paths, expand relative paths
        int missing = 0;
-       while(!feof(stream) && fgets(string, BCTEXTLEN, stream) ) {
+       while( !feof(stream) && fgets(string, BCTEXTLEN, stream) ) {
                int len = strlen(string);
-               if( !len || string[0] == '#' || string[0] == ' ') continue;
-               string[len-1] = 0;
-               if( access(string,R_OK) && !missing++ )
-                       eprintf(_("%s:no such file"), string);
-               path_list.append(cstrdup(string));
+               if( !len || string[0] == '#' || string[0] == ' ' ) continue;
+               if( string[len-1] == '\n' ) string[len-1] = 0;
+               char path[BCTEXTLEN], *pp = path, *ep = pp + sizeof(path)-1;
+               if( string[0] == '.' && string[1] == '/' && prefix[0] )
+                       pp += snprintf(pp, ep-pp, "%s/", prefix);
+               snprintf(pp, ep-pp, "%s", string);
+               if( access(path, R_OK) && !missing++ )
+                       eprintf(_("%s:no such file"), path);
+               path_list.append(cstrdup(path));
        }
 
 //for(int i = 0; i < path_list.total; i++) printf("%s\n", path_list.values[i]);
index b44319be24a0c32d8aaacf0d41f819853e5f54a5..029feba532414a0dede0682c97d33e2909da5846 100644 (file)
@@ -60,7 +60,7 @@ Preferences::Preferences()
        sprintf(index_directory, "%s/", File::get_config_path());
        if(strlen(index_directory))
                fs.complete_path(index_directory);
-       cache_size = 0x1000000;
+       cache_size = 0x10000000;
        index_size = 0x400000;
        index_count = 500;
        use_thumbnails = 1;
index 4fe5c0f00c12ae664999e0f20b97fba8d556056c..dcfd41d4e82f5b2247cd016dec432b4dc353dec3 100644 (file)
@@ -126,7 +126,7 @@ PKG_3RD([fdk],[auto],
   [ libAACdec/include libAACenc/include libSYS/include ])
 
 PKG_3RD([ffmpeg],[yes],
-  [ffmpeg-3.3.4],
+  [ffmpeg-3.4.1],
   [ libavutil/libavutil.a \
     libavcodec/libavcodec.a \
     libpostproc/libpostproc.a \
@@ -223,6 +223,11 @@ PKG_3RD([libjpeg],[auto],
     simd/.libs/libsimd.a ],
   [ . ])
 
+PKG_3RD([opus],[auto],
+  [opus-1.2.1],
+  [ .libs/libopus.a ],
+  [ include ])
+
 PKG_3RD([openjpeg],[auto],
   [openjpeg-2.1.0-20160221],
   [ bin/libopenjp2.a ],
@@ -453,8 +458,6 @@ CHECK_LIB([fdk], [fdk-aac], [faacDecInit])
 CHECK_HEADERS([fdk], [fdk headers], [fdk-aac/genericStds.h])
 CHECK_LIB([jbig], [jbig], [jbg_dec_init])
 CHECK_LIB([vdpau], [vdpau], [vdp_device_create_x11])
-CHECK_LIB([opus], [opus], [opus_multistream_decoder_create])
-CHECK_HEADERS([opus], [libopus headers], [opus/opus_multistream.h])
 
 #if test "x$HAVE_mjpegtools" = "xyes"; then
 #CFG_CFLAGS+=" -I/usr/include/mjpegtools"
@@ -524,6 +527,10 @@ CHECK_WANT([ESOUND], [no], [use esd], [
  CHECK_LIB([audiofile], [audiofile], [afOpenFile])
  CHECK_HEADERS([audiofile], [audiofile headers], [audiofile.h])])
 
+CHECK_WANT([LIBOPUS], [auto], [use libopus], [
+ CHECK_LIB([opus], [opus], [opus_multistream_decoder_create])
+ CHECK_HEADERS([opus], [libopus headers], [opus/opus_multistream.h])])
+
 CHECK_WANT([DL], [auto], [system has libdl], [
  CHECK_LIB([DL], [dl], [dlopen])])
 
@@ -540,7 +547,7 @@ CHECK_WANT([OPENEXR], [auto], [use openexr], [
  saved_LIBS="$LIBS"
  saved_CXXFLAGS="$CXXFLAGS"
  # ilmbase libs
- LIBS=" -lIlmImf -lIlmThread -lIex"
+ LIBS=" -lIlmImf -lIlmThread -lIex -lpthread"
  CXXFLAGS="-I/usr/include/OpenEXR"
  AC_LANG_PUSH(C++)
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@@ -660,6 +667,7 @@ PKG_PROVIDE([twolame])
 PKG_PROVIDE([x264])
 PKG_PROVIDE([x265])
 PKG_PROVIDE([libvpx])
+PKG_PROVIDE([opus], [$WANT_OPUS])
 
 AC_SUBST(STATIC_BLDS)
 AC_SUBST(SHARED_LIBS)
index 173a5a9ebe5a7c94f19d1cb4aa8a28f3418f11aa..95236fdba6d0e91c0f9ed64819a8c45e8ca70af5 100644 (file)
@@ -50,12 +50,9 @@ aresample sample_rate=48000
 #asettb
 #ashowinfo
 #asidedata
-#asilencedetect
-#asilenceremove
 #asplit
 astats
 #astreamselect
-#astreamsync
 atadenoise
 atempo
 atrim start=1:end=240:start_pts=1:end_pts=2:duration=1:start_sample=1:end_sample=2
@@ -67,11 +64,10 @@ bass
 bbox
 bench
 biquad
-bitplaneoise
 blackdetect
 blackframe
 #blend
-boxblue
+boxblur
 #buffer
 #buffersink
 bwdif
@@ -124,8 +120,6 @@ erosion
 #extractplanes
 extrastereo
 fade
-#ffabuffersink
-#ffbuffersink
 fftfilt
 field
 #fieldhint
@@ -135,7 +129,6 @@ fieldorder
 #find_rect
 #firequalizer
 flanger
-#fliporder
 #format
 #fps
 #framepack
@@ -166,7 +159,6 @@ il
 inflate
 interlace
 #interleave
-#isdesctest
 #join
 kerndeint
 lenscorrection
@@ -258,7 +250,7 @@ signalstats
 #silencedetect
 silenceremove
 sine
-smartblue
+smartblur
 #smptebars
 #smptehdbars
 sobel
@@ -302,6 +294,30 @@ xbr
 yadif
 #yuvtestsrc
 zoompan
+; new in 3.4.1
+#acopy
+bitplanenoise
+boxblur
+ciescope
+crossfeed
+deflicker
+despill
+doubleweave
+floodfill
+haas
+limiter
+loop
+lumakey
+oscilloscope
+pixscope
+pseudocolor
+roberts
+smartblur
+#superequalizer
+#surround
+tlut2
+tonemap
+#vmafmotion
 ; in git
 #afir
 #headphone
index 7268028bdbf72a26e53cb269244af0543ca9af29..e2d2d4d483b0ea062283301ee0ddd2daeca084aa 100644 (file)
@@ -130,6 +130,7 @@ ffmpeg.cfg_params= \
                $(call inc_path,lame,include) \
                $(call inc_path,openjpeg,src/lib/openjp2) \
                $(call inc_path,libogg,include) \
+               $(call inc_path,opus,include) \
                $(call inc_path,libvorbis,include) \
                $(call inc_path,libtheora,include) \
                $(call inc_path,libvpx) \
@@ -146,6 +147,7 @@ ffmpeg.cfg_params= \
                $(call ld_path,twolame,libtwolame/.libs) \
                $(call ld_path,lame,libmp3lame/.libs) \
                $(call ld_path,openjpeg,bin) \
+               $(call ld_path,opus,.libs) \
                $(call ld_path,libogg,lib/.libs) \
                $(call ld_path,libvorbis,lib/.libs) \
                $(call ld_path,libtheora,lib/.libs) \
@@ -243,7 +245,7 @@ $(call rules,$(call std-build,esound,audiofile))
 $(call rules,$(call std-build,faac))
 $(call rules,$(call std-build,faad2))
 $(call rules,$(call std-build,fdk))
-$(call rules,$(call std-build,ffmpeg, faad2 faac fdk twolame lame openjpeg libtheora x264 x265 libvpx))
+$(call rules,$(call std-build,ffmpeg, faad2 faac fdk twolame lame openjpeg opus libtheora x264 x265 libvpx))
 $(call rules,$(call std-build,fftw))
 $(call rules,$(call std-build,flac,libogg))
 $(call rules,$(call std-build,giflib))
@@ -264,6 +266,7 @@ $(call rules,$(call std-build,mjpegtools, libjpeg))
 $(call rules,$(call std-build,opencv))
 $(call rules,$(call std-build,openexr, ilmbase))
 $(call rules,$(call std-build,openjpeg))
+$(call rules,$(call std-build,opus))
 $(call rules,$(call std-build,speech_tools))
 $(call rules,$(call std-build,tiff))
 $(call rules,$(call std-build,twolame))
index 579810c5746fb29c776640336254a304722b51c8..47936c5f0f8cf66789a1089d94b333286112a0a2 100644 (file)
@@ -33,3 +33,4 @@ https://bitbucket.org/multicoreware/x265/downloads/x265_2.4.tar.gz
 http://ffmpeg.org/releases/ffmpeg-3.3.tar.bz2
 https://chromium.googlesource.com/webm/libvpx/+archive/0c0a05046db1c0b59a7fcc29785a190fdbbe39c2.tar.gz = 1,6,1
 https://github.com/swh/ladspa/releases/tag/v0.4.17, plugin.org.uk
+https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch1 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch1
deleted file mode 100644 (file)
index 40d7edd..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-diff -urN a/configure b/configure
---- a/configure        2017-04-12 19:55:54.000000000 -0600
-+++ b/configure        2017-04-16 16:12:23.518837543 -0600
-@@ -5812,7 +5812,7 @@
-                                { check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
-                                die "ERROR: libopenjpeg not found"; }
- enabled libopenmpt        && require_pkg_config "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create
--enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
-+enabled libopus           && use_pkg_config opus opus_multistream.h opus_multistream_decoder_create
- enabled libpulse          && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new
- enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
- enabled librubberband     && require_pkg_config "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new
-@@ -5871,7 +5871,9 @@
-                                die "ERROR: libx264 must be installed and version must be >= 0.118."; } &&
-                              { check_cpp_condition x264.h "X264_MPEG2" &&
-                                enable libx262; }
--enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
-+enabled libx265           && { use_pkg_config x265 "stdint.h x265.h" x265_api_get ||
-+                               { require libx265 x265.h x265_encoder_encode -lx265 -lstdc++ &&
-+                                 warn "using libx265 without pkg-config"; } } &&
-                              { check_cpp_condition x265.h "X265_BUILD >= 68" ||
-                                die "ERROR: libx265 version must be >= 68."; }
- enabled libxavs           && require libxavs "stdint.h xavs.h" xavs_encoder_encode -lxavs
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch2 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch2
deleted file mode 100644 (file)
index daa9953..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ru ffmpeg-3.0.orig/libavformat/bluray.c ffmpeg-3.0/libavformat/bluray.c
---- ffmpeg-3.0.orig/libavformat/bluray.c       2015-03-13 11:34:50.000000000 -0600
-+++ ffmpeg-3.0/libavformat/bluray.c    2016-05-09 14:07:34.758713307 -0600
-@@ -28,7 +28,7 @@
- #include "libavutil/opt.h"
- #define BLURAY_PROTO_PREFIX     "bluray:"
--#define MIN_PLAYLIST_LENGTH     180     /* 3 min */
-+#define MIN_PLAYLIST_LENGTH     0
- typedef struct {
-     const AVClass *class;
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch4 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch4
deleted file mode 100644 (file)
index 66edd3d..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-diff -urN a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
---- a/libavformat/mpegtsenc.c  2017-04-12 19:55:55.000000000 -0600
-+++ b/libavformat/mpegtsenc.c  2017-04-16 16:40:18.488361991 -0600
-@@ -56,9 +56,8 @@
-     int sid;           /* service ID */
-     char *name;
-     char *provider_name;
--    int pcr_pid;
--    int pcr_packet_count;
--    int pcr_packet_period;
-+    int64_t pcr, pcr_packet_timer, pcr_packet_period;
-+    int pcr_sid, pcr_pid;
-     AVProgram *program;
- } MpegTSService;
-@@ -78,14 +77,12 @@
-     MpegTSSection pat; /* MPEG-2 PAT table */
-     MpegTSSection sdt; /* MPEG-2 SDT table context */
-     MpegTSService **services;
--    int sdt_packet_count;
--    int sdt_packet_period;
--    int pat_packet_count;
--    int pat_packet_period;
-+    int64_t sdt_packet_timer, sdt_packet_period;
-+    int64_t pat_packet_timer, pat_packet_period;
-     int nb_services;
-     int onid;
-     int tsid;
--    int64_t first_pcr;
-+    int64_t pcr, first_pcr, delay;
-     int mux_rate; ///< set to 1 when VBR
-     int pes_payload_size;
-@@ -95,12 +92,14 @@
-     int service_type;
-     int pmt_start_pid;
-+    int pcr_start_pid;
-     int start_pid;
-     int m2ts_mode;
-+    int64_t ts_offset;
-     int reemit_pat_pmt; // backward compatibility
--    int pcr_period;
-+    double pcr_period;
- #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
- #define MPEGTS_FLAG_AAC_LATM        0x02
- #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES           0x04
-@@ -111,8 +110,6 @@
-     int tables_version;
-     double pat_period;
-     double sdt_period;
--    int64_t last_pat_ts;
--    int64_t last_sdt_ts;
-     int omit_video_pes_length;
- } MpegTSWrite;
-@@ -222,10 +219,10 @@
- #define DEFAULT_PROVIDER_NAME   "FFmpeg"
- #define DEFAULT_SERVICE_NAME    "Service01"
--/* we retransmit the SI info at this rate */
-+/* we retransmit the SI info at this rate (ms) */
- #define SDT_RETRANS_TIME 500
- #define PAT_RETRANS_TIME 100
--#define PCR_RETRANS_TIME 20
-+#define PCR_RETRANS_TIME 50
- typedef struct MpegTSWriteStream {
-     struct MpegTSService *service;
-@@ -717,6 +714,7 @@
-     service->pmt.pid       = ts->pmt_start_pid + ts->nb_services;
-     service->sid           = sid;
-     service->pcr_pid       = 0x1fff;
-+    service->pcr_sid       = 0x1fff;
-     service->provider_name = av_strdup(provider_name);
-     service->name          = av_strdup(name);
-     if (!service->provider_name || !service->name)
-@@ -732,18 +730,11 @@
-     return NULL;
- }
--static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
--{
--    return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
--           ts->first_pcr;
--}
--
- static void mpegts_prefix_m2ts_header(AVFormatContext *s)
- {
-     MpegTSWrite *ts = s->priv_data;
-     if (ts->m2ts_mode) {
--        int64_t pcr = get_pcr(s->priv_data, s->pb);
--        uint32_t tp_extra_header = pcr % 0x3fffffff;
-+        uint32_t tp_extra_header = ts->pcr % 0x3fffffff;
-         tp_extra_header = AV_RB32(&tp_extra_header);
-         avio_write(s->pb, (unsigned char *) &tp_extra_header,
-                    sizeof(tp_extra_header));
-@@ -764,6 +755,7 @@
-     MpegTSService *service;
-     AVStream *st, *pcr_st = NULL;
-     AVDictionaryEntry *title, *provider;
-+    double clk_rate;
-     int i, j;
-     const char *service_name;
-     const char *provider_name;
-@@ -772,6 +764,15 @@
-     if (s->max_delay < 0) /* Not set by the caller */
-         s->max_delay = 0;
-+    ts->delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
-+
-+    if (ts->m2ts_mode == -1) {
-+        if (av_match_ext(s->filename, "m2ts")) {
-+            ts->m2ts_mode = 1;
-+        } else {
-+            ts->m2ts_mode = 0;
-+        }
-+    }
-     // round up to a whole number of TS packets
-     ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
-@@ -818,6 +819,8 @@
-             service->program          = program;
-         }
-     }
-+    if (ts->m2ts_mode > 1)
-+        service->pmt.pid = 0x00ff + ts->service_id;
-     ts->pat.pid          = PAT_PID;
-     /* Initialize at 15 so that it wraps and is equal to 0 for the
-@@ -903,10 +906,9 @@
-         ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
-         /* update PCR pid by using the first video stream */
-         if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
--            service->pcr_pid == 0x1fff) {
--            service->pcr_pid = ts_st->pid;
-+            service->pcr_sid == 0x1fff)
-             pcr_st           = st;
--        }
-+
-         if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
-             st->codecpar->extradata_size > 0) {
-             AVStream *ast;
-@@ -942,78 +944,47 @@
-     av_freep(&pids);
-     /* if no video stream, use the first stream as PCR */
--    if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
--        pcr_st           = s->streams[0];
--        ts_st            = pcr_st->priv_data;
--        service->pcr_pid = ts_st->pid;
--    } else
--        ts_st = pcr_st->priv_data;
--
--    if (ts->mux_rate > 1) {
--        service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
--                                     (TS_PACKET_SIZE * 8 * 1000);
--        ts->sdt_packet_period      = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
--                                     (TS_PACKET_SIZE * 8 * 1000);
--        ts->pat_packet_period      = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
--                                     (TS_PACKET_SIZE * 8 * 1000);
--
--        if (ts->copyts < 1)
--            ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
--    } else {
--        /* Arbitrary values, PAT/PMT will also be written on video key frames */
--        ts->sdt_packet_period = 200;
--        ts->pat_packet_period = 40;
--        if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
--            int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
--            if (!frame_size) {
--                av_log(s, AV_LOG_WARNING, "frame size not set\n");
--                service->pcr_packet_period =
--                    pcr_st->codecpar->sample_rate / (10 * 512);
--            } else {
--                service->pcr_packet_period =
--                    pcr_st->codecpar->sample_rate / (10 * frame_size);
--            }
--        } else {
--            // max delta PCR 0.1s
--            // TODO: should be avg_frame_rate
--            service->pcr_packet_period =
--                ts_st->user_tb.den / (10 * ts_st->user_tb.num);
--        }
--        if (!service->pcr_packet_period)
--            service->pcr_packet_period = 1;
--    }
--
--    ts->last_pat_ts = AV_NOPTS_VALUE;
--    ts->last_sdt_ts = AV_NOPTS_VALUE;
--    // The user specified a period, use only it
--    if (ts->pat_period < INT_MAX/2) {
--        ts->pat_packet_period = INT_MAX;
-+    if (!pcr_st && s->nb_streams > 0)
-+        pcr_st = s->streams[0];
-+    if (!pcr_st) {
-+        av_log(s, AV_LOG_ERROR, "no streams\n");
-+        ret = AVERROR(EINVAL);
-+        goto fail;
-     }
--    if (ts->sdt_period < INT_MAX/2) {
--        ts->sdt_packet_period = INT_MAX;
-+    ts_st  = pcr_st->priv_data;
-+    if (service->pcr_sid == 0x1fff)
-+        service->pcr_sid   = ts_st->pid;
-+    if (service->pcr_pid == 0x1fff)
-+        service->pcr_pid   = ts->m2ts_mode > 1 ?
-+            0x1000 + ts->service_id : service->pcr_sid ;
-+    if (service->pmt.pid == service->pcr_pid) {
-+        av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", service->pcr_pid);
-+        ret = AVERROR(EINVAL);
-+        goto fail;
-     }
-+    clk_rate = ts->mux_rate > 1 ? ts->mux_rate : PCR_TIME_BASE;
-+    ts->sdt_packet_period      = ts->sdt_period < 0 ? -1 : ts->sdt_period/1000 * clk_rate;
-+    ts->pat_packet_period      = ts->pat_period/1000 * clk_rate;
-+    service->pcr_packet_period = ts->pcr_period/1000 * clk_rate;
-+    if (service->pcr_packet_period < (TS_PACKET_SIZE*8*10))
-+        service->pcr_packet_period = (TS_PACKET_SIZE*8*10);
-+    av_log(s, AV_LOG_VERBOSE, "clk_rate %f: ticks/pkt %d pcr, %d sdt, %d pmt\n", clk_rate,
-+        (int)service->pcr_packet_period, (int)ts->sdt_packet_period, (int)ts->pat_packet_period);
-+
-+    if (ts->copyts < 1)
-+        ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
-+
-     // output a PCR as soon as possible
--    service->pcr_packet_count = service->pcr_packet_period;
--    ts->pat_packet_count      = ts->pat_packet_period - 1;
--    ts->sdt_packet_count      = ts->sdt_packet_period - 1;
-+    ts->pcr = 0;
-+    service->pcr_packet_timer = 0;
-+    ts->pat_packet_timer      = 0;
-+    ts->sdt_packet_timer      = 0;
-     if (ts->mux_rate == 1)
-         av_log(s, AV_LOG_VERBOSE, "muxrate VBR, ");
-     else
-         av_log(s, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate);
--    av_log(s, AV_LOG_VERBOSE,
--           "pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\n",
--           service->pcr_packet_period,
--           ts->sdt_packet_period, ts->pat_packet_period);
--
--    if (ts->m2ts_mode == -1) {
--        if (av_match_ext(s->filename, "m2ts")) {
--            ts->m2ts_mode = 1;
--        } else {
--            ts->m2ts_mode = 0;
--        }
--    }
-     return 0;
-@@ -1028,22 +999,12 @@
-     MpegTSWrite *ts = s->priv_data;
-     int i;
--    if (++ts->sdt_packet_count == ts->sdt_packet_period ||
--        (dts != AV_NOPTS_VALUE && ts->last_sdt_ts == AV_NOPTS_VALUE) ||
--        (dts != AV_NOPTS_VALUE && dts - ts->last_sdt_ts >= ts->sdt_period*90000.0)
--    ) {
--        ts->sdt_packet_count = 0;
--        if (dts != AV_NOPTS_VALUE)
--            ts->last_sdt_ts = FFMAX(dts, ts->last_sdt_ts);
-+    if ( ts->sdt_packet_period >= 0 && ts->pcr >= ts->sdt_packet_timer ) {
-+        ts->sdt_packet_timer = ts->pcr + ts->sdt_packet_period;
-         mpegts_write_sdt(s);
-     }
--    if (++ts->pat_packet_count == ts->pat_packet_period ||
--        (dts != AV_NOPTS_VALUE && ts->last_pat_ts == AV_NOPTS_VALUE) ||
--        (dts != AV_NOPTS_VALUE && dts - ts->last_pat_ts >= ts->pat_period*90000.0) ||
--        force_pat) {
--        ts->pat_packet_count = 0;
--        if (dts != AV_NOPTS_VALUE)
--            ts->last_pat_ts = FFMAX(dts, ts->last_pat_ts);
-+    if (ts->pcr >= ts->pat_packet_timer || force_pat) {
-+        ts->pat_packet_timer = ts->pcr + ts->pat_packet_period;
-         mpegts_write_pat(s);
-         for (i = 0; i < ts->nb_services; i++)
-             mpegts_write_pmt(s, ts->services[i]);
-@@ -1085,13 +1046,14 @@
- {
-     MpegTSWrite *ts = s->priv_data;
-     MpegTSWriteStream *ts_st = st->priv_data;
-+    uint32_t pcr_pid = ts_st->service->pcr_pid;
-     uint8_t *q;
-     uint8_t buf[TS_PACKET_SIZE];
-     q    = buf;
-     *q++ = 0x47;
--    *q++ = ts_st->pid >> 8;
--    *q++ = ts_st->pid;
-+    *q++ = pcr_pid >> 8;
-+    *q++ = pcr_pid;
-     *q++ = 0x20 | ts_st->cc;   /* Adaptation only */
-     /* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) */
-     *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
-@@ -1102,7 +1064,7 @@
-     }
-     /* PCR coded into 6 bytes */
--    q += write_pcr_bits(q, get_pcr(ts, s->pb));
-+    q += write_pcr_bits(q, ts->pcr);
-     /* stuffing bytes */
-     memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
-@@ -1171,8 +1133,6 @@
-     uint8_t *q;
-     int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags;
-     int afc_len, stuffing_len;
--    int64_t pcr = -1; /* avoid warning */
--    int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
-     int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
-     av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO);
-@@ -1182,28 +1142,33 @@
-     is_start = 1;
-     while (payload_size > 0) {
-+        ts->pcr = ts->first_pcr + (ts->mux_rate == 1 ?
-+            (dts == AV_NOPTS_VALUE ? 0 : (dts - ts->delay) * 300) :
-+            // add 11, pcr references the last byte of program clock reference base
-+            av_rescale(avio_tell(s->pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate));
-+
-         retransmit_si_info(s, force_pat, dts);
-         force_pat = 0;
-         write_pcr = 0;
--        if (ts_st->pid == ts_st->service->pcr_pid) {
--            if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on frames
--                ts_st->service->pcr_packet_count++;
--            if (ts_st->service->pcr_packet_count >=
--                ts_st->service->pcr_packet_period) {
--                ts_st->service->pcr_packet_count = 0;
-+        if (ts_st->pid == ts_st->service->pcr_sid) {
-+            if( ts->pcr >= ts_st->service->pcr_packet_timer ) {
-+                ts_st->service->pcr_packet_timer = ts->pcr + ts_st->service->pcr_packet_period;
-                 write_pcr = 1;
-             }
-         }
--
-+        if (write_pcr && ts_st->service->pcr_sid != ts_st->service->pcr_pid) {
-+           mpegts_insert_pcr_only(s, st);
-+           continue;
-+        }
-         if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
--            (dts - get_pcr(ts, s->pb) / 300) > delay) {
--            /* pcr insert gets priority over null packet insert */
--            if (write_pcr)
--                mpegts_insert_pcr_only(s, st);
-+               (dts - ts->pcr / 300) > ts->delay) {
-+           /* pcr insert gets priority over null packet insert */
-+           if (write_pcr)
-+               mpegts_insert_pcr_only(s, st);
-             else
--                mpegts_insert_null_packet(s);
--            /* recalculate write_pcr and possibly retransmit si_info */
-+               mpegts_insert_null_packet(s);
-+            /* recalculate write_pcr and possibly retransimit si_info */
-             continue;
-         }
-@@ -1213,6 +1178,10 @@
-         val  = ts_st->pid >> 8;
-         if (is_start)
-             val |= 0x40;
-+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
-+          st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
-+          ts->m2ts_mode > 1)
-+            val |= 0x20;
-         *q++      = val;
-         *q++      = ts_st->pid;
-         ts_st->cc = ts_st->cc + 1 & 0xf;
-@@ -1224,7 +1193,7 @@
-         }
-         if (key && is_start && pts != AV_NOPTS_VALUE) {
-             // set Random Access for key frames
--            if (ts_st->pid == ts_st->service->pcr_pid)
-+            if (ts_st->pid == ts_st->service->pcr_sid)
-                 write_pcr = 1;
-             set_af_flag(buf, 0x40);
-             q = get_ts_payload_start(buf);
-@@ -1232,14 +1201,10 @@
-         if (write_pcr) {
-             set_af_flag(buf, 0x10);
-             q = get_ts_payload_start(buf);
--            // add 11, pcr references the last byte of program clock reference base
-             if (ts->mux_rate > 1)
--                pcr = get_pcr(ts, s->pb);
--            else
--                pcr = (dts - delay) * 300;
--            if (dts != AV_NOPTS_VALUE && dts < pcr / 300)
-+            if (dts != AV_NOPTS_VALUE && dts < ts->pcr / 300)
-                 av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n");
--            extend_af(buf, write_pcr_bits(q, pcr));
-+            extend_af(buf, write_pcr_bits(q, ts->pcr));
-             q = get_ts_payload_start(buf);
-         }
-         if (is_start) {
-@@ -1340,11 +1305,13 @@
-             *q++ = flags;
-             *q++ = header_len;
-             if (pts != AV_NOPTS_VALUE) {
--                write_pts(q, flags >> 6, pts);
-+                int64_t ts_pts = pts + ts->ts_offset;
-+                write_pts(q, flags >> 6, ts_pts);
-                 q += 5;
-             }
-             if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
--                write_pts(q, 1, dts);
-+                int64_t ts_dts = dts + ts->ts_offset;
-+                write_pts(q, 1, ts_dts);
-                 q += 5;
-             }
-             if (pes_extension && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) {
-@@ -1515,7 +1482,6 @@
-     uint8_t *data = NULL;
-     MpegTSWrite *ts = s->priv_data;
-     MpegTSWriteStream *ts_st = st->priv_data;
--    const int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) * 2;
-     int64_t dts = pkt->dts, pts = pkt->pts;
-     int opus_samples = 0;
-     int side_data_size;
-@@ -1536,16 +1502,15 @@
-     }
-     if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
--        ts->pat_packet_count = ts->pat_packet_period - 1;
--        ts->sdt_packet_count = ts->sdt_packet_period - 1;
-+        ts->pat_packet_timer = ts->sdt_packet_timer = 0;
-         ts->flags           &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;
-     }
-     if (ts->copyts < 1) {
-         if (pts != AV_NOPTS_VALUE)
--            pts += delay;
-+            pts += 2*ts->delay;
-         if (dts != AV_NOPTS_VALUE)
--            dts += delay;
-+            dts += 2*ts->delay;
-     }
-     if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
-@@ -1733,7 +1698,7 @@
-             AVStream *st2 = s->streams[i];
-             MpegTSWriteStream *ts_st2 = st2->priv_data;
-             if (   ts_st2->payload_size
--               && (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2)) {
-+               && (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > ts->delay)) {
-                 mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
-                                  ts_st2->payload_pts, ts_st2->payload_dts,
-                                  ts_st2->payload_flags & AV_PKT_FLAG_KEY, stream_id);
-@@ -1904,12 +1869,18 @@
-     { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
-       offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
-       { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
-+    { "mpegts_pcr_start_pid", "Set the first pid of the PCR.",
-+      offsetof(MpegTSWrite, pcr_start_pid), AV_OPT_TYPE_INT,
-+      { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
-     { "mpegts_start_pid", "Set the first pid.",
-       offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
-       { .i64 = 0x0100 }, 0x0010, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM },
-     { "mpegts_m2ts_mode", "Enable m2ts mode.",
-       offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_BOOL,
--      { .i64 = -1 }, -1, 1, AV_OPT_FLAG_ENCODING_PARAM },
-+      { .i64 = -1 }, -1, 2, AV_OPT_FLAG_ENCODING_PARAM },
-+    { "mpegts_pcr_offset", "clock offset.",
-+      offsetof(MpegTSWrite, ts_offset), AV_OPT_TYPE_BOOL,
-+      { .i64 = 0 }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-     { "muxrate", NULL,
-       offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT,
-       { .i64 = 1 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-@@ -1947,15 +1918,15 @@
-     { "omit_video_pes_length", "Omit the PES packet length for video packets",
-       offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
-       { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
--    { "pcr_period", "PCR retransmission time in milliseconds",
--      offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
--      { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
--    { "pat_period", "PAT/PMT retransmission time limit in seconds",
-+    { "pcr_period", "PCR retransmission time limit in msecs",
-+      offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_DOUBLE,
-+      { .dbl = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-+    { "pat_period", "PAT/PMT retransmission time limit in msecs",
-       offsetof(MpegTSWrite, pat_period), AV_OPT_TYPE_DOUBLE,
--      { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
--    { "sdt_period", "SDT retransmission time limit in seconds",
-+      { .dbl = PAT_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-+    { "sdt_period", "SDT retransmission time limit in msecs",
-       offsetof(MpegTSWrite, sdt_period), AV_OPT_TYPE_DOUBLE,
--      { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-+      { .dbl = SDT_RETRANS_TIME }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-     { NULL },
- };
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch5 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.patch5
deleted file mode 100644 (file)
index 55cc48b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-diff -ur a/libavformat/avformat.h b/libavformat/avformat.h
---- a/libavformat/avformat.h   2017-06-06 20:03:55.000000000 -0600
-+++ b/libavformat/avformat.h   2017-07-20 09:10:40.434571231 -0600
-@@ -504,6 +504,9 @@
-                                         The user or muxer can override this through
-                                         AVFormatContext.avoid_negative_ts
-                                         */
-+#define AVFMT_SEEK_NOSTREAMS  0x80000 /**< Stream index ignored by seek,
-+                                           or some streams fail to seek
-+                                           */
- #define AVFMT_SEEK_TO_PTS   0x4000000 /**< Seeking is based on PTS */
-@@ -664,7 +667,8 @@
-     /**
-      * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
-      * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
--     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
-+     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS,
-+     * AVFMT_SEEK_NOSTREAMS
-      */
-     int flags;
-diff -ur a/libavformat/dv.c b/libavformat/dv.c
---- a/libavformat/dv.c 2017-06-06 20:03:55.000000000 -0600
-+++ b/libavformat/dv.c 2017-07-20 09:12:00.277148325 -0600
-@@ -632,6 +632,7 @@
- AVInputFormat ff_dv_demuxer = {
-     .name           = "dv",
-     .long_name      = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
-+    .flags          = AVFMT_SEEK_NOSTREAMS,
-     .priv_data_size = sizeof(RawDVContext),
-     .read_probe     = dv_probe,
-     .read_header    = dv_read_header,
-diff -ur a/libavformat/matroskadec.c b/libavformat/matroskadec.c
---- a/libavformat/matroskadec.c        2017-06-06 20:03:55.000000000 -0600
-+++ b/libavformat/matroskadec.c        2017-07-20 12:29:39.804273095 -0600
-@@ -3936,6 +3936,7 @@
- AVInputFormat ff_matroska_demuxer = {
-     .name           = "matroska,webm",
-     .long_name      = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
-+    .flags          = AVFMT_SEEK_NOSTREAMS,
-     .extensions     = "mkv,mk3d,mka,mks",
-     .priv_data_size = sizeof(MatroskaDemuxContext),
-     .read_probe     = matroska_probe,
-@@ -3949,6 +3950,7 @@
- AVInputFormat ff_webm_dash_manifest_demuxer = {
-     .name           = "webm_dash_manifest",
-     .long_name      = NULL_IF_CONFIG_SMALL("WebM DASH Manifest"),
-+    .flags          = AVFMT_SEEK_NOSTREAMS,
-     .priv_data_size = sizeof(MatroskaDemuxContext),
-     .read_header    = webm_dash_manifest_read_header,
-     .read_packet    = webm_dash_manifest_read_packet,
-diff -ur a/libavformat/utils.c b/libavformat/utils.c
---- a/libavformat/utils.c      2017-06-06 20:04:02.000000000 -0600
-+++ b/libavformat/utils.c      2017-07-20 09:53:28.684729516 -0600
-@@ -2412,6 +2412,13 @@
-         return seek_frame_byte(s, stream_index, timestamp, flags);
-     }
-+    if (stream_index != -1 && (s->iformat->flags & AVFMT_SEEK_NOSTREAMS)) {
-+            timestamp = av_rescale_q(timestamp,
-+                    s->streams[stream_index]->time_base,
-+                    AV_TIME_BASE_Q);
-+            stream_index = -1;
-+    }
-+
-     if (stream_index < 0) {
-         stream_index = av_find_default_stream_index(s);
-         if (stream_index < 0)
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.tar.xz b/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.tar.xz
deleted file mode 100644 (file)
index 671b619..0000000
Binary files a/cinelerra-5.1/thirdparty/src/ffmpeg-3.3.4.tar.xz and /dev/null differ
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch1 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch1
new file mode 100644 (file)
index 0000000..daa9953
--- /dev/null
@@ -0,0 +1,12 @@
+diff -ru ffmpeg-3.0.orig/libavformat/bluray.c ffmpeg-3.0/libavformat/bluray.c
+--- ffmpeg-3.0.orig/libavformat/bluray.c       2015-03-13 11:34:50.000000000 -0600
++++ ffmpeg-3.0/libavformat/bluray.c    2016-05-09 14:07:34.758713307 -0600
+@@ -28,7 +28,7 @@
+ #include "libavutil/opt.h"
+ #define BLURAY_PROTO_PREFIX     "bluray:"
+-#define MIN_PLAYLIST_LENGTH     180     /* 3 min */
++#define MIN_PLAYLIST_LENGTH     0
+ typedef struct {
+     const AVClass *class;
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch2 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch2
new file mode 100644 (file)
index 0000000..bb628d9
--- /dev/null
@@ -0,0 +1,498 @@
+diff -ur a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
+--- a/libavformat/mpegtsenc.c  2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/mpegtsenc.c  2017-12-18 10:54:14.260167666 -0700
+@@ -56,9 +56,8 @@
+     int sid;           /* service ID */
+     char *name;
+     char *provider_name;
+-    int pcr_pid;
+-    int pcr_packet_count;
+-    int pcr_packet_period;
++    int64_t pcr, pcr_packet_timer, pcr_packet_period;
++    int pcr_sid, pcr_pid;
+     AVProgram *program;
+ } MpegTSService;
+@@ -78,14 +77,12 @@
+     MpegTSSection pat; /* MPEG-2 PAT table */
+     MpegTSSection sdt; /* MPEG-2 SDT table context */
+     MpegTSService **services;
+-    int sdt_packet_count;
+-    int sdt_packet_period;
+-    int pat_packet_count;
+-    int pat_packet_period;
++    int64_t sdt_packet_timer, sdt_packet_period;
++    int64_t pat_packet_timer, pat_packet_period;
+     int nb_services;
+     int onid;
+     int tsid;
+-    int64_t first_pcr;
++    int64_t pcr, first_pcr, delay;
+     int mux_rate; ///< set to 1 when VBR
+     int pes_payload_size;
+@@ -95,12 +92,14 @@
+     int service_type;
+     int pmt_start_pid;
++    int pcr_start_pid;
+     int start_pid;
+     int m2ts_mode;
++    int64_t ts_offset;
+     int reemit_pat_pmt; // backward compatibility
+-    int pcr_period;
++    double pcr_period;
+ #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
+ #define MPEGTS_FLAG_AAC_LATM        0x02
+ #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES           0x04
+@@ -111,8 +110,6 @@
+     int tables_version;
+     double pat_period;
+     double sdt_period;
+-    int64_t last_pat_ts;
+-    int64_t last_sdt_ts;
+     int omit_video_pes_length;
+ } MpegTSWrite;
+@@ -222,10 +219,10 @@
+ #define DEFAULT_PROVIDER_NAME   "FFmpeg"
+ #define DEFAULT_SERVICE_NAME    "Service01"
+-/* we retransmit the SI info at this rate */
++/* we retransmit the SI info at this rate (ms) */
+ #define SDT_RETRANS_TIME 500
+ #define PAT_RETRANS_TIME 100
+-#define PCR_RETRANS_TIME 20
++#define PCR_RETRANS_TIME 50
+ typedef struct MpegTSWriteStream {
+     struct MpegTSService *service;
+@@ -721,6 +718,7 @@
+     service->pmt.pid       = ts->pmt_start_pid + ts->nb_services;
+     service->sid           = sid;
+     service->pcr_pid       = 0x1fff;
++    service->pcr_sid       = 0x1fff;
+     service->provider_name = av_strdup(provider_name);
+     service->name          = av_strdup(name);
+     if (!service->provider_name || !service->name)
+@@ -736,18 +734,11 @@
+     return NULL;
+ }
+-static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
+-{
+-    return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
+-           ts->first_pcr;
+-}
+-
+ static void mpegts_prefix_m2ts_header(AVFormatContext *s)
+ {
+     MpegTSWrite *ts = s->priv_data;
+     if (ts->m2ts_mode) {
+-        int64_t pcr = get_pcr(s->priv_data, s->pb);
+-        uint32_t tp_extra_header = pcr % 0x3fffffff;
++        uint32_t tp_extra_header = ts->pcr % 0x3fffffff;
+         tp_extra_header = AV_RB32(&tp_extra_header);
+         avio_write(s->pb, (unsigned char *) &tp_extra_header,
+                    sizeof(tp_extra_header));
+@@ -768,6 +759,7 @@
+     MpegTSService *service;
+     AVStream *st, *pcr_st = NULL;
+     AVDictionaryEntry *title, *provider;
++    double clk_rate;
+     int i, j;
+     const char *service_name;
+     const char *provider_name;
+@@ -776,6 +768,15 @@
+     if (s->max_delay < 0) /* Not set by the caller */
+         s->max_delay = 0;
++    ts->delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
++
++    if (ts->m2ts_mode == -1) {
++        if (av_match_ext(s->filename, "m2ts")) {
++            ts->m2ts_mode = 1;
++        } else {
++            ts->m2ts_mode = 0;
++        }
++    }
+     // round up to a whole number of TS packets
+     ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
+@@ -822,6 +823,8 @@
+             service->program          = program;
+         }
+     }
++    if (ts->m2ts_mode > 1)
++        service->pmt.pid = 0x00ff + ts->service_id;
+     ts->pat.pid          = PAT_PID;
+     /* Initialize at 15 so that it wraps and is equal to 0 for the
+@@ -907,10 +910,9 @@
+         ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
+         /* update PCR pid by using the first video stream */
+         if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+-            service->pcr_pid == 0x1fff) {
+-            service->pcr_pid = ts_st->pid;
++            service->pcr_sid == 0x1fff)
+             pcr_st           = st;
+-        }
++
+         if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
+             st->codecpar->extradata_size > 0) {
+             AVStream *ast;
+@@ -946,78 +948,47 @@
+     av_freep(&pids);
+     /* if no video stream, use the first stream as PCR */
+-    if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
+-        pcr_st           = s->streams[0];
+-        ts_st            = pcr_st->priv_data;
+-        service->pcr_pid = ts_st->pid;
+-    } else
+-        ts_st = pcr_st->priv_data;
+-
+-    if (ts->mux_rate > 1) {
+-        service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period /
+-                                     (TS_PACKET_SIZE * 8 * 1000);
+-        ts->sdt_packet_period      = (int64_t)ts->mux_rate * SDT_RETRANS_TIME /
+-                                     (TS_PACKET_SIZE * 8 * 1000);
+-        ts->pat_packet_period      = (int64_t)ts->mux_rate * PAT_RETRANS_TIME /
+-                                     (TS_PACKET_SIZE * 8 * 1000);
+-
+-        if (ts->copyts < 1)
+-            ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
+-    } else {
+-        /* Arbitrary values, PAT/PMT will also be written on video key frames */
+-        ts->sdt_packet_period = 200;
+-        ts->pat_packet_period = 40;
+-        if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
+-            if (!frame_size) {
+-                av_log(s, AV_LOG_WARNING, "frame size not set\n");
+-                service->pcr_packet_period =
+-                    pcr_st->codecpar->sample_rate / (10 * 512);
+-            } else {
+-                service->pcr_packet_period =
+-                    pcr_st->codecpar->sample_rate / (10 * frame_size);
+-            }
+-        } else {
+-            // max delta PCR 0.1s
+-            // TODO: should be avg_frame_rate
+-            service->pcr_packet_period =
+-                ts_st->user_tb.den / (10 * ts_st->user_tb.num);
+-        }
+-        if (!service->pcr_packet_period)
+-            service->pcr_packet_period = 1;
+-    }
+-
+-    ts->last_pat_ts = AV_NOPTS_VALUE;
+-    ts->last_sdt_ts = AV_NOPTS_VALUE;
+-    // The user specified a period, use only it
+-    if (ts->pat_period < INT_MAX/2) {
+-        ts->pat_packet_period = INT_MAX;
++    if (!pcr_st && s->nb_streams > 0)
++        pcr_st = s->streams[0];
++    if (!pcr_st) {
++        av_log(s, AV_LOG_ERROR, "no streams\n");
++        ret = AVERROR(EINVAL);
++        goto fail;
+     }
+-    if (ts->sdt_period < INT_MAX/2) {
+-        ts->sdt_packet_period = INT_MAX;
++    ts_st  = pcr_st->priv_data;
++    if (service->pcr_sid == 0x1fff)
++        service->pcr_sid   = ts_st->pid;
++    if (service->pcr_pid == 0x1fff)
++        service->pcr_pid   = ts->m2ts_mode > 1 ?
++            0x1000 + ts->service_id : service->pcr_sid ;
++    if (service->pmt.pid == service->pcr_pid) {
++        av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", service->pcr_pid);
++        ret = AVERROR(EINVAL);
++        goto fail;
+     }
++    clk_rate = ts->mux_rate > 1 ? ts->mux_rate : PCR_TIME_BASE;
++    ts->sdt_packet_period      = ts->sdt_period < 0 ? -1 : ts->sdt_period/1000 * clk_rate;
++    ts->pat_packet_period      = ts->pat_period/1000 * clk_rate;
++    service->pcr_packet_period = ts->pcr_period/1000 * clk_rate;
++    if (service->pcr_packet_period < (TS_PACKET_SIZE*8*10))
++        service->pcr_packet_period = (TS_PACKET_SIZE*8*10);
++    av_log(s, AV_LOG_VERBOSE, "clk_rate %f: ticks/pkt %d pcr, %d sdt, %d pmt\n", clk_rate,
++        (int)service->pcr_packet_period, (int)ts->sdt_packet_period, (int)ts->pat_packet_period);
++
++    if (ts->copyts < 1)
++        ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
++
+     // output a PCR as soon as possible
+-    service->pcr_packet_count = service->pcr_packet_period;
+-    ts->pat_packet_count      = ts->pat_packet_period - 1;
+-    ts->sdt_packet_count      = ts->sdt_packet_period - 1;
++    ts->pcr = 0;
++    service->pcr_packet_timer = 0;
++    ts->pat_packet_timer      = 0;
++    ts->sdt_packet_timer      = 0;
+     if (ts->mux_rate == 1)
+         av_log(s, AV_LOG_VERBOSE, "muxrate VBR, ");
+     else
+         av_log(s, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate);
+-    av_log(s, AV_LOG_VERBOSE,
+-           "pcr every %d pkts, sdt every %d, pat/pmt every %d pkts\n",
+-           service->pcr_packet_period,
+-           ts->sdt_packet_period, ts->pat_packet_period);
+-
+-    if (ts->m2ts_mode == -1) {
+-        if (av_match_ext(s->filename, "m2ts")) {
+-            ts->m2ts_mode = 1;
+-        } else {
+-            ts->m2ts_mode = 0;
+-        }
+-    }
+     return 0;
+@@ -1032,22 +1003,12 @@
+     MpegTSWrite *ts = s->priv_data;
+     int i;
+-    if (++ts->sdt_packet_count == ts->sdt_packet_period ||
+-        (dts != AV_NOPTS_VALUE && ts->last_sdt_ts == AV_NOPTS_VALUE) ||
+-        (dts != AV_NOPTS_VALUE && dts - ts->last_sdt_ts >= ts->sdt_period*90000.0)
+-    ) {
+-        ts->sdt_packet_count = 0;
+-        if (dts != AV_NOPTS_VALUE)
+-            ts->last_sdt_ts = FFMAX(dts, ts->last_sdt_ts);
++    if ( ts->sdt_packet_period >= 0 && ts->pcr >= ts->sdt_packet_timer ) {
++        ts->sdt_packet_timer = ts->pcr + ts->sdt_packet_period;
+         mpegts_write_sdt(s);
+     }
+-    if (++ts->pat_packet_count == ts->pat_packet_period ||
+-        (dts != AV_NOPTS_VALUE && ts->last_pat_ts == AV_NOPTS_VALUE) ||
+-        (dts != AV_NOPTS_VALUE && dts - ts->last_pat_ts >= ts->pat_period*90000.0) ||
+-        force_pat) {
+-        ts->pat_packet_count = 0;
+-        if (dts != AV_NOPTS_VALUE)
+-            ts->last_pat_ts = FFMAX(dts, ts->last_pat_ts);
++    if (ts->pcr >= ts->pat_packet_timer || force_pat) {
++        ts->pat_packet_timer = ts->pcr + ts->pat_packet_period;
+         mpegts_write_pat(s);
+         for (i = 0; i < ts->nb_services; i++)
+             mpegts_write_pmt(s, ts->services[i]);
+@@ -1089,13 +1050,14 @@
+ {
+     MpegTSWrite *ts = s->priv_data;
+     MpegTSWriteStream *ts_st = st->priv_data;
++    uint32_t pcr_pid = ts_st->service->pcr_pid;
+     uint8_t *q;
+     uint8_t buf[TS_PACKET_SIZE];
+     q    = buf;
+     *q++ = 0x47;
+-    *q++ = ts_st->pid >> 8;
+-    *q++ = ts_st->pid;
++    *q++ = pcr_pid >> 8;
++    *q++ = pcr_pid;
+     *q++ = 0x20 | ts_st->cc;   /* Adaptation only */
+     /* Continuity Count field does not increment (see 13818-1 section 2.4.3.3) */
+     *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
+@@ -1106,7 +1068,7 @@
+     }
+     /* PCR coded into 6 bytes */
+-    q += write_pcr_bits(q, get_pcr(ts, s->pb));
++    q += write_pcr_bits(q, ts->pcr);
+     /* stuffing bytes */
+     memset(q, 0xFF, TS_PACKET_SIZE - (q - buf));
+@@ -1175,8 +1137,6 @@
+     uint8_t *q;
+     int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags;
+     int afc_len, stuffing_len;
+-    int64_t pcr = -1; /* avoid warning */
+-    int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
+     int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
+     av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO);
+@@ -1186,28 +1146,33 @@
+     is_start = 1;
+     while (payload_size > 0) {
++        ts->pcr = ts->first_pcr + (ts->mux_rate == 1 ?
++            (dts == AV_NOPTS_VALUE ? 0 : (dts - ts->delay) * 300) :
++            // add 11, pcr references the last byte of program clock reference base
++            av_rescale(avio_tell(s->pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate));
++
+         retransmit_si_info(s, force_pat, dts);
+         force_pat = 0;
+         write_pcr = 0;
+-        if (ts_st->pid == ts_st->service->pcr_pid) {
+-            if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on frames
+-                ts_st->service->pcr_packet_count++;
+-            if (ts_st->service->pcr_packet_count >=
+-                ts_st->service->pcr_packet_period) {
+-                ts_st->service->pcr_packet_count = 0;
++        if (ts_st->pid == ts_st->service->pcr_sid) {
++            if( ts->pcr >= ts_st->service->pcr_packet_timer ) {
++                ts_st->service->pcr_packet_timer = ts->pcr + ts_st->service->pcr_packet_period;
+                 write_pcr = 1;
+             }
+         }
+-
++        if (write_pcr && ts_st->service->pcr_sid != ts_st->service->pcr_pid) {
++           mpegts_insert_pcr_only(s, st);
++           continue;
++        }
+         if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE &&
+-            (dts - get_pcr(ts, s->pb) / 300) > delay) {
+-            /* pcr insert gets priority over null packet insert */
+-            if (write_pcr)
+-                mpegts_insert_pcr_only(s, st);
++               (dts - ts->pcr / 300) > ts->delay) {
++           /* pcr insert gets priority over null packet insert */
++           if (write_pcr)
++               mpegts_insert_pcr_only(s, st);
+             else
+-                mpegts_insert_null_packet(s);
+-            /* recalculate write_pcr and possibly retransmit si_info */
++               mpegts_insert_null_packet(s);
++            /* recalculate write_pcr and possibly retransimit si_info */
+             continue;
+         }
+@@ -1217,6 +1182,10 @@
+         val  = ts_st->pid >> 8;
+         if (is_start)
+             val |= 0x40;
++        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
++          st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
++          ts->m2ts_mode > 1)
++            val |= 0x20;
+         *q++      = val;
+         *q++      = ts_st->pid;
+         ts_st->cc = ts_st->cc + 1 & 0xf;
+@@ -1228,7 +1197,7 @@
+         }
+         if (key && is_start && pts != AV_NOPTS_VALUE) {
+             // set Random Access for key frames
+-            if (ts_st->pid == ts_st->service->pcr_pid)
++            if (ts_st->pid == ts_st->service->pcr_sid)
+                 write_pcr = 1;
+             set_af_flag(buf, 0x40);
+             q = get_ts_payload_start(buf);
+@@ -1236,14 +1205,10 @@
+         if (write_pcr) {
+             set_af_flag(buf, 0x10);
+             q = get_ts_payload_start(buf);
+-            // add 11, pcr references the last byte of program clock reference base
+             if (ts->mux_rate > 1)
+-                pcr = get_pcr(ts, s->pb);
+-            else
+-                pcr = (dts - delay) * 300;
+-            if (dts != AV_NOPTS_VALUE && dts < pcr / 300)
++            if (dts != AV_NOPTS_VALUE && dts < ts->pcr / 300)
+                 av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n");
+-            extend_af(buf, write_pcr_bits(q, pcr));
++            extend_af(buf, write_pcr_bits(q, ts->pcr));
+             q = get_ts_payload_start(buf);
+         }
+         if (is_start) {
+@@ -1344,11 +1309,13 @@
+             *q++ = flags;
+             *q++ = header_len;
+             if (pts != AV_NOPTS_VALUE) {
+-                write_pts(q, flags >> 6, pts);
++                int64_t ts_pts = pts + ts->ts_offset;
++                write_pts(q, flags >> 6, ts_pts);
+                 q += 5;
+             }
+             if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) {
+-                write_pts(q, 1, dts);
++                int64_t ts_dts = dts + ts->ts_offset;
++                write_pts(q, 1, ts_dts);
+                 q += 5;
+             }
+             if (pes_extension && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) {
+@@ -1519,7 +1486,6 @@
+     uint8_t *data = NULL;
+     MpegTSWrite *ts = s->priv_data;
+     MpegTSWriteStream *ts_st = st->priv_data;
+-    const int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) * 2;
+     int64_t dts = pkt->dts, pts = pkt->pts;
+     int opus_samples = 0;
+     int side_data_size;
+@@ -1540,16 +1506,15 @@
+     }
+     if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
+-        ts->pat_packet_count = ts->pat_packet_period - 1;
+-        ts->sdt_packet_count = ts->sdt_packet_period - 1;
++        ts->pat_packet_timer = ts->sdt_packet_timer = 0;
+         ts->flags           &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;
+     }
+     if (ts->copyts < 1) {
+         if (pts != AV_NOPTS_VALUE)
+-            pts += delay;
++            pts += 2*ts->delay;
+         if (dts != AV_NOPTS_VALUE)
+-            dts += delay;
++            dts += 2*ts->delay;
+     }
+     if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
+@@ -1737,7 +1702,7 @@
+             AVStream *st2 = s->streams[i];
+             MpegTSWriteStream *ts_st2 = st2->priv_data;
+             if (   ts_st2->payload_size
+-               && (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2)) {
++               && (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > ts->delay)) {
+                 mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
+                                  ts_st2->payload_pts, ts_st2->payload_dts,
+                                  ts_st2->payload_flags & AV_PKT_FLAG_KEY, stream_id);
+@@ -1908,12 +1873,18 @@
+     { "mpegts_pmt_start_pid", "Set the first pid of the PMT.",
+       offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT,
+       { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
++    { "mpegts_pcr_start_pid", "Set the first pid of the PCR.",
++      offsetof(MpegTSWrite, pcr_start_pid), AV_OPT_TYPE_INT,
++      { .i64 = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM },
+     { "mpegts_start_pid", "Set the first pid.",
+       offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT,
+       { .i64 = 0x0100 }, 0x0010, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM },
+     { "mpegts_m2ts_mode", "Enable m2ts mode.",
+       offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_BOOL,
+-      { .i64 = -1 }, -1, 1, AV_OPT_FLAG_ENCODING_PARAM },
++      { .i64 = -1 }, -1, 2, AV_OPT_FLAG_ENCODING_PARAM },
++    { "mpegts_pcr_offset", "clock offset.",
++      offsetof(MpegTSWrite, ts_offset), AV_OPT_TYPE_BOOL,
++      { .i64 = 0 }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+     { "muxrate", NULL,
+       offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT,
+       { .i64 = 1 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+@@ -1951,15 +1922,15 @@
+     { "omit_video_pes_length", "Omit the PES packet length for video packets",
+       offsetof(MpegTSWrite, omit_video_pes_length), AV_OPT_TYPE_BOOL,
+       { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+-    { "pcr_period", "PCR retransmission time in milliseconds",
+-      offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_INT,
+-      { .i64 = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+-    { "pat_period", "PAT/PMT retransmission time limit in seconds",
++    { "pcr_period", "PCR retransmission time limit in msecs",
++      offsetof(MpegTSWrite, pcr_period), AV_OPT_TYPE_DOUBLE,
++      { .dbl = PCR_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
++    { "pat_period", "PAT/PMT retransmission time limit in msecs",
+       offsetof(MpegTSWrite, pat_period), AV_OPT_TYPE_DOUBLE,
+-      { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+-    { "sdt_period", "SDT retransmission time limit in seconds",
++      { .dbl = PAT_RETRANS_TIME }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
++    { "sdt_period", "SDT retransmission time limit in msecs",
+       offsetof(MpegTSWrite, sdt_period), AV_OPT_TYPE_DOUBLE,
+-      { .dbl = INT_MAX }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
++      { .dbl = SDT_RETRANS_TIME }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+     { NULL },
+ };
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch3 b/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.patch3
new file mode 100644 (file)
index 0000000..a96cf1c
--- /dev/null
@@ -0,0 +1,70 @@
+diff -ur a/libavformat/avformat.h b/libavformat/avformat.h
+--- a/libavformat/avformat.h   2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/avformat.h   2017-12-18 11:11:31.791996302 -0700
+@@ -504,6 +504,9 @@
+                                         The user or muxer can override this through
+                                         AVFormatContext.avoid_negative_ts
+                                         */
++#define AVFMT_SEEK_NOSTREAMS  0x80000 /**< Stream index ignored by seek,
++                                           or some streams fail to seek
++                                           */
+ #define AVFMT_SEEK_TO_PTS   0x4000000 /**< Seeking is based on PTS */
+@@ -664,7 +667,8 @@
+     /**
+      * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
+      * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
+-     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
++     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS,
++     * AVFMT_SEEK_NOSTREAMS
+      */
+     int flags;
+diff -ur a/libavformat/dv.c b/libavformat/dv.c
+--- a/libavformat/dv.c 2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/dv.c 2017-12-18 11:11:31.792996246 -0700
+@@ -632,6 +632,7 @@
+ AVInputFormat ff_dv_demuxer = {
+     .name           = "dv",
+     .long_name      = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
++    .flags          = AVFMT_SEEK_NOSTREAMS,
+     .priv_data_size = sizeof(RawDVContext),
+     .read_probe     = dv_probe,
+     .read_header    = dv_read_header,
+diff -ur a/libavformat/matroskadec.c b/libavformat/matroskadec.c
+--- a/libavformat/matroskadec.c        2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/matroskadec.c        2017-12-18 11:11:31.793996189 -0700
+@@ -3984,6 +3984,7 @@
+ AVInputFormat ff_matroska_demuxer = {
+     .name           = "matroska,webm",
+     .long_name      = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
++    .flags          = AVFMT_SEEK_NOSTREAMS,
+     .extensions     = "mkv,mk3d,mka,mks",
+     .priv_data_size = sizeof(MatroskaDemuxContext),
+     .read_probe     = matroska_probe,
+@@ -3997,6 +3998,7 @@
+ AVInputFormat ff_webm_dash_manifest_demuxer = {
+     .name           = "webm_dash_manifest",
+     .long_name      = NULL_IF_CONFIG_SMALL("WebM DASH Manifest"),
++    .flags          = AVFMT_SEEK_NOSTREAMS,
+     .priv_data_size = sizeof(MatroskaDemuxContext),
+     .read_header    = webm_dash_manifest_read_header,
+     .read_packet    = webm_dash_manifest_read_packet,
+diff -ur a/libavformat/utils.c ./libavformat/utils.c
+--- a/libavformat/utils.c      2017-12-10 14:35:18.000000000 -0700
++++ b/libavformat/utils.c      2017-12-18 11:11:31.795996077 -0700
+@@ -2416,6 +2416,13 @@
+         return seek_frame_byte(s, stream_index, timestamp, flags);
+     }
++    if (stream_index != -1 && (s->iformat->flags & AVFMT_SEEK_NOSTREAMS)) {
++            timestamp = av_rescale_q(timestamp,
++                    s->streams[stream_index]->time_base,
++                    AV_TIME_BASE_Q);
++            stream_index = -1;
++    }
++
+     if (stream_index < 0) {
+         stream_index = av_find_default_stream_index(s);
+         if (stream_index < 0)
diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.tar.xz b/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.tar.xz
new file mode 100644 (file)
index 0000000..8970943
Binary files /dev/null and b/cinelerra-5.1/thirdparty/src/ffmpeg-3.4.1.tar.xz differ
index 2e9797e73975bb493816d71d7db64560a7891f2c..daa9953880fd0b326f34cd17c68f50f0dcdc5a93 100644 (file)
@@ -1,6 +1,6 @@
-diff -ur a/libavformat/bluray.c b/libavformat/bluray.c
---- a/libavformat/bluray.c     2017-10-13 16:31:25.000000000 -0600
-+++ b/libavformat/bluray.c     2017-10-13 20:05:45.910046165 -0600
+diff -ru ffmpeg-3.0.orig/libavformat/bluray.c ffmpeg-3.0/libavformat/bluray.c
+--- ffmpeg-3.0.orig/libavformat/bluray.c       2015-03-13 11:34:50.000000000 -0600
++++ ffmpeg-3.0/libavformat/bluray.c    2016-05-09 14:07:34.758713307 -0600
 @@ -28,7 +28,7 @@
  #include "libavutil/opt.h"
  
index fac116493e1388162e86911f2b62ec0d3009818d..bb628d933ab56c3644aacf12697c4272cb3ca767 100644 (file)
@@ -1,6 +1,6 @@
 diff -ur a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
---- a/libavformat/mpegtsenc.c  2017-10-13 16:31:25.000000000 -0600
-+++ b/libavformat/mpegtsenc.c  2017-10-13 20:06:27.930649088 -0600
+--- a/libavformat/mpegtsenc.c  2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/mpegtsenc.c  2017-12-18 10:54:14.260167666 -0700
 @@ -56,9 +56,8 @@
      int sid;           /* service ID */
      char *name;
@@ -496,4 +496,3 @@ diff -ur a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
      { NULL },
  };
  
-Only in b/libavformat: mpegtsenc.c.orig
index c774d19a40d88325300cf4f338bb0f57572ca23f..a96cf1cd88fd92cff3222797586c201e3d29285c 100644 (file)
@@ -1,6 +1,6 @@
 diff -ur a/libavformat/avformat.h b/libavformat/avformat.h
---- a/libavformat/avformat.h   2017-10-13 16:31:25.000000000 -0600
-+++ b/libavformat/avformat.h   2017-10-13 20:07:24.178440418 -0600
+--- a/libavformat/avformat.h   2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/avformat.h   2017-12-18 11:11:31.791996302 -0700
 @@ -504,6 +504,9 @@
                                          The user or muxer can override this through
                                          AVFormatContext.avoid_negative_ts
@@ -22,8 +22,8 @@ diff -ur a/libavformat/avformat.h b/libavformat/avformat.h
      int flags;
  
 diff -ur a/libavformat/dv.c b/libavformat/dv.c
---- a/libavformat/dv.c 2017-10-13 16:31:25.000000000 -0600
-+++ b/libavformat/dv.c 2017-10-13 20:07:24.178440418 -0600
+--- a/libavformat/dv.c 2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/dv.c 2017-12-18 11:11:31.792996246 -0700
 @@ -632,6 +632,7 @@
  AVInputFormat ff_dv_demuxer = {
      .name           = "dv",
@@ -33,8 +33,8 @@ diff -ur a/libavformat/dv.c b/libavformat/dv.c
      .read_probe     = dv_probe,
      .read_header    = dv_read_header,
 diff -ur a/libavformat/matroskadec.c b/libavformat/matroskadec.c
---- a/libavformat/matroskadec.c        2017-10-13 16:31:25.000000000 -0600
-+++ b/libavformat/matroskadec.c        2017-10-13 20:07:24.180440304 -0600
+--- a/libavformat/matroskadec.c        2017-12-10 14:35:10.000000000 -0700
++++ b/libavformat/matroskadec.c        2017-12-18 11:11:31.793996189 -0700
 @@ -3984,6 +3984,7 @@
  AVInputFormat ff_matroska_demuxer = {
      .name           = "matroska,webm",
@@ -51,11 +51,10 @@ diff -ur a/libavformat/matroskadec.c b/libavformat/matroskadec.c
      .priv_data_size = sizeof(MatroskaDemuxContext),
      .read_header    = webm_dash_manifest_read_header,
      .read_packet    = webm_dash_manifest_read_packet,
-Only in b/libavformat: matroskadec.c.orig
-diff -ur a/libavformat/utils.c b/libavformat/utils.c
---- a/libavformat/utils.c      2017-10-13 16:31:25.000000000 -0600
-+++ b/libavformat/utils.c      2017-10-13 20:07:24.182440190 -0600
-@@ -2415,6 +2415,13 @@
+diff -ur a/libavformat/utils.c ./libavformat/utils.c
+--- a/libavformat/utils.c      2017-12-10 14:35:18.000000000 -0700
++++ b/libavformat/utils.c      2017-12-18 11:11:31.795996077 -0700
+@@ -2416,6 +2416,13 @@
          return seek_frame_byte(s, stream_index, timestamp, flags);
      }
  
@@ -69,4 +68,3 @@ diff -ur a/libavformat/utils.c b/libavformat/utils.c
      if (stream_index < 0) {
          stream_index = av_find_default_stream_index(s);
          if (stream_index < 0)
-Only in b/libavformat: utils.c.orig
diff --git a/cinelerra-5.1/thirdparty/src/opus-1.2.1.tar.xz b/cinelerra-5.1/thirdparty/src/opus-1.2.1.tar.xz
new file mode 100644 (file)
index 0000000..c2f3c81
Binary files /dev/null and b/cinelerra-5.1/thirdparty/src/opus-1.2.1.tar.xz differ