From d2ba1fb50c72ee8bb92111cd32453b741c545769 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 25 Aug 2011 21:47:47 +0200 Subject: [PATCH 1/8] configure: fix typo in avconv dependency list --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d4e352eca3..e26124e8d1 100755 --- a/configure +++ b/configure @@ -1493,8 +1493,8 @@ postproc_deps="gpl" # programs ffmpeg_deps="avcodec avformat swscale" ffmpeg_select="buffer_filter" -av_deps="avcodec avformat swscale" -av_select="buffer_filter" +avconv_deps="avcodec avformat swscale" +avconv_select="buffer_filter" avplay_deps="avcodec avformat swscale sdl" avplay_select="rdft" avprobe_deps="avcodec avformat" From 5f677aac7687a5ceac45b53be5e8fe6ebf07c34d Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 18 Aug 2011 19:03:28 +0200 Subject: [PATCH 2/8] xmv: eliminate superfluous zeroing of zero data Signed-off-by: Diego Biurrun --- libavformat/xmv.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/libavformat/xmv.c b/libavformat/xmv.c index a6081aff7b..4c2400bd85 100644 --- a/libavformat/xmv.c +++ b/libavformat/xmv.c @@ -235,17 +235,8 @@ static int xmv_read_header(AVFormatContext *s, /** Initialize the packet context */ xmv->next_packet_offset = avio_tell(pb); - - xmv->next_packet_size = this_packet_size - xmv->next_packet_offset; - xmv->this_packet_size = 0; - - xmv->video.current_frame = 0; - xmv->video.frame_count = 0; - xmv->video.pts = 0; - xmv->video.last_pts = 0; - - xmv->current_stream = 0; - xmv->stream_count = xmv->audio_track_count + 1; + xmv->next_packet_size = this_packet_size - xmv->next_packet_offset; + xmv->stream_count = xmv->audio_track_count + 1; return 0; } From c960e67ad0f6b318a5f229bb662c899e7e7570d8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 26 Aug 2011 17:40:07 +0200 Subject: [PATCH 3/8] Replace deprecated av_find_stream_info() by avformat_find_stream_info(). --- avprobe.c | 2 +- avserver.c | 4 ++-- libavformat/seek-test.c | 2 +- tools/pktdumper.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/avprobe.c b/avprobe.c index 3843af9b72..d502421416 100644 --- a/avprobe.c +++ b/avprobe.c @@ -277,7 +277,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) /* fill the streams in the format context */ - if ((err = av_find_stream_info(fmt_ctx)) < 0) { + if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) { print_error(filename, err); return err; } diff --git a/avserver.c b/avserver.c index f31b8ddb01..2b028a3f4e 100644 --- a/avserver.c +++ b/avserver.c @@ -2162,7 +2162,7 @@ static int open_input_stream(HTTPContext *c, const char *info) } s->flags |= AVFMT_FLAG_GENPTS; c->fmt_in = s; - if (strcmp(s->iformat->name, "ffm") && av_find_stream_info(c->fmt_in) < 0) { + if (strcmp(s->iformat->name, "ffm") && avformat_find_stream_info(c->fmt_in, NULL) < 0) { http_log("Could not find stream info '%s'\n", input_filename); av_close_input_file(s); return -1; @@ -3621,7 +3621,7 @@ static void build_file_streams(void) } else { /* find all the AVStreams inside and reference them in 'stream' */ - if (av_find_stream_info(infile) < 0) { + if (avformat_find_stream_info(infile, NULL) < 0) { http_log("Could not find codec parameters from '%s'\n", stream->feed_filename); av_close_input_file(infile); diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c index 71b2a2d6c0..3dd60dc160 100644 --- a/libavformat/seek-test.c +++ b/libavformat/seek-test.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) exit(1); } - ret = av_find_stream_info(ic); + ret = avformat_find_stream_info(ic, NULL); if (ret < 0) { fprintf(stderr, "%s: could not find codec parameters\n", filename); exit(1); diff --git a/tools/pktdumper.c b/tools/pktdumper.c index 80816d24b9..56bc7b7ce0 100644 --- a/tools/pktdumper.c +++ b/tools/pktdumper.c @@ -89,9 +89,9 @@ int main(int argc, char **argv) return 1; } - err = av_find_stream_info(fctx); + err = avformat_find_stream_info(fctx, NULL); if (err < 0) { - fprintf(stderr, "av_find_stream_info: error %d\n", err); + fprintf(stderr, "avformat_find_stream_info: error %d\n", err); return 1; } From 0138a8dead3d4874aa9c6f60f64423586c69f4d4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 8 Aug 2011 12:06:26 +0200 Subject: [PATCH 4/8] doxygen: drop pointless star from pointer variable names --- libavcodec/s3tc.h | 8 ++++---- libavutil/fifo.h | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libavcodec/s3tc.h b/libavcodec/s3tc.h index 45da6fa8ac..6e10f43843 100644 --- a/libavcodec/s3tc.h +++ b/libavcodec/s3tc.h @@ -29,8 +29,8 @@ /** * Decode DXT1 encoded data to RGB32 - * @param *src source buffer, has to be aligned on a 4-byte boundary - * @param *dst destination buffer + * @param src source buffer, has to be aligned on a 4-byte boundary + * @param dst destination buffer * @param w width of output image * @param h height of output image * @param stride line size of output image @@ -40,8 +40,8 @@ void ff_decode_dxt1(const uint8_t *src, uint8_t *dst, const unsigned int stride); /** * Decode DXT3 encoded data to RGB32 - * @param *src source buffer, has to be aligned on a 4-byte boundary - * @param *dst destination buffer + * @param src source buffer, has to be aligned on a 4-byte boundary + * @param dst destination buffer * @param w width of output image * @param h height of output image * @param stride line size of output image diff --git a/libavutil/fifo.h b/libavutil/fifo.h index cd361b0222..92319616b9 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -41,20 +41,20 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); /** * Free an AVFifoBuffer. - * @param *f AVFifoBuffer to free + * @param f AVFifoBuffer to free */ void av_fifo_free(AVFifoBuffer *f); /** * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. - * @param *f AVFifoBuffer to reset + * @param f AVFifoBuffer to reset */ void av_fifo_reset(AVFifoBuffer *f); /** * Return the amount of data in bytes in the AVFifoBuffer, that is the * amount of data you can read from it. - * @param *f AVFifoBuffer to read from + * @param f AVFifoBuffer to read from * @return size */ int av_fifo_size(AVFifoBuffer *f); @@ -62,27 +62,27 @@ int av_fifo_size(AVFifoBuffer *f); /** * Return the amount of space in bytes in the AVFifoBuffer, that is the * amount of data you can write into it. - * @param *f AVFifoBuffer to write into + * @param f AVFifoBuffer to write into * @return size */ int av_fifo_space(AVFifoBuffer *f); /** * Feed data from an AVFifoBuffer to a user-supplied callback. - * @param *f AVFifoBuffer to read from + * @param f AVFifoBuffer to read from * @param buf_size number of bytes to read - * @param *func generic read function - * @param *dest data destination + * @param func generic read function + * @param dest data destination */ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** * Feed data from a user-supplied callback to an AVFifoBuffer. - * @param *f AVFifoBuffer to write to - * @param *src data source; non-const since it may be used as a + * @param f AVFifoBuffer to write to + * @param src data source; non-const since it may be used as a * modifiable context by the function defined in func * @param size number of bytes to write - * @param *func generic write function; the first parameter is src, + * @param func generic write function; the first parameter is src, * the second is dest_buf, the third is dest_buf_size. * func must return the number of bytes written to dest_buf, or <= 0 to * indicate no more data available to write. @@ -93,7 +93,7 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void /** * Resize an AVFifoBuffer. - * @param *f AVFifoBuffer to resize + * @param f AVFifoBuffer to resize * @param size new AVFifoBuffer size in bytes * @return <0 for failure, >=0 otherwise */ @@ -101,7 +101,7 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); /** * Read and discard the specified amount of data from an AVFifoBuffer. - * @param *f AVFifoBuffer to read from + * @param f AVFifoBuffer to read from * @param size amount of data to read in bytes */ void av_fifo_drain(AVFifoBuffer *f, int size); From 0249478756091ab62f2d68f4d25f6b095f6723d8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 5 Aug 2011 13:15:04 +0200 Subject: [PATCH 5/8] doxygen: fix wrong comment syntax, //< vs. ///< --- avconv.c | 6 +++--- ffmpeg.c | 6 +++--- libavcodec/aac.h | 10 +++++----- libavcodec/aacps.c | 8 ++++---- libavcodec/aacps.h | 8 ++++---- libavcodec/aacps_tablegen.h | 2 +- libavcodec/avcodec.h | 4 ++-- libavcodec/mpeg4audio.h | 4 ++-- libavcodec/mpegvideo.h | 2 +- libavcodec/snow.c | 2 +- libavcodec/truespeech.c | 14 +++++++------- libavcodec/vp3.c | 2 +- libavfilter/vf_drawbox.c | 2 +- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/avconv.c b/avconv.c index 57721f8fb2..64b2347bf5 100644 --- a/avconv.c +++ b/avconv.c @@ -90,9 +90,9 @@ typedef struct StreamMap { * select an input file for an output file */ typedef struct MetadataMap { - int file; //< file index - char type; //< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram - int index; //< stream/chapter/program number + int file; ///< file index + char type; ///< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram + int index; ///< stream/chapter/program number } MetadataMap; static const OptionDef options[]; diff --git a/ffmpeg.c b/ffmpeg.c index c4ac3f9f62..f2e5bae8b2 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -89,9 +89,9 @@ typedef struct StreamMap { * select an input file for an output file */ typedef struct MetadataMap { - int file; //< file index - char type; //< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram - int index; //< stream/chapter/program number + int file; ///< file index + char type; ///< type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram + int index; ///< stream/chapter/program number } MetadataMap; typedef struct ChapterMap { diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 4861ec0320..0653f810fd 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -104,11 +104,11 @@ enum CouplingPoint { * Output configuration status */ enum OCStatus { - OC_NONE, //< Output unconfigured - OC_TRIAL_PCE, //< Output configuration under trial specified by an inband PCE - OC_TRIAL_FRAME, //< Output configuration under trial specified by a frame header - OC_GLOBAL_HDR, //< Output configuration set in a global header but not yet locked - OC_LOCKED, //< Output configuration locked in place + OC_NONE, ///< Output unconfigured + OC_TRIAL_PCE, ///< Output configuration under trial specified by an inband PCE + OC_TRIAL_FRAME, ///< Output configuration under trial specified by a frame header + OC_GLOBAL_HDR, ///< Output configuration set in a global header but not yet locked + OC_LOCKED, ///< Output configuration locked in place }; /** diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c index 93bdd91dea..d7d6ef88d8 100644 --- a/libavcodec/aacps.c +++ b/libavcodec/aacps.c @@ -28,9 +28,9 @@ #include "aacps_tablegen.h" #include "aacpsdata.c" -#define PS_BASELINE 0 //< Operate in Baseline PS mode - //< Baseline implies 10 or 20 stereo bands, - //< mixing mode A, and no ipd/opd +#define PS_BASELINE 0 ///< Operate in Baseline PS mode + ///< Baseline implies 10 or 20 stereo bands, + ///< mixing mode A, and no ipd/opd #define numQMFSlots 32 //numTimeSlots * RATE @@ -654,7 +654,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3 const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; const float peak_decay_factor = 0.76592833836465f; const float transient_impact = 1.5f; - const float a_smooth = 0.25f; //< Smoothing coefficient + const float a_smooth = 0.25f; ///< Smoothing coefficient int i, k, m, n; int n0 = 0, nL = 32; static const int link_delay[] = { 3, 4, 5 }; diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h index 59a9bff4bc..124fbee221 100644 --- a/libavcodec/aacps.h +++ b/libavcodec/aacps.h @@ -52,11 +52,11 @@ typedef struct { int num_env; int enable_ipdopd; int border_position[PS_MAX_NUM_ENV+1]; - int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //thread_count) int picture_range_start, picture_range_end; ///< the part of picture that this context can allocate in - uint8_t *visualization_buffer[3]; //< temporary buffer vor MV visualization + uint8_t *visualization_buffer[3]; ///< temporary buffer vor MV visualization int last_dc[3]; ///< last DC values for MPEG1 int16_t *dc_val_base; int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous diff --git a/libavcodec/snow.c b/libavcodec/snow.c index b87d8285f6..2af5d234d7 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -3306,7 +3306,7 @@ static void update_last_header_values(SnowContext *s){ static int qscale2qlog(int qscale){ return rint(QROOT*log(qscale / (float)FF_QP2LAMBDA)/log(2)) - + 61*QROOT/8; //<64 >60 + + 61*QROOT/8; ///< 64 > 60 } static int ratecontrol_1pass(SnowContext *s, AVFrame *pict) diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index f8897754eb..6b6d13142f 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -33,13 +33,13 @@ */ typedef struct { /* input data */ - int16_t vector[8]; //< input vector: 5/5/4/4/4/3/3/3 - int offset1[2]; //< 8-bit value, used in one copying offset - int offset2[4]; //< 7-bit value, encodes offsets for copying and for two-point filter - int pulseoff[4]; //< 4-bit offset of pulse values block - int pulsepos[4]; //< 27-bit variable, encodes 7 pulse positions - int pulseval[4]; //< 7x2-bit pulse values - int flag; //< 1-bit flag, shows how to choose filters + int16_t vector[8]; ///< input vector: 5/5/4/4/4/3/3/3 + int offset1[2]; ///< 8-bit value, used in one copying offset + int offset2[4]; ///< 7-bit value, encodes offsets for copying and for two-point filter + int pulseoff[4]; ///< 4-bit offset of pulse values block + int pulsepos[4]; ///< 27-bit variable, encodes 7 pulse positions + int pulseval[4]; ///< 7x2-bit pulse values + int flag; ///< 1-bit flag, shows how to choose filters /* temporary data */ int filtbuf[146]; // some big vector used for storing filters int prevfilt[8]; // filter from previous frame diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 13a3bda4a5..462a482f42 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -225,7 +225,7 @@ typedef struct Vp3DecodeContext { /* these arrays need to be on 16-byte boundaries since SSE2 operations * index into them */ - DECLARE_ALIGNED(16, int16_t, qmat)[3][2][3][64]; // Date: Mon, 30 May 2011 13:19:35 +0200 Subject: [PATCH 6/8] postprocess.c: filter name needs to be double 0 terminated Signed-off-by: Reinhard Tartler --- libpostproc/postprocess.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index ca6d85f4a0..fb51d942e5 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -731,7 +731,8 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) ppMode->maxClippedThreshold= 0.01; ppMode->error=0; - av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE); + memset(temp, 0, GET_MODE_BUFFER_SIZE); + av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE - 1); av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name); @@ -787,7 +788,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) plen= strlen(p); spaceLeft= p - temp + plen; - if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE){ + if(spaceLeft + newlen >= GET_MODE_BUFFER_SIZE - 1){ ppMode->error++; break; } From f2011ed234f580de01768257f3da6e73fbf8ac7b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 29 Jun 2011 17:30:23 +0200 Subject: [PATCH 7/8] fifo: add av_fifo_peek2(), and deprecate av_fifo_peek() The new function provides a more generic interface than av_fifo_peek() for peeking at a FIFO buffer data. Signed-off-by: Anton Khirnov --- doc/APIchanges | 3 +++ libavformat/dvenc.c | 4 ++-- libavutil/avutil.h | 5 ++++- libavutil/fifo.h | 31 ++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index cfce48bfcd..a31268195f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-08-xx - xxxxxx - lavu 51.9.0 + Add av_fifo_peek2(), deprecate av_fifo_peek(). + 2011-08-xx - xxxxxxx - lavf 53.4.0 Add avformat_query_codec(). diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 15b659bc8d..5c55338e2c 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -192,8 +192,8 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr) if (of*2 >= size) continue; - frame_ptr[d] = av_fifo_peek(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit - frame_ptr[d+1] = av_fifo_peek(c->audio_data[channel], of*2); // that DV is a big-endian PCM + frame_ptr[d] = *av_fifo_peek2(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit + frame_ptr[d+1] = *av_fifo_peek2(c->audio_data[channel], of*2); // that DV is a big-endian PCM } frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ } diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 01e4e2fb7f..484659a58b 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 8 +#define LIBAVUTIL_VERSION_MINOR 9 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -63,6 +63,9 @@ #ifndef FF_API_FIND_OPT #define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52) #endif +#ifndef FF_API_AV_FIFO_PEEK +#define FF_API_AV_FIFO_PEEK (LIBAVUTIL_VERSION_MAJOR < 52) +#endif /** * Return the LIBAVUTIL_VERSION_INT constant. diff --git a/libavutil/fifo.h b/libavutil/fifo.h index 92319616b9..961463a2a4 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -25,6 +25,7 @@ #define AVUTIL_FIFO_H #include +#include "avutil.h" typedef struct AVFifoBuffer { uint8_t *buffer; @@ -106,11 +107,35 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); */ void av_fifo_drain(AVFifoBuffer *f, int size); -static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs) +/** + * Return a pointer to the data stored in a FIFO buffer at a certain offset. + * The FIFO buffer is not modified. + * + * @param *f AVFifoBuffer to peek at, f must be non-NULL + * @param offs an offset in bytes, its absolute value must be less + * than the used buffer size or the returned pointer will + * point outside to the buffer data. + * The used buffer size can be checked with av_fifo_size(). + */ +static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) { uint8_t *ptr = f->rptr + offs; if (ptr >= f->end) - ptr -= f->end - f->buffer; - return *ptr; + ptr = f->buffer + (ptr - f->end); + else if (ptr < f->buffer) + ptr = f->end - (f->buffer - ptr); + return ptr; } + +#if FF_API_AV_FIFO_PEEK +/** + * @deprecated Use av_fifo_peek2() instead. + */ +attribute_deprecated +static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs) +{ + return *av_fifo_peek2(f, offs); +} +#endif + #endif /* AVUTIL_FIFO_H */ From 1717ba0cdd587fe3463c1d8560f2c7e13fb21ba3 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Jul 2011 09:49:42 +0200 Subject: [PATCH 8/8] fifo: add FIFO API test program, and fate test Signed-off-by: Anton Khirnov --- libavutil/Makefile | 2 +- libavutil/fifo.c | 36 ++++++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 4 ++++ tests/ref/fate/fifo | 27 +++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/ref/fate/fifo diff --git a/libavutil/Makefile b/libavutil/Makefile index cfe7bae222..bded2c63c5 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -75,7 +75,7 @@ OBJS-$(ARCH_ARM) += arm/cpu.o OBJS-$(ARCH_PPC) += ppc/cpu.o OBJS-$(ARCH_X86) += x86/cpu.o -TESTPROGS = adler32 aes avstring base64 cpu crc des eval file lfg lls \ +TESTPROGS = adler32 aes avstring base64 cpu crc des eval file fifo lfg lls \ md5 opt parseutils rational sha tree TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo diff --git a/libavutil/fifo.c b/libavutil/fifo.c index f87a99dee5..5774d33d25 100644 --- a/libavutil/fifo.c +++ b/libavutil/fifo.c @@ -127,3 +127,39 @@ void av_fifo_drain(AVFifoBuffer *f, int size) f->rptr -= f->end - f->buffer; f->rndx += size; } + +#ifdef TEST + +#undef printf + +int main(void) +{ + /* create a FIFO buffer */ + AVFifoBuffer *fifo = av_fifo_alloc(13 * sizeof(int)); + int i, j, n; + + /* fill data */ + for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++) + av_fifo_generic_write(fifo, &i, sizeof(int), NULL); + + /* peek at FIFO */ + n = av_fifo_size(fifo)/sizeof(int); + for (i = -n+1; i < n; i++) { + int *v = (int *)av_fifo_peek2(fifo, i*sizeof(int)); + printf("%d: %d\n", i, *v); + } + printf("\n"); + + /* read data */ + for (i = 0; av_fifo_size(fifo) >= sizeof(int); i++) { + av_fifo_generic_read(fifo, &j, sizeof(int), NULL); + printf("%d ", j); + } + printf("\n"); + + av_fifo_free(fifo); + + return 0; +} + +#endif diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 4299f081ac..a65b724305 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -25,6 +25,10 @@ FATE_TESTS += fate-eval fate-eval: libavutil/eval-test$(EXESUF) fate-eval: CMD = run libavutil/eval-test +FATE_TESTS += fate-fifo +fate-fifo: libavutil/fifo-test$(EXESUF) +fate-fifo: CMD = run libavutil/fifo-test + FATE_TESTS += fate-md5 fate-md5: libavutil/md5-test$(EXESUF) fate-md5: CMD = run libavutil/md5-test diff --git a/tests/ref/fate/fifo b/tests/ref/fate/fifo new file mode 100644 index 0000000000..18a5691fee --- /dev/null +++ b/tests/ref/fate/fifo @@ -0,0 +1,27 @@ +-12: 1 +-11: 2 +-10: 3 +-9: 4 +-8: 5 +-7: 6 +-6: 7 +-5: 8 +-4: 9 +-3: 10 +-2: 11 +-1: 12 +0: 0 +1: 1 +2: 2 +3: 3 +4: 4 +5: 5 +6: 6 +7: 7 +8: 8 +9: 9 +10: 10 +11: 11 +12: 12 + +0 1 2 3 4 5 6 7 8 9 10 11 12