[SCM] libav/master: add patches post v11 release
siretart at users.alioth.debian.org
siretart at users.alioth.debian.org
Sat Oct 18 17:54:55 UTC 2014
The following commit has been merged in the master branch:
commit 331257c4034c3d9de0e6597bd1713a98b0e5bf1a
Author: Reinhard Tartler <siretart at tauware.de>
Date: Sat Oct 18 13:53:11 2014 -0400
add patches post v11 release
These patches will be included in the next upstream release and can then
be safely dropped.
These patch files generated with:
git format-patch v11..upstream/release/11 -o debian/patches/upstream
diff --git a/debian/patches/series b/debian/patches/series
index 3199e41..ea3c2b4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,16 @@
03-disable-configuration-warnings.patch
+
+# patches added post v11 release. can be dropped on next upstream release
+# patche files generated with:
+# git format-patch v11..upstream/release/11 -o debian/patches/upstream
+
+upstream/0001-apetag-Fix-APE-tag-size-check.patch
+upstream/0002-Update-default-FATE-URL-for-release-11.patch
+upstream/0003-h264-Always-invoke-the-get_format-callback.patch
+upstream/0004-mpeg12-Always-invoke-the-get_format-callback.patch
+upstream/0005-hevc-Initialize-mergecand_list-to-0.patch
+upstream/0006-h264-reset-ret-to-avoid-propagating-minor-failures.patch
+upstream/0007-hevc_mvs-initialize-the-temporal-MV-in-case-of-missi.patch
+upstream/0008-hevc_mvs-make-sure-to-always-initialize-the-temporal.patch
+upstream/0009-imc-fix-order-of-operations-in-coefficients-read.patch
+upstream/0010-resample-Avoid-off-by-1-errors-in-PTS-calcs.patch
diff --git a/debian/patches/upstream/0001-apetag-Fix-APE-tag-size-check.patch b/debian/patches/upstream/0001-apetag-Fix-APE-tag-size-check.patch
new file mode 100644
index 0000000..8e39ffc
--- /dev/null
+++ b/debian/patches/upstream/0001-apetag-Fix-APE-tag-size-check.patch
@@ -0,0 +1,36 @@
+From b45ab61b24a8f2aeafdd4451491b1b30b7875ee5 Mon Sep 17 00:00:00 2001
+From: Katerina Barone-Adesi <katerinab at gmail.com>
+Date: Tue, 16 Sep 2014 01:40:24 +0200
+Subject: [PATCH 01/10] apetag: Fix APE tag size check
+
+The size variable is (correctly) unsigned, but is passed to several functions
+which take signed parameters, such as avio_read, sometimes after having
+numbers added to it. So ensure that size remains within the bounds that
+these functions can handle.
+
+(cherry picked from commit c5560e72d0bb69f8a1ac9536570398f84388f396)
+Signed-off-by: Diego Biurrun <diego at biurrun.de>
+---
+ libavformat/apetag.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/apetag.c b/libavformat/apetag.c
+index 22884ef..bd8d0ed 100644
+--- a/libavformat/apetag.c
++++ b/libavformat/apetag.c
+@@ -57,8 +57,10 @@ static int ape_tag_read_field(AVFormatContext *s)
+ av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key);
+ return -1;
+ }
+- if (size >= UINT_MAX)
+- return -1;
++ if (size > INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
++ av_log(s, AV_LOG_ERROR, "APE tag size too large.\n");
++ return AVERROR_INVALIDDATA;
++ }
+ if (flags & APE_TAG_FLAG_IS_BINARY) {
+ uint8_t filename[1024];
+ enum AVCodecID id;
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0002-Update-default-FATE-URL-for-release-11.patch b/debian/patches/upstream/0002-Update-default-FATE-URL-for-release-11.patch
new file mode 100644
index 0000000..d1ff5bb
--- /dev/null
+++ b/debian/patches/upstream/0002-Update-default-FATE-URL-for-release-11.patch
@@ -0,0 +1,25 @@
+From 9eb442cca23bb8d33b3e6d37b8c0e3afff04c37a Mon Sep 17 00:00:00 2001
+From: Diego Biurrun <diego at biurrun.de>
+Date: Wed, 17 Sep 2014 07:08:57 -0700
+Subject: [PATCH 02/10] Update default FATE URL for release/11
+
+---
+ tests/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/Makefile b/tests/Makefile
+index 5fad291..eab1eca 100644
+--- a/tests/Makefile
++++ b/tests/Makefile
+@@ -128,7 +128,7 @@ $(FATE_AVCONV) $(FATE_SAMPLES_AVCONV): avconv$(EXESUF)
+ ifdef SAMPLES
+ FATE += $(FATE_SAMPLES)
+ fate-rsync:
+- rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES)
++ rsync -vaLW rsync://fate-suite.libav.org/fate-suite-11/ $(SAMPLES)
+ else
+ fate-rsync:
+ @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite"
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0003-h264-Always-invoke-the-get_format-callback.patch b/debian/patches/upstream/0003-h264-Always-invoke-the-get_format-callback.patch
new file mode 100644
index 0000000..0a6594a
--- /dev/null
+++ b/debian/patches/upstream/0003-h264-Always-invoke-the-get_format-callback.patch
@@ -0,0 +1,101 @@
+From 09c848855a7bf11a9ab4a69971cced260b17817d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi at remlab.net>
+Date: Thu, 25 Sep 2014 11:59:57 +0300
+Subject: [PATCH 03/10] h264: Always invoke the get_format() callback
+
+Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
+---
+ libavcodec/h264_slice.c | 51 ++++++++++++++++++++++++++++++-------------------
+ 1 file changed, 31 insertions(+), 20 deletions(-)
+
+diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
+index 83d3426..1ee7a3d 100644
+--- a/libavcodec/h264_slice.c
++++ b/libavcodec/h264_slice.c
+@@ -975,45 +975,54 @@ static int clone_slice(H264Context *dst, H264Context *src)
+
+ static enum AVPixelFormat get_pixel_format(H264Context *h)
+ {
++ enum AVPixelFormat pix_fmts[2];
++ const enum AVPixelFormat *choices = pix_fmts;
++
++ pix_fmts[1] = AV_PIX_FMT_NONE;
++
+ switch (h->sps.bit_depth_luma) {
+ case 9:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+- return AV_PIX_FMT_GBRP9;
++ pix_fmts[0] = AV_PIX_FMT_GBRP9;
+ } else
+- return AV_PIX_FMT_YUV444P9;
++ pix_fmts[0] = AV_PIX_FMT_YUV444P9;
+ } else if (CHROMA422(h))
+- return AV_PIX_FMT_YUV422P9;
++ pix_fmts[0] = AV_PIX_FMT_YUV422P9;
+ else
+- return AV_PIX_FMT_YUV420P9;
++ pix_fmts[0] = AV_PIX_FMT_YUV420P9;
+ break;
+ case 10:
+ if (CHROMA444(h)) {
+ if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+- return AV_PIX_FMT_GBRP10;
++ pix_fmts[0] = AV_PIX_FMT_GBRP10;
+ } else
+- return AV_PIX_FMT_YUV444P10;
++ pix_fmts[0] = AV_PIX_FMT_YUV444P10;
+ } else if (CHROMA422(h))
+- return AV_PIX_FMT_YUV422P10;
++ pix_fmts[0] = AV_PIX_FMT_YUV422P10;
+ else
+- return AV_PIX_FMT_YUV420P10;
++ pix_fmts[0] = AV_PIX_FMT_YUV420P10;
+ break;
+ case 8:
+ if (CHROMA444(h)) {
+- if (h->avctx->colorspace == AVCOL_SPC_RGB) {
+- return AV_PIX_FMT_GBRP;
+- } else
+- return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
+- : AV_PIX_FMT_YUV444P;
++ if (h->avctx->colorspace == AVCOL_SPC_RGB)
++ pix_fmts[0] = AV_PIX_FMT_GBRP;
++ else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
++ pix_fmts[0] = AV_PIX_FMT_YUVJ444P;
++ else
++ pix_fmts[0] = AV_PIX_FMT_YUV444P;
+ } else if (CHROMA422(h)) {
+- return h->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P
+- : AV_PIX_FMT_YUV422P;
++ if (h->avctx->color_range == AVCOL_RANGE_JPEG)
++ pix_fmts[0] = AV_PIX_FMT_YUVJ422P;
++ else
++ pix_fmts[0] = AV_PIX_FMT_YUV422P;
+ } else {
+- return ff_get_format(h->avctx, h->avctx->codec->pix_fmts ?
+- h->avctx->codec->pix_fmts :
+- h->avctx->color_range == AVCOL_RANGE_JPEG ?
+- h264_hwaccel_pixfmt_list_jpeg_420 :
+- h264_hwaccel_pixfmt_list_420);
++ if (h->avctx->codec->pix_fmts)
++ choices = h->avctx->codec->pix_fmts;
++ else if (h->avctx->color_range == AVCOL_RANGE_JPEG)
++ choices = h264_hwaccel_pixfmt_list_jpeg_420;
++ else
++ choices = h264_hwaccel_pixfmt_list_420;
+ }
+ break;
+ default:
+@@ -1021,6 +1030,8 @@ static enum AVPixelFormat get_pixel_format(H264Context *h)
+ "Unsupported bit depth %d\n", h->sps.bit_depth_luma);
+ return AVERROR_INVALIDDATA;
+ }
++
++ return ff_get_format(h->avctx, choices);
+ }
+
+ /* export coded and cropped frame dimensions to AVCodecContext */
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0004-mpeg12-Always-invoke-the-get_format-callback.patch b/debian/patches/upstream/0004-mpeg12-Always-invoke-the-get_format-callback.patch
new file mode 100644
index 0000000..8eb0785
--- /dev/null
+++ b/debian/patches/upstream/0004-mpeg12-Always-invoke-the-get_format-callback.patch
@@ -0,0 +1,56 @@
+From ce0972ecddef3eee3c03e393108e5728821e3e37 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi at remlab.net>
+Date: Thu, 25 Sep 2014 11:59:58 +0300
+Subject: [PATCH 04/10] mpeg12: Always invoke the get_format() callback
+
+Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
+---
+ libavcodec/mpeg12dec.c | 19 ++++++++++++++++---
+ 1 file changed, 16 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
+index e3bd167..93e3900 100644
+--- a/libavcodec/mpeg12dec.c
++++ b/libavcodec/mpeg12dec.c
+@@ -1181,10 +1181,21 @@ static const enum AVPixelFormat mpeg12_hwaccel_pixfmt_list_420[] = {
+ AV_PIX_FMT_NONE
+ };
+
++static const enum AVPixelFormat mpeg12_pixfmt_list_422[] = {
++ AV_PIX_FMT_YUV422P,
++ AV_PIX_FMT_NONE
++};
++
++static const enum AVPixelFormat mpeg12_pixfmt_list_444[] = {
++ AV_PIX_FMT_YUV444P,
++ AV_PIX_FMT_NONE
++};
++
+ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
+ {
+ Mpeg1Context *s1 = avctx->priv_data;
+ MpegEncContext *s = &s1->mpeg_enc_ctx;
++ const enum AVPixelFormat *pix_fmts;
+
+ #if FF_API_XVMC
+ FF_DISABLE_DEPRECATION_WARNINGS
+@@ -1194,11 +1205,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
+ #endif /* FF_API_XVMC */
+
+ if (s->chroma_format < 2)
+- return ff_get_format(avctx, mpeg12_hwaccel_pixfmt_list_420);
++ pix_fmts = mpeg12_hwaccel_pixfmt_list_420;
+ else if (s->chroma_format == 2)
+- return AV_PIX_FMT_YUV422P;
++ pix_fmts = mpeg12_pixfmt_list_422;
+ else
+- return AV_PIX_FMT_YUV444P;
++ pix_fmts = mpeg12_pixfmt_list_444;
++
++ return ff_get_format(avctx, pix_fmts);
+ }
+
+ /* Call this function when we know all parameters.
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0005-hevc-Initialize-mergecand_list-to-0.patch b/debian/patches/upstream/0005-hevc-Initialize-mergecand_list-to-0.patch
new file mode 100644
index 0000000..a80c5b3
--- /dev/null
+++ b/debian/patches/upstream/0005-hevc-Initialize-mergecand_list-to-0.patch
@@ -0,0 +1,29 @@
+From 570cefb02b4f149c4263677e1a3eea216ee0ec8c Mon Sep 17 00:00:00 2001
+From: Luca Barbato <lu_zero at gentoo.org>
+Date: Wed, 17 Sep 2014 19:51:40 +0200
+Subject: [PATCH 05/10] hevc: Initialize mergecand_list to 0
+
+Unbreak cf6090dc6252f2b276aa4133e3d73a89f4c6046c.
+
+CC: libav-stable at libav.org
+Sample-Id: hevc-conformance-LTRPSPS_A_Qualcomm_1
+---
+ libavcodec/hevc_mvs.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
+index cc5a16c..a611b76 100644
+--- a/libavcodec/hevc_mvs.c
++++ b/libavcodec/hevc_mvs.c
+@@ -556,6 +556,8 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
+ int nPbH2 = nPbH;
+ HEVCLocalContext *lc = &s->HEVClc;
+
++ memset(mergecand_list, 0, MRG_MAX_NUM_CANDS * sizeof(*mergecand_list));
++
+ if (s->pps->log2_parallel_merge_level > 2 && nCS == 8) {
+ singleMCLFlag = 1;
+ x0 = lc->cu.x;
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0006-h264-reset-ret-to-avoid-propagating-minor-failures.patch b/debian/patches/upstream/0006-h264-reset-ret-to-avoid-propagating-minor-failures.patch
new file mode 100644
index 0000000..0b02894
--- /dev/null
+++ b/debian/patches/upstream/0006-h264-reset-ret-to-avoid-propagating-minor-failures.patch
@@ -0,0 +1,29 @@
+From ff24824a721576195c3b4a711e3ee2af900de795 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni at gmx.at>
+Date: Sun, 28 Sep 2014 00:46:50 +0100
+Subject: [PATCH 06/10] h264: reset ret to avoid propagating minor failures
+
+Unbreak 772d150a6e82542c06b0c251e73dd299d98d1027.
+
+CC: libav-stable at libav.org
+Bug-Id: 750 / 905753
+Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
+---
+ libavcodec/h264.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libavcodec/h264.c b/libavcodec/h264.c
+index 1fd5e50..562b102 100644
+--- a/libavcodec/h264.c
++++ b/libavcodec/h264.c
+@@ -1679,6 +1679,7 @@ again:
+ goto end;
+ }
+
++ ret = 0;
+ end:
+ /* clean up */
+ if (h->cur_pic_ptr && !h->droppable) {
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0007-hevc_mvs-initialize-the-temporal-MV-in-case-of-missi.patch b/debian/patches/upstream/0007-hevc_mvs-initialize-the-temporal-MV-in-case-of-missi.patch
new file mode 100644
index 0000000..d61934c
--- /dev/null
+++ b/debian/patches/upstream/0007-hevc_mvs-initialize-the-temporal-MV-in-case-of-missi.patch
@@ -0,0 +1,30 @@
+From de31f857077a52714f3a2f2e92ac037d42d37769 Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Mon, 29 Sep 2014 16:16:50 +0000
+Subject: [PATCH 07/10] hevc_mvs: initialize the temporal MV in case of missing
+ ref
+
+The caller expects the MV to always be initialized.
+---
+ libavcodec/hevc_mvs.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
+index a611b76..8b172a2 100644
+--- a/libavcodec/hevc_mvs.c
++++ b/libavcodec/hevc_mvs.c
+@@ -257,8 +257,10 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
+
+ HEVCFrame *ref = s->ref->collocated_ref;
+
+- if (!ref)
++ if (!ref) {
++ memset(mvLXCol, 0, sizeof(*mvLXCol));
+ return 0;
++ }
+
+ tab_mvf = ref->tab_mvf;
+ colPic = ref->poc;
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0008-hevc_mvs-make-sure-to-always-initialize-the-temporal.patch b/debian/patches/upstream/0008-hevc_mvs-make-sure-to-always-initialize-the-temporal.patch
new file mode 100644
index 0000000..6342a7c
--- /dev/null
+++ b/debian/patches/upstream/0008-hevc_mvs-make-sure-to-always-initialize-the-temporal.patch
@@ -0,0 +1,50 @@
+From 0b41eeac45fb7f7ad6d3f4fc846b00d108824b0b Mon Sep 17 00:00:00 2001
+From: Anton Khirnov <anton at khirnov.net>
+Date: Mon, 29 Sep 2014 16:25:14 +0000
+Subject: [PATCH 08/10] hevc_mvs: make sure to always initialize the temporal
+ MV fully
+
+The spec requires this.
+
+Fixes uninitialized reads on some samples.
+
+Remove now unnecessary initialization of the whole merge candidate list.
+---
+ libavcodec/hevc_mvs.c | 14 ++++----------
+ 1 file changed, 4 insertions(+), 10 deletions(-)
+
+diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
+index 8b172a2..721eb3a 100644
+--- a/libavcodec/hevc_mvs.c
++++ b/libavcodec/hevc_mvs.c
+@@ -481,14 +481,10 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
+ mergecandlist[nb_merge_cand].is_intra = 0;
+ mergecandlist[nb_merge_cand].pred_flag[0] = available_l0;
+ mergecandlist[nb_merge_cand].pred_flag[1] = available_l1;
+- if (available_l0) {
+- mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
+- mergecandlist[nb_merge_cand].ref_idx[0] = 0;
+- }
+- if (available_l1) {
+- mergecandlist[nb_merge_cand].mv[1] = mv_l1_col;
+- mergecandlist[nb_merge_cand].ref_idx[1] = 0;
+- }
++ AV_ZERO16(mergecandlist[nb_merge_cand].ref_idx);
++ mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
++ mergecandlist[nb_merge_cand].mv[1] = mv_l1_col;
++
+ if (merge_idx == nb_merge_cand)
+ return;
+ nb_merge_cand++;
+@@ -558,8 +554,6 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
+ int nPbH2 = nPbH;
+ HEVCLocalContext *lc = &s->HEVClc;
+
+- memset(mergecand_list, 0, MRG_MAX_NUM_CANDS * sizeof(*mergecand_list));
+-
+ if (s->pps->log2_parallel_merge_level > 2 && nCS == 8) {
+ singleMCLFlag = 1;
+ x0 = lc->cu.x;
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0009-imc-fix-order-of-operations-in-coefficients-read.patch b/debian/patches/upstream/0009-imc-fix-order-of-operations-in-coefficients-read.patch
new file mode 100644
index 0000000..8c4859d
--- /dev/null
+++ b/debian/patches/upstream/0009-imc-fix-order-of-operations-in-coefficients-read.patch
@@ -0,0 +1,36 @@
+From e443165c323406d01da7e7930f042d265d01fb35 Mon Sep 17 00:00:00 2001
+From: Vittorio Giovara <vittorio.giovara at gmail.com>
+Date: Mon, 13 Oct 2014 15:42:28 +0100
+Subject: [PATCH 09/10] imc: fix order of operations in coefficients read
+
+Reported-by: Ruoyu <liangry at ucweb.com>
+---
+ libavcodec/imc.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/libavcodec/imc.c b/libavcodec/imc.c
+index 41ca8c8..500f564 100644
+--- a/libavcodec/imc.c
++++ b/libavcodec/imc.c
+@@ -873,14 +873,14 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
+
+ flag = get_bits1(&q->gb);
+ if (stream_format_code & 0x1)
+- imc_decode_level_coefficients_raw(q, chctx->levlCoeffBuf,
+- chctx->flcoeffs1, chctx->flcoeffs2);
+- else if (stream_format_code & 0x1)
+ imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);
+ else
+ imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf);
+
+- if (stream_format_code & 0x4)
++ if (stream_format_code & 0x1)
++ imc_decode_level_coefficients_raw(q, chctx->levlCoeffBuf,
++ chctx->flcoeffs1, chctx->flcoeffs2);
++ else if (stream_format_code & 0x4)
+ imc_decode_level_coefficients(q, chctx->levlCoeffBuf,
+ chctx->flcoeffs1, chctx->flcoeffs2);
+ else
+--
+2.1.0
+
diff --git a/debian/patches/upstream/0010-resample-Avoid-off-by-1-errors-in-PTS-calcs.patch b/debian/patches/upstream/0010-resample-Avoid-off-by-1-errors-in-PTS-calcs.patch
new file mode 100644
index 0000000..335f719
--- /dev/null
+++ b/debian/patches/upstream/0010-resample-Avoid-off-by-1-errors-in-PTS-calcs.patch
@@ -0,0 +1,64 @@
+From ca8c62d187fdca13979379fb2ab172ed662aa2f8 Mon Sep 17 00:00:00 2001
+From: "Timothy B. Terriberry" <tterribe at xiph.org>
+Date: Mon, 13 Oct 2014 17:46:00 -0700
+Subject: [PATCH 10/10] resample: Avoid off-by-1 errors in PTS calcs.
+
+The rounding used in the PTS calculations in filter_frame() does
+not actually match the number of samples output by the resampler.
+This leads to off-by-1 errors in the timestamps indicating gaps and
+underruns, even when the input timestamps are all contiguous.
+
+Bug-Id: 753
+
+Signed-off-by: Anton Khirnov <anton at khirnov.net>
+(cherry picked from commit 6cbbf0592f4f3940aac7f687850d1b726a2ea836)
+Signed-off-by: Anton Khirnov <anton at khirnov.net>
+---
+ libavfilter/af_resample.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c
+index bc8fd8a..a59e6f8 100644
+--- a/libavfilter/af_resample.c
++++ b/libavfilter/af_resample.c
+@@ -42,6 +42,7 @@ typedef struct ResampleContext {
+ AVDictionary *options;
+
+ int64_t next_pts;
++ int64_t next_in_pts;
+
+ /* set by filter_frame() to signal an output frame to request_frame() */
+ int got_output;
+@@ -154,6 +155,7 @@ static int config_output(AVFilterLink *outlink)
+
+ outlink->time_base = (AVRational){ 1, outlink->sample_rate };
+ s->next_pts = AV_NOPTS_VALUE;
++ s->next_in_pts = AV_NOPTS_VALUE;
+
+ av_get_channel_layout_string(buf1, sizeof(buf1),
+ -1, inlink ->channel_layout);
+@@ -255,7 +257,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+ }
+
+ out->sample_rate = outlink->sample_rate;
+- if (in->pts != AV_NOPTS_VALUE) {
++ /* Only convert in->pts if there is a discontinuous jump.
++ This ensures that out->pts tracks the number of samples actually
++ output by the resampler in the absence of such a jump.
++ Otherwise, the rounding in av_rescale_q() and av_rescale()
++ causes off-by-1 errors. */
++ if (in->pts != AV_NOPTS_VALUE && in->pts != s->next_in_pts) {
+ out->pts = av_rescale_q(in->pts, inlink->time_base,
+ outlink->time_base) -
+ av_rescale(delay, outlink->sample_rate,
+@@ -264,6 +271,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+ out->pts = s->next_pts;
+
+ s->next_pts = out->pts + out->nb_samples;
++ s->next_in_pts = in->pts + in->nb_samples;
+
+ ret = ff_filter_frame(outlink, out);
+ s->got_output = 1;
+--
+2.1.0
+
--
Libav/FFmpeg packaging
More information about the pkg-multimedia-commits
mailing list