Go to the documentation of this file.
43 #define FLAC_MAX_SEQUENTIAL_HEADERS 4
45 #define FLAC_MIN_HEADERS 10
47 #define FLAC_AVG_FRAME_SIZE 8192
50 #define FLAC_HEADER_BASE_SCORE 10
51 #define FLAC_HEADER_CHANGED_PENALTY 7
52 #define FLAC_HEADER_CRC_FAIL_PENALTY 50
53 #define FLAC_HEADER_NOT_PENALIZED_YET 100000
54 #define FLAC_HEADER_NOT_SCORED_YET -100000
57 #define MAX_FRAME_HEADER_SIZE 16
117 uint8_t **wrap_buf,
int *allocated_size)
124 start -=
f->end -
f->buffer;
125 if (
f->end - start >=
len)
132 "couldn't reallocate wrap buffer of size %d",
len);
137 int seg_len =
FFMIN(
f->end - start,
len);
138 memcpy(tmp_buf, start, seg_len);
139 tmp_buf = (
uint8_t*)tmp_buf + seg_len;
142 start += seg_len - (
f->end -
f->buffer);
162 start -=
f->end -
f->buffer;
181 while (*end_handle) {
182 end_handle = &(*end_handle)->
next;
186 *end_handle =
av_mallocz(
sizeof(**end_handle));
189 "couldn't allocate FLACHeaderMarker\n");
192 (*end_handle)->fi = fi;
193 (*end_handle)->offset =
offset;
205 int buf_size,
int search_start)
207 int size = 0, mod_offset = (buf_size - 1) % 4,
i, j;
210 for (
i = 0;
i < mod_offset;
i++) {
211 if ((
AV_RB16(buf +
i) & 0xFFFE) == 0xFFF8) {
217 for (;
i < buf_size - 1;
i += 4) {
219 if (((
x & ~(
x + 0x01010101)) & 0x80808080)) {
220 for (j = 0; j < 4; j++) {
221 if ((
AV_RB16(buf +
i + j) & 0xFFFE) == 0xFFF8) {
234 int search_end,
size = 0, read_len,
temp;
240 read_len = search_end - search_start + 1;
243 search_start += read_len - 1;
246 if (search_start != search_end) {
249 wrap[0] = buf[read_len - 1];
251 read_len = search_end - (search_start + 1) + 1;
265 search_start += read_len - 1;
278 int log_level_offset)
281 if (child_fi->samplerate != header_fi->samplerate) {
284 "sample rate change detected in adjacent frames\n");
286 if (child_fi->bps != header_fi->bps) {
289 "bits per sample change detected in adjacent frames\n");
295 "blocking strategy change detected in adjacent frames\n");
297 if (child_fi->channels != header_fi->channels) {
300 "number of channels change detected in adjacent frames\n");
308 int log_level_offset)
311 int deduction, deduction_expected = 0,
i;
317 (child_fi->frame_or_sample_num
320 int64_t expected_frame_num, expected_sample_num;
326 while (curr != child) {
330 expected_frame_num++;
338 if (expected_frame_num == child_fi->frame_or_sample_num ||
339 expected_sample_num == child_fi->frame_or_sample_num)
340 deduction_expected = deduction ? 0 : 1;
344 "sample/frame number mismatch in adjacent frames\n");
348 if (deduction && !deduction_expected) {
353 int inverted_test = 0;
371 while (start->
next != child)
375 header->next->link_penalty[
i-1] >=
384 read_len = (
end->offset - start->
offset) - read_len;
392 if (!crc ^ !inverted_test) {
395 "crc check failed from offset %i (frame %"PRId64
") to %i (frame %"PRId64
")\n",
397 child->
offset, child_fi->frame_or_sample_num);
429 header->max_score = base_score;
444 header->best_child = child;
445 header->max_score = base_score + child_score;
462 for (curr = fpc->
headers; curr; curr = curr->
next) {
497 if (
header->fi.is_var_size)
499 else if (
header->best_child)
515 const uint8_t **poutbuf,
int *poutbuf_size,
516 const uint8_t *buf,
int buf_size)
522 const uint8_t *read_start = buf;
537 *poutbuf_size = buf_size;
551 for (curr = fpc->
headers; curr != best_child; curr =
temp) {
554 "dropping low score %i frame header from offset %i to %i\n",
565 for (curr = best_child->
next; curr; curr = curr->
next)
593 while ((buf_size && read_end < buf + buf_size &&
606 read_end = read_end +
FFMIN(buf + buf_size - read_end,
630 read_end - read_start,
NULL);
639 start_offset =
FFMAX(0, start_offset);
642 if (nb_headers < 0) {
644 "find_new_headers couldn't allocate FLAC header\n");
651 if (read_end < buf + buf_size) {
652 read_start = read_end;
673 read_start = read_end =
NULL;
677 for (curr = fpc->
headers; curr; curr = curr->
next) {
712 return buf_size ? read_end - buf : 0;
724 "couldn't allocate fifo_buf\n");
FLACHeaderMarker * headers
linked-list that starts at the first CRC-8 verified header within buffer
#define FLAC_HEADER_BASE_SCORE
scoring settings for score_header
static int frame_header_is_valid(AVCodecContext *avctx, const uint8_t *buf, FLACFrameInfo *fi)
#define AV_LOG_WARNING
Something somehow does not look correct.
static int check_header_fi_mismatch(FLACParseContext *fpc, FLACFrameInfo *header_fi, FLACFrameInfo *child_fi, int log_level_offset)
int nb_headers_buffered
number of headers that are buffered
static int find_new_headers(FLACParseContext *fpc, int search_start)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
uint64_t channel_layout
Audio channel layout.
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
int sample_rate
samples per second
int duration
Duration of the current frame.
static av_cold int end(AVCodecContext *avctx)
uint8_t * wrap_buf
general fifo read buffer when wrapped
int64_t frame_or_sample_num
frame number or sample number
int is_var_size
specifies if the stream uses variable block sizes or a fixed block size; also determines the meaning ...
static void score_sequences(FLACParseContext *fpc)
int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset)
Validate and decode a frame header.
#define FLAC_HEADER_CHANGED_PENALTY
#define FLAC_MAX_SEQUENTIAL_HEADERS
maximum number of adjacent headers that compare CRCs against each other
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int wrap_buf_allocated_size
actual allocated size of the buffer
void av_fifo_drain(AVFifoBuffer *f, int size)
Discard data from the FIFO.
static uint8_t * flac_fifo_read_wrap(FLACParseContext *fpc, int offset, int len, uint8_t **wrap_buf, int *allocated_size)
Non-destructive fast fifo pointer fetching Returns a pointer from the specified offset.
AVFifoBuffer * fifo_buf
buffer to store all data until headers can be verified
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
int best_header_valid
flag set when the parser returns junk; if set return best_header next time
static uint8_t * flac_fifo_read(FLACParseContext *fpc, int offset, int *len)
Return a pointer in the fifo buffer where the offset starts at until the wrap point or end of request...
static int get_best_header(FLACParseContext *fpc, const uint8_t **poutbuf, int *poutbuf_size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_fifo_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
#define FLAC_AVG_FRAME_SIZE
estimate for average size of a FLAC frame
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int last_fi_valid
set if last_fi is valid
AVCodecContext * avctx
codec context pointer for logging
static int find_headers_search_validate(FLACParseContext *fpc, int offset)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVCodecParserContext * pc
parent context
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
AVCodecParser ff_flac_parser
static int score_header(FLACParseContext *fpc, FLACHeaderMarker *header)
Score a header.
#define PTRDIFF_SPECIFIER
FLACCOMMONINFO int blocksize
block size of the frame
static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int find_headers_search(FLACParseContext *fpc, uint8_t *buf, int buf_size, int search_start)
void ff_flac_set_channel_layout(AVCodecContext *avctx)
#define FLAC_HEADER_CRC_FAIL_PENALTY
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define FLAC_HEADER_NOT_SCORED_YET
static const uint8_t header[24]
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static av_cold int flac_parse_init(AVCodecParserContext *c)
int channels
number of audio channels
FLACHeaderMarker * best_header
highest scoring header within buffer
#define PARSER_FLAG_COMPLETE_FRAMES
#define i(width, name, range_min, range_max)
int end_padded
specifies if fifo_buf's end is padded
AVFifoBuffer * av_fifo_alloc_array(size_t nmemb, size_t size)
Initialize an AVFifoBuffer.
static int check_header_mismatch(FLACParseContext *fpc, FLACHeaderMarker *header, FLACHeaderMarker *child, int log_level_offset)
int nb_headers_found
number of headers found in the last flac_parse() call
#define MAX_FRAME_HEADER_SIZE
largest possible size of flac header
main external API structure.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define PARSER_FLAG_USE_CODEC_TS
#define FLAC_MIN_HEADERS
minimum number of headers buffered and checked before returning frames
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
#define FLAC_HEADER_NOT_PENALIZED_YET
FLACFrameInfo last_fi
last decoded frame header info
static void flac_parse_close(AVCodecParserContext *c)