webrtc/test/fuzzers/frame_buffer3_fuzzer.cc
philipel ceac5d560e New FrameBuffer3.
FrameBuffer3 keep track of order, decodability and continuity of the inserted frames. Compared to FrameBuffer2 which schedule frames for decoding and is thread safe, FrameBuffer3 does not schedule decoding and is thread unsafe.

Change-Id: Ic3bd540c4f69cec26fce53a40425f3bcd9afe085
Bug: webrtc:13343
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238985
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35494}
2021-12-07 18:31:37 +00:00

81 lines
2.3 KiB
C++

/*
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/array_view.h"
#include "api/video/encoded_frame.h"
#include "modules/video_coding/frame_buffer3.h"
#include "test/fuzzers/fuzz_data_helper.h"
namespace webrtc {
namespace {
class FuzzyFrameObject : public EncodedFrame {
public:
int64_t ReceivedTime() const override { return 0; }
int64_t RenderTime() const override { return 0; }
};
} // namespace
void FuzzOneInput(const uint8_t* data, size_t size) {
if (size > 10000) {
return;
}
FrameBuffer buffer(/*max_frame_slots=*/100, /*max_decode_history=*/1000);
test::FuzzDataHelper helper(rtc::MakeArrayView(data, size));
while (helper.BytesLeft() > 0) {
int action = helper.ReadOrDefaultValue<uint8_t>(0) % 7;
switch (action) {
case 0: {
buffer.LastContinuousFrameId();
break;
}
case 1: {
buffer.LastContinuousTemporalUnitFrameId();
break;
}
case 2: {
buffer.NextDecodableTemporalUnitRtpTimestamp();
break;
}
case 3: {
buffer.LastDecodableTemporalUnitRtpTimestamp();
break;
}
case 4: {
buffer.ExtractNextDecodableTemporalUnit();
break;
}
case 5: {
buffer.DropNextDecodableTemporalUnit();
break;
}
case 6: {
auto frame = std::make_unique<FuzzyFrameObject>();
frame->SetTimestamp(helper.ReadOrDefaultValue<uint32_t>(0));
frame->SetId(helper.ReadOrDefaultValue<int64_t>(0));
frame->is_last_spatial_layer = helper.ReadOrDefaultValue<bool>(false);
frame->num_references = helper.ReadOrDefaultValue<uint8_t>(0) %
EncodedFrame::kMaxFrameReferences;
for (uint8_t i = 0; i < frame->num_references; ++i) {
frame->references[i] = helper.ReadOrDefaultValue<int64_t>(0);
}
buffer.InsertFrame(std::move(frame));
break;
}
}
}
}
} // namespace webrtc