MCPcopy Create free account
hub / github.com/BabitMF/bmf / fuzz_decode_encode

Function fuzz_decode_encode

bmf/test/fuzz_ffmpeg_modules/fuzz.cpp:83–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void fuzz_decode_encode(std::tuple<int, int, int, int> crop, int crf, std::string preset) {
84 BMFLOG_SET_LEVEL(BMF_INFO);
85
86 // decode from input file
87 VideoFrame decoded_vf;
88 EXPECT_NO_THROW(decoded_vf = decode_one_frame("../../files/big_bunny_10s_30fps.mp4"));
89 ASSERT_TRUE(decoded_vf);
90
91 // crop params
92 int x, y, width, height;
93 std::tie(x, y, width, height) = crop;
94
95 // crop decoded frame
96 EXPECT_NO_THROW(decoded_vf.crop(x, y, width, height));
97
98 // setup encoder
99 nlohmann::json video_para, audio_para;
100 video_para["codec"] = "h264";
101 video_para["width"] = width;
102 video_para["height"] = height;
103 video_para["crf"] = crf;
104 video_para["preset"] = preset;
105 nlohmann::json encoder_para;
106 encoder_para["output_path"] = "./output.mp4";
107 encoder_para["video_params"] = video_para;
108 auto encode_one_frame = make_sync_func<std::tuple<VideoFrame>, std::tuple<>>(
109 ModuleInfo("c_ffmpeg_encoder"), JsonParam(encoder_para)
110 );
111
112 // encode frame
113 if (width%2==0 && height%2==0) {
114 EXPECT_NO_THROW(encode_one_frame(decoded_vf));
115 } else {
116 EXPECT_THROW(encode_one_frame(decoded_vf), std::exception);
117 }
118}
119
120FUZZ_TEST(ffmpeg_module, fuzz_decode_encode)
121 .WithDomains(AnyEvenCrop(), InRange(0, 51), AnyPreset());

Callers

nothing calls this directly

Calls 3

ModuleInfoFunction · 0.85
decode_one_frameFunction · 0.70
cropMethod · 0.45

Tested by

no test coverage detected