From b0c1f248d9dd5b21d9c11e4e28b8862548d64cbd Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Tue, 1 Nov 2022 09:24:29 +1100 Subject: [PATCH] avcodec/svq1enc: output ident string in extradata field This will enable the acurate identification of FFmpeg produced SVQ1 streams, should there be new bugs found in the encoder. --- libavcodec/svq1enc.c | 16 +++++++++++++++- tests/ref/vsynth/vsynth1-svq1 | 4 ++-- tests/ref/vsynth/vsynth2-svq1 | 4 ++-- tests/ref/vsynth/vsynth3-svq1 | 4 ++-- tests/ref/vsynth/vsynth_lena-svq1 | 4 ++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index b275b333dc..8f09e634a5 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -41,6 +41,7 @@ #include "svq1.h" #include "svq1encdsp.h" #include "svq1enc_cb.h" +#include "version.h" #include "libavutil/avassert.h" #include "libavutil/frame.h" @@ -572,6 +573,19 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) return 0; } +static av_cold int write_ident(AVCodecContext *avctx, const char *ident) +{ + int size = strlen(ident); + avctx->extradata = av_malloc(size + 8); + if (!avctx->extradata) + return AVERROR(ENOMEM); + AV_WB32(avctx->extradata, size + 8); + AV_WL32(avctx->extradata + 4, MKTAG('S', 'V', 'Q', '1')); + memcpy(avctx->extradata + 8, ident, size); + avctx->extradata_size = size + 8; + return 0; +} + static av_cold int svq1_encode_init(AVCodecContext *avctx) { SVQ1EncContext *const s = avctx->priv_data; @@ -632,7 +646,7 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) ff_h263_encode_init(&s->m); // mv_penalty - return 0; + return write_ident(avctx, s->avctx->flags & AV_CODEC_FLAG_BITEXACT ? "Lavc" : LIBAVCODEC_IDENT); } static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, diff --git a/tests/ref/vsynth/vsynth1-svq1 b/tests/ref/vsynth/vsynth1-svq1 index e91ef46f17..6a517f6b7b 100644 --- a/tests/ref/vsynth/vsynth1-svq1 +++ b/tests/ref/vsynth/vsynth1-svq1 @@ -1,4 +1,4 @@ -78cdca850b19faf3aac0b0682207451e *tests/data/fate/vsynth1-svq1.mov -1333541 tests/data/fate/vsynth1-svq1.mov +89b1ec4d7bbee1ed2710c8cc8c1e269d *tests/data/fate/vsynth1-svq1.mov +1333561 tests/data/fate/vsynth1-svq1.mov 0b9ee47ee4bf735fe3697daad64fc409 *tests/data/fate/vsynth1-svq1.out.rawvideo stddev: 9.57 PSNR: 28.50 MAXDIFF: 210 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-svq1 b/tests/ref/vsynth/vsynth2-svq1 index b50ba45e20..01d78bd279 100644 --- a/tests/ref/vsynth/vsynth2-svq1 +++ b/tests/ref/vsynth/vsynth2-svq1 @@ -1,4 +1,4 @@ -42578021105a2f526179c5601e635312 *tests/data/fate/vsynth2-svq1.mov -940337 tests/data/fate/vsynth2-svq1.mov +14f355a06d475dcf6a90ac6ab3ae2970 *tests/data/fate/vsynth2-svq1.mov +940357 tests/data/fate/vsynth2-svq1.mov ba8f6b721a8e19fe8a6ef92a8cff7479 *tests/data/fate/vsynth2-svq1.out.rawvideo stddev: 3.71 PSNR: 36.72 MAXDIFF: 210 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth3-svq1 b/tests/ref/vsynth/vsynth3-svq1 index ba1d3d5082..05fd497336 100644 --- a/tests/ref/vsynth/vsynth3-svq1 +++ b/tests/ref/vsynth/vsynth3-svq1 @@ -1,4 +1,4 @@ -03805cb764c00c2162b2bed24b7f34bd *tests/data/fate/vsynth3-svq1.mov -40757 tests/data/fate/vsynth3-svq1.mov +969dcdd69774b9c42dcf81e8dd393364 *tests/data/fate/vsynth3-svq1.mov +40777 tests/data/fate/vsynth3-svq1.mov a99efde992a2e3efcc085ecc6920a1e3 *tests/data/fate/vsynth3-svq1.out.rawvideo stddev: 14.49 PSNR: 24.91 MAXDIFF: 183 bytes: 86700/ 86700 diff --git a/tests/ref/vsynth/vsynth_lena-svq1 b/tests/ref/vsynth/vsynth_lena-svq1 index 94f260865a..0889eba5bb 100644 --- a/tests/ref/vsynth/vsynth_lena-svq1 +++ b/tests/ref/vsynth/vsynth_lena-svq1 @@ -1,4 +1,4 @@ -7534b2c6b7fc7201f193e9b4514cdb90 *tests/data/fate/vsynth_lena-svq1.mov -766817 tests/data/fate/vsynth_lena-svq1.mov +8890d9ca13934391b6891ac5f67897c6 *tests/data/fate/vsynth_lena-svq1.mov +766837 tests/data/fate/vsynth_lena-svq1.mov 85261558fa744ef468fe77dbe4d91d8d *tests/data/fate/vsynth_lena-svq1.out.rawvideo stddev: 3.23 PSNR: 37.93 MAXDIFF: 61 bytes: 7603200/ 7603200