Hi!

Attached patch fixes ticket #6717, files without sei can be produced
with remuxing and seeking, even if this is a (separate) bug, such
files exist in the wild.

Please comment, Carl Eugen
From c3ce0a75f13663958034a70fb4a982671532d269 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffm...@gmail.com>
Date: Mon, 4 Dec 2017 01:05:57 +0100
Subject: [PATCH] lavc: Allow forcing work-around for old x264 cabac 8x8 4:4:4
 bug.

Fixes ticket #6717.
---
 libavcodec/avcodec.h       |    1 +
 libavcodec/h264_cabac.c    |    5 ++++-
 libavcodec/options_table.h |    1 +
 libavcodec/version.h       |    2 +-
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5db6a81..bae8812 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2516,6 +2516,7 @@ typedef struct AVCodecContext {
      */
     int workaround_bugs;
 #define FF_BUG_AUTODETECT       1  ///< autodetection
+#define FF_BUG_X264_CAB_8x8_444 2
 #define FF_BUG_XVID_ILACE       4
 #define FF_BUG_UMP4             8
 #define FF_BUG_NO_PADDING       16
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index ec5fc74..8b2973a 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1919,6 +1919,9 @@ int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
     int dct8x8_allowed = h->ps.pps->transform_8x8_mode;
     const int decode_chroma = sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2;
     const int pixel_shift = h->pixel_shift;
+    AVCodecContext *avctx = h->avctx;
+    if (h->x264_build < 151U)
+        avctx->workaround_bugs |= FF_BUG_X264_CAB_8x8_444;
 
     mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride;
 
@@ -2347,7 +2350,7 @@ decode_intra_mb:
     if (CHROMA444(h) && IS_8x8DCT(mb_type)){
         int i;
         uint8_t *nnz_cache = sl->non_zero_count_cache;
-        if (h->x264_build < 151U) {
+        if (avctx->workaround_bugs & FF_BUG_X264_CAB_8x8_444) {
             for (i = 0; i < 2; i++){
                 if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
                     nnz_cache[3+8* 1 + 2*8*i]=
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index d89f58d..ed35bec 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -112,6 +112,7 @@ static const AVOption avcodec_options[] = {
 {"bug", "work around not autodetected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
 {"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
 {"xvid_ilace", "Xvid interlacing bug (autodetected if FOURCC == XVIX)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_XVID_ILACE }, INT_MIN, INT_MAX, V|D, "bug"},
+{"x264_cab_8x8_444", "x264 cabac 8x8 4:4:4 encoding bug (autodetected if possible)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_X264_CAB_8x8_444 }, INT_MIN, INT_MAX, V|D, "bug"},
 {"ump4", "(autodetected if FOURCC == UMP4)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_UMP4 }, INT_MIN, INT_MAX, V|D, "bug"},
 {"no_padding", "padding bug (autodetected)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_NO_PADDING }, INT_MIN, INT_MAX, V|D, "bug"},
 {"amv", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AMV }, INT_MIN, INT_MAX, V|D, "bug"},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d67b689..3b5c300 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR   6
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to