My purpose is to decode flac data for testing purposes. I'm going to create a small stub that has a function that takes data and size as input arguments. There is no need to make anykind of output file because I'm only going to make test for decoding. I have read some examples and api documentation from libflac page (http://ift.tt/29hTvBq).
Now this is giving me :ERROR: initializing decoder: (null) because FLAC__stream_decoder_init_stream is commented. Reason it is commented is that I don't know how to properly use it and get decoding work. Any advice and comments that could help me to get decoding work?
#include <stdio.h>
#include <stdlib.h>
#include "share/compat.h"
#include "FLAC/stream_decoder.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FLAC__bool ok = true;
FLAC__StreamDecoder *decoder = 0;
FLAC__StreamDecoderInitStatus init_status;
// init decoder
if((decoder = FLAC__stream_decoder_new()) == NULL) {
fprintf(stderr, "ERROR: allocating decoder\n");
return 1;
}
(void)FLAC__stream_decoder_set_md5_checking(decoder, true);
//init_status = FLAC__stream_decoder_init_stream ( decoder, read_callback, /*seek_callback*/ NULL, /*tell_callback*/ NULL, /*length_callback*/ NULL, /*eof_callback*/ NULL, write_callback,/*metadata_callback*/,error_callback,client_data);
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]);
ok = false;
}
if(ok) {
ok = FLAC__stream_decoder_process_until_end_of_stream(decoder);
fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED");
fprintf(stderr, " state: %s\n", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)]);
}
FLAC__stream_decoder_delete(decoder);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire