From 77c806636b4a94f41c724e45208201eb926dd8ce Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sat, 3 Jun 2023 14:40:19 -0600 Subject: [PATCH] ffmpeg git patches for 6.0 updates --- .../thirdparty/src/ffmpeg.git.patch0 | 5 +- .../thirdparty/src/ffmpeg.git.patch2 | 49 ++++++++++--------- .../thirdparty/src/ffmpeg.git.patch3 | 12 ++--- .../thirdparty/src/ffmpeg.git.patch4 | 2 +- .../thirdparty/src/ffmpeg.git.patch8 | 2 +- .../thirdparty/src/ffmpeg.git.patch9 | 2 +- .../thirdparty/src/ffmpeg.git.patchC | 14 +++--- .../thirdparty/src/ffmpeg.git.patchZ1 | 10 +--- 8 files changed, 46 insertions(+), 50 deletions(-) diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch0 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch0 index 7deb9356..06435263 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch0 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch0 @@ -8,7 +8,8 @@ + #include "libavcodec/aaccoder_trellis.h" - /** + typedef float (*quantize_and_encode_band_func)(struct AACEncContext *s, PutBitContext *pb, + --- a/libavcodec/hevc_mvs.c +++ b/libavcodec/hevc_mvs.c @@ -25,6 +25,8 @@ @@ -22,7 +23,7 @@ { 1, 0, }, --- a/libavcodec/opus_pvq.c +++ b/libavcodec/opus_pvq.c -@@ -31,6 +31,8 @@ +@@ -36,6 +36,8 @@ #define CELT_PVQ_U(n, k) (ff_celt_pvq_u_row[FFMIN(n, k)][FFMAX(n, k)]) #define CELT_PVQ_V(n, k) (CELT_PVQ_U(n, k) + CELT_PVQ_U(n, (k) + 1)) diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch2 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch2 index 6e1a7fc6..d346510e 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch2 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch2 @@ -1,6 +1,6 @@ ---- a/libavformat/mpegtsenc.c -+++ b/libavformat/mpegtsenc.c -@@ -84,9 +84,11 @@ +--- a/libavformat/mpegtsenc.c 2023-05-25 11:35:50.216478386 -0600 ++++ b/libavformat/mpegtsenc.c 2023-05-25 11:36:49.259182848 -0600 +@@ -87,9 +87,11 @@ int64_t pat_period; /* PAT/PMT period in PCR time base */ int64_t nit_period; /* NIT period in PCR time base */ int nb_services; @@ -14,7 +14,7 @@ int mux_rate; ///< set to 1 when VBR int pes_payload_size; int64_t total_size; -@@ -252,7 +254,7 @@ +@@ -256,7 +258,7 @@ int data_st_warning; int64_t pcr_period; /* PCR period in PCR time base */ @@ -23,7 +23,7 @@ /* For Opus */ int opus_queued_samples; -@@ -945,18 +947,18 @@ +@@ -949,18 +951,18 @@ return 0; } @@ -47,7 +47,7 @@ tp_extra_header = AV_RB32(&tp_extra_header); avio_write(s->pb, (unsigned char *) &tp_extra_header, sizeof(tp_extra_header)); -@@ -1042,9 +1044,6 @@ +@@ -1046,9 +1048,6 @@ else ts_st->pcr_period = 1; } @@ -57,7 +57,7 @@ } static void select_pcr_streams(AVFormatContext *s) -@@ -1107,6 +1106,7 @@ +@@ -1111,6 +1110,7 @@ if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = 0; @@ -65,7 +65,7 @@ // round up to a whole number of TS packets ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14; -@@ -1166,7 +1166,9 @@ +@@ -1170,7 +1170,9 @@ /* MPEG pid values < 16 are reserved. Applications which set st->id in * this range are assigned a calculated pid. */ if (st->id < 16) { @@ -76,7 +76,7 @@ switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: ts_st->pid = ts->m2ts_video_pid++; -@@ -1193,9 +1195,9 @@ +@@ -1197,9 +1199,9 @@ av_log(s, AV_LOG_ERROR, "Cannot automatically assign PID for stream %d\n", st->index); return AVERROR(EINVAL); } @@ -88,7 +88,7 @@ } else { ts_st->pid = st->id; } -@@ -1263,9 +1265,14 @@ +@@ -1267,9 +1269,14 @@ ts->last_pat_ts = AV_NOPTS_VALUE; ts->last_sdt_ts = AV_NOPTS_VALUE; ts->last_nit_ts = AV_NOPTS_VALUE; @@ -106,7 +106,7 @@ /* assign provider name */ provider = av_dict_get(s->metadata, "service_provider", NULL, 0); -@@ -1281,8 +1288,8 @@ +@@ -1285,8 +1292,8 @@ av_log(s, AV_LOG_VERBOSE, "muxrate %d, ", ts->mux_rate); av_log(s, AV_LOG_VERBOSE, "sdt every %"PRId64" ms, pat/pmt every %"PRId64" ms", @@ -117,7 +117,7 @@ if (ts->flags & MPEGTS_FLAG_NIT) av_log(s, AV_LOG_VERBOSE, ", nit every %"PRId64" ms", av_rescale(ts->nit_period, 1000, PCR_TIME_BASE)); av_log(s, AV_LOG_VERBOSE, "\n"); -@@ -1291,36 +1298,40 @@ +@@ -1295,36 +1302,40 @@ } /* send SDT, NIT, PAT and PMT tables regularly */ @@ -182,7 +182,7 @@ } } -@@ -1357,25 +1368,29 @@ +@@ -1361,25 +1372,29 @@ static void mpegts_insert_pcr_only(AVFormatContext *s, AVStream *st) { MpegTSWrite *ts = s->priv_data; @@ -218,7 +218,7 @@ /* stuffing bytes */ memset(q, 0xFF, TS_PACKET_SIZE - (q - buf)); -@@ -1475,9 +1490,9 @@ +@@ -1479,9 +1494,9 @@ int afc_len, stuffing_len; int is_dvb_subtitle = (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE); int is_dvb_teletext = (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT); @@ -229,7 +229,7 @@ int force_nit = 0; av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO); -@@ -1494,21 +1509,19 @@ +@@ -1498,21 +1513,19 @@ is_start = 1; while (payload_size > 0) { @@ -260,7 +260,7 @@ if (pcr >= ts->next_pcr) { int64_t next_pcr = INT64_MAX; for (int i = 0; i < s->nb_streams; i++) { -@@ -1518,36 +1531,43 @@ +@@ -1522,36 +1535,43 @@ AVStream *st2 = s->streams[st2_index]; MpegTSWriteStream *ts_st2 = st2->priv_data; if (ts_st2->pcr_period) { @@ -321,7 +321,7 @@ /* prepare packet header */ q = buf; *q++ = 0x47; -@@ -1576,7 +1596,6 @@ +@@ -1581,7 +1601,6 @@ if (write_pcr) { set_af_flag(buf, 0x10); q = get_ts_payload_start(buf); @@ -329,7 +329,7 @@ if (dts != AV_NOPTS_VALUE && dts < pcr / 300) av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n"); extend_af(buf, write_pcr_bits(q, pcr)); -@@ -1840,8 +1859,8 @@ +@@ -1845,8 +1864,8 @@ uint8_t *data = NULL; MpegTSWrite *ts = s->priv_data; MpegTSWriteStream *ts_st = st->priv_data; @@ -340,7 +340,7 @@ int64_t dts = pkt->dts, pts = pkt->pts; int opus_samples = 0; size_t side_data_size; -@@ -1861,9 +1880,9 @@ +@@ -1866,9 +1885,9 @@ if (ts->copyts < 1) { if (pts != AV_NOPTS_VALUE) @@ -352,7 +352,7 @@ } if (!ts_st->first_timestamp_checked && (pts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE)) { -@@ -2262,8 +2281,10 @@ +@@ -2299,8 +2318,10 @@ 0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_SERVICE_TYPE_HEVC_DIGITAL_HDTV }, 0x01, 0xff, ENC, "mpegts_service_type" }, { "mpegts_pmt_start_pid", "Set the first pid of the PMT.", OFFSET(pmt_start_pid), AV_OPT_TYPE_INT, { .i64 = 0x1000 }, FIRST_OTHER_PID, LAST_OTHER_PID, ENC }, @@ -364,7 +364,7 @@ { "mpegts_m2ts_mode", "Enable m2ts mode.", OFFSET(m2ts_mode), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, ENC }, { "muxrate", NULL, OFFSET(mux_rate), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC }, { "pes_payload_size", "Minimum PES packet payload in bytes", -@@ -2287,10 +2308,10 @@ +@@ -2326,10 +2347,10 @@ OFFSET(omit_video_pes_length), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, ENC }, { "pcr_period", "PCR retransmission time in milliseconds", OFFSET(pcr_period_ms), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, ENC }, @@ -392,16 +392,17 @@ +++ b/libavformat/bluray.c @@ -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; + --- a/doc/muxers.texi +++ b/doc/muxers.texi -@@ -1934,7 +1934,8 @@ +@@ -1930,7 +1930,8 @@ Maximum time in seconds between PAT/PMT tables. Default is @code{0.1}. @item sdt_period @var{duration} diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch3 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch3 index d553a807..7edb2e24 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch3 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch3 @@ -1,6 +1,6 @@ --- a/libavformat/avformat.h +++ b/libavformat/avformat.h -@@ -499,6 +499,9 @@ +@@ -497,6 +497,9 @@ The user or muxer can override this through AVFormatContext.avoid_negative_ts */ @@ -10,7 +10,7 @@ #define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */ -@@ -670,7 +673,8 @@ +@@ -560,7 +563,8 @@ /** * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, * AVFMT_NOTIMESTAMPS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, @@ -22,7 +22,7 @@ --- a/libavformat/dv.c +++ b/libavformat/dv.c -@@ -640,6 +640,7 @@ +@@ -672,6 +672,7 @@ const AVInputFormat ff_dv_demuxer = { .name = "dv", .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), @@ -32,7 +32,7 @@ .read_header = dv_read_header, --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c -@@ -4427,6 +4427,7 @@ +@@ -4432,6 +4432,7 @@ const AVInputFormat ff_webm_dash_manifest_demuxer = { .name = "webm_dash_manifest", .long_name = NULL_IF_CONFIG_SMALL("WebM DASH Manifest"), @@ -40,7 +40,7 @@ .priv_class = &webm_dash_class, .priv_data_size = sizeof(MatroskaDemuxContext), .flags_internal = FF_FMT_INIT_CLEANUP, -@@ -4439,6 +4440,7 @@ +@@ -4444,6 +4445,7 @@ const AVInputFormat ff_matroska_demuxer = { .name = "matroska,webm", .long_name = NULL_IF_CONFIG_SMALL("Matroska / WebM"), @@ -50,7 +50,7 @@ .flags_internal = FF_FMT_INIT_CLEANUP, --- a/libavformat/seek.c +++ b/libavformat/seek.c -@@ -600,6 +600,13 @@ +@@ -602,6 +602,13 @@ return seek_frame_byte(s, stream_index, timestamp, flags); } diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch4 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch4 index 722fe2d0..0cff0a5a 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch4 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch4 @@ -1,6 +1,6 @@ --- a/libavformat/avidec.c +++ b/libavformat/avidec.c -@@ -1995,6 +1995,7 @@ +@@ -2006,6 +2006,7 @@ .priv_data_size = sizeof(AVIContext), .flags_internal = FF_FMT_INIT_CLEANUP, .extensions = "avi", diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch8 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch8 index 1a9476c7..f2fc30d6 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch8 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch8 @@ -1,6 +1,6 @@ --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c -@@ -685,7 +685,7 @@ +@@ -634,7 +634,7 @@ if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) ff_mpeg4_frame_end(avctx, buf, buf_size); diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch9 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch9 index 40eb4f1a..99fa5480 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch9 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patch9 @@ -1,6 +1,6 @@ --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c -@@ -976,9 +976,9 @@ +@@ -977,9 +977,9 @@ PacketDesc *pkt_desc; while ((pkt_desc = stream->predecode_packet) && diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchC b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchC index bce5202e..e197e5fb 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchC +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchC @@ -1,16 +1,16 @@ --- a/libavcodec/encode.c +++ b/libavcodec/encode.c -@@ -191,7 +191,7 @@ +@@ -290,7 +290,7 @@ } if (!frame->buf[0]) { - if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY || + if (avci->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY || - (avci->frame_thread_encoder && avctx->active_thread_type & FF_THREAD_FRAME))) + avci->frame_thread_encoder)) return AVERROR_EOF; -@@ -243,8 +243,10 @@ - avpkt->flags |= avci->intra_only_flag; +@@ -309,8 +309,10 @@ + ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet); } - if (avci->draining && !got_packet) @@ -19,9 +19,9 @@ avci->draining_done = 1; + } - end: - if (ret < 0 || !got_packet) -@@ -365,10 +367,16 @@ + return ret; + } +@@ -491,10 +493,16 @@ if (avci->draining) return AVERROR_EOF; diff --git a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchZ1 b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchZ1 index e6f708da..29cfb628 100644 --- a/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchZ1 +++ b/cinelerra-5.1/thirdparty/src/ffmpeg.git.patchZ1 @@ -39,17 +39,11 @@ static void wrapped_avframe_release_buffer(void *unused, uint8_t *data) { AVFrame *frame = (AVFrame *)data; -@@ -109,6 +141,7 @@ +@@ -111,6 +143,7 @@ .p.id = AV_CODEC_ID_WRAPPED_AVFRAME, + .p.capabilities = AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, FF_CODEC_ENCODE_CB(wrapped_avframe_encode), - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .p.pix_fmts = pix_fmts_all, }; const FFCodec ff_wrapped_avframe_decoder = { -@@ -118,4 +151,5 @@ - .p.id = AV_CODEC_ID_WRAPPED_AVFRAME, - FF_CODEC_DECODE_CB(wrapped_avframe_decode), - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, -+ - }; -- 2.26.2