From 4fdeb9c8b732246f0a3699f16db092b06ee4445c Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Fri, 1 Dec 2017 05:12:59 +0000 Subject: [PATCH] ffmpeg: RPi patch cleanup --- ...ormat-to-fix-an-issue-with-MMAL-ren.patch} | 0 ...e6f9f3d01f7fc0f3ae4b66f6c725f9fb1105.patch | 24 -- ...l-unsupported-GMC-with-more-than-one.patch | 48 +++ ...peg-99.1003-pfcd_hevc_optimisations.patch} | 177 +---------- ...g-99.1004-added_upstream_mvc_patches.patch | 283 ++++++++++++++++++ 5 files changed, 343 insertions(+), 189 deletions(-) rename packages/multimedia/ffmpeg/patches/{ffmpeg-99.1003-Call-get_format-to-fix-an-issue-with-MMAL-ren.patch => ffmpeg-99.1001-Call-get_format-to-fix-an-issue-with-MMAL-ren.patch} (100%) delete mode 100644 packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-73fde6f9f3d01f7fc0f3ae4b66f6c725f9fb1105.patch create mode 100644 packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-mpeg4video-Signal-unsupported-GMC-with-more-than-one.patch rename packages/multimedia/ffmpeg/patches/{ffmpeg-99.1001-pfcd_hevc_optimisations.patch => ffmpeg-99.1003-pfcd_hevc_optimisations.patch} (99%) create mode 100644 packages/multimedia/ffmpeg/patches/ffmpeg-99.1004-added_upstream_mvc_patches.patch diff --git a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1003-Call-get_format-to-fix-an-issue-with-MMAL-ren.patch b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1001-Call-get_format-to-fix-an-issue-with-MMAL-ren.patch similarity index 100% rename from packages/multimedia/ffmpeg/patches/ffmpeg-99.1003-Call-get_format-to-fix-an-issue-with-MMAL-ren.patch rename to packages/multimedia/ffmpeg/patches/ffmpeg-99.1001-Call-get_format-to-fix-an-issue-with-MMAL-ren.patch diff --git a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-73fde6f9f3d01f7fc0f3ae4b66f6c725f9fb1105.patch b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-73fde6f9f3d01f7fc0f3ae4b66f6c725f9fb1105.patch deleted file mode 100644 index 5240cf58ce..0000000000 --- a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-73fde6f9f3d01f7fc0f3ae4b66f6c725f9fb1105.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 73fde6f9f3d01f7fc0f3ae4b66f6c725f9fb1105 Mon Sep 17 00:00:00 2001 -From: Hendrik Leppkes -Date: Mon, 1 Sep 2014 11:39:09 +0200 -Subject: [PATCH] h264_parser: force grabing a new timestamp until a frame - start was found - ---- - libavcodec/h264_parser.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c -index 2fd3f2b..7165652 100644 ---- a/libavcodec/h264_parser.c -+++ b/libavcodec/h264_parser.c -@@ -525,6 +525,9 @@ static int h264_parse(AVCodecParserContext *s, - } else { - next = h264_find_frame_end(p, buf, buf_size); - -+ if (next == END_NOT_FOUND && pc->frame_start_found == 0) -+ s->fetch_timestamp = 1; -+ - if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; diff --git a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-mpeg4video-Signal-unsupported-GMC-with-more-than-one.patch b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-mpeg4video-Signal-unsupported-GMC-with-more-than-one.patch new file mode 100644 index 0000000000..c3c09d6325 --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1002-mpeg4video-Signal-unsupported-GMC-with-more-than-one.patch @@ -0,0 +1,48 @@ +From 214a8ccc1489db28ce6cec2739365d7eebbdb0f9 Mon Sep 17 00:00:00 2001 +From: popcornmix +Date: Fri, 5 Jun 2015 22:48:33 +0100 +Subject: [PATCH] mpeg4video: Signal unsupported GMC with more than one warp + point + +--- + libavcodec/avcodec.h | 1 + + libavcodec/mpeg4videodec.c | 4 ++++ + 2 files changed, 5 insertions(+) + +diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h +index c207d3a784..08aa8112b1 100644 +--- a/libavcodec/avcodec.h ++++ b/libavcodec/avcodec.h +@@ -2967,6 +2967,7 @@ typedef struct AVCodecContext { + #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. + #define FF_BUG_TRUNCATED 16384 + #define FF_BUG_IEDGE 32768 ++#define FF_BUG_GMC_UNSUPPORTED (1<<30) + + /** + * strictly follow the standard (MPEG-4, ...). +diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c +index cd39131d55..d8c8227cb4 100644 +--- a/libavcodec/mpeg4videodec.c ++++ b/libavcodec/mpeg4videodec.c +@@ -2250,6 +2250,9 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) + + if (ctx->divx_version >= 0) + s->workaround_bugs |= FF_BUG_HPEL_CHROMA; ++ ++ if (ctx->num_sprite_warping_points > 1) ++ s->workaround_bugs |= FF_BUG_GMC_UNSUPPORTED; + } + + if (s->workaround_bugs & FF_BUG_STD_QPEL) { +@@ -2274,6 +2277,7 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx) + s->workaround_bugs, ctx->lavc_build, ctx->xvid_build, + ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : ""); + ++ avctx->workaround_bugs = s->workaround_bugs; + if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 && + s->codec_id == AV_CODEC_ID_MPEG4 && + avctx->idct_algo == FF_IDCT_AUTO) { +-- +2.14.1 + diff --git a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1001-pfcd_hevc_optimisations.patch b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1003-pfcd_hevc_optimisations.patch similarity index 99% rename from packages/multimedia/ffmpeg/patches/ffmpeg-99.1001-pfcd_hevc_optimisations.patch rename to packages/multimedia/ffmpeg/patches/ffmpeg-99.1003-pfcd_hevc_optimisations.patch index 97b8ef604c..5104bfd261 100644 --- a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1001-pfcd_hevc_optimisations.patch +++ b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1003-pfcd_hevc_optimisations.patch @@ -516,7 +516,7 @@ index c4ec09b1c4..3b94d47e9a 100644 +$(SUBDIR)rpi_hevcdec.o $(SUBDIR)rpi_shader_template.o $(SUBDIR)rpi_qpu.o: $(SUBDIR)rpi_hevc_shader.h +endif diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c -index 4f34312e67..a5289a5e14 100644 +index 4f34312e67..5361a22141 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -222,6 +222,7 @@ static void register_all(void) @@ -527,14 +527,6 @@ index 4f34312e67..a5289a5e14 100644 REGISTER_DECODER(HEVC, hevc); REGISTER_DECODER(HEVC_QSV, hevc_qsv); REGISTER_DECODER(HEVC_RKMPP, hevc_rkmpp); -@@ -731,6 +732,7 @@ static void register_all(void) - REGISTER_PARSER(H261, h261); - REGISTER_PARSER(H263, h263); - REGISTER_PARSER(H264, h264); -+ REGISTER_PARSER(H264_MVC, h264_mvc); - REGISTER_PARSER(HEVC, hevc); - REGISTER_PARSER(MJPEG, mjpeg); - REGISTER_PARSER(MLP, mlp); diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index 1eeac5449e..64aca64e52 100644 --- a/libavcodec/arm/Makefile @@ -8301,37 +8293,10 @@ index 0000000000..8c32cb23e7 +endfunc + diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h -index 18c3e3ea1e..e1a0a9ebc0 100644 +index 18c3e3ea1e..c26b6d607c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h -@@ -449,6 +449,8 @@ enum AVCodecID { - AV_CODEC_ID_GDV, - AV_CODEC_ID_FITS, - -+ AV_CODEC_ID_H264_MVC, -+ - /* various PCM "codecs" */ - AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs - AV_CODEC_ID_PCM_S16LE = 0x10000, -@@ -2965,6 +2967,7 @@ typedef struct AVCodecContext { - #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. - #define FF_BUG_TRUNCATED 16384 - #define FF_BUG_IEDGE 32768 -+#define FF_BUG_GMC_UNSUPPORTED (1 << 16) - - /** - * strictly follow the standard (MPEG-4, ...). -@@ -3317,6 +3320,9 @@ typedef struct AVCodecContext { - #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244 - #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA) - #define FF_PROFILE_H264_CAVLC_444 44 -+#define FF_PROFILE_H264_MULTIVIEW_HIGH 118 -+#define FF_PROFILE_H264_STEREO_HIGH 128 -+#define FF_PROFILE_H264_MULTIVIEW_HIGH_DEPTH 138 - - #define FF_PROFILE_VC1_SIMPLE 0 - #define FF_PROFILE_VC1_MAIN 1 -@@ -3627,7 +3633,13 @@ typedef struct AVCodecContext { +@@ -3627,7 +3627,13 @@ typedef struct AVCodecContext { #endif /** @@ -8346,7 +8311,7 @@ index 18c3e3ea1e..e1a0a9ebc0 100644 * the end of the audio. I.e. this number of decoded samples must be * discarded by the caller from the end of the stream to get the original * audio without any trailing padding. -@@ -4816,6 +4828,17 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); +@@ -4816,6 +4822,17 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); */ AVCodec *avcodec_find_decoder(enum AVCodecID id); @@ -8400,10 +8365,10 @@ index af0f6da2e9..bd491c0c55 100644 AVCodecContext *avctx; BswapDSPContext bdsp; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c -index 6a13bbbf0e..ff10f3b2bc 100644 +index 6a13bbbf0e..478b7c0ffc 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c -@@ -1665,6 +1665,48 @@ static const AVCodecDescriptor codec_descriptors[] = { +@@ -1665,6 +1665,41 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_LOSSLESS, .mime_types= MT("image/png"), }, @@ -8441,128 +8406,23 @@ index 6a13bbbf0e..ff10f3b2bc 100644 + .name = "ylc", + .long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, -+ }, -+ { -+ .id = AV_CODEC_ID_H264_MVC, -+ .type = AVMEDIA_TYPE_VIDEO, -+ .name = "h264_mvc", -+ .long_name = NULL_IF_CONFIG_SMALL("H264 MVC"), -+ .props = AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { -diff --git a/libavcodec/h264.h b/libavcodec/h264.h -index 86df5eb9b3..22c4f1d82a 100644 ---- a/libavcodec/h264.h -+++ b/libavcodec/h264.h -@@ -41,7 +41,9 @@ enum { - H264_NAL_END_STREAM = 11, - H264_NAL_FILLER_DATA = 12, - H264_NAL_SPS_EXT = 13, -+ H264_NAL_SPS_SUBSET = 15, - H264_NAL_AUXILIARY_SLICE = 19, -+ H264_NAL_SLICE_EXT = 20, - }; - - #endif /* AVCODEC_H264_H */ diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c -index dd0a965af0..5e43def0e9 100644 +index dd0a965af0..053325c26b 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c -@@ -60,6 +60,8 @@ typedef struct H264ParseContext { - uint8_t parse_history[6]; - int parse_history_count; - int parse_last_mb; -+ int is_mvc; -+ int slice_ext; - int64_t reference_dts; - int last_frame_num, last_picture_structure; - } H264ParseContext; -@@ -109,24 +111,27 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf, - } else if (state <= 5) { - int nalu_type = buf[i] & 0x1F; - if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS || -- nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) { -+ nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD || -+ nalu_type == H264_NAL_SPS_SUBSET) { - if (pc->frame_start_found) { - i++; +@@ -115,7 +115,7 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf, goto found; } } else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA || - nalu_type == H264_NAL_IDR_SLICE) { -+ nalu_type == H264_NAL_IDR_SLICE || (p->is_mvc && nalu_type == H264_NAL_SLICE_EXT)) { ++ nalu_type == H264_NAL_IDR_SLICE)) { state += 8; -+ -+ p->slice_ext = (nalu_type == H264_NAL_SLICE_EXT); continue; } - state = 7; - } else { - p->parse_history[p->parse_history_count++] = buf[i]; -- if (p->parse_history_count > 5) { -+ if (p->parse_history_count > 8) { - unsigned int mb, last_mb = p->parse_last_mb; - GetBitContext gb; - -- init_get_bits(&gb, p->parse_history, 8*p->parse_history_count); -+ init_get_bits8(&gb, p->parse_history + 3*p->slice_ext, p->parse_history_count - 3*p->slice_ext); - p->parse_history_count = 0; - mb= get_ue_golomb_long(&gb); - p->parse_last_mb = mb; -@@ -149,7 +154,7 @@ found: - pc->frame_start_found = 0; - if (p->is_avc) - return next_avc; -- return i - (state & 5) - 5 * (state > 7); -+ return i - (state & 5) - 8 * (state > 7); - } - - static int scan_mmco_reset(AVCodecParserContext *s, GetBitContext *gb, -@@ -594,7 +599,8 @@ static int h264_parse(AVCodecParserContext *s, - } - } - -- parse_nal_units(s, avctx, buf, buf_size); -+ if (!p->is_mvc) -+ parse_nal_units(s, avctx, buf, buf_size); - - if (avctx->framerate.num) - avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); -@@ -651,7 +657,7 @@ static int h264_split(AVCodecContext *avctx, - if ((state & 0xFFFFFF00) != 0x100) - break; - nalu_type = state & 0x1F; -- if (nalu_type == H264_NAL_SPS) { -+ if (nalu_type == H264_NAL_SPS || nalu_type == H264_NAL_SPS_SUBSET) { - has_sps = 1; - } else if (nalu_type == H264_NAL_PPS) - has_pps = 1; -@@ -703,3 +709,23 @@ AVCodecParser ff_h264_parser = { - .parser_close = h264_close, - .split = h264_split, - }; -+ -+static av_cold int init_mvc(AVCodecParserContext *s) -+{ -+ H264ParseContext *p = s->priv_data; -+ int ret = init(s); -+ if (ret < 0) -+ return ret; -+ -+ p->is_mvc = 1; -+ return 0; -+} -+ -+AVCodecParser ff_h264_mvc_parser = { -+ .codec_ids = { AV_CODEC_ID_H264_MVC }, -+ .priv_data_size = sizeof(H264ParseContext), -+ .parser_init = init_mvc, -+ .parser_parse = h264_parse, -+ .parser_close = h264_close, -+ .split = h264_split, -+}; diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 0b1195dc3e..5ef81fa739 100644 --- a/libavcodec/mmaldec.c @@ -40769,19 +40629,6 @@ index ad5aedd5f7..0d2df8b870 100644 frame->format); break; case AVMEDIA_TYPE_AUDIO: -diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c -index 53cbcfb543..f93f06fcfb 100644 ---- a/libavformat/mpegts.c -+++ b/libavformat/mpegts.c -@@ -701,7 +701,7 @@ static const StreamType ISO_types[] = { - #endif - { 0x1b, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, - { 0x1c, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC }, -- { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, -+ { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264_MVC }, - { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000 }, - { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC }, - { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS }, diff --git a/libavformat/utils.c b/libavformat/utils.c index 1a7996c4fd..271e70ed84 100644 --- a/libavformat/utils.c @@ -42133,14 +41980,14 @@ index 0000000000..59c0d3959e +# -Wa,-ahls diff --git a/pi-util/conf_pi2.sh b/pi-util/conf_pi2.sh new file mode 100755 -index 0000000000..4e9bd5fa35 +index 0000000000..4de256bc8a --- /dev/null +++ b/pi-util/conf_pi2.sh @@ -0,0 +1,32 @@ +echo "Configure for Pi2/3" + -+RPI_TOOLROOT=/opt/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-rpi-4.9.3-linux-gnueabihf -+RPI_OPT_VC=/opt/bcm-rootfs/opt/vc ++RPI_TOOLROOT=`pwd`/../tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf ++RPI_OPT_VC=`pwd`/../firmware/opt/vc + +RPI_INCLUDES="-I$RPI_OPT_VC/include -I$RPI_OPT_VC/include/interface/vcos/pthreads -I$RPI_OPT_VC/include/interface/vmcs_host/linux" +RPI_LIBDIRS="-L$RPI_TOOLROOT/lib -L$RPI_OPT_VC/lib" diff --git a/packages/multimedia/ffmpeg/patches/ffmpeg-99.1004-added_upstream_mvc_patches.patch b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1004-added_upstream_mvc_patches.patch new file mode 100644 index 0000000000..1d1fd1690e --- /dev/null +++ b/packages/multimedia/ffmpeg/patches/ffmpeg-99.1004-added_upstream_mvc_patches.patch @@ -0,0 +1,283 @@ +From 8f170986cda0695f28eb2cd4e863aaae0e14d19f Mon Sep 17 00:00:00 2001 +From: Hendrik Leppkes +Date: Sat, 9 Jan 2016 16:34:09 +0100 +Subject: [PATCH 1/4] avcodec: add h264_mvc codec id and profiles + +--- + libavcodec/avcodec.h | 3 +++ + libavcodec/codec_desc.c | 7 +++++++ + libavcodec/profiles.c | 1 + + libavformat/mpegts.c | 2 +- + 4 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h +index 6c4b011b5c..8f1f5a3e53 100644 +--- a/libavcodec/avcodec.h ++++ b/libavcodec/avcodec.h +@@ -449,6 +449,8 @@ enum AVCodecID { + AV_CODEC_ID_GDV, + AV_CODEC_ID_FITS, + ++ AV_CODEC_ID_H264_MVC, ++ + /* various PCM "codecs" */ + AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs + AV_CODEC_ID_PCM_S16LE = 0x10000, +@@ -3318,6 +3320,7 @@ typedef struct AVCodecContext { + #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244 + #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA) + #define FF_PROFILE_H264_CAVLC_444 44 ++#define FF_PROFILE_H264_MULTIVIEW_HIGH_DEPTH 138 + + #define FF_PROFILE_VC1_SIMPLE 0 + #define FF_PROFILE_VC1_MAIN 1 +diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c +index 478b7c0ffc..ff10f3b2bc 100644 +--- a/libavcodec/codec_desc.c ++++ b/libavcodec/codec_desc.c +@@ -1700,6 +1700,13 @@ static const AVCodecDescriptor codec_descriptors[] = { + .long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, ++ { ++ .id = AV_CODEC_ID_H264_MVC, ++ .type = AVMEDIA_TYPE_VIDEO, ++ .name = "h264_mvc", ++ .long_name = NULL_IF_CONFIG_SMALL("H264 MVC"), ++ .props = AV_CODEC_PROP_LOSSY, ++ }, + + /* various PCM "codecs" */ + { +diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c +index 30498efedf..9d3cf4b535 100644 +--- a/libavcodec/profiles.c ++++ b/libavcodec/profiles.c +@@ -72,6 +72,7 @@ const AVProfile ff_h264_profiles[] = { + { FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" }, + { FF_PROFILE_H264_MULTIVIEW_HIGH, "Multiview High" }, + { FF_PROFILE_H264_STEREO_HIGH, "Stereo High" }, ++ { FF_PROFILE_H264_MULTIVIEW_HIGH_DEPTH, "Multiview High Depth" }, + { FF_PROFILE_UNKNOWN }, + }; + +diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c +index 53cbcfb543..f93f06fcfb 100644 +--- a/libavformat/mpegts.c ++++ b/libavformat/mpegts.c +@@ -701,7 +701,7 @@ static const StreamType ISO_types[] = { + #endif + { 0x1b, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, + { 0x1c, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC }, +- { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 }, ++ { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264_MVC }, + { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000 }, + { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC }, + { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS }, +-- +2.14.1 + + +From 00de72f97e8f69f5d4c614bff956ec726f97fa2e Mon Sep 17 00:00:00 2001 +From: Hendrik Leppkes +Date: Sat, 9 Jan 2016 16:34:40 +0100 +Subject: [PATCH 2/4] h264_parser: add support for parsing h264 mvc NALUs + +--- + libavcodec/allcodecs.c | 1 + + libavcodec/h264.h | 2 ++ + libavcodec/h264_parser.c | 34 ++++++++++++++++++++++++++++++---- + 3 files changed, 33 insertions(+), 4 deletions(-) + +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index 5361a22141..a5289a5e14 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -732,6 +732,7 @@ static void register_all(void) + REGISTER_PARSER(H261, h261); + REGISTER_PARSER(H263, h263); + REGISTER_PARSER(H264, h264); ++ REGISTER_PARSER(H264_MVC, h264_mvc); + REGISTER_PARSER(HEVC, hevc); + REGISTER_PARSER(MJPEG, mjpeg); + REGISTER_PARSER(MLP, mlp); +diff --git a/libavcodec/h264.h b/libavcodec/h264.h +index 86df5eb9b3..22c4f1d82a 100644 +--- a/libavcodec/h264.h ++++ b/libavcodec/h264.h +@@ -41,7 +41,9 @@ enum { + H264_NAL_END_STREAM = 11, + H264_NAL_FILLER_DATA = 12, + H264_NAL_SPS_EXT = 13, ++ H264_NAL_SPS_SUBSET = 15, + H264_NAL_AUXILIARY_SLICE = 19, ++ H264_NAL_SLICE_EXT = 20, + }; + + #endif /* AVCODEC_H264_H */ +diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c +index 053325c26b..855c74896e 100644 +--- a/libavcodec/h264_parser.c ++++ b/libavcodec/h264_parser.c +@@ -62,6 +62,7 @@ typedef struct H264ParseContext { + int parse_last_mb; + int64_t reference_dts; + int last_frame_num, last_picture_structure; ++ int is_mvc; + } H264ParseContext; + + +@@ -109,14 +110,18 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf, + } else if (state <= 5) { + int nalu_type = buf[i] & 0x1F; + if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS || +- nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) { ++ nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD || ++ nalu_type == H264_NAL_SPS_SUBSET) { + if (pc->frame_start_found) { + i++; + goto found; + } + } else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA || +- nalu_type == H264_NAL_IDR_SLICE)) { ++ nalu_type == H264_NAL_IDR_SLICE || (p->is_mvc && nalu_type == H264_NAL_SLICE_EXT)) { + state += 8; ++ ++ if (nalu_type == H264_NAL_SLICE_EXT) ++ i += 3; // skip mvc extension + continue; + } + state = 7; +@@ -594,7 +599,8 @@ static int h264_parse(AVCodecParserContext *s, + } + } + +- parse_nal_units(s, avctx, buf, buf_size); ++ if (!p->is_mvc) ++ parse_nal_units(s, avctx, buf, buf_size); + + if (avctx->framerate.num) + avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); +@@ -651,7 +657,7 @@ static int h264_split(AVCodecContext *avctx, + if ((state & 0xFFFFFF00) != 0x100) + break; + nalu_type = state & 0x1F; +- if (nalu_type == H264_NAL_SPS) { ++ if (nalu_type == H264_NAL_SPS || nalu_type == H264_NAL_SPS_SUBSET) { + has_sps = 1; + } else if (nalu_type == H264_NAL_PPS) + has_pps = 1; +@@ -703,3 +709,23 @@ AVCodecParser ff_h264_parser = { + .parser_close = h264_close, + .split = h264_split, + }; ++ ++static av_cold int init_mvc(AVCodecParserContext *s) ++{ ++ H264ParseContext *p = s->priv_data; ++ int ret = init(s); ++ if (ret < 0) ++ return ret; ++ ++ p->is_mvc = 1; ++ return 0; ++} ++ ++AVCodecParser ff_h264_mvc_parser = { ++ .codec_ids = { AV_CODEC_ID_H264_MVC }, ++ .priv_data_size = sizeof(H264ParseContext), ++ .parser_init = init_mvc, ++ .parser_parse = h264_parse, ++ .parser_close = h264_close, ++ .split = h264_split, ++}; +-- +2.14.1 + + +From bbf5daa149ccc2c462be1bd5f6f710eba0e82094 Mon Sep 17 00:00:00 2001 +From: Hendrik Leppkes +Date: Tue, 28 Nov 2017 16:12:12 +0000 +Subject: [PATCH 3/4] h264_parser: force grabing a new timestamp until a frame + start was found + +--- + libavcodec/h264_parser.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c +index 855c74896e..90a99a19a8 100644 +--- a/libavcodec/h264_parser.c ++++ b/libavcodec/h264_parser.c +@@ -587,6 +587,9 @@ static int h264_parse(AVCodecParserContext *s, + } else { + next = h264_find_frame_end(p, buf, buf_size, avctx); + ++ if (next == END_NOT_FOUND && pc->frame_start_found == 0) ++ s->fetch_timestamp = 1; ++ + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; +-- +2.14.1 + + +From 3a0ebb0f7473a9a5ab93e01f7261862a3d324e50 Mon Sep 17 00:00:00 2001 +From: popcornmix +Date: Tue, 28 Nov 2017 18:32:08 +0000 +Subject: [PATCH 4/4] extract_extradata_bsf: Support H264_MVC + +--- + libavcodec/extract_extradata_bsf.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c +index ed6509c681..188e62a42d 100644 +--- a/libavcodec/extract_extradata_bsf.c ++++ b/libavcodec/extract_extradata_bsf.c +@@ -56,7 +56,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt, + HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS, + }; + static const int extradata_nal_types_h264[] = { +- H264_NAL_SPS, H264_NAL_PPS, ++ H264_NAL_SPS, H264_NAL_SPS_SUBSET, H264_NAL_PPS, + }; + + ExtractExtradataContext *s = ctx->priv_data; +@@ -88,14 +88,14 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt, + if (nal->type == HEVC_NAL_SPS) has_sps = 1; + if (nal->type == HEVC_NAL_VPS) has_vps = 1; + } else { +- if (nal->type == H264_NAL_SPS) has_sps = 1; ++ if (nal->type == H264_NAL_SPS || nal->type == H264_NAL_SPS_SUBSET) has_sps = 1; + } + } + } + + if (extradata_size && + ((ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) || +- (ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) { ++ ((ctx->par_in->codec_id == AV_CODEC_ID_H264 || ctx->par_in->codec_id == AV_CODEC_ID_H264_MVC) && has_sps))) { + AVBufferRef *filtered_buf; + uint8_t *extradata, *filtered_data; + +@@ -247,6 +247,7 @@ static const struct { + } extract_tab[] = { + { AV_CODEC_ID_CAVS, extract_extradata_mpeg4 }, + { AV_CODEC_ID_H264, extract_extradata_h2645 }, ++ { AV_CODEC_ID_H264_MVC, extract_extradata_h2645 }, + { AV_CODEC_ID_HEVC, extract_extradata_h2645 }, + { AV_CODEC_ID_MPEG1VIDEO, extract_extradata_mpeg12 }, + { AV_CODEC_ID_MPEG2VIDEO, extract_extradata_mpeg12 }, +@@ -306,6 +307,7 @@ fail: + static const enum AVCodecID codec_ids[] = { + AV_CODEC_ID_CAVS, + AV_CODEC_ID_H264, ++ AV_CODEC_ID_H264_MVC, + AV_CODEC_ID_HEVC, + AV_CODEC_ID_MPEG1VIDEO, + AV_CODEC_ID_MPEG2VIDEO, +-- +2.14.1 +