From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 1/7] lavc/flac_parser: use a custom FIFO implementation Date: Fri, 31 Dec 2021 12:30:33 +0100 Message-ID: <AM7PR03MB66603F923DD437ACDD834A7C8F469@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) In-Reply-To: <20211231105307.30946-1-anton@khirnov.net> Anton Khirnov: > FLAC parser currently uses AVFifoBuffer in a highly non-trivial manner, > modifying its "internals" (the whole struct is currently public, but no > other code touches its contents directly). E.g. it does not use any > av_fifo functions for reading the FIFO contents, but implements its own. > > Reimplement the needed parts of the AVFifoBuffer API in the FLAC parser, > making it completely self-contained. This will allow us to make > AVFifoBuffer private. > --- > libavcodec/flac_parser.c | 191 +++++++++++++++++++++++++++++++-------- > 1 file changed, 153 insertions(+), 38 deletions(-) > > diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c > index 3b27b152fc..d6af5ce836 100644 > --- a/libavcodec/flac_parser.c > +++ b/libavcodec/flac_parser.c > @@ -34,7 +34,6 @@ > > #include "libavutil/attributes.h" > #include "libavutil/crc.h" > -#include "libavutil/fifo.h" > #include "bytestream.h" > #include "parser.h" > #include "flac.h" > @@ -57,6 +56,15 @@ > #define MAX_FRAME_HEADER_SIZE 16 > #define MAX_FRAME_VERIFY_SIZE (MAX_FRAME_HEADER_SIZE + 1) > > +typedef struct FifoBuffer { > + uint8_t *buffer; > + uint8_t *end; > + uint8_t *rptr; > + uint8_t *wptr; > + size_t rndx; > + size_t wndx; > +} FifoBuffer; > + > typedef struct FLACHeaderMarker { > int offset; /**< byte offset from start of FLACParseContext->buffer */ > int link_penalty[FLAC_MAX_SEQUENTIAL_HEADERS]; /**< array of local scores > @@ -84,7 +92,7 @@ typedef struct FLACParseContext { > int nb_headers_buffered; /**< number of headers that are buffered */ > int best_header_valid; /**< flag set when the parser returns junk; > if set return best_header next time */ > - AVFifoBuffer *fifo_buf; /**< buffer to store all data until headers > + FifoBuffer fifo_buf; /**< buffer to store all data until headers > can be verified */ > int end_padded; /**< specifies if fifo_buf's end is padded */ > uint8_t *wrap_buf; /**< general fifo read buffer when wrapped */ > @@ -127,6 +135,17 @@ static int frame_header_is_valid(AVCodecContext *avctx, const uint8_t *buf, > return 1; > } > > +static size_t flac_fifo_size(FifoBuffer *f) Missing const > +{ > + av_assert0(f->wndx >= f->rndx); This assert looks very fishy: It will trigger if wndx has already wrapped around while rndx has not yet (or rather, if wndx has wrapped around once more than rndx). Or am I missing something here? > + return f->wndx - f->rndx; > +} > + > +static size_t flac_fifo_space(FifoBuffer *f) > +{ > + return f->end - f->buffer - flac_fifo_size(f); > +} > + _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2021-12-31 11:30 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-31 10:53 Anton Khirnov 2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 2/7] lavf/dvenc: replace av_fifo_peek2() with av_fifo_generic_peek_at() Anton Khirnov 2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 3/7] lavu/fifo: deprecate av_fifo_peek2() Anton Khirnov 2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 4/7] lavu/fifo: simplify av_fifo_alloc() Anton Khirnov 2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 5/7] lavu/fifo: do not copy the whole fifo when reallocating Anton Khirnov 2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 6/7] lavu/fifo: drop useless comments Anton Khirnov 2021-12-31 11:47 ` Andreas Rheinhardt 2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 7/7] lavu/fifo: return errors on trying to read/write too much Anton Khirnov 2021-12-31 11:30 ` Andreas Rheinhardt [this message] 2022-01-02 14:24 ` [FFmpeg-devel] [PATCH] lavc/flac_parser: use a custom FIFO implementation Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AM7PR03MB66603F923DD437ACDD834A7C8F469@AM7PR03MB6660.eurprd03.prod.outlook.com \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git