av/codec/h264/h264dec/fuzz/helpers.h

60 lines
1.6 KiB
C

/*
DESCRIPTION
helpers.h defines some structs and function signatures that will help to
interface with C code used in our fuzz testing.
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
LICENSE
Copyright (C) 2019 the Australian Ocean Lab (AusOcean).
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
#ifndef HELPERS_H
#define HELPERS_H
#include <stdlib.h>
#include <stdint.h>
struct Reader {
char* data;
int curr;
int len;
int err;
};
struct BitReader {
struct Reader* r;
uint64_t n;
int bits;
int nRead;
int err;
};
// new_BitReader returns a new instance of a BitReader given the backing array
// d and the length of the data l.
struct BitReader* new_BitReader(char*, int);
// next_byte provides the next byte from a Reader r and advances it's byte index.
char next_byte(struct Reader*);
// read_bits intends to emulate the BitReader.ReadBits function defined in the
// bits package. This is used when a bit reader is required to obtain bytes from
// a stream in the C test code.
uint64_t read_bits(struct BitReader*, int);
#endif // HELPERS_H