[FFmpeg-devel] [PATCHv3 2/4] avcodec/svq1enc: output ident string in extradata field
Peter Ross
pross at xvid.org
Tue Oct 25 12:17:17 EEST 2022
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 9bd5a04368..73c85bff6b 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"
@@ -567,6 +568,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;
@@ -628,7 +642,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
--
2.35.1
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20221025/01014a4b/attachment.sig>
More information about the ffmpeg-devel
mailing list