--- /dev/null
+--- a/libavformat/mpegts.c
++++ b/libavformat/mpegts.c
+@@ -1014,10 +1014,12 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt)
+ pes->buffer = NULL;
+ reset_pes_packet_state(pes);
+
++ /*
+ sd = av_packet_new_side_data(pkt, AV_PKT_DATA_MPEGTS_STREAM_ID, 1);
+ if (!sd)
+ return AVERROR(ENOMEM);
+ *sd = pes->stream_id;
++ */
+
+ return 0;
+ }
--- /dev/null
+--- a/configure
++++ b/configure
+@@ -3353,10 +3353,8 @@ xv_outdev_deps="xlib"
+ # protocols
+ async_protocol_deps="threads"
+ bluray_protocol_deps="libbluray"
+-ffrtmpcrypt_protocol_conflict="librtmp_protocol"
+ ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
+ ffrtmpcrypt_protocol_select="tcp_protocol"
+-ffrtmphttp_protocol_conflict="librtmp_protocol"
+ ffrtmphttp_protocol_select="http_protocol"
+ ftp_protocol_select="tcp_protocol"
+ gopher_protocol_select="network"
+@@ -3369,20 +3367,18 @@ https_protocol_suggest="zlib"
+ icecast_protocol_select="http_protocol"
+ mmsh_protocol_select="http_protocol"
+ mmst_protocol_select="network"
+-rtmp_protocol_conflict="librtmp_protocol"
+-rtmp_protocol_select="tcp_protocol"
+-rtmp_protocol_suggest="zlib"
+-rtmpe_protocol_select="ffrtmpcrypt_protocol"
+-rtmpe_protocol_suggest="zlib"
+-rtmps_protocol_conflict="librtmp_protocol"
+-rtmps_protocol_select="tls_protocol"
+-rtmps_protocol_suggest="zlib"
+-rtmpt_protocol_select="ffrtmphttp_protocol"
+-rtmpt_protocol_suggest="zlib"
+-rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
+-rtmpte_protocol_suggest="zlib"
+-rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
+-rtmpts_protocol_suggest="zlib"
++ffrtmp_protocol_select="tcp_protocol"
++ffrtmp_protocol_suggest="zlib"
++ffrtmpe_protocol_select="ffrtmpcrypt_protocol"
++ffrtmpe_protocol_suggest="zlib"
++ffrtmps_protocol_select="tls_protocol"
++ffrtmps_protocol_suggest="zlib"
++ffrtmpt_protocol_select="ffrtmphttp_protocol"
++ffrtmpt_protocol_suggest="zlib"
++ffrtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
++ffrtmpte_protocol_suggest="zlib"
++ffrtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
++ffrtmpts_protocol_suggest="zlib"
+ rtp_protocol_select="udp_protocol"
+ schannel_conflict="openssl gnutls libtls mbedtls"
+ sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
+--- a/libavformat/Makefile
++++ b/libavformat/Makefile
+@@ -599,12 +599,12 @@ OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o
+ OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o
+ OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
+ OBJS-$(CONFIG_PROMPEG_PROTOCOL) += prompeg.o
+-OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
+-OBJS-$(CONFIG_RTMPE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
+-OBJS-$(CONFIG_RTMPS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
+-OBJS-$(CONFIG_RTMPT_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
+-OBJS-$(CONFIG_RTMPTE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
+-OBJS-$(CONFIG_RTMPTS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
++OBJS-$(CONFIG_FFRTMP_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
++OBJS-$(CONFIG_FFRTMPE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
++OBJS-$(CONFIG_FFRTMPS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
++OBJS-$(CONFIG_FFRTMPT_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
++OBJS-$(CONFIG_FFRTMPTE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
++OBJS-$(CONFIG_FFRTMPTS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
+ OBJS-$(CONFIG_RTP_PROTOCOL) += rtpproto.o ip.o
+ OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
+ OBJS-$(CONFIG_SRTP_PROTOCOL) += srtpproto.o srtp.o
+--- a/libavformat/protocols.c
++++ b/libavformat/protocols.c
+@@ -44,12 +44,12 @@ extern const URLProtocol ff_mmst_protocol;
+ extern const URLProtocol ff_md5_protocol;
+ extern const URLProtocol ff_pipe_protocol;
+ extern const URLProtocol ff_prompeg_protocol;
+-extern const URLProtocol ff_rtmp_protocol;
+-extern const URLProtocol ff_rtmpe_protocol;
+-extern const URLProtocol ff_rtmps_protocol;
+-extern const URLProtocol ff_rtmpt_protocol;
+-extern const URLProtocol ff_rtmpte_protocol;
+-extern const URLProtocol ff_rtmpts_protocol;
++extern const URLProtocol ff_ffrtmp_protocol;
++extern const URLProtocol ff_ffrtmpe_protocol;
++extern const URLProtocol ff_ffrtmps_protocol;
++extern const URLProtocol ff_ffrtmpt_protocol;
++extern const URLProtocol ff_ffrtmpte_protocol;
++extern const URLProtocol ff_ffrtmpts_protocol;
+ extern const URLProtocol ff_rtp_protocol;
+ extern const URLProtocol ff_sctp_protocol;
+ extern const URLProtocol ff_srtp_protocol;
+--- a/libavformat/rtmpproto.c
++++ b/libavformat/rtmpproto.c
+@@ -2592,7 +2592,7 @@ static int inject_fake_duration_metadata(RTMPContext *rt)
+ static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **opts)
+ {
+ RTMPContext *rt = s->priv_data;
+- char proto[8], hostname[256], path[1024], auth[100], *fname;
++ char *proto, tmpProto[10], hostname[256], path[1024], auth[100], *fname;
+ char *old_app, *qmark, *n, fname_buffer[1024];
+ uint8_t buf[2048];
+ int port;
+@@ -2603,7 +2603,9 @@ static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **o
+
+ rt->is_input = !(flags & AVIO_FLAG_WRITE);
+
+- av_url_split(proto, sizeof(proto), auth, sizeof(auth),
++ memset(tmpProto, 0, sizeof(tmpProto));
++ proto = &tmpProto[2];
++ av_url_split(tmpProto, sizeof(tmpProto), auth, sizeof(auth),
+ hostname, sizeof(hostname), &port,
+ path, sizeof(path), s->filename);
+
+@@ -3137,9 +3139,9 @@ const URLProtocol ff_##flavor##_protocol = { \
+ };
+
+
+-RTMP_PROTOCOL(rtmp)
+-RTMP_PROTOCOL(rtmpe)
+-RTMP_PROTOCOL(rtmps)
+-RTMP_PROTOCOL(rtmpt)
+-RTMP_PROTOCOL(rtmpte)
+-RTMP_PROTOCOL(rtmpts)
++RTMP_PROTOCOL(ffrtmp)
++RTMP_PROTOCOL(ffrtmpe)
++RTMP_PROTOCOL(ffrtmps)
++RTMP_PROTOCOL(ffrtmpt)
++RTMP_PROTOCOL(ffrtmpte)
++RTMP_PROTOCOL(ffrtmpts)
--- /dev/null
+--- a/libavformat/hls.c
++++ b/libavformat/hls.c
+@@ -207,6 +207,8 @@ typedef struct HLSContext {
+ int max_reload;
+ int http_persistent;
+ int http_multiple;
++ char *key_uri_replace_old;
++ char *key_uri_replace_new;
+ AVIOContext *playlist_pb;
+ } HLSContext;
+
+@@ -1205,8 +1207,16 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
+ } else if (seg->key_type == KEY_AES_128) {
+ char iv[33], key[33], url[MAX_URL_SIZE];
+ if (strcmp(seg->key, pls->key_url)) {
++ char *key_url = NULL;
+ AVIOContext *pb = NULL;
+- if (open_url(pls->parent, &pb, seg->key, c->avio_opts, opts, NULL) == 0) {
++ if (NULL != c->key_uri_replace_old && \
++ NULL != c-> key_uri_replace_new && \
++ '\0' != c->key_uri_replace_old[0]) {
++ key_url = av_strireplace(seg->key, c->key_uri_replace_old, c->key_uri_replace_new);
++ } else {
++ key_url = seg->key;
++ }
++ if (open_url(pls->parent, &pb, key_url, c->avio_opts, opts, NULL) == 0) {
+ ret = avio_read(pb, pls->key, sizeof(pls->key));
+ if (ret != sizeof(pls->key)) {
+ av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n",
+@@ -1218,6 +1228,8 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
+ seg->key);
+ }
+ av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
++ if (key_url != seg->key)
++ av_free(key_url);
+ }
+ ff_data_to_hex(iv, seg->iv, sizeof(seg->iv), 0);
+ ff_data_to_hex(key, pls->key, sizeof(pls->key), 0);
+@@ -2319,6 +2331,8 @@ static const AVOption hls_options[] = {
+ OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
+ {"http_multiple", "Use multiple HTTP connections for fetching segments",
+ OFFSET(http_multiple), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, FLAGS},
++ { "key_uri_old", "allow to replace part of AES key uri - old", OFFSET(key_uri_replace_old), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, FLAGS },
++ { "key_uri_new", "allow to replace part of AES key uri - new", OFFSET(key_uri_replace_new), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, FLAGS },
+ {NULL}
+ };
+
--- /dev/null
+--- a/libavcodec/aacdec_template.c
++++ b/libavcodec/aacdec_template.c
+@@ -2482,7 +2482,7 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
+ * @param decode 1 if tool is used normally, 0 if tool is used in LTP.
+ * @param coef spectral coefficients
+ */
+-static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
++static __attribute__((optimize(0))) void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
+ IndividualChannelStream *ics, int decode)
+ {
+ const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
+--- a/libavcodec/aacps.c
++++ b/libavcodec/aacps.c
+@@ -659,7 +659,7 @@ static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC])
+ par[ 1] = AAC_HALF_SUM(par[ 0], par[ 1]);
+ }
+
+-static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34)
++static void __attribute__((optimize(0))) decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34)
+ {
+ LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]);
+ LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
+--- a/libavcodec/fft_template.c
++++ b/libavcodec/fft_template.c
+@@ -562,7 +562,7 @@ static void fft##n(FFTComplex *z)\
+ pass(z,FFT_NAME(ff_cos_##n),n4/2);\
+ }
+
+-static void fft4(FFTComplex *z)
++static void __attribute__((optimize(0))) fft4(FFTComplex *z)
+ {
+ FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
+
+@@ -576,7 +576,7 @@ static void fft4(FFTComplex *z)
+ BF(z[2].im, z[0].im, t2, t5);
+ }
+
+-static void fft8(FFTComplex *z)
++static void __attribute__((optimize(0))) fft8(FFTComplex *z)
+ {
+ FFTDouble t1, t2, t3, t4, t5, t6;
+
+--- a/libavcodec/mdct_template.c
++++ b/libavcodec/mdct_template.c
+@@ -102,7 +102,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
+ * @param output N/2 samples
+ * @param input N/2 samples
+ */
+-void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
++void __attribute__((optimize(0))) ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
+ {
+ int k, n8, n4, n2, n, j;
+ const uint16_t *revtab = s->revtab;
--- /dev/null
+--- a/libavformat/avio.h
++++ b/libavformat/avio.h
+@@ -290,13 +290,6 @@ typedef struct AVIOContext {
+ */
+ int writeout_count;
+
+- /**
+- * Original buffer size
+- * used internally after probing and ensure seekback to reset the buffer size
+- * This field is internal to libavformat and access from outside is not allowed.
+- */
+- int orig_buffer_size;
+-
+ /**
+ * Threshold to favor readahead over seek.
+ * This is current internal only, do not use from outside.
+--- a/libavformat/aviobuf.c
++++ b/libavformat/aviobuf.c
+@@ -33,7 +33,7 @@
+ #include "url.h"
+ #include <stdarg.h>
+
+-#define IO_BUFFER_SIZE 32768
++#define IO_BUFFER_SIZE 262144
+
+ /**
+ * Do seeks within this distance ahead of the current buffer by skipping
+@@ -90,7 +90,6 @@ int ffio_init_context(AVIOContext *s,
+ memset(s, 0, sizeof(AVIOContext));
+
+ s->buffer = buffer;
+- s->orig_buffer_size =
+ s->buffer_size = buffer_size;
+ s->buf_ptr = buffer;
+ s->buf_ptr_max = buffer;
+@@ -570,15 +569,16 @@ static void fill_buffer(AVIOContext *s)
+ }
+
+ /* make buffer smaller in case it ended up large after probing */
+- if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size && len >= s->orig_buffer_size) {
++ if (s->read_packet && s->buffer_size > max_buffer_size) {
+ if (dst == s->buffer && s->buf_ptr != dst) {
+- int ret = ffio_set_buf_size(s, s->orig_buffer_size);
++ int ret = ffio_set_buf_size(s, max_buffer_size);
+ if (ret < 0)
+ av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n");
+
+ s->checksum_ptr = dst = s->buffer;
+ }
+- len = s->orig_buffer_size;
++ av_assert0(len >= max_buffer_size);
++ len = max_buffer_size;
+ }
+
+ len = read_packet_wrapper(s, dst, len);
+@@ -1086,7 +1086,6 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
+
+ av_free(s->buffer);
+ s->buffer = buffer;
+- s->orig_buffer_size =
+ s->buffer_size = buf_size;
+ s->buf_ptr = s->buf_ptr_max = buffer;
+ url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);
+--- a/libavformat/utils.c
++++ b/libavformat/utils.c
+@@ -138,6 +138,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
+ #endif
+ #endif
+
++void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
++{
++ if (min_size < *size)
++ return ptr;
++
++ min_size = FFMAX(17 * min_size / 16 + 32, min_size);
++
++ ptr = av_realloc(ptr, min_size);
++ /* we could set this to the unmodified min_size but this is safer
++ * if the user lost the ptr and uses NULL now
++ */
++ if (!ptr)
++ min_size = 0;
++
++ *size = min_size;
++
++ return ptr;
++}
++
+ int64_t av_stream_get_end_pts(const AVStream *st)
+ {
+ if (st->internal->priv_pts) {
--- /dev/null
+--- a/libavformat/hls.c
++++ b/libavformat/hls.c
+@@ -2074,8 +2074,10 @@
+ HLSContext *c = s->priv_data;
+ int ret, i, minplaylist = -1;
+
+- recheck_discard_flags(s, c->first_packet);
+- c->first_packet = 0;
++ if (c->first_packet) {
++ recheck_discard_flags(s, 1);
++ c->first_packet = 0;
++ }
+
+ for (i = 0; i < c->n_playlists; i++) {
+ struct playlist *pls = c->playlists[i];
--- /dev/null
+--- a/libavformat/mov.c
++++ b/libavformat/mov.c
+@@ -3558,8 +3558,10 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
+
+ if (ctts_data_old && ctts_index_old < ctts_count_old) {
+ curr_ctts = ctts_data_old[ctts_index_old].duration;
++ /*
+ av_log(mov->fc, AV_LOG_DEBUG, "stts: %"PRId64" ctts: %"PRId64", ctts_index: %"PRId64", ctts_count: %"PRId64"\n",
+ curr_cts, curr_ctts, ctts_index_old, ctts_count_old);
++ */
+ curr_cts += curr_ctts;
+ ctts_sample_old++;
+ if (ctts_sample_old == ctts_data_old[ctts_index_old].count) {
+++ /dev/null
---- a/libavcodec/amfenc.c
-+++ b/libavcodec/amfenc.c
-@@ -680,6 +680,52 @@ int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame)
- break;
- }
-
-+ // Override Picture Type for Frame
-+ if (avctx->codec->id == AV_CODEC_ID_H264) {
-+ switch (frame->pict_type) {
-+ case AV_PICTURE_TYPE_I:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_I);
-+ break;
-+ case AV_PICTURE_TYPE_P:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_P);
-+ break;
-+ case AV_PICTURE_TYPE_B:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_B);
-+ break;
-+ case AV_PICTURE_TYPE_S:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_SKIP);
-+ break;
-+ default:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_NONE);
-+ break;
-+ }
-+ // Keyframe overrides previous assignment.
-+ if (frame->key_frame) {
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_IDR);
-+ }
-+ } else if (avctx->codec->id == AV_CODEC_ID_HEVC) {
-+ switch (frame->pict_type) {
-+ case AV_PICTURE_TYPE_I:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_I);
-+ break;
-+ case AV_PICTURE_TYPE_P:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_P);
-+ break;
-+ case AV_PICTURE_TYPE_B:
-+ av_log(ctx, AV_LOG_WARNING, "Ignoring B-Frame, unsupported by AMD AMF H.265 Encoder.");
-+ break;
-+ case AV_PICTURE_TYPE_S:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_SKIP);
-+ break;
-+ default:
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE);
-+ break;
-+ }
-+ // Keyframe overrides previous assignment.
-+ if (frame->key_frame) {
-+ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_IDR);
-+ }
-+ }
-
- // submit surface
- res = ctx->encoder->pVtbl->SubmitInput(ctx->encoder, (AMFData*)surface);
+++ /dev/null
---- a/configure
-+++ b/configure
-@@ -3291,10 +3291,8 @@
- # protocols
- async_protocol_deps="threads"
- bluray_protocol_deps="libbluray"
--ffrtmpcrypt_protocol_conflict="librtmp_protocol"
- ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
- ffrtmpcrypt_protocol_select="tcp_protocol"
--ffrtmphttp_protocol_conflict="librtmp_protocol"
- ffrtmphttp_protocol_select="http_protocol"
- ftp_protocol_select="tcp_protocol"
- gopher_protocol_select="network"
-@@ -3307,20 +3305,18 @@
- icecast_protocol_select="http_protocol"
- mmsh_protocol_select="http_protocol"
- mmst_protocol_select="network"
--rtmp_protocol_conflict="librtmp_protocol"
--rtmp_protocol_select="tcp_protocol"
--rtmp_protocol_suggest="zlib"
--rtmpe_protocol_select="ffrtmpcrypt_protocol"
--rtmpe_protocol_suggest="zlib"
--rtmps_protocol_conflict="librtmp_protocol"
--rtmps_protocol_select="tls_protocol"
--rtmps_protocol_suggest="zlib"
--rtmpt_protocol_select="ffrtmphttp_protocol"
--rtmpt_protocol_suggest="zlib"
--rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
--rtmpte_protocol_suggest="zlib"
--rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
--rtmpts_protocol_suggest="zlib"
-+ffrtmp_protocol_select="tcp_protocol"
-+ffrtmp_protocol_suggest="zlib"
-+ffrtmpe_protocol_select="ffrtmpcrypt_protocol"
-+ffrtmpe_protocol_suggest="zlib"
-+ffrtmps_protocol_select="tls_protocol"
-+ffrtmps_protocol_suggest="zlib"
-+ffrtmpt_protocol_select="ffrtmphttp_protocol"
-+ffrtmpt_protocol_suggest="zlib"
-+ffrtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
-+ffrtmpte_protocol_suggest="zlib"
-+ffrtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
-+ffrtmpts_protocol_suggest="zlib"
- rtp_protocol_select="udp_protocol"
- schannel_conflict="openssl gnutls libtls mbedtls"
- sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
---- a/libavformat/Makefile
-+++ b/libavformat/Makefile
-@@ -593,12 +593,12 @@
- OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o
- OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
- OBJS-$(CONFIG_PROMPEG_PROTOCOL) += prompeg.o
--OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
--OBJS-$(CONFIG_RTMPE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
--OBJS-$(CONFIG_RTMPS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
--OBJS-$(CONFIG_RTMPT_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
--OBJS-$(CONFIG_RTMPTE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
--OBJS-$(CONFIG_RTMPTS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
-+OBJS-$(CONFIG_FFRTMP_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
-+OBJS-$(CONFIG_FFRTMPE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
-+OBJS-$(CONFIG_FFRTMPS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
-+OBJS-$(CONFIG_FFRTMPT_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
-+OBJS-$(CONFIG_FFRTMPTE_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
-+OBJS-$(CONFIG_FFRTMPTS_PROTOCOL) += rtmpproto.o rtmpdigest.o rtmppkt.o
- OBJS-$(CONFIG_RTP_PROTOCOL) += rtpproto.o ip.o
- OBJS-$(CONFIG_SCTP_PROTOCOL) += sctp.o
- OBJS-$(CONFIG_SRTP_PROTOCOL) += srtpproto.o srtp.o
---- a/libavformat/protocols.c
-+++ b/libavformat/protocols.c
-@@ -44,12 +44,12 @@
- extern const URLProtocol ff_md5_protocol;
- extern const URLProtocol ff_pipe_protocol;
- extern const URLProtocol ff_prompeg_protocol;
--extern const URLProtocol ff_rtmp_protocol;
--extern const URLProtocol ff_rtmpe_protocol;
--extern const URLProtocol ff_rtmps_protocol;
--extern const URLProtocol ff_rtmpt_protocol;
--extern const URLProtocol ff_rtmpte_protocol;
--extern const URLProtocol ff_rtmpts_protocol;
-+extern const URLProtocol ff_ffrtmp_protocol;
-+extern const URLProtocol ff_ffrtmpe_protocol;
-+extern const URLProtocol ff_ffrtmps_protocol;
-+extern const URLProtocol ff_ffrtmpt_protocol;
-+extern const URLProtocol ff_ffrtmpte_protocol;
-+extern const URLProtocol ff_ffrtmpts_protocol;
- extern const URLProtocol ff_rtp_protocol;
- extern const URLProtocol ff_sctp_protocol;
- extern const URLProtocol ff_srtp_protocol;
---- a/libavformat/rtmpproto.c
-+++ b/libavformat/rtmpproto.c
-@@ -2592,7 +2592,7 @@
- static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **opts)
- {
- RTMPContext *rt = s->priv_data;
-- char proto[8], hostname[256], path[1024], auth[100], *fname;
-+ char *proto, tmpProto[10], hostname[256], path[1024], auth[100], *fname;
- char *old_app, *qmark, *n, fname_buffer[1024];
- uint8_t buf[2048];
- int port;
-@@ -2603,7 +2603,9 @@
-
- rt->is_input = !(flags & AVIO_FLAG_WRITE);
-
-- av_url_split(proto, sizeof(proto), auth, sizeof(auth),
-+ memset(tmpProto, 0, sizeof(tmpProto));
-+ proto = &tmpProto[2];
-+ av_url_split(tmpProto, sizeof(tmpProto), auth, sizeof(auth),
- hostname, sizeof(hostname), &port,
- path, sizeof(path), s->filename);
-
-@@ -3137,9 +3139,9 @@
- };
-
-
--RTMP_PROTOCOL(rtmp)
--RTMP_PROTOCOL(rtmpe)
--RTMP_PROTOCOL(rtmps)
--RTMP_PROTOCOL(rtmpt)
--RTMP_PROTOCOL(rtmpte)
--RTMP_PROTOCOL(rtmpts)
-+RTMP_PROTOCOL(ffrtmp)
-+RTMP_PROTOCOL(ffrtmpe)
-+RTMP_PROTOCOL(ffrtmps)
-+RTMP_PROTOCOL(ffrtmpt)
-+RTMP_PROTOCOL(ffrtmpte)
-+RTMP_PROTOCOL(ffrtmpts)
+++ /dev/null
---- a/libavcodec/h264_slice.c
-+++ b/libavcodec/h264_slice.c
-@@ -1463,6 +1463,11 @@
- h->avctx->has_b_frames = sps->num_reorder_frames;
- }
-
-+ if (sps && sps->bitstream_restriction_flag &&
-+ h->avctx->has_b_frames < sps->num_reorder_frames) {
-+ h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, sps->num_reorder_frames);
-+ }
-+
- last_pic_droppable = h->droppable;
- last_pic_structure = h->picture_structure;
- h->droppable = (nal->ref_idc == 0);
+++ /dev/null
---- a/libavformat/mov.c
-+++ b/libavformat/mov.c
-@@ -3558,8 +3558,10 @@
-
- if (ctts_data_old && ctts_index_old < ctts_count_old) {
- curr_ctts = ctts_data_old[ctts_index_old].duration;
-+ /*
- av_log(mov->fc, AV_LOG_DEBUG, "stts: %"PRId64" ctts: %"PRId64", ctts_index: %"PRId64", ctts_count: %"PRId64"\n",
- curr_cts, curr_ctts, ctts_index_old, ctts_count_old);
-+ */
- curr_cts += curr_ctts;
- ctts_sample_old++;
- if (ctts_sample_old == ctts_data_old[ctts_index_old].count) {
+++ /dev/null
---- a/libavformat/hls.c
-+++ b/libavformat/hls.c
-@@ -2062,8 +2062,10 @@
- HLSContext *c = s->priv_data;
- int ret, i, minplaylist = -1;
-
-- recheck_discard_flags(s, c->first_packet);
-- c->first_packet = 0;
-+ if (c->first_packet) {
-+ recheck_discard_flags(s, 1);
-+ c->first_packet = 0;
-+ }
-
- for (i = 0; i < c->n_playlists; i++) {
- struct playlist *pls = c->playlists[i];
+++ /dev/null
---- a/libavformat/mpegts.c
-+++ b/libavformat/mpegts.c
-@@ -948,10 +948,12 @@
- pes->buffer = NULL;
- reset_pes_packet_state(pes);
-
-+ /*
- sd = av_packet_new_side_data(pkt, AV_PKT_DATA_MPEGTS_STREAM_ID, 1);
- if (!sd)
- return AVERROR(ENOMEM);
- *sd = pes->stream_id;
-+ */
-
- return 0;
- }
+++ /dev/null
---- a/libavformat/hls.c
-+++ b/libavformat/hls.c
-@@ -208,6 +208,8 @@
- int max_reload;
- int http_persistent;
- int http_multiple;
-+ char *key_uri_replace_old;
-+ char *key_uri_replace_new;
- AVIOContext *playlist_pb;
- } HLSContext;
-
-@@ -1198,8 +1200,16 @@
- } else if (seg->key_type == KEY_AES_128) {
- char iv[33], key[33], url[MAX_URL_SIZE];
- if (strcmp(seg->key, pls->key_url)) {
-+ char *key_url = NULL;
- AVIOContext *pb = NULL;
-- if (open_url(pls->parent, &pb, seg->key, c->avio_opts, opts, NULL) == 0) {
-+ if (NULL != c->key_uri_replace_old && \
-+ NULL != c-> key_uri_replace_new && \
-+ '\0' != c->key_uri_replace_old[0]) {
-+ key_url = av_strireplace(seg->key, c->key_uri_replace_old, c->key_uri_replace_new);
-+ } else {
-+ key_url = seg->key;
-+ }
-+ if (open_url(pls->parent, &pb, key_url, c->avio_opts, opts, NULL) == 0) {
- ret = avio_read(pb, pls->key, sizeof(pls->key));
- if (ret != sizeof(pls->key)) {
- av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
-@@ -1211,6 +1221,8 @@
- seg->key);
- }
- av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
-+ if (key_url != seg->key)
-+ av_free(key_url);
- }
- ff_data_to_hex(iv, seg->iv, sizeof(seg->iv), 0);
- ff_data_to_hex(key, pls->key, sizeof(pls->key), 0);
-@@ -2315,6 +2327,8 @@
- OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
- {"http_multiple", "Use multiple HTTP connections for fetching segments",
- OFFSET(http_multiple), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, FLAGS},
-+ { "key_uri_old", "allow to replace part of AES key uri - old", OFFSET(key_uri_replace_old), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, FLAGS },
-+ { "key_uri_new", "allow to replace part of AES key uri - new", OFFSET(key_uri_replace_new), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, FLAGS },
- {NULL}
- };
-
+++ /dev/null
---- a/libavformat/avio.h
-+++ b/libavformat/avio.h
-@@ -290,12 +290,6 @@ typedef struct AVIOContext {
- */
- int writeout_count;
-
-- /**
-- * Original buffer size
-- * used internally after probing and ensure seekback to reset the buffer size
-- * This field is internal to libavformat and access from outside is not allowed.
-- */
-- int orig_buffer_size;
-
- /**
- * Threshold to favor readahead over seek.
---- a/libavformat/aviobuf.c
-+++ b/libavformat/aviobuf.c
-@@ -33,7 +33,7 @@
- #include "url.h"
- #include <stdarg.h>
-
--#define IO_BUFFER_SIZE 32768
-+#define IO_BUFFER_SIZE 262144
-
- /**
- * Do seeks within this distance ahead of the current buffer by skipping
-@@ -90,7 +90,6 @@ int ffio_init_context(AVIOContext *s,
- memset(s, 0, sizeof(AVIOContext));
-
- s->buffer = buffer;
-- s->orig_buffer_size =
- s->buffer_size = buffer_size;
- s->buf_ptr = buffer;
- s->buf_ptr_max = buffer;
-@@ -570,16 +569,16 @@ static void fill_buffer(AVIOContext *s)
- }
-
- /* make buffer smaller in case it ended up large after probing */
-- if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) {
-+ if (s->read_packet && s->buffer_size > max_buffer_size) {
- if (dst == s->buffer && s->buf_ptr != dst) {
-- int ret = ffio_set_buf_size(s, s->orig_buffer_size);
-+ int ret = ffio_set_buf_size(s, max_buffer_size);
- if (ret < 0)
- av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n");
-
- s->checksum_ptr = dst = s->buffer;
- }
-- av_assert0(len >= s->orig_buffer_size);
-- len = s->orig_buffer_size;
-+ av_assert0(len >= max_buffer_size);
-+ len = max_buffer_size;
- }
-
- len = read_packet_wrapper(s, dst, len);
-@@ -1087,7 +1086,6 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size)
-
- av_free(s->buffer);
- s->buffer = buffer;
-- s->orig_buffer_size =
- s->buffer_size = buf_size;
- s->buf_ptr = s->buf_ptr_max = buffer;
- url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);
---- a/libavformat/utils.c
-+++ b/libavformat/utils.c
-@@ -138,6 +138,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
- #endif
- #endif
-
-+void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
-+{
-+ if (min_size < *size)
-+ return ptr;
-+
-+ min_size = FFMAX(17 * min_size / 16 + 32, min_size);
-+
-+ ptr = av_realloc(ptr, min_size);
-+ /* we could set this to the unmodified min_size but this is safer
-+ * if the user lost the ptr and uses NULL now
-+ */
-+ if (!ptr)
-+ min_size = 0;
-+
-+ *size = min_size;
-+
-+ return ptr;
-+}
-+
- int64_t av_stream_get_end_pts(const AVStream *st)
- {
- if (st->internal->priv_pts) {
+++ /dev/null
---- a/libavcodec/mpegvideo.c
-+++ b/libavcodec/mpegvideo.c
-@@ -538,6 +538,8 @@
- s->avctx->width = s1->avctx->width;
- s->avctx->height = s1->avctx->height;
-
-+ s->quarter_sample = s1->quarter_sample;
-+
- s->coded_picture_number = s1->coded_picture_number;
- s->picture_number = s1->picture_number;
+++ /dev/null
---- a/libavcodec/mdct_template.c
-+++ b/libavcodec/mdct_template.c
-@@ -102,7 +102,7 @@ av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
- * @param output N/2 samples
- * @param input N/2 samples
- */
--void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
-+void __attribute__((optimize(0))) ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
- {
- int k, n8, n4, n2, n, j;
- const uint16_t *revtab = s->revtab;
---- a/libavcodec/aacps.c
-+++ b/libavcodec/aacps.c
-@@ -659,7 +659,7 @@
- par[ 1] = AAC_HALF_SUM(par[ 0], par[ 1]);
- }
-
--static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34)
-+static void __attribute__((optimize(0))) decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34)
- {
- LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]);
- LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
---- a/libavcodec/fft_template.c
-+++ b/libavcodec/fft_template.c
-@@ -538,7 +538,7 @@
- pass(z,FFT_NAME(ff_cos_##n),n4/2);\
- }
-
--static void fft4(FFTComplex *z)
-+static void __attribute__((optimize(0))) fft4(FFTComplex *z)
- {
- FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
-
-@@ -552,7 +552,7 @@
- BF(z[2].im, z[0].im, t2, t5);
- }
-
--static void fft8(FFTComplex *z)
-+static void __attribute__((optimize(0))) fft8(FFTComplex *z)
- {
- FFTDouble t1, t2, t3, t4, t5, t6;
-
---- a/libavcodec/aacdec_template.c
-+++ b/libavcodec/aacdec_template.c
-@@ -2483,7 +2483,7 @@
- * @param decode 1 if tool is used normally, 0 if tool is used in LTP.
- * @param coef spectral coefficients
- */
--static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
-+static __attribute__((optimize(0))) void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
- IndividualChannelStream *ics, int decode)
- {
- const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
--- /dev/null
+It will add -mips64r6 and -mips64r2 to cmdline which will
+cause conflicts
+
+in OE we user mips32r2 and mips64r2 for mips arch versions
+so there is no benefit of detecting it automatically by
+poking at tools especially in cross env
+
+Fixes errors like
+
+linking -mnan=2008 module with previous -mnan=legacy modules
+failed to merge target specific data of file
+
+-Khem
+Upstream-Status: Inappropriate [OE-Specific]
+
+--- a/configure
++++ b/configure
+@@ -5758,12 +5758,9 @@ elif enabled mips; then
+
+ # Enable minimum ISA based on selected options
+ if enabled mips64; then
+- enabled mips64r6 && check_inline_asm_flags mips64r6 '"dlsa $0, $0, $0, 1"' '-mips64r6'
+ enabled mips64r2 && check_inline_asm_flags mips64r2 '"dext $0, $0, 0, 1"' '-mips64r2'
+ disabled mips64r6 && disabled mips64r2 && check_inline_asm_flags mips64r1 '"daddi $0, $0, 0"' '-mips64'
+ else
+- enabled mips32r6 && check_inline_asm_flags mips32r6 '"aui $0, $0, 0"' '-mips32r6'
+- enabled mips32r5 && check_inline_asm_flags mips32r5 '"eretnc"' '-mips32r5'
+ enabled mips32r2 && check_inline_asm_flags mips32r2 '"ext $0, $0, 0, 1"' '-mips32r2'
+ disabled mips32r6 && disabled mips32r5 && disabled mips32r2 && check_inline_asm_flags mips32r1 '"addi $0, $0, 0"' '-mips32'
+ fi
endif
#
-# ffmpeg_patches
+# ffmpeg_patch
#
-FFMPEG_PATCHES = \
- ffmpeg-$(FFMPEG_VER)-fix_hls.patch \
- ffmpeg-$(FFMPEG_VER)-increase_buffer_size.patch \
- ffmpeg-$(FFMPEG_VER)-optimize_aac.patch \
- ffmpeg-$(FFMPEG_VER)-fix_edit_list_parsing.patch \
- ffmpeg-$(FFMPEG_VER)-fix_mpegts.patch \
- ffmpeg-$(FFMPEG_VER)-allow_to_choose_rtmp_impl_at_runtime.patch \
- ffmpeg-$(FFMPEG_VER)-hls_replace_key_uri.patch \
- ffmpeg-$(FFMPEG_VER)-corrupt-h264-frames.patch \
- ffmpeg-$(FFMPEG_VER)-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch \
- ffmpeg-$(FFMPEG_VER)-mpeg-quarter-sample.patch
+FFMPEG_PATCH = ffmpeg-02-fix_mpegts.patch
+FFMPEG_PATCH += ffmpeg-03-allow_to_choose_rtmp_impl_at_runtime.patch
+FFMPEG_PATCH += ffmpeg-04-hls_replace_key_uri.patch
+FFMPEG_PATCH += ffmpeg-06-optimize_aac.patch
+FFMPEG_PATCH += ffmpeg-07-increase_buffer_size.patch
+FFMPEG_PATCH += ffmpeg-08-recheck_discard_flags.patch
+FFMPEG_PATCH += ffmpeg-09-fix_edit_list_parsing.patch
+FFMPEG_PATCH += ffmpeg-mips64_cpu_detection.patch
ffmpeg-armbox: $(ARCHIVE)/ffmpeg-$(FFMPEG_VER).tar.xz | $(TARGETPREFIX)
$(START_BUILD)
$(REMOVE)/ffmpeg-$(FFMPEG_VER)
$(UNTAR)/ffmpeg-$(FFMPEG_VER).tar.xz
set -e; pushd $(BUILD_TMP)/ffmpeg-$(FFMPEG_VER) && \
- for i in $(FFMPEG_PATCHES); do \
+ for i in $(FFMPEG_PATCH); do \
echo -e "==> $(TERM_RED)Applying Patch:$(TERM_NORMAL) $$i"; \
$(PATCH)/ffmpeg/$$i; \
done; \
# FFMPEG | A complete, cross-platform solution to record, convert and stream audio and video
ifeq ($(BOXTYPE), armbox)
-FFMPEG_VER = 4.1.3
+FFMPEG_VER = 4.2
else
FFMPEG_GIT = 2ba896f
endif