diff mbox series

[FFmpeg-devel] avformat/framecrcenc: allow setting which side data parameters are printed

Message ID 20240425143459.2875-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat/framecrcenc: allow setting which side data parameters are printed | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

James Almer April 25, 2024, 2:34 p.m. UTC
For some side data types, the size is dependent on the arch at runtime, which
is not good for FATE tests.
Add an option to set which parameters may be printed, starting with size.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/framecrcenc.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Michael Niedermayer April 27, 2024, 12:17 a.m. UTC | #1
On Thu, Apr 25, 2024 at 11:34:59AM -0300, James Almer wrote:
> For some side data types, the size is dependent on the arch at runtime, which
> is not good for FATE tests.

Which are not bit exact ?

I guess its pointer size or something.

Either way i have some local improvments for framecrc that iam using for
testing ill post that. It may be a better direction (with some bitexact flag)
than globally disabling size.

thx

[...]
James Almer April 27, 2024, 12:21 a.m. UTC | #2
On 4/26/2024 9:17 PM, Michael Niedermayer wrote:
> On Thu, Apr 25, 2024 at 11:34:59AM -0300, James Almer wrote:
>> For some side data types, the size is dependent on the arch at runtime, which
>> is not good for FATE tests.
> 
> Which are not bit exact ?

All the AV_PKT_DATA_IAMF_* ones, and AV_FRAME_DATA_VIDEO_ENC_PARAMS (but 
this one is not relevant to the framecrc muxer).

> 
> I guess its pointer size or something.

sizeof(size_t), sizeof(intptr_t), and assorted alignments.

> 
> Either way i have some local improvments for framecrc that iam using for
> testing ill post that. It may be a better direction (with some bitexact flag)
> than globally disabling size.

Ok.

> 
> thx
> 
> [...]
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
index ce306a6c49..7d0e3978f2 100644
--- a/libavformat/framecrcenc.c
+++ b/libavformat/framecrcenc.c
@@ -23,6 +23,7 @@ 
 
 #include "libavutil/adler32.h"
 #include "libavutil/avstring.h"
+#include "libavutil/opt.h"
 
 #include "libavcodec/codec_id.h"
 #include "libavcodec/codec_par.h"
@@ -32,6 +33,11 @@ 
 #include "internal.h"
 #include "mux.h"
 
+struct FrameCRCContext {
+    const AVClass *avclass;
+    int flags;
+};
+
 static int framecrc_write_header(struct AVFormatContext *s)
 {
     int i;
@@ -48,8 +54,11 @@  static int framecrc_write_header(struct AVFormatContext *s)
     return ff_framehash_write_header(s);
 }
 
+#define SD_SIZE 1
+
 static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
+    struct FrameCRCContext *c = s->priv_data;
     uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
     char buf[256];
 
@@ -61,6 +70,7 @@  static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
         av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems);
 
         for (int i = 0; i < pkt->side_data_elems; i++) {
+            if (c->flags & SD_SIZE)
             av_strlcatf(buf, sizeof(buf), ", %8"SIZE_SPECIFIER,
                         pkt->side_data[i].size);
         }
@@ -70,11 +80,29 @@  static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
     return 0;
 }
 
+#define OFFSET(x) offsetof(struct FrameCRCContext, x)
+#define ENC AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption framecrc_options[] = {
+    { "print_side_data", "set which side data parameters to print", OFFSET(flags),
+        AV_OPT_TYPE_FLAGS, { .i64 = SD_SIZE }, INT_MIN, INT_MAX, ENC, .unit = "flags"},
+    { "size", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SD_SIZE }, INT_MIN, INT_MAX, ENC, .unit = "flags"},
+    { NULL },
+};
+
+static const AVClass framecrc_class = {
+    .class_name = "framecrc muxer",
+    .item_name  = av_default_item_name,
+    .option     = framecrc_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 const FFOutputFormat ff_framecrc_muxer = {
     .p.name            = "framecrc",
     .p.long_name       = NULL_IF_CONFIG_SMALL("framecrc testing"),
+    .p.priv_class      = &framecrc_class,
     .p.audio_codec     = AV_CODEC_ID_PCM_S16LE,
     .p.video_codec     = AV_CODEC_ID_RAWVIDEO,
+    .priv_data_size    = sizeof(struct FrameCRCContext),
     .write_header      = framecrc_write_header,
     .write_packet      = framecrc_write_packet,
     .p.flags           = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT |