Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-06-16 07:25:18 +0400
committerMichael Niedermayer <michaelni@gmx.at>2011-06-16 08:29:01 +0400
commit56629aa0127e7f8f2f5dad3ebe794424b51afd64 (patch)
tree3882ab613274639d8f30e48d15e04cff2cf8a3fb /libavfilter
parent33651e3edffcf404e7dce33395b31b1113e5d4b2 (diff)
parent7a02527b05e2ae5ffab579062dbe3c888758335f (diff)
Merge branch 'master' into oldabi
* master: mmsh: fixed printf injection bug in mmsh request ac3enc: use correct alignment and length in channel coupling dsp functions. ffmpeg: don't abuse a global for passing framerate from input to output ffmpeg: don't abuse a global for passing channels from input to output ffmpeg: don't abuse a global for passing samplerate from input to output Make buffer size check consistent and avoid a possible overflow. Fix spelling. Full support for sending H.264 in RTP ARM: update ff_h264_idct8_add4_neon for 4:4:4 changes swscale: use SwsContext for av_log when available Support reading chan atoms with empty channel descriptions. Reindent after last commit. Fix multi-channel AAC encoding. Fix "redundant redeclaration" warning. Fix compilation with --disable-everything --enable-encoder=ac3/ac3_fixed. vf_mp: Fix large memleak. swscale: Remove HAVE_MMX from files that are only compiled with MMX enabled. swscale: Fix compilation with --disable-mmx2. mjpegenc: Fix JFIF version swscale: remove misplaced comment. ffmpeg: fix streaming to ffserver. swscale: split out RGB48 output functions from yuv2packed[12X]_c(). build: move vpath directives to main Makefile swscale: fix JPEG-range YUV scaling artifacts. build: move ALLFFLIBS to a more logical place ARM: factor some repetitive code into macros CrystalHD: Use mp4toannexb bitstream filter. CrystalHD: Keep mp4toannexb filter around for entire decoder lifetime. Fix SVQ3 after adding 4:4:4 H.264 support H.264: fix CODEC_FLAG_GRAY 4:4:4 H.264 decoding support matroskadec: properly decode color space in an endian neutral way matroskadec: use a temporary fourcc variable matroskaenc: ensure the written colorspace don't depend on host endianness ac3enc: fix allocation of floating point samples. utils: Drop pointless '#if 1' preprocessor directive. ac3enc: remove empty ac3_float function that is never called ac3enc: split templated float vs. fixed functions into a separate file. ac3enc: dynamically allocate AC3EncodeContext fields windowed_samples and mdct ac3enc: use function pointer to choose between AC-3 and E-AC-3 header output functions. Roll back 4:4:4 H.264 for now Needs some ARM/PPC asm modifications. Fix SVQ3 after adding 4:4:4 H.264 support H.264: fix CODEC_FLAG_GRAY 4:4:4 H.264 decoding support h264_parser: Fix whitespace after previous change. h264_parser: Fix behaviour when PARSER_FLAG_COMPLETE_FRAMES is set. wav: remove an invalid free(). lavf: initialise reference_dts in av_estimate_timings_from_pts. h264: don't be so picky on decoding pps in extradata. avcodec.h: add or elaborate on some documentation comments. h264: change a few comments into error messages ac3dec: fix doxy-style for comment ("///>" should be "///<" instead). img2: add .dpx to the list of supported file extensions. ffv1: fix undefined behavior with insane widths. replace remaining usage of deprecated av_metadata_set2() by av_dict_set() matroskaenc: write colourspace element for rawvideo tracks nsv: simplify probe function nsv: return error code instead of discarding it in read_header() ARM: jrevdct_arm: simplify stack usage ARM: jrevdct_arm: use push/pop mnemonics ARM: jrevdct_arm: misc cleanup ARM: optimised mpadsp_apply_window_fixed Add some (important) changelog entries H264: Reduce pointless diffs to qatar Revert "H264: Split out hl_motion and template it, this seems a bit faster" libavfilter: implement avfilter_fill_frame_from_video_buffer_ref() avfiltergraph: make the AVFilterInOut alloc/free API public avfiltergraph: change the syntax of avfilter_graph_parse() graphparser: prefer void * over AVClass * for log contexts h264: Complexify frame num gap shortening code Update todo mpeg12: replace 2 asserts by av_assert0 cmdutils: add missing NULL check in parse_options() x11grab: remove a memory allocation and the associated memcpy. Fix --disable-everything build: fix "make install" with documentation disabled build: simplify some conditional targets resample: clarify supported resampling. lavfi: fix signature for avfilter_graph_parse() and avfilter_graph_config() avfiltergraph: use meaningful error codes Revert "ac3: there was no libav in 2010 thus this code cannot be from libav." Fix -t option for formats which holds dts and no pts dnxhd: Renama tables Extract rotation in MOV metadata bitstream: Properly promote av_reverse values before shifting. pixfmt: Replace 9/10bit deprecation by a technical explanation. libavutil/swscale: YUV444P10/YUV444P9 support. H.264: Fix high bit depth explicit biweight h264: Fix 10-bit H.264 x86 chroma v loopfilter asm. Replace DEBUG_SEEK/DEBUG_SI + av_log combinations by av_dlog. Update copyright year for ac3enc_opts_template.c. adts: Adjust frame size mask to follow the specification. APIchanges: fill hash for the avfilter_get_audio_buffer_ref_from_arrays addition lavfi: avfilter_merge_formats: handle case where inputs are same lavfi: use avfilter_get_audio_buffer_ref_from_arrays() in defaults.c lavfi: implement avfilter_get_audio_buffer_ref_from_arrays() APIchanges: remove duplicated entry APIchanges: fill in dates and numbers APIchanges: remove duplicated entry APIchanges: correctly interleave entries APIchanges: add entry for av_force_cpu_flags() addition lavf: bump minor after the addition of fps_probe_size to AVFormatContext lavc: bump minor after the addition of AVCodecContext.request_sample_fmt movenc: Add RTP muxer/hinter options movenc: Pass the RTP AVFormatContext to the SDP generation rtspenc: Add RTP muxer options rtspenc: Add an AVClass for setting muxer specific options rtpenc_chain: Pass the rtpflags options through to the chained muxer rtpenc: Declare the rtp flags private AVOptions in rtpenc.h sdp: Reindent after the previous commit rtpenc: MP4A-LATM payload support avoptions: Add an av_opt_flag_is_set function for inspecting flag fields sdp: Allow passing an AVFormatContext to the SDP generation mov: Fix wrong timestamp generation for fragmented movies that have time offset caused by the first edit list entry. mpeg12: more advanced ffmpeg mpeg2 aspect guessing code. ac3: there was no libav in 2010 thus this code cannot be from libav. swscale: split YUYV output out of yuv2packed[12X]_c(). dict: This code was developed in ffmpeg and not libav, nor by libav developers. Correct copyright notices. lavf: make compute_pkt_fields2() return meaningful error values matroskadec: set timestamps for RealAudio packets. intelh263dec: aspect ratio processing fix. intelh263dec: fix "Strict H.263 compliance" file playback oss,sndio: simplify by using FFMIN. swscale: extract monowhite/black output from yuv2packed[12X]_c(). swscale: de-macro'ify RGB15/16/32 input functions. swscale: rearrange code. movdec: Add support for the 'wfex' atom. ffmpeg.c: Add a necessary const qualifier riff: Fix potential memleak. swscale: change 48bit RGB input macros to inline functions. swscale: change 9/10bit YUV input macros to inline functions. swscale: extract gray16 output functions from yuv2packed[12X](). swscale: use standard clipping functions. swscale: merge macros that are used only once. swscale: fix function declarations in swscale.c. swscale: fix function declaration keywords in x86/swscale_template.c. jpegdec: actually search for and parse RSTn crypto: Use av_freep instead of av_free Revert "crypto: fix potential double free" Revert "build: remove empty $(OBJS) target" crypto: Use av_freep instead of av_free aac: fix adts frame size mask, fix demuxer probing for some files. lavf: don't try to free private options if priv_data is NULL. lavfi: handle NULL lists in avfilter_make_format_list swscale: fix types of assembly arguments. swscale: move two macros that are only used once into caller. swscale: remove unused function. Fix "mixed declarations and code" warnings. options: Add missing braces around struct initializer. mov: Remove leftover crufty debug statement with references to a local file. dvbsubdec: Fix compilation of debug code. Remove all uses of now deprecated metadata functions. Move metadata API from lavf to lavu. crypto: fix potential double free libx264: fix double free ffplay: remove -debug option ffplay: remove -vismv option mpegvideo: use av_get_picture_type_char() in ff_print_debug_info() Remove some non-compiling debug messages. ffplay: Fix non-compiling debug printf and replace it by av_dlog. H264: x86 predict init cosmetics. ac3enc: Fix linking of AC-3 encoder without the E-AC-3 encoder. Move E-AC-3 encoder functions to a separate eac3enc.c file. ac3enc: remove convenience macro, #define DEBUG ac3enc: remove unused #define vc1: re-initialize tables after width/height change. APIchanges: fill-in git commit hash for av_get_bytes_per_sample() addition samplefmt: add av_get_bytes_per_sample() libvpxenc: add forgotten AVClass. iirfilter: fix biquad filter coefficients. swscale: remove duplicate conversion routine in swScale(). swscale: add yuv2planar/packed function typedefs. swscale: integrate yuv2nv12X_C into yuv2yuvX() function pointers. swscale: reindent x86 init code. swscale: extract SWS_FULL_CHR_H_INT conditional into init code. swscale: cosmetics. swscale: remove alp/chr/lumSrcOffset. swscale: un-special-case yuv2yuvX16_c(). shorten: Remove stray DEBUG #define and corresponding av_dlog statement. vorbisdec: Restore mistakenly removed debug output. v4l2: set default standard to NULL sws: make dither_scale const configure: Document --enable-vdpau. Replace some av_log/printf + #ifdef combinations by av_dlog. Replace some nonstandard DEBUG_* preprocessor directives by plain DEBUG. svq1dec: Fix debug statements that referenced non-existing context. Replace some printf instances in debug code by av_log. showfiltfmts: use av_get_pix_fmt_name() inverse.c: Replace unnecessary intmath.h header by necessary stdint.h. Drop unnecessary directory prefixes from #include directives. Makefile: critical build fix after the merge. make fate passed locally due to ffmpeg/ffmpeg_g being there from before ffplay: Fix -vismv mem: Trying to workaround posix_memalign() bug on OSX build: remove empty $(OBJS) target build: make rule for linking ff* apply only to these targets eval: add support for pow() function build: rearrange some lines in a more logical way s302m: fix resampling for 16 and 24bits. ARM: remove MUL64 and MAC64 inline asm build: clean up .PHONY lists build: move all (un)install* target aliases to toplevel Makefile flvenc: propagate error properly build: remove stale dependency build: do not add CFLAGS-yes to CFLAGS utils.c: fix crash with threading enabled. configure: simplify source_path setup configure: remove --source-path option pixdesc: remove duplicated header inclusion lavfi: use av_samples_alloc() in avfilter_default_get_audio_buffer() lavfi: prefer nb_samples over size in AVFilterBufferRefAudioProps samplefmt: switch nb_channels/nb_samples params order in av_samples_alloc() samplefmt: change layout for arrays created by av_samples_alloc() and _fill_arrays() lavf: deprecate AVFormatParameters.time_base. img2: add framerate private option. img2: add video_size private option. img2: add pixel_format private option. tty: add framerate private option. Move code for "ffmpeg: fix massive leak occurring when seeking" / e4841a404bdabfeafb917454d510b60d888cb761 elsewhere lavf: remove reference to output-example in Makefile vsrc_buffer: add flags param to av_vsrc_buffer_add_video_buffer_ref Remove some unused scripts from tools/. Add x86 assembly for some 10-bit H.264 intra predict functions. v4l2: do not force NTSC as standard Add const to avfilter_get_video_buffer_ref_from_arrays arguments. Skip tableprint.h during 'make checkheaders'. Remove unnecessary LIBAVFORMAT_BUILD #ifdef. Drop explicit filenames from @file Doxygen tags. Skip generated table headers during 'make checkheaders'. lavf,lavc: free avoptions in a generic way. AVOptions: add av_opt_free convenience function. sdl: align option fields after last commit ffmpeg: fix massive leak occurring when seeking ffprobe: implement -i FILE option tableprint: Restore mistakenly deleted common.h #include for FF_ARRAY_ELEMS. ffplay.texi: document -i FILE option cmdutils: remove unnecessary OPT_DUMMY implementation cmdutils: change the signature of the function argument in parse_options() sdl: use the filename for defining the window title, if not specified tiff: print log in case of unknown / unsupported tag. tiff: fix linesize for mono-white/black formats. Fix build of eval-test program configure: Document --enable-vaapi swscale: override the lack of the accurate rounding flag when needed for dither. swscale: factor should_dither out ac3enc: extract all exponents for the frame at once ARM: remove MULL inline asm mathops: use MUL64 macro where it forms part of other ops tty: factorise returning error codes. rawdec: add framerate private option. x11grab: add framerate private option. fbdev,v4l2: remove some forgotten uses of AVFormatParameters.time_base. bktr: don't error when AVFormatParameters.time_base isn't set. cmdutils: add missing const qualifier Skip headers not designed to work standalone during 'make checkheaders'. Add missing #includes to make headers self-contained. musepack: remove unnecessary #include from mpcdata.h musepack: remove extraneous mpcdata.h inclusions Fix error check in av_file_map() udp: support old, crappy non pthread mode ffmpeg: use opt_acodec when setting audio codec in opt_target. ffmpeg: fix segfault with too many output files ffplay: error out with invalid sample rate or channels. oggdec: fix Ticket185 build: simplify commands for clean target j2kdec: dont fail on non zero cblock style. makefile: fix j2k encoder dependancies udp: fix indention swscale: split swscale.c in unscaled and generic conversion routines. swscale: cosmetics. swscale: integrate (literally) swscale_template.c in swscale.c. swscale: split out x86/swscale_template.c from swscale.c. swscale: enable hScale_altivec_real. swscale: split out ppc _template.c files from main swscale.c. swscale: remove indirections in ppc/swscale_template.c. swscale: split out unscaled altivec YUV converters in their own file. mpegvideoenc: fix multislice fate tests with threading disabled. cmdutils: move "#undef main" from ffplay.c to cmdutils.h wav: update size check for ds64 wav: fix skip size at end of ds64 chunk mpegts: Wrap #ifdef DEBUG and av_hex_dump_log() combination in a macro. build: Simplify texi2html invocation through the --output option. Mark some variables with av_unused Replace avcodec_get_pix_fmt_name() by av_get_pix_fmt_name(). svq3: Check negative mb_type to fix potential crash. svq3: Move svq3-specific fields to their own context. rawdec: initialize return value to 0. Remove unused get_psnr() prototype rawdec: don't leak option strings. bktr: get default framerate from video standard. swscale: remove unused COMPILE_TEMPLATE_ALTIVEC. h264 fill_filter_caches: Dont init chroma nnz_cache. In print_report, print progression time in hours:mins:secs:us ffmpeg: In print_report, use int64_t for pts to check for 0 and avoid inf value for bitrate. In libswscale, use all lines when converting from 422p to rgb with mmx, improve quality. Replace custom DEBUG preprocessor trickery by the standard one. vorbis: Remove non-compiling debug statement. vorbis: Remove pointless DEBUG #ifdef around debug output macros. cook: Remove non-compiling debug output. Remove pointless #ifdefs around function declarations in a header. Replace #ifdef + av_log() combinations by av_dlog(). Replace custom debug output functions by av_dlog(). cook: Remove unused debug functions. lavfi: add avfilter_link_free() function swscale: reintroduce sws_format_name() symbol Remove stray extra arguments from av_dlog() invocations. targa: fix big-endian build v4l2: remove one forgotten use of AVFormatParameters.pix_fmt. vfwcap: add a framerate private option. v4l2: add a framerate private option. libdc1394: add a framerate private option. fbdev: add a framerate private option. bktr: add a framerate private option. oma: check avio_read() return value nutdec: remove unused variable Remove unused variables swscale: dither for planar yuv outputs swscale: Fix use of uninitialized values (bug probably introduced from a marge of libav) cpudetect: add av_force_cpu_flags() swscale: allocate larger buffer to handle altivec overreads. H264/MPEG frame-level multi-threading. vsrc_buffer: propagate error code in av_vsrc_buffer_add_frame() lavfi: reindent after the previous commit lavfi: add braces around the block of an if() expression in avfilter_default_get_video_buffer lavfi: clarify the context of a comment in avfilter_default_get_video_buffer() lavfi: apply misc style fixes Cosmetic changes to h264_idct_10bit.asm. 2x faster h264_idct_add8_10. aacenc: Add stereo_mode option. h264: remove CONFIG_GPL from x86 intra prediction code. doc: cosmetics: libx264 typos postprocess: Remove test for impossible condition (was: Re: postprocess.c: replace check for p==NULL with *p==0) Fix various uninitialized variable warnings Port remove of get_sws_cpuflags from MPlayer's libmpcodecs. Replace "vector const" by "const vector" otherwise gcc 4.6.0 fails. Port recent changes to MPlayer libmpcodecs. Replace non-existent HAVE_SSE2 with HAVE_SSE. Simplify code and avoid compiler warning about incompatible types. Fix type of out[] variable, it should not be const. ARM: ac3dsp: optimised update_bap_counts() mpegaudiodec: Fix av_dlog() invocation. swscale: fix compilation of bfin due to missing pixdesc.h header lavf: tag dump_format() as @deprecated yuv4mpeg: complain and exit if a non-rawvideo stream is selected ffmpeg: handle copy of packets for AVFMT_RAWPICTURE output formats doc/examples: give meaningful names to the example files h264/10bit: add HAVE_ALIGNED_STACK checks. swscale: More accurate rounding in YSCALE_YUV_2_PACKEDX_FULL_C() Update 8-bit H.264 IDCT function names to reflect bit-depth. Add IDCT functions for 10-bit H.264. mpegaudioenc: Fix broken av_dlog statement. Employ correct printf format specifiers, mostly in debug output. ARM: fix MUL64 inline asm for pre-armv6 doc: add libvpx encoder section vf_drawtext: Replace FFmpeg by Libav in license boilerplate. mpegaudiodec: remove unusued code and variables postprocess.c: filter name needs to be double 0 terminated improved 'edts' atom writing support mpegaudio: clean up compute_antialias() definition vp8: fix segmentation race during frame-threading. Port libmpcodec fixes from MPlayer. Merge remote-tracking branch 'ffmpeg-mt/master' swscale: Remove unused variable. ARM: simplify inline asm with 64-bit operands Add "const" to avoid "initialization discards qualifiers" warning. Add const to fix "cast discards qualifiers" warnings. Include pixdesc.h for av_get_pix_fmt_name. wav: Don't avio_seek() if we know we'll run into EOF api-example: uppercase first letter in "copyright" output-example: create @file doxy from text in the copyright header examples: move API examples to a dedicated dir in doc ffmpeg: simplify opt_*_codec() options v4l2: rewrite code iterating the supported standards v4l2: perform minor style fixes v4l2: replace memset() with explicit struct initialization rawdec: fail in case of unknow pixel format swscale: remove sws_format_name() error.c: fix compile flags TCP: change default timeout to 5sec Revert "Timeout TCP open() after 5 seconds." Fix various unused variable warnings Fix various bad printf format warnings ARM: enable UAL syntax in asm.S Remove now unused nb_istreams variable. Add const to vector types for input in altivec code. Remove unused variable, avoiding compiler warning. Cast pointers to uintptr_t rather than unsigned int. v4l2: don't leak video standard string on error. swscale: Remove disabled code. avfilter: Surround function only used in debug mode by appropriate #ifdef. vf_crop: Replace #ifdef DEBUG + av_log() by av_dlog(). build: remove BUILD_ROOT variable vp8: use av_clip_uintp2() where possible swscale: Commits that could not be pulled earlier due to bugs #2 Commits that could not be pulled earlier due to bugs. Revert 1a5e4fd8c5b99478b4e08a69261930bb12aa948b for postproc. This broke the code doc: correct AC-3 option subsection placement ac3enc: fix LOCAL_ALIGNED usage in count_mantissa_bits() ac3dsp: do not use the ff_* prefix when referencing ff_ac3_bap_bits. swscale: use av_clip_uint8() in yuv2yuv1_c(). swscale: replace formatConvBuffer[VOF] by allocated array. v4l2: create file @doxy from text in the copyright header v4l2: remove pointless empty lines v4l2: set default standard to NULL v4l2: use OFFSET macro when setting options ac3dsp: fix loop condition in ac3_update_bap_counts_c() ARM: unbreak build lavdev: add SDL output device ac3enc: modify mantissa bit counting to keep bap counts for all values of bap instead of just 0 to 4. ac3enc: split mantissa bit counting into a separate function. ac3enc: store per-block/channel bap pointers by reference block in a 2D array rather than in the AC3Block struct. lavu: add av_get_pix_fmt_name() convenience function iff: remove duplicated file description cmdutils: remove OPT_FUNC2 get_bits: add av_unused tag to cache variable sws: replace all long with int. ARM: aacdec: fix constraints on inline asm ARM: remove unnecessary volatile from inline asm ARM: add "cc" clobbers to inline asm where needed ARM: improve FASTDIV asm ac3enc: use LOCAL_ALIGNED macro APIchanges: fill in git hash for av_get_pix_fmt_name (0420bd7). lavu: add av_get_pix_fmt_name() convenience function cmdutils: remove OPT_FUNC2 swscale: fix crash in bilinear scaling. vpxenc: add VP8E_SET_STATIC_THRESHOLD mapping webm: support stereo videos in matroska/webm muxer rgb2rgb: remove duplicate mmx/mmx2/3dnow/sse2 functions. swscale: reindent h[cy]scale_fast() and updateDitherTables(). swscale: reformat x86/swscale_template.c. swscale: remove duplicate mmx/mmx2 functions if they are identical. swscale: remove if (c->dstFormat) branch from yuv2packed[12X](). swscale: remove if(full_chr_int) from yuv2packed1(). swscale: remove if(accurate_rnd) branch from functions. swscale: revive SWS_CPU_CAPS until next major bump. swscale: Remove commented-out printf cruft. Export PCR pid Export more transport stream information. Output MPEG-TS stream identifiers. lavf: deprecate AVFormatParameters.pix_fmt. rawdec: add a pixel_format private option. v4l2: add a pixel_format private option. libdc1394: add a pixel_format private option. cosmetics: indentation and alignment after previous commit ac3enc: add support for E-AC-3 encoding. ac3enc: Move AC-3 AVOptions array to a separate file to make it easier to use only selected options for the different AC-3 encoder types. ARM: disable ff_vector_fmul_vfp on VFPv3 systems ARM: check for VFPv3 swscale: Remove unused variables in x86 code. doc: Drop DJGPP section, Libav now compiles out-of-the-box on FreeDOS. x86: Add appropriate ifdefs around certain AVX functions. cmdutils: use sws_freeContext() instead of av_freep(). swscale: delay allocation of formatConvBuffer(). swscale: fix build with --disable-swscale-alpha. movenc: Deprecate the global RTP hinting flag, use a private AVOption instead movenc: Add an AVClass for setting muxer specific options libdc1394: choose best video mode and rate based on camera capabilities. Remove support for libdc1394 < 2.0. avopt: fix segfault swscale: fix non-bitexact yuv2yuv[X2]() MMX/MMX2 functions. swscale: dont loose precission on RGB/BGR48 input, that is dont drop half the bits. patch checklist: suggest --disable-yasm test. lavdev: prefer the inclusion of avdevice.h over that of libavformat/avformat.h lavdev: include libavformat/avformat.h in avdevice.h fate.txt: replace FATE rsync command with a make command configure: report yasm/nasm presence properly tcp: make connect() timeout properly rawdec: factor video demuxer definitions into a macro. rtspdec: add initial_pause private option. lavf: deprecate AVFormatParameters.width/height. tty: add video_size private option. rawdec: add video_size private option. x11grab: add video_size private option. x11grab: factorize returning error codes. vfwcap: add video_size private option. v4l2: add video_size private option. v4l2: factorize returning error codes. libdc1394: add video_size private option. libdc1394: return meaninful error codes. bktr: add video_size private option. bktr: factorize returning error codes. Fix memleak Fix typo Remove specific note when not specific Minor cleanup in libx264.c Add metadata conversion table to the wav demuxer Fix 32bit rawvideo in avi on big-endian. id3v2: Check malloc result. ID3v2 tags can be very large. id3v2: Initialize tflags for version 2.2. webm: Additional options/presets for VP8 encodes under FFmpeg muxers: Add a flag to mark muxers that allow (non strict) monotone timestamps. swscale: Do not loose precission on yuv values after rgb->yuv. libx264: support aspect Ratio Switch ARM: add ARMv6 optimised av_clip_uintp2 ARM: remove volatile from asm statements in libavutil/intmath ARM: fix av_clipl_int32_arm() v4l: include avdevice.h ffserver: move close_connection() call to avoid a temporary string and copy. lavf: initialize demuxer private options. AVOptions: set string default values. Fix compilation with YASM/NASM versions not supporting AVX. lavdevice: mark v4l for removal on next major bump. swscale: fix compile on ppc. swscale: fix compile on x86-32. build: Remove generated .version file on distclean. configure: Add -D_GNU_SOURCE to CPPFLAGS on OS/2. doc: Drop hint at --enable-memalign-hack for MinGW, it is now autodetected. ffplay: Remove disabled code. Mark parameterless function declarations as 'void'. swscale: use av_clip_uint8() in yuv2yuv1_c(). swscale: remove VOF/VOFW. swscale: split chroma buffers into separate U/V planes. swscale: replace formatConvBuffer[VOF] by allocated array. rgb2rgb: remove duplicate mmx/mmx2/3dnow/sse2 functions. swscale: reindent h[cy]scale_fast() and updateDitherTables(). swscale: reformat x86/swscale_template.c. swscale: remove duplicate mmx/mmx2 functions if they are identical. swscale: remove if (c->dstFormat) branch from yuv2packed[12X](). swscale: remove if(full_chr_int) from yuv2packed1(). swscale: remove if(accurate_rnd) branch from functions. ffserver: Fix a null pointer dereference as a result of the FF_API_MAX_STREAMS cleanup. libdc1394: fix compilation. swscale: revive SWS_CPU_CAPS until next major bump. swscale: Remove commented-out printf cruft. ac3enc: initialize all coefficients to zero. ffv1: fix 16bits multithreading doc: create separate section for audio encoders swscale: Remove orphaned, commented-out function declaration. swscale: Eliminate rgb24toyv12_c() duplication. mpegvideo_enc: use AV_LOG_ERROR instead of AV_LOG_INFO for two error messages Fail when lowres value is lower than 0 Remove h263_msmpeg4 from MpegEncContext. APIchanges: Fill in git hash for fps_probe_size (30315a8) avformat: Add fpsprobesize as an AVOption. swscale: document SWS_CPU_CAPS* Revert removial of SWS flags from e66149e714006d099d1ebfcca3f22ca74fc7dcf4 avoptions: Return explicitly NAN or {0,0} if the option isn't found rtmp: Reindent rtmp: Don't try to do av_malloc(0) swscale: remove duplicatiopn of rgb24toyv12_c() Return -1 on invalid input instead of crashing. vf_mp: fix name of the remove-logo filter referenced in filters.texi tty: replace AVFormatParameters.sample_rate abuse with a private option. Fix end time of last chapter in compute_chapters_end ffmpeg: get rid of useless AVInputStream.nb_streams. ffmpeg: simplify managing input files and streams ffmpeg: purge redundant AVInputStream.index. lavf: deprecate AVFormatParameters.channel. libdc1394: add a private option for channel. dv1394: add a private option for channel. v4l2: reindent. v4l2: add a private option for channel. lavf: deprecate AVFormatParameters.standard. v4l2: add a private option for video standard. v4l: add a private option for video standard. dv1394: add a private option for video standard. bktr: add a private option for video standard. lavf: deprecate AVFormatParameters.{channels,sample_rate}. rawdec: add sample_rate/channels private options. ALSA: add channels and sample_rate private options. oss: add channels and sample_rate private options. sndio: add channels and sample_rate private options. lavf: deprecate AVFormatParameters.mpeg2ts_raw. mpegts: add compute_pcr option. lavf: add priv_class field to AVInputFormat. lavfi: add select filter eval: implement not() expression vsrc_buffer: return an error code if no frames are available ffmpeg: handle the case when get_filtered_frame() fails indeo3: add out-of-buffer write check Add reading of disc number to mov.c Fix end time of last chapter in compute_chapters_end(). Do not reset channel_layout to 0. vsrc_buffer: remove duplicated file description Merge swscale bloatup This will be cleaned up in the next merge swscale: MMX optim of hscale16() swscale: dont loose bits on planar >8bit yuv ind gray nput. swscale: Switch to ronalds yuv2yuvX16inC_template() its very similar to baptsites and supports alpha configure: enable memalign_hack automatically when needed rawdec: fix decoding of QT WRAW files matroska: improve declaration of video_stereo_* constant tables matroskadec: fix reverted condition to accept combine_plane operation Fix register types for LOAD_AB arguments, fixes compilation with NASM. swscale: unbreak the build on non-x86 systems. swscale: remove if(bitexact) branch from functions. swscale: remove if(canMMX2BeUsed) conditional. swscale: remove swScale_{c,MMX,MMX2} duplication. swscale: use emms_c(). Move emms_c() from libavcodec to libavutil. tiff: set palette in the context when specified in TIFF_PAL tag rtsp: use strtoul to parse rtptime and seq values. pgssubdec: fix incorrect colors. dvdsubdec: fix incorrect colors. ape: Allow demuxing of files with metadata tags. swscale: remove dead macro WRITEBGR24OLD. swscale: remove AMD3DNOW "optimizations". swscale: remove duplicate code in ppc/ subdirectory. swscale: remove duplicated x86/ functions. swscale: force --enable-runtime-cpudetect and remove SWS_CPU_CAPS_*. vsrc_buffer.h: add file doxy vsrc_buffer: tweak error message in init() wav: fix various printf warnings related to wrong argument type wav: propagate ff_get_wav_header() error code in w64_read_header() msmpeg4: reindent. lavc: remove msmpeg4v1 encoder. Remove avconfig.h and INCINSTDIRs on uninstall. ac3enc: add channel coupling support partial revert of 01d3ebaf219d83c0a70cdf9696ecb6b868e8a165 fate: reenable frext-pph10i4_panasonic_a after the bitstream has been fixed avcodec_find_decoder: prefer non experimental decoders. j2kdec: mark as CODEC_CAP_EXPERIMENTAL j2k[c/h] j2kdec.c: Implement 2 code block styles j2k: Add void as the parameter of function ff_j2k_init_tier1_luts Add Kamil Nowosads j2k code. matroska: cleanup handling of video stereo mode oggdec: use av_dlog() mem: define the MAX_MALLOC_SIZE constant and use it in place of INT_MAX configure: Add -U__STRICT_ANSI__ to CPPFLAGS on Cygwin and DOS. muxers.texi changes for mkv/webm options aacdec: fix typo in scalefactor clipping check mpegaudio: Correct license header add 5.1 to stereo downmix to resample.c this is based on previous 6to2channel-resample.patch from ffmpeg2theora but updated to work with trunk and using av_clip_int16. fate: fix fate-h264-conformance-frext-pph10i4-panasonic-a crcs. fate: update 9/10bit refs. h264: Properly set coded_{width, height} when parsing H.264. x86 asm: Add SECTION_TEXT to dct32_sse.asm. Fix 9/10 bit in swscale. Do not ask for samples if a specific channel layout was requested. libx264: specify field for default union values in options movdec: dont divide by zero when stts_data[0].duration = 0. Fix ticket127 dct32: Replacing libav by ffmpeg in the license header with the authors permission. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> ffmpeg: Don't trigger url_interrupt_cb on the first signal avoptions: Check the return value from av_get_number lavf: fix style for avformat_alloc_output_context2() lavf: deprecate avformat_alloc_output_context() in favor of avformat_alloc_output_context2() lavfi: make vsrc_buffer.h header public dct32_sse: eliminate some spills Fix compilation with --disable-yasm. Fix dct32() compilation with --disable-yasm mpeg2dec: Fix lowres 3 lavfi: bump minor and add changelog entry after the split filter addition vf_split: add documentation to filters.texi vf_split: give more meaningful names to the output pads vf_split: define draw_slice() before end_frame() vf_split: add description vf_split: fix various nits wmadec: avoid infinit loop. DirectShow capture: Fix build ffmpeg: get rid of the -vglobal option. dct32: Add AVX implementation of 32-point DCT dct32: Change pass 6 permutation to allow for AVX implementation dct32: port SSE 32-point DCT to YASM matroska: switch stereo mode from int to string and add support in the demuxer too matroska: cosmetics Create a stereo_mode metadata tag to specify the stereo 3d video layout using the StereoMode tag in a matroska/webm video track. libavfilter: vf_split from soc. DirectShow capture support Signed-off-by: Michael Niedermayer <michaelni@gmx.at> multiple inclusion guard cleanup avio: document buffer must created with av_malloc() and friends avio: check AVIOContext malloc failure swscale: point out an alternative to sws_getContext svq3: Do initialization after parsing the extradata Fix channel_layout documentation. add changelog entries for 0.7_beta2 ffserver: dont just crash fix ffserver's SIGSEGV avoptions: Support getting flag values using av_get_int preset dir for win32 Merge remote-tracking branch 'ffmpeg-mt/master' Add a flag to disable side data merging. Merge/split side data. Encoding alac with more than two channels is not supported. mp3lame: add #include required for AV_RB32 macro. configure: make executable again LATM/AAC: Free previously initialized context on reinit. configure: Do not unconditionally add -Wall to host CFLAGS. configure: Set OS/2 objformat to a.out. Add support for a.out object format to assembler macros. fate: disable threading for encoding fate: add comment field fate: allow overriding default build and install dirs mpegtsenc: Add an AVClass pointer to the private data mpegaudio: clean up #includes mpegaudio: move all header parsing to mpegaudiodecheader.[ch] vf_libopencv: prefer opencv/cxcore.h over cxtypes.h decoders.texi: fix typos in rawvideo section cmdutils: use const AVClass * when senseful encoders.texi: add documentation for the libx264 encoder decoders.texi: add documentation for rawvideo decoder and options doc: add decoders.texi file encoders.texi: decrease level for audio encoders section ffprobe.texi: remove inclusion of muxers section indeo3: release buffer in indeo3_decode_end() indeo3: remove unnecessary includes indeo3: add @file doxy and a link to multimedia wiki documentation cmdutils: reset *picref_ptr to NULL in get_filtered_frame() ffmpeg: remove useless NULL-check on avfilter_unref_buffer libmp3lame: include "libavutil/intreadwrite.h" header qdm2: Use floating point synthesis filter. h264: correct border check. h264: fix loopfilter with threading at slice boundaries. Fix ff_mpa_synth_filter_fixed() prototype Reindent rtpenc_chain: Pass the MP4A_LATM flag to chained muxers rtpenc: MP4A-LATM payload support movenc: Pass AVFormatContext flags to the SDP generation sdp: Allow passing AVFormatContext flags to the SDP generation vsrc_buffer: document av_vsrc_buffer_add_video_buffer_ref() vsrc_buffer: add av_vsrc_buffer_add_frame() vsrc_buffer: fix example in docs, add mandatory parameters vsrc_buffer: make the source accept sws_param in init vsrc_buffer: propagate avfilter_open() error code vsrc_buffer: fix style lavfi: add avfilter_get_video_buffer_ref_from_frame to avcodec.h vsrc_buffer: remove dependency on AVFrame Rename costablegen.c ---> cos_tablegen.c. Collapse tableprint.c into tableprint.h. Simplify trig table rules Remove potentially unstable filenames from comments in generated files. Ignore generated tables and generated table generator programs. Simplify CLEANFILES make variable by using wildcards. Remove silly insults from avformat_version() Doxygen documentation. mpegaudiodsp: fix x86 and ppc makefiles configure: Adjust AVX assembler check. mpegaudio: remove unused version of SAME_HEADER_MASK mpegaudio: remove useless #undef at end of file asfdec: add missing #include for av_bswap32() mpegaudio: merge two #if CONFIG_FLOAT blocks mpegaudio: move some struct definitions from mpegaudio.h Move some mpegaudio functions to new mpegaudiodsp subsystem Clean up #includes in cmdutils.h. g729: Merge g729.h into g729dec.c. av_find_stream_info: Print more details about max anaylize duration failures. 10l: wrap float_interleave functions in HAVE_YASM. Add little description for -rc_override APIchanges: fill in date and commit for request_sample_fmt Add floating-point sample format support to the ac3, eac3, dca, aac, and vorbis decoders. Add support for request_sample_format in ffmpeg and ffplay. Add APIchanges entry for request_sample_fmt. Add request_sample_fmt field to AVCodecContext. Add float_interleave() to FmtConvertContext with x86-optimized versions. Remove unused make variable SEEK_REFFILE fate: remove redundant aref and vref references Parse 'bext' metadata in the wav demuxer Cosmetics: indent Keep parsing wav until EOF if the input is seekable and we know the size of the data tag Refactor the tag checking into a switch statement Use avio_tell() instead of url_ftell() add x264opts entry to docs cleaned up the udp.c, removed some variables and an av_log configure: favor pkg_config over sdl_config libx264: support passing arbitrary parameters. ffmpeg: dont show_banner() on verbose<0 fate: remove do_ffmpeg_nocheck function fate: do not collect -benchmark output mpegaudiodec: remove decode_end() function fate: run aref and vref as regular tests mpegaudio: sanitise compute_antialias_* names mpeg12: add slice-threading checks to slice-threading initializers. h264: copy pixel_shift between slice threading contexts. mdec: enable frame-level multithreading. mdec.c: fix overread. id3v2: prevent unsigned integer overflow in ff_id3v2_parse() id3v2: add @file doxy and link to format documentation configure: opensolaris install is not compatible with ffmpeg, allow overriding it. Fix compilation of iirfilter-test. eval: opensolaris strtod() cannot handle 0x1234 libx264: handle closed GOP codec flag lavf: remove duplicate assignment in avformat_alloc_context. lavf: use designated initializers for AVClasses. Make sure neither data_size nor sample_count is negative Refactor the 'fmt ' tag search and parsing flvdec: clenup debug code asfdec: fix possible overread on broken files. asfdec: do not fall back to binary/generic search asfdec: reindent after previous commit c7bd5ed asfdec: fallback to binary search internally mpegaudio: add _fixed suffix to some names Modify x86util.asm to ease transitioning to 10-bit H.264 assembly. ffmpeg: reset top_field_first in opt_input_file(). dct: build dct32 as separate object files qdm2: include correct header for rdft Ogg demuxer: give meaningful error codes and warnings. update changelog with 9/10 bit H264 and FFV1 changes Add some forgotten const to function arguments in libavfilter & libavformat. Write channel_layout for multichannel aif files. Fix ff_mov_write_chan() so it can be used by other muxers. Fix some mov files with little endian audio (tickets 201 - 203). iff/8svx: redesign 8SVX demuxing and decoding for handling stereo samples correctly iff: compact code setting metadata tags iff: fix bitrate computation for compressed audio stream iff: distinguish fields for audio and video compression imgutils: introduce internal image_get_linesize() and use it imgutils: make av_image_get_linesize() return AVERROR(EINVAL) for invalid pixel formats drawtext: specify union type for setting default options drawtext: reindent after the previous commit drawtext: fix strftime() text expansion ffmpeg: fix -aspect cli option Restructure video filter implementation in ffmpeg.c. ffplay: remove audio_write_get_buf_size() forward declaration lavfi: print key-frame and picture type information in ff_dlog_ref() mathops: remove ancient confusing comment rawdec: Allow overriding top field first. ffmpeg: initialize input_codec array earlier. cmdutils: Allocate private decoder context if its not allocated yet. cws2fws: Improve error message wording. tools: Check the return value of write(). mpegaudio: move OUT_FMT macro to mpegaudiodec.c mpegaudio: remove OUT_MIN/MAX macros Add missing #includes to mp3_header_(de)compress bsf dct: fix indentation dct: bypass table allocation for DCT_II of size 32 pngdec: relax condition for setting monoblack pixel format h264dsp_mmx: Add #ifdefs around some mmxext functions on x86_64. Remove unused header mpegaudio3.h. Support decoding of 1bpp rawvideo in avi (ticket 205). Support decoding of 2bpp rawvideo in avi (ticket 206). Bump minor after adding a caf muxer. configure: another try on fixing osx/mingw SDL aacdec: Use float instead of int16_t for ltp_state to avoid needless rounding. av_picture_crop(): Support simple cases with packed pixels too. acelp: Remove unused gray_decode table. dfa: Remove unused variable. configure: Include AVX availability in summary output. rawdec: propagate pict_type information to the output frame showinfo: replace "CRC" by "checksum" showinfo: fix vertical align nit showinfo: fix computation of Adler checksum imgutils: generalize linesize computation for bitstream formats configure: use same CPPFLAGS in kFreeBSD as Linux Conflicts: ffserver.c libavcodec/avcodec.h libavcodec/opt.h libavcodec/version.h libavdevice/avdevice.h libavfilter/avfilter.h libavformat/avformat.h libavformat/metadata.c libavformat/metadata.h libavformat/utils.c libavformat/version.h libavutil/avutil.h libavutil/mem.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/Makefile4
-rw-r--r--libavfilter/allfilters.c2
-rw-r--r--libavfilter/avcodec.c31
-rw-r--r--libavfilter/avcodec.h31
-rw-r--r--libavfilter/avfilter.c102
-rw-r--r--libavfilter/avfilter.h42
-rw-r--r--libavfilter/avfiltergraph.c14
-rw-r--r--libavfilter/avfiltergraph.h28
-rw-r--r--libavfilter/defaults.c133
-rw-r--r--libavfilter/formats.c15
-rw-r--r--libavfilter/gradfun.h14
-rw-r--r--libavfilter/graphparser.c53
-rw-r--r--libavfilter/internal.h4
-rw-r--r--libavfilter/libmpcodecs/vf_detc.c2
-rw-r--r--libavfilter/libmpcodecs/vf_dint.c12
-rw-r--r--libavfilter/libmpcodecs/vf_divtc.c9
-rw-r--r--libavfilter/libmpcodecs/vf_gradfun.c6
-rw-r--r--libavfilter/libmpcodecs/vf_ilpack.c13
-rw-r--r--libavfilter/libmpcodecs/vf_pp7.c4
-rw-r--r--libavfilter/libmpcodecs/vf_sab.c2
-rw-r--r--libavfilter/libmpcodecs/vf_scale.h1
-rw-r--r--libavfilter/libmpcodecs/vf_smartblur.c6
-rw-r--r--libavfilter/libmpcodecs/vf_unsharp.c2
-rw-r--r--libavfilter/vf_crop.c8
-rw-r--r--libavfilter/vf_drawtext.c121
-rw-r--r--libavfilter/vf_fieldorder.c3
-rw-r--r--libavfilter/vf_gradfun.c6
-rw-r--r--libavfilter/vf_libopencv.c2
-rw-r--r--libavfilter/vf_mp.c13
-rw-r--r--libavfilter/vf_scale.c3
-rw-r--r--libavfilter/vf_select.c351
-rw-r--r--libavfilter/vf_showinfo.c22
-rw-r--r--libavfilter/vf_split.c66
-rw-r--r--libavfilter/vf_unsharp.c4
-rw-r--r--libavfilter/vsrc_buffer.c130
-rw-r--r--libavfilter/vsrc_buffer.h21
-rw-r--r--libavfilter/vsrc_movie.c2
-rw-r--r--libavfilter/x86/gradfun.c6
38 files changed, 933 insertions, 355 deletions
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index de34089468..2324fb999e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -6,7 +6,7 @@ FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
FFLIBS-$(CONFIG_SCALE_FILTER) += swscale
FFLIBS-$(CONFIG_MP_FILTER) += avcodec
-HEADERS = avcodec.h avfilter.h avfiltergraph.h
+HEADERS = avcodec.h avfilter.h avfiltergraph.h vsrc_buffer.h
OBJS = allfilters.o \
avfilter.o \
@@ -46,12 +46,14 @@ OBJS-$(CONFIG_OVERLAY_FILTER) += vf_overlay.o
OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o
OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o
+OBJS-$(CONFIG_SELECT_FILTER) += vf_select.o
OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o
OBJS-$(CONFIG_SETPTS_FILTER) += vf_setpts.o
OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o
OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o
OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o
+OBJS-$(CONFIG_SPLIT_FILTER) += vf_split.o
OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o
OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o
OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 1973602305..5f1065f23f 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -62,12 +62,14 @@ void avfilter_register_all(void)
REGISTER_FILTER (PAD, pad, vf);
REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf);
REGISTER_FILTER (SCALE, scale, vf);
+ REGISTER_FILTER (SELECT, select, vf);
REGISTER_FILTER (SETDAR, setdar, vf);
REGISTER_FILTER (SETPTS, setpts, vf);
REGISTER_FILTER (SETSAR, setsar, vf);
REGISTER_FILTER (SETTB, settb, vf);
REGISTER_FILTER (SHOWINFO, showinfo, vf);
REGISTER_FILTER (SLICIFY, slicify, vf);
+ REGISTER_FILTER (SPLIT, split, vf);
REGISTER_FILTER (TRANSPOSE, transpose, vf);
REGISTER_FILTER (UNSHARP, unsharp, vf);
REGISTER_FILTER (VFLIP, vflip, vf);
diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
index c2f8651106..2010040d14 100644
--- a/libavfilter/avcodec.c
+++ b/libavfilter/avcodec.c
@@ -40,3 +40,34 @@ void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
dst->video->pict_type = src->pict_type;
}
}
+
+AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame,
+ int perms)
+{
+ AVFilterBufferRef *picref =
+ avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize, perms,
+ frame->width, frame->height,
+ frame->format);
+ if (!picref)
+ return NULL;
+ avfilter_copy_frame_props(picref, frame);
+ return picref;
+}
+
+int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
+ const AVFilterBufferRef *picref)
+{
+ if (!picref || !picref->video || !frame)
+ return AVERROR(EINVAL);
+
+ memcpy(frame->data, picref->data, sizeof(frame->data));
+ memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
+ frame->pkt_pos = picref->pos;
+ frame->interlaced_frame = picref->video->interlaced;
+ frame->top_field_first = picref->video->top_field_first;
+ frame->key_frame = picref->video->key_frame;
+ frame->pict_type = picref->video->pict_type;
+ frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
+
+ return 0;
+}
diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h
index f438860d0b..dec5ae4a7c 100644
--- a/libavfilter/avcodec.h
+++ b/libavfilter/avcodec.h
@@ -30,6 +30,7 @@
#include "libavcodec/avcodec.h" // AVFrame
#include "avfilter.h"
+#include "vsrc_buffer.h"
/**
* Copy the frame properties of src to dst, without copying the actual
@@ -37,4 +38,34 @@
*/
void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
+/**
+ * Create and return a picref reference from the data and properties
+ * contained in frame.
+ *
+ * @param perms permissions to assign to the new buffer reference
+ */
+AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
+
+/**
+ * Fill an AVFrame with the information stored in picref.
+ *
+ * @param frame an already allocated AVFrame
+ * @param picref a video buffer reference
+ * @return 0 in case of success, a negative AVERROR code in case of
+ * failure
+ */
+int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
+ const AVFilterBufferRef *picref);
+
+/**
+ * Add frame data to buffer_src.
+ *
+ * @param buffer_src pointer to a buffer source context
+ * @param flags a combination of AV_VSRC_BUF_FLAG_* flags
+ * @return >= 0 in case of success, a negative AVERROR code in case of
+ * failure
+ */
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
+ const AVFrame *frame, int flags);
+
#endif /* AVFILTER_AVCODEC_H */
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 72e0a87f8e..3b2e3ca2be 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -77,8 +77,8 @@ static void store_in_pool(AVFilterBufferRef *ref)
av_assert0(ref->buf->data[0]);
- if(pool->count == POOL_SIZE){
- AVFilterBufferRef *ref1= pool->pic[0];
+ if (pool->count == POOL_SIZE) {
+ AVFilterBufferRef *ref1 = pool->pic[0];
av_freep(&ref1->video);
av_freep(&ref1->audio);
av_freep(&ref1->buf->data[0]);
@@ -89,9 +89,9 @@ static void store_in_pool(AVFilterBufferRef *ref)
pool->pic[POOL_SIZE-1] = NULL;
}
- for(i=0; i<POOL_SIZE; i++){
- if(!pool->pic[i]){
- pool->pic[i]= ref;
+ for (i = 0; i < POOL_SIZE; i++) {
+ if (!pool->pic[i]) {
+ pool->pic[i] = ref;
pool->count++;
break;
}
@@ -102,8 +102,8 @@ void avfilter_unref_buffer(AVFilterBufferRef *ref)
{
if (!ref)
return;
- if (!(--ref->buf->refcount)){
- if(!ref->buf->free){
+ if (!(--ref->buf->refcount)) {
+ if (!ref->buf->free) {
store_in_pool(ref);
return;
}
@@ -165,6 +165,31 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
return 0;
}
+void avfilter_link_free(AVFilterLink **link)
+{
+ if (!*link)
+ return;
+
+ if ((*link)->pool) {
+ int i;
+ for (i = 0; i < POOL_SIZE; i++) {
+ if ((*link)->pool->pic[i]) {
+ AVFilterBufferRef *picref = (*link)->pool->pic[i];
+ /* free buffer: picrefs stored in the pool are not
+ * supposed to contain a free callback */
+ av_freep(&picref->buf->data[0]);
+ av_freep(&picref->buf);
+
+ av_freep(&picref->audio);
+ av_freep(&picref->video);
+ av_freep(&picref);
+ }
+ }
+ av_freep(&(*link)->pool);
+ }
+ av_freep(link);
+}
+
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
{
@@ -280,10 +305,9 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
av_get_picture_type_char(ref->video->pict_type));
}
if (ref->audio) {
- av_dlog(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d",
+ av_dlog(ctx, " cl:%"PRId64"d n:%d r:%d p:%d",
ref->audio->channel_layout,
ref->audio->nb_samples,
- ref->audio->size,
ref->audio->sample_rate,
ref->audio->planar);
}
@@ -340,7 +364,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int
}
AVFilterBufferRef *
-avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
+avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
int w, int h, enum PixelFormat format)
{
AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
@@ -380,16 +404,16 @@ fail:
}
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
- enum AVSampleFormat sample_fmt, int size,
+ enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar)
{
AVFilterBufferRef *ret = NULL;
if (link->dstpad->get_audio_buffer)
- ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar);
+ ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout, planar);
if (!ret)
- ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar);
+ ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout, planar);
if (ret)
ret->type = AVMEDIA_TYPE_AUDIO;
@@ -397,6 +421,48 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
return ret;
}
+AVFilterBufferRef *
+avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
+ int nb_samples, enum AVSampleFormat sample_fmt,
+ int64_t channel_layout, int planar)
+{
+ AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
+ AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef));
+
+ if (!samples || !samplesref)
+ goto fail;
+
+ samplesref->buf = samples;
+ samplesref->buf->free = ff_avfilter_default_free_buffer;
+ if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps))))
+ goto fail;
+
+ samplesref->audio->nb_samples = nb_samples;
+ samplesref->audio->channel_layout = channel_layout;
+ samplesref->audio->planar = planar;
+
+ /* make sure the buffer gets read permission or it's useless for output */
+ samplesref->perms = perms | AV_PERM_READ;
+
+ samples->refcount = 1;
+ samplesref->type = AVMEDIA_TYPE_AUDIO;
+ samplesref->format = sample_fmt;
+
+ memcpy(samples->data, data, sizeof(samples->data));
+ memcpy(samples->linesize, linesize, sizeof(samples->linesize));
+ memcpy(samplesref->data, data, sizeof(samplesref->data));
+ memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize));
+
+ return samplesref;
+
+fail:
+ if (samplesref && samplesref->audio)
+ av_freep(&samplesref->audio);
+ av_freep(&samplesref);
+ av_freep(&samples);
+ return NULL;
+}
+
int avfilter_request_frame(AVFilterLink *link)
{
FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1);
@@ -520,6 +586,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
{
void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
AVFilterPad *dst = link->dstpad;
+ int i;
FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);
@@ -536,14 +603,15 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms,
samplesref->format,
- samplesref->audio->size,
+ samplesref->audio->nb_samples,
samplesref->audio->channel_layout,
samplesref->audio->planar);
link->cur_buf->pts = samplesref->pts;
link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
/* Copy actual data into new samples buffer */
- memcpy(link->cur_buf->data[0], samplesref->data[0], samplesref->audio->size);
+ for (i = 0; samplesref->data[i]; i++)
+ memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]);
avfilter_unref_buffer(samplesref);
} else
@@ -683,7 +751,7 @@ void avfilter_free(AVFilterContext *filter)
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
- av_freep(&link);
+ avfilter_link_free(&link);
}
for (i = 0; i < filter->output_count; i++) {
if ((link = filter->outputs[i])) {
@@ -692,7 +760,7 @@ void avfilter_free(AVFilterContext *filter)
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
- av_freep(&link);
+ avfilter_link_free(&link);
}
av_freep(&filter->name);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 8251f2bf0e..7a844c4a11 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -26,7 +26,7 @@
#include "libavutil/samplefmt.h"
#define LIBAVFILTER_VERSION_MAJOR 1
-#define LIBAVFILTER_VERSION_MINOR 78
+#define LIBAVFILTER_VERSION_MINOR 79
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -98,8 +98,7 @@ typedef struct AVFilterBuffer {
*/
typedef struct AVFilterBufferRefAudioProps {
int64_t channel_layout; ///< channel layout of audio buffer
- int nb_samples; ///< number of audio samples
- int size; ///< audio buffer size
+ int nb_samples; ///< number of audio samples per channel
uint32_t sample_rate; ///< audio buffer sample rate
int planar; ///< audio buffer - planar or packed
} AVFilterBufferRefAudioProps;
@@ -234,7 +233,8 @@ typedef struct AVFilterFormats {
* Create a list of supported formats. This is intended for use in
* AVFilter->query_formats().
*
- * @param fmts list of media formats, terminated by -1
+ * @param fmts list of media formats, terminated by -1. If NULL an
+ * empty list is created.
* @return the format list, with no existing references
*/
AVFilterFormats *avfilter_make_format_list(const int *fmts);
@@ -372,7 +372,7 @@ struct AVFilterPad {
* Input audio pads only.
*/
AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
- enum AVSampleFormat sample_fmt, int size,
+ enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar);
/**
@@ -461,7 +461,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
/** default handler for get_audio_buffer() for audio inputs */
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
- enum AVSampleFormat sample_fmt, int size,
+ enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar);
/**
@@ -636,6 +636,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
AVFilterContext *dst, unsigned dstpad);
/**
+ * Free the link in *link, and set its pointer to NULL.
+ */
+void avfilter_link_free(AVFilterLink **link);
+
+/**
* Negotiate the media format, dimensions, etc of all inputs to a filter.
*
* @param filter the filter to negotiate the properties for its inputs
@@ -669,7 +674,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
* @param format the pixel format of the image specified by the data and linesize arrays
*/
AVFilterBufferRef *
-avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
+avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
int w, int h, enum PixelFormat format);
/**
@@ -679,17 +684,34 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int
* be requested
* @param perms the required access permissions
* @param sample_fmt the format of each sample in the buffer to allocate
- * @param size the buffer size in bytes
+ * @param nb_samples the number of samples per channel
* @param channel_layout the number and type of channels per sample in the buffer to allocate
* @param planar audio data layout - planar or packed
* @return A reference to the samples. This must be unreferenced with
* avfilter_unref_buffer when you are finished with it.
*/
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
- enum AVSampleFormat sample_fmt, int size,
+ enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar);
/**
+ * Create an audio buffer reference wrapped around an already
+ * allocated samples buffer.
+ *
+ * @param data pointers to the samples plane buffers
+ * @param linesize linesize for the samples plane buffers
+ * @param perms the required access permissions
+ * @param nb_samples number of samples per channel
+ * @param sample_fmt the format of each sample in the buffer to allocate
+ * @param channel_layout the channel layout of the buffer
+ * @param planar audio data layout - planar or packed
+ */
+AVFilterBufferRef *
+avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
+ int nb_samples, enum AVSampleFormat sample_fmt,
+ int64_t channel_layout, int planar);
+
+/**
* Request an input frame from the filter at the other end of the link.
*
* @param link the input link
@@ -861,4 +883,4 @@ static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
&f->output_pads, &f->outputs, p);
}
-#endif /* AVFILTER_AVFILTER_H */
+#endif /* AVFILTER_AVFILTER_H */
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index bdf22b3df9..60d529ba73 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -90,7 +90,7 @@ int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
av_log(log_ctx, AV_LOG_ERROR,
"Input pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any source\n",
filt->input_pads[j].name, filt->name, filt->filter->name);
- return -1;
+ return AVERROR(EINVAL);
}
}
@@ -99,7 +99,7 @@ int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
av_log(log_ctx, AV_LOG_ERROR,
"Output pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any destination\n",
filt->output_pads[j].name, filt->name, filt->filter->name);
- return -1;
+ return AVERROR(EINVAL);
}
}
}
@@ -178,7 +178,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
av_log(log_ctx, AV_LOG_ERROR,
"Impossible to convert between the formats supported by the filter "
"'%s' and the filter '%s'\n", link->src->name, link->dst->name);
- return -1;
+ return AVERROR(EINVAL);
}
}
}
@@ -216,9 +216,11 @@ static void pick_formats(AVFilterGraph *graph)
int ff_avfilter_graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
{
+ int ret;
+
/* find supported formats from sub-filters, and merge along links */
- if (query_formats(graph, log_ctx))
- return -1;
+ if ((ret = query_formats(graph, log_ctx)) < 0)
+ return ret;
/* Once everything is merged, it's possible that we'll still have
* multiple valid media format choices. We pick the first one. */
@@ -227,7 +229,7 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
return 0;
}
-int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx)
+int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
{
int ret;
diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h
index 0140af0801..a975926fd1 100644
--- a/libavfilter/avfiltergraph.h
+++ b/libavfilter/avfiltergraph.h
@@ -76,7 +76,7 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
* @param log_ctx context used for logging
* @return 0 in case of success, a negative AVERROR code otherwise
*/
-int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
+int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
/**
* Free a graph, destroy its links, and set *graph to NULL.
@@ -108,16 +108,32 @@ typedef struct AVFilterInOut {
} AVFilterInOut;
/**
+ * Create an AVFilterInOut.
+ * Must be free with avfilter_inout_free().
+ */
+AVFilterInOut *avfilter_inout_alloc(void);
+
+/**
+ * Free the AVFilterInOut in *inout, and set its pointer to NULL.
+ * If *inout is NULL, do nothing.
+ */
+void avfilter_inout_free(AVFilterInOut **inout);
+
+/**
* Add a graph described by a string to a graph.
*
* @param graph the filter graph where to link the parsed graph context
* @param filters string to be parsed
- * @param inputs linked list to the inputs of the graph
- * @param outputs linked list to the outputs of the graph
+ * @param inputs linked list to the inputs of the graph, may be NULL.
+ * It is updated to contain the list of open inputs after the parsing,
+ * should be freed with avfilter_inout_free().
+ * @param outputs linked list to the outputs of the graph, may be NULL.
+ * It is updated to contain the list of open outputs after the parsing,
+ * should be freed with avfilter_inout_free().
* @return zero on success, a negative AVERROR code on error
*/
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
- AVFilterInOut *inputs, AVFilterInOut *outputs,
- AVClass *log_ctx);
+ AVFilterInOut **inputs, AVFilterInOut **outputs,
+ void *log_ctx);
-#endif /* AVFILTER_AVFILTERGRAPH_H */
+#endif /* AVFILTER_AVFILTERGRAPH_H */
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 9ee23e57b7..c39ed64048 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -40,28 +40,30 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
uint8_t *data[4];
int i;
AVFilterBufferRef *picref = NULL;
- AVFilterPool *pool= link->pool;
-
- if(pool) for(i=0; i<POOL_SIZE; i++){
- picref= pool->pic[i];
- if(picref && picref->buf->format == link->format && picref->buf->w == w && picref->buf->h == h){
- AVFilterBuffer *pic= picref->buf;
- pool->pic[i]= NULL;
- pool->count--;
- picref->video->w = w;
- picref->video->h = h;
- picref->perms = perms | AV_PERM_READ;
- picref->format= link->format;
- pic->refcount = 1;
- memcpy(picref->data, pic->data, sizeof(picref->data));
- memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
- return picref;
+ AVFilterPool *pool = link->pool;
+
+ if (pool) {
+ for (i = 0; i < POOL_SIZE; i++) {
+ picref = pool->pic[i];
+ if (picref && picref->buf->format == link->format && picref->buf->w == w && picref->buf->h == h) {
+ AVFilterBuffer *pic = picref->buf;
+ pool->pic[i] = NULL;
+ pool->count--;
+ picref->video->w = w;
+ picref->video->h = h;
+ picref->perms = perms | AV_PERM_READ;
+ picref->format = link->format;
+ pic->refcount = 1;
+ memcpy(picref->data, pic->data, sizeof(picref->data));
+ memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
+ return picref;
+ }
}
- }else
+ } else
pool = link->pool = av_mallocz(sizeof(AVFilterPool));
- // +2 is needed for swscaler, +16 to be SIMD-friendly
- if ((i=av_image_alloc(data, linesize, w, h, link->format, 16)) < 0)
+ // align: +2 is needed for swscaler, +16 to be SIMD-friendly
+ if ((i = av_image_alloc(data, linesize, w, h, link->format, 16)) < 0)
return NULL;
picref = avfilter_get_video_buffer_ref_from_arrays(data, linesize,
@@ -72,88 +74,37 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
}
memset(data[0], 128, i);
- picref->buf->priv= pool;
- picref->buf->free= NULL;
+ picref->buf->priv = pool;
+ picref->buf->free = NULL;
return picref;
}
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
- enum AVSampleFormat sample_fmt, int size,
+ enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar)
{
- AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
- AVFilterBufferRef *ref = NULL;
- int i, sample_size, chans_nb, bufsize, per_channel_size, step_size = 0;
- char *buf;
-
- if (!samples || !(ref = av_mallocz(sizeof(AVFilterBufferRef))))
- goto fail;
-
- ref->buf = samples;
- ref->format = sample_fmt;
-
- ref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps));
- if (!ref->audio)
- goto fail;
-
- ref->audio->channel_layout = channel_layout;
- ref->audio->size = size;
- ref->audio->planar = planar;
-
- /* make sure the buffer gets read permission or it's useless for output */
- ref->perms = perms | AV_PERM_READ;
-
- samples->refcount = 1;
- samples->free = ff_avfilter_default_free_buffer;
-
- sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3;
- chans_nb = av_get_channel_layout_nb_channels(channel_layout);
-
- per_channel_size = size/chans_nb;
- ref->audio->nb_samples = per_channel_size/sample_size;
-
- /* Set the number of bytes to traverse to reach next sample of a particular channel:
- * For planar, this is simply the sample size.
- * For packed, this is the number of samples * sample_size.
- */
- for (i = 0; i < chans_nb; i++)
- samples->linesize[i] = planar > 0 ? per_channel_size : sample_size;
- memset(&samples->linesize[chans_nb], 0, (8-chans_nb) * sizeof(samples->linesize[0]));
+ AVFilterBufferRef *samplesref = NULL;
+ int linesize[8];
+ uint8_t *data[8];
+ int nb_channels = av_get_channel_layout_nb_channels(channel_layout);
/* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
- bufsize = (size + 15)&~15;
- buf = av_malloc(bufsize);
- if (!buf)
- goto fail;
-
- /* For planar, set the start point of each channel's data within the buffer
- * For packed, set the start point of the entire buffer only
- */
- samples->data[0] = buf;
- if (buf && planar) {
- for (i = 1; i < chans_nb; i++) {
- step_size += per_channel_size;
- samples->data[i] = buf + step_size;
- }
- } else {
- for (i = 1; i < chans_nb; i++)
- samples->data[i] = buf;
- }
-
- memset(&samples->data[chans_nb], 0, (8-chans_nb) * sizeof(samples->data[0]));
-
- memcpy(ref->data, samples->data, sizeof(ref->data));
- memcpy(ref->linesize, samples->linesize, sizeof(ref->linesize));
+ if (av_samples_alloc(data, linesize,
+ nb_channels, nb_samples, sample_fmt,
+ planar, 16) < 0)
+ return NULL;
- return ref;
+ samplesref =
+ avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
+ nb_samples, sample_fmt,
+ channel_layout, planar);
+ if (!samplesref) {
+ av_free(data[0]);
+ return NULL;
+ }
-fail:
- if (ref)
- av_free(ref->audio);
- av_free(ref);
- av_free(samples);
- return NULL;
+ return samplesref;
}
void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
@@ -210,7 +161,7 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa
if (outlink) {
outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE, samplesref->format,
- samplesref->audio->size,
+ samplesref->audio->nb_samples,
samplesref->audio->channel_layout,
samplesref->audio->planar);
outlink->out_buf->pts = samplesref->pts;
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 101ef09e5f..58593fcce0 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -44,6 +44,8 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
AVFilterFormats *ret;
unsigned i, j, k = 0;
+ if (a == b) return a;
+
ret = av_mallocz(sizeof(AVFilterFormats));
/* merge list of formats */
@@ -73,15 +75,18 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
AVFilterFormats *avfilter_make_format_list(const int *fmts)
{
AVFilterFormats *formats;
- int count;
+ int count = 0;
- for (count = 0; fmts[count] != -1; count++)
- ;
+ if (fmts)
+ for (count = 0; fmts[count] != -1; count++)
+ ;
formats = av_mallocz(sizeof(AVFilterFormats));
- formats->formats = av_malloc(sizeof(*formats->formats) * count);
formats->format_count = count;
- memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
+ if (count) {
+ formats->formats = av_malloc(sizeof(*formats->formats) * count);
+ memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
+ }
return formats;
}
diff --git a/libavfilter/gradfun.h b/libavfilter/gradfun.h
index 3dacbcb252..3c01085b83 100644
--- a/libavfilter/gradfun.h
+++ b/libavfilter/gradfun.h
@@ -33,16 +33,16 @@ typedef struct {
int chroma_r; ///< blur radius for the chroma planes
uint16_t *buf; ///< holds image data for blur algorithm passed into filter.
/// DSP functions.
- void (*filter_line) (uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers);
- void (*blur_line) (uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width);
+ void (*filter_line) (uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers);
+ void (*blur_line) (uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width);
} GradFunContext;
-void ff_gradfun_filter_line_c(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers);
-void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width);
+void ff_gradfun_filter_line_c(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers);
+void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width);
-void ff_gradfun_filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers);
-void ff_gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers);
+void ff_gradfun_filter_line_mmx2(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers);
+void ff_gradfun_filter_line_ssse3(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers);
-void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width);
+void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width);
#endif /* AVFILTER_GRADFUN_H */
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index 4f11529900..d62ba8d205 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -36,7 +36,7 @@
*/
static int link_filter(AVFilterContext *src, int srcpad,
AVFilterContext *dst, int dstpad,
- AVClass *log_ctx)
+ void *log_ctx)
{
int ret;
if ((ret = avfilter_link(src, srcpad, dst, dstpad))) {
@@ -55,7 +55,7 @@ static int link_filter(AVFilterContext *src, int srcpad,
* @return a pointer (that need to be freed after use) to the name
* between parenthesis
*/
-static char *parse_link_name(const char **buf, AVClass *log_ctx)
+static char *parse_link_name(const char **buf, void *log_ctx)
{
const char *start = *buf;
char *name;
@@ -92,7 +92,7 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx)
* @return 0 in case of success, a negative AVERROR code otherwise
*/
static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
- const char *filt_name, const char *args, AVClass *log_ctx)
+ const char *filt_name, const char *args, void *log_ctx)
{
AVFilter *filt;
char inst_name[30];
@@ -151,7 +151,7 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind
* @return 0 in case of success, a negative AVERROR code otherwise
*/
static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGraph *graph,
- int index, AVClass *log_ctx)
+ int index, void *log_ctx)
{
char *opts = NULL;
char *name = av_get_token(buf, "=,;[\n");
@@ -168,13 +168,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr
return ret;
}
-static void free_inout(AVFilterInOut *head)
+AVFilterInOut *avfilter_inout_alloc(void)
{
- while (head) {
- AVFilterInOut *next = head->next;
- av_free(head->name);
- av_free(head);
- head = next;
+ return av_mallocz(sizeof(AVFilterInOut));
+}
+
+void avfilter_inout_free(AVFilterInOut **inout)
+{
+ while (*inout) {
+ AVFilterInOut *next = (*inout)->next;
+ av_freep(&(*inout)->name);
+ av_freep(inout);
+ *inout = next;
}
}
@@ -201,7 +206,7 @@ static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element)
static int link_filter_inouts(AVFilterContext *filt_ctx,
AVFilterInOut **curr_inputs,
- AVFilterInOut **open_inputs, AVClass *log_ctx)
+ AVFilterInOut **open_inputs, void *log_ctx)
{
int pad = filt_ctx->input_count, ret;
@@ -249,7 +254,7 @@ static int link_filter_inouts(AVFilterContext *filt_ctx,
}
static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs,
- AVFilterInOut **open_outputs, AVClass *log_ctx)
+ AVFilterInOut **open_outputs, void *log_ctx)
{
int pad = 0;
@@ -284,7 +289,7 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs,
static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,
AVFilterInOut **open_inputs,
- AVFilterInOut **open_outputs, AVClass *log_ctx)
+ AVFilterInOut **open_outputs, void *log_ctx)
{
int ret, pad = 0;
@@ -328,8 +333,8 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,
}
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
- AVFilterInOut *open_inputs,
- AVFilterInOut *open_outputs, AVClass *log_ctx)
+ AVFilterInOut **open_inputs, AVFilterInOut **open_outputs,
+ void *log_ctx)
{
int index = 0, ret;
char chr = 0;
@@ -341,7 +346,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
const char *filterchain = filters;
filters += strspn(filters, WHITESPACES);
- if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
+ if ((ret = parse_inputs(&filters, &curr_inputs, open_outputs, log_ctx)) < 0)
goto fail;
if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
@@ -350,14 +355,14 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
if (filter->input_count == 1 && !curr_inputs && !index) {
/* First input can be omitted if it is "[in]" */
const char *tmp = "[in]";
- if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
+ if ((ret = parse_inputs(&tmp, &curr_inputs, open_outputs, log_ctx)) < 0)
goto fail;
}
- if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)
+ if ((ret = link_filter_inouts(filter, &curr_inputs, open_inputs, log_ctx)) < 0)
goto fail;
- if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
+ if ((ret = parse_outputs(&filters, &curr_inputs, open_inputs, open_outputs,
log_ctx)) < 0)
goto fail;
@@ -382,10 +387,10 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
goto fail;
}
- if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
+ if (*open_inputs && !strcmp((*open_inputs)->name, "out") && curr_inputs) {
/* Last output can be omitted if it is "[out]" */
const char *tmp = "[out]";
- if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
+ if ((ret = parse_outputs(&tmp, &curr_inputs, open_inputs, open_outputs,
log_ctx)) < 0)
goto fail;
}
@@ -396,8 +401,8 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
for (; graph->filter_count > 0; graph->filter_count--)
avfilter_free(graph->filters[graph->filter_count - 1]);
av_freep(&graph->filters);
- free_inout(open_inputs);
- free_inout(open_outputs);
- free_inout(curr_inputs);
+ avfilter_inout_free(open_inputs);
+ avfilter_inout_free(open_outputs);
+ avfilter_inout_free(&curr_inputs);
return ret;
}
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 159e979168..be1e9b08f2 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -31,7 +31,7 @@
typedef struct AVFilterPool {
AVFilterBufferRef *pic[POOL_SIZE];
int count;
-}AVFilterPool;
+} AVFilterPool;
/**
* Check for the validity of graph.
@@ -58,4 +58,4 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx);
/** default handler for freeing audio/video buffer when there are no references left */
void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
-#endif /* AVFILTER_INTERNAL_H */
+#endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/libmpcodecs/vf_detc.c b/libavfilter/libmpcodecs/vf_detc.c
index 8dd51da794..28d20e09b7 100644
--- a/libavfilter/libmpcodecs/vf_detc.c
+++ b/libavfilter/libmpcodecs/vf_detc.c
@@ -382,7 +382,7 @@ static void uninit(struct vf_instance *vf)
}
static struct {
- char *name;
+ const char *name;
int (*func)(struct vf_priv_s *p, mp_image_t *new, mp_image_t *old);
int needread;
} anal_funcs[] = {
diff --git a/libavfilter/libmpcodecs/vf_dint.c b/libavfilter/libmpcodecs/vf_dint.c
index 7038381221..ac5bf54a54 100644
--- a/libavfilter/libmpcodecs/vf_dint.c
+++ b/libavfilter/libmpcodecs/vf_dint.c
@@ -32,7 +32,7 @@ struct vf_priv_s {
float sense; // first parameter
float level; // second parameter
unsigned int imgfmt;
- char diff;
+ int diff;
uint32_t max;
// int dfr;
// int rdfr;
@@ -73,7 +73,7 @@ static int config (struct vf_instance *vf,
vf->priv->diff = 31;
mp_msg (MSGT_VFILTER, MSGL_INFO, "Drop-interlaced: %dx%d diff %d / level %u\n",
vf->priv->pmpi->width, vf->priv->pmpi->height,
- (int)vf->priv->diff, (unsigned int)vf->priv->max);
+ vf->priv->diff, (unsigned int)vf->priv->max);
// vf->priv->rdfr = vf->priv->dfr = 0;
vf->priv->was_dint = 0;
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
@@ -81,10 +81,10 @@ static int config (struct vf_instance *vf,
static int put_image (struct vf_instance *vf, mp_image_t *mpi, double pts)
{
- char rrow0[MAXROWSIZE];
- char rrow1[MAXROWSIZE];
- char rrow2[MAXROWSIZE];
- char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/;
+ int8_t rrow0[MAXROWSIZE];
+ int8_t rrow1[MAXROWSIZE];
+ int8_t rrow2[MAXROWSIZE];
+ int8_t *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/;
int rowsize = mpi->width;
uint32_t nok = 0, max = vf->priv->max;
int diff = vf->priv->diff;
diff --git a/libavfilter/libmpcodecs/vf_divtc.c b/libavfilter/libmpcodecs/vf_divtc.c
index 25447f0596..4c171d1728 100644
--- a/libavfilter/libmpcodecs/vf_divtc.c
+++ b/libavfilter/libmpcodecs/vf_divtc.c
@@ -42,7 +42,7 @@ struct vf_priv_s
ocount, sum[5];
double threshold;
FILE *file;
- char *bdata;
+ int8_t *bdata;
unsigned int *csdata;
int *history;
};
@@ -384,8 +384,8 @@ static int analyze(struct vf_priv_s *p)
{
int *buf=0, *bp, bufsize=0, n, b, f, i, j, m, s;
unsigned int *cbuf=0, *cp;
- char *pbuf;
- char lbuf[256];
+ int8_t *pbuf;
+ int8_t lbuf[256];
int sum[5];
double d;
@@ -598,7 +598,8 @@ static void uninit(struct vf_instance *vf)
static int vf_open(vf_instance_t *vf, char *args)
{
struct vf_priv_s *p;
- char *filename="framediff.log", *ap, *q, *a;
+ const char *filename="framediff.log";
+ char *ap, *q, *a;
if(args && !(args=av_strdup(args)))
{
diff --git a/libavfilter/libmpcodecs/vf_gradfun.c b/libavfilter/libmpcodecs/vf_gradfun.c
index 2732f55d9a..fd4236cc37 100644
--- a/libavfilter/libmpcodecs/vf_gradfun.c
+++ b/libavfilter/libmpcodecs/vf_gradfun.c
@@ -188,7 +188,7 @@ static void filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc,
}
#endif // HAVE_SSSE3
-#if HAVE_SSE2 && HAVE_6REGS
+#if HAVE_SSE && HAVE_6REGS
#define BLURV(load)\
intptr_t x = -2*width;\
__asm__ volatile(\
@@ -231,7 +231,7 @@ static void blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1,
BLURV("movdqa");
}
}
-#endif // HAVE_6REGS && HAVE_SSE2
+#endif // HAVE_6REGS && HAVE_SSE
static void filter(struct vf_priv_s *ctx, uint8_t *dst, uint8_t *src,
int width, int height, int dstride, int sstride, int r)
@@ -385,7 +385,7 @@ static int vf_open(vf_instance_t *vf, char *args)
vf->priv->blur_line = blur_line_c;
vf->priv->filter_line = filter_line_c;
-#if HAVE_SSE2 && HAVE_6REGS
+#if HAVE_SSE && HAVE_6REGS
if (gCpuCaps.hasSSE2)
vf->priv->blur_line = blur_line_sse2;
#endif
diff --git a/libavfilter/libmpcodecs/vf_ilpack.c b/libavfilter/libmpcodecs/vf_ilpack.c
index 77555a7b41..db4a849e1f 100644
--- a/libavfilter/libmpcodecs/vf_ilpack.c
+++ b/libavfilter/libmpcodecs/vf_ilpack.c
@@ -28,6 +28,7 @@
#include "img_format.h"
#include "mp_image.h"
#include "vf.h"
+#include "libavutil/attributes.h"
typedef void (pack_func_t)(unsigned char *dst, unsigned char *y,
unsigned char *u, unsigned char *v, int w, int us, int vs);
@@ -38,7 +39,8 @@ struct vf_priv_s {
};
static void pack_nn_C(unsigned char *dst, unsigned char *y,
- unsigned char *u, unsigned char *v, int w)
+ unsigned char *u, unsigned char *v, int w,
+ int av_unused us, int av_unused vs)
{
int j;
for (j = w/2; j; j--) {
@@ -77,7 +79,8 @@ static void pack_li_1_C(unsigned char *dst, unsigned char *y,
#if HAVE_MMX
static void pack_nn_MMX(unsigned char *dst, unsigned char *y,
- unsigned char *u, unsigned char *v, int w)
+ unsigned char *u, unsigned char *v, int w,
+ int av_unused us, int av_unused vs)
{
__asm__ volatile (""
ASMALIGN(4)
@@ -103,7 +106,7 @@ static void pack_nn_MMX(unsigned char *dst, unsigned char *y,
: "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8)
: "memory"
);
- pack_nn_C(dst, y, u, v, (w&7));
+ pack_nn_C(dst, y, u, v, (w&7), 0, 0);
}
#if HAVE_EBX_AVAILABLE
@@ -413,12 +416,12 @@ static int vf_open(vf_instance_t *vf, char *args)
vf->priv->mode = 1;
if (args) sscanf(args, "%d", &vf->priv->mode);
- pack_nn = (pack_func_t *)pack_nn_C;
+ pack_nn = pack_nn_C;
pack_li_0 = pack_li_0_C;
pack_li_1 = pack_li_1_C;
#if HAVE_MMX
if(gCpuCaps.hasMMX) {
- pack_nn = (pack_func_t *)pack_nn_MMX;
+ pack_nn = pack_nn_MMX;
#if HAVE_EBX_AVAILABLE
pack_li_0 = pack_li_0_MMX;
pack_li_1 = pack_li_1_MMX;
diff --git a/libavfilter/libmpcodecs/vf_pp7.c b/libavfilter/libmpcodecs/vf_pp7.c
index f8b64b658a..c075d6619c 100644
--- a/libavfilter/libmpcodecs/vf_pp7.c
+++ b/libavfilter/libmpcodecs/vf_pp7.c
@@ -286,8 +286,8 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri
int x, y;
const int stride= is_luma ? p->temp_stride : ((width+16+15)&(~15));
uint8_t *p_src= p->src + 8*stride;
- DCTELEM *block= p->src;
- DCTELEM *temp= p->src + 32;
+ DCTELEM *block= (DCTELEM *)p->src;
+ DCTELEM *temp= (DCTELEM *)(p->src + 32);
if (!src || !dst) return; // HACK avoid crash for Y8 colourspace
for(y=0; y<height; y++){
diff --git a/libavfilter/libmpcodecs/vf_sab.c b/libavfilter/libmpcodecs/vf_sab.c
index 377c9e33a8..51e9d78158 100644
--- a/libavfilter/libmpcodecs/vf_sab.c
+++ b/libavfilter/libmpcodecs/vf_sab.c
@@ -102,7 +102,7 @@ static int allocStuff(FilterParam *f, int width, int height){
swsF.lumH= swsF.lumV= vec;
swsF.chrH= swsF.chrV= NULL;
f->preFilterContext= sws_getContext(
- width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, get_sws_cpuflags()|SWS_POINT, &swsF, NULL, NULL);
+ width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, SWS_POINT, &swsF, NULL, NULL);
sws_freeVec(vec);
vec = sws_getGaussianVec(f->strength, 5.0);
diff --git a/libavfilter/libmpcodecs/vf_scale.h b/libavfilter/libmpcodecs/vf_scale.h
index 91ed103c30..4de3b48ec3 100644
--- a/libavfilter/libmpcodecs/vf_scale.h
+++ b/libavfilter/libmpcodecs/vf_scale.h
@@ -29,7 +29,6 @@ extern float sws_lum_sharpen;
extern int sws_flags;
-int get_sws_cpuflags(void);
struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
#endif /* MPLAYER_VF_SCALE_H */
diff --git a/libavfilter/libmpcodecs/vf_smartblur.c b/libavfilter/libmpcodecs/vf_smartblur.c
index 3e20880f04..5bfcb2806e 100644
--- a/libavfilter/libmpcodecs/vf_smartblur.c
+++ b/libavfilter/libmpcodecs/vf_smartblur.c
@@ -87,7 +87,7 @@ static int allocStuff(FilterParam *f, int width, int height){
swsF.lumH= swsF.lumV= vec;
swsF.chrH= swsF.chrV= NULL;
f->filterContext= sws_getContext(
- width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, SWS_BICUBIC | get_sws_cpuflags(), &swsF, NULL, NULL);
+ width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, SWS_BICUBIC, &swsF, NULL, NULL);
sws_freeVec(vec);
@@ -183,11 +183,11 @@ static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride,
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
int cw= mpi->w >> mpi->chroma_x_shift;
int ch= mpi->h >> mpi->chroma_y_shift;
- FilterParam *f= &vf->priv;
+ int threshold = vf->priv->luma.threshold || vf->priv->chroma.threshold;
mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|
- (f->threshold) ? MP_IMGFLAG_READABLE : 0,
+ (threshold ? MP_IMGFLAG_READABLE : 0),
mpi->w,mpi->h);
assert(mpi->flags&MP_IMGFLAG_PLANAR);
diff --git a/libavfilter/libmpcodecs/vf_unsharp.c b/libavfilter/libmpcodecs/vf_unsharp.c
index cd464321f4..db22f78e9d 100644
--- a/libavfilter/libmpcodecs/vf_unsharp.c
+++ b/libavfilter/libmpcodecs/vf_unsharp.c
@@ -132,7 +132,7 @@ static int config( struct vf_instance *vf,
int z, stepsX, stepsY;
FilterParam *fp;
- char *effect;
+ const char *effect;
// allocate buffers
diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 55dc13e9aa..8182a36531 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -264,11 +264,9 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
crop->x &= ~((1 << crop->hsub) - 1);
crop->y &= ~((1 << crop->vsub) - 1);
-#ifdef DEBUG
- av_log(ctx, AV_LOG_DEBUG,
- "n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
- (int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x, crop->y, crop->x+crop->w, crop->y+crop->h);
-#endif
+ av_dlog(ctx, "n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
+ (int)crop->var_values[VAR_N], crop->var_values[VAR_T], crop->x,
+ crop->y, crop->x+crop->w, crop->y+crop->h);
ref2->data[0] += crop->y * ref2->linesize[0];
ref2->data[0] += crop->x * crop->max_step[0];
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index b26029bb8f..cf0eb43344 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -49,9 +49,11 @@ typedef struct {
const AVClass *class;
uint8_t *fontfile; ///< font to be used
uint8_t *text; ///< text to be drawn
- uint8_t *text_priv; ///< used to detect whether text changed
+ uint8_t *expanded_text; ///< used to contain the strftime()-expanded text
+ size_t expanded_text_size; ///< size in bytes of the expanded_text buffer
int ft_load_flags; ///< flags used for loading fonts, see FT_LOAD_*
FT_Vector *positions; ///< positions for each element in the text
+ size_t nb_positions; ///< number of elements of positions array
char *textfile; ///< file with text to be drawn
unsigned int x; ///< x position to start drawing text
unsigned int y; ///< y position to start drawing text
@@ -84,37 +86,37 @@ typedef struct {
#define OFFSET(x) offsetof(DrawTextContext, x)
static const AVOption drawtext_options[]= {
-{"fontfile", "set font file", OFFSET(fontfile), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
-{"text", "set text", OFFSET(text), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
-{"textfile", "set text file", OFFSET(textfile), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
-{"fontcolor","set foreground color", OFFSET(fontcolor_string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
-{"boxcolor", "set box color", OFFSET(boxcolor_string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
-{"shadowcolor", "set shadow color", OFFSET(shadowcolor_string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
-{"box", "set box", OFFSET(draw_box), FF_OPT_TYPE_INT, 0, 0, 1 },
-{"fontsize", "set font size", OFFSET(fontsize), FF_OPT_TYPE_INT, 16, 1, 72 },
-{"x", "set x", OFFSET(x), FF_OPT_TYPE_INT, 0, 0, INT_MAX },
-{"y", "set y", OFFSET(y), FF_OPT_TYPE_INT, 0, 0, INT_MAX },
-{"shadowx", "set x", OFFSET(shadowx), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX },
-{"shadowy", "set y", OFFSET(shadowy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX },
-{"tabsize", "set tab size", OFFSET(tabsize), FF_OPT_TYPE_INT, 4, 0, INT_MAX },
+{"fontfile", "set font file", OFFSET(fontfile), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX },
+{"text", "set text", OFFSET(text), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX },
+{"textfile", "set text file", OFFSET(textfile), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX },
+{"fontcolor","set foreground color", OFFSET(fontcolor_string), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX },
+{"boxcolor", "set box color", OFFSET(boxcolor_string), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX },
+{"shadowcolor", "set shadow color", OFFSET(shadowcolor_string), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX },
+{"box", "set box", OFFSET(draw_box), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
+{"fontsize", "set font size", OFFSET(fontsize), FF_OPT_TYPE_INT, {.dbl=16}, 1, 72 },
+{"x", "set x", OFFSET(x), FF_OPT_TYPE_INT, {.dbl=0}, 0, INT_MAX },
+{"y", "set y", OFFSET(y), FF_OPT_TYPE_INT, {.dbl=0}, 0, INT_MAX },
+{"shadowx", "set x", OFFSET(shadowx), FF_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX },
+{"shadowy", "set y", OFFSET(shadowy), FF_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX },
+{"tabsize", "set tab size", OFFSET(tabsize), FF_OPT_TYPE_INT, {.dbl=4}, 0, INT_MAX },
/* FT_LOAD_* flags */
-{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), FF_OPT_TYPE_FLAGS, FT_LOAD_DEFAULT|FT_LOAD_RENDER, 0, INT_MAX, 0, "ft_load_flags" },
-{"default", "set default", 0, FF_OPT_TYPE_CONST, FT_LOAD_DEFAULT, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"no_scale", "set no_scale", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_SCALE, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"no_hinting", "set no_hinting", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_HINTING, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"render", "set render", 0, FF_OPT_TYPE_CONST, FT_LOAD_RENDER, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"no_bitmap", "set no_bitmap", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_BITMAP, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"vertical_layout", "set vertical_layout", 0, FF_OPT_TYPE_CONST, FT_LOAD_VERTICAL_LAYOUT, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"force_autohint", "set force_autohint", 0, FF_OPT_TYPE_CONST, FT_LOAD_FORCE_AUTOHINT, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"crop_bitmap", "set crop_bitmap", 0, FF_OPT_TYPE_CONST, FT_LOAD_CROP_BITMAP, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"pedantic", "set pedantic", 0, FF_OPT_TYPE_CONST, FT_LOAD_PEDANTIC, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"ignore_global_advance_width", "set ignore_global_advance_width", 0, FF_OPT_TYPE_CONST, FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"no_recurse", "set no_recurse", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_RECURSE, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"ignore_transform", "set ignore_transform", 0, FF_OPT_TYPE_CONST, FT_LOAD_IGNORE_TRANSFORM, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"monochrome", "set monochrome", 0, FF_OPT_TYPE_CONST, FT_LOAD_MONOCHROME, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"linear_design", "set linear_design", 0, FF_OPT_TYPE_CONST, FT_LOAD_LINEAR_DESIGN, INT_MIN, INT_MAX, 0, "ft_load_flags" },
-{"no_autohint", "set no_autohint", 0, FF_OPT_TYPE_CONST, FT_LOAD_NO_AUTOHINT, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), FF_OPT_TYPE_FLAGS, {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" },
+{"default", "set default", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_DEFAULT}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"no_scale", "set no_scale", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_SCALE}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"no_hinting", "set no_hinting", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_HINTING}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"render", "set render", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_RENDER}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"no_bitmap", "set no_bitmap", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"vertical_layout", "set vertical_layout", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_VERTICAL_LAYOUT}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"force_autohint", "set force_autohint", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_FORCE_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"crop_bitmap", "set crop_bitmap", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_CROP_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"pedantic", "set pedantic", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_PEDANTIC}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"ignore_global_advance_width", "set ignore_global_advance_width", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"no_recurse", "set no_recurse", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_RECURSE}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"ignore_transform", "set ignore_transform", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_IGNORE_TRANSFORM}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"monochrome", "set monochrome", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_MONOCHROME}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"linear_design", "set linear_design", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_LINEAR_DESIGN}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
+{"no_autohint", "set no_autohint", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" },
{NULL},
};
@@ -349,6 +351,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_freep(&dtext->fontfile);
av_freep(&dtext->text);
+ av_freep(&dtext->expanded_text);
av_freep(&dtext->fontcolor_string);
av_freep(&dtext->boxcolor_string);
av_freep(&dtext->positions);
@@ -517,7 +520,7 @@ static inline int is_newline(uint32_t c)
static int draw_glyphs(DrawTextContext *dtext, AVFilterBufferRef *picref,
int width, int height, const uint8_t rgbcolor[4], const uint8_t yuvcolor[4], int x, int y)
{
- char *text = dtext->text;
+ char *text = HAVE_LOCALTIME_R ? dtext->expanded_text : dtext->text;
uint32_t code = 0;
int i;
uint8_t *p;
@@ -559,45 +562,51 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
uint32_t code = 0, prev_code = 0;
int x = 0, y = 0, i = 0, ret;
int text_height, baseline;
+ char *text = dtext->text;
uint8_t *p;
- int str_w = 0;
+ int str_w = 0, len;
int y_min = 32000, y_max = -32000;
FT_Vector delta;
Glyph *glyph = NULL, *prev_glyph = NULL;
Glyph dummy = { 0 };
- if (dtext->text != dtext->text_priv) {
#if HAVE_LOCALTIME_R
- time_t now = time(0);
- struct tm ltime;
- uint8_t *buf = NULL;
- int buflen = 2*strlen(dtext->text) + 1, len;
-
- localtime_r(&now, &ltime);
-
- while ((buf = av_realloc(buf, buflen))) {
- *buf = 1;
- if ((len = strftime(buf, buflen, dtext->text, &ltime)) != 0 || *buf == 0)
- break;
- buflen *= 2;
- }
- if (!buf)
- return AVERROR(ENOMEM);
- av_freep(&dtext->text);
- dtext->text = dtext->text_priv = buf;
-#else
- dtext->text_priv = dtext->text;
+ time_t now = time(0);
+ struct tm ltime;
+ uint8_t *buf = dtext->expanded_text;
+ int buf_size = dtext->expanded_text_size;
+
+ if (!buf) {
+ buf_size = 2*strlen(dtext->text)+1;
+ buf = av_malloc(buf_size);
+ }
+
+ localtime_r(&now, &ltime);
+
+ do {
+ *buf = 1;
+ if (strftime(buf, buf_size, dtext->text, &ltime) != 0 || *buf == 0)
+ break;
+ buf_size *= 2;
+ } while ((buf = av_realloc(buf, buf_size)));
+
+ if (!buf)
+ return AVERROR(ENOMEM);
+ text = dtext->expanded_text = buf;
+ dtext->expanded_text_size = buf_size;
#endif
- if (!(dtext->positions = av_realloc(dtext->positions,
- strlen(dtext->text)*sizeof(*dtext->positions))))
+ if ((len = strlen(text)) > dtext->nb_positions) {
+ if (!(dtext->positions =
+ av_realloc(dtext->positions, len*sizeof(*dtext->positions))))
return AVERROR(ENOMEM);
+ dtext->nb_positions = len;
}
x = dtext->x;
y = dtext->y;
/* load and cache glyphs */
- for (i = 0, p = dtext->text; *p; i++) {
+ for (i = 0, p = text; *p; i++) {
GET_UTF8(code, *p++, continue;);
/* get glyph */
@@ -614,7 +623,7 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
/* compute and save position for each glyph */
glyph = NULL;
- for (i = 0, p = dtext->text; *p; i++) {
+ for (i = 0, p = text; *p; i++) {
GET_UTF8(code, *p++, continue;);
/* skip the \n in the sequence \r\n */
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index 59ca77821a..0913b6950e 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -153,7 +153,7 @@ static void end_frame(AVFilterLink *inlink)
AVFilterBufferRef *inpicref = inlink->cur_buf;
AVFilterBufferRef *outpicref = outlink->out_buf;
- int h, w, plane, line_step, line_size, line;
+ int h, plane, line_step, line_size, line;
uint8_t *cpy_src, *cpy_dst;
if ( inpicref->video->interlaced
@@ -162,7 +162,6 @@ static void end_frame(AVFilterLink *inlink)
"picture will move %s one line\n",
fieldorder->dst_tff ? "up" : "down");
h = inpicref->video->h;
- w = inpicref->video->w;
for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) {
line_step = inpicref->linesize[plane];
line_size = fieldorder->line_size[plane];
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index 83ed3d79e4..32dd3c1072 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -49,7 +49,7 @@ DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = {
{0x54,0x34,0x4C,0x2C,0x52,0x32,0x4A,0x2A},
};
-void ff_gradfun_filter_line_c(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
+void ff_gradfun_filter_line_c(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
{
int x;
for (x = 0; x < width; x++, dc += x & 1) {
@@ -63,7 +63,7 @@ void ff_gradfun_filter_line_c(uint8_t *dst, uint8_t *src, uint16_t *dc, int widt
}
}
-void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
+void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width)
{
int x, v, old;
for (x = 0; x < width; x++) {
@@ -74,7 +74,7 @@ void ff_gradfun_blur_line_c(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t
}
}
-static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, int height, int dst_linesize, int src_linesize, int r)
+static void filter(GradFunContext *ctx, uint8_t *dst, const uint8_t *src, int width, int height, int dst_linesize, int src_linesize, int r)
{
int bstride = FFALIGN(width, 16) / 2;
int y;
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 8401b4dcb7..d21acade0e 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -26,7 +26,7 @@
/* #define DEBUG */
#include <opencv/cv.h>
-#include <opencv/cxtypes.h>
+#include <opencv/cxcore.h>
#include "libavutil/avstring.h"
#include "libavutil/file.h"
#include "avfilter.h"
diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c
index 866dbb16d2..0642b44f00 100644
--- a/libavfilter/vf_mp.c
+++ b/libavfilter/vf_mp.c
@@ -287,15 +287,6 @@ zrmjpeg
CpuCaps gCpuCaps; //FIXME initialize this so optims work
-//exact copy from vf_scale.c
-int get_sws_cpuflags(void){
- return
- (gCpuCaps.hasMMX ? SWS_CPU_CAPS_MMX : 0)
- | (gCpuCaps.hasMMX2 ? SWS_CPU_CAPS_MMX2 : 0)
- | (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0)
- | (gCpuCaps.hasAltiVec ? SWS_CPU_CAPS_ALTIVEC : 0);
-}
-
static void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam)
{
static int firstTime=1;
@@ -348,7 +339,7 @@ struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat,
if (srcFormat == IMGFMT_RGB8 || srcFormat == IMGFMT_BGR8) sfmt = PIX_FMT_PAL8;
sws_getFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam);
- return sws_getContext(srcW, srcH, sfmt, dstW, dstH, dfmt, flags | get_sws_cpuflags(), srcFilterParam, dstFilterParam, NULL);
+ return sws_getContext(srcW, srcH, sfmt, dstW, dstH, dfmt, flags , srcFilterParam, dstFilterParam, NULL);
}
typedef struct {
@@ -891,7 +882,7 @@ static void end_frame(AVFilterLink *inlink)
}
free_mp_image(mpi);
-// avfilter_unref_buffer(inpic);
+ avfilter_unref_buffer(inpic);
}
AVFilter avfilter_vf_mp = {
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 9ff93bd411..e172a2e586 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -270,7 +270,8 @@ static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h,
ScaleContext *scale = link->dst->priv;
AVFilterBufferRef *cur_pic = link->cur_buf;
AVFilterBufferRef *out_buf = link->dst->outputs[0]->out_buf;
- const uint8_t *in[4], *out[4];
+ const uint8_t *in[4];
+ uint8_t *out[4];
int in_stride[4],out_stride[4];
int i;
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c
new file mode 100644
index 0000000000..3d05167d13
--- /dev/null
+++ b/libavfilter/vf_select.c
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 2011 Stefano Sabatini
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * filter for selecting which frame passes in the filterchain
+ */
+
+#include "libavutil/eval.h"
+#include "libavutil/fifo.h"
+#include "avfilter.h"
+
+static const char *var_names[] = {
+ "E", ///< Euler number
+ "PHI", ///< golden ratio
+ "PI", ///< greek pi
+
+ "TB", ///< timebase
+
+ "pts", ///< original pts in the file of the frame
+ "start_pts", ///< first PTS in the stream, expressed in TB units
+ "prev_pts", ///< previous frame PTS
+ "prev_selected_pts", ///< previous selected frame PTS
+
+ "t", ///< first PTS in seconds
+ "start_t", ///< first PTS in the stream, expressed in seconds
+ "prev_t", ///< previous frame time
+ "prev_selected_t", ///< previously selected time
+
+ "pict_type", ///< the type of picture in the movie
+ "PICT_TYPE_I",
+ "PICT_TYPE_P",
+ "PICT_TYPE_B",
+ "PICT_TYPE_S",
+ "PICT_TYPE_SI",
+ "PICT_TYPE_SP",
+ "PICT_TYPE_BI",
+
+ "interlace_type", ///< the frame interlace type
+ "INTERLACE_TYPE_P",
+ "INTERLACE_TYPE_T",
+ "INTERLACE_TYPE_B",
+
+ "n", ///< frame number (starting from zero)
+ "selected_n", ///< selected frame number (starting from zero)
+ "prev_selected_n", ///< number of the last selected frame
+
+ "key", ///< tell if the frame is a key frame
+ "pos", ///< original position in the file of the frame
+
+ NULL
+};
+
+enum var_name {
+ VAR_E,
+ VAR_PHI,
+ VAR_PI,
+
+ VAR_TB,
+
+ VAR_PTS,
+ VAR_START_PTS,
+ VAR_PREV_PTS,
+ VAR_PREV_SELECTED_PTS,
+
+ VAR_T,
+ VAR_START_T,
+ VAR_PREV_T,
+ VAR_PREV_SELECTED_T,
+
+ VAR_PICT_TYPE,
+ VAR_PICT_TYPE_I,
+ VAR_PICT_TYPE_P,
+ VAR_PICT_TYPE_B,
+ VAR_PICT_TYPE_S,
+ VAR_PICT_TYPE_SI,
+ VAR_PICT_TYPE_SP,
+ VAR_PICT_TYPE_BI,
+
+ VAR_INTERLACE_TYPE,
+ VAR_INTERLACE_TYPE_P,
+ VAR_INTERLACE_TYPE_T,
+ VAR_INTERLACE_TYPE_B,
+
+ VAR_N,
+ VAR_SELECTED_N,
+ VAR_PREV_SELECTED_N,
+
+ VAR_KEY,
+ VAR_POS,
+
+ VAR_VARS_NB
+};
+
+#define FIFO_SIZE 8
+
+typedef struct {
+ AVExpr *expr;
+ double var_values[VAR_VARS_NB];
+ double select;
+ int cache_frames;
+ AVFifoBuffer *pending_frames; ///< FIFO buffer of video frames
+} SelectContext;
+
+static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+ SelectContext *select = ctx->priv;
+ int ret;
+
+ if ((ret = av_expr_parse(&select->expr, args ? args : "1",
+ var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
+ av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", args);
+ return ret;
+ }
+
+ select->pending_frames = av_fifo_alloc(FIFO_SIZE*sizeof(AVFilterBufferRef*));
+ if (!select->pending_frames) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to allocate pending frames buffer.\n");
+ return AVERROR(ENOMEM);
+ }
+ return 0;
+}
+
+#define INTERLACE_TYPE_P 0
+#define INTERLACE_TYPE_T 1
+#define INTERLACE_TYPE_B 2
+
+static int config_input(AVFilterLink *inlink)
+{
+ SelectContext *select = inlink->dst->priv;
+
+ select->var_values[VAR_E] = M_E;
+ select->var_values[VAR_PHI] = M_PHI;
+ select->var_values[VAR_PI] = M_PI;
+
+ select->var_values[VAR_N] = 0.0;
+ select->var_values[VAR_SELECTED_N] = 0.0;
+
+ select->var_values[VAR_TB] = av_q2d(inlink->time_base);
+
+ select->var_values[VAR_PREV_PTS] = NAN;
+ select->var_values[VAR_PREV_SELECTED_PTS] = NAN;
+ select->var_values[VAR_PREV_SELECTED_T] = NAN;
+ select->var_values[VAR_START_PTS] = NAN;
+ select->var_values[VAR_START_T] = NAN;
+
+ select->var_values[VAR_PICT_TYPE_I] = AV_PICTURE_TYPE_I;
+ select->var_values[VAR_PICT_TYPE_P] = AV_PICTURE_TYPE_P;
+ select->var_values[VAR_PICT_TYPE_B] = AV_PICTURE_TYPE_B;
+ select->var_values[VAR_PICT_TYPE_SI] = AV_PICTURE_TYPE_SI;
+ select->var_values[VAR_PICT_TYPE_SP] = AV_PICTURE_TYPE_SP;
+
+ select->var_values[VAR_INTERLACE_TYPE_P] = INTERLACE_TYPE_P;
+ select->var_values[VAR_INTERLACE_TYPE_T] = INTERLACE_TYPE_T;
+ select->var_values[VAR_INTERLACE_TYPE_B] = INTERLACE_TYPE_B;;
+
+ return 0;
+}
+
+#define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
+#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
+
+static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *picref)
+{
+ SelectContext *select = ctx->priv;
+ AVFilterLink *inlink = ctx->inputs[0];
+ double res;
+
+ if (isnan(select->var_values[VAR_START_PTS]))
+ select->var_values[VAR_START_PTS] = TS2D(picref->pts);
+
+ select->var_values[VAR_PTS] = TS2D(picref->pts);
+ select->var_values[VAR_T ] = picref->pts * av_q2d(inlink->time_base);
+ select->var_values[VAR_POS] = picref->pos == -1 ? NAN : picref->pos;
+ select->var_values[VAR_PREV_PTS] = TS2D(picref ->pts);
+
+ select->var_values[VAR_INTERLACE_TYPE] =
+ !picref->video->interlaced ? INTERLACE_TYPE_P :
+ picref->video->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
+ select->var_values[VAR_PICT_TYPE] = picref->video->pict_type;
+
+ res = av_expr_eval(select->expr, select->var_values, NULL);
+ av_log(inlink->dst, AV_LOG_DEBUG,
+ "n:%d pts:%d t:%f pos:%d interlace_type:%c key:%d pict_type:%c "
+ "-> select:%f\n",
+ (int)select->var_values[VAR_N],
+ (int)select->var_values[VAR_PTS],
+ select->var_values[VAR_T],
+ (int)select->var_values[VAR_POS],
+ select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' :
+ select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' :
+ select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?',
+ (int)select->var_values[VAR_KEY],
+ av_get_picture_type_char(select->var_values[VAR_PICT_TYPE]),
+ res);
+
+ select->var_values[VAR_N] += 1.0;
+
+ if (res) {
+ select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];
+ select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS];
+ select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];
+ select->var_values[VAR_SELECTED_N] += 1.0;
+ }
+ return res;
+}
+
+static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+{
+ SelectContext *select = inlink->dst->priv;
+
+ select->select = select_frame(inlink->dst, picref);
+ if (select->select) {
+ /* frame was requested through poll_frame */
+ if (select->cache_frames) {
+ if (!av_fifo_space(select->pending_frames))
+ av_log(inlink->dst, AV_LOG_ERROR,
+ "Buffering limit reached, cannot cache more frames\n");
+ else
+ av_fifo_generic_write(select->pending_frames, &picref,
+ sizeof(picref), NULL);
+ return;
+ }
+ avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0));
+ }
+}
+
+static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+{
+ SelectContext *select = inlink->dst->priv;
+
+ if (select->select && !select->cache_frames)
+ avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+}
+
+static void end_frame(AVFilterLink *inlink)
+{
+ SelectContext *select = inlink->dst->priv;
+ AVFilterBufferRef *picref = inlink->cur_buf;
+
+ if (select->select) {
+ if (select->cache_frames)
+ return;
+ avfilter_end_frame(inlink->dst->outputs[0]);
+ }
+ avfilter_unref_buffer(picref);
+}
+
+static int request_frame(AVFilterLink *outlink)
+{
+ AVFilterContext *ctx = outlink->src;
+ SelectContext *select = ctx->priv;
+ AVFilterLink *inlink = outlink->src->inputs[0];
+ select->select = 0;
+
+ if (av_fifo_size(select->pending_frames)) {
+ AVFilterBufferRef *picref;
+ av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL);
+ avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
+ avfilter_draw_slice(outlink, 0, outlink->h, 1);
+ avfilter_end_frame(outlink);
+ avfilter_unref_buffer(picref);
+ return 0;
+ }
+
+ while (!select->select) {
+ int ret = avfilter_request_frame(inlink);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int poll_frame(AVFilterLink *outlink)
+{
+ SelectContext *select = outlink->src->priv;
+ AVFilterLink *inlink = outlink->src->inputs[0];
+ int count, ret;
+
+ if (!av_fifo_size(select->pending_frames)) {
+ if ((count = avfilter_poll_frame(inlink)) <= 0)
+ return count;
+ /* request frame from input, and apply select condition to it */
+ select->cache_frames = 1;
+ while (count-- && av_fifo_space(select->pending_frames)) {
+ ret = avfilter_request_frame(inlink);
+ if (ret < 0)
+ break;
+ }
+ select->cache_frames = 0;
+ }
+
+ return av_fifo_size(select->pending_frames)/sizeof(AVFilterBufferRef *);
+}
+
+static av_cold void uninit(AVFilterContext *ctx)
+{
+ SelectContext *select = ctx->priv;
+ AVFilterBufferRef *picref;
+ int i;
+
+ av_expr_free(select->expr);
+ select->expr = NULL;
+
+ for (i = 0; i < av_fifo_size(select->pending_frames)/sizeof(picref); i++) {
+ av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL);
+ avfilter_unref_buffer(picref);
+ }
+ av_fifo_free(select->pending_frames);
+}
+
+AVFilter avfilter_vf_select = {
+ .name = "select",
+ .description = NULL_IF_CONFIG_SMALL("Select frames to pass in output."),
+ .init = init,
+ .uninit = uninit,
+
+ .priv_size = sizeof(SelectContext),
+
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .get_video_buffer = avfilter_null_get_video_buffer,
+ .config_props = config_input,
+ .start_frame = start_frame,
+ .draw_slice = draw_slice,
+ .end_frame = end_frame },
+ { .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .poll_frame = poll_frame,
+ .request_frame = request_frame, },
+ { .name = NULL}},
+};
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index d512199602..82aa3b9901 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -43,19 +43,25 @@ static void end_frame(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->dst;
ShowInfoContext *showinfo = ctx->priv;
AVFilterBufferRef *picref = inlink->cur_buf;
- uint32_t plane_crc[4], crc = 0;
- int plane;
+ uint32_t plane_checksum[4] = {0}, checksum = 0;
+ int i, plane, vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
- for (plane = 0; plane < 4; plane++) {
+ for (plane = 0; picref->data[plane] && plane < 4; plane++) {
size_t linesize = av_image_get_linesize(picref->format, picref->video->w, plane);
- plane_crc[plane] = av_adler32_update(0 , picref->data[plane], linesize);
- crc = av_adler32_update(crc, picref->data[plane], linesize);
+ uint8_t *data = picref->data[plane];
+ int h = plane == 1 || plane == 2 ? inlink->h >> vsub : inlink->h;
+
+ for (i = 0; i < h; i++) {
+ plane_checksum[plane] = av_adler32_update(plane_checksum[plane], data, linesize);
+ checksum = av_adler32_update(checksum, data, linesize);
+ data += picref->linesize[plane];
+ }
}
av_log(ctx, AV_LOG_INFO,
"n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" "
"fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
- "crc:%u plane_crc:[%u %u %u %u]\n",
+ "checksum:%u plane_checksum:[%u %u %u %u]\n",
showinfo->frame,
picref->pts, picref ->pts * av_q2d(inlink->time_base), picref->pos,
av_pix_fmt_descriptors[picref->format].name,
@@ -65,7 +71,7 @@ static void end_frame(AVFilterLink *inlink)
picref->video->top_field_first ? 'T' : 'B', /* Top / Bottom */
picref->video->key_frame,
av_get_picture_type_char(picref->video->pict_type),
- crc, plane_crc[0], plane_crc[1], plane_crc[2], plane_crc[3]);
+ checksum, plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3]);
showinfo->frame++;
avfilter_end_frame(inlink->dst->outputs[0]);
@@ -83,7 +89,7 @@ AVFilter avfilter_vf_showinfo = {
.get_video_buffer = avfilter_null_get_video_buffer,
.start_frame = avfilter_null_start_frame,
.end_frame = end_frame,
- .min_perms = AV_PERM_READ, },
+ .min_perms = AV_PERM_READ, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
diff --git a/libavfilter/vf_split.c b/libavfilter/vf_split.c
new file mode 100644
index 0000000000..cbebf264fa
--- /dev/null
+++ b/libavfilter/vf_split.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2007 Bobby Bingham
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Video splitter
+ */
+
+#include "avfilter.h"
+
+static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+{
+ avfilter_start_frame(inlink->dst->outputs[0],
+ avfilter_ref_buffer(picref, ~AV_PERM_WRITE));
+ avfilter_start_frame(inlink->dst->outputs[1],
+ avfilter_ref_buffer(picref, ~AV_PERM_WRITE));
+}
+
+static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+{
+ avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+ avfilter_draw_slice(inlink->dst->outputs[1], y, h, slice_dir);
+}
+
+static void end_frame(AVFilterLink *inlink)
+{
+ avfilter_end_frame(inlink->dst->outputs[0]);
+ avfilter_end_frame(inlink->dst->outputs[1]);
+
+ avfilter_unref_buffer(inlink->cur_buf);
+}
+
+AVFilter avfilter_vf_split = {
+ .name = "split",
+ .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."),
+
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .get_video_buffer= avfilter_null_get_video_buffer,
+ .start_frame = start_frame,
+ .draw_slice = draw_slice,
+ .end_frame = end_frame, },
+ { .name = NULL}},
+ .outputs = (AVFilterPad[]) {{ .name = "output1",
+ .type = AVMEDIA_TYPE_VIDEO, },
+ { .name = "output2",
+ .type = AVMEDIA_TYPE_VIDEO, },
+ { .name = NULL}},
+};
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 7aa7a43651..fa75de5d94 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -63,7 +63,7 @@ typedef struct {
FilterParam chroma; ///< chroma parameters (width, height, amount)
} UnsharpContext;
-static void unsharpen(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride, int width, int height, FilterParam *fp)
+static void unsharpen(uint8_t *dst, const uint8_t *src, int dst_stride, int src_stride, int width, int height, FilterParam *fp)
{
uint32_t **sc = fp->sc;
uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;
@@ -96,7 +96,7 @@ static void unsharpen(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride
tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2;
}
if (x >= fp->steps_x && y >= fp->steps_y) {
- uint8_t* srx = src - fp->steps_y * src_stride + x - fp->steps_x;
+ const uint8_t* srx = src - fp->steps_y * src_stride + x - fp->steps_x;
uint8_t* dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x;
res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16);
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 84f3b33c3f..246444b3ac 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -29,8 +29,7 @@
#include "libavutil/imgutils.h"
typedef struct {
- AVFrame frame;
- int has_frame;
+ AVFilterBufferRef *picref;
int h, w;
enum PixelFormat pix_fmt;
AVRational time_base; ///< time_base to set in the output link
@@ -38,92 +37,114 @@ typedef struct {
char sws_param[256];
} BufferSourceContext;
-int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,
- const char *sws_param)
+int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter,
+ AVFilterBufferRef *picref, int flags)
{
BufferSourceContext *c = buffer_filter->priv;
+ AVFilterLink *outlink = buffer_filter->outputs[0];
int ret;
- if (c->has_frame) {
- av_log(buffer_filter, AV_LOG_ERROR,
- "Buffering several frames is not supported. "
- "Please consume all available frames before adding a new one.\n"
- );
- //return -1;
- }
-
- if(!c->sws_param[0]){
- snprintf(c->sws_param, 255, "%d:%d:%s", c->w, c->h, sws_param);
+ if (c->picref) {
+ if (flags & AV_VSRC_BUF_FLAG_OVERWRITE) {
+ avfilter_unref_buffer(c->picref);
+ c->picref = NULL;
+ } else {
+ av_log(buffer_filter, AV_LOG_ERROR,
+ "Buffering several frames is not supported. "
+ "Please consume all available frames before adding a new one.\n");
+ return AVERROR(EINVAL);
+ }
}
- if (frame->width != c->w || frame->height != c->h || frame->format != c->pix_fmt) {
- AVFilterContext *scale= buffer_filter->outputs[0]->dst;
+ if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
+ AVFilterContext *scale = buffer_filter->outputs[0]->dst;
AVFilterLink *link;
+ char scale_param[1024];
av_log(buffer_filter, AV_LOG_INFO,
"Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
- frame->width, frame->height, av_pix_fmt_descriptors[frame->format].name);
+ picref->video->w, picref->video->h, av_pix_fmt_descriptors[picref->format].name);
- if(!scale || strcmp(scale->filter->name,"scale")){
- AVFilter *f= avfilter_get_by_name("scale");
+ if (!scale || strcmp(scale->filter->name, "scale")) {
+ AVFilter *f = avfilter_get_by_name("scale");
av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n");
- if(avfilter_open(&scale, f, "Input equalizer") < 0)
- return -1;
+ if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
+ return ret;
- if((ret=avfilter_init_filter(scale, c->sws_param, NULL))<0){
+ snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
+ if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
avfilter_free(scale);
return ret;
}
- if((ret=avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0))<0){
+ if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
avfilter_free(scale);
return ret;
}
scale->outputs[0]->time_base = scale->inputs[0]->time_base;
scale->outputs[0]->format= c->pix_fmt;
- } else if(!strcmp(scale->filter->name, "scale")) {
- snprintf(c->sws_param, 255, "%d:%d:%s", scale->outputs[0]->w, scale->outputs[0]->h, sws_param);
- scale->filter->init(scale, c->sws_param, NULL);
+ } else if (!strcmp(scale->filter->name, "scale")) {
+ snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s",
+ scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
+ scale->filter->init(scale, scale_param, NULL);
}
- c->pix_fmt = scale->inputs[0]->format = frame->format;
- c->w = scale->inputs[0]->w = frame->width;
- c->h = scale->inputs[0]->h = frame->height;
+ c->pix_fmt = scale->inputs[0]->format = picref->format;
+ c->w = scale->inputs[0]->w = picref->video->w;
+ c->h = scale->inputs[0]->h = picref->video->h;
- link= scale->outputs[0];
+ link = scale->outputs[0];
if ((ret = link->srcpad->config_props(link)) < 0)
return ret;
}
- c->frame = *frame;
- memcpy(c->frame.data , frame->data , sizeof(frame->data));
- memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize));
- c->has_frame = 1;
+ c->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
+ picref->video->w, picref->video->h);
+ av_image_copy(c->picref->data, c->picref->linesize,
+ picref->data, picref->linesize,
+ picref->format, picref->video->w, picref->video->h);
+ avfilter_copy_buffer_ref_props(c->picref, picref);
return 0;
}
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)
+#if CONFIG_AVCODEC
+#include "avcodec.h"
+
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
+ const AVFrame *frame, int flags)
{
- return av_vsrc_buffer_add_frame2(buffer_filter, frame, "");
+ int ret;
+ AVFilterBufferRef *picref =
+ avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
+ if (!picref)
+ return AVERROR(ENOMEM);
+ ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref, flags);
+ picref->buf->data[0] = NULL;
+ avfilter_unref_buffer(picref);
+
+ return ret;
}
+#endif
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
{
BufferSourceContext *c = ctx->priv;
char pix_fmt_str[128];
int n = 0;
+ *c->sws_param = 0;
if (!args ||
- (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d", &c->w, &c->h, pix_fmt_str,
+ (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d:%255c", &c->w, &c->h, pix_fmt_str,
&c->time_base.num, &c->time_base.den,
- &c->sample_aspect_ratio.num, &c->sample_aspect_ratio.den)) != 7) {
- av_log(ctx, AV_LOG_ERROR, "Expected 7 arguments, but only %d found in '%s'\n", n, args);
+ &c->sample_aspect_ratio.num, &c->sample_aspect_ratio.den, c->sws_param)) < 7) {
+ av_log(ctx, AV_LOG_ERROR, "Expected at least 7 arguments, but only %d found in '%s'\n", n, args);
return AVERROR(EINVAL);
}
+
if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) {
char *tail;
c->pix_fmt = strtol(pix_fmt_str, &tail, 10);
@@ -133,10 +154,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
}
}
- av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d\n",
+ av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s\n",
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
c->time_base.num, c->time_base.den,
- c->sample_aspect_ratio.num, c->sample_aspect_ratio.den);
+ c->sample_aspect_ratio.num, c->sample_aspect_ratio.den, c->sws_param);
return 0;
}
@@ -164,31 +185,18 @@ static int config_props(AVFilterLink *link)
static int request_frame(AVFilterLink *link)
{
BufferSourceContext *c = link->src->priv;
- AVFilterBufferRef *picref;
- if (!c->has_frame) {
- av_log(link->src, AV_LOG_ERROR,
+ if (!c->picref) {
+ av_log(link->src, AV_LOG_WARNING,
"request_frame() called with no available frame!\n");
- //return -1;
+ return AVERROR(EINVAL);
}
- /* This picture will be needed unmodified later for decoding the next
- * frame */
- picref = avfilter_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
- AV_PERM_REUSE2,
- link->w, link->h);
-
- av_image_copy(picref->data, picref->linesize,
- c->frame.data, c->frame.linesize,
- picref->format, link->w, link->h);
- avfilter_copy_frame_props(picref, &c->frame);
-
- avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
+ avfilter_start_frame(link, avfilter_ref_buffer(c->picref, ~0));
avfilter_draw_slice(link, 0, link->h, 1);
avfilter_end_frame(link);
- avfilter_unref_buffer(picref);
-
- c->has_frame = 0;
+ avfilter_unref_buffer(c->picref);
+ c->picref = NULL;
return 0;
}
@@ -196,7 +204,7 @@ static int request_frame(AVFilterLink *link)
static int poll_frame(AVFilterLink *link)
{
BufferSourceContext *c = link->src->priv;
- return !!(c->has_frame);
+ return !!(c->picref);
}
AVFilter avfilter_vsrc_buffer = {
diff --git a/libavfilter/vsrc_buffer.h b/libavfilter/vsrc_buffer.h
index 2dda546e01..b661d414ea 100644
--- a/libavfilter/vsrc_buffer.h
+++ b/libavfilter/vsrc_buffer.h
@@ -1,5 +1,4 @@
/*
- * Memory buffer source filter
* Copyright (c) 2008 Vitor Sessak
*
* This file is part of FFmpeg.
@@ -27,12 +26,24 @@
* memory buffer source API for video
*/
-#include "libavcodec/avcodec.h" /* AVFrame */
#include "avfilter.h"
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame);
+/**
+ * Tell av_vsrc_buffer_add_video_buffer_ref() to overwrite the already
+ * cached video buffer with the new added one, otherwise the function
+ * will complain and exit.
+ */
+#define AV_VSRC_BUF_FLAG_OVERWRITE 1
-int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,
- const char *sws_param);
+/**
+ * Add video buffer data in picref to buffer_src.
+ *
+ * @param buffer_src pointer to a buffer source context
+ * @param flags a combination of AV_VSRC_BUF_FLAG_* flags
+ * @return >= 0 in case of success, a negative AVERROR code in case of
+ * failure
+ */
+int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_src,
+ AVFilterBufferRef *picref, int flags);
#endif /* AVFILTER_VSRC_BUFFER_H */
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index e36412f480..6c5c831fed 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -153,7 +153,7 @@ static int movie_init(AVFilterContext *ctx)
movie->w = movie->codec_ctx->width;
movie->h = movie->codec_ctx->height;
- av_log(ctx, AV_LOG_INFO, "seek_point:%lld format_name:%s file_name:%s stream_index:%d\n",
+ av_log(ctx, AV_LOG_INFO, "seek_point:%"PRIi64" format_name:%s file_name:%s stream_index:%d\n",
movie->seek_point, movie->format_name, movie->file_name,
movie->stream_index);
diff --git a/libavfilter/x86/gradfun.c b/libavfilter/x86/gradfun.c
index 894a44b9ff..05d4a6fd6e 100644
--- a/libavfilter/x86/gradfun.c
+++ b/libavfilter/x86/gradfun.c
@@ -23,7 +23,7 @@
DECLARE_ALIGNED(16, static const uint16_t, pw_7f)[8] = {0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F};
DECLARE_ALIGNED(16, static const uint16_t, pw_ff)[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
-void ff_gradfun_filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
+void ff_gradfun_filter_line_mmx2(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
{
#if HAVE_MMX
intptr_t x;
@@ -71,7 +71,7 @@ void ff_gradfun_filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc, int w
#endif
}
-void ff_gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers)
+void ff_gradfun_filter_line_ssse3(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
{
#if HAVE_SSSE3
intptr_t x;
@@ -118,7 +118,7 @@ void ff_gradfun_filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc, int
#endif // HAVE_SSSE3
}
-void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int src_linesize, int width)
+void ff_gradfun_blur_line_sse2(uint16_t *dc, uint16_t *buf, const uint16_t *buf1, const uint8_t *src, int src_linesize, int width)
{
#if HAVE_SSE
#define BLURV(load)\