diff --git a/CREDITS b/CREDITS index 1d0666b6df..e29f0b853c 100644 --- a/CREDITS +++ b/CREDITS @@ -1,55 +1,6 @@ -This file contains the names of some of the people who have contributed to -FFmpeg. The names are sorted alphabetically by last name. As this file is -currently quite outdated and git serves as a much better tool for determining -authorship, it remains here for historical reasons only. +See the Git history of the project (git://source.ffmpeg.org/ffmpeg) to +get the names of people who have contributed to FFmpeg. -Dénes Balatoni -Michel Bardiaux -Fabrice Bellard -Patrice Bensoussan -Alex Beregszaszi -BERO -Thilo Borgmann -Mario Brito -Ronald Bultje -Alex Converse -Maarten Daniels -Reimar Doeffinger -Tim Ferguson -Brian Foley -Arpad Gereoffy -Philip Gladstone -Vladimir Gneushev -Roine Gustafsson -David Hammerton -Wolfgang Hesseler -Marc Hoffman -Falk Hueffner -Aurélien Jacobs -Steven Johnson -Zdenek Kabelac -Robin Kay -Todd Kirby -Nick Kurshev -Benjamin Larsson -Loïc Le Loarer -Daniel Maas -Mike Melanson -Loren Merritt -Jeff Muizelaar -Michael Niedermayer -François Revol -Peter Ross -Måns Rullgård -Stefano Sabatini -Roman Shaposhnik -Oded Shimon -Dieter Shirley -Konstantin Shishkov -Juan J. Sierralta -Ewald Snel -Sascha Sommer -Leon van Stuivenberg -Roberto Togni -Lionel Ulmer -Reynaldo Verdejo +To check the log, you can type the command "git log" in the FFmpeg +source directory, or browse the online repository at +http://source.ffmpeg.org. diff --git a/Changelog b/Changelog index c509c4cf68..5ee9200bca 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,9 @@ version : - EVRC decoder - audio fade filter - filtering audio with unknown channel layout +- allpass, bass, bandpass, bandreject, biquad, equalizer, highpass, lowpass + and treble audio filter +- improved showspectrum filter, with multichannel support and sox-like colors version 1.1: diff --git a/configure b/configure index 0f62610a5f..1f652465dd 100755 --- a/configure +++ b/configure @@ -3347,12 +3347,17 @@ esac # determine libc flavour +# uclibc defines __GLIBC__, so it needs to be checked before glibc. if check_cpp_condition features.h "defined __UCLIBC__"; then libc_type=uclibc add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 elif check_cpp_condition features.h "defined __GLIBC__"; then libc_type=glibc add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 +# MinGW headers can be installed on Cygwin, so check for newlib first. +elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then + libc_type=newlib + add_cppflags -U__STRICT_ANSI__ elif check_header _mingw.h; then libc_type=mingw check_cpp_condition _mingw.h \ @@ -3364,9 +3369,6 @@ elif check_header _mingw.h; then add_compat msvcrt/snprintf.o add_cflags "-include $source_path/compat/msvcrt/snprintf.h" fi -elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then - libc_type=newlib - add_cppflags -U__STRICT_ANSI__ elif check_func_headers stdlib.h _get_doserrno; then libc_type=msvcrt add_compat strtod.o strtod=avpriv_strtod @@ -4523,7 +4525,7 @@ pkgconfig_generate(){ requires=$5 enabled ${name#lib} || return 0 mkdir -p $name - cat < $name/$name.pc + cat < $name/$name${build_suffix}.pc prefix=$prefix exec_prefix=\${prefix} libdir=$libdir @@ -4559,27 +4561,27 @@ Cflags: -I\${includedir} EOF } -libavfilter_pc_deps="libavutil = $LIBAVUTIL_VERSION" -enabled libavfilter_deps_avcodec && prepend libavfilter_pc_deps "libavcodec = $LIBAVCODEC_VERSION," -enabled libavfilter_deps_avformat && prepend libavfilter_pc_deps "libavformat = $LIBAVFORMAT_VERSION," -enabled libavfilter_deps_avresample && prepend libavfilter_pc_deps "libavresample = $LIBAVRESAMPLE_VERSION," -enabled libavfilter_deps_swscale && prepend libavfilter_pc_deps "libswscale = $LIBSWSCALE_VERSION," -enabled libavfilter_deps_swresample && prepend libavfilter_pc_deps "libswresample = $LIBSWRESAMPLE_VERSION," -enabled libavfilter_deps_postproc && prepend libavfilter_pc_deps "libpostproc = $LIBPOSTPROC_VERSION," +libavfilter_pc_deps="libavutil${build_suffix} = $LIBAVUTIL_VERSION" +enabled libavfilter_deps_avcodec && prepend libavfilter_pc_deps "libavcodec${build_suffix} = $LIBAVCODEC_VERSION," +enabled libavfilter_deps_avformat && prepend libavfilter_pc_deps "libavformat${build_suffix} = $LIBAVFORMAT_VERSION," +enabled libavfilter_deps_avresample && prepend libavfilter_pc_deps "libavresample${build_suffix} = $LIBAVRESAMPLE_VERSION," +enabled libavfilter_deps_swscale && prepend libavfilter_pc_deps "libswscale${build_suffix} = $LIBSWSCALE_VERSION," +enabled libavfilter_deps_swresample && prepend libavfilter_pc_deps "libswresample${build_suffix} = $LIBSWRESAMPLE_VERSION," +enabled libavfilter_deps_postproc && prepend libavfilter_pc_deps "libpostproc${build_suffix} = $LIBPOSTPROC_VERSION," libavfilter_pc_deps=${libavfilter_pc_deps%, } -libavdevice_pc_deps="libavformat = $LIBAVFORMAT_VERSION" -enabled lavfi_indev && prepend libavdevice_pc_deps "libavfilter = $LIBAVFILTER_VERSION," +libavdevice_pc_deps="libavformat${build_suffix} = $LIBAVFORMAT_VERSION" +enabled lavfi_indev && prepend libavdevice_pc_deps "libavfilter${build_suffix} = $LIBAVFILTER_VERSION," pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM" -pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" +pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec${build_suffix} = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$libavdevice_pc_deps" pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$libavfilter_pc_deps" -pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" +pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" +pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil${build_suffix} = $LIBAVUTIL_VERSION" fix_ffmpeg_remote(){ git_remote_from=$1 diff --git a/doc/developer.texi b/doc/developer.texi index a108da7adc..eaf5980145 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -217,8 +217,13 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}: @enumerate @item - Contributions should be licensed under the LGPL 2.1, including an - "or any later version" clause, or the MIT license. GPL 2 including + Contributions should be licensed under the + @uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1}, + including an "or any later version" clause, or, if you prefer + a gift-style license, the + @uref{http://www.isc.org/software/license/, ISC} or + @uref{http://mit-license.org/, MIT} license. + @uref{http://www.gnu.org/licenses/gpl-2.0.html, GPL 2} including an "or any later version" clause is also acceptable, but LGPL is preferred. @item @@ -341,8 +346,6 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}: We think our rules are not too hard. If you have comments, contact us. -Note, these rules are mostly borrowed from the MPlayer project. - @anchor{Submitting patches} @section Submitting patches diff --git a/doc/eval.texi b/doc/eval.texi index f77b87deac..9b98c18cdf 100644 --- a/doc/eval.texi +++ b/doc/eval.texi @@ -20,122 +20,51 @@ The following unary operators are available: @code{+}, @code{-}. The following functions are available: @table @option -@item sinh(x) -Compute hyperbolic sine of @var{x}. - -@item cosh(x) -Compute hyperbolic cosine of @var{x}. - -@item tanh(x) -Compute hyperbolic tangent of @var{x}. - -@item sin(x) -Compute sine of @var{x}. - -@item cos(x) -Compute cosine of @var{x}. - -@item tan(x) -Compute tangent of @var{x}. - -@item atan(x) -Compute arctangent of @var{x}. - -@item asin(x) -Compute arcsine of @var{x}. +@item abs(x) +Compute absolute value of @var{x}. @item acos(x) Compute arccosine of @var{x}. -@item exp(x) -Compute exponential of @var{x} (with base @code{e}, the Euler's number). +@item asin(x) +Compute arcsine of @var{x}. -@item log(x) -Compute natural logarithm of @var{x}. - -@item abs(x) -Compute absolute value of @var{x}. - -@item squish(x) -Compute expression @code{1/(1 + exp(4*x))}. - -@item gauss(x) -Compute Gauss function of @var{x}, corresponding to -@code{exp(-x*x/2) / sqrt(2*PI)}. - -@item isinf(x) -Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. - -@item isnan(x) -Return 1.0 if @var{x} is NAN, 0.0 otherwise. - -@item mod(x, y) -Compute the remainder of division of @var{x} by @var{y}. - -@item max(x, y) -Return the maximum between @var{x} and @var{y}. - -@item min(x, y) -Return the maximum between @var{x} and @var{y}. - -@item eq(x, y) -Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise. - -@item gte(x, y) -Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise. - -@item gt(x, y) -Return 1 if @var{x} is greater than @var{y}, 0 otherwise. - -@item lte(x, y) -Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise. - -@item lt(x, y) -Return 1 if @var{x} is lesser than @var{y}, 0 otherwise. - -@item st(var, expr) -Allow to store the value of the expression @var{expr} in an internal -variable. @var{var} specifies the number of the variable where to -store the value, and it is a value ranging from 0 to 9. The function -returns the value stored in the internal variable. -Note, Variables are currently not shared between expressions. - -@item ld(var) -Allow to load the value of the internal variable with number -@var{var}, which was previously stored with st(@var{var}, @var{expr}). -The function returns the loaded value. - -@item while(cond, expr) -Evaluate expression @var{expr} while the expression @var{cond} is -non-zero, and returns the value of the last @var{expr} evaluation, or -NAN if @var{cond} was always false. +@item atan(x) +Compute arctangent of @var{x}. @item ceil(expr) Round the value of expression @var{expr} upwards to the nearest integer. For example, "ceil(1.5)" is "2.0". +@item cos(x) +Compute cosine of @var{x}. + +@item cosh(x) +Compute hyperbolic cosine of @var{x}. + +@item eq(x, y) +Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise. + +@item exp(x) +Compute exponential of @var{x} (with base @code{e}, the Euler's number). + @item floor(expr) Round the value of expression @var{expr} downwards to the nearest integer. For example, "floor(-1.5)" is "-2.0". -@item trunc(expr) -Round the value of expression @var{expr} towards zero to the nearest -integer. For example, "trunc(-1.5)" is "-1.0". +@item gauss(x) +Compute Gauss function of @var{x}, corresponding to +@code{exp(-x*x/2) / sqrt(2*PI)}. -@item sqrt(expr) -Compute the square root of @var{expr}. This is equivalent to -"(@var{expr})^.5". +@item gcd(x, y) +Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and +@var{y} are 0 or either or both are less than zero then behavior is undefined. -@item not(expr) -Return 1.0 if @var{expr} is zero, 0.0 otherwise. +@item gt(x, y) +Return 1 if @var{x} is greater than @var{y}, 0 otherwise. -@item pow(x, y) -Compute the power of @var{x} elevated @var{y}, it is equivalent to -"(@var{x})^(@var{y})". - -@item random(x) -Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the -internal variable which will be used to save the seed/state. +@item gte(x, y) +Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise. @item hypot(x, y) This function is similar to the C function with the same name; it returns @@ -143,10 +72,6 @@ This function is similar to the C function with the same name; it returns right triangle with sides of length @var{x} and @var{y}, or the distance of the point (@var{x}, @var{y}) from the origin. -@item gcd(x, y) -Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and -@var{y} are 0 or either or both are less than zero then behavior is undefined. - @item if(x, y) Evaluate @var{x}, and if the result is non-zero return the result of the evaluation of @var{y}, return 0 otherwise. @@ -163,20 +88,111 @@ evaluation of @var{y}, return 0 otherwise. Evaluate @var{x}, and if the result is zero return the evaluation result of @var{y}, otherwise the evaluation result of @var{z}. -@item taylor(expr, x) taylor(expr, x, id) -Evaluate a taylor series at x. -expr represents the LD(id)-th derivates of f(x) at 0. If id is not specified -then 0 is assumed. -note, when you have the derivatives at y instead of 0 -taylor(expr, x-y) can be used -When the series does not converge the results are undefined. +@item isinf(x) +Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. + +@item isnan(x) +Return 1.0 if @var{x} is NAN, 0.0 otherwise. + +@item ld(var) +Allow to load the value of the internal variable with number +@var{var}, which was previously stored with st(@var{var}, @var{expr}). +The function returns the loaded value. + +@item log(x) +Compute natural logarithm of @var{x}. + +@item lt(x, y) +Return 1 if @var{x} is lesser than @var{y}, 0 otherwise. + +@item lte(x, y) +Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise. + +@item max(x, y) +Return the maximum between @var{x} and @var{y}. + +@item min(x, y) +Return the maximum between @var{x} and @var{y}. + +@item mod(x, y) +Compute the remainder of division of @var{x} by @var{y}. + +@item not(expr) +Return 1.0 if @var{expr} is zero, 0.0 otherwise. + +@item pow(x, y) +Compute the power of @var{x} elevated @var{y}, it is equivalent to +"(@var{x})^(@var{y})". + +@item random(x) +Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the +internal variable which will be used to save the seed/state. + +@item root(expr, max) +Find an input value for which the function represented by @var{expr} +with argument @var{ld(0)} is 0 in the interval 0..@var{max}. + +The expression in @var{expr} must denote a continuous function or the +result is undefined. + +@var{ld(0)} is used to represent the function input value, which means +that the given expression will be evaluated multiple times with +various input values that the expression can access through +@code{ld(0)}. When the expression evaluates to 0 then the +corresponding input value will be returned. + +@item sin(x) +Compute sine of @var{x}. + +@item sinh(x) +Compute hyperbolic sine of @var{x}. + +@item sqrt(expr) +Compute the square root of @var{expr}. This is equivalent to +"(@var{expr})^.5". + +@item squish(x) +Compute expression @code{1/(1 + exp(4*x))}. + +@item st(var, expr) +Allow to store the value of the expression @var{expr} in an internal +variable. @var{var} specifies the number of the variable where to +store the value, and it is a value ranging from 0 to 9. The function +returns the value stored in the internal variable. +Note, Variables are currently not shared between expressions. + +@item tan(x) +Compute tangent of @var{x}. + +@item tanh(x) +Compute hyperbolic tangent of @var{x}. + +@item taylor(expr, x) +@item taylor(expr, x, id) +Evaluate a Taylor series at @var{x}, given an expression representing +the @code{ld(id)}-th derivative of a function at 0. + +When the series does not converge the result is undefined. + +@var{ld(id)} is used to represent the derivative order in @var{expr}, +which means that the given expression will be evaluated multiple times +with various input values that the expression can access through +@code{ld(id)}. If @var{id} is not specified then 0 is assumed. + +Note, when you have the derivatives at y instead of 0, +@code{taylor(expr, x-y)} can be used. @item time(0) Return the current (wallclock) time in seconds. -@item root(expr, max) -Finds x where f(x)=0 in the interval 0..max. -f() must be continuous or the result is undefined. +@item trunc(expr) +Round the value of expression @var{expr} towards zero to the nearest +integer. For example, "trunc(-1.5)" is "-1.0". + +@item while(cond, expr) +Evaluate expression @var{expr} while the expression @var{cond} is +non-zero, and returns the value of the last @var{expr} evaluation, or +NAN if @var{cond} was always false. @end table The following constants are available: diff --git a/doc/filter_design.txt b/doc/filter_design.txt index 362fce4146..772ca9dfb0 100644 --- a/doc/filter_design.txt +++ b/doc/filter_design.txt @@ -15,13 +15,13 @@ Format negotiation the list of supported formats. For video links, that means pixel format. For audio links, that means - channel layout, and sample format (the sample packing is implied by the - sample format). + channel layout, sample format (the sample packing is implied by the sample + format) and sample rate. The lists are not just lists, they are references to shared objects. When the negotiation mechanism computes the intersection of the formats - supported at each ends of a link, all references to both lists are - replaced with a reference to the intersection. And when a single format is + supported at each end of a link, all references to both lists are replaced + with a reference to the intersection. And when a single format is eventually chosen for a link amongst the remaining list, again, all references to the list are updated. @@ -68,15 +68,15 @@ Buffer references ownership and permissions Here are the (fairly obvious) rules for reference ownership: - * A reference received by the start_frame or filter_frame method - belong to the corresponding filter. + * A reference received by the filter_frame method (or its start_frame + deprecated version) belongs to the corresponding filter. Special exception: for video references: the reference may be used internally for automatic copying and must not be destroyed before end_frame; it can be given away to ff_start_frame. - * A reference passed to ff_start_frame or ff_filter_frame is given - away and must no longer be used. + * A reference passed to ff_filter_frame (or the deprecated + ff_start_frame) is given away and must no longer be used. * A reference created with avfilter_ref_buffer belongs to the code that created it. @@ -90,27 +90,11 @@ Buffer references ownership and permissions Link reference fields --------------------- - The AVFilterLink structure has a few AVFilterBufferRef fields. Here are - the rules to handle them: - - * cur_buf is set before the start_frame and filter_frame methods to - the same reference given as argument to the methods and belongs to the - destination filter of the link. If it has not been cleared after - end_frame or filter_frame, libavfilter will automatically destroy - the reference; therefore, any filter that needs to keep the reference - for longer must set cur_buf to NULL. - - * out_buf belongs to the source filter of the link and can be used to - store a reference to the buffer that has been sent to the destination. - If it is not NULL after end_frame or filter_frame, libavfilter will - automatically destroy the reference. - - If a video input pad does not have a start_frame method, the default - method will request a buffer on the first output of the filter, store - the reference in out_buf and push a second reference to the output. - - * src_buf, cur_buf_copy and partial_buf are used by libavfilter - internally and must not be accessed by filters. + The AVFilterLink structure has a few AVFilterBufferRef fields. The + cur_buf and out_buf were used with the deprecated + start_frame/draw_slice/end_frame API and should no longer be used. + src_buf, cur_buf_copy and partial_buf are used by libavfilter internally + and must not be accessed by filters. Reference permissions --------------------- @@ -119,8 +103,10 @@ Buffer references ownership and permissions the code that owns the reference is allowed to do to the buffer data. Different references for the same buffer can have different permissions. - For video filters, the permissions only apply to the parts of the buffer - that have already been covered by the draw_slice method. + For video filters that implement the deprecated + start_frame/draw_slice/end_frame API, the permissions only apply to the + parts of the buffer that have already been covered by the draw_slice + method. The value is a binary OR of the following constants: @@ -179,9 +165,9 @@ Buffer references ownership and permissions with the WRITE permission. * Filters that intend to keep a reference after the filtering process - is finished (after end_frame or filter_frame returns) must have the - PRESERVE permission on it and remove the WRITE permission if they - create a new reference to give it away. + is finished (after filter_frame returns) must have the PRESERVE + permission on it and remove the WRITE permission if they create a new + reference to give it away. * Filters that intend to modify a reference they have kept after the end of the filtering process need the REUSE2 permission and must remove @@ -198,11 +184,11 @@ Frame scheduling Simple filters that output one frame for each input frame should not have to worry about it. - start_frame / filter_frame - ---------------------------- + filter_frame + ------------ - These methods are called when a frame is pushed to the filter's input. - They can be called at any time except in a reentrant way. + This method is called when a frame is pushed to the filter's input. It + can be called at any time except in a reentrant way. If the input frame is enough to produce output, then the filter should push the output frames on the output link immediately. @@ -213,7 +199,7 @@ Frame scheduling filter; these buffered frames must be flushed immediately if a new input produces new output. - (Example: framerate-doubling filter: start_frame must (1) flush the + (Example: framerate-doubling filter: filter_frame must (1) flush the second copy of the previous frame, if it is still there, (2) push the first copy of the incoming frame, (3) keep the second copy for later.) @@ -233,8 +219,8 @@ Frame scheduling This method is called when a frame is wanted on an output. - For an input, it should directly call start_frame or filter_frame on - the corresponding output. + For an input, it should directly call filter_frame on the corresponding + output. For a filter, if there are queued frames already ready, one of these frames should be pushed. If not, the filter should request a frame on @@ -255,7 +241,7 @@ Frame scheduling } while (!frame_pushed) { input = input_where_a_frame_is_most_needed(); - ret = avfilter_request_frame(input); + ret = ff_request_frame(input); if (ret == AVERROR_EOF) { process_eof_on_input(); } else if (ret < 0) { @@ -266,4 +252,14 @@ Frame scheduling Note that, except for filters that can have queued frames, request_frame does not push frames: it requests them to its input, and as a reaction, - the start_frame / filter_frame method will be called and do the work. + the filter_frame method will be called and do the work. + +Legacy API +========== + + Until libavfilter 3.23, the filter_frame method was split: + + - for video filters, it was made of start_frame, draw_slice (that could be + called several times on distinct parts of the frame) and end_frame; + + - for audio filters, it was called filter_samples. diff --git a/doc/filters.texi b/doc/filters.texi index 21e2cff680..76a73e6dad 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -282,6 +282,306 @@ aconvert=u8:auto @end example @end itemize +@section allpass + +Apply a two-pole all-pass filter with central frequency (in Hz) +@var{frequency}, and filter-width @var{width}. +An all-pass filter changes the audio's frequency to phase relationship +without changing its frequency to amplitude relationship. + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set frequency in Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +@end table + +@section highpass + +Apply a high-pass filter with 3dB point frequency. +The filter can be either single-pole, or double-pole (the default). +The filter roll off at 6dB per pole per octave (20dB per pole per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set frequency in Hz. Default is 3000. + +@item poles, p +Set number of poles. Default is 2. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +Applies only to double-pole filter. +The default is 0.707q and gives a Butterworth response. +@end table + +@section lowpass + +Apply a low-pass filter with 3dB point frequency. +The filter can be either single-pole or double-pole (the default). +The filter roll off at 6dB per pole per octave (20dB per pole per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set frequency in Hz. Default is 500. + +@item poles, p +Set number of poles. Default is 2. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +Applies only to double-pole filter. +The default is 0.707q and gives a Butterworth response. +@end table + +@section bass + +Boost or cut the bass (lower) frequencies of the audio using a two-pole +shelving filter with a response similar to that of a standard +hi-fi's tone-controls. This is also known as shelving equalisation (EQ). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item gain, g +Give the gain at 0 Hz. Its useful range is about -20 +(for a large cut) to +20 (for a large boost). +Beware of clipping when using a positive gain. + +@item frequency, f +Set the filter's central frequency and so can be used +to extend or reduce the frequency range to be boosted or cut. +The default value is @code{100} Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Determine how steep is the filter's shelf transition. +@end table + +@section treble + +Boost or cut treble (upper) frequencies of the audio using a two-pole +shelving filter with a response similar to that of a standard +hi-fi's tone-controls. This is also known as shelving equalisation (EQ). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item gain, g +Give the gain at whichever is the lower of ~22 kHz and the +Nyquist frequency. Its useful range is about -20 (for a large cut) +to +20 (for a large boost). Beware of clipping when using a positive gain. + +@item frequency, f +Set the filter's central frequency and so can be used +to extend or reduce the frequency range to be boosted or cut. +The default value is @code{3000} Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Determine how steep is the filter's shelf transition. +@end table + +@section bandpass + +Apply a two-pole Butterworth band-pass filter with central +frequency @var{frequency}, and (3dB-point) band-width width. +The @var{csg} option selects a constant skirt gain (peak gain = Q) +instead of the default: constant 0dB peak gain. +The filter roll off at 6dB per octave (20dB per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set the filter's central frequency. Default is @code{3000}. + +@item csg +Constant skirt gain if set to 1. Defaults to 0. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +@end table + +@section bandreject + +Apply a two-pole Butterworth band-reject filter with central +frequency @var{frequency}, and (3dB-point) band-width @var{width}. +The filter roll off at 6dB per octave (20dB per decade). + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set the filter's central frequency. Default is @code{3000}. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Specify the band-width of a filter in width_type units. +@end table + +@section biquad + +Apply a biquad IIR filter with the given coefficients. +Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2} +are the numerator and denominator coefficients respectively. + +@section equalizer + +Apply a two-pole peaking equalisation (EQ) filter. With this +filter, the signal-level at and around a selected frequency can +be increased or decreased, whilst (unlike bandpass and bandreject +filters) that at all other frequencies is unchanged. + +In order to produce complex equalisation curves, this filter can +be given several times, each with a different central frequency. + +The filter accepts parameters as a list of @var{key}=@var{value} +pairs, separated by ":". + +A description of the accepted parameters follows. + +@table @option +@item frequency, f +Set the filter's central frequency in Hz. + +@item width_type +Set method to specify band-width of filter. +@table @option +@item h +Hz +@item q +Q-Factor +@item o +octave +@item s +slope +@end table + +@item width, w +Specify the band-width of a filter in width_type units. + +@item gain, g +Set the required gain or attenuation in dB. +Beware of clipping when using a positive gain. +@end table + @section afade Apply fade-in/out effect to input audio. @@ -319,28 +619,30 @@ the output audio will be silence. Default is 0. If set this option is used instead of @var{nb_samples} one. @item curve -Set cuve for fade transition. +Set curve for fade transition. + +It accepts the following values: @table @option -@item @var{triangular, linear slope (default)} -@code{tri} -@item @var{quarter of sine wave} -@code{qsin} -@item @var{half of sine wave} -@code{esin} -@item @var{exponential sine wave} -@code{hsin} -@item @var{logarithmic} -@code{log} -@item @var{inverted parabola} -@code{par} -@item @var{quadratic} -@code{qua} -@item @var{cubic} -@code{cub} -@item @var{square root} -@code{squ} -@item @var{cubic root} -@code{cbr} +@item tri +select triangular, linear slope (default) +@item qsin +select quarter of sine wave +@item hsin +select half of sine wave +@item esin +select exponential sine wave +@item log +select logarithmic +@item par +select inverted parabola +@item qua +select quadratic +@item cub +select cubic +@item squ +select square root +@item cbr +select cubic root @end table @end table @@ -3014,10 +3316,14 @@ corresponding pixel component values. The @var{lut} filter requires either YUV or RGB pixel formats in input, and accepts the options: @table @option -@item @var{c0} (first pixel component) -@item @var{c1} (second pixel component) -@item @var{c2} (third pixel component) -@item @var{c3} (fourth pixel component, corresponds to the alpha component) +@item c0 +set first pixel component expression +@item c1 +set second pixel component expression +@item c2 +set third pixel component expression +@item c3 +set fourth pixel component expression, corresponds to the alpha component @end table The exact component associated to each option depends on the format in @@ -3026,19 +3332,27 @@ input. The @var{lutrgb} filter requires RGB pixel formats in input, and accepts the options: @table @option -@item @var{r} (red component) -@item @var{g} (green component) -@item @var{b} (blue component) -@item @var{a} (alpha component) +@item r +set red component expression +@item g +set green component expression +@item b +set blue component expression +@item a +alpha component expression @end table The @var{lutyuv} filter requires YUV pixel formats in input, and accepts the options: @table @option -@item @var{y} (Y/luminance component) -@item @var{u} (U/Cb component) -@item @var{v} (V/Cr component) -@item @var{a} (alpha component) +@item y +set Y/luminance component expression +@item u +set U/Cb component expression +@item v +set V/Cr component expression +@item a +set alpha component expression @end table The expressions can contain the following constants and functions: @@ -3078,34 +3392,58 @@ expression All expressions default to "val". -Some examples follow: +@subsection Examples + +@itemize +@item +Negate input video: @example -# negate input video lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val" lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val" +@end example -# the above is the same as +The above is the same as: +@example lutrgb="r=negval:g=negval:b=negval" lutyuv="y=negval:u=negval:v=negval" +@end example -# negate luminance +@item +Negate luminance: +@example lutyuv=y=negval +@end example -# remove chroma components, turns the video into a graytone image +@item +Remove chroma components, turns the video into a graytone image: +@example lutyuv="u=128:v=128" +@end example -# apply a luma burning effect +@item +Apply a luma burning effect: +@example lutyuv="y=2*val" +@end example -# remove green and blue components +@item +Remove green and blue components: +@example lutrgb="g=0:b=0" +@end example -# set a constant alpha channel value on input +@item +Set a constant alpha channel value on input: +@example format=rgba,lutrgb=a="maxval-minval/2" +@end example -# correct luminance gamma by a 0.5 factor +@item +Correct luminance gamma by a 0.5 factor: +@example lutyuv=y=gammaval(0.5) @end example +@end itemize @section mp @@ -3419,14 +3757,50 @@ testsrc=s=100x100, split=4 [in0][in1][in2][in3]; @section pad -Add paddings to the input image, and places the original input at the +Add paddings to the input image, and place the original input at the given coordinates @var{x}, @var{y}. -It accepts the following parameters: +The filter accepts parameters as a list of @var{key}=@var{value} pairs, +separated by ":". + +If the key of the first options is omitted, the arguments are +interpreted according to the syntax @var{width}:@var{height}:@var{x}:@var{y}:@var{color}. -The parameters @var{width}, @var{height}, @var{x}, and @var{y} are -expressions containing the following constants: +A description of the accepted options follows. + +@table @option +@item width, w +@item height, h +Specify an expression for the size of the output image with the +paddings added. If the value for @var{width} or @var{height} is 0, the +corresponding input size is used for the output. + +The @var{width} expression can reference the value set by the +@var{height} expression, and vice versa. + +The default value of @var{width} and @var{height} is 0. + +@item x +@item y +Specify an expression for the offsets where to place the input image +in the padded area with respect to the top/left border of the output +image. + +The @var{x} expression can reference the value set by the @var{y} +expression, and vice versa. + +The default value of @var{x} and @var{y} is 0. + +@item color +Specify the color of the padded area, it can be the name of a color +(case insensitive match) or a 0xRRGGBB[AA] sequence. + +The default value of @var{color} is "black". +@end table + +The value for the @var{width}, @var{height}, @var{x}, and @var{y} +options are expressions containing the following constants: @table @option @item in_w, in_h @@ -3460,39 +3834,6 @@ horizontal and vertical chroma subsample values. For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. @end table -Follows the description of the accepted parameters. - -@table @option -@item width, height - -Specify the size of the output image with the paddings added. If the -value for @var{width} or @var{height} is 0, the corresponding input size -is used for the output. - -The @var{width} expression can reference the value set by the -@var{height} expression, and vice versa. - -The default value of @var{width} and @var{height} is 0. - -@item x, y - -Specify the offsets where to place the input image in the padded area -with respect to the top/left border of the output image. - -The @var{x} expression can reference the value set by the @var{y} -expression, and vice versa. - -The default value of @var{x} and @var{y} is 0. - -@item color - -Specify the color of the padded area, it can be the name of a color -(case insensitive match) or a 0xRRGGBB[AA] sequence. - -The default value of @var{color} is "black". - -@end table - @subsection Examples @itemize @@ -3504,6 +3845,11 @@ column 0, row 40: pad=640:480:0:40:violet @end example +The example above is equivalent to the following command: +@example +pad=width=640:height=480:x=0:y=40:color=violet +@end example + @item Pad the input to get an output with dimensions increased by 3/2, and put the input video at the center of the padded area: @@ -5705,10 +6051,60 @@ spectrum. The filter accepts the following named parameters: @table @option @item size, s -Specify the video size for the output. Default value is @code{640x480}. +Specify the video size for the output. Default value is @code{640x512}. + @item slide Specify if the spectrum should slide along the window. Default value is @code{0}. + +@item mode +Specify display mode. + +It accepts the following values: +@table @samp +@item combined +all channels are displayed in the same row +@item separate +all channels are displayed in separate rows +@end table + +Default value is @samp{combined}. + +@item color +Specify display color mode. + +It accepts the following values: +@table @samp +@item channel +each channel is displayed in a separate color +@item intensity +each channel is is displayed using the same color scheme +@end table + +Default value is @samp{channel}. + +@item scale +Specify scale used for calculating intensity color values. + +It accepts the following values: +@table @samp +@item lin +linear +@item sqrt +square root, default +@item cbrt +cubic root +@item log +logarithmic +@end table + +Default value is @samp{sqrt}. + +@item saturation +Set saturation modifier for displayed colors. Negative values provide +alternative color scheme. @code{0} is no saturation at all. +Saturation must be in [-10.0, 10.0] range. +Default value is @code{1}. @end table The usage is very similar to the showwaves filter; see the examples in that diff --git a/doc/indevs.texi b/doc/indevs.texi index 621e1de978..cc5d66622c 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -583,10 +583,16 @@ command: ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav @end example -@section video4linux2 +@section video4linux2, v4l2 Video4Linux2 input video device. +"v4l2" can be used as alias for "video4linux2". + +If FFmpeg is built with v4l-utils support (by using the +@code{--enable-libv4l2} configure option), the device will always rely +on libv4l2. + The name of the device to grab is a file device node, usually Linux systems tend to automatically create such nodes when the device (e.g. an USB webcam) is plugged into the system, and has a name of the @@ -596,8 +602,8 @@ the device. Video4Linux2 devices usually support a limited set of @var{width}x@var{height} sizes and framerates. You can check which are supported using @command{-list_formats all} for Video4Linux2 devices. - -Some usage examples of the video4linux2 devices with ffmpeg and ffplay: +Some devices, like TV cards, support one or more standards. It is possible +to list all the supported standards using @command{-list_standards all}. The time base for the timestamps is 1 microsecond. Depending on the kernel version and configuration, the timestamps may be derived from the real time @@ -606,19 +612,93 @@ boot time, unaffected by NTP or manual changes to the clock). The @option{-timestamps abs} or @option{-ts abs} option can be used to force conversion into the real time clock. -Note that if FFmpeg is build with v4l-utils support ("--enable-libv4l2" -option), it will always be used. +Some usage examples of the video4linux2 device with @command{ffmpeg} +and @command{ffplay}: +@itemize +@item +Grab and show the input of a video4linux2 device: @example -# Grab and show the input of a video4linux2 device. ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0 - -# Grab and record the input of a video4linux2 device, leave the -framerate and size as previously set. -ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg @end example -"v4l" and "v4l2" can be used as aliases for the respective "video4linux" and -"video4linux2". +@item +Grab and record the input of a video4linux2 device, leave the +framerate and size as previously set: +@example +ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg +@end example +@end itemize + +For more information about Video4Linux, check @url{http://linuxtv.org/}. + +@subsection Options + +@table @option +@item standard +Set the standard. Must be the name of a supported standard. To get a +list of the supported standards, use the @option{list_standards} +option. + +@item channel +Set the input channel number. Default to 0. + +@item video_size +Set the video frame size. The argument must be a string in the form +@var{WIDTH}x@var{HEIGHT} or a valid size abbreviation. + +@item pixel_format +Select the pixel format (only valid for raw video input). + +@item input_format +Set the preferred pixel format (for raw video) or a codec name. +This option allows to select the input format, when several are +available. + +@item framerate +Set the preferred video framerate. + +@item list_formats +List available formats (supported pixel formats, codecs, and frame +sizes) and exit. + +Available values are: +@table @samp +@item all +Show all available (compressed and non-compressed) formats. + +@item raw +Show only raw video (non-compressed) formats. + +@item compressed +Show only compressed formats. +@end table + +@item list_standards +List supported standards and exit. + +Available values are: +@table @samp +@item all +Show all supported standards. +@end table + +@item timestamps, ts +Set type of timestamps for grabbed frames. + +Available values are: +@table @samp +@item default +Use timestamps from the kernel. + +@item abs +Use absolute timestamps (wall clock). + +@item mono2abs +Force conversion from monotonic to absolute timestamps. +@end table + +Default value is @code{default}. +@end table @section vfwcap diff --git a/doc/muxers.texi b/doc/muxers.texi index 965a4bb124..0aea87b4e7 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -645,7 +645,7 @@ of the generated segments. May not work with some combinations of muxers/codecs. It is set to @code{0} by default. @end table -@section Examples +@subsection Examples @itemize @item @@ -727,10 +727,11 @@ Write an mp3 with an ID3v2.3 header and an ID3v1 footer: ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3 @end example -Attach a picture to an mp3: +To attach a picture to an mp3 file select both the audio and the picture stream +with @code{map}: @example -ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover" --metadata:s:v comment="Cover (Front)" out.mp3 +ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1 +-metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3 @end example @section ogg diff --git a/doc/syntax.texi b/doc/syntax.texi index a3aabce1e9..4dddc3cbc2 100644 --- a/doc/syntax.texi +++ b/doc/syntax.texi @@ -112,6 +112,22 @@ Specify the size of the sourced video, it may be a string of the form The following abbreviations are recognized: @table @samp +@item ntsc +720x480 +@item pal +720x576 +@item qntsc +352x240 +@item qpal +352x288 +@item sntsc +640x480 +@item spal +768x576 +@item film +352x240 +@item ntsc-film +352x240 @item sqcif 128x96 @item qcif @@ -170,6 +186,18 @@ The following abbreviations are recognized: 1280x720 @item hd1080 1920x1080 +@item 2k +2048x1080 +@item 2kflat +1998x1080 +@item 2kscope +2048x858 +@item 4k +4096x2160 +@item 4kflat +3996x2160 +@item 4kscope +4096x1716 @end table @anchor{video rate syntax} @@ -187,17 +215,17 @@ The following abbreviations are recognized: @item pal 25/1 @item qntsc -30000/1 +30000/1001 @item qpal 25/1 @item sntsc -30000/1 +30000/1001 @item spal 25/1 @item film 24/1 @item ntsc-film -24000/1 +24000/1001 @end table @anchor{ratio syntax} diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index b285f4ce88..4f320b9b29 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -126,6 +126,7 @@ static void uninit_options(OptionsContext *o, int is_input) av_freep(&o->stream_maps); av_freep(&o->audio_channel_maps); av_freep(&o->streamid_map); + av_freep(&o->attachments); if (is_input) recording_time = o->recording_time; @@ -2140,7 +2141,7 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) return AVERROR(EINVAL); } snprintf(layout_str, sizeof(layout_str), "%"PRIu64, layout); - ret = opt_default(NULL, opt, layout_str); + ret = opt_default_new(o, opt, layout_str); if (ret < 0) return ret; diff --git a/ffplay.c b/ffplay.c index 93090ad60b..2dbe8b965c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -181,11 +181,11 @@ typedef struct VideoState { AVStream *audio_st; PacketQueue audioq; int audio_hw_buf_size; - DECLARE_ALIGNED(16,uint8_t,audio_buf2)[AVCODEC_MAX_AUDIO_FRAME_SIZE * 4]; uint8_t silence_buf[SDL_AUDIO_BUFFER_SIZE]; uint8_t *audio_buf; uint8_t *audio_buf1; unsigned int audio_buf_size; /* in bytes */ + unsigned int audio_buf1_size; int audio_buf_index; /* in bytes */ int audio_write_buf_size; AVPacket audio_pkt_temp; @@ -268,6 +268,8 @@ static const char *input_filename; static const char *window_title; static int fs_screen_width; static int fs_screen_height; +static int default_width = 640; +static int default_height = 480; static int screen_width = 0; static int screen_height = 0; static int audio_disable; @@ -992,8 +994,7 @@ static void stream_close(VideoState *is) SDL_DestroyCond(is->subpq_cond); SDL_DestroyCond(is->continue_read_thread); #if !CONFIG_AVFILTER - if (is->img_convert_ctx) - sws_freeContext(is->img_convert_ctx); + sws_freeContext(is->img_convert_ctx); #endif av_free(is); } @@ -1022,29 +1023,30 @@ static void sigterm_handler(int sig) exit(123); } -static int video_open(VideoState *is, int force_set_video_mode) +static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp) { int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; int w,h; - VideoPicture *vp = &is->pictq[is->pictq_rindex]; SDL_Rect rect; if (is_full_screen) flags |= SDL_FULLSCREEN; else flags |= SDL_RESIZABLE; + if (vp && vp->width) { + calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); + default_width = rect.w; + default_height = rect.h; + } + if (is_full_screen && fs_screen_width) { w = fs_screen_width; h = fs_screen_height; } else if (!is_full_screen && screen_width) { w = screen_width; h = screen_height; - } else if (vp->width) { - calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); - w = rect.w; - h = rect.h; } else { - w = 640; - h = 480; + w = default_width; + h = default_height; } if (screen && is->width == screen->w && screen->w == w && is->height== screen->h && screen->h == h && !force_set_video_mode) @@ -1068,7 +1070,7 @@ static int video_open(VideoState *is, int force_set_video_mode) static void video_display(VideoState *is) { if (!screen) - video_open(is, 0); + video_open(is, 0, NULL); if (is->audio_st && is->show_mode != SHOW_MODE_VIDEO) video_audio_display(is); else if (is->video_st) @@ -1217,6 +1219,20 @@ static void stream_toggle_pause(VideoState *is) is->paused = !is->paused; } +static void toggle_pause(VideoState *is) +{ + stream_toggle_pause(is); + is->step = 0; +} + +static void step_to_next_frame(VideoState *is) +{ + /* if the stream is paused unpause it, then step */ + if (is->paused) + stream_toggle_pause(is); + is->step = 1; +} + static double compute_target_delay(double delay, VideoState *is) { double sync_threshold, diff; @@ -1458,7 +1474,7 @@ static void alloc_picture(VideoState *is) avfilter_unref_bufferp(&vp->picref); #endif - video_open(is, 0); + video_open(is, 0, vp); vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, SDL_YV12_OVERLAY, @@ -2066,8 +2082,14 @@ static int synchronize_audio(VideoState *is, int nb_samples) return wanted_nb_samples; } -/* decode one audio frame and returns its uncompressed size */ -static int audio_decode_frame(VideoState *is, double *pts_ptr) +/** + * Decode one audio frame and return its uncompressed size. + * + * The processed audio frame is decoded, converted if required, and + * stored in is->audio_buf, with size in bytes given by the return + * value. + */ +static int audio_decode_frame(VideoState *is) { AVPacket *pkt_temp = &is->audio_pkt_temp; AVPacket *pkt = &is->audio_pkt; @@ -2075,7 +2097,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) int len1, len2, data_size, resampled_data_size; int64_t dec_channel_layout; int got_frame; - double pts; + av_unused double audio_clock0; int new_packet = 0; int flush_complete = 0; int wanted_nb_samples; @@ -2143,8 +2165,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) if (is->swr_ctx) { const uint8_t **in = (const uint8_t **)is->frame->extended_data; - uint8_t *out[] = {is->audio_buf2}; - int out_count = sizeof(is->audio_buf2) / is->audio_tgt.channels / av_get_bytes_per_sample(is->audio_tgt.fmt); + uint8_t **out = &is->audio_buf1; + int out_count = (int64_t)wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate + 256; + int out_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, out_count, is->audio_tgt.fmt, 0); if (wanted_nb_samples != is->frame->nb_samples) { if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / is->frame->sample_rate, wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate) < 0) { @@ -2152,6 +2175,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) break; } } + av_fast_malloc(&is->audio_buf1, &is->audio_buf1_size, out_size); + if (!is->audio_buf1) + return AVERROR(ENOMEM); len2 = swr_convert(is->swr_ctx, out, out_count, in, is->frame->nb_samples); if (len2 < 0) { fprintf(stderr, "swr_convert() failed\n"); @@ -2161,24 +2187,22 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) fprintf(stderr, "warning: audio buffer is probably too small\n"); swr_init(is->swr_ctx); } - is->audio_buf = is->audio_buf2; + is->audio_buf = is->audio_buf1; resampled_data_size = len2 * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt); } else { is->audio_buf = is->frame->data[0]; resampled_data_size = data_size; } - /* if no pts, then compute it */ - pts = is->audio_clock; - *pts_ptr = pts; + audio_clock0 = is->audio_clock; is->audio_clock += (double)data_size / (is->frame->channels * is->frame->sample_rate * av_get_bytes_per_sample(is->frame->format)); #ifdef DEBUG { static double last_clock; - printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", + printf("audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n", is->audio_clock - last_clock, - is->audio_clock, pts); + is->audio_clock, audio_clock0); last_clock = is->audio_clock; } #endif @@ -2222,13 +2246,12 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) int audio_size, len1; int bytes_per_sec; int frame_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1); - double pts; audio_callback_time = av_gettime(); while (len > 0) { if (is->audio_buf_index >= is->audio_buf_size) { - audio_size = audio_decode_frame(is, &pts); + audio_size = audio_decode_frame(is); if (audio_size < 0) { /* if error, just output silence */ is->audio_buf = is->silence_buf; @@ -2437,6 +2460,7 @@ static void stream_component_close(VideoState *is, int stream_index) av_free_packet(&is->audio_pkt); swr_free(&is->swr_ctx); av_freep(&is->audio_buf1); + is->audio_buf1_size = 0; is->audio_buf = NULL; avcodec_free_frame(&is->frame); @@ -2636,10 +2660,11 @@ static int read_thread(void *arg) if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) { ret = stream_component_open(is, st_index[AVMEDIA_TYPE_VIDEO]); } - is->refresh_tid = SDL_CreateThread(refresh_thread, is); if (is->show_mode == SHOW_MODE_NONE) is->show_mode = ret >= 0 ? SHOW_MODE_VIDEO : SHOW_MODE_RDFT; + is->refresh_tid = SDL_CreateThread(refresh_thread, is); + if (st_index[AVMEDIA_TYPE_SUBTITLE] >= 0) { stream_component_open(is, st_index[AVMEDIA_TYPE_SUBTITLE]); } @@ -2705,6 +2730,8 @@ static int read_thread(void *arg) } is->seek_req = 0; eof = 0; + if (is->paused) + step_to_next_frame(is); } if (is->queue_attachments_req) { avformat_queue_attached_pictures(ic); @@ -2913,21 +2940,7 @@ static void toggle_full_screen(VideoState *is) is->pictq[i].reallocate = 1; #endif is_full_screen = !is_full_screen; - video_open(is, 1); -} - -static void toggle_pause(VideoState *is) -{ - stream_toggle_pause(is); - is->step = 0; -} - -static void step_to_next_frame(VideoState *is) -{ - /* if the stream is paused unpause it, then step */ - if (is->paused) - stream_toggle_pause(is); - is->step = 1; + video_open(is, 1, NULL); } static void toggle_audio_display(VideoState *is) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 5b98856e67..d17366c8ee 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -257,10 +257,12 @@ typedef struct ChannelElement { SpectralBandReplication sbr; } ChannelElement; +typedef struct AACContext AACContext; + /** * main AAC context */ -typedef struct AACContext { +struct AACContext { AVClass *class; AVCodecContext *avctx; AVFrame frame; @@ -317,6 +319,18 @@ typedef struct AACContext { OutputConfiguration oc[2]; int warned_num_aac_frames; -} AACContext; + + /* aacdec functions pointers */ + void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); + void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce); + void (*apply_tns)(float coef[1024], TemporalNoiseShaping *tns, + IndividualChannelStream *ics, int decode); + void (*windowing_and_mdct_ltp)(AACContext *ac, float *out, + float *in, IndividualChannelStream *ics); + void (*update_ltp)(AACContext *ac, SingleChannelElement *sce); + +}; + +void ff_aacdec_init_mips(AACContext *c); #endif /* AVCODEC_AAC_H */ diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 2538948edd..d4ea115cd5 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -108,6 +108,8 @@ #if ARCH_ARM # include "arm/aac.h" +#elif ARCH_MIPS +# include "mips/aacdec_mips.h" #endif static VLC vlc_scalefactors; @@ -872,6 +874,8 @@ static void reset_predictor_group(PredictorState *ps, int group_num) ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \ size); +static void aacdec_init(AACContext *ac); + static av_cold int aac_decode_init(AVCodecContext *avctx) { AACContext *ac = avctx->priv_data; @@ -879,6 +883,8 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->avctx = avctx; ac->oc[1].m4ac.sample_rate = avctx->sample_rate; + aacdec_init(ac); + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (avctx->extradata_size > 0) { @@ -2165,10 +2171,10 @@ static void apply_ltp(AACContext *ac, SingleChannelElement *sce) predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; memset(&predTime[i], 0, (2048 - i) * sizeof(float)); - windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); + ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); if (sce->tns.present) - apply_tns(predFreq, &sce->tns, &sce->ics, 0); + ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) if (ltp->used[sfb]) @@ -2380,25 +2386,25 @@ static void spectral_to_sample(AACContext *ac) if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) { if (che->ch[0].ics.predictor_present) { if (che->ch[0].ics.ltp.present) - apply_ltp(ac, &che->ch[0]); + ac->apply_ltp(ac, &che->ch[0]); if (che->ch[1].ics.ltp.present && type == TYPE_CPE) - apply_ltp(ac, &che->ch[1]); + ac->apply_ltp(ac, &che->ch[1]); } } if (che->ch[0].tns.present) - apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); + ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1); if (che->ch[1].tns.present) - apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); + ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1); if (type <= TYPE_CPE) apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling); if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) { - imdct_and_windowing(ac, &che->ch[0]); + ac->imdct_and_windowing(ac, &che->ch[0]); if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - update_ltp(ac, &che->ch[0]); + ac->update_ltp(ac, &che->ch[0]); if (type == TYPE_CPE) { - imdct_and_windowing(ac, &che->ch[1]); + ac->imdct_and_windowing(ac, &che->ch[1]); if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) - update_ltp(ac, &che->ch[1]); + ac->update_ltp(ac, &che->ch[1]); } if (ac->oc[1].m4ac.sbr > 0) { ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret); @@ -2979,6 +2985,17 @@ static av_cold int latm_decode_init(AVCodecContext *avctx) return ret; } +static void aacdec_init(AACContext *c) +{ + c->imdct_and_windowing = imdct_and_windowing; + c->apply_ltp = apply_ltp; + c->apply_tns = apply_tns; + c->windowing_and_mdct_ltp = windowing_and_mdct_ltp; + c->update_ltp = update_ltp; + + if(ARCH_MIPS) + ff_aacdec_init_mips(c); +} /** * AVOptions for Japanese DTV specific extensions (ADTS only) */ diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 904e0bb9ef..b1174dc219 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -336,7 +336,7 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) { int nb_coefs; int blk, bnd; - AC3Block *block, *block0; + AC3Block *block, *block0 = NULL; if (s->channel_mode != AC3_CHMODE_STEREO) return; diff --git a/libavcodec/arm/videodsp_init_armv5te.c b/libavcodec/arm/videodsp_init_armv5te.c index c6ca1146ea..d11a07061b 100644 --- a/libavcodec/arm/videodsp_init_armv5te.c +++ b/libavcodec/arm/videodsp_init_armv5te.c @@ -19,7 +19,7 @@ */ #include "libavutil/arm/cpu.h" -#include +#include "libavcodec/videodsp.h" #include "videodsp_arm.h" void ff_prefetch_arm(uint8_t *mem, ptrdiff_t stride, int h); diff --git a/libavcodec/bfin/Makefile b/libavcodec/bfin/Makefile index be81e6c39a..d1b41bc7f4 100644 --- a/libavcodec/bfin/Makefile +++ b/libavcodec/bfin/Makefile @@ -2,7 +2,7 @@ OBJS += bfin/dsputil_bfin.o \ bfin/fdct_bfin.o \ bfin/idct_bfin.o \ bfin/pixels_bfin.o \ - bfin/vp3_bfin.o \ - bfin/vp3_idct_bfin.o \ OBJS-$(CONFIG_MPEGVIDEOENC) += bfin/mpegvideo_bfin.o +OBJS-$(CONFIG_VP3DSP) += bfin/vp3_bfin.o \ + bfin/vp3_idct_bfin.o diff --git a/libavcodec/bfin/dsputil_bfin.c b/libavcodec/bfin/dsputil_bfin.c index 955aea01f6..da6edb5e5e 100644 --- a/libavcodec/bfin/dsputil_bfin.c +++ b/libavcodec/bfin/dsputil_bfin.c @@ -257,13 +257,7 @@ void ff_dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) if (avctx->dct_algo == FF_DCT_AUTO) c->fdct = ff_bfin_fdct; - // FIXME convert to VP3DSPContext - if (0) { // avctx->idct_algo == FF_IDCT_VP3) { - c->idct_permutation_type = FF_NO_IDCT_PERM; - c->idct = ff_bfin_vp3_idct; - c->idct_add = ff_bfin_vp3_idct_add; - c->idct_put = ff_bfin_vp3_idct_put; - } else if (avctx->idct_algo == FF_IDCT_AUTO) { + if (avctx->idct_algo == FF_IDCT_AUTO) { c->idct_permutation_type = FF_NO_IDCT_PERM; c->idct = ff_bfin_idct; c->idct_add = bfin_idct_add; diff --git a/libavcodec/bfin/dsputil_bfin.h b/libavcodec/bfin/dsputil_bfin.h index 04f87cc2b8..293092363b 100644 --- a/libavcodec/bfin/dsputil_bfin.h +++ b/libavcodec/bfin/dsputil_bfin.h @@ -38,9 +38,6 @@ void ff_bfin_idct (int16_t *block) attribute_l1_text; void ff_bfin_fdct (int16_t *block) attribute_l1_text; -void ff_bfin_vp3_idct (int16_t *block); -void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block); -void ff_bfin_vp3_idct_add (uint8_t *dest, int line_size, int16_t *block); void ff_bfin_add_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text; void ff_bfin_put_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text; void ff_bfin_diff_pixels (int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride) attribute_l1_text; diff --git a/libavcodec/bfin/vp3_bfin.c b/libavcodec/bfin/vp3_bfin.c index 06d3443a2f..d9364790f1 100644 --- a/libavcodec/bfin/vp3_bfin.c +++ b/libavcodec/bfin/vp3_bfin.c @@ -18,9 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "libavcodec/avcodec.h" +#include "libavcodec/vp3dsp.h" #include "libavcodec/dsputil.h" #include "dsputil_bfin.h" +#include "vp3_bfin.h" /* Intra iDCT offset 128 */ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block) @@ -33,6 +37,8 @@ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, int16_t *block) for (i=0;i<8;i++) for (j=0;j<8;j++) dest[line_size*i+j]=cm[block[i*8+j]]; + + memset(block, 0, 128); } /* Inter iDCT */ @@ -40,4 +46,12 @@ void ff_bfin_vp3_idct_add (uint8_t *dest, int line_size, int16_t *block) { ff_bfin_vp3_idct (block); ff_bfin_add_pixels_clamped (block, dest, line_size); + + memset(block, 0, 128); +} + +void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags) +{ + c->idct_add = ff_bfin_vp3_idct_add; + c->idct_put = ff_bfin_vp3_idct_put; } diff --git a/libavcodec/bfin/vp3_bfin.h b/libavcodec/bfin/vp3_bfin.h new file mode 100644 index 0000000000..f0bf824951 --- /dev/null +++ b/libavcodec/bfin/vp3_bfin.h @@ -0,0 +1,29 @@ +/* + * 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 + */ + + +#ifndef AVCODEC_BFIN_VP3_BFIN_H +#define AVCODEC_BFIN_VP3_BFIN_H + +#include + +void ff_bfin_vp3_idct(int16_t *block); +void ff_bfin_vp3_idct_put(uint8_t *dest, int line_size, int16_t *block); +void ff_bfin_vp3_idct_add(uint8_t *dest, int line_size, int16_t *block); + +#endif /* AVCODEC_BFIN_VP3_BFIN_H */ diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 35fe962e8d..c2c1ea1b0c 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1209,7 +1209,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac if ((ret = bink_decode_plane(c, &gb, plane_idx, !!plane)) < 0) return ret; } else { - if ((ret = binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane)) < 0) + if ((ret = binkb_decode_plane(c, &gb, plane_idx, + !avctx->frame_number, !!plane)) < 0) return ret; } if (get_bits_count(&gb) >= bits_count) diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 6e94d32ecc..0af685e28b 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -180,7 +180,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si for (i = 0; i < ctx->mb_height; i++) { ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2)); av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]); - if (buf_size < ctx->mb_scan_index[i] + 0x280) { + if (buf_size < ctx->mb_scan_index[i] + 0x280LL) { av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n"); return -1; } diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 2922883de5..7e20995a1d 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -29,54 +29,6 @@ #include "bit_depth_template.c" -static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) -{ - int i; - for(i=0; i s->num_blocks_packed) { - s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16*sizeof(unsigned char)); + s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16); s->num_blocks_packed = num_blocks_packed; } @@ -213,7 +213,7 @@ static int tgv_decode_inter(TgvContext *s, const uint8_t *buf, for (y = 0; y < s->avctx->height / 4; y++) for (x = 0; x < s->avctx->width / 4; x++) { unsigned int vector = get_bits(&gb, vector_bits); - const unsigned char *src; + const uint8_t *src; int src_stride; if (vector < num_mvs) { diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 074be4cfbb..29d76ed62e 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -123,6 +123,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f) int sxe = f->avctx->width * (sx + 1) / f->num_h_slices; int sys = f->avctx->height * sy / f->num_v_slices; int sye = f->avctx->height * (sy + 1) / f->num_v_slices; + + if (!fs) + return AVERROR(ENOMEM); + f->slice_context[i] = fs; memcpy(fs, f, sizeof(*fs)); memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 78beb9a47e..a012df334f 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -896,6 +896,8 @@ slices_ok: #define STATS_OUT_SIZE 1024 * 1024 * 6 if (avctx->flags & CODEC_FLAG_PASS1) { avctx->stats_out = av_mallocz(STATS_OUT_SIZE); + if (!avctx->stats_out) + return AVERROR(ENOMEM); for (i = 0; i < s->quant_table_count; i++) for (j = 0; j < s->slice_count; j++) { FFV1Context *sf = s->slice_context[j]; diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 9d5ecd04cf..0e887e6f89 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -254,7 +254,7 @@ static int decode_subframe_fixed(FLACContext *s, int32_t *decoded, int pred_order, int bps) { const int blocksize = s->blocksize; - int a, b, c, d, i; + int av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d), i; /* warm up samples */ for (i = 0; i < pred_order; i++) { @@ -505,6 +505,16 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data, FLAC_MAX_CHANNELS, 32); } + if (buf_size > 5 && !memcmp(buf, "\177FLAC", 5)) { + av_log(s->avctx, AV_LOG_DEBUG, "skiping flac header packet 1\n"); + return buf_size; + } + + if (buf_size > 0 && (*buf & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT) { + av_log(s->avctx, AV_LOG_DEBUG, "skiping vorbis comment\n"); + return buf_size; + } + /* check that there is at least the smallest decodable amount of data. this amount corresponds to the smallest valid FLAC frame possible. FF F8 69 02 00 00 9A 00 00 34 46 */ diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 7855416567..21464ed6b4 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -245,6 +245,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, FlashSVContext *s = avctx->priv_data; int h_blocks, v_blocks, h_part, v_part, i, j; GetBitContext gb; + int last_blockwidth = s->block_width; + int last_blockheight= s->block_height; /* no supplementary picture */ if (buf_size == 0) @@ -260,6 +262,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->block_height = 16 * (get_bits(&gb, 4) + 1); s->image_height = get_bits(&gb, 12); + if ( last_blockwidth != s->block_width + || last_blockheight!= s->block_height) + av_freep(&s->blocks); + if (s->ver == 2) { skip_bits(&gb, 6); if (get_bits1(&gb)) { @@ -323,9 +329,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, s->keyframedata = av_realloc(s->keyframedata, avpkt->size); memcpy(s->keyframedata, avpkt->data, avpkt->size); } - if(s->ver == 2) - s->blocks = av_realloc(s->blocks, - (v_blocks + !!v_part) * (h_blocks + !!h_part) + if(s->ver == 2 && !s->blocks) + s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) * sizeof(s->blocks[0])); av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 8436032b18..34cd8c0658 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1462,7 +1462,6 @@ static void decode_postinit(H264Context *h, int setup_finished) cur->f.repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: - // Force progressive here, doubling interlaced frame is a bad idea. cur->f.repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: @@ -2368,7 +2367,7 @@ static int field_end(H264Context *h, int in_setup) * past end by one (callers fault) and resync_mb_y != 0 * causes problems for the first MB line, too. */ - if (!FIELD_PICTURE && h->current_slice) + if (!FIELD_PICTURE && h->current_slice && !h->sps.new) ff_er_frame_end(s); ff_MPV_frame_end(s); @@ -2776,7 +2775,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0) || s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma || h->cur_chroma_format_idc != h->sps.chroma_format_idc || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))); - + if (h0->s.avctx->pix_fmt != get_pixel_format(h0)) + must_reinit = 1; s->mb_width = h->sps.mb_width; s->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag); @@ -3906,6 +3906,7 @@ static int execute_decode_slices(H264Context *h, int context_count) if (context_count == 1) { return decode_slice(avctx, &h); } else { + av_assert0(context_count > 0); for (i = 1; i < context_count; i++) { hx = h->thread_context[i]; hx->s.err_recognition = avctx->err_recognition; diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index bbca26ab4d..54b3775761 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1712,7 +1712,7 @@ decode_cabac_residual_internal(H264Context *h, int16_t *block, \ if( coeff_abs >= 15 ) { \ int j = 0; \ - while( get_cabac_bypass( CC ) ) { \ + while(get_cabac_bypass( CC ) && j<30) { \ j++; \ } \ \ diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 9c92bf3875..2c56bfa493 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -107,23 +107,26 @@ static int read_len_table(uint8_t *dst, GetBitContext *gb) return 0; } -static void generate_joint_tables(HYuvContext *s) +static int generate_joint_tables(HYuvContext *s) { uint16_t symbols[1 << VLC_BITS]; uint16_t bits[1 << VLC_BITS]; uint8_t len[1 << VLC_BITS]; + int ret; + if (s->bitstream_bpp < 24) { int p, i, y, u; for (p = 0; p < 3; p++) { for (i = y = 0; y < 256; y++) { int len0 = s->len[0][y]; int limit = VLC_BITS - len0; - if(limit <= 0) + if(limit <= 0 || !len0) continue; for (u = 0; u < 256; u++) { int len1 = s->len[p][u]; - if (len1 > limit) + if (len1 > limit || !len1) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1; bits[i] = (s->bits[0][y] << len1) + s->bits[p][u]; symbols[i] = (y << 8) + u; @@ -132,8 +135,9 @@ static void generate_joint_tables(HYuvContext *s) } } ff_free_vlc(&s->vlc[3 + p]); - ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1, - bits, 2, 2, symbols, 2, 2, 0); + if ((ret = ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1, + bits, 2, 2, symbols, 2, 2, 0)) < 0) + return ret; } } else { uint8_t (*map)[4] = (uint8_t(*)[4])s->pix_bgr_map; @@ -146,18 +150,19 @@ static void generate_joint_tables(HYuvContext *s) for (i = 0, g = -16; g < 16; g++) { int len0 = s->len[p0][g & 255]; int limit0 = VLC_BITS - len0; - if (limit0 < 2) + if (limit0 < 2 || !len0) continue; for (b = -16; b < 16; b++) { int len1 = s->len[p1][b & 255]; int limit1 = limit0 - len1; - if (limit1 < 1) + if (limit1 < 1 || !len1) continue; code = (s->bits[p0][g & 255] << len1) + s->bits[p1][b & 255]; for (r = -16; r < 16; r++) { int len2 = s->len[2][r & 255]; - if (len2 > limit1) + if (len2 > limit1 || !len2) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; bits[i] = (code << len2) + s->bits[2][r & 255]; if (s->decorrelate) { @@ -174,14 +179,17 @@ static void generate_joint_tables(HYuvContext *s) } } ff_free_vlc(&s->vlc[3]); - init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0); + if ((ret = init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0)) < 0) + return ret; } + return 0; } static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, src, length * 8); @@ -192,11 +200,13 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) return -1; } ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } - generate_joint_tables(s); + if ((ret = generate_joint_tables(s)) < 0) + return ret; return (get_bits_count(&gb) + 7) / 8; } @@ -205,6 +215,7 @@ static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8); @@ -228,11 +239,13 @@ static int read_old_huffman_tables(HYuvContext *s) for (i = 0; i < 3; i++) { ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } - generate_joint_tables(s); + if ((ret = generate_joint_tables(s)) < 0) + return ret; return 0; } diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 6b1fd89d6b..8e7f8cae46 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -576,7 +576,7 @@ static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, in } } else { int size = -opcode + 1; - uint32_t pixel = AV_RL32(src); + uint32_t pixel = AV_RN32(src); for (i = 0; i < size; i++) { *(uint32_t *)(dst + y*linesize + x * 4) = pixel; x += 1; diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 3285578a70..e0550a702b 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -969,6 +969,13 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, if (buf_size < s->decoding_map_size) return buf_size; + if (s->last_frame.data[0] && av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) { + if (s->last_frame.data[0]) + avctx->release_buffer(avctx, &s->last_frame); + if (s->second_last_frame.data[0]) + avctx->release_buffer(avctx, &s->second_last_frame); + } + s->decoding_map = buf; bytestream2_init(&s->stream_ptr, buf + s->decoding_map_size, buf_size - s->decoding_map_size); diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c index 2722312f11..5a62e9da2b 100644 --- a/libavcodec/kbdwin.c +++ b/libavcodec/kbdwin.c @@ -16,9 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include -#include +#include "libavutil/avassert.h" +#include "libavutil/mathematics.h" #include "libavutil/attributes.h" #include "kbdwin.h" diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index f3e6db446a..826a547565 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -1,9 +1,10 @@ LIBAVCODEC_$MAJOR { global: av*; + #deprecated, remove after next bump audio_resample; audio_resample_close; - #deprecated, remove after next bump dsputil_init; + ff_dsputil_init; ff_find_pix_fmt; ff_framenum_to_drop_timecode; ff_framenum_to_smtpe_timecode; diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 13e8ef914c..c35508376b 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -100,6 +100,12 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p case AV_PIX_FMT_RGBA: case AV_PIX_FMT_RGB48: case AV_PIX_FMT_RGBA64: + case AV_PIX_FMT_GBR24P: + case AV_PIX_FMT_GBRP9: + case AV_PIX_FMT_GBRP10: + case AV_PIX_FMT_GBRP12: + case AV_PIX_FMT_GBRP14: + case AV_PIX_FMT_GBRP16: color_space = CLRSPC_SRGB; break; case AV_PIX_FMT_YUV410P: @@ -182,6 +188,35 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx) ctx->enc_params.tcp_numlayers = ctx->numlayers; ctx->enc_params.tcp_rates[0] = FFMAX(avctx->compression_level, 0) * 2; + if (ctx->cinema_mode > 0) { + ctx->enc_params.irreversible = 1; + ctx->enc_params.tcp_mct = 1; + ctx->enc_params.tile_size_on = 0; + /* no subsampling */ + ctx->enc_params.cp_tdx=1; + ctx->enc_params.cp_tdy=1; + ctx->enc_params.subsampling_dx = 1; + ctx->enc_params.subsampling_dy = 1; + /* Tile and Image shall be at (0,0) */ + ctx->enc_params.cp_tx0 = 0; + ctx->enc_params.cp_ty0 = 0; + ctx->enc_params.image_offset_x0 = 0; + ctx->enc_params.image_offset_y0 = 0; + /* Codeblock size= 32*32 */ + ctx->enc_params.cblockw_init = 32; + ctx->enc_params.cblockh_init = 32; + ctx->enc_params.csty |= 0x01; + /* No ROI */ + ctx->enc_params.roi_compno = -1; + + if (ctx->enc_params.prog_order != CPRL) { + av_log(avctx, AV_LOG_ERROR, "prog_order forced to CPRL\n"); + ctx->enc_params.prog_order = CPRL; + } + ctx->enc_params.tp_flag = 'C'; + ctx->enc_params.tp_on = 1; + } + ctx->compress = opj_create_compress(ctx->format); if (!ctx->compress) { av_log(avctx, AV_LOG_ERROR, "Error creating the compressor\n"); @@ -351,6 +386,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, opj_cio_t *stream; int cpyresult = 0; int ret, len; + AVFrame gbrframe; // x0, y0 is the top left corner of the image // x1, y1 is the width, height of the reference grid @@ -369,6 +405,25 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, case AV_PIX_FMT_RGBA64: cpyresult = libopenjpeg_copy_packed16(avctx, frame, image); break; + case AV_PIX_FMT_GBR24P: + case AV_PIX_FMT_GBRP9: + case AV_PIX_FMT_GBRP10: + case AV_PIX_FMT_GBRP12: + case AV_PIX_FMT_GBRP14: + case AV_PIX_FMT_GBRP16: + gbrframe = *frame; + gbrframe.data[0] = frame->data[2]; // swap to be rgb + gbrframe.data[1] = frame->data[0]; + gbrframe.data[2] = frame->data[1]; + gbrframe.linesize[0] = frame->linesize[2]; + gbrframe.linesize[1] = frame->linesize[0]; + gbrframe.linesize[2] = frame->linesize[1]; + if (avctx->pix_fmt == AV_PIX_FMT_GBR24P) { + cpyresult = libopenjpeg_copy_unpacked8(avctx, &gbrframe, image); + } else { + cpyresult = libopenjpeg_copy_unpacked16(avctx, &gbrframe, image); + } + break; case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV410P: case AV_PIX_FMT_YUV411P: @@ -505,6 +560,8 @@ AVCodec ff_libopenjpeg_encoder = { .capabilities = 0, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64, + AV_PIX_FMT_GBR24P, + AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, AV_PIX_FMT_GRAY16, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA422P, diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 93377e2220..9958c148c7 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -287,7 +287,7 @@ static av_cold int decode_init(AVCodecContext *avctx) break; case LOCO_CRGBA: case LOCO_RGBA: - avctx->pix_fmt = AV_PIX_FMT_RGB32; + avctx->pix_fmt = AV_PIX_FMT_BGRA; break; default: av_log(avctx, AV_LOG_INFO, "Unknown colorspace, index = %i\n", l->mode); diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 68e850c60e..cd96fa4d82 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -33,7 +33,7 @@ #include "mpeg12.h" #include "thread.h" -typedef struct MDECContext{ +typedef struct MDECContext { AVCodecContext *avctx; DSPContext dsp; AVFrame picture; @@ -57,36 +57,36 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) int level, diff, i, j, run; int component; RLTable *rl = &ff_rl_mpeg1; - uint8_t * const scantable= a->scantable.permutated; - const uint16_t *quant_matrix= ff_mpeg1_default_intra_matrix; - const int qscale= a->qscale; + uint8_t * const scantable = a->scantable.permutated; + const uint16_t *quant_matrix = ff_mpeg1_default_intra_matrix; + const int qscale = a->qscale; /* DC coefficient */ - if(a->version==2){ - block[0]= 2*get_sbits(&a->gb, 10) + 1024; - }else{ + if (a->version == 2) { + block[0] = 2 * get_sbits(&a->gb, 10) + 1024; + } else { component = (n <= 3 ? 0 : n - 4 + 1); diff = decode_dc(&a->gb, component); if (diff >= 0xffff) - return -1; - a->last_dc[component]+= diff; - block[0] = a->last_dc[component]<<3; + return AVERROR_INVALIDDATA; + a->last_dc[component] += diff; + block[0] = a->last_dc[component] << 3; } i = 0; { OPEN_READER(re, &a->gb); /* now quantify & encode AC coefficients */ - for(;;) { + for (;;) { UPDATE_CACHE(re, &a->gb); GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); - if(level == 127){ + if (level == 127) { break; - } else if(level != 0) { - i += run; - j = scantable[i]; - level= (level*qscale*quant_matrix[j])>>3; + } else if (level != 0) { + i += run; + j = scantable[i]; + level = (level * qscale * quant_matrix[j]) >> 3; level = (level ^ SHOW_SBITS(re, &a->gb, 1)) - SHOW_SBITS(re, &a->gb, 1); LAST_SKIP_BITS(re, &a->gb, 1); } else { @@ -94,21 +94,21 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) run = SHOW_UBITS(re, &a->gb, 6)+1; LAST_SKIP_BITS(re, &a->gb, 6); UPDATE_CACHE(re, &a->gb); level = SHOW_SBITS(re, &a->gb, 10); SKIP_BITS(re, &a->gb, 10); - i += run; - j = scantable[i]; - if(level<0){ - level= -level; - level= (level*qscale*quant_matrix[j])>>3; - level= (level-1)|1; - level= -level; - }else{ - level= (level*qscale*quant_matrix[j])>>3; - level= (level-1)|1; + i += run; + j = scantable[i]; + if (level < 0) { + level = -level; + level = (level * qscale * quant_matrix[j]) >> 3; + level = (level - 1) | 1; + level = -level; + } else { + level = (level * qscale * quant_matrix[j]) >> 3; + level = (level - 1) | 1; } } - if (i > 63){ + if (i > 63) { av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y); - return -1; + return AVERROR_INVALIDDATA; } block[j] = level; @@ -119,34 +119,38 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) return 0; } -static inline int decode_mb(MDECContext *a, int16_t block[6][64]){ - int i; - const int block_index[6]= {5,4,0,1,2,3}; +static inline int decode_mb(MDECContext *a, int16_t block[6][64]) +{ + int i, ret; + const int block_index[6] = { 5, 4, 0, 1, 2, 3 }; a->dsp.clear_blocks(block[0]); - for(i=0; i<6; i++){ - if( mdec_decode_block_intra(a, block[ block_index[i] ], block_index[i]) < 0 || - get_bits_left(&a->gb) < 0) - return -1; + for (i = 0; i < 6; i++) { + if ((ret = mdec_decode_block_intra(a, block[block_index[i]], + block_index[i])) < 0) + return ret; + if (get_bits_left(&a->gb) < 0) + return AVERROR_INVALIDDATA; } return 0; } -static inline void idct_put(MDECContext *a, int mb_x, int mb_y){ - int16_t (*block)[64]= a->block; - int linesize= a->picture.linesize[0]; +static inline void idct_put(MDECContext *a, int mb_x, int mb_y) +{ + int16_t (*block)[64] = a->block; + int linesize = a->picture.linesize[0]; - uint8_t *dest_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16; - uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8; - uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8; + uint8_t *dest_y = a->picture.data[0] + (mb_y * 16 * linesize ) + mb_x * 16; + uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8; + uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8; - a->dsp.idct_put(dest_y , linesize, block[0]); - a->dsp.idct_put(dest_y + 8, linesize, block[1]); - a->dsp.idct_put(dest_y + 8*linesize , linesize, block[2]); - a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]); + a->dsp.idct_put(dest_y, linesize, block[0]); + a->dsp.idct_put(dest_y + 8, linesize, block[1]); + a->dsp.idct_put(dest_y + 8 * linesize, linesize, block[2]); + a->dsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]); - if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ + if (!(a->avctx->flags & CODEC_FLAG_GRAY)) { a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]); a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]); } @@ -156,112 +160,106 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; MDECContext * const a = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p= &a->picture; - int i; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + AVFrame *picture = data; + AVFrame * const p = &a->picture; + int i, ret; - if(p->data[0]) + if (p->data[0]) ff_thread_release_buffer(avctx, p); - p->reference= 0; - if(ff_thread_get_buffer(avctx, p) < 0){ + p->reference = 0; + if ((ret = ff_thread_get_buffer(avctx, p)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; + return ret; } - p->pict_type= AV_PICTURE_TYPE_I; - p->key_frame= 1; + p->pict_type = AV_PICTURE_TYPE_I; + p->key_frame = 1; av_fast_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!a->bitstream_buffer) return AVERROR(ENOMEM); - for(i=0; ibitstream_buffer[i] = buf[i+1]; - a->bitstream_buffer[i+1]= buf[i ]; + for (i = 0; i < buf_size; i += 2) { + a->bitstream_buffer[i] = buf[i + 1]; + a->bitstream_buffer[i + 1] = buf[i]; } - init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8); + init_get_bits(&a->gb, a->bitstream_buffer, buf_size * 8); /* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */ skip_bits(&a->gb, 32); - a->qscale= get_bits(&a->gb, 16); - a->version= get_bits(&a->gb, 16); + a->qscale = get_bits(&a->gb, 16); + a->version = get_bits(&a->gb, 16); - a->last_dc[0]= - a->last_dc[1]= - a->last_dc[2]= 128; + a->last_dc[0] = a->last_dc[1] = a->last_dc[2] = 128; - for(a->mb_x=0; a->mb_xmb_width; a->mb_x++){ - for(a->mb_y=0; a->mb_ymb_height; a->mb_y++){ - if( decode_mb(a, a->block) <0) - return -1; + for (a->mb_x = 0; a->mb_x < a->mb_width; a->mb_x++) { + for (a->mb_y = 0; a->mb_y < a->mb_height; a->mb_y++) { + if ((ret = decode_mb(a, a->block)) < 0) + return ret; idct_put(a, a->mb_x, a->mb_y); } } - p->quality= a->qscale * FF_QP2LAMBDA; + p->quality = a->qscale * FF_QP2LAMBDA; memset(p->qscale_table, a->qscale, a->mb_width); *picture = a->picture; *got_frame = 1; - return (get_bits_count(&a->gb)+31)/32*4; + return (get_bits_count(&a->gb) + 31) / 32 * 4; } -static av_cold void mdec_common_init(AVCodecContext *avctx){ +static av_cold int decode_init(AVCodecContext *avctx) +{ MDECContext * const a = avctx->priv_data; + AVFrame *p = &a->picture; - ff_dsputil_init(&a->dsp, avctx); - - a->mb_width = (avctx->coded_width + 15) / 16; - a->mb_height = (avctx->coded_height + 15) / 16; + a->mb_width = (avctx->coded_width + 15) / 16; + a->mb_height = (avctx->coded_height + 15) / 16; avcodec_get_frame_defaults(&a->picture); - avctx->coded_frame= &a->picture; - a->avctx= avctx; -} + avctx->coded_frame = &a->picture; + a->avctx = avctx; -static av_cold int decode_init(AVCodecContext *avctx){ - MDECContext * const a = avctx->priv_data; - AVFrame *p= &a->picture; - - mdec_common_init(avctx); + ff_dsputil_init(&a->dsp, avctx); ff_mpeg12_init_vlcs(); ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct); - if( avctx->idct_algo == FF_IDCT_AUTO ) + if (avctx->idct_algo == FF_IDCT_AUTO) avctx->idct_algo = FF_IDCT_SIMPLE; - p->qstride= 0; - p->qscale_table= av_mallocz(a->mb_width); - avctx->pix_fmt= AV_PIX_FMT_YUVJ420P; + p->qstride = 0; + p->qscale_table = av_mallocz(a->mb_width); + avctx->pix_fmt = AV_PIX_FMT_YUVJ420P; return 0; } -static av_cold int decode_init_thread_copy(AVCodecContext *avctx){ +static av_cold int decode_init_thread_copy(AVCodecContext *avctx) +{ MDECContext * const a = avctx->priv_data; - AVFrame *p = &a->picture; + AVFrame *p = &a->picture; - avctx->coded_frame= p; - a->avctx= avctx; + avctx->coded_frame = p; + a->avctx = avctx; p->qscale_table= av_mallocz(a->mb_width); return 0; } - -static av_cold int decode_end(AVCodecContext *avctx){ +static av_cold int decode_end(AVCodecContext *avctx) +{ MDECContext * const a = avctx->priv_data; - if(a->picture.data[0]) + if (a->picture.data[0]) avctx->release_buffer(avctx, &a->picture); av_freep(&a->bitstream_buffer); av_freep(&a->picture.qscale_table); - a->bitstream_buffer_size=0; + a->bitstream_buffer_size = 0; return 0; } diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index d30bac3d76..54d27e8af3 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -297,7 +297,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, * Flip the buffer upside-down and put it in the YVU order to match the * way Mimic encodes frames. */ -static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVPicture *src) +static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVFrame *src) { int i; dst->data[0] = src->data[0] + ( ctx->avctx->height - 1) * src->linesize[0]; @@ -374,7 +374,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, ctx->next_cur_index = (ctx->cur_index - 1) & 15; prepare_avpic(ctx, &ctx->flipped_ptrs[ctx->cur_index], - (AVPicture*) &ctx->buf_ptrs[ctx->cur_index]); + &ctx->buf_ptrs[ctx->cur_index]); ff_thread_finish_setup(avctx); diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile index 01811975c6..609939ded7 100644 --- a/libavcodec/mips/Makefile +++ b/libavcodec/mips/Makefile @@ -13,3 +13,4 @@ OBJS-$(CONFIG_FFT) += mips/fft_init_table.o MIPSFPU-OBJS-$(CONFIG_FFT) += mips/fft_mips.o MIPSFPU-OBJS += mips/fmtconvert_mips.o OBJS-$(CONFIG_AC3DSP) += mips/ac3dsp_mips.o +OBJS-$(CONFIG_AAC_DECODER) += mips/aacdec_mips.o diff --git a/libavcodec/mips/aacdec_mips.c b/libavcodec/mips/aacdec_mips.c new file mode 100644 index 0000000000..e4033668da --- /dev/null +++ b/libavcodec/mips/aacdec_mips.c @@ -0,0 +1,831 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Authors: Darko Laus (darko@mips.com) + * Djordje Pesut (djordje@mips.com) + * Mirjana Vulin (mvulin@mips.com) + * + * 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 + * Reference: libavcodec/aacdec.c + */ + +#include "libavcodec/aac.h" +#include "aacdec_mips.h" +#include "libavcodec/aactab.h" +#include "libavcodec/sinewin.h" + +#if HAVE_INLINE_ASM +static av_always_inline int lcg_random(unsigned previous_val) +{ + union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; + return v.s; +} + +static void imdct_and_windowing_mips(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *in = sce->coeffs; + float *out = sce->ret; + float *saved = sce->saved; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; + float *buf = ac->buf_mdct; + int i; + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + for (i = 0; i < 1024; i += 128) + ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); + } else + ac->mdct.imdct_half(&ac->mdct, buf, in); + + /* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && + (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { + ac->fdsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512); + } else { + { + float *buf1 = saved; + float *buf2 = out; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 1792 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + { + float wi; + float wj; + int i; + float temp0, temp1, temp2, temp3; + float *dst0 = out + 448 + 0*128; + float *dst1 = dst0 + 64 + 63; + float *dst2 = saved + 63; + float *win0 = (float*)swindow; + float *win1 = win0 + 64 + 63; + float *win0_prev = (float*)swindow_prev; + float *win1_prev = win0_prev + 64 + 63; + float *src0_prev = saved + 448; + float *src1_prev = buf + 0*128 + 63; + float *src0 = buf + 0*128 + 64; + float *src1 = buf + 1*128 + 63; + + for(i = 0; i < 64; i++) + { + temp0 = src0_prev[0]; + temp1 = src1_prev[0]; + wi = *win0_prev; + wj = *win1_prev; + temp2 = src0[0]; + temp3 = src1[0]; + dst0[0] = temp0 * wj - temp1 * wi; + dst1[0] = temp0 * wi + temp1 * wj; + + wi = *win0; + wj = *win1; + + temp0 = src0[128]; + temp1 = src1[128]; + dst0[128] = temp2 * wj - temp3 * wi; + dst1[128] = temp2 * wi + temp3 * wj; + + temp2 = src0[256]; + temp3 = src1[256]; + dst0[256] = temp0 * wj - temp1 * wi; + dst1[256] = temp0 * wi + temp1 * wj; + dst0[384] = temp2 * wj - temp3 * wi; + dst1[384] = temp2 * wi + temp3 * wj; + + temp0 = src0[384]; + temp1 = src1[384]; + dst0[512] = temp0 * wj - temp1 * wi; + dst2[0] = temp0 * wi + temp1 * wj; + + src0++; + src1--; + src0_prev++; + src1_prev--; + win0++; + win1--; + win0_prev++; + win1_prev--; + dst0++; + dst1--; + dst2--; + } + } + } else { + ac->fdsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64); + { + float *buf1 = buf + 64; + float *buf2 = out + 576; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 1792 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + } + } + + // buffer update + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + ac->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64); + ac->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64); + ac->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64); + { + float *buf1 = buf + 7*128 + 64; + float *buf2 = saved + 448; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 256 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + float *buf1 = buf + 512; + float *buf2 = saved; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 1792 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + { + float *buf1 = buf + 7*128 + 64; + float *buf2 = saved + 448; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 256 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } + } else { // LONG_STOP or ONLY_LONG + float *buf1 = buf + 512; + float *buf2 = saved; + int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; + int loop_end; + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 2048 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf1), + [dst]"+r"(buf2) + : + : "memory" + ); + } +} + +static void apply_ltp_mips(AACContext *ac, SingleChannelElement *sce) +{ + const LongTermPrediction *ltp = &sce->ics.ltp; + const uint16_t *offsets = sce->ics.swb_offset; + int i, sfb; + int j, k; + + if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { + float *predTime = sce->ret; + float *predFreq = ac->buf_mdct; + float *p_predTime; + int16_t num_samples = 2048; + + if (ltp->lag < 1024) + num_samples = ltp->lag + 1024; + j = (2048 - num_samples) >> 2; + k = (2048 - num_samples) & 3; + p_predTime = &predTime[num_samples]; + + for (i = 0; i < num_samples; i++) + predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef; + for (i = 0; i < j; i++) { + + /* loop unrolled 4 times */ + __asm__ volatile ( + "sw $0, 0(%[p_predTime]) \n\t" + "sw $0, 4(%[p_predTime]) \n\t" + "sw $0, 8(%[p_predTime]) \n\t" + "sw $0, 12(%[p_predTime]) \n\t" + "addiu %[p_predTime], %[p_predTime], 16 \n\t" + + : [p_predTime]"+r"(p_predTime) + : + : "memory" + ); + } + for (i = 0; i < k; i++) { + + __asm__ volatile ( + "sw $0, 0(%[p_predTime]) \n\t" + "addiu %[p_predTime], %[p_predTime], 4 \n\t" + + : [p_predTime]"+r"(p_predTime) + : + : "memory" + ); + } + + ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics); + + if (sce->tns.present) + ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0); + + for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++) + if (ltp->used[sfb]) + for (i = offsets[sfb]; i < offsets[sfb + 1]; i++) + sce->coeffs[i] += predFreq[i]; + } +} + +#if HAVE_MIPSFPU +static void update_ltp_mips(AACContext *ac, SingleChannelElement *sce) +{ + IndividualChannelStream *ics = &sce->ics; + float *saved = sce->saved; + float *saved_ltp = sce->coeffs; + const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; + const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; + int i; + int loop_end, loop_end1, loop_end2; + float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10, temp11; + + if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { + float *buf = saved; + float *buf0 = saved_ltp; + float *p_saved_ltp = saved_ltp + 576; + float *ptr1 = &saved_ltp[512]; + float *ptr2 = &ac->buf_mdct[1023]; + float *ptr3 = (float*)&swindow[63]; + loop_end1 = (int)(p_saved_ltp + 448); + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 2048 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [src]"+r"(buf), + [dst]"+r"(buf0) + : + : "memory" + ); + + /* loop unrolled 8 times */ + __asm__ volatile ( + "1: \n\t" + "sw $0, 0(%[p_saved_ltp]) \n\t" + "sw $0, 4(%[p_saved_ltp]) \n\t" + "sw $0, 8(%[p_saved_ltp]) \n\t" + "sw $0, 12(%[p_saved_ltp]) \n\t" + "sw $0, 16(%[p_saved_ltp]) \n\t" + "sw $0, 20(%[p_saved_ltp]) \n\t" + "sw $0, 24(%[p_saved_ltp]) \n\t" + "sw $0, 28(%[p_saved_ltp]) \n\t" + "addiu %[p_saved_ltp], %[p_saved_ltp], 32 \n\t" + "bne %[p_saved_ltp], %[loop_end1], 1b \n\t" + + : [p_saved_ltp]"+r"(p_saved_ltp) + : [loop_end1]"r"(loop_end1) + : "memory" + ); + + ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + for (i = 0; i < 16; i++){ + /* loop unrolled 4 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[ptr2]) \n\t" + "lwc1 %[temp1], -4(%[ptr2]) \n\t" + "lwc1 %[temp2], -8(%[ptr2]) \n\t" + "lwc1 %[temp3], -12(%[ptr2]) \n\t" + "lwc1 %[temp4], 0(%[ptr3]) \n\t" + "lwc1 %[temp5], -4(%[ptr3]) \n\t" + "lwc1 %[temp6], -8(%[ptr3]) \n\t" + "lwc1 %[temp7], -12(%[ptr3]) \n\t" + "mul.s %[temp8], %[temp0], %[temp4] \n\t" + "mul.s %[temp9], %[temp1], %[temp5] \n\t" + "mul.s %[temp10], %[temp2], %[temp6] \n\t" + "mul.s %[temp11], %[temp3], %[temp7] \n\t" + "swc1 %[temp8], 0(%[ptr1]) \n\t" + "swc1 %[temp9], 4(%[ptr1]) \n\t" + "swc1 %[temp10], 8(%[ptr1]) \n\t" + "swc1 %[temp11], 12(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + "addiu %[ptr2], %[ptr2], -16 \n\t" + "addiu %[ptr3], %[ptr3], -16 \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), + [ptr1]"+r"(ptr1), [ptr2]"+r"(ptr2), [ptr3]"+r"(ptr3) + : + : "memory" + ); + } + } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { + float *buff0 = saved; + float *buff1 = saved_ltp; + float *ptr1 = &saved_ltp[512]; + float *ptr2 = &ac->buf_mdct[1023]; + float *ptr3 = (float*)&swindow[63]; + loop_end = (int)(saved + 448); + + /* loop unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "sw $0, 2304(%[dst]) \n\t" + "sw $0, 2308(%[dst]) \n\t" + "sw $0, 2312(%[dst]) \n\t" + "sw $0, 2316(%[dst]) \n\t" + "sw $0, 2320(%[dst]) \n\t" + "sw $0, 2324(%[dst]) \n\t" + "sw $0, 2328(%[dst]) \n\t" + "sw $0, 2332(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [src]"+r"(buff0), [dst]"+r"(buff1) + : [loop_end]"r"(loop_end) + : "memory" + ); + ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); + for (i = 0; i < 16; i++){ + /* loop unrolled 8 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[ptr2]) \n\t" + "lwc1 %[temp1], -4(%[ptr2]) \n\t" + "lwc1 %[temp2], -8(%[ptr2]) \n\t" + "lwc1 %[temp3], -12(%[ptr2]) \n\t" + "lwc1 %[temp4], 0(%[ptr3]) \n\t" + "lwc1 %[temp5], -4(%[ptr3]) \n\t" + "lwc1 %[temp6], -8(%[ptr3]) \n\t" + "lwc1 %[temp7], -12(%[ptr3]) \n\t" + "mul.s %[temp8], %[temp0], %[temp4] \n\t" + "mul.s %[temp9], %[temp1], %[temp5] \n\t" + "mul.s %[temp10], %[temp2], %[temp6] \n\t" + "mul.s %[temp11], %[temp3], %[temp7] \n\t" + "swc1 %[temp8], 0(%[ptr1]) \n\t" + "swc1 %[temp9], 4(%[ptr1]) \n\t" + "swc1 %[temp10], 8(%[ptr1]) \n\t" + "swc1 %[temp11], 12(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + "addiu %[ptr2], %[ptr2], -16 \n\t" + "addiu %[ptr3], %[ptr3], -16 \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), + [ptr1]"+r"(ptr1), [ptr2]"+r"(ptr2), [ptr3]"+r"(ptr3) + : + : "memory" + ); + } + } else { // LONG_STOP or ONLY_LONG + float *ptr1, *ptr2, *ptr3; + ac->fdsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); + + ptr1 = &saved_ltp[512]; + ptr2 = &ac->buf_mdct[1023]; + ptr3 = (float*)&lwindow[511]; + + for (i = 0; i < 512; i+=4){ + /* loop unrolled 4 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[ptr2]) \n\t" + "lwc1 %[temp1], -4(%[ptr2]) \n\t" + "lwc1 %[temp2], -8(%[ptr2]) \n\t" + "lwc1 %[temp3], -12(%[ptr2]) \n\t" + "lwc1 %[temp4], 0(%[ptr3]) \n\t" + "lwc1 %[temp5], -4(%[ptr3]) \n\t" + "lwc1 %[temp6], -8(%[ptr3]) \n\t" + "lwc1 %[temp7], -12(%[ptr3]) \n\t" + "mul.s %[temp8], %[temp0], %[temp4] \n\t" + "mul.s %[temp9], %[temp1], %[temp5] \n\t" + "mul.s %[temp10], %[temp2], %[temp6] \n\t" + "mul.s %[temp11], %[temp3], %[temp7] \n\t" + "swc1 %[temp8], 0(%[ptr1]) \n\t" + "swc1 %[temp9], 4(%[ptr1]) \n\t" + "swc1 %[temp10], 8(%[ptr1]) \n\t" + "swc1 %[temp11], 12(%[ptr1]) \n\t" + "addiu %[ptr1], %[ptr1], 16 \n\t" + "addiu %[ptr2], %[ptr2], -16 \n\t" + "addiu %[ptr3], %[ptr3], -16 \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), + [ptr1]"+r"(ptr1), [ptr2]"+r"(ptr2), + [ptr3]"+r"(ptr3) + : + : "memory" + ); + } + } + + { + float *buf1 = sce->ltp_state+1024; + float *buf2 = sce->ltp_state; + float *buf3 = sce->ret; + float *buf4 = sce->ltp_state+1024; + float *buf5 = saved_ltp; + float *buf6 = sce->ltp_state+2048; + + /* loops unrolled 8 times */ + __asm__ volatile ( + ".set push \n\t" + ".set noreorder \n\t" + "addiu %[loop_end], %[src], 4096 \n\t" + "addiu %[loop_end1], %[src1], 4096 \n\t" + "addiu %[loop_end2], %[src2], 4096 \n\t" + "1: \n\t" + "lw %[temp0], 0(%[src]) \n\t" + "lw %[temp1], 4(%[src]) \n\t" + "lw %[temp2], 8(%[src]) \n\t" + "lw %[temp3], 12(%[src]) \n\t" + "lw %[temp4], 16(%[src]) \n\t" + "lw %[temp5], 20(%[src]) \n\t" + "lw %[temp6], 24(%[src]) \n\t" + "lw %[temp7], 28(%[src]) \n\t" + "addiu %[src], %[src], 32 \n\t" + "sw %[temp0], 0(%[dst]) \n\t" + "sw %[temp1], 4(%[dst]) \n\t" + "sw %[temp2], 8(%[dst]) \n\t" + "sw %[temp3], 12(%[dst]) \n\t" + "sw %[temp4], 16(%[dst]) \n\t" + "sw %[temp5], 20(%[dst]) \n\t" + "sw %[temp6], 24(%[dst]) \n\t" + "sw %[temp7], 28(%[dst]) \n\t" + "bne %[src], %[loop_end], 1b \n\t" + " addiu %[dst], %[dst], 32 \n\t" + "2: \n\t" + "lw %[temp0], 0(%[src1]) \n\t" + "lw %[temp1], 4(%[src1]) \n\t" + "lw %[temp2], 8(%[src1]) \n\t" + "lw %[temp3], 12(%[src1]) \n\t" + "lw %[temp4], 16(%[src1]) \n\t" + "lw %[temp5], 20(%[src1]) \n\t" + "lw %[temp6], 24(%[src1]) \n\t" + "lw %[temp7], 28(%[src1]) \n\t" + "addiu %[src1], %[src1], 32 \n\t" + "sw %[temp0], 0(%[dst1]) \n\t" + "sw %[temp1], 4(%[dst1]) \n\t" + "sw %[temp2], 8(%[dst1]) \n\t" + "sw %[temp3], 12(%[dst1]) \n\t" + "sw %[temp4], 16(%[dst1]) \n\t" + "sw %[temp5], 20(%[dst1]) \n\t" + "sw %[temp6], 24(%[dst1]) \n\t" + "sw %[temp7], 28(%[dst1]) \n\t" + "bne %[src1], %[loop_end1], 2b \n\t" + " addiu %[dst1], %[dst1], 32 \n\t" + "3: \n\t" + "lw %[temp0], 0(%[src2]) \n\t" + "lw %[temp1], 4(%[src2]) \n\t" + "lw %[temp2], 8(%[src2]) \n\t" + "lw %[temp3], 12(%[src2]) \n\t" + "lw %[temp4], 16(%[src2]) \n\t" + "lw %[temp5], 20(%[src2]) \n\t" + "lw %[temp6], 24(%[src2]) \n\t" + "lw %[temp7], 28(%[src2]) \n\t" + "addiu %[src2], %[src2], 32 \n\t" + "sw %[temp0], 0(%[dst2]) \n\t" + "sw %[temp1], 4(%[dst2]) \n\t" + "sw %[temp2], 8(%[dst2]) \n\t" + "sw %[temp3], 12(%[dst2]) \n\t" + "sw %[temp4], 16(%[dst2]) \n\t" + "sw %[temp5], 20(%[dst2]) \n\t" + "sw %[temp6], 24(%[dst2]) \n\t" + "sw %[temp7], 28(%[dst2]) \n\t" + "bne %[src2], %[loop_end2], 3b \n\t" + " addiu %[dst2], %[dst2], 32 \n\t" + ".set pop \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&r"(temp6), [temp7]"=&r"(temp7), + [loop_end]"=&r"(loop_end), [loop_end1]"=&r"(loop_end1), + [loop_end2]"=&r"(loop_end2), [src]"+r"(buf1), + [dst]"+r"(buf2), [src1]"+r"(buf3), [dst1]"+r"(buf4), + [src2]"+r"(buf5), [dst2]"+r"(buf6) + : + : "memory" + ); + } +} +#endif /* HAVE_MIPSFPU */ +#endif /* HAVE_INLINE_ASM */ + +void ff_aacdec_init_mips(AACContext *c) +{ +#if HAVE_INLINE_ASM + c->imdct_and_windowing = imdct_and_windowing_mips; + c->apply_ltp = apply_ltp_mips; +#if HAVE_MIPSFPU + c->update_ltp = update_ltp_mips; +#endif /* HAVE_MIPSFPU */ +#endif /* HAVE_INLINE_ASM */ +} diff --git a/libavcodec/mips/aacdec_mips.h b/libavcodec/mips/aacdec_mips.h new file mode 100644 index 0000000000..9ba307962f --- /dev/null +++ b/libavcodec/mips/aacdec_mips.h @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Authors: Darko Laus (darko@mips.com) + * Djordje Pesut (djordje@mips.com) + * Mirjana Vulin (mvulin@mips.com) + * + * AAC Spectral Band Replication decoding functions optimized for MIPS + * + * 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 + * Reference: libavcodec/aacdec.c + */ + +#ifndef AVCODEC_MIPS_AACDEC_FLOAT_H +#define AVCODEC_MIPS_AACDEC_FLOAT_H + +#include "libavcodec/aac.h" + +#if HAVE_INLINE_ASM && HAVE_MIPSFPU +static inline float *VMUL2_mips(float *dst, const float *v, unsigned idx, + const float *scale) +{ + float temp0, temp1, temp2; + int temp3, temp4; + float *ret; + + __asm__ volatile( + "andi %[temp3], %[idx], 15 \n\t" + "ext %[temp4], %[idx], 4, 4 \n\t" + "sll %[temp3], %[temp3], 2 \n\t" + "sll %[temp4], %[temp4], 2 \n\t" + "lwc1 %[temp2], 0(%[scale]) \n\t" + "lwxc1 %[temp0], %[temp3](%[v]) \n\t" + "lwxc1 %[temp1], %[temp4](%[v]) \n\t" + "mul.s %[temp0], %[temp0], %[temp2] \n\t" + "mul.s %[temp1], %[temp1], %[temp2] \n\t" + "addiu %[ret], %[dst], 8 \n\t" + "swc1 %[temp0], 0(%[dst]) \n\t" + "swc1 %[temp1], 4(%[dst]) \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [ret]"=&r"(ret) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst) + : "memory" + ); + return ret; +} + +static inline float *VMUL4_mips(float *dst, const float *v, unsigned idx, + const float *scale) +{ + int temp0, temp1, temp2, temp3; + float temp4, temp5, temp6, temp7, temp8; + float *ret; + + __asm__ volatile( + "andi %[temp0], %[idx], 3 \n\t" + "ext %[temp1], %[idx], 2, 2 \n\t" + "ext %[temp2], %[idx], 4, 2 \n\t" + "ext %[temp3], %[idx], 6, 2 \n\t" + "sll %[temp0], %[temp0], 2 \n\t" + "sll %[temp1], %[temp1], 2 \n\t" + "sll %[temp2], %[temp2], 2 \n\t" + "sll %[temp3], %[temp3], 2 \n\t" + "lwc1 %[temp4], 0(%[scale]) \n\t" + "lwxc1 %[temp5], %[temp0](%[v]) \n\t" + "lwxc1 %[temp6], %[temp1](%[v]) \n\t" + "lwxc1 %[temp7], %[temp2](%[v]) \n\t" + "lwxc1 %[temp8], %[temp3](%[v]) \n\t" + "mul.s %[temp5], %[temp5], %[temp4] \n\t" + "mul.s %[temp6], %[temp6], %[temp4] \n\t" + "mul.s %[temp7], %[temp7], %[temp4] \n\t" + "mul.s %[temp8], %[temp8], %[temp4] \n\t" + "addiu %[ret], %[dst], 16 \n\t" + "swc1 %[temp5], 0(%[dst]) \n\t" + "swc1 %[temp6], 4(%[dst]) \n\t" + "swc1 %[temp7], 8(%[dst]) \n\t" + "swc1 %[temp8], 12(%[dst]) \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [ret]"=&r"(ret) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst) + : "memory" + ); + return ret; +} + +static inline float *VMUL2S_mips(float *dst, const float *v, unsigned idx, + unsigned sign, const float *scale) +{ + int temp0, temp1, temp2, temp3, temp4, temp5; + float temp6, temp7, temp8, temp9; + float *ret; + + __asm__ volatile( + "andi %[temp0], %[idx], 15 \n\t" + "ext %[temp1], %[idx], 4, 4 \n\t" + "lw %[temp4], 0(%[scale]) \n\t" + "srl %[temp2], %[sign], 1 \n\t" + "sll %[temp3], %[sign], 31 \n\t" + "sll %[temp2], %[temp2], 31 \n\t" + "sll %[temp0], %[temp0], 2 \n\t" + "sll %[temp1], %[temp1], 2 \n\t" + "lwxc1 %[temp8], %[temp0](%[v]) \n\t" + "lwxc1 %[temp9], %[temp1](%[v]) \n\t" + "xor %[temp5], %[temp4], %[temp2] \n\t" + "xor %[temp4], %[temp4], %[temp3] \n\t" + "mtc1 %[temp5], %[temp6] \n\t" + "mtc1 %[temp4], %[temp7] \n\t" + "mul.s %[temp8], %[temp8], %[temp6] \n\t" + "mul.s %[temp9], %[temp9], %[temp7] \n\t" + "addiu %[ret], %[dst], 8 \n\t" + "swc1 %[temp8], 0(%[dst]) \n\t" + "swc1 %[temp9], 4(%[dst]) \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), + [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), + [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [ret]"=&r"(ret) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst), [sign]"r"(sign) + : "memory" + ); + return ret; +} + +static inline float *VMUL4S_mips(float *dst, const float *v, unsigned idx, + unsigned sign, const float *scale) +{ + int temp0, temp1, temp2, temp3, temp4; + float temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17; + float *ret; + unsigned int mask = 1U << 31; + + __asm__ volatile( + "lw %[temp0], 0(%[scale]) \n\t" + "and %[temp1], %[idx], 3 \n\t" + "ext %[temp2], %[idx], 2, 2 \n\t" + "ext %[temp3], %[idx], 4, 2 \n\t" + "ext %[temp4], %[idx], 6, 2 \n\t" + "sll %[temp1], %[temp1], 2 \n\t" + "sll %[temp2], %[temp2], 2 \n\t" + "sll %[temp3], %[temp3], 2 \n\t" + "sll %[temp4], %[temp4], 2 \n\t" + "lwxc1 %[temp10], %[temp1](%[v]) \n\t" + "lwxc1 %[temp11], %[temp2](%[v]) \n\t" + "lwxc1 %[temp12], %[temp3](%[v]) \n\t" + "lwxc1 %[temp13], %[temp4](%[v]) \n\t" + "and %[temp1], %[sign], %[mask] \n\t" + "ext %[temp2], %[idx], 12, 1 \n\t" + "ext %[temp3], %[idx], 13, 1 \n\t" + "ext %[temp4], %[idx], 14, 1 \n\t" + "sllv %[sign], %[sign], %[temp2] \n\t" + "xor %[temp1], %[temp0], %[temp1] \n\t" + "and %[temp2], %[sign], %[mask] \n\t" + "mtc1 %[temp1], %[temp14] \n\t" + "xor %[temp2], %[temp0], %[temp2] \n\t" + "sllv %[sign], %[sign], %[temp3] \n\t" + "mtc1 %[temp2], %[temp15] \n\t" + "and %[temp3], %[sign], %[mask] \n\t" + "sllv %[sign], %[sign], %[temp4] \n\t" + "xor %[temp3], %[temp0], %[temp3] \n\t" + "and %[temp4], %[sign], %[mask] \n\t" + "mtc1 %[temp3], %[temp16] \n\t" + "xor %[temp4], %[temp0], %[temp4] \n\t" + "mtc1 %[temp4], %[temp17] \n\t" + "mul.s %[temp10], %[temp10], %[temp14] \n\t" + "mul.s %[temp11], %[temp11], %[temp15] \n\t" + "mul.s %[temp12], %[temp12], %[temp16] \n\t" + "mul.s %[temp13], %[temp13], %[temp17] \n\t" + "addiu %[ret], %[dst], 16 \n\t" + "swc1 %[temp10], 0(%[dst]) \n\t" + "swc1 %[temp11], 4(%[dst]) \n\t" + "swc1 %[temp12], 8(%[dst]) \n\t" + "swc1 %[temp13], 12(%[dst]) \n\t" + + : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), + [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), + [temp4]"=&r"(temp4), [temp10]"=&f"(temp10), + [temp11]"=&f"(temp11), [temp12]"=&f"(temp12), + [temp13]"=&f"(temp13), [temp14]"=&f"(temp14), + [temp15]"=&f"(temp15), [temp16]"=&f"(temp16), + [temp17]"=&f"(temp17), [ret]"=&r"(ret), + [sign]"+r"(sign) + : [idx]"r"(idx), [scale]"r"(scale), [v]"r"(v), + [dst]"r"(dst), [mask]"r"(mask) + : "memory" + ); + return ret; +} + +#define VMUL2 VMUL2_mips +#define VMUL4 VMUL4_mips +#define VMUL2S VMUL2S_mips +#define VMUL4S VMUL4S_mips +#endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ + +#endif /* AVCODEC_MIPS_AACDEC_FLOAT_H */ diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 2c16c9ad22..ce61cab15b 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1092,7 +1092,6 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, vard = s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16); pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; -// pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; c->mc_mb_var_sum_temp += (vard+128)>>8; if(mb_type){ @@ -1171,7 +1170,6 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, } } -// pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; set_p_mv_tables(s, mx, my, mb_type!=CANDIDATE_MB_TYPE_INTER4V); /* get intra luma score */ diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 03f4f9ff1e..0675004948 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -94,10 +94,6 @@ struct MpegEncContext; typedef struct Picture{ struct AVFrame f; - /** - * halfpel luma planes. - */ - uint8_t *interpolated[3]; int8_t *qscale_table_base; int16_t (*motion_val_base[2])[2]; uint32_t *mb_type_base; @@ -144,7 +140,6 @@ typedef struct Picture{ uint16_t *mb_var; ///< Table for MB variances uint16_t *mc_mb_var; ///< Table for motion compensated MB variances uint8_t *mb_mean; ///< Table for MB luminance - int32_t *mb_cmp_score; ///< Table for MB cmp scores, for mb decision FIXME remove int b_frame_score; /* */ struct MpegEncContext *owner2; ///< pointer to the MpegEncContext that allocated this picture int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change) @@ -729,10 +724,10 @@ typedef struct MpegEncContext { int context_reinit; } MpegEncContext; -#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \ - (pic >= old_ctx->picture && pic < old_ctx->picture+old_ctx->picture_count ?\ - &new_ctx->picture[pic - old_ctx->picture] : pic - (Picture*)old_ctx + (Picture*)new_ctx)\ - : NULL) +#define REBASE_PICTURE(pic, new_ctx, old_ctx) \ + ((pic && pic >= old_ctx->picture && \ + pic < old_ctx->picture + old_ctx->picture_count) ? \ + &new_ctx->picture[pic - old_ctx->picture] : NULL) /* mpegvideo_enc common options */ #define FF_MPV_FLAG_SKIP_RD 0x0001 diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 11607d22c8..87531d7cd9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2844,6 +2844,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ int16_t ac[6][16]; const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0; static const int dquant_tab[4]={-1,1,-2,2}; + int storecoefs = s->mb_intra && s->dc_val[0]; av_assert2(backup_s.dquant == 0); @@ -2863,7 +2864,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(qp < s->avctx->qmin || qp > s->avctx->qmax) continue; backup_s.dquant= dquant; - if(s->mb_intra && s->dc_val[0]){ + if(storecoefs){ for(i=0; i<6; i++){ dc[i]= s->dc_val[0][ s->block_index[i] ]; memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(int16_t)*16); @@ -2873,7 +2874,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb, &dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]); if(best_s.qscale != qp){ - if(s->mb_intra && s->dc_val[0]){ + if(storecoefs){ for(i=0; i<6; i++){ s->dc_val[0][ s->block_index[i] ]= dc[i]; memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(int16_t)*16); diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index 36a46b5978..e969994875 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -203,36 +203,40 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, pos += p2; } else { //run of pixels uint8_t pix[3]; //original pixel - switch(depth){ - case 8: pix[0] = bytestream2_get_byte(gb); - break; - case 16: pix16 = bytestream2_get_le16(gb); - break; - case 24: pix[0] = bytestream2_get_byte(gb); - pix[1] = bytestream2_get_byte(gb); - pix[2] = bytestream2_get_byte(gb); - break; - case 32: pix32 = bytestream2_get_le32(gb); - break; - } if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end) || (pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end)) continue; - for(i = 0; i < p1; i++) { - switch(depth){ - case 8: *output++ = pix[0]; - break; - case 16: *(uint16_t*)output = pix16; - output += 2; - break; - case 24: *output++ = pix[0]; - *output++ = pix[1]; - *output++ = pix[2]; - break; - case 32: *(uint32_t*)output = pix32; - output += 4; - break; + + switch(depth){ + case 8: + pix[0] = bytestream2_get_byte(gb); + for(i = 0; i < p1; i++) + *output++ = pix[0]; + break; + case 16: + pix16 = bytestream2_get_le16(gb); + for(i = 0; i < p1; i++) { + *(uint16_t*)output = pix16; + output += 2; } + break; + case 24: + pix[0] = bytestream2_get_byte(gb); + pix[1] = bytestream2_get_byte(gb); + pix[2] = bytestream2_get_byte(gb); + for(i = 0; i < p1; i++) { + *output++ = pix[0]; + *output++ = pix[1]; + *output++ = pix[2]; + } + break; + case 32: + pix32 = bytestream2_get_le32(gb); + for(i = 0; i < p1; i++) { + *(uint32_t*)output = pix32; + output += 4; + } + break; } pos += p1; } diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c index 545fefc47a..d5bb2d4e35 100644 --- a/libavcodec/mss3.c +++ b/libavcodec/mss3.c @@ -295,7 +295,7 @@ static void rac_normalise(RangeCoder *c) c->low |= *c->src++; } else if (!c->low) { c->got_error = 1; - return; + c->low = 1; } if (c->range >= RAC_BOTTOM) return; diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 593df60294..97c0ad19b6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -765,10 +765,14 @@ static int decode_frame(AVCodecContext *avctx, exit_loop: if (s->bits_per_pixel == 1 && s->color_type == PNG_COLOR_TYPE_PALETTE){ - int i, j; + int i, j, k; uint8_t *pd = s->current_picture->data[0]; for (j = 0; j < s->height; j++) { - for (i = s->width/8-1; i >= 0; i--) { + i = s->width / 8; + for (k = 7; k >= 1; k--) + if ((s->width&7) >= k) + pd[8*i + k - 1] = (pd[i]>>8-k) & 1; + for (i--; i >= 0; i--) { pd[8*i + 7]= pd[i] & 1; pd[8*i + 6]= (pd[i]>>1) & 1; pd[8*i + 5]= (pd[i]>>2) & 1; diff --git a/libavcodec/ppc/fmtconvert_altivec.c b/libavcodec/ppc/fmtconvert_altivec.c index d40ce07583..740614d335 100644 --- a/libavcodec/ppc/fmtconvert_altivec.c +++ b/libavcodec/ppc/fmtconvert_altivec.c @@ -93,7 +93,7 @@ static void float_to_int16_stride_altivec(int16_t *dst, const float *src, long len, int stride) { int i; - vector signed short d, s; + vector signed short d; for (i = 0; i < len - 7; i += 8) { d = float_to_int16_one_altivec(src + i); diff --git a/libavcodec/proresdsp.h b/libavcodec/proresdsp.h index a9df91851f..706162af52 100644 --- a/libavcodec/proresdsp.h +++ b/libavcodec/proresdsp.h @@ -24,6 +24,7 @@ #define AVCODEC_PRORESDSP_H #include +#include "dsputil.h" #define PRORES_BITS_PER_SAMPLE 10 ///< output precision of prores decoder diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 2bd8df8e0a..1ca72b44f2 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -1023,6 +1023,9 @@ void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) PerThreadContext *p = avctx->thread_opaque; FrameThreadContext *fctx; + if (!f->data[0]) + return; + if (!(avctx->active_thread_type&FF_THREAD_FRAME)) { avctx->release_buffer(avctx, f); return; diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index ca2aab7b56..4deea07baf 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -649,7 +649,8 @@ static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_arra if (!superblocktype_2_3) { /* This case is untested, no samples available */ - SAMPLES_NEEDED + av_log_ask_for_sample(NULL, "!superblocktype_2_3"); + return; for (ch = 0; ch < nb_channels; ch++) for (sb = 0; sb < 30; sb++) { for (j = 1; j < 63; j++) { // The loop only iterates to 63 so the code doesn't overflow the buffer @@ -685,7 +686,7 @@ static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_arra for (j = 0; j < 64; j++) acc += tone_level_idx_temp[ch][sb][j]; - multres = 0x66666667 * (acc * 10); + multres = 0x66666667LL * (acc * 10); esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31); for (ch = 0; ch < nb_channels; ch++) for (sb = 0; sb < 30; sb++) diff --git a/libavcodec/qdm2_tablegen.h b/libavcodec/qdm2_tablegen.h index 585edfdd65..a90682f43c 100644 --- a/libavcodec/qdm2_tablegen.h +++ b/libavcodec/qdm2_tablegen.h @@ -37,7 +37,7 @@ #include "libavcodec/qdm2_tables.h" #else static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1]; -static float noise_table[4096]; +static float noise_table[4096 + 20]; static uint8_t random_dequant_index[256][5]; static uint8_t random_dequant_type24[128][3]; static float noise_samples[128]; diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 70ad1f8fed..c9284920b6 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -29,6 +29,7 @@ #include "libavutil/imgutils.h" #include "libavcodec/dsputil.h" #include "sanm_data.h" +#include "libavutil/avassert.h" #define NGLYPHS 256 @@ -613,6 +614,16 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1, } else { int mx = motion_vectors[code][0]; int my = motion_vectors[code][1]; + int index = prev2 - (const uint8_t*)ctx->frm2; + + av_assert2(index >= 0 && index < (ctx->buf_size>>1)); + + if (index < - mx - my*stride || + (ctx->buf_size>>1) - index < mx + size + (my + size - 1)*stride) { + av_log(ctx->avctx, AV_LOG_ERROR, "MV is invalid \n"); + return AVERROR_INVALIDDATA; + } + for (k = 0; k < size; k++) memcpy(dst + k * stride, prev2 + mx + (my + k) * stride, size); } diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 86c1a7dda5..af6454304c 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -693,7 +693,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, if (pkt->size < TAK_MIN_FRAME_HEADER_BYTES) return AVERROR_INVALIDDATA; - init_get_bits(gb, pkt->data, pkt->size * 8); + if ((ret = init_get_bits8(gb, pkt->data, pkt->size)) < 0) + return ret; if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0) return ret; diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index 7167278351..acb25c3899 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -594,7 +594,6 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, * At least currently Ut Video is IDR only. * Set flags accordingly. */ - avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index 67d8fc9d77..9661c7c8ea 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -54,7 +54,6 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return ret; dst = pkt->data; - avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index e056ffb525..ef763fa675 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -80,7 +80,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) { MpegEncContext *s = &v->s; int topleft_mb_pos, top_mb_pos; - int stride_y, fieldtx; + int stride_y, fieldtx = 0; int v_dist; /* The put pixels loop is always one MB row behind the decoding loop, @@ -93,7 +93,8 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) if (!s->first_slice_line) { if (s->mb_x) { topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1; - fieldtx = v->fieldtx_plane[topleft_mb_pos]; + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[topleft_mb_pos]; stride_y = s->linesize << fieldtx; v_dist = (16 - fieldtx) >> (fieldtx == 0); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0], @@ -117,7 +118,8 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) } if (s->mb_x == s->mb_width - 1) { top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x; - fieldtx = v->fieldtx_plane[top_mb_pos]; + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[top_mb_pos]; stride_y = s->linesize << fieldtx; v_dist = fieldtx ? 15 : 8; s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0], @@ -2726,7 +2728,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; - int16_t *dc_val; + int16_t *dc_val = NULL; int16_t *ac_val, *ac_val2; int dcdiff; int a_avail = v->a_avail, c_avail = v->c_avail; @@ -2938,7 +2940,7 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int i; - int16_t *dc_val; + int16_t *dc_val = NULL; int16_t *ac_val, *ac_val2; int dcdiff; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; @@ -5672,7 +5674,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, continue; } v->second_field = 1; - v->blocks_off = s->mb_width * s->mb_height << 1; + v->blocks_off = s->b8_stride * (s->mb_height&~1); v->mb_off = s->mb_stride * s->mb_height >> 1; } else { v->second_field = 0; diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 792dbb2a61..00a77e9e78 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -1928,11 +1928,11 @@ static int vp3_decode_frame(AVCodecContext *avctx, int type = get_bits(&gb, 7); skip_bits_long(&gb, 6*8); /* "theora" */ + if (s->avctx->active_thread_type&FF_THREAD_FRAME) { + av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n"); + return AVERROR_PATCHWELCOME; + } if (type == 0) { - if (s->avctx->active_thread_type&FF_THREAD_FRAME) { - av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n"); - return AVERROR_PATCHWELCOME; - } vp3_decode_end(avctx); ret = theora_decode_header(avctx, &gb); diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c index 2c22130642..f3f9bd231d 100644 --- a/libavcodec/vp3dsp.c +++ b/libavcodec/vp3dsp.c @@ -310,6 +310,8 @@ av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags) if (ARCH_ARM) ff_vp3dsp_init_arm(c, flags); + if (ARCH_BFIN) + ff_vp3dsp_init_bfin(c, flags); if (ARCH_PPC) ff_vp3dsp_init_ppc(c, flags); if (ARCH_X86) diff --git a/libavcodec/vp3dsp.h b/libavcodec/vp3dsp.h index 8ffecca780..558077f908 100644 --- a/libavcodec/vp3dsp.h +++ b/libavcodec/vp3dsp.h @@ -49,6 +49,7 @@ typedef struct VP3DSPContext { void ff_vp3dsp_init(VP3DSPContext *c, int flags); void ff_vp3dsp_init_arm(VP3DSPContext *c, int flags); +void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags); void ff_vp3dsp_init_ppc(VP3DSPContext *c, int flags); void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags); diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 7df5adade3..6cc377036c 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -394,8 +394,6 @@ static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha) mb_type = vp56_decode_mv(s, row, col); ref_frame = vp56_reference_frame[mb_type]; - s->dsp.clear_blocks(*s->block_coeff); - s->parse_coeff(s); vp56_add_predictors_dc(s, ref_frame); @@ -448,6 +446,11 @@ static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha) } break; } + + if (is_alpha) { + s->block_coeff[4][0] = 0; + s->block_coeff[5][0] = 0; + } } static int vp56_size_changed(VP56Context *s) diff --git a/libavcodec/wma.c b/libavcodec/wma.c index 5af20739a5..1e6ca61047 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -134,6 +134,10 @@ int ff_wma_init(AVCodecContext *avctx, int flags2) bps = (float)avctx->bit_rate / (float)(avctx->channels * avctx->sample_rate); s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2; + if (s->byte_offset_bits + 3 > MIN_CACHE_BITS) { + av_log(avctx, AV_LOG_ERROR, "byte_offset_bits %d is too large\n", s->byte_offset_bits); + return AVERROR_PATCHWELCOME; + } /* compute high frequency value and choose if noise coding should be activated */ diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index c3b6ab3b5f..7ddc434d78 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -25,8 +25,6 @@ * @author Ronald S. Bultje */ -#define UNCHECKED_BITSTREAM_READER 1 - #include #include "libavutil/channel_layout.h" @@ -1442,8 +1440,8 @@ static int synth_frame(AVCodecContext *ctx, GetBitContext *gb, int frame_idx, float *excitation, float *synth) { WMAVoiceContext *s = ctx->priv_data; - int n, n_blocks_x2, log_n_blocks_x2, cur_pitch_val; - int pitch[MAX_BLOCKS], last_block_pitch; + int n, n_blocks_x2, log_n_blocks_x2, av_uninit(cur_pitch_val); + int pitch[MAX_BLOCKS], av_uninit(last_block_pitch); /* Parse frame type ("frame header"), see frame_descs */ int bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)], block_nsamples; diff --git a/libavcodec/x86/diracdsp_mmx.c b/libavcodec/x86/diracdsp_mmx.c index ee89295c94..cb6465f950 100644 --- a/libavcodec/x86/diracdsp_mmx.c +++ b/libavcodec/x86/diracdsp_mmx.c @@ -60,6 +60,9 @@ void ff_diracdsp_init_mmx(DiracDSPContext* c) { int mm_flags = av_get_cpu_flags(); + if (!(mm_flags & AV_CPU_FLAG_MMX)) + return; + #if HAVE_YASM c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx; #if !ARCH_X86_64 diff --git a/libavcodec/x86/dsputil.asm b/libavcodec/x86/dsputil.asm index 6a76655a8b..587d5ee968 100644 --- a/libavcodec/x86/dsputil.asm +++ b/libavcodec/x86/dsputil.asm @@ -648,46 +648,3 @@ BSWAP32_BUF INIT_XMM ssse3 BSWAP32_BUF - -INIT_XMM sse2 -; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) -cglobal put_pixels16, 4,5,4 - movsxdifnidn r2, r2d - lea r4, [r2*3] -.loop: - movu m0, [r1] - movu m1, [r1+r2] - movu m2, [r1+r2*2] - movu m3, [r1+r4] - lea r1, [r1+r2*4] - mova [r0], m0 - mova [r0+r2], m1 - mova [r0+r2*2], m2 - mova [r0+r4], m3 - sub r3d, 4 - lea r0, [r0+r2*4] - jnz .loop - REP_RET - -; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) -cglobal avg_pixels16, 4,5,4 - movsxdifnidn r2, r2d - lea r4, [r2*3] -.loop: - movu m0, [r1] - movu m1, [r1+r2] - movu m2, [r1+r2*2] - movu m3, [r1+r4] - lea r1, [r1+r2*4] - pavgb m0, [r0] - pavgb m1, [r0+r2] - pavgb m2, [r0+r2*2] - pavgb m3, [r0+r4] - mova [r0], m0 - mova [r0+r2], m1 - mova [r0+r2*2], m2 - mova [r0+r4], m3 - sub r3d, 4 - lea r0, [r0+r2*4] - jnz .loop - REP_RET diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c index 303d36d109..2e8300a788 100644 --- a/libavcodec/x86/dsputil_mmx.c +++ b/libavcodec/x86/dsputil_mmx.c @@ -1612,40 +1612,67 @@ void ff_avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src, #define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\ void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ {\ - OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\ + if (h&3)\ + ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\ + else\ + OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\ }\ void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ {\ - OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\ + if (h&3)\ + ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\ + else\ + OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\ }\ void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ {\ - OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\ - OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\ + if (h&3) {\ + ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\ + } else {\ + OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\ + OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\ + }\ } +#if HAVE_MMX_INLINE DIRAC_PIXOP(put, put, mmx) DIRAC_PIXOP(avg, avg, mmx) -DIRAC_PIXOP(avg, ff_avg, mmxext) +#endif #if HAVE_YASM +DIRAC_PIXOP(avg, ff_avg, mmxext) + void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) + ff_put_dirac_pixels16_c(dst, src, stride, h); + else ff_put_pixels16_sse2(dst, src[0], stride, h); } void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) + ff_avg_dirac_pixels16_c(dst, src, stride, h); + else ff_avg_pixels16_sse2(dst, src[0], stride, h); } void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) { + ff_put_dirac_pixels32_c(dst, src, stride, h); + } else { ff_put_pixels16_sse2(dst , src[0] , stride, h); ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h); + } } void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) { + if (h&3) { + ff_avg_dirac_pixels32_c(dst, src, stride, h); + } else { ff_avg_pixels16_sse2(dst , src[0] , stride, h); ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h); + } } #endif #endif diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c index 01172afbf1..9e959c3850 100644 --- a/libavcodec/x86/h264_qpel.c +++ b/libavcodec/x86/h264_qpel.c @@ -544,7 +544,7 @@ void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth) SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmxext, ); SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmxext, ); } else if (bit_depth == 10) { -#if !ARCH_X86_64 +#if ARCH_X86_32 SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_mmxext, ff_); SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_mmxext, ff_); SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_mmxext, ff_); diff --git a/libavcodec/x86/hpeldsp.asm b/libavcodec/x86/hpeldsp.asm index 72bc111baa..7f0c285fa3 100644 --- a/libavcodec/x86/hpeldsp.asm +++ b/libavcodec/x86/hpeldsp.asm @@ -4,6 +4,7 @@ ;* Copyright (c) Nick Kurshev ;* Copyright (c) 2002 Michael Niedermayer ;* Copyright (c) 2002 Zdenek Kabelac +;* Copyright (c) 2013 Daniel Kang ;* ;* MMX optimized hpel functions ;* @@ -469,3 +470,46 @@ INIT_MMX mmxext AVG_PIXELS8_XY2 INIT_MMX 3dnow AVG_PIXELS8_XY2 + +INIT_XMM sse2 +; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) +cglobal put_pixels16, 4,5,4 + movsxdifnidn r2, r2d + lea r4, [r2*3] +.loop: + movu m0, [r1] + movu m1, [r1+r2] + movu m2, [r1+r2*2] + movu m3, [r1+r4] + lea r1, [r1+r2*4] + mova [r0], m0 + mova [r0+r2], m1 + mova [r0+r2*2], m2 + mova [r0+r4], m3 + sub r3d, 4 + lea r0, [r0+r2*4] + jnz .loop + REP_RET + +; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) +cglobal avg_pixels16, 4,5,4 + movsxdifnidn r2, r2d + lea r4, [r2*3] +.loop: + movu m0, [r1] + movu m1, [r1+r2] + movu m2, [r1+r2*2] + movu m3, [r1+r4] + lea r1, [r1+r2*4] + pavgb m0, [r0] + pavgb m1, [r0+r2] + pavgb m2, [r0+r2*2] + pavgb m3, [r0+r4] + mova [r0], m0 + mova [r0+r2], m1 + mova [r0+r2*2], m2 + mova [r0+r4], m3 + sub r3d, 4 + lea r0, [r0+r2*4] + jnz .loop + REP_RET diff --git a/libavcodec/x86/idct_sse2_xvid.c b/libavcodec/x86/idct_sse2_xvid.c index d121b25031..09b9e40364 100644 --- a/libavcodec/x86/idct_sse2_xvid.c +++ b/libavcodec/x86/idct_sse2_xvid.c @@ -376,7 +376,7 @@ inline void ff_idct_xvid_sse2(short *block) JZ("%%esi", "1f") "5: \n\t" iMTX_MULT("7*16(%0)", MANGLE(iTab2), ROUND(walkenIdctRounders+5*16), PUT_ODD(ROW7)) -#if !ARCH_X86_64 +#if ARCH_X86_32 iLLM_HEAD #endif iLLM_PASS("%0") diff --git a/libavcodec/x86/mpeg4qpel.asm b/libavcodec/x86/mpeg4qpel.asm index fe47bf302e..afbdf351c7 100644 --- a/libavcodec/x86/mpeg4qpel.asm +++ b/libavcodec/x86/mpeg4qpel.asm @@ -2,6 +2,7 @@ ;* mpeg4 qpel ;* Copyright (c) 2003 Michael Niedermayer ;* Copyright (c) 2008 Loren Merritt +;* Copyright (c) 2013 Daniel Kang ;* ;* This file is part of FFmpeg. ;* diff --git a/libavcodec/x86/vp3dsp_init.c b/libavcodec/x86/vp3dsp_init.c index 1df570ec0b..288dbcc6f3 100644 --- a/libavcodec/x86/vp3dsp_init.c +++ b/libavcodec/x86/vp3dsp_init.c @@ -64,7 +64,7 @@ void ff_vp3_h_loop_filter_mmxext(uint8_t *src, int stride, "paddb "#regb", "#regr" \n\t" \ "paddb "#regd", "#regp" \n\t" -static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h) +static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h) { // START_TIMER MOVQ_BFE(mm6); diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c index afe67510d7..4e63397380 100644 --- a/libavdevice/alsa-audio-common.c +++ b/libavdevice/alsa-audio-common.c @@ -62,48 +62,45 @@ static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id) } } -#define REORDER_OUT_50(NAME, TYPE) \ -static void alsa_reorder_ ## NAME ## _out_50(const void *in_v, void *out_v, int n) \ -{ \ - const TYPE *in = in_v; \ - TYPE *out = out_v; \ -\ - while (n-- > 0) { \ +#define MAKE_REORDER_FUNC(NAME, TYPE, CHANNELS, LAYOUT, MAP) \ +static void alsa_reorder_ ## NAME ## _ ## LAYOUT(const void *in_v, \ + void *out_v, \ + int n) \ +{ \ + const TYPE *in = in_v; \ + TYPE *out = out_v; \ + \ + while (n-- > 0) { \ + MAP \ + in += CHANNELS; \ + out += CHANNELS; \ + } \ +} + +#define MAKE_REORDER_FUNCS(CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(int8, int8_t, CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(int16, int16_t, CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(int32, int32_t, CHANNELS, LAYOUT, MAP) \ + MAKE_REORDER_FUNC(f32, float, CHANNELS, LAYOUT, MAP) + +MAKE_REORDER_FUNCS(5, out_50, \ out[0] = in[0]; \ out[1] = in[1]; \ out[2] = in[3]; \ out[3] = in[4]; \ out[4] = in[2]; \ - in += 5; \ - out += 5; \ - } \ -} + ); -#define REORDER_OUT_51(NAME, TYPE) \ -static void alsa_reorder_ ## NAME ## _out_51(const void *in_v, void *out_v, int n) \ -{ \ - const TYPE *in = in_v; \ - TYPE *out = out_v; \ -\ - while (n-- > 0) { \ +MAKE_REORDER_FUNCS(6, out_51, \ out[0] = in[0]; \ out[1] = in[1]; \ out[2] = in[4]; \ out[3] = in[5]; \ out[4] = in[2]; \ out[5] = in[3]; \ - in += 6; \ - out += 6; \ - } \ -} + ); -#define REORDER_OUT_71(NAME, TYPE) \ -static void alsa_reorder_ ## NAME ## _out_71(const void *in_v, void *out_v, int n) \ -{ \ - const TYPE *in = in_v; \ - TYPE *out = out_v; \ -\ - while (n-- > 0) { \ +MAKE_REORDER_FUNCS(8, out_71, \ out[0] = in[0]; \ out[1] = in[1]; \ out[2] = in[4]; \ @@ -112,23 +109,7 @@ static void alsa_reorder_ ## NAME ## _out_71(const void *in_v, void *out_v, int out[5] = in[3]; \ out[6] = in[6]; \ out[7] = in[7]; \ - in += 8; \ - out += 8; \ - } \ -} - -REORDER_OUT_50(int8, int8_t) -REORDER_OUT_51(int8, int8_t) -REORDER_OUT_71(int8, int8_t) -REORDER_OUT_50(int16, int16_t) -REORDER_OUT_51(int16, int16_t) -REORDER_OUT_71(int16, int16_t) -REORDER_OUT_50(int32, int32_t) -REORDER_OUT_51(int32, int32_t) -REORDER_OUT_71(int32, int32_t) -REORDER_OUT_50(f32, float) -REORDER_OUT_51(f32, float) -REORDER_OUT_71(f32, float) + ); #define FORMAT_I8 0 #define FORMAT_I16 1 diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 5f0102746d..2e4b395505 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -116,6 +116,7 @@ struct video_data { int channel; char *pixel_format; /**< Set by a private option. */ int list_format; /**< Set by a private option. */ + int list_standard; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ }; @@ -381,6 +382,30 @@ static void list_formats(AVFormatContext *ctx, int fd, int type) } } +static void list_standards(AVFormatContext *ctx) +{ + int ret; + struct video_data *s = ctx->priv_data; + struct v4l2_standard standard; + + if (s->std_id == 0) + return; + + for (standard.index = 0; ; standard.index++) { + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0) { + if (errno == EINVAL) + break; + else { + av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", strerror(errno)); + return; + } + } + av_log(ctx, AV_LOG_INFO, "%2d, %16llx, %s\n", + standard.index, standard.id, standard.name); + } +} + static int mmap_init(AVFormatContext *ctx) { int i, res; @@ -658,12 +683,10 @@ static int v4l2_set_parameters(AVFormatContext *s1) struct video_data *s = s1->priv_data; struct v4l2_standard standard = { 0 }; struct v4l2_streamparm streamparm = { 0 }; - struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; + struct v4l2_fract *tpf; AVRational framerate_q = { 0 }; int i, ret; - streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", @@ -672,57 +695,87 @@ static int v4l2_set_parameters(AVFormatContext *s1) } if (s->standard) { - av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n", - s->standard); - /* set tv standard */ - for(i=0;;i++) { - standard.index = i; - ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); - if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) - break; - } - if (ret < 0) { - av_log(s1, AV_LOG_ERROR, "Unknown standard '%s'\n", s->standard); - return ret; - } + if (s->std_id) { + av_log(s1, AV_LOG_DEBUG, "Setting standard: %s\n", s->standard); + /* set tv standard */ + for (i = 0; ; i++) { + standard.index = i; + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) + break; + } + if (ret < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "Unknown or unsupported standard '%s'\n", s->standard); + return AVERROR(ret); + } - av_log(s1, AV_LOG_DEBUG, - "The V4L2 driver set standard: %s, id: %"PRIu64"\n", - s->standard, (uint64_t)standard.id); - if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { - av_log(s1, AV_LOG_ERROR, - "The V4L2 driver ioctl set standard(%s) failed\n", - s->standard); - return AVERROR(EIO); + if (v4l2_ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_STD): %s\n", strerror(errno)); + return AVERROR(ret); + } + } else { + av_log(s1, AV_LOG_WARNING, + "This device does not support any standard\n"); } } - if (framerate_q.num && framerate_q.den) { - av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", - framerate_q.den, framerate_q.num); - tpf->numerator = framerate_q.den; - tpf->denominator = framerate_q.num; - - if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { - av_log(s1, AV_LOG_ERROR, - "ioctl set time per frame(%d/%d) failed\n", - framerate_q.den, framerate_q.num); - return AVERROR(EIO); - } - - if (framerate_q.num != tpf->denominator || - framerate_q.den != tpf->numerator) { - av_log(s1, AV_LOG_INFO, - "The driver changed the time per frame from " - "%d/%d to %d/%d\n", - framerate_q.den, framerate_q.num, - tpf->numerator, tpf->denominator); + /* get standard */ + if (v4l2_ioctl(s->fd, VIDIOC_G_STD, &s->std_id) == 0) { + tpf = &standard.frameperiod; + for (i = 0; ; i++) { + standard.index = i; + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", strerror(errno)); + return AVERROR(ret); + } + if (standard.id == s->std_id) { + av_log(s1, AV_LOG_DEBUG, + "Current standard: %s, id: %"PRIu64", frameperiod: %d/%d\n", + standard.name, (uint64_t)standard.id, tpf->numerator, tpf->denominator); + break; + } } } else { - if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { - av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", - strerror(errno)); - return AVERROR(errno); + tpf = &streamparm.parm.capture.timeperframe; + } + + streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (v4l2_ioctl(s->fd, VIDIOC_G_PARM, &streamparm) < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); + return AVERROR(ret); + } + + if (framerate_q.num && framerate_q.den) { + if (streamparm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) { + tpf = &streamparm.parm.capture.timeperframe; + + av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", + framerate_q.den, framerate_q.num); + tpf->numerator = framerate_q.den; + tpf->denominator = framerate_q.num; + + if (v4l2_ioctl(s->fd, VIDIOC_S_PARM, &streamparm) < 0) { + ret = errno; + av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_PARM): %s\n", strerror(errno)); + return AVERROR(ret); + } + + if (framerate_q.num != tpf->denominator || + framerate_q.den != tpf->numerator) { + av_log(s1, AV_LOG_INFO, + "The driver changed the time per frame from " + "%d/%d to %d/%d\n", + framerate_q.den, framerate_q.num, + tpf->numerator, tpf->denominator); + } + } else { + av_log(s1, AV_LOG_WARNING, + "The driver does not allow to change time per frame\n"); } } s1->streams[0]->avg_frame_rate.num = tpf->denominator; @@ -824,6 +877,11 @@ static int v4l2_read_header(AVFormatContext *s1) return AVERROR_EXIT; } + if (s->list_standard) { + list_standards(s1); + return AVERROR_EXIT; + } + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->pixel_format) { @@ -952,6 +1010,9 @@ static const AVOption options[] = { { "raw", "show only non-compressed formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.i64 = V4L_RAWFORMATS }, 0, INT_MAX, DEC, "list_formats" }, { "compressed", "show only compressed formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.i64 = V4L_COMPFORMATS }, 0, INT_MAX, DEC, "list_formats" }, + { "list_standards", "list supported standards and exit", OFFSET(list_standard), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, DEC, "list_standards" }, + { "all", "show all supported standards", OFFSET(list_standard), AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, DEC, "list_standards" }, + { "timestamps", "set type of timestamps for grabbed frames", OFFSET(ts_mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "timestamps" }, { "ts", "set type of timestamps for grabbed frames", OFFSET(ts_mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "timestamps" }, { "default", "use timestamps from the kernel", OFFSET(ts_mode), AV_OPT_TYPE_CONST, {.i64 = V4L_TS_DEFAULT }, 0, 2, DEC, "timestamps" }, diff --git a/libavdevice/version.h b/libavdevice/version.h index 5eed4f5e1a..9e0c0ae940 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -29,7 +29,7 @@ #define LIBAVDEVICE_VERSION_MAJOR 54 #define LIBAVDEVICE_VERSION_MINOR 3 -#define LIBAVDEVICE_VERSION_MICRO 102 +#define LIBAVDEVICE_VERSION_MICRO 103 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 5835a7ed5e..938b183316 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -53,6 +53,7 @@ OBJS-$(CONFIG_SWSCALE) += lswsutils.o OBJS-$(CONFIG_ACONVERT_FILTER) += af_aconvert.o OBJS-$(CONFIG_AFADE_FILTER) += af_afade.o OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o +OBJS-$(CONFIG_ALLPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o @@ -68,14 +69,22 @@ OBJS-$(CONFIG_ASPLIT_FILTER) += split.o OBJS-$(CONFIG_ASTREAMSYNC_FILTER) += af_astreamsync.o OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o +OBJS-$(CONFIG_BANDPASS_FILTER) += af_biquads.o +OBJS-$(CONFIG_BANDREJECT_FILTER) += af_biquads.o +OBJS-$(CONFIG_BASS_FILTER) += af_biquads.o +OBJS-$(CONFIG_BIQUAD_FILTER) += af_biquads.o OBJS-$(CONFIG_CHANNELMAP_FILTER) += af_channelmap.o OBJS-$(CONFIG_CHANNELSPLIT_FILTER) += af_channelsplit.o OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o OBJS-$(CONFIG_EBUR128_FILTER) += f_ebur128.o +OBJS-$(CONFIG_EQUALIZER_FILTER) += af_biquads.o +OBJS-$(CONFIG_HIGHPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_JOIN_FILTER) += af_join.o +OBJS-$(CONFIG_LOWPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_PAN_FILTER) += af_pan.o OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o OBJS-$(CONFIG_SILENCEDETECT_FILTER) += af_silencedetect.o +OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += af_volumedetect.o diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index 44b71e4acb..f67a7a8c1b 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -231,6 +231,11 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) if (inlink == ctx->inputs[input_number]) break; av_assert1(input_number < am->nb_inputs); + if (ff_bufqueue_is_full(&am->in[input_number].queue)) { + av_log(ctx, AV_LOG_ERROR, "Buffer queue overflow\n"); + avfilter_unref_buffer(insamples); + return AVERROR(ENOMEM); + } ff_bufqueue_add(ctx, &am->in[input_number].queue, insamples); am->in[input_number].nb_samples += insamples->audio->nb_samples; nb_samples = am->in[0].nb_samples; @@ -255,6 +260,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) outbuf->audio->nb_samples = nb_samples; outbuf->audio->channel_layout = outlink->channel_layout; + outbuf->audio->channels = outlink->channels; while (nb_samples) { ns = nb_samples; diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c new file mode 100644 index 0000000000..123d7a2eee --- /dev/null +++ b/libavfilter/af_biquads.c @@ -0,0 +1,599 @@ +/* + * Copyright (c) 2013 Paul B Mahol + * Copyright (c) 2006-2008 Rob Sykes + * + * 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 + */ + +/* + * 2-pole filters designed by Robert Bristow-Johnson + * see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt + * + * 1-pole filters based on code (c) 2000 Chris Bagwell + * Algorithms: Recursive single pole low/high pass filter + * Reference: The Scientist and Engineer's Guide to Digital Signal Processing + * + * low-pass: output[N] = input[N] * A + output[N-1] * B + * X = exp(-2.0 * pi * Fc) + * A = 1 - X + * B = X + * Fc = cutoff freq / sample rate + * + * Mimics an RC low-pass filter: + * + * ---/\/\/\/\-----------> + * | + * --- C + * --- + * | + * | + * V + * + * high-pass: output[N] = A0 * input[N] + A1 * input[N-1] + B1 * output[N-1] + * X = exp(-2.0 * pi * Fc) + * A0 = (1 + X) / 2 + * A1 = -(1 + X) / 2 + * B1 = X + * Fc = cutoff freq / sample rate + * + * Mimics an RC high-pass filter: + * + * || C + * ----||---------> + * || | + * < + * > R + * < + * | + * V + */ + +#include "libavutil/opt.h" +#include "libavutil/avassert.h" +#include "audio.h" +#include "avfilter.h" +#include "internal.h" + +enum FilterType { + biquad, + equalizer, + bass, + treble, + band, + bandpass, + bandreject, + allpass, + highpass, + lowpass, +}; + +enum WidthType { + NONE, + HZ, + OCTAVE, + QFACTOR, + SLOPE, +}; + +typedef struct ChanCache { + double i1, i2; + double o1, o2; +} ChanCache; + +typedef struct { + const AVClass *class; + + enum FilterType filter_type; + enum WidthType width_type; + int poles; + int csg; + + double gain; + double frequency; + double width; + + double a0, a1, a2; + double b0, b1, b2; + + ChanCache *cache; + + void (*filter)(const void *ibuf, void *obuf, int len, + double *i1, double *i2, double *o1, double *o2, + double b0, double b1, double b2, double a1, double a2); +} BiquadsContext; + +static av_cold int init(AVFilterContext *ctx, const char *args) +{ + BiquadsContext *p = ctx->priv; + int ret; + + av_opt_set_defaults(p); + + if ((ret = av_set_options_string(p, args, "=", ":")) < 0) + return ret; + + if (p->filter_type != biquad) { + if (p->frequency <= 0 || p->width <= 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n", + p->frequency, p->width); + return AVERROR(EINVAL); + } + } + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats; + AVFilterChannelLayouts *layouts; + static const enum AVSampleFormat sample_fmts[] = { + AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_S32P, + AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_DBLP, + AV_SAMPLE_FMT_NONE + }; + + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + ff_set_common_channel_layouts(ctx, layouts); + + formats = ff_make_format_list(sample_fmts); + if (!formats) + return AVERROR(ENOMEM); + ff_set_common_formats(ctx, formats); + + formats = ff_all_samplerates(); + if (!formats) + return AVERROR(ENOMEM); + ff_set_common_samplerates(ctx, formats); + + return 0; +} + +#define BIQUAD_FILTER(name, type, min, max) \ +static void biquad_## name (const void *input, void *output, int len, \ + double *in1, double *in2, \ + double *out1, double *out2, \ + double b0, double b1, double b2, \ + double a1, double a2) \ +{ \ + const type *ibuf = input; \ + type *obuf = output; \ + double i1 = *in1; \ + double i2 = *in2; \ + double o1 = *out1; \ + double o2 = *out2; \ + int i; \ + \ + for (i = 0; i < len; i++) { \ + double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 - o1 * a1 - o2 * a2; \ + i2 = i1; \ + i1 = ibuf[i]; \ + o2 = o1; \ + o1 = o0; \ + if (o0 < min) { \ + av_log(NULL, AV_LOG_WARNING, "clipping\n"); \ + obuf[i] = min; \ + } else if (o0 > max) { \ + av_log(NULL, AV_LOG_WARNING, "clipping\n"); \ + obuf[i] = max; \ + } else { \ + obuf[i] = o0; \ + } \ + } \ + *in1 = i1; \ + *in2 = i2; \ + *out1 = o1; \ + *out2 = o2; \ +} + +BIQUAD_FILTER(s16, int16_t, INT16_MIN, INT16_MAX) +BIQUAD_FILTER(s32, int32_t, INT32_MIN, INT32_MAX) +BIQUAD_FILTER(flt, float, -1., 1.) +BIQUAD_FILTER(dbl, double, -1., 1.) + +static int config_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + BiquadsContext *p = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + double A = exp(p->gain / 40 * log(10.)); + double w0 = 2 * M_PI * p->frequency / inlink->sample_rate; + double alpha; + + if (w0 > M_PI) { + av_log(ctx, AV_LOG_ERROR, + "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n", + p->frequency, inlink->sample_rate); + return AVERROR(EINVAL); + } + + switch (p->width_type) { + case NONE: + alpha = 0.0; + break; + case HZ: + alpha = sin(w0) / (2 * p->frequency / p->width); + break; + case OCTAVE: + alpha = sin(w0) * sinh(log(2.) / 2 * p->width * w0 / sin(w0)); + break; + case QFACTOR: + alpha = sin(w0) / (2 * p->width); + break; + case SLOPE: + alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / p->width - 1) + 2); + break; + default: + av_assert0(0); + } + + switch (p->filter_type) { + case biquad: + break; + case equalizer: + p->a0 = 1 + alpha / A; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha / A; + p->b0 = 1 + alpha * A; + p->b1 = -2 * cos(w0); + p->b2 = 1 - alpha * A; + break; + case bass: + p->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha; + p->a1 = -2 * ((A - 1) + (A + 1) * cos(w0)); + p->a2 = (A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha; + p->b0 = A * ((A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha); + p->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0)); + p->b2 = A * ((A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha); + break; + case treble: + p->a0 = (A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha; + p->a1 = 2 * ((A - 1) - (A + 1) * cos(w0)); + p->a2 = (A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha; + p->b0 = A * ((A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha); + p->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0)); + p->b2 = A * ((A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha); + break; + case bandpass: + if (p->csg) { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = sin(w0) / 2; + p->b1 = 0; + p->b2 = -sin(w0) / 2; + } else { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = alpha; + p->b1 = 0; + p->b2 = -alpha; + } + break; + case bandreject: + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = 1; + p->b1 = -2 * cos(w0); + p->b2 = 1; + break; + case lowpass: + if (p->poles == 1) { + p->a0 = 1; + p->a1 = -exp(-w0); + p->a2 = 0; + p->b0 = 1 + p->a1; + p->b1 = 0; + p->b2 = 0; + } else { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = (1 - cos(w0)) / 2; + p->b1 = 1 - cos(w0); + p->b2 = (1 - cos(w0)) / 2; + } + break; + case highpass: + if (p->poles == 1) { + p->a0 = 1; + p->a1 = -exp(-w0); + p->a2 = 0; + p->b0 = (1 - p->a1) / 2; + p->b1 = -p->b0; + p->b2 = 0; + } else { + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = (1 + cos(w0)) / 2; + p->b1 = -(1 + cos(w0)); + p->b2 = (1 + cos(w0)) / 2; + } + break; + case allpass: + p->a0 = 1 + alpha; + p->a1 = -2 * cos(w0); + p->a2 = 1 - alpha; + p->b0 = 1 - alpha; + p->b1 = -2 * cos(w0); + p->b2 = 1 + alpha; + break; + default: + av_assert0(0); + } + + p->a1 /= p->a0; + p->a2 /= p->a0; + p->b0 /= p->a0; + p->b1 /= p->a0; + p->b2 /= p->a0; + + p->cache = av_realloc_f(p->cache, sizeof(ChanCache), inlink->channels); + if (!p->cache) + return AVERROR(ENOMEM); + + switch (inlink->format) { + case AV_SAMPLE_FMT_S16P: p->filter = biquad_s16; break; + case AV_SAMPLE_FMT_S32P: p->filter = biquad_s32; break; + case AV_SAMPLE_FMT_FLTP: p->filter = biquad_flt; break; + case AV_SAMPLE_FMT_DBLP: p->filter = biquad_dbl; break; + default: av_assert0(0); + } + + return 0; +} + +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) +{ + BiquadsContext *p = inlink->dst->priv; + AVFilterLink *outlink = inlink->dst->outputs[0]; + AVFilterBufferRef *out_buf; + int nb_samples = buf->audio->nb_samples; + int ch; + + if (buf->perms & AV_PERM_WRITE) { + out_buf = buf; + } else { + out_buf = ff_get_audio_buffer(inlink, AV_PERM_WRITE, nb_samples); + if (!out_buf) + return AVERROR(ENOMEM); + out_buf->pts = buf->pts; + } + + for (ch = 0; ch < buf->audio->channels; ch++) + p->filter(buf->extended_data[ch], + out_buf->extended_data[ch], nb_samples, + &p->cache[ch].i1, &p->cache[ch].i2, + &p->cache[ch].o1, &p->cache[ch].o2, + p->b0, p->b1, p->b2, p->a1, p->a2); + + if (buf != out_buf) + avfilter_unref_buffer(buf); + + return ff_filter_frame(outlink, out_buf); +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + BiquadsContext *p = ctx->priv; + + av_freep(&p->cache); + av_opt_free(p); +} + +static const AVFilterPad inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + }, + { NULL } +}; + +static const AVFilterPad outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_output, + }, + { NULL } +}; + +#define OFFSET(x) offsetof(BiquadsContext, x) +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +#define DEFINE_BIQUAD_FILTER(name_, description_) \ +AVFILTER_DEFINE_CLASS(name_); \ +static av_cold int name_##_init(AVFilterContext *ctx, const char *args) \ +{ \ + BiquadsContext *p = ctx->priv; \ + p->class = &name_##_class; \ + p->filter_type = name_; \ + return init(ctx, args); \ +} \ + \ +AVFilter avfilter_af_##name_ = { \ + .name = #name_, \ + .description = NULL_IF_CONFIG_SMALL(description_), \ + .priv_size = sizeof(BiquadsContext), \ + .init = name_##_init, \ + .uninit = uninit, \ + .query_formats = query_formats, \ + .inputs = inputs, \ + .outputs = outputs, \ + .priv_class = &name_##_class, \ +} + +#if CONFIG_EQUALIZER_FILTER +static const AVOption equalizer_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS}, + {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS}, + {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter."); +#endif /* CONFIG_EQUALIZER_FILTER */ +#if CONFIG_BASS_FILTER +static const AVOption bass_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies."); +#endif /* CONFIG_BASS_FILTER */ +#if CONFIG_TREBLE_FILTER +static const AVOption treble_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS}, + {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies."); +#endif /* CONFIG_TREBLE_FILTER */ +#if CONFIG_BANDPASS_FILTER +static const AVOption bandpass_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {"csg", "use constant skirt gain", OFFSET(csg), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(bandpass, "Apply a two-pole Butterworth band-pass filter."); +#endif /* CONFIG_BANDPASS_FILTER */ +#if CONFIG_BANDREJECT_FILTER +static const AVOption bandreject_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(bandreject, "Apply a two-pole Butterworth band-reject filter."); +#endif /* CONFIG_BANDREJECT_FILTER */ +#if CONFIG_LOWPASS_FILTER +static const AVOption lowpass_options[] = { + {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS}, + {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(lowpass, "Apply a low-pass filter with 3dB point frequency."); +#endif /* CONFIG_LOWPASS_FILTER */ +#if CONFIG_HIGHPASS_FILTER +static const AVOption highpass_options[] = { + {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS}, + {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(highpass, "Apply a high-pass filter with 3dB point frequency."); +#endif /* CONFIG_HIGHPASS_FILTER */ +#if CONFIG_ALLPASS_FILTER +static const AVOption allpass_options[] = { + {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS}, + {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HZ}, HZ, SLOPE, FLAGS, "width_type"}, + {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"}, + {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, + {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, + {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, + {"width", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS}, + {"w", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter."); +#endif /* CONFIG_ALLPASS_FILTER */ +#if CONFIG_BIQUAD_FILTER +static const AVOption biquad_options[] = { + {"a0", NULL, OFFSET(a0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"a1", NULL, OFFSET(a1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"a2", NULL, OFFSET(a2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"b0", NULL, OFFSET(b0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"b1", NULL, OFFSET(b1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {"b2", NULL, OFFSET(b2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS}, + {NULL}, +}; + +DEFINE_BIQUAD_FILTER(biquad, "Apply a biquad IIR filter with the given coefficients."); +#endif /* CONFIG_BIQUAD_FILTER */ diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 24df56193a..47158f9737 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -47,6 +47,7 @@ void avfilter_register_all(void) REGISTER_FILTER(ACONVERT, aconvert, af); REGISTER_FILTER(AFADE, afade, af); REGISTER_FILTER(AFORMAT, aformat, af); + REGISTER_FILTER(ALLPASS, allpass, af); REGISTER_FILTER(AMERGE, amerge, af); REGISTER_FILTER(AMIX, amix, af); REGISTER_FILTER(ANULL, anull, af); @@ -62,14 +63,22 @@ void avfilter_register_all(void) REGISTER_FILTER(ASTREAMSYNC, astreamsync, af); REGISTER_FILTER(ASYNCTS, asyncts, af); REGISTER_FILTER(ATEMPO, atempo, af); + REGISTER_FILTER(BANDPASS, bandpass, af); + REGISTER_FILTER(BANDREJECT, bandreject, af); + REGISTER_FILTER(BASS, bass, af); + REGISTER_FILTER(BIQUAD, biquad, af); REGISTER_FILTER(CHANNELMAP, channelmap, af); REGISTER_FILTER(CHANNELSPLIT, channelsplit, af); REGISTER_FILTER(EARWAX, earwax, af); REGISTER_FILTER(EBUR128, ebur128, af); + REGISTER_FILTER(EQUALIZER, equalizer, af); + REGISTER_FILTER(HIGHPASS, highpass, af); REGISTER_FILTER(JOIN, join, af); + REGISTER_FILTER(LOWPASS, lowpass, af); REGISTER_FILTER(PAN, pan, af); REGISTER_FILTER(RESAMPLE, resample, af); REGISTER_FILTER(SILENCEDETECT, silencedetect, af); + REGISTER_FILTER(TREBLE, treble, af); REGISTER_FILTER(VOLUME, volume, af); REGISTER_FILTER(VOLUMEDETECT, volumedetect, af); diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c index 2343d19e9c..dd3c886df0 100644 --- a/libavfilter/avcodec.c +++ b/libavfilter/avcodec.c @@ -102,7 +102,7 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame } samplesref = avfilter_get_audio_buffer_ref_from_arrays_channels( - (uint8_t **)frame->data, frame->linesize[0], perms, + (uint8_t **)frame->extended_data, frame->linesize[0], perms, frame->nb_samples, frame->format, channels, layout); if (!samplesref) return NULL; diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 977fca92a6..4eb973169a 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -27,38 +27,77 @@ #include #include "libavcodec/avfft.h" +#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avfilter.h" #include "internal.h" +enum DisplayMode { COMBINED, SEPARATE, NB_MODES }; +enum DisplayScale { LINEAR, SQRT, CBRT, LOG, NB_SCALES }; +enum ColorMode { CHANNEL, INTENSITY, NB_CLMODES }; + typedef struct { const AVClass *class; int w, h; AVFilterBufferRef *outpicref; int req_fullfilled; + int nb_display_channels; + int channel_height; int sliding; ///< 1 if sliding mode, 0 otherwise + enum DisplayMode mode; ///< channel display mode + enum ColorMode color_mode; ///< display color scheme + enum DisplayScale scale; + float saturation; ///< color saturation multiplier int xpos; ///< x position (current column) RDFTContext *rdft; ///< Real Discrete Fourier Transform context int rdft_bits; ///< number of bits (RDFT window size = 1<priv; @@ -76,8 +115,12 @@ static av_cold int init(AVFilterContext *ctx, const char *args) static av_cold void uninit(AVFilterContext *ctx) { ShowSpectrumContext *showspectrum = ctx->priv; + int i; + av_freep(&showspectrum->combine_buffer); av_rdft_end(showspectrum->rdft); + for (i = 0; i < showspectrum->nb_display_channels; i++) + av_freep(&showspectrum->rdft_data[i]); av_freep(&showspectrum->rdft_data); av_freep(&showspectrum->window_func_lut); avfilter_unref_bufferp(&showspectrum->outpicref); @@ -90,7 +133,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }; - static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE }; + static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_NONE }; /* set input audio formats */ formats = ff_make_format_list(sample_fmts); @@ -120,19 +163,23 @@ static int query_formats(AVFilterContext *ctx) static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = ctx->inputs[0]; ShowSpectrumContext *showspectrum = ctx->priv; - int i, rdft_bits, win_size; + int i, rdft_bits, win_size, h; outlink->w = showspectrum->w; outlink->h = showspectrum->h; + h = (showspectrum->mode == COMBINED) ? outlink->h : outlink->h / inlink->channels; + showspectrum->channel_height = h; + /* RDFT window size (precision) according to the requested output frame height */ - for (rdft_bits = 1; 1<h; rdft_bits++); + for (rdft_bits = 1; 1 << rdft_bits < 2 * h; rdft_bits++); win_size = 1 << rdft_bits; /* (re-)configuration if the video output changed (or first init) */ if (rdft_bits != showspectrum->rdft_bits) { - size_t rdft_size; + size_t rdft_size, rdft_listsize; AVFilterBufferRef *outpicref; av_rdft_end(showspectrum->rdft); @@ -142,12 +189,25 @@ static int config_output(AVFilterLink *outlink) /* RDFT buffers: x2 for each (display) channel buffer. * Note: we use free and malloc instead of a realloc-like function to * make sure the buffer is aligned in memory for the FFT functions. */ + for (i = 0; i < showspectrum->nb_display_channels; i++) + av_freep(&showspectrum->rdft_data[i]); av_freep(&showspectrum->rdft_data); - if (av_size_mult(sizeof(*showspectrum->rdft_data), 2 * win_size, &rdft_size) < 0) + showspectrum->nb_display_channels = inlink->channels; + + if (av_size_mult(sizeof(*showspectrum->rdft_data), + showspectrum->nb_display_channels, &rdft_listsize) < 0) return AVERROR(EINVAL); - showspectrum->rdft_data = av_malloc(rdft_size); + if (av_size_mult(sizeof(**showspectrum->rdft_data), + win_size, &rdft_size) < 0) + return AVERROR(EINVAL); + showspectrum->rdft_data = av_malloc(rdft_listsize); if (!showspectrum->rdft_data) return AVERROR(ENOMEM); + for (i = 0; i < showspectrum->nb_display_channels; i++) { + showspectrum->rdft_data[i] = av_malloc(rdft_size); + if (!showspectrum->rdft_data[i]) + return AVERROR(ENOMEM); + } showspectrum->filled = 0; /* pre-calc windowing function (hann here) */ @@ -173,6 +233,10 @@ static int config_output(AVFilterLink *outlink) if (showspectrum->xpos >= outlink->w) showspectrum->xpos = 0; + showspectrum->combine_buffer = + av_realloc_f(showspectrum->combine_buffer, outlink->h * 3, + sizeof(*showspectrum->combine_buffer)); + av_log(ctx, AV_LOG_VERBOSE, "s:%dx%d RDFT window size:%d\n", showspectrum->w, showspectrum->h, win_size); return 0; @@ -213,62 +277,180 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFilterBufferRef *insampl AVFilterLink *outlink = ctx->outputs[0]; ShowSpectrumContext *showspectrum = ctx->priv; AVFilterBufferRef *outpicref = showspectrum->outpicref; - const int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout); /* nb_freq contains the power of two superior or equal to the output image * height (or half the RDFT window size) */ const int nb_freq = 1 << (showspectrum->rdft_bits - 1); const int win_size = nb_freq << 1; + const double w = 1. / (sqrt(nb_freq) * 32768.); - int ch, n, y; - FFTSample *data[2]; - const int nb_display_channels = FFMIN(nb_channels, 2); + int ch, plane, n, y; const int start = showspectrum->filled; const int add_samples = FFMIN(win_size - start, nb_samples); /* fill RDFT input with the number of samples available */ - for (ch = 0; ch < nb_display_channels; ch++) { + for (ch = 0; ch < showspectrum->nb_display_channels; ch++) { const int16_t *p = (int16_t *)insamples->extended_data[ch]; p += showspectrum->consumed; - data[ch] = showspectrum->rdft_data + win_size * ch; // select channel buffer for (n = 0; n < add_samples; n++) - data[ch][start + n] = p[n] * showspectrum->window_func_lut[start + n]; + showspectrum->rdft_data[ch][start + n] = p[n] * showspectrum->window_func_lut[start + n]; } showspectrum->filled += add_samples; /* complete RDFT window size? */ if (showspectrum->filled == win_size) { + /* channel height */ + int h = showspectrum->channel_height; + /* run RDFT on each samples set */ - for (ch = 0; ch < nb_display_channels; ch++) - av_rdft_calc(showspectrum->rdft, data[ch]); + for (ch = 0; ch < showspectrum->nb_display_channels; ch++) + av_rdft_calc(showspectrum->rdft, showspectrum->rdft_data[ch]); /* fill a new spectrum column */ -#define RE(ch) data[ch][2*y + 0] -#define IM(ch) data[ch][2*y + 1] -#define MAGNITUDE(re, im) sqrt((re)*(re) + (im)*(im)) +#define RE(y, ch) showspectrum->rdft_data[ch][2 * y + 0] +#define IM(y, ch) showspectrum->rdft_data[ch][2 * y + 1] +#define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch)) + /* initialize buffer for combining to black */ for (y = 0; y < outlink->h; y++) { - // FIXME: bin[0] contains first and last bins - uint8_t *p = outpicref->data[0] + (outlink->h - y - 1) * outpicref->linesize[0]; - const double w = 1. / sqrt(nb_freq); - int a = sqrt(w * MAGNITUDE(RE(0), IM(0))); - int b = nb_display_channels > 1 ? sqrt(w * MAGNITUDE(RE(1), IM(1))) : a; + showspectrum->combine_buffer[3 * y ] = 0; + showspectrum->combine_buffer[3 * y + 1] = 127.5; + showspectrum->combine_buffer[3 * y + 2] = 127.5; + } - if (showspectrum->sliding) { - memmove(p, p + 3, (outlink->w - 1) * 3); - p += (outlink->w - 1) * 3; - } else { - p += showspectrum->xpos * 3; + for (ch = 0; ch < showspectrum->nb_display_channels; ch++) { + float yf, uf, vf; + + /* decide color range */ + switch (showspectrum->mode) { + case COMBINED: + // reduce range by channel count + yf = 256.0f / showspectrum->nb_display_channels; + switch (showspectrum->color_mode) { + case INTENSITY: + uf = yf; + vf = yf; + break; + case CHANNEL: + /* adjust saturation for mixed UV coloring */ + /* this factor is correct for infinite channels, an approximation otherwise */ + uf = yf * M_PI; + vf = yf * M_PI; + break; + default: + av_assert0(0); + } + break; + case SEPARATE: + // full range + yf = 256.0f; + uf = 256.0f; + vf = 256.0f; + break; + default: + av_assert0(0); } - a = FFMIN(a, 255); - b = FFMIN(b, 255); - p[0] = a; - p[1] = b; - p[2] = (a + b) / 2; + if (showspectrum->color_mode == CHANNEL) { + if (showspectrum->nb_display_channels > 1) { + uf *= 0.5 * sin((2 * M_PI * ch) / showspectrum->nb_display_channels); + vf *= 0.5 * cos((2 * M_PI * ch) / showspectrum->nb_display_channels); + } else { + uf = 0.0f; + vf = 0.0f; + } + } + uf *= showspectrum->saturation; + vf *= showspectrum->saturation; + + /* draw the channel */ + for (y = 0; y < h; y++) { + int row = (showspectrum->mode == COMBINED) ? y : ch * h + y; + float *out = &showspectrum->combine_buffer[3 * row]; + + /* get magnitude */ + float a = w * MAGNITUDE(y, ch); + + /* apply scale */ + switch (showspectrum->scale) { + case LINEAR: + break; + case SQRT: + a = sqrt(a); + break; + case CBRT: + a = cbrt(a); + break; + case LOG: + a = 1 - log(FFMAX(FFMIN(1, a), 1e-6)) / log(1e-6); // zero = -120dBFS + break; + default: + av_assert0(0); + } + + if (showspectrum->color_mode == INTENSITY) { + float y, u, v; + int i; + + for (i = 1; i < sizeof(intensity_color_table) / sizeof(*intensity_color_table) - 1; i++) + if (intensity_color_table[i].a >= a) + break; + // i now is the first item >= the color + // now we know to interpolate between item i - 1 and i + if (a <= intensity_color_table[i - 1].a) { + y = intensity_color_table[i - 1].y; + u = intensity_color_table[i - 1].u; + v = intensity_color_table[i - 1].v; + } else if (a >= intensity_color_table[i].a) { + y = intensity_color_table[i].y; + u = intensity_color_table[i].u; + v = intensity_color_table[i].v; + } else { + float start = intensity_color_table[i - 1].a; + float end = intensity_color_table[i].a; + float lerpfrac = (a - start) / (end - start); + y = intensity_color_table[i - 1].y * (1.0f - lerpfrac) + + intensity_color_table[i].y * lerpfrac; + u = intensity_color_table[i - 1].u * (1.0f - lerpfrac) + + intensity_color_table[i].u * lerpfrac; + v = intensity_color_table[i - 1].v * (1.0f - lerpfrac) + + intensity_color_table[i].v * lerpfrac; + } + + out[0] += y * yf; + out[1] += u * uf; + out[2] += v * vf; + } else { + out[0] += a * yf; + out[1] += a * uf; + out[2] += a * vf; + } + } } + + /* copy to output */ + if (showspectrum->sliding) { + for (plane = 0; plane < 3; plane++) { + for (y = 0; y < outlink->h; y++) { + uint8_t *p = outpicref->data[plane] + + y * outpicref->linesize[plane]; + memmove(p, p + 1, outlink->w - 1); + } + } + showspectrum->xpos = outlink->w - 1; + } + for (plane = 0; plane < 3; plane++) { + uint8_t *p = outpicref->data[plane] + + (outlink->h - 1) * outpicref->linesize[plane] + + showspectrum->xpos; + for (y = 0; y < outlink->h; y++) { + *p = rint(FFMAX(0, FFMIN(showspectrum->combine_buffer[3 * y + plane], 255))); + p -= outpicref->linesize[plane]; + } + } + outpicref->pts = insamples->pts + av_rescale_q(showspectrum->consumed, (AVRational){ 1, inlink->sample_rate }, diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 4759d13c5f..7c0bee68f4 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -391,7 +391,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha return AVERROR(ENOSYS); } -#define MAX_REGISTERED_AVFILTERS_NB 128 +#define MAX_REGISTERED_AVFILTERS_NB 256 static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; diff --git a/libavfilter/bufferqueue.h b/libavfilter/bufferqueue.h index a27fb86112..34c4c0f08b 100644 --- a/libavfilter/bufferqueue.h +++ b/libavfilter/bufferqueue.h @@ -54,6 +54,14 @@ struct FFBufQueue { #define BUCKET(i) queue->queue[(queue->head + (i)) % FF_BUFQUEUE_SIZE] +/** + * Test if a buffer queue is full. + */ +static inline int ff_bufqueue_is_full(struct FFBufQueue *queue) +{ + return queue->available == FF_BUFQUEUE_SIZE; +} + /** * Add a buffer to the queue. * @@ -63,7 +71,7 @@ struct FFBufQueue { static inline void ff_bufqueue_add(void *log, struct FFBufQueue *queue, AVFilterBufferRef *buf) { - if (queue->available == FF_BUFQUEUE_SIZE) { + if (ff_bufqueue_is_full(queue)) { av_log(log, AV_LOG_WARNING, "Buffer queue overflow, dropping.\n"); avfilter_unref_buffer(BUCKET(--queue->available)); } diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index 074d43a674..3fdf8d3fe3 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -384,7 +384,6 @@ static int request_frame(AVFilterLink *link) { BufferSourceContext *c = link->src->priv; AVFilterBufferRef *buf; - int ret = 0; if (!av_fifo_size(c->fifo)) { if (c->eof) @@ -394,9 +393,7 @@ static int request_frame(AVFilterLink *link) } av_fifo_generic_read(c->fifo, &buf, sizeof(buf), NULL); - ff_filter_frame(link, buf); - - return ret; + return ff_filter_frame(link, buf); } static int poll_frame(AVFilterLink *link) diff --git a/libavfilter/libmpcodecs/vd_ffmpeg.h b/libavfilter/libmpcodecs/av_helpers.h similarity index 83% rename from libavfilter/libmpcodecs/vd_ffmpeg.h rename to libavfilter/libmpcodecs/av_helpers.h index 081d6ee545..90b67d5a0f 100644 --- a/libavfilter/libmpcodecs/vd_ffmpeg.h +++ b/libavfilter/libmpcodecs/av_helpers.h @@ -1,4 +1,6 @@ /* + * Generic libav* helpers + * * This file is part of MPlayer. * * MPlayer is free software; you can redistribute it and/or modify @@ -16,9 +18,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPLAYER_VD_FFMPEG_H -#define MPLAYER_VD_FFMPEG_H +#ifndef MPLAYER_AV_HELPERS_H +#define MPLAYER_AV_HELPERS_H void ff_init_avcodec(void); +void ff_init_avformat(void); -#endif /* MPLAYER_VD_FFMPEG_H */ +#endif /* MPLAYER_AV_HELPERS_H */ diff --git a/libavfilter/libmpcodecs/cpudetect.h b/libavfilter/libmpcodecs/cpudetect.h index c0bb7b763b..710f6e6513 100644 --- a/libavfilter/libmpcodecs/cpudetect.h +++ b/libavfilter/libmpcodecs/cpudetect.h @@ -19,8 +19,6 @@ #ifndef MPLAYER_CPUDETECT_H #define MPLAYER_CPUDETECT_H -//#include "config.h" - #define CPUTYPE_I386 3 #define CPUTYPE_I486 4 #define CPUTYPE_I586 5 @@ -40,7 +38,10 @@ typedef struct cpucaps_s { int hasSSE2; int hasSSE3; int hasSSSE3; + int hasSSE4; + int hasSSE42; int hasSSE4a; + int hasAVX; int isX86; unsigned cl_size; /* size of cache line */ int hasAltiVec; diff --git a/libavfilter/libmpcodecs/help_mp.h b/libavfilter/libmpcodecs/help_mp.h index 87b828d933..6ceb6301f3 100644 --- a/libavfilter/libmpcodecs/help_mp.h +++ b/libavfilter/libmpcodecs/help_mp.h @@ -70,12 +70,14 @@ static const char help_text[]= #define MSGTR_NoHomeDir "Cannot find HOME directory.\n" #define MSGTR_GetpathProblem "get_path(\"config\") problem\n" #define MSGTR_CreatingCfgFile "Creating config file: %s\n" -#define MSGTR_BuiltinCodecsConf "Using built-in default codecs.conf.\n" -#define MSGTR_CantLoadFont "Cannot load bitmap font: %s\n" -#define MSGTR_CantLoadSub "Cannot load subtitles: %s\n" +#define MSGTR_CantLoadFont "Cannot load bitmap font '%s'.\n" +#define MSGTR_CantLoadSub "Cannot load subtitles '%s'.\n" #define MSGTR_DumpSelectedStreamMissing "dump: FATAL: Selected stream missing!\n" #define MSGTR_CantOpenDumpfile "Cannot open dump file.\n" #define MSGTR_CoreDumped "Core dumped ;)\n" +#define MSGTR_DumpBytesWrittenPercent "dump: %"PRIu64" bytes written (~%.1f%%)\r" +#define MSGTR_DumpBytesWritten "dump: %"PRIu64" bytes written\r" +#define MSGTR_DumpBytesWrittenTo "dump: %"PRIu64" bytes written to '%s'.\n" #define MSGTR_FPSnotspecified "FPS not specified in the header or invalid, use the -fps option.\n" #define MSGTR_TryForceAudioFmtStr "Trying to force audio codec driver family %s...\n" #define MSGTR_CantFindAudioCodec "Cannot find codec for audio format 0x%X.\n" @@ -112,8 +114,6 @@ static const char help_text[]= #define MSGTR_Playing "\nPlaying %s.\n" #define MSGTR_NoSound "Audio: no sound\n" #define MSGTR_FPSforced "FPS forced to be %5.3f (ftime: %5.3f).\n" -#define MSGTR_CompiledWithRuntimeDetection "Compiled with runtime CPU detection.\n" -#define MSGTR_CompiledWithCPUExtensions "Compiled for x86 CPU with extensions:" #define MSGTR_AvailableVideoOutputDrivers "Available video output drivers:\n" #define MSGTR_AvailableAudioOutputDrivers "Available audio output drivers:\n" #define MSGTR_AvailableAudioCodecs "Available audio codecs:\n" @@ -121,7 +121,6 @@ static const char help_text[]= #define MSGTR_AvailableAudioFm "Available (compiled-in) audio codec families/drivers:\n" #define MSGTR_AvailableVideoFm "Available (compiled-in) video codec families/drivers:\n" #define MSGTR_AvailableFsType "Available fullscreen layer change modes:\n" -#define MSGTR_UsingRTCTiming "Using Linux hardware RTC timing (%ldHz).\n" #define MSGTR_CannotReadVideoProperties "Video: Cannot read properties.\n" #define MSGTR_NoStreamFound "No stream found.\n" #define MSGTR_ErrorInitializingVODevice "Error opening/initializing the selected video_out (-vo) device.\n" @@ -129,7 +128,7 @@ static const char help_text[]= #define MSGTR_ForcedAudioCodec "Forced audio codec: %s\n" #define MSGTR_Video_NoVideo "Video: no video\n" #define MSGTR_NotInitializeVOPorVO "\nFATAL: Could not initialize video filters (-vf) or video output (-vo).\n" -#define MSGTR_Paused "\n ===== PAUSE =====\r" // no more than 23 characters (status line for audio files) +#define MSGTR_Paused " ===== PAUSE =====" // no more than 23 characters (status line for audio files) #define MSGTR_PlaylistLoadUnable "\nUnable to load playlist %s.\n" #define MSGTR_Exit_SIGILL_RTCpuSel \ "- MPlayer crashed by an 'Illegal Instruction'.\n"\ @@ -156,15 +155,11 @@ static const char help_text[]= #define MSGTR_AddedSubtitleFile "SUB: Added subtitle file (%d): %s\n" #define MSGTR_RemovedSubtitleFile "SUB: Removed subtitle file (%d): %s\n" #define MSGTR_ErrorOpeningOutputFile "Error opening file [%s] for writing!\n" -#define MSGTR_CommandLine "CommandLine:" #define MSGTR_RTCDeviceNotOpenable "Failed to open %s: %s (it should be readable by the user.)\n" #define MSGTR_LinuxRTCInitErrorIrqpSet "Linux RTC init error in ioctl (rtc_irqp_set %lu): %s\n" #define MSGTR_IncreaseRTCMaxUserFreq "Try adding \"echo %lu > /proc/sys/dev/rtc/max-user-freq\" to your system startup scripts.\n" #define MSGTR_LinuxRTCInitErrorPieOn "Linux RTC init error in ioctl (rtc_pie_on): %s\n" #define MSGTR_UsingTimingType "Using %s timing.\n" -#define MSGTR_NoIdleAndGui "The -idle option cannot be used with GMPlayer.\n" -#define MSGTR_MenuInitialized "Menu initialized: %s\n" -#define MSGTR_MenuInitFailed "Menu init failed.\n" #define MSGTR_Getch2InitializedTwice "WARNING: getch2_init called twice!\n" #define MSGTR_DumpstreamFdUnavailable "Cannot dump this stream - no file descriptor available.\n" #define MSGTR_CantOpenLibmenuFilterWithThisRootMenu "Can't open libmenu video filter with root menu %s.\n" @@ -188,6 +183,17 @@ static const char help_text[]= #define MSGTR_MenuCall "Menu call\n" #define MSGTR_MasterQuit "Option -udp-slave: exiting because master exited\n" #define MSGTR_InvalidIP "Option -udp-ip: invalid IP address\n" +#define MSGTR_Forking "Forking...\n" +#define MSGTR_Forked "Forked...\n" +#define MSGTR_CouldntStartGdb "Couldn't start gdb\n" +#define MSGTR_CouldntFork "Couldn't fork\n" +#define MSGTR_FilenameTooLong "Filename is too long, can not load file or directory specific config files\n" +#define MSGTR_AudioDeviceStuck "Audio device got stuck!\n" +#define MSGTR_AudioOutputTruncated "Audio output truncated at end.\n" +#define MSGTR_ASSCannotAddVideoFilter "ASS: cannot add video filter\n" +#define MSGTR_PtsAfterFiltersMissing "pts after filters MISSING\n" +#define MSGTR_CommandLine "CommandLine:" +#define MSGTR_MenuInitFailed "Menu init failed.\n" // --- edit decision lists #define MSGTR_EdlOutOfMem "Can't allocate enough memory to hold EDL data.\n" @@ -205,7 +211,6 @@ static const char help_text[]= #define MSGTR_EdloutBadStop "EDL skip canceled, last start > stop\n" #define MSGTR_EdloutStartSkip "EDL skip start, press 'i' again to end block.\n" #define MSGTR_EdloutEndSkip "EDL skip end, line written.\n" -#define MSGTR_MPEndposNoSizeBased "Option -endpos in MPlayer does not yet support size units.\n" // mplayer.c OSD #define MSGTR_OSDenabled "enabled" @@ -219,6 +224,8 @@ static const char help_text[]= #define MSGTR_OSDChapter "Chapter: (%d) %s" #define MSGTR_OSDAngle "Angle: %d/%d" #define MSGTR_OSDDeinterlace "Deinterlace: %s" +#define MSGTR_OSDCapturing "Capturing: %s" +#define MSGTR_OSDCapturingFailure "Capturing failed" // property values #define MSGTR_Enabled "enabled" @@ -298,12 +305,9 @@ static const char help_text[]= #define MSGTR_CannotAllocateBytes "Couldn't allocate %d bytes.\n" #define MSGTR_SettingAudioDelay "Setting audio delay to %5.3fs.\n" #define MSGTR_SettingVideoDelay "Setting video delay to %5.3fs.\n" -#define MSGTR_SettingAudioInputGain "Setting audio input gain to %f.\n" -#define MSGTR_LamePresetEquals "\npreset=%s\n\n" #define MSGTR_LimitingAudioPreload "Limiting audio preload to 0.4s.\n" #define MSGTR_IncreasingAudioDensity "Increasing audio density to 4.\n" #define MSGTR_ZeroingAudioPreloadAndMaxPtsCorrection "Forcing audio preload to 0, max pts correction to 0.\n" -#define MSGTR_CBRAudioByterate "\n\nCBR audio: %d bytes/sec, %d bytes/block\n" #define MSGTR_LameVersion "LAME version %s (%s)\n\n" #define MSGTR_InvalidBitrateForLamePreset "Error: The bitrate specified is out of the valid range for this preset.\n"\ "\n"\ @@ -411,7 +415,7 @@ static const char help_text[]= "Cannot set LAME options, check bitrate/samplerate, some very low bitrates\n"\ "(<32) need lower samplerates (i.e. -srate 8000).\n"\ "If everything else fails, try a preset." -#define MSGTR_ConfigFileError "config file error" +#define MSGTR_ConfigFileError "Config file error" #define MSGTR_ErrorParsingCommandLine "error parsing command line" #define MSGTR_VideoStreamRequired "Video stream is mandatory!\n" #define MSGTR_ForcingInputFPS "Input fps will be interpreted as %5.3f instead.\n" @@ -490,8 +494,6 @@ static const char help_text[]= #define MSGTR_CodecNeedsOutfmt "\ncodec(%s) needs an 'outfmt'!\n" #define MSGTR_CantAllocateComment "Can't allocate memory for comment. " #define MSGTR_GetTokenMaxNotLessThanMAX_NR_TOKEN "get_token(): max >= MAX_MR_TOKEN!" -#define MSGTR_ReadingFile "Reading %s: " -#define MSGTR_CantOpenFileError "Can't open '%s': %s\n" #define MSGTR_CantGetMemoryForLine "Can't get memory for 'line': %s\n" #define MSGTR_CantReallocCodecsp "Can't realloc '*codecsp': %s\n" #define MSGTR_CodecNameNotUnique "Codec name '%s' isn't unique." @@ -557,10 +559,40 @@ static const char help_text[]= #define MSGTR_Preferences "Preferences" #define MSGTR_AudioPreferences "Audio driver configuration" #define MSGTR_NoMediaOpened "No media opened." -#define MSGTR_VCDTrack "VCD track %d" +#define MSGTR_Title "Title %d" #define MSGTR_NoChapter "No chapter" #define MSGTR_Chapter "Chapter %d" #define MSGTR_NoFileLoaded "No file loaded." +#define MSGTR_Filter_UTF8Subtitles "UTF-8 encoded subtitles (*.utf, *.utf-8, *.utf8)" +#define MSGTR_Filter_AllSubtitles "All subtitles" +#define MSGTR_Filter_AllFiles "All files" +#define MSGTR_Filter_TTF "True Type fonts (*.ttf)" +#define MSGTR_Filter_Type1 "Type1 fonts (*.pfb)" +#define MSGTR_Filter_AllFonts "All fonts" +#define MSGTR_Filter_FontFiles "Font files (*.desc)" +#define MSGTR_Filter_DDRawAudio "Dolby Digital / PCM (*.ac3, *.pcm)" +#define MSGTR_Filter_MPEGAudio "MPEG audio (*.mp2, *.mp3, *.mpga, *.m4a, *.aac, *.f4a)" +#define MSGTR_Filter_MatroskaAudio "Matroska audio (*.mka)" +#define MSGTR_Filter_OGGAudio "Ogg audio (*.oga, *.ogg, *.spx)" +#define MSGTR_Filter_WAVAudio "WAV audio (*.wav)" +#define MSGTR_Filter_WMAAudio "Windows Media audio (*.wma)" +#define MSGTR_Filter_AllAudioFiles "All audio files" +#define MSGTR_Filter_AllVideoFiles "All video files" +#define MSGTR_Filter_AVIFiles "AVI files" +#define MSGTR_Filter_DivXFiles "DivX files" +#define MSGTR_Filter_FlashVideo "Flash Video" +#define MSGTR_Filter_MP3Files "MP3 files" +#define MSGTR_Filter_MP4Files "MP4 files" +#define MSGTR_Filter_MPEGFiles "MPEG files" +#define MSGTR_Filter_MP2TS "MPEG-2 transport streams" +#define MSGTR_Filter_MatroskaMedia "Matroska media" +#define MSGTR_Filter_OGGMedia "Ogg media" +#define MSGTR_Filter_QTMedia "QuickTime media" +#define MSGTR_Filter_RNMedia "RealNetworks media" +#define MSGTR_Filter_VideoCDImages "VCD/SVCD images" +#define MSGTR_Filter_WAVFiles "WAV files" +#define MSGTR_Filter_WindowsMedia "Windows media" +#define MSGTR_Filter_Playlists "Playlists" // --- buttons --- #define MSGTR_Ok "OK" @@ -573,43 +605,43 @@ static const char help_text[]= #define MSGTR_Browse "Browse" // --- error messages --- -#define MSGTR_NEMDB "Sorry, not enough memory to draw buffer." +#define MSGTR_NEMDB "Sorry, not enough memory to draw buffer.\n" #define MSGTR_NEMFMR "Sorry, not enough memory for menu rendering." -#define MSGTR_IDFGCVD "Sorry, I did not find a GUI-compatible video output driver." +#define MSGTR_IDFGCVD "Sorry, no GUI-compatible video output driver found.\n" #define MSGTR_NEEDLAVC "Sorry, you cannot play non-MPEG files with your DXR3/H+ device without reencoding.\nPlease enable lavc in the DXR3/H+ configuration box." -#define MSGTR_UNKNOWNWINDOWTYPE "Unknown window type found ..." +#define MSGTR_ICONERROR "Icon '%s' (size %d) not found or unsupported format.\n" // --- skin loader error messages -#define MSGTR_SKIN_ERRORMESSAGE "[skin] error in skin config file on line %d: %s" -#define MSGTR_SKIN_WARNING1 "[skin] warning: in config file line %d:\nwidget (%s) found but no \"section\" found before" -#define MSGTR_SKIN_WARNING2 "[skin] warning: in config file line %d:\nwidget (%s) found but no \"subsection\" found before" -#define MSGTR_SKIN_WARNING3 "[skin] warning: in config file line %d:\nthis subsection is not supported by widget (%s)" -#define MSGTR_SKIN_SkinFileNotFound "[skin] file ( %s ) not found.\n" -#define MSGTR_SKIN_SkinFileNotReadable "[skin] file ( %s ) not readable.\n" -#define MSGTR_SKIN_BITMAP_16bit "Bitmaps of 16 bits or less depth not supported (%s).\n" -#define MSGTR_SKIN_BITMAP_FileNotFound "File not found (%s)\n" -#define MSGTR_SKIN_BITMAP_BMPReadError "BMP read error (%s)\n" -#define MSGTR_SKIN_BITMAP_TGAReadError "TGA read error (%s)\n" -#define MSGTR_SKIN_BITMAP_PNGReadError "PNG read error (%s)\n" -#define MSGTR_SKIN_BITMAP_RLENotSupported "RLE packed TGA not supported (%s)\n" -#define MSGTR_SKIN_BITMAP_UnknownFileType "unknown file type (%s)\n" -#define MSGTR_SKIN_BITMAP_ConversionError "24 bit to 32 bit conversion error (%s)\n" -#define MSGTR_SKIN_BITMAP_UnknownMessage "unknown message: %s\n" -#define MSGTR_SKIN_FONT_NotEnoughtMemory "not enough memory\n" +#define MSGTR_SKIN_ERRORMESSAGE "Error in skin config file on line %d: %s" +#define MSGTR_SKIN_ERROR_SECTION "No section specified for '%s'.\n" +#define MSGTR_SKIN_ERROR_WINDOW "No window specified for '%s'.\n" +#define MSGTR_SKIN_ERROR_ITEM "This item is not supported by '%s'.\n" +#define MSGTR_SKIN_UNKNOWN_ITEM "Unknown item '%s'\n" +#define MSGTR_SKIN_UNKNOWN_NAME "Unknown name '%s'\n" +#define MSGTR_SKIN_SkinFileNotFound "Skin file %s not found.\n" +#define MSGTR_SKIN_SkinFileNotReadable "Skin file %s not readable.\n" +#define MSGTR_SKIN_BITMAP_16bit "Color depth of bitmap %s is 16 bits or less which is not supported.\n" +#define MSGTR_SKIN_BITMAP_FileNotFound "Bitmap %s not found.\n" +#define MSGTR_SKIN_BITMAP_PNGReadError "PNG read error in %s\n" +#define MSGTR_SKIN_BITMAP_ConversionError "24 bit to 32 bit conversion error in %s\n" +#define MSGTR_SKIN_UnknownMessage "Unknown message '%s'\n" +#define MSGTR_SKIN_NotEnoughMemory "Not enough memory\n" +#define MSGTR_SKIN_TooManyItemsDeclared "Too many items declared.\n" #define MSGTR_SKIN_FONT_TooManyFontsDeclared "Too many fonts declared.\n" -#define MSGTR_SKIN_FONT_FontFileNotFound "Font file not found.\n" +#define MSGTR_SKIN_FONT_FontFileNotFound "Font description file not found.\n" #define MSGTR_SKIN_FONT_FontImageNotFound "Font image file not found.\n" -#define MSGTR_SKIN_FONT_NonExistentFontID "non-existent font identifier (%s)\n" -#define MSGTR_SKIN_UnknownParameter "unknown parameter (%s)\n" -#define MSGTR_SKIN_SKINCFG_SkinNotFound "Skin not found (%s).\n" -#define MSGTR_SKIN_SKINCFG_SelectedSkinNotFound "Selected skin ( %s ) not found, trying 'default'...\n" -#define MSGTR_SKIN_SKINCFG_SkinCfgReadError "skin config file read error (%s)\n" +#define MSGTR_SKIN_FONT_NonExistentFont "Font '%s' not found.\n" +#define MSGTR_SKIN_UnknownParameter "Unknown parameter '%s'\n" +#define MSGTR_SKIN_SKINCFG_SkinNotFound "Skin '%s' not found.\n" +#define MSGTR_SKIN_SKINCFG_SelectedSkinNotFound "Selected skin '%s' not found, trying skin 'default'...\n" +#define MSGTR_SKIN_SKINCFG_SkinCfgError "Config file processing error with skin '%s'\n" #define MSGTR_SKIN_LABEL "Skins:" // --- GTK menus #define MSGTR_MENU_AboutMPlayer "About MPlayer" #define MSGTR_MENU_Open "Open..." #define MSGTR_MENU_PlayFile "Play file..." +#define MSGTR_MENU_PlayCD "Play CD..." #define MSGTR_MENU_PlayVCD "Play VCD..." #define MSGTR_MENU_PlayDVD "Play DVD..." #define MSGTR_MENU_PlayURL "Play URL..." @@ -627,6 +659,7 @@ static const char help_text[]= #define MSGTR_MENU_NormalSize "Normal size" #define MSGTR_MENU_DoubleSize "Double size" #define MSGTR_MENU_FullScreen "Fullscreen" +#define MSGTR_MENU_CD "CD" #define MSGTR_MENU_DVD "DVD" #define MSGTR_MENU_VCD "VCD" #define MSGTR_MENU_PlayDisc "Open disc..." @@ -641,7 +674,7 @@ static const char help_text[]= #define MSGTR_MENU_PlayList MSGTR_PlayList #define MSGTR_MENU_SkinBrowser "Skin browser" #define MSGTR_MENU_Preferences MSGTR_Preferences -#define MSGTR_MENU_Exit "Exit..." +#define MSGTR_MENU_Exit "Exit" #define MSGTR_MENU_Mute "Mute" #define MSGTR_MENU_Original "Original" #define MSGTR_MENU_AspectRatio "Aspect ratio" @@ -702,9 +735,10 @@ static const char help_text[]= #define MSGTR_PREFERENCES_HFrameDrop "Enable HARD frame dropping (dangerous)" #define MSGTR_PREFERENCES_Flip "Flip image upside down" #define MSGTR_PREFERENCES_Panscan "Panscan: " -#define MSGTR_PREFERENCES_OSDTimer "Timer and indicators" -#define MSGTR_PREFERENCES_OSDProgress "Progressbars only" -#define MSGTR_PREFERENCES_OSDTimerPercentageTotalTime "Timer, percentage and total time" +#define MSGTR_PREFERENCES_OSD_LEVEL0 "Subtitles only" +#define MSGTR_PREFERENCES_OSD_LEVEL1 "Volume and seek" +#define MSGTR_PREFERENCES_OSD_LEVEL2 "Volume, seek, timer and percentage" +#define MSGTR_PREFERENCES_OSD_LEVEL3 "Volume, seek, timer, percentage and total time" #define MSGTR_PREFERENCES_Subtitle "Subtitle:" #define MSGTR_PREFERENCES_SUB_Delay "Delay: " #define MSGTR_PREFERENCES_SUB_FPS "FPS:" @@ -777,6 +811,7 @@ static const char help_text[]= #define MSGTR_PREFERENCES_SaveWinPos "Save window position" #define MSGTR_PREFERENCES_XSCREENSAVER "Stop XScreenSaver" #define MSGTR_PREFERENCES_PlayBar "Enable playbar" +#define MSGTR_PREFERENCES_NoIdle "Quit after playing" #define MSGTR_PREFERENCES_AutoSync "AutoSync on/off" #define MSGTR_PREFERENCES_AutoSyncValue "Autosync: " #define MSGTR_PREFERENCES_CDROMDevice "CD-ROM device:" @@ -798,39 +833,62 @@ static const char help_text[]= #define MSGTR_MSGBOX_LABEL_Error "Error!" #define MSGTR_MSGBOX_LABEL_Warning "Warning!" -// bitmap.c -#define MSGTR_NotEnoughMemoryC32To1 "[c32to1] not enough memory for image\n" -#define MSGTR_NotEnoughMemoryC1To32 "[c1to32] not enough memory for image\n" - // cfg.c -#define MSGTR_ConfigFileReadError "[cfg] config file read error ...\n" -#define MSGTR_UnableToSaveOption "[cfg] Unable to save the '%s' option.\n" +#define MSGTR_UnableToSaveOption "Unable to save option '%s'.\n" // interface.c -#define MSGTR_DeletingSubtitles "[GUI] Deleting subtitles.\n" -#define MSGTR_LoadingSubtitles "[GUI] Loading subtitles: %s\n" -#define MSGTR_AddingVideoFilter "[GUI] Adding video filter: %s\n" -#define MSGTR_RemovingVideoFilter "[GUI] Removing video filter: %s\n" +#define MSGTR_DeletingSubtitles "Deleting subtitles.\n" +#define MSGTR_LoadingSubtitles "Loading subtitles '%s'.\n" +#define MSGTR_AddingVideoFilter "Adding video filter '%s'.\n" // mw.c #define MSGTR_NotAFile "This does not seem to be a file: %s !\n" // ws.c -#define MSGTR_WS_CouldNotOpenDisplay "[ws] Could not open the display.\n" -#define MSGTR_WS_RemoteDisplay "[ws] Remote display, disabling XMITSHM.\n" -#define MSGTR_WS_NoXshm "[ws] Sorry, your system does not support the X shared memory extension.\n" -#define MSGTR_WS_NoXshape "[ws] Sorry, your system does not support the XShape extension.\n" -#define MSGTR_WS_ColorDepthTooLow "[ws] Sorry, the color depth is too low.\n" -#define MSGTR_WS_TooManyOpenWindows "[ws] There are too many open windows.\n" -#define MSGTR_WS_ShmError "[ws] shared memory extension error\n" -#define MSGTR_WS_NotEnoughMemoryDrawBuffer "[ws] Sorry, not enough memory to draw buffer.\n" +#define MSGTR_WS_RemoteDisplay "Remote display, disabling XMITSHM.\n" +#define MSGTR_WS_NoXshm "Sorry, your system does not support the X shared memory extension.\n" +#define MSGTR_WS_NoXshape "Sorry, your system does not support the XShape extension.\n" +#define MSGTR_WS_ColorDepthTooLow "Sorry, the color depth is too low.\n" +#define MSGTR_WS_TooManyOpenWindows "There are too many open windows.\n" +#define MSGTR_WS_ShmError "shared memory extension error\n" +#define MSGTR_WS_NotEnoughMemoryDrawBuffer "Sorry, not enough memory to draw buffer.\n" #define MSGTR_WS_DpmsUnavailable "DPMS not available?\n" #define MSGTR_WS_DpmsNotEnabled "Could not enable DPMS.\n" +#define MSGTR_WS_XError "An X11 Error has occurred!\n" // wsxdnd.c #define MSGTR_WS_NotAFile "This does not seem to be a file...\n" #define MSGTR_WS_DDNothing "D&D: Nothing returned!\n" +// Win32 GUI +#define MSGTR_Close "Close" +#define MSGTR_Default "Defaults" +#define MSGTR_Down "Down" +#define MSGTR_Load "Load" +#define MSGTR_Save "Save" +#define MSGTR_Up "Up" +#define MSGTR_DirectorySelect "Select directory..." +#define MSGTR_PlaylistSave "Save playlist..." +#define MSGTR_PlaylistSelect "Select playlist..." +#define MSGTR_SelectTitleChapter "Select title/chapter..." +#define MSGTR_MENU_DebugConsole "Debug Console" +#define MSGTR_MENU_OnlineHelp "Online Help" +#define MSGTR_MENU_PlayDirectory "Play directory..." +#define MSGTR_MENU_SeekBack "Seek Backwards" +#define MSGTR_MENU_SeekForw "Seek Forwards" +#define MSGTR_MENU_ShowHide "Show/Hide" +#define MSGTR_MENU_SubtitlesOnOff "Subtitle Visibility On/Off" +#define MSGTR_PLAYLIST_AddFile "Add File..." +#define MSGTR_PLAYLIST_AddURL "Add URL..." +#define MSGTR_PREFERENCES_Priority "Priority:" +#define MSGTR_PREFERENCES_PriorityHigh "high" +#define MSGTR_PREFERENCES_PriorityLow "low" +#define MSGTR_PREFERENCES_PriorityNormal "normal" +#define MSGTR_PREFERENCES_PriorityNormalAbove "above normal" +#define MSGTR_PREFERENCES_PriorityNormalBelow "below normal" +#define MSGTR_PREFERENCES_ShowInVideoWin "Display in the video window (DirectX only)" + + // ======================= video output drivers ======================== #define MSGTR_VOincompCodec "The selected video_out device is incompatible with this codec.\n"\ @@ -984,7 +1042,6 @@ static const char help_text[]= // vo_sdl.c #define MSGTR_LIBVO_SDL_CouldntGetAnyAcceptableSDLModeForOutput "[VO_SDL] Couldn't get any acceptable SDL Mode for output.\n" #define MSGTR_LIBVO_SDL_SetVideoModeFailed "[VO_SDL] set_video_mode: SDL_SetVideoMode failed: %s.\n" -#define MSGTR_LIBVO_SDL_SetVideoModeFailedFull "[VO_SDL] Set_fullmode: SDL_SetVideoMode failed: %s.\n" #define MSGTR_LIBVO_SDL_MappingI420ToIYUV "[VO_SDL] Mapping I420 to IYUV.\n" #define MSGTR_LIBVO_SDL_UnsupportedImageFormat "[VO_SDL] Unsupported image format (0x%X).\n" #define MSGTR_LIBVO_SDL_InfoPleaseUseVmOrZoom "[VO_SDL] Info - please use -vm or -zoom to switch to the best resolution.\n" @@ -1151,16 +1208,15 @@ static const char help_text[]= // old vo drivers that have been replaced #define MSGTR_VO_PGM_HasBeenReplaced "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n" #define MSGTR_VO_MD5_HasBeenReplaced "The md5 video output driver has been replaced by -vo md5sum.\n" +#define MSGTR_VO_GL2_HasBeenRenamed "The gl2 video output driver has been renamed to -vo gl_tiled, but you really should be using -vo gl instead.\n" // ======================= audio output drivers ======================== // audio_out.c #define MSGTR_AO_ALSA9_1x_Removed "audio_out: alsa9 and alsa1x modules were removed, use -ao alsa instead.\n" -#define MSGTR_AO_TryingPreferredAudioDriver "Trying preferred audio driver '%.*s', options '%s'\n" #define MSGTR_AO_NoSuchDriver "No such audio driver '%.*s'\n" #define MSGTR_AO_FailedInit "Failed to initialize audio driver '%s'\n" -#define MSGTR_AO_TryingEveryKnown "Trying every known audio driver...\n" // ao_oss.c #define MSGTR_AO_OSS_CantOpenMixer "[AO OSS] audio_setup: Can't open mixer device %s: %s\n" @@ -1196,7 +1252,7 @@ static const char help_text[]= // ao_pcm.c #define MSGTR_AO_PCM_FileInfo "[AO PCM] File: %s (%s)\nPCM: Samplerate: %iHz Channels: %s Format %s\n" -#define MSGTR_AO_PCM_HintInfo "[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast\n[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n" +#define MSGTR_AO_PCM_HintInfo "[AO PCM] Info: Faster dumping is achieved with -benchmark -vc null -vo null -ao pcm:fast\n[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).\n" #define MSGTR_AO_PCM_CantOpenOutputFile "[AO PCM] Failed to open %s for writing!\n" // ao_sdl.c @@ -1213,7 +1269,7 @@ static const char help_text[]= #define MSGTR_AO_SGI_CantSetParms_Samplerate "[AO SGI] init: setparams failed: %s\nCould not set desired samplerate.\n" #define MSGTR_AO_SGI_CantSetAlRate "[AO SGI] init: AL_RATE was not accepted on the given resource.\n" #define MSGTR_AO_SGI_CantGetParms "[AO SGI] init: getparams failed: %s\n" -#define MSGTR_AO_SGI_SampleRateInfo "[AO SGI] init: samplerate is now %lf (desired rate is %lf)\n" +#define MSGTR_AO_SGI_SampleRateInfo "[AO SGI] init: samplerate is now %f (desired rate is %f)\n" #define MSGTR_AO_SGI_InitConfigError "[AO SGI] init: %s\n" #define MSGTR_AO_SGI_InitOpenAudioFailed "[AO SGI] init: Unable to open audio channel: %s\n" #define MSGTR_AO_SGI_Uninit "[AO SGI] uninit: ...\n" @@ -1229,31 +1285,6 @@ static const char help_text[]= #define MSGTR_AO_SUN_CantUseSelect "[AO SUN]\n *** Your audio driver DOES NOT support select() ***\nRecompile MPlayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n" #define MSGTR_AO_SUN_CantReopenReset "[AO SUN]\nFatal error: *** CANNOT REOPEN / RESET AUDIO DEVICE (%s) ***\n" -// ao_alsa5.c -#define MSGTR_AO_ALSA5_InitInfo "[AO ALSA5] alsa-init: requested format: %d Hz, %d channels, %s\n" -#define MSGTR_AO_ALSA5_SoundCardNotFound "[AO ALSA5] alsa-init: no soundcards found.\n" -#define MSGTR_AO_ALSA5_InvalidFormatReq "[AO ALSA5] alsa-init: invalid format (%s) requested - output disabled.\n" -#define MSGTR_AO_ALSA5_PlayBackError "[AO ALSA5] alsa-init: playback open error: %s\n" -#define MSGTR_AO_ALSA5_PcmInfoError "[AO ALSA5] alsa-init: PCM info error: %s\n" -#define MSGTR_AO_ALSA5_SoundcardsFound "[AO ALSA5] alsa-init: %d soundcard(s) found, using: %s\n" -#define MSGTR_AO_ALSA5_PcmChanInfoError "[AO ALSA5] alsa-init: PCM channel info error: %s\n" -#define MSGTR_AO_ALSA5_CantSetParms "[AO ALSA5] alsa-init: error setting parameters: %s\n" -#define MSGTR_AO_ALSA5_CantSetChan "[AO ALSA5] alsa-init: error setting up channel: %s\n" -#define MSGTR_AO_ALSA5_ChanPrepareError "[AO ALSA5] alsa-init: channel prepare error: %s\n" -#define MSGTR_AO_ALSA5_DrainError "[AO ALSA5] alsa-uninit: playback drain error: %s\n" -#define MSGTR_AO_ALSA5_FlushError "[AO ALSA5] alsa-uninit: playback flush error: %s\n" -#define MSGTR_AO_ALSA5_PcmCloseError "[AO ALSA5] alsa-uninit: PCM close error: %s\n" -#define MSGTR_AO_ALSA5_ResetDrainError "[AO ALSA5] alsa-reset: playback drain error: %s\n" -#define MSGTR_AO_ALSA5_ResetFlushError "[AO ALSA5] alsa-reset: playback flush error: %s\n" -#define MSGTR_AO_ALSA5_ResetChanPrepareError "[AO ALSA5] alsa-reset: channel prepare error: %s\n" -#define MSGTR_AO_ALSA5_PauseDrainError "[AO ALSA5] alsa-pause: playback drain error: %s\n" -#define MSGTR_AO_ALSA5_PauseFlushError "[AO ALSA5] alsa-pause: playback flush error: %s\n" -#define MSGTR_AO_ALSA5_ResumePrepareError "[AO ALSA5] alsa-resume: channel prepare error: %s\n" -#define MSGTR_AO_ALSA5_Underrun "[AO ALSA5] alsa-play: alsa underrun, resetting stream.\n" -#define MSGTR_AO_ALSA5_PlaybackPrepareError "[AO ALSA5] alsa-play: playback prepare error: %s\n" -#define MSGTR_AO_ALSA5_WriteErrorAfterReset "[AO ALSA5] alsa-play: write error after reset: %s - giving up.\n" -#define MSGTR_AO_ALSA5_OutPutError "[AO ALSA5] alsa-play: output error: %s\n" - // ao_alsa.c #define MSGTR_AO_ALSA_InvalidMixerIndexDefaultingToZero "[AO_ALSA] Invalid mixer index. Defaulting to 0.\n" #define MSGTR_AO_ALSA_MixerOpenError "[AO_ALSA] Mixer open error: %s\n" @@ -1337,7 +1368,6 @@ static const char help_text[]= // ========================== INPUT ========================================= // joystick.c -#define MSGTR_INPUT_JOYSTICK_Opening "Opening joystick device %s\n" #define MSGTR_INPUT_JOYSTICK_CantOpen "Can't open joystick device %s: %s\n" #define MSGTR_INPUT_JOYSTICK_ErrReading "Error while reading joystick device: %s\n" #define MSGTR_INPUT_JOYSTICK_LoosingBytes "Joystick: We lose %d bytes of data\n" @@ -1345,8 +1375,6 @@ static const char help_text[]= #define MSGTR_INPUT_JOYSTICK_WarnUnknownEvent "Joystick warning unknown event type %d\n" // appleir.c -#define MSGTR_INPUT_APPLE_IR_Init "Initializing Apple IR on %s\n" -#define MSGTR_INPUT_APPLE_IR_Detect "Detected Apple IR on %s\n" #define MSGTR_INPUT_APPLE_IR_CantOpen "Can't open Apple IR device: %s\n" // input.c @@ -1373,12 +1401,10 @@ static const char help_text[]= #define MSGTR_INPUT_INPUT_ErrBuffer2SmallForCmd "Buffer is too small for command %s\n" #define MSGTR_INPUT_INPUT_ErrWhyHere "What are we doing here?\n" #define MSGTR_INPUT_INPUT_ErrCantInitJoystick "Can't init input joystick\n" -#define MSGTR_INPUT_INPUT_ErrCantStatFile "Can't stat %s: %s\n" #define MSGTR_INPUT_INPUT_ErrCantOpenFile "Can't open %s: %s\n" #define MSGTR_INPUT_INPUT_ErrCantInitAppleRemote "Can't init Apple Remote.\n" // lirc.c -#define MSGTR_SettingUpLIRC "Setting up LIRC support...\n" #define MSGTR_LIRCopenfailed "Failed to open LIRC support. You will not be able to use your remote control.\n" #define MSGTR_LIRCcfgerr "Failed to read LIRC config file %s.\n" @@ -1393,7 +1419,6 @@ static const char help_text[]= #define MSGTR_WarningLenIsntDivisible "Warning, len isn't divisible by samplesize!\n" #define MSGTR_MuxbufMallocErr "Muxer frame buffer cannot allocate memory!\n" #define MSGTR_MuxbufReallocErr "Muxer frame buffer cannot reallocate memory!\n" -#define MSGTR_MuxbufSending "Muxer frame buffer sending %d frame(s) to the muxer.\n" #define MSGTR_WritingHeader "Writing header...\n" #define MSGTR_WritingTrailer "Writing index...\n" @@ -1411,7 +1436,6 @@ static const char help_text[]= #define MSGTR_ON2AviFormat "ON2 AVI format" #define MSGTR_Detected_XXX_FileFormat "%s file format detected.\n" #define MSGTR_DetectedAudiofile "Audio file detected.\n" -#define MSGTR_NotSystemStream "Not MPEG System Stream format... (maybe Transport Stream?)\n" #define MSGTR_InvalidMPEGES "Invalid MPEG-ES stream??? Contact the author, it may be a bug :(\n" #define MSGTR_FormatNotRecognized "============ Sorry, this file format is not recognized/supported =============\n"\ "=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n" @@ -1436,11 +1460,8 @@ static const char help_text[]= #define MSGTR_MOVcomprhdr "MOV: Compressed headers support requires ZLIB!\n" #define MSGTR_MOVvariableFourCC "MOV: WARNING: Variable FourCC detected!?\n" #define MSGTR_MOVtooManyTrk "MOV: WARNING: too many tracks" -#define MSGTR_FoundAudioStream "==> Found audio stream: %d\n" -#define MSGTR_FoundVideoStream "==> Found video stream: %d\n" #define MSGTR_DetectedTV "TV detected! ;-)\n" #define MSGTR_ErrorOpeningOGGDemuxer "Unable to open the Ogg demuxer.\n" -#define MSGTR_ASFSearchingForAudioStream "ASF: Searching for audio stream (id:%d).\n" #define MSGTR_CannotOpenAudioStream "Cannot open audio stream: %s\n" #define MSGTR_CannotOpenSubtitlesStream "Cannot open subtitle stream: %s\n" #define MSGTR_OpeningAudioDemuxerFailed "Failed to open audio demuxer: %s\n" @@ -1453,7 +1474,7 @@ static const char help_text[]= #define MSGTR_EnterTelecineMode "\ndemux_mpg: 24000/1001fps progressive NTSC content detected, switching framerate.\n" #define MSGTR_CacheFill "\rCache fill: %5.2f%% (%"PRId64" bytes) " -#define MSGTR_NoBindFound "No bind found for key '%s'." +#define MSGTR_NoBindFound "No bind found for key '%s'.\n" #define MSGTR_FailedToOpen "Failed to open %s.\n" #define MSGTR_VideoID "[%s] Video stream found, -vid %d\n" @@ -1473,17 +1494,7 @@ static const char help_text[]= // aviheader.c #define MSGTR_MPDEMUX_AVIHDR_EmptyList "** empty list?!\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundMovieAt "Found movie at 0x%X - 0x%X\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundBitmapInfoHeader "Found 'bih', %u bytes of %d\n" -#define MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForMPG4V1 "Regenerating keyframe table for M$ mpg4v1 video.\n" -#define MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForDIVX3 "Regenerating keyframe table for DIVX3 video.\n" -#define MSGTR_MPDEMUX_AVIHDR_RegeneratingKeyfTableForMPEG4 "Regenerating keyframe table for MPEG-4 video.\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundWaveFmt "Found 'wf', %d bytes of %d\n" -#define MSGTR_MPDEMUX_AVIHDR_FoundAVIV2Header "AVI: dmlh found (size=%d) (total_frames=%d)\n" -#define MSGTR_MPDEMUX_AVIHDR_ReadingIndexBlockChunksForFrames "Reading INDEX block, %d chunks for %d frames (fpos=%"PRId64").\n" -#define MSGTR_MPDEMUX_AVIHDR_AdditionalRIFFHdr "Additional RIFF header...\n" #define MSGTR_MPDEMUX_AVIHDR_WarnNotExtendedAVIHdr "** Warning: this is no extended AVI header..\n" -#define MSGTR_MPDEMUX_AVIHDR_BrokenChunk "Broken chunk? chunksize=%d (id=%.4s)\n" #define MSGTR_MPDEMUX_AVIHDR_BuildingODMLidx "AVI: ODML: Building ODML index (%d superindexchunks).\n" #define MSGTR_MPDEMUX_AVIHDR_BrokenODMLfile "AVI: ODML: Broken (incomplete?) file detected. Will use traditional index.\n" #define MSGTR_MPDEMUX_AVIHDR_CantReadIdxFile "Can't read index file %s: %s\n" @@ -1497,6 +1508,8 @@ static const char help_text[]= #define MSGTR_MPDEMUX_AVIHDR_IdxFileSaved "Saved index file: %s\n" // demux_audio.c +#define MSGTR_MPDEMUX_AUDIO_BadID3v2TagSize "Audio demuxer: bad ID3v2 tag size: larger than stream (%u).\n" +#define MSGTR_MPDEMUX_AUDIO_DamagedAppendedID3v2Tag "Audio demuxer: damaged appended ID3v2 tag detected.\n" #define MSGTR_MPDEMUX_AUDIO_UnknownFormat "Audio demuxer: unknown format %d.\n" // demux_demuxers.c @@ -1615,21 +1628,15 @@ static const char help_text[]= #define MSGTR_UsingExternalPP "[PP] Using external postprocessing filter, max q = %d.\n" #define MSGTR_UsingCodecPP "[PP] Using codec's postprocessing, max q = %d.\n" -#define MSGTR_VideoAttributeNotSupportedByVO_VD "Video attribute '%s' is not supported by selected vo & vd.\n" #define MSGTR_VideoCodecFamilyNotAvailableStr "Requested video codec family [%s] (vfm=%s) not available.\nEnable it at compilation.\n" #define MSGTR_AudioCodecFamilyNotAvailableStr "Requested audio codec family [%s] (afm=%s) not available.\nEnable it at compilation.\n" #define MSGTR_OpeningVideoDecoder "Opening video decoder: [%s] %s\n" #define MSGTR_SelectedVideoCodec "Selected video codec: [%s] vfm: %s (%s)\n" #define MSGTR_OpeningAudioDecoder "Opening audio decoder: [%s] %s\n" #define MSGTR_SelectedAudioCodec "Selected audio codec: [%s] afm: %s (%s)\n" -#define MSGTR_BuildingAudioFilterChain "Building audio filter chain for %dHz/%dch/%s -> %dHz/%dch/%s...\n" -#define MSGTR_UninitVideoStr "Uninit video: %s\n" -#define MSGTR_UninitAudioStr "Uninit audio: %s\n" #define MSGTR_VDecoderInitFailed "VDecoder init failed :(\n" #define MSGTR_ADecoderInitFailed "ADecoder init failed :(\n" #define MSGTR_ADecoderPreinitFailed "ADecoder preinit failed :(\n" -#define MSGTR_AllocatingBytesForInputBuffer "dec_audio: Allocating %d bytes for input buffer.\n" -#define MSGTR_AllocatingBytesForOutputBuffer "dec_audio: Allocating %d + %d = %d bytes for output buffer.\n" // ad_dvdpcm.c: #define MSGTR_SamplesWanted "Samples of this format are needed to improve support. Please contact the developers.\n" @@ -1645,8 +1652,6 @@ static const char help_text[]= // vd_dshow.c, vd_dmo.c #define MSGTR_DownloadCodecPackage "You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n" -#define MSGTR_DShowInitOK "INFO: Win32/DShow video codec init OK.\n" -#define MSGTR_DMOInitOK "INFO: Win32/DMO video codec init OK.\n" // libmpcodecs/vd_dmo.c vd_dshow.c vd_vfw.c #define MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec "[VD_DMO] Couldn't allocate image for cinepak codec.\n" @@ -1774,12 +1779,12 @@ static const char help_text[]= // ================================== stream ==================================== -// ai_alsa1x.c -#define MSGTR_MPDEMUX_AIALSA1X_CannotSetSamplerate "Cannot set samplerate.\n" -#define MSGTR_MPDEMUX_AIALSA1X_CannotSetBufferTime "Cannot set buffer time.\n" -#define MSGTR_MPDEMUX_AIALSA1X_CannotSetPeriodTime "Cannot set period time.\n" +// ai_alsa.c +#define MSGTR_MPDEMUX_AIALSA_CannotSetSamplerate "Cannot set samplerate.\n" +#define MSGTR_MPDEMUX_AIALSA_CannotSetBufferTime "Cannot set buffer time.\n" +#define MSGTR_MPDEMUX_AIALSA_CannotSetPeriodTime "Cannot set period time.\n" -// ai_alsa1x.c / ai_alsa.c +// ai_alsa.c #define MSGTR_MPDEMUX_AIALSA_PcmBrokenConfig "Broken configuration for this PCM: no configurations available.\n" #define MSGTR_MPDEMUX_AIALSA_UnavailableAccessType "Access type not available.\n" #define MSGTR_MPDEMUX_AIALSA_UnavailableSampleFmt "Sample format not available.\n" @@ -1790,7 +1795,6 @@ static const char help_text[]= #define MSGTR_MPDEMUX_AIALSA_ErrorOpeningAudio "Error opening audio: %s\n" #define MSGTR_MPDEMUX_AIALSA_AlsaStatusError "ALSA status error: %s" #define MSGTR_MPDEMUX_AIALSA_AlsaXRUN "ALSA xrun!!! (at least %.3f ms long)\n" -#define MSGTR_MPDEMUX_AIALSA_AlsaStatus "ALSA Status:\n" #define MSGTR_MPDEMUX_AIALSA_AlsaXRUNPrepareError "ALSA xrun: prepare error: %s" #define MSGTR_MPDEMUX_AIALSA_AlsaReadWriteError "ALSA read/write error" @@ -1850,7 +1854,7 @@ static const char help_text[]= #define MSGTR_MPDEMUX_ASF_UnknownASFStreamType "unknown ASF stream type\n" #define MSGTR_MPDEMUX_ASF_Failed2ParseHTTPResponse "Failed to parse HTTP response.\n" #define MSGTR_MPDEMUX_ASF_ServerReturn "Server returned %d:%s\n" -#define MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma "ASF HTTP PARSE WARNING : Pragma %s cut from %zd bytes to %d\n" +#define MSGTR_MPDEMUX_ASF_ASFHTTPParseWarnCuttedPragma "ASF HTTP PARSE WARNING : Pragma %s cut from %zu bytes to %zu\n" #define MSGTR_MPDEMUX_ASF_SocketWriteError "socket write error: %s\n" #define MSGTR_MPDEMUX_ASF_HeaderParseFailed "Failed to parse header.\n" #define MSGTR_MPDEMUX_ASF_NoStreamFound "No stream found.\n" @@ -1907,6 +1911,17 @@ static const char help_text[]= #define MSGTR_CantOpenBluray "Couldn't open Blu-ray device: %s\n" #define MSGTR_CantOpenDVD "Couldn't open DVD device: %s (%s)\n" +#define MSGTR_URLParsingFailed "URL parsing failed on url %s\n" +#define MSGTR_FailedSetStreamOption "Failed to set stream option %s=%s\n" +#define MSGTR_StreamNeedType "Streams need a type!\n" +#define MSGTR_StreamProtocolNULL "Stream type %s has protocols == NULL, it's a bug\n" +#define MSGTR_StreamCantHandleURL "No stream found to handle url %s\n" +#define MSGTR_StreamNULLFilename "open_output_stream(), NULL filename, report this bug\n" +#define MSGTR_StreamErrorWritingCapture "Error writing capture file: %s\n" +#define MSGTR_StreamSeekFailed "Seek failed\n" +#define MSGTR_StreamNotSeekable "Stream not seekable!\n" +#define MSGTR_StreamCannotSeekBackward "Cannot seek backward in linear streams!\n" + // stream_cdda.c #define MSGTR_MPDEMUX_CDDA_CantOpenCDDADevice "Can't open CDDA device.\n" #define MSGTR_MPDEMUX_CDDA_CantOpenDisc "Can't open disc.\n" @@ -1979,21 +1994,16 @@ static const char help_text[]= // stream_bluray.c #define MSGTR_BlurayNoDevice "No Blu-ray device/location was specified ...\n" #define MSGTR_BlurayNoTitles "Can't find any Blu-ray-compatible title here.\n" -#define MSGTR_BlurayOK "Blu-ray successfully opened.\n" // stream_radio.c #define MSGTR_RADIO_ChannelNamesDetected "[radio] Radio channel names detected.\n" -#define MSGTR_RADIO_FreqRange "[radio] Allowed frequency range is %.2f-%.2f MHz.\n" #define MSGTR_RADIO_WrongFreqForChannel "[radio] Wrong frequency for channel %s\n" #define MSGTR_RADIO_WrongChannelNumberFloat "[radio] Wrong channel number: %.2f\n" #define MSGTR_RADIO_WrongChannelNumberInt "[radio] Wrong channel number: %d\n" #define MSGTR_RADIO_WrongChannelName "[radio] Wrong channel name: %s\n" #define MSGTR_RADIO_FreqParameterDetected "[radio] Radio frequency parameter detected.\n" -#define MSGTR_RADIO_DoneParsingChannels "[radio] Done parsing channels.\n" #define MSGTR_RADIO_GetTunerFailed "[radio] Warning: ioctl get tuner failed: %s. Setting frac to %d.\n" #define MSGTR_RADIO_NotRadioDevice "[radio] %s is no radio device!\n" -#define MSGTR_RADIO_TunerCapLowYes "[radio] tuner is low:yes frac=%d\n" -#define MSGTR_RADIO_TunerCapLowNo "[radio] tuner is low:no frac=%d\n" #define MSGTR_RADIO_SetFreqFailed "[radio] ioctl set frequency 0x%x (%.2f) failed: %s\n" #define MSGTR_RADIO_GetFreqFailed "[radio] ioctl get frequency failed: %s\n" #define MSGTR_RADIO_SetMuteFailed "[radio] ioctl set mute failed: %s\n" @@ -2003,27 +2013,22 @@ static const char help_text[]= #define MSGTR_RADIO_DroppingFrame "\n[radio] too bad - dropping audio frame (%d bytes)!\n" #define MSGTR_RADIO_BufferEmpty "[radio] grab_audio_frame: buffer empty, waiting for %d data bytes.\n" #define MSGTR_RADIO_AudioInitFailed "[radio] audio_in_init failed: %s\n" -#define MSGTR_RADIO_AudioBuffer "[radio] Audio capture - buffer=%d bytes (block=%d bytes).\n" #define MSGTR_RADIO_AllocateBufferFailed "[radio] cannot allocate audio buffer (block=%d,buf=%d): %s\n" #define MSGTR_RADIO_CurrentFreq "[radio] Current frequency: %.2f\n" #define MSGTR_RADIO_SelectedChannel "[radio] Selected channel: %d - %s (freq: %.2f)\n" #define MSGTR_RADIO_ChangeChannelNoChannelList "[radio] Can not change channel: no channel list given.\n" #define MSGTR_RADIO_UnableOpenDevice "[radio] Unable to open '%s': %s\n" -#define MSGTR_RADIO_RadioDevice "[radio] Radio fd: %d, %s\n" #define MSGTR_RADIO_InitFracFailed "[radio] init_frac failed.\n" #define MSGTR_RADIO_WrongFreq "[radio] Wrong frequency: %.2f\n" #define MSGTR_RADIO_UsingFreq "[radio] Using frequency: %.2f.\n" #define MSGTR_RADIO_AudioInInitFailed "[radio] audio_in_init failed.\n" -#define MSGTR_RADIO_BufferString "[radio] %s: in buffer=%d dropped=%d\n" #define MSGTR_RADIO_AudioInSetupFailed "[radio] audio_in_setup call failed: %s\n" -#define MSGTR_RADIO_CaptureStarting "[radio] Starting capture stuff.\n" #define MSGTR_RADIO_ClearBufferFailed "[radio] Clearing buffer failed: %s\n" #define MSGTR_RADIO_StreamEnableCacheFailed "[radio] Call to stream_enable_cache failed: %s\n" #define MSGTR_RADIO_DriverUnknownStr "[radio] Unknown driver name: %s\n" #define MSGTR_RADIO_DriverV4L2 "[radio] Using V4Lv2 radio interface.\n" #define MSGTR_RADIO_DriverV4L "[radio] Using V4Lv1 radio interface.\n" #define MSGTR_RADIO_DriverBSDBT848 "[radio] Using *BSD BT848 radio interface.\n" -#define MSGTR_RADIO_AvailableDrivers "[radio] Available drivers: " //tv.c #define MSGTR_TV_BogusNormParameter "tv.c: norm_from_string(%s): Bogus norm parameter, setting %s.\n" @@ -2035,30 +2040,23 @@ static const char help_text[]= " be ignored! You should try again with YV12 (which is the default\n"\ " colorspace) and read the documentation!\n"\ "==================================================================\n" -#define MSGTR_TV_SelectedNormId "Selected norm id: %d\n" -#define MSGTR_TV_SelectedNorm "Selected norm : %s\n" #define MSGTR_TV_CannotSetNorm "Error: Cannot set norm!\n" #define MSGTR_TV_MJP_WidthHeight " MJP: width %d height %d\n" #define MSGTR_TV_UnableToSetWidth "Unable to set requested width: %d\n" #define MSGTR_TV_UnableToSetHeight "Unable to set requested height: %d\n" #define MSGTR_TV_NoTuner "Selected input hasn't got a tuner!\n" #define MSGTR_TV_UnableFindChanlist "Unable to find selected channel list! (%s)\n" -#define MSGTR_TV_SelectedChanlist "Selected channel list: %s (including %d channels)\n" #define MSGTR_TV_ChannelFreqParamConflict "You can't set frequency and channel simultaneously!\n" #define MSGTR_TV_ChannelNamesDetected "TV channel names detected.\n" #define MSGTR_TV_NoFreqForChannel "Couldn't find frequency for channel %s (%s)\n" #define MSGTR_TV_SelectedChannel3 "Selected channel: %s - %s (freq: %.3f)\n" #define MSGTR_TV_SelectedChannel2 "Selected channel: %s (freq: %.3f)\n" -#define MSGTR_TV_SelectedFrequency "Selected frequency: %lu (%.3f)\n" -#define MSGTR_TV_RequestedChannel "Requested channel: %s\n" #define MSGTR_TV_UnsupportedAudioType "Audio type '%s (%x)' unsupported!\n" -#define MSGTR_TV_AudioFormat " TV audio: %d channels, %d bits, %d Hz\n" #define MSGTR_TV_AvailableDrivers "Available drivers:\n" #define MSGTR_TV_DriverInfo "Selected driver: %s\n name: %s\n author: %s\n comment: %s\n" #define MSGTR_TV_NoSuchDriver "No such driver: %s\n" #define MSGTR_TV_DriverAutoDetectionFailed "TV driver autodetection failed.\n" #define MSGTR_TV_UnknownColorOption "Unknown color option (%d) specified!\n" -#define MSGTR_TV_CurrentFrequency "Current frequency: %lu (%.3f)\n" #define MSGTR_TV_NoTeletext "No teletext" #define MSGTR_TV_Bt848IoctlFailed "tvi_bsdbt848: Call to %s ioctl failed. Error: %s\n" #define MSGTR_TV_Bt848InvalidAudioRate "tvi_bsdbt848: Invalid audio rate. Error: %s\n" @@ -2086,14 +2084,7 @@ static const char help_text[]= #define MSGTR_TVI_DS_DeviceNotFound "tvi_dshow: Device #%d not found\n" #define MSGTR_TVI_DS_UnableGetDeviceName "tvi_dshow: Unable to get name for device #%d\n" #define MSGTR_TVI_DS_UsingDevice "tvi_dshow: Using device #%d: %s\n" -#define MSGTR_TVI_DS_DeviceName "tvi_dshow: Device #%d: %s\n" #define MSGTR_TVI_DS_DirectGetFreqFailed "tvi_dshow: Unable to get frequency directly. OS built-in channels table will be used.\n" -#define MSGTR_TVI_DS_DirectSetFreqFailed "tvi_dshow: Unable to set frequency directly. OS built-in channels table will be used.\n" -#define MSGTR_TVI_DS_SupportedNorms "tvi_dshow: supported norms:" -#define MSGTR_TVI_DS_AvailableVideoInputs "tvi_dshow: available video inputs:" -#define MSGTR_TVI_DS_AvailableAudioInputs "tvi_dshow: available audio inputs:" -//following phrase will be printed near the selected audio/video input -#define MSGTR_TVI_DS_InputSelected "(selected)" #define MSGTR_TVI_DS_UnableExtractFreqTable "tvi_dshow: Unable to load frequency table from kstvtune.ax\n" #define MSGTR_TVI_DS_WrongDeviceParam "tvi_dshow: Wrong device parameter: %s\n" #define MSGTR_TVI_DS_WrongDeviceIndex "tvi_dshow: Wrong device index: %d\n" @@ -2105,7 +2096,6 @@ static const char help_text[]= #define MSGTR_TVI_DS_ChangingWidthHeightNotSupported "tvi_dshow: Changing video width/height is not supported by device.\n" #define MSGTR_TVI_DS_SelectingInputNotSupported "tvi_dshow: Selection of capture source is not supported by device\n" -#define MSGTR_TVI_DS_FreqTableLoaded "tvi_dshow: loaded system (%s) frequency table for country id=%d (channels:%d).\n" #define MSGTR_TVI_DS_ErrorParsingAudioFormatStruct "tvi_dshow: Unable to parse audio format structure.\n" #define MSGTR_TVI_DS_ErrorParsingVideoFormatStruct "tvi_dshow: Unable to parse video format structure.\n" #define MSGTR_TVI_DS_UnableSetAudioMode "tvi_dshow: Unable to set audio mode %d. Error:0x%x\n" diff --git a/libavfilter/libmpcodecs/img_format.c b/libavfilter/libmpcodecs/img_format.c index 380f3b0328..61bf898801 100644 --- a/libavfilter/libmpcodecs/img_format.c +++ b/libavfilter/libmpcodecs/img_format.c @@ -19,53 +19,88 @@ #include "config.h" #include "img_format.h" #include "stdio.h" +#include "libavutil/bswap.h" const char *ff_vo_format_name(int format) { static char unknown_format[20]; switch(format) { - case IMGFMT_RGB1: return "RGB 1-bit"; - case IMGFMT_RGB4: return "RGB 4-bit"; - case IMGFMT_RG4B: return "RGB 4-bit per byte"; - case IMGFMT_RGB8: return "RGB 8-bit"; - case IMGFMT_RGB12: return "RGB 12-bit"; - case IMGFMT_RGB15: return "RGB 15-bit"; - case IMGFMT_RGB16: return "RGB 16-bit"; - case IMGFMT_RGB24: return "RGB 24-bit"; -// case IMGFMT_RGB32: return "RGB 32-bit"; + case IMGFMT_RGB1: return "RGB 1-bit"; + case IMGFMT_RGB4: return "RGB 4-bit"; + case IMGFMT_RG4B: return "RGB 4-bit per byte"; + case IMGFMT_RGB8: return "RGB 8-bit"; + case IMGFMT_RGB12: return "RGB 12-bit"; + case IMGFMT_RGB15: return "RGB 15-bit"; + case IMGFMT_RGB16: return "RGB 16-bit"; + case IMGFMT_RGB24: return "RGB 24-bit"; +// case IMGFMT_RGB32: return "RGB 32-bit"; case IMGFMT_RGB48LE: return "RGB 48-bit LE"; case IMGFMT_RGB48BE: return "RGB 48-bit BE"; - case IMGFMT_BGR1: return "BGR 1-bit"; - case IMGFMT_BGR4: return "BGR 4-bit"; - case IMGFMT_BG4B: return "BGR 4-bit per byte"; - case IMGFMT_BGR8: return "BGR 8-bit"; - case IMGFMT_BGR12: return "BGR 12-bit"; - case IMGFMT_BGR15: return "BGR 15-bit"; - case IMGFMT_BGR16: return "BGR 16-bit"; - case IMGFMT_BGR24: return "BGR 24-bit"; -// case IMGFMT_BGR32: return "BGR 32-bit"; - case IMGFMT_ABGR: return "ABGR"; - case IMGFMT_BGRA: return "BGRA"; - case IMGFMT_ARGB: return "ARGB"; - case IMGFMT_RGBA: return "RGBA"; - case IMGFMT_YVU9: return "Planar YVU9"; - case IMGFMT_IF09: return "Planar IF09"; - case IMGFMT_YV12: return "Planar YV12"; - case IMGFMT_I420: return "Planar I420"; - case IMGFMT_IYUV: return "Planar IYUV"; - case IMGFMT_CLPL: return "Planar CLPL"; - case IMGFMT_Y800: return "Planar Y800"; - case IMGFMT_Y8: return "Planar Y8"; + case IMGFMT_RGB64LE: return "RGB 64-bit LE"; + case IMGFMT_RGB64BE: return "RGB 64-bit BE"; + case IMGFMT_BGR1: return "BGR 1-bit"; + case IMGFMT_BGR4: return "BGR 4-bit"; + case IMGFMT_BG4B: return "BGR 4-bit per byte"; + case IMGFMT_BGR8: return "BGR 8-bit"; + case IMGFMT_BGR12: return "BGR 12-bit"; + case IMGFMT_BGR15: return "BGR 15-bit"; + case IMGFMT_BGR16: return "BGR 16-bit"; + case IMGFMT_BGR24: return "BGR 24-bit"; +// case IMGFMT_BGR32: return "BGR 32-bit"; + case IMGFMT_ABGR: return "ABGR"; + case IMGFMT_BGRA: return "BGRA"; + case IMGFMT_ARGB: return "ARGB"; + case IMGFMT_RGBA: return "RGBA"; + case IMGFMT_GBR24P: return "Planar GBR 24-bit"; + case IMGFMT_GBR12P: return "Planar GBR 36-bit"; + case IMGFMT_GBR14P: return "Planar GBR 42-bit"; + case IMGFMT_YVU9: return "Planar YVU9"; + case IMGFMT_IF09: return "Planar IF09"; + case IMGFMT_YV12: return "Planar YV12"; + case IMGFMT_I420: return "Planar I420"; + case IMGFMT_IYUV: return "Planar IYUV"; + case IMGFMT_CLPL: return "Planar CLPL"; + case IMGFMT_Y800: return "Planar Y800"; + case IMGFMT_Y8: return "Planar Y8"; + case IMGFMT_Y8A: return "Planar Y8 with alpha"; + case IMGFMT_Y16_LE: return "Planar Y16 little-endian"; + case IMGFMT_Y16_BE: return "Planar Y16 big-endian"; case IMGFMT_420P16_LE: return "Planar 420P 16-bit little-endian"; case IMGFMT_420P16_BE: return "Planar 420P 16-bit big-endian"; + case IMGFMT_420P14_LE: return "Planar 420P 14-bit little-endian"; + case IMGFMT_420P14_BE: return "Planar 420P 14-bit big-endian"; + case IMGFMT_420P12_LE: return "Planar 420P 12-bit little-endian"; + case IMGFMT_420P12_BE: return "Planar 420P 12-bit big-endian"; + case IMGFMT_420P10_LE: return "Planar 420P 10-bit little-endian"; + case IMGFMT_420P10_BE: return "Planar 420P 10-bit big-endian"; + case IMGFMT_420P9_LE: return "Planar 420P 9-bit little-endian"; + case IMGFMT_420P9_BE: return "Planar 420P 9-bit big-endian"; case IMGFMT_422P16_LE: return "Planar 422P 16-bit little-endian"; case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian"; + case IMGFMT_422P14_LE: return "Planar 422P 14-bit little-endian"; + case IMGFMT_422P14_BE: return "Planar 422P 14-bit big-endian"; + case IMGFMT_422P12_LE: return "Planar 422P 12-bit little-endian"; + case IMGFMT_422P12_BE: return "Planar 422P 12-bit big-endian"; + case IMGFMT_422P10_LE: return "Planar 422P 10-bit little-endian"; + case IMGFMT_422P10_BE: return "Planar 422P 10-bit big-endian"; + case IMGFMT_422P9_LE: return "Planar 422P 9-bit little-endian"; + case IMGFMT_422P9_BE: return "Planar 422P 9-bit big-endian"; case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian"; case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian"; + case IMGFMT_444P14_LE: return "Planar 444P 14-bit little-endian"; + case IMGFMT_444P14_BE: return "Planar 444P 14-bit big-endian"; + case IMGFMT_444P12_LE: return "Planar 444P 12-bit little-endian"; + case IMGFMT_444P12_BE: return "Planar 444P 12-bit big-endian"; + case IMGFMT_444P10_LE: return "Planar 444P 10-bit little-endian"; + case IMGFMT_444P10_BE: return "Planar 444P 10-bit big-endian"; + case IMGFMT_444P9_LE: return "Planar 444P 9-bit little-endian"; + case IMGFMT_444P9_BE: return "Planar 444P 9-bit big-endian"; case IMGFMT_420A: return "Planar 420P with alpha"; case IMGFMT_444P: return "Planar 444P"; + case IMGFMT_444A: return "Planar 444P with alpha"; case IMGFMT_422P: return "Planar 422P"; + case IMGFMT_422A: return "Planar 422P with alpha"; case IMGFMT_411P: return "Planar 411P"; case IMGFMT_NV12: return "Planar NV12"; case IMGFMT_NV21: return "Planar NV21"; @@ -90,33 +125,82 @@ const char *ff_vo_format_name(int format) case IMGFMT_CLJR: return "Packed CLJR"; case IMGFMT_YUVP: return "Packed YUVP"; case IMGFMT_UYVP: return "Packed UYVP"; - case IMGFMT_MPEGPES: return "Mpeg PES"; - case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced"; - case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first"; - case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; + case IMGFMT_MPEGPES: return "Mpeg PES"; + case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced"; + case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first"; + case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation"; case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT"; - case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; - case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; - case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; - case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; - case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration"; - case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; + case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; + case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration"; + case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration"; } snprintf(unknown_format,20,"Unknown 0x%04x",format); return unknown_format; } -int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift) +int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits) { int xs = 0, ys = 0; int bpp; - int bpp_factor = 1; int err = 0; - switch (format) { - case IMGFMT_420P16_LE: - case IMGFMT_420P16_BE: - bpp_factor = 2; + int bits = 8; + if ((format & 0xff0000f0) == 0x34000050) + format = av_bswap32(format); + if ((format & 0xf00000ff) == 0x50000034) { + switch (format >> 24) { + case 0x50: + break; + case 0x51: + bits = 16; + break; + case 0x52: + bits = 10; + break; + case 0x53: + bits = 9; + break; + default: + err = 1; + break; + } + switch (format & 0x00ffffff) { + case 0x00343434: // 444 + xs = 0; + ys = 0; + break; + case 0x00323234: // 422 + xs = 1; + ys = 0; + break; + case 0x00303234: // 420 + xs = 1; + ys = 1; + break; + case 0x00313134: // 411 + xs = 2; + ys = 0; + break; + case 0x00303434: // 440 + xs = 0; + ys = 1; + break; + default: + err = 1; + break; + } + } else switch (format) { + case IMGFMT_444A: + xs = 0; + ys = 0; + break; + case IMGFMT_422A: + xs = 1; + ys = 0; + break; case IMGFMT_420A: case IMGFMT_I420: case IMGFMT_IYUV: @@ -129,28 +213,6 @@ int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift) xs = 2; ys = 2; break; - case IMGFMT_444P16_LE: - case IMGFMT_444P16_BE: - bpp_factor = 2; - case IMGFMT_444P: - xs = 0; - ys = 0; - break; - case IMGFMT_422P16_LE: - case IMGFMT_422P16_BE: - bpp_factor = 2; - case IMGFMT_422P: - xs = 1; - ys = 0; - break; - case IMGFMT_411P: - xs = 2; - ys = 0; - break; - case IMGFMT_440P: - xs = 0; - ys = 1; - break; case IMGFMT_Y8: case IMGFMT_Y800: xs = 31; @@ -162,9 +224,10 @@ int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift) } if (x_shift) *x_shift = xs; if (y_shift) *y_shift = ys; + if (component_bits) *component_bits = bits; bpp = 8 + ((16 >> xs) >> ys); - if (format == IMGFMT_420A) + if (format == IMGFMT_420A || format == IMGFMT_422A || format == IMGFMT_444A) bpp += 8; - bpp *= bpp_factor; + bpp *= (bits + 7) >> 3; return err ? 0 : bpp; } diff --git a/libavfilter/libmpcodecs/img_format.h b/libavfilter/libmpcodecs/img_format.h index 6f972b560d..d4d64d8d35 100644 --- a/libavfilter/libmpcodecs/img_format.h +++ b/libavfilter/libmpcodecs/img_format.h @@ -36,55 +36,69 @@ #define IMGFMT_RGB32 (IMGFMT_RGB|32) #define IMGFMT_RGB48LE (IMGFMT_RGB|48) #define IMGFMT_RGB48BE (IMGFMT_RGB|48|128) +#define IMGFMT_RGB64LE (IMGFMT_RGB|64) +#define IMGFMT_RGB64BE (IMGFMT_RGB|64|128) #define IMGFMT_BGR_MASK 0xFFFFFF00 #define IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8)) -#define IMGFMT_BGR1 (IMGFMT_BGR|1) -#define IMGFMT_BGR4 (IMGFMT_BGR|4) +#define IMGFMT_BGR1 (IMGFMT_BGR|1) +#define IMGFMT_BGR4 (IMGFMT_BGR|4) #define IMGFMT_BGR4_CHAR (IMGFMT_BGR|4|128) // BGR4 with 1 pixel per byte -#define IMGFMT_BGR8 (IMGFMT_BGR|8) +#define IMGFMT_BGR8 (IMGFMT_BGR|8) #define IMGFMT_BGR12 (IMGFMT_BGR|12) #define IMGFMT_BGR15 (IMGFMT_BGR|15) #define IMGFMT_BGR16 (IMGFMT_BGR|16) #define IMGFMT_BGR24 (IMGFMT_BGR|24) #define IMGFMT_BGR32 (IMGFMT_BGR|32) +#define IMGFMT_GBR24P (('G'<<24)|('B'<<16)|('R'<<8)|24) +#define IMGFMT_GBR12PLE (('G'<<24)|('B'<<16)|('R'<<8)|36) +#define IMGFMT_GBR12PBE (('G'<<24)|('B'<<16)|('R'<<8)|36|128) +#define IMGFMT_GBR14PLE (('G'<<24)|('B'<<16)|('R'<<8)|42) +#define IMGFMT_GBR14PBE (('G'<<24)|('B'<<16)|('R'<<8)|42|128) + #if HAVE_BIGENDIAN -#define IMGFMT_ABGR IMGFMT_RGB32 -#define IMGFMT_BGRA (IMGFMT_RGB32|64) -#define IMGFMT_ARGB IMGFMT_BGR32 -#define IMGFMT_RGBA (IMGFMT_BGR32|64) +#define IMGFMT_ABGR IMGFMT_RGB32 +#define IMGFMT_BGRA (IMGFMT_RGB32|128) +#define IMGFMT_ARGB IMGFMT_BGR32 +#define IMGFMT_RGBA (IMGFMT_BGR32|128) +#define IMGFMT_RGB64NE IMGFMT_RGB64BE #define IMGFMT_RGB48NE IMGFMT_RGB48BE #define IMGFMT_RGB12BE IMGFMT_RGB12 -#define IMGFMT_RGB12LE (IMGFMT_RGB12|64) +#define IMGFMT_RGB12LE (IMGFMT_RGB12|128) #define IMGFMT_RGB15BE IMGFMT_RGB15 -#define IMGFMT_RGB15LE (IMGFMT_RGB15|64) +#define IMGFMT_RGB15LE (IMGFMT_RGB15|128) #define IMGFMT_RGB16BE IMGFMT_RGB16 -#define IMGFMT_RGB16LE (IMGFMT_RGB16|64) +#define IMGFMT_RGB16LE (IMGFMT_RGB16|128) #define IMGFMT_BGR12BE IMGFMT_BGR12 -#define IMGFMT_BGR12LE (IMGFMT_BGR12|64) +#define IMGFMT_BGR12LE (IMGFMT_BGR12|128) #define IMGFMT_BGR15BE IMGFMT_BGR15 -#define IMGFMT_BGR15LE (IMGFMT_BGR15|64) +#define IMGFMT_BGR15LE (IMGFMT_BGR15|128) #define IMGFMT_BGR16BE IMGFMT_BGR16 -#define IMGFMT_BGR16LE (IMGFMT_BGR16|64) +#define IMGFMT_BGR16LE (IMGFMT_BGR16|128) +#define IMGFMT_GBR12P IMGFMT_GBR12PBE +#define IMGFMT_GBR14P IMGFMT_GBR14PBE #else -#define IMGFMT_ABGR (IMGFMT_BGR32|64) +#define IMGFMT_ABGR (IMGFMT_BGR32|128) #define IMGFMT_BGRA IMGFMT_BGR32 -#define IMGFMT_ARGB (IMGFMT_RGB32|64) +#define IMGFMT_ARGB (IMGFMT_RGB32|128) #define IMGFMT_RGBA IMGFMT_RGB32 +#define IMGFMT_RGB64NE IMGFMT_RGB64LE #define IMGFMT_RGB48NE IMGFMT_RGB48LE -#define IMGFMT_RGB12BE (IMGFMT_RGB12|64) +#define IMGFMT_RGB12BE (IMGFMT_RGB12|128) #define IMGFMT_RGB12LE IMGFMT_RGB12 -#define IMGFMT_RGB15BE (IMGFMT_RGB15|64) +#define IMGFMT_RGB15BE (IMGFMT_RGB15|128) #define IMGFMT_RGB15LE IMGFMT_RGB15 -#define IMGFMT_RGB16BE (IMGFMT_RGB16|64) +#define IMGFMT_RGB16BE (IMGFMT_RGB16|128) #define IMGFMT_RGB16LE IMGFMT_RGB16 -#define IMGFMT_BGR12BE (IMGFMT_BGR12|64) +#define IMGFMT_BGR12BE (IMGFMT_BGR12|128) #define IMGFMT_BGR12LE IMGFMT_BGR12 -#define IMGFMT_BGR15BE (IMGFMT_BGR15|64) +#define IMGFMT_BGR15BE (IMGFMT_BGR15|128) #define IMGFMT_BGR15LE IMGFMT_BGR15 -#define IMGFMT_BGR16BE (IMGFMT_BGR16|64) +#define IMGFMT_BGR16BE (IMGFMT_BGR16|128) #define IMGFMT_BGR16LE IMGFMT_BGR16 +#define IMGFMT_GBR12P IMGFMT_GBR12PLE +#define IMGFMT_GBR14P IMGFMT_GBR14PLE #endif /* old names for compatibility */ @@ -94,8 +108,8 @@ #define IMGFMT_IS_RGB(fmt) (((fmt)&IMGFMT_RGB_MASK)==IMGFMT_RGB) #define IMGFMT_IS_BGR(fmt) (((fmt)&IMGFMT_BGR_MASK)==IMGFMT_BGR) -#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&0x3F) -#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x3F) +#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&0x7F) +#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x7F) /* Planar YUV Formats */ @@ -110,6 +124,7 @@ #define IMGFMT_Y8 0x20203859 #define IMGFMT_NV12 0x3231564E #define IMGFMT_NV21 0x3132564E +#define IMGFMT_Y16_LE 0x20363159 /* unofficial Planar Formats, FIXME if official 4CC exists */ #define IMGFMT_444P 0x50343434 @@ -117,53 +132,123 @@ #define IMGFMT_411P 0x50313134 #define IMGFMT_440P 0x50303434 #define IMGFMT_HM12 0x32314D48 +#define IMGFMT_Y16_BE 0x59313620 +// Gray with alpha +#define IMGFMT_Y8A 0x59320008 // 4:2:0 planar with alpha #define IMGFMT_420A 0x41303234 +// 4:2:2 planar with alpha +#define IMGFMT_422A 0x41323234 +// 4:4:4 planar with alpha +#define IMGFMT_444A 0x41343434 #define IMGFMT_444P16_LE 0x51343434 #define IMGFMT_444P16_BE 0x34343451 +#define IMGFMT_444P14_LE 0x54343434 +#define IMGFMT_444P14_BE 0x34343454 +#define IMGFMT_444P12_LE 0x55343434 +#define IMGFMT_444P12_BE 0x34343455 +#define IMGFMT_444P10_LE 0x52343434 +#define IMGFMT_444P10_BE 0x34343452 +#define IMGFMT_444P9_LE 0x53343434 +#define IMGFMT_444P9_BE 0x34343453 #define IMGFMT_422P16_LE 0x51323234 #define IMGFMT_422P16_BE 0x34323251 +#define IMGFMT_422P14_LE 0x54323234 +#define IMGFMT_422P14_BE 0x34323254 +#define IMGFMT_422P12_LE 0x55323234 +#define IMGFMT_422P12_BE 0x34323255 +#define IMGFMT_422P10_LE 0x52323234 +#define IMGFMT_422P10_BE 0x34323252 +#define IMGFMT_422P9_LE 0x53323234 +#define IMGFMT_422P9_BE 0x34323253 #define IMGFMT_420P16_LE 0x51303234 #define IMGFMT_420P16_BE 0x34323051 +#define IMGFMT_420P14_LE 0x54303234 +#define IMGFMT_420P14_BE 0x34323054 +#define IMGFMT_420P12_LE 0x55303234 +#define IMGFMT_420P12_BE 0x34323055 +#define IMGFMT_420P10_LE 0x52303234 +#define IMGFMT_420P10_BE 0x34323052 +#define IMGFMT_420P9_LE 0x53303234 +#define IMGFMT_420P9_BE 0x34323053 #if HAVE_BIGENDIAN #define IMGFMT_444P16 IMGFMT_444P16_BE +#define IMGFMT_444P14 IMGFMT_444P14_BE +#define IMGFMT_444P12 IMGFMT_444P12_BE +#define IMGFMT_444P10 IMGFMT_444P10_BE +#define IMGFMT_444P9 IMGFMT_444P9_BE #define IMGFMT_422P16 IMGFMT_422P16_BE +#define IMGFMT_422P14 IMGFMT_422P14_BE +#define IMGFMT_422P12 IMGFMT_422P12_BE +#define IMGFMT_422P10 IMGFMT_422P10_BE +#define IMGFMT_422P9 IMGFMT_422P9_BE #define IMGFMT_420P16 IMGFMT_420P16_BE +#define IMGFMT_420P14 IMGFMT_420P14_BE +#define IMGFMT_420P12 IMGFMT_420P12_BE +#define IMGFMT_420P10 IMGFMT_420P10_BE +#define IMGFMT_420P9 IMGFMT_420P9_BE +#define IMGFMT_Y16 IMGFMT_Y16_BE +#define IMGFMT_IS_YUVP16_NE(fmt) IMGFMT_IS_YUVP16_BE(fmt) #else #define IMGFMT_444P16 IMGFMT_444P16_LE +#define IMGFMT_444P14 IMGFMT_444P14_LE +#define IMGFMT_444P12 IMGFMT_444P12_LE +#define IMGFMT_444P10 IMGFMT_444P10_LE +#define IMGFMT_444P9 IMGFMT_444P9_LE #define IMGFMT_422P16 IMGFMT_422P16_LE +#define IMGFMT_422P14 IMGFMT_422P14_LE +#define IMGFMT_422P12 IMGFMT_422P12_LE +#define IMGFMT_422P10 IMGFMT_422P10_LE +#define IMGFMT_422P9 IMGFMT_422P9_LE #define IMGFMT_420P16 IMGFMT_420P16_LE +#define IMGFMT_420P14 IMGFMT_420P14_LE +#define IMGFMT_420P12 IMGFMT_420P12_LE +#define IMGFMT_420P10 IMGFMT_420P10_LE +#define IMGFMT_420P9 IMGFMT_420P9_LE +#define IMGFMT_Y16 IMGFMT_Y16_LE +#define IMGFMT_IS_YUVP16_NE(fmt) IMGFMT_IS_YUVP16_LE(fmt) #endif -#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt ^ IMGFMT_420P16_LE) & 0xff0000ff) == 0) -#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt ^ IMGFMT_420P16_BE) & 0xff0000ff) == 0) -#define IMGFMT_IS_YUVP16_NE(fmt) (((fmt ^ IMGFMT_420P16 ) & 0xff0000ff) == 0) +#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt - 0x51000034) & 0xfc0000ff) == 0) +#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000fc) == 0) #define IMGFMT_IS_YUVP16(fmt) (IMGFMT_IS_YUVP16_LE(fmt) || IMGFMT_IS_YUVP16_BE(fmt)) +/** + * \brief Find the corresponding full 16 bit format, i.e. IMGFMT_420P10_LE -> IMGFMT_420P16_LE + * \return normalized format ID or 0 if none exists. + */ +static inline int normalize_yuvp16(int fmt) { + if (IMGFMT_IS_YUVP16_LE(fmt)) + return (fmt & 0x00ffffff) | 0x51000000; + if (IMGFMT_IS_YUVP16_BE(fmt)) + return (fmt & 0xffffff00) | 0x00000051; + return 0; +} + /* Packed YUV Formats */ -#define IMGFMT_IUYV 0x56595549 -#define IMGFMT_IY41 0x31435949 +#define IMGFMT_IUYV 0x56595549 // Interlaced UYVY +#define IMGFMT_IY41 0x31435949 // Interlaced Y41P #define IMGFMT_IYU1 0x31555949 #define IMGFMT_IYU2 0x32555949 #define IMGFMT_UYVY 0x59565955 -#define IMGFMT_UYNV 0x564E5955 -#define IMGFMT_cyuv 0x76757963 -#define IMGFMT_Y422 0x32323459 +#define IMGFMT_UYNV 0x564E5955 // Exactly same as UYVY +#define IMGFMT_cyuv 0x76757963 // upside-down UYVY +#define IMGFMT_Y422 0x32323459 // Exactly same as UYVY #define IMGFMT_YUY2 0x32595559 -#define IMGFMT_YUNV 0x564E5559 +#define IMGFMT_YUNV 0x564E5559 // Exactly same as YUY2 #define IMGFMT_YVYU 0x55595659 #define IMGFMT_Y41P 0x50313459 #define IMGFMT_Y211 0x31313259 -#define IMGFMT_Y41T 0x54313459 -#define IMGFMT_Y42T 0x54323459 -#define IMGFMT_V422 0x32323456 +#define IMGFMT_Y41T 0x54313459 // Y41P, Y lsb = transparency +#define IMGFMT_Y42T 0x54323459 // UYVY, Y lsb = transparency +#define IMGFMT_V422 0x32323456 // upside-down UYVY? #define IMGFMT_V655 0x35353656 #define IMGFMT_CLJR 0x524A4C43 -#define IMGFMT_YUVP 0x50565559 -#define IMGFMT_UYVP 0x50565955 +#define IMGFMT_YUVP 0x50565559 // 10-bit YUYV +#define IMGFMT_UYVP 0x50565955 // 10-bit UYVY /* Compressed Formats */ #define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S')) @@ -207,8 +292,9 @@ const char *ff_vo_format_name(int format); /** * Calculates the scale shifts for the chroma planes for planar YUV * + * \param component_bits bits per component * \return bits-per-pixel for format if successful (i.e. format is 3 or 4-planes planar YUV), 0 otherwise */ -int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift); +int ff_mp_get_chroma_shift(int format, int *x_shift, int *y_shift, int *component_bits); #endif /* MPLAYER_IMG_FORMAT_H */ diff --git a/libavfilter/libmpcodecs/mp_image.c b/libavfilter/libmpcodecs/mp_image.c index 1ef5cbd55b..33d5c07730 100644 --- a/libavfilter/libmpcodecs/mp_image.c +++ b/libavfilter/libmpcodecs/mp_image.c @@ -121,11 +121,24 @@ void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ mpi->flags|=MP_IMGFLAG_SWAPPED; return; } - mpi->flags|=MP_IMGFLAG_YUV; mpi->num_planes=3; - if (ff_mp_get_chroma_shift(out_fmt, NULL, NULL)) { + if (out_fmt == IMGFMT_GBR24P) { + mpi->bpp=24; mpi->flags|=MP_IMGFLAG_PLANAR; - mpi->bpp = ff_mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift); + return; + } else if (out_fmt == IMGFMT_GBR12P) { + mpi->bpp=36; + mpi->flags|=MP_IMGFLAG_PLANAR; + return; + } else if (out_fmt == IMGFMT_GBR14P) { + mpi->bpp=42; + mpi->flags|=MP_IMGFLAG_PLANAR; + return; + } + mpi->flags|=MP_IMGFLAG_YUV; + if (ff_mp_get_chroma_shift(out_fmt, NULL, NULL, NULL)) { + mpi->flags|=MP_IMGFLAG_PLANAR; + mpi->bpp = ff_mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift, NULL); mpi->chroma_width = mpi->width >> mpi->chroma_x_shift; mpi->chroma_height = mpi->height >> mpi->chroma_y_shift; } @@ -136,6 +149,8 @@ void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ case IMGFMT_YV12: return; case IMGFMT_420A: + case IMGFMT_422A: + case IMGFMT_444A: case IMGFMT_IF09: mpi->num_planes=4; case IMGFMT_YVU9: @@ -145,20 +160,51 @@ void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ case IMGFMT_440P: case IMGFMT_444P16_LE: case IMGFMT_444P16_BE: + case IMGFMT_444P14_LE: + case IMGFMT_444P14_BE: + case IMGFMT_444P12_LE: + case IMGFMT_444P12_BE: + case IMGFMT_444P10_LE: + case IMGFMT_444P10_BE: + case IMGFMT_444P9_LE: + case IMGFMT_444P9_BE: case IMGFMT_422P16_LE: case IMGFMT_422P16_BE: + case IMGFMT_422P14_LE: + case IMGFMT_422P14_BE: + case IMGFMT_422P12_LE: + case IMGFMT_422P12_BE: + case IMGFMT_422P10_LE: + case IMGFMT_422P10_BE: + case IMGFMT_422P9_LE: + case IMGFMT_422P9_BE: case IMGFMT_420P16_LE: case IMGFMT_420P16_BE: + case IMGFMT_420P14_LE: + case IMGFMT_420P14_BE: + case IMGFMT_420P12_LE: + case IMGFMT_420P12_BE: + case IMGFMT_420P10_LE: + case IMGFMT_420P10_BE: + case IMGFMT_420P9_LE: + case IMGFMT_420P9_BE: return; + case IMGFMT_Y16_LE: + case IMGFMT_Y16_BE: + mpi->bpp=16; case IMGFMT_Y800: case IMGFMT_Y8: /* they're planar ones, but for easier handling use them as packed */ mpi->flags&=~MP_IMGFLAG_PLANAR; mpi->num_planes=1; return; + case IMGFMT_Y8A: + mpi->num_planes=2; + return; case IMGFMT_UYVY: mpi->flags|=MP_IMGFLAG_SWAPPED; case IMGFMT_YUY2: + mpi->chroma_x_shift = 1; mpi->bpp=16; mpi->num_planes=1; return; diff --git a/libavfilter/libmpcodecs/mp_image.h b/libavfilter/libmpcodecs/mp_image.h index d658ab03f1..35b50a60f1 100644 --- a/libavfilter/libmpcodecs/mp_image.h +++ b/libavfilter/libmpcodecs/mp_image.h @@ -42,7 +42,14 @@ //--- buffer content restrictions: // set if buffer content shouldn't be modified: #define MP_IMGFLAG_PRESERVE 0x01 -// set if buffer content will be READ for next frame's MC: (I/P mpeg frames) +// set if buffer content will be READ. +// This can be e.g. for next frame's MC: (I/P mpeg frames) - +// then in combination with MP_IMGFLAG_PRESERVE - or it +// can be because a video filter or codec will read a significant +// amount of data while processing that frame (e.g. blending something +// onto the frame, MV based intra prediction). +// A frame marked like this should not be placed in to uncachable +// video RAM for example. #define MP_IMGFLAG_READABLE 0x02 //--- buffer width/stride/plane restrictions: (used for direct rendering) diff --git a/libavfilter/libmpcodecs/mp_msg.h b/libavfilter/libmpcodecs/mp_msg.h index 250bfb2752..51cdff3cef 100644 --- a/libavfilter/libmpcodecs/mp_msg.h +++ b/libavfilter/libmpcodecs/mp_msg.h @@ -148,14 +148,16 @@ void ff_mp_msg(int mod, int lev, const char *format, ... ) __attribute__ ((forma # ifdef MP_DEBUG # define mp_dbg(mod,lev, args... ) ff_mp_msg(mod, lev, ## args ) # else -# define mp_dbg(mod,lev, args... ) /* only useful for developers */ + // only useful for developers, disable but check syntax +# define mp_dbg(mod,lev, args... ) do { if (0) ff_mp_msg(mod, lev, ## args ); } while (0) # endif #else // not GNU C void ff_mp_msg(int mod, int lev, const char *format, ... ); # ifdef MP_DEBUG # define mp_dbg(mod,lev, ... ) ff_mp_msg(mod, lev, __VA_ARGS__) # else -# define mp_dbg(mod,lev, ... ) /* only useful for developers */ + // only useful for developers, disable but check syntax +# define mp_dbg(mod,lev, ... ) do { if (0) ff_mp_msg(mod, lev, __VA_ARGS__); } while (0) # endif #endif /* __GNUC__ */ diff --git a/libavfilter/libmpcodecs/pullup.c b/libavfilter/libmpcodecs/pullup.c index a28b8cfc27..b5fae9ba61 100644 --- a/libavfilter/libmpcodecs/pullup.c +++ b/libavfilter/libmpcodecs/pullup.c @@ -19,9 +19,10 @@ #include #include #include + +#include "libavutil/x86/asm.h" #include "config.h" #include "pullup.h" -#include "cpudetect.h" diff --git a/libavfilter/libmpcodecs/vf_divtc.c b/libavfilter/libmpcodecs/vf_divtc.c index 0e023f3fcf..61f6e35f09 100644 --- a/libavfilter/libmpcodecs/vf_divtc.c +++ b/libavfilter/libmpcodecs/vf_divtc.c @@ -26,6 +26,7 @@ #include "mp_msg.h" #include "cpudetect.h" #include "libavutil/common.h" +#include "libavutil/x86/asm.h" #include "mpbswap.h" #include "img_format.h" diff --git a/libavfilter/libmpcodecs/vf_filmdint.c b/libavfilter/libmpcodecs/vf_filmdint.c index db31f426e9..93354e2ec0 100644 --- a/libavfilter/libmpcodecs/vf_filmdint.c +++ b/libavfilter/libmpcodecs/vf_filmdint.c @@ -30,7 +30,7 @@ #include "vd.h" #include "vf.h" #include "cmmx.h" - +#include "libavutil/x86/asm.h" #include "libvo/fastmemcpy.h" #define NUM_STORED 4 diff --git a/libavfilter/libmpcodecs/vf_fspp.c b/libavfilter/libmpcodecs/vf_fspp.c index 6090c9aeab..a8a33e2644 100644 --- a/libavfilter/libmpcodecs/vf_fspp.c +++ b/libavfilter/libmpcodecs/vf_fspp.c @@ -45,12 +45,13 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #include "libvo/fastmemcpy.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" +#include "libavutil/x86/asm.h" #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" diff --git a/libavfilter/libmpcodecs/vf_ilpack.c b/libavfilter/libmpcodecs/vf_ilpack.c index 17d6ae4450..4db6c0a8b7 100644 --- a/libavfilter/libmpcodecs/vf_ilpack.c +++ b/libavfilter/libmpcodecs/vf_ilpack.c @@ -29,6 +29,7 @@ #include "mp_image.h" #include "vf.h" #include "libavutil/attributes.h" +#include "libavutil/x86/asm.h" typedef void (pack_func_t)(unsigned char *dst, unsigned char *y, unsigned char *u, unsigned char *v, int w, int us, int vs); diff --git a/libavfilter/libmpcodecs/vf_ivtc.c b/libavfilter/libmpcodecs/vf_ivtc.c index 2418358a3b..8a47a57748 100644 --- a/libavfilter/libmpcodecs/vf_ivtc.c +++ b/libavfilter/libmpcodecs/vf_ivtc.c @@ -27,7 +27,7 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" - +#include "libavutil/x86/asm.h" #include "libvo/fastmemcpy.h" diff --git a/libavfilter/libmpcodecs/vf_mcdeint.c b/libavfilter/libmpcodecs/vf_mcdeint.c index 6ae255dde3..b9ffaf21ca 100644 --- a/libavfilter/libmpcodecs/vf_mcdeint.c +++ b/libavfilter/libmpcodecs/vf_mcdeint.c @@ -54,6 +54,7 @@ Known Issues: #include "mp_msg.h" #include "cpudetect.h" +#include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/avcodec.h" @@ -66,7 +67,7 @@ Known Issues: #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #define MIN(a,b) ((a) > (b) ? (b) : (a)) #define MAX(a,b) ((a) < (b) ? (b) : (a)) @@ -186,6 +187,7 @@ static int config(struct vf_instance *vf, for(i=0; i<3; i++){ AVCodecContext *avctx_enc; + AVDictionary *opts = NULL; #if 0 int is_chroma= !!i; int w= ((width + 31) & (~31))>>is_chroma; @@ -196,7 +198,7 @@ static int config(struct vf_instance *vf, vf->priv->src [i]= malloc(vf->priv->temp_stride[i]*h*sizeof(uint8_t)); #endif avctx_enc= - vf->priv->avctx_enc= avcodec_alloc_context(); + vf->priv->avctx_enc= avcodec_alloc_context3(enc); avctx_enc->width = width; avctx_enc->height = height; avctx_enc->time_base= (AVRational){1,25}; // meaningless @@ -206,7 +208,7 @@ static int config(struct vf_instance *vf, avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 1; - avctx_enc->flags2= CODEC_FLAG2_MEMC_ONLY; + av_dict_set(&opts, "memc_only", "1", 0); avctx_enc->me_cmp= avctx_enc->me_sub_cmp= FF_CMP_SAD; //SSE; avctx_enc->mb_cmp= FF_CMP_SSE; @@ -224,7 +226,8 @@ static int config(struct vf_instance *vf, avctx_enc->flags |= CODEC_FLAG_QPEL; } - avcodec_open(avctx_enc, enc); + avcodec_open2(avctx_enc, enc, &opts); + av_dict_free(&opts); } vf->priv->frame= avcodec_alloc_frame(); diff --git a/libavfilter/libmpcodecs/vf_noise.c b/libavfilter/libmpcodecs/vf_noise.c index e141e6b022..3b946e99bb 100644 --- a/libavfilter/libmpcodecs/vf_noise.c +++ b/libavfilter/libmpcodecs/vf_noise.c @@ -37,6 +37,7 @@ #include "vf.h" #include "libvo/fastmemcpy.h" #include "libavutil/mem.h" +#include "libavutil/x86/asm.h" #define MAX_NOISE 4096 #define MAX_SHIFT 1024 diff --git a/libavfilter/libmpcodecs/vf_pp7.c b/libavfilter/libmpcodecs/vf_pp7.c index 14bd863525..30f95307bb 100644 --- a/libavfilter/libmpcodecs/vf_pp7.c +++ b/libavfilter/libmpcodecs/vf_pp7.c @@ -44,8 +44,6 @@ #define XMIN(a,b) ((a) < (b) ? (a) : (b)) #define XMAX(a,b) ((a) > (b) ? (a) : (b)) -typedef short int16_t; - //===========================================================================// static const uint8_t __attribute__((aligned(8))) dither[8][8]={ { 0, 48, 12, 60, 3, 51, 15, 63, }, diff --git a/libavfilter/libmpcodecs/vf_pullup.c b/libavfilter/libmpcodecs/vf_pullup.c index 1a0de7c480..e4a28c46d5 100644 --- a/libavfilter/libmpcodecs/vf_pullup.c +++ b/libavfilter/libmpcodecs/vf_pullup.c @@ -270,7 +270,10 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { - if (height&3) return 0; + if (height&3) { + ff_mp_msg(MSGT_VFILTER, MSGL_ERR, "height must be divisible by four\n"); + return 0; + } return ff_vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); } diff --git a/libavfilter/libmpcodecs/vf_qp.c b/libavfilter/libmpcodecs/vf_qp.c index e8740d0a30..579ec1c98f 100644 --- a/libavfilter/libmpcodecs/vf_qp.c +++ b/libavfilter/libmpcodecs/vf_qp.c @@ -33,6 +33,7 @@ #include "libavcodec/avcodec.h" #include "libavutil/eval.h" +#include "libavutil/mem.h" struct vf_priv_s { diff --git a/libavfilter/libmpcodecs/vf_sab.c b/libavfilter/libmpcodecs/vf_sab.c index a5ad17c5ee..2928a858d3 100644 --- a/libavfilter/libmpcodecs/vf_sab.c +++ b/libavfilter/libmpcodecs/vf_sab.c @@ -32,6 +32,7 @@ #endif #include "libavutil/avutil.h" +#include "libavutil/mem.h" #include "img_format.h" #include "mp_image.h" #include "vf.h" diff --git a/libavfilter/libmpcodecs/vf_spp.c b/libavfilter/libmpcodecs/vf_spp.c index f821374e06..75ede23ccb 100644 --- a/libavfilter/libmpcodecs/vf_spp.c +++ b/libavfilter/libmpcodecs/vf_spp.c @@ -37,6 +37,7 @@ #include "mp_msg.h" #include "cpudetect.h" +#include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/avcodec.h" @@ -49,7 +50,7 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #include "libvo/fastmemcpy.h" #define XMIN(a,b) ((a) < (b) ? (a) : (b)) @@ -578,8 +579,8 @@ static int vf_open(vf_instance_t *vf, char *args){ ff_init_avcodec(); - vf->priv->avctx= avcodec_alloc_context(); - dsputil_init(&vf->priv->dsp, vf->priv->avctx); + vf->priv->avctx= avcodec_alloc_context3(NULL); + ff_dsputil_init(&vf->priv->dsp, vf->priv->avctx); vf->priv->log2_count= 3; diff --git a/libavfilter/libmpcodecs/vf_stereo3d.c b/libavfilter/libmpcodecs/vf_stereo3d.c index 3dd1df9a66..fe75bd0cc4 100644 --- a/libavfilter/libmpcodecs/vf_stereo3d.c +++ b/libavfilter/libmpcodecs/vf_stereo3d.c @@ -43,9 +43,11 @@ typedef enum stereo_code { ANAGLYPH_GM_GRAY, //anaglyph green/magenta gray ANAGLYPH_GM_HALF, //anaglyph green/magenta half colored ANAGLYPH_GM_COLOR, //anaglyph green/magenta colored + ANAGLYPH_GM_DUBOIS, //anaglyph green/magenta dubois ANAGLYPH_YB_GRAY, //anaglyph yellow/blue gray ANAGLYPH_YB_HALF, //anaglyph yellow/blue half colored ANAGLYPH_YB_COLOR, //anaglyph yellow/blue colored + ANAGLYPH_YB_DUBOIS, //anaglyph yellow/blue dubois MONO_L, //mono output for debugging (left eye only) MONO_R, //mono output for debugging (right eye only) SIDE_BY_SIDE_LR, //side by side parallel (left eye left, right eye right) @@ -72,37 +74,55 @@ typedef struct component { } component; //==global variables==// -static const int ana_coeff[10][3][6] = { - {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_GRAY +static const int ana_coeff[][3][6] = { + [ANAGLYPH_RC_GRAY] = + {{19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 19595, 38470, 7471}, { 0, 0, 0, 19595, 38470, 7471}}, - {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_HALF + [ANAGLYPH_RC_HALF] = + {{19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 0, 65536, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{65536, 0, 0, 0, 0, 0}, //ANAGLYPH_RC_COLOR + [ANAGLYPH_RC_COLOR] = + {{65536, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 65536, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{29891, 32800, 11559, -2849, -5763, -102}, //ANAGLYPH_RC_DUBOIS + [ANAGLYPH_RC_DUBOIS] = + {{29891, 32800, 11559, -2849, -5763, -102}, {-2627, -2479, -1033, 24804, 48080, -1209}, { -997, -1350, -358, -4729, -7403, 80373}}, - {{ 0, 0, 0, 19595, 38470, 7471}, //ANAGLYPH_GM_GRAY + [ANAGLYPH_GM_GRAY] = + {{ 0, 0, 0, 19595, 38470, 7471}, {19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 19595, 38470, 7471}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_GM_HALF + [ANAGLYPH_GM_HALF] = + {{ 0, 0, 0, 65536, 0, 0}, {19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_GM_COLOR + [ANAGLYPH_GM_COLOR] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 65536, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{ 0, 0, 0, 19595, 38470, 7471}, //ANAGLYPH_YB_GRAY + [ANAGLYPH_GM_DUBOIS] = + {{-4063,-10354, -2556, 34669, 46203, 1573}, + {18612, 43778, 9372, -1049, -983, -4260}, + { -983, -1769, 1376, 590, 4915, 61407}}, + [ANAGLYPH_YB_GRAY] = + {{ 0, 0, 0, 19595, 38470, 7471}, { 0, 0, 0, 19595, 38470, 7471}, {19595, 38470, 7471, 0, 0, 0}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_YB_HALF + [ANAGLYPH_YB_HALF] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 0, 0, 0, 65536, 0}, {19595, 38470, 7471, 0, 0, 0}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_YB_COLOR + [ANAGLYPH_YB_COLOR] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 0, 0, 0, 65536, 0}, - { 0, 0, 65536, 0, 0, 0}} + { 0, 0, 65536, 0, 0, 0}}, + [ANAGLYPH_YB_DUBOIS] = + {{65535,-12650,18451, -987, -7590, -1049}, + {-1604, 56032, 4196, 370, 3826, -1049}, + {-2345,-10676, 1358, 5801, 11416, 56217}}, }; struct vf_priv_s { @@ -195,9 +215,11 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, case ANAGLYPH_GM_GRAY: case ANAGLYPH_GM_HALF: case ANAGLYPH_GM_COLOR: + case ANAGLYPH_GM_DUBOIS: case ANAGLYPH_YB_GRAY: case ANAGLYPH_YB_HALF: case ANAGLYPH_YB_COLOR: + case ANAGLYPH_YB_DUBOIS: memcpy(vf->priv->ana_matrix, ana_coeff[vf->priv->out.fmt], sizeof(vf->priv->ana_matrix)); break; @@ -322,9 +344,11 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) case ANAGLYPH_GM_GRAY: case ANAGLYPH_GM_HALF: case ANAGLYPH_GM_COLOR: + case ANAGLYPH_GM_DUBOIS: case ANAGLYPH_YB_GRAY: case ANAGLYPH_YB_HALF: - case ANAGLYPH_YB_COLOR: { + case ANAGLYPH_YB_COLOR: + case ANAGLYPH_YB_DUBOIS: { int i,x,y,il,ir,o; unsigned char *source = mpi->planes[0]; unsigned char *dest = dmpi->planes[0]; @@ -410,12 +434,16 @@ static const struct format_preset { {"anaglyph_green_magenta_half_color",ANAGLYPH_GM_HALF}, {"agmc", ANAGLYPH_GM_COLOR}, {"anaglyph_green_magenta_color", ANAGLYPH_GM_COLOR}, + {"agmd", ANAGLYPH_GM_DUBOIS}, + {"anaglyph_green_magenta_dubois", ANAGLYPH_GM_DUBOIS}, {"aybg", ANAGLYPH_YB_GRAY}, {"anaglyph_yellow_blue_gray", ANAGLYPH_YB_GRAY}, {"aybh", ANAGLYPH_YB_HALF}, {"anaglyph_yellow_blue_half_color", ANAGLYPH_YB_HALF}, {"aybc", ANAGLYPH_YB_COLOR}, {"anaglyph_yellow_blue_color", ANAGLYPH_YB_COLOR}, + {"aybd", ANAGLYPH_YB_DUBOIS}, + {"anaglyph_yellow_blue_dubois", ANAGLYPH_YB_DUBOIS}, {"ml", MONO_L}, {"mono_left", MONO_L}, {"mr", MONO_R}, diff --git a/libavfilter/libmpcodecs/vf_unsharp.c b/libavfilter/libmpcodecs/vf_unsharp.c index b947769fc2..89eddecc8b 100644 --- a/libavfilter/libmpcodecs/vf_unsharp.c +++ b/libavfilter/libmpcodecs/vf_unsharp.c @@ -165,7 +165,8 @@ static void get_image( struct vf_instance *vf, mp_image_t *mpi ) { if( mpi->imgfmt!=vf->priv->outfmt ) return; // colorspace differ - vf->dmpi = ff_vf_get_image( vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->w, mpi->h ); + mpi->priv = + vf->dmpi = ff_vf_get_image( vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->width, mpi->height ); mpi->planes[0] = vf->dmpi->planes[0]; mpi->stride[0] = vf->dmpi->stride[0]; mpi->width = vf->dmpi->width; @@ -179,12 +180,12 @@ static void get_image( struct vf_instance *vf, mp_image_t *mpi ) { } static int put_image( struct vf_instance *vf, mp_image_t *mpi, double pts) { - mp_image_t *dmpi; + mp_image_t *dmpi = mpi->priv; + mpi->priv = NULL; if( !(mpi->flags & MP_IMGFLAG_DIRECT) ) // no DR, so get a new image! hope we'll get DR buffer: - vf->dmpi = ff_vf_get_image( vf->next,vf->priv->outfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w, mpi->h); - dmpi= vf->dmpi; + dmpi = vf->dmpi = ff_vf_get_image( vf->next,vf->priv->outfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height); unsharp( dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam ); unsharp( dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam ); diff --git a/libavfilter/libmpcodecs/vf_uspp.c b/libavfilter/libmpcodecs/vf_uspp.c index 7444e03328..54cc0f9e11 100644 --- a/libavfilter/libmpcodecs/vf_uspp.c +++ b/libavfilter/libmpcodecs/vf_uspp.c @@ -30,12 +30,13 @@ #include "mp_msg.h" #include "cpudetect.h" +#include "libavutil/mem.h" #include "libavcodec/avcodec.h" #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "vd_ffmpeg.h" +#include "av_helpers.h" #include "libvo/fastmemcpy.h" #define XMIN(a,b) ((a) < (b) ? (a) : (b)) @@ -94,7 +95,9 @@ static const uint8_t offset[511][2]= { { 7, 1}, {15, 1}, { 7, 9}, {15, 9}, { 7, 3}, {15, 3}, { 7,11}, {15,11}, { 7, 5}, {15, 5}, { 7,13}, {15,13}, { 7, 7}, {15, 7}, { 7,15}, {15,15}, -{ 0, 0}, { 8, 0}, { 0, 8}, { 8, 8}, { 4, 4}, {12, 4}, { 4,12}, {12,12}, { 0, 4}, { 8, 4}, { 0,12}, { 8,12}, { 4, 0}, {12, 0}, { 4, 8}, {12, 8}, { 2, 2}, {10, 2}, { 2,10}, {10,10}, { 6, 6}, {14, 6}, { 6,14}, {14,14}, { 2, 6}, {10, 6}, { 2,14}, {10,14}, { 6, 2}, {14, 2}, { 6,10}, {14,10}, { 0, 2}, { 8, 2}, { 0,10}, { 8,10}, { 4, 6}, {12, 6}, { 4,14}, {12,14}, { 0, 6}, { 8, 6}, { 0,14}, { 8,14}, { 4, 2}, {12, 2}, { 4,10}, {12,10}, { 2, 0}, {10, 0}, { 2, 8}, {10, 8}, { 6, 4}, {14, 4}, { 6,12}, {14,12}, { 2, 4}, {10, 4}, { 2,12}, {10,12}, { 6, 0}, {14, 0}, { 6, 8}, {14, 8}, { 1, 1}, { 9, 1}, { 1, 9}, { 9, 9}, { 5, 5}, {13, 5}, { 5,13}, {13,13}, { 1, 5}, { 9, 5}, { 1,13}, { 9,13}, { 5, 1}, {13, 1}, { 5, 9}, {13, 9}, { 3, 3}, {11, 3}, { 3,11}, {11,11}, { 7, 7}, {15, 7}, { 7,15}, {15,15}, { 3, 7}, {11, 7}, { 3,15}, {11,15}, { 7, 3}, {15, 3}, { 7,11}, {15,11}, { 1, 3}, { 9, 3}, { 1,11}, { 9,11}, { 5, 7}, {13, 7}, { 5,15}, {13,15}, { 1, 7}, { 9, 7}, { 1,15}, { 9,15}, { 5, 3}, {13, 3}, { 5,11}, {13,11}, { 3, 1}, {11,1}, { 3, 9}, {11, 9}, { 7, 5}, {15, 5}, { 7,13}, {15,13}, { 3, 5}, {11, 5}, { 3,13}, {11,13}, { 7, 1}, {15, 1}, { 7, 9}, {15, 9}, { 0, 1}, { 8, 1}, { 0, 9}, { 8, 9}, { 4, 5}, {12, 5}, { 4,13}, {12,13}, { 0, 5}, { 8, 5}, { 0,13}, { 8,13}, { 4, 1}, {12, 1}, { 4, 9}, {12, 9}, { 2, 3}, {10, 3}, { 2,11}, {10,11}, { 6, 7}, {14, 7}, { 6,15}, {14,15}, { 2, 7}, {10, 7}, { 2,15}, {10,15}, { 6, 3}, {14, 3}, { 6,11}, {14,11}, { 0, 3}, { 8, 3}, { 0,11}, { 8,11}, { 4, 7}, {12, 7}, { 4,15}, {12,15}, { 0, 7}, { 8, 7}, { 0,15}, { 8,15}, { 4, 3}, {12, 3}, { 4,11}, {12,11}, { 2, 1}, {10, 1}, { 2, 9}, {10, 9}, { 6, 5}, {14, 5}, { 6,13}, {14,13}, { 2, 5}, {10, 5}, { 2,13}, {10,13}, { 6, 1}, {14, 1}, { 6, 9}, {14, 9}, { 1, 0}, { 9, 0}, { 1, 8}, { 9, 8}, { 5, 4}, {13, 4}, { 5,12}, {13,12}, { 1, 4}, { 9, 4}, { 1,12}, { 9,12}, { 5, 0}, {13, 0}, { 5, 8}, {13, 8}, { 3, 2}, {11, 2}, { 3,10}, {11,10}, { 7, 6}, {15, 6}, { 7,14}, {15,14}, { 3, 6}, {11, 6}, { 3,14}, {11,14}, { 7, 2}, {15, 2}, { 7,10}, {15,10}, { 1, 2}, { 9, 2}, { 1,10}, {9,10}, { 5, 6}, {13, 6}, { 5,14}, {13,14}, { 1, 6}, { 9, 6}, { 1,14}, { 9,14}, { 5, 2}, {13, 2}, { 5,10}, {13,10}, { 3, 0}, {11, 0}, { 3, 8}, {11, 8}, { 7, 4}, {15, 4}, { 7,12}, {15,12}, { 3, 4}, {11, 4}, { 3,12}, {11,12}, { 7, 0}, {15, 0}, { 7, 8}, {15, 8}, +{ 0, 0}, { 8, 0}, { 0, 8}, { 8, 8}, { 4, 4}, {12, 4}, { 4,12}, {12,12}, { 0, 4}, { 8, 4}, { 0,12}, { 8,12}, { 4, 0}, {12, 0}, { 4, 8}, {12, 8}, { 2, 2}, {10, 2}, { 2,10}, {10,10}, { 6, 6}, {14, 6}, { 6,14}, {14,14}, { 2, 6}, {10, 6}, { 2,14}, {10,14}, { 6, 2}, {14, 2}, { 6,10}, {14,10}, { 0, 2}, { 8, 2}, { 0,10}, { 8,10}, { 4, 6}, {12, 6}, { 4,14}, {12,14}, { 0, 6}, { 8, 6}, { 0,14}, { 8,14}, { 4, 2}, {12, 2}, { 4,10}, {12,10}, { 2, 0}, {10, 0}, { 2, 8}, {10, 8}, { 6, 4}, {14, 4}, { 6,12}, {14,12}, { 2, 4}, {10, 4}, { 2,12}, {10,12}, { 6, 0}, {14, 0}, { 6, 8}, {14, 8}, { 1, 1}, { 9, 1}, { 1, 9}, { 9, 9}, { 5, 5}, {13, 5}, { 5,13}, {13,13}, { 1, 5}, { 9, 5}, { 1,13}, { 9,13}, { 5, 1}, {13, 1}, { 5, 9}, {13, 9}, { 3, 3}, {11, 3}, { 3,11}, {11,11}, { 7, 7}, {15, 7}, { 7,15}, {15,15}, { 3, 7}, {11, 7}, { 3,15}, {11,15}, { 7, 3}, {15, 3}, { 7,11}, {15,11}, { 1, 3}, { 9, 3}, { 1,11}, { 9,11}, { 5, 7}, {13, 7}, { 5,15}, {13,15}, { 1, 7}, { 9, 7}, { 1,15}, { 9,15}, { 5, 3}, {13, 3}, { 5,11}, {13,11}, { 3, 1}, {11, 1} +, { 3, 9}, {11, 9}, { 7, 5}, {15, 5}, { 7,13}, {15,13}, { 3, 5}, {11, 5}, { 3,13}, {11,13}, { 7, 1}, {15, 1}, { 7, 9}, {15, 9}, { 0, 1}, { 8, 1}, { 0, 9}, { 8, 9}, { 4, 5}, {12, 5}, { 4,13}, {12,13}, { 0, 5}, { 8, 5}, { 0,13}, { 8,13}, { 4, 1}, {12, 1}, { 4, 9}, {12, 9}, { 2, 3}, {10, 3}, { 2,11}, {10,11}, { 6, 7}, {14, 7}, { 6,15}, {14,15}, { 2, 7}, {10, 7}, { 2,15}, {10,15}, { 6, 3}, {14, 3}, { 6,11}, {14,11}, { 0, 3}, { 8, 3}, { 0,11}, { 8,11}, { 4, 7}, {12, 7}, { 4,15}, {12,15}, { 0, 7}, { 8, 7}, { 0,15}, { 8,15}, { 4, 3}, {12, 3}, { 4,11}, {12,11}, { 2, 1}, {10, 1}, { 2, 9}, {10, 9}, { 6, 5}, {14, 5}, { 6,13}, {14,13}, { 2, 5}, {10, 5}, { 2,13}, {10,13}, { 6, 1}, {14, 1}, { 6, 9}, {14, 9}, { 1, 0}, { 9, 0}, { 1, 8}, { 9, 8}, { 5, 4}, {13, 4}, { 5,12}, {13,12}, { 1, 4}, { 9, 4}, { 1,12}, { 9,12}, { 5, 0}, {13, 0}, { 5, 8}, {13, 8}, { 3, 2}, {11, 2}, { 3,10}, {11,10}, { 7, 6}, {15, 6}, { 7,14}, {15,14}, { 3, 6}, {11, 6}, { 3,14}, {11,14}, { 7, 2}, {15, 2}, { 7,10}, {15,10}, { 1, 2}, { 9, 2}, { 1,10}, { 9, +10}, { 5, 6}, {13, 6}, { 5,14}, {13,14}, { 1, 6}, { 9, 6}, { 1,14}, { 9,14}, { 5, 2}, {13, 2}, { 5,10}, {13,10}, { 3, 0}, {11, 0}, { 3, 8}, {11, 8}, { 7, 4}, {15, 4}, { 7,12}, {15,12}, { 3, 4}, {11, 4}, { 3,12}, {11,12}, { 7, 0}, {15, 0}, { 7, 8}, {15, 8}, }; struct vf_priv_s { @@ -201,6 +204,8 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds for(j=0; j<3; j++){ int is_chroma= !!j; + if (!dst[j]) + continue; // HACK avoid crash for Y8 colourspace store_slice_c(dst[j], p->temp[j], dst_stride[j], p->temp_stride[j], width>>is_chroma, height>>is_chroma, 8-p->log2_count); } } @@ -222,9 +227,10 @@ static int config(struct vf_instance *vf, } for(i=0; i< (1<priv->log2_count); i++){ AVCodecContext *avctx_enc; + AVDictionary *opts = NULL; avctx_enc= - vf->priv->avctx_enc[i]= avcodec_alloc_context(); + vf->priv->avctx_enc[i]= avcodec_alloc_context3(NULL); avctx_enc->width = width + BLOCK; avctx_enc->height = height + BLOCK; avctx_enc->time_base= (AVRational){1,25}; // meaningless @@ -234,7 +240,9 @@ static int config(struct vf_instance *vf, avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 123; - avcodec_open(avctx_enc, enc); + av_dict_set(&opts, "no_bitstream", "1", 0); + avcodec_open2(avctx_enc, enc, &opts); + av_dict_free(&opts); assert(avctx_enc->codec); } vf->priv->frame= avcodec_alloc_frame(); diff --git a/libavfilter/version.h b/libavfilter/version.h index d73fd3bba6..f90d3f2018 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -29,7 +29,7 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 3 -#define LIBAVFILTER_VERSION_MINOR 34 +#define LIBAVFILTER_VERSION_MINOR 35 #define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 1ff949327a..8df9595550 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -102,7 +102,7 @@ static const AVOption crop_options[] = { { "w", "set the width crop area expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "out_h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "keep_aspect", "force packed RGB in input and output", OFFSET(keep_aspect), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS }, + { "keep_aspect", "keep aspect ratio", OFFSET(keep_aspect), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS }, {NULL} }; diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 9a22a63b63..bf0ac62117 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -83,8 +83,8 @@ static void apply_delogo(uint8_t *dst, int dst_linesize, if (!direct) av_image_copy_plane(dst, dst_linesize, src, src_linesize, w, h); - dst += (logo_y1+1)*dst_linesize; - src += (logo_y1+1)*src_linesize; + dst += (logo_y1 + 1) * dst_linesize; + src += (logo_y1 + 1) * src_linesize; for (y = logo_y1+1; y < logo_y2-1; y++) { for (x = logo_x1+1, diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index b30f8ae8ad..4381586bec 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -26,6 +26,7 @@ * libmpcodecs/vf_hqdn3d.c. */ +#include "config.h" #include "libavutil/common.h" #include "libavutil/pixdesc.h" #include "libavutil/intreadwrite.h" @@ -33,21 +34,7 @@ #include "formats.h" #include "internal.h" #include "video.h" - -typedef struct { - int16_t *coefs[4]; - uint16_t *line; - uint16_t *frame_prev[3]; - double strength[4]; - int hsub, vsub; - int depth; - void (*denoise_row[17])(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -} HQDN3DContext; - -void ff_hqdn3d_row_8_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -void ff_hqdn3d_row_9_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -void ff_hqdn3d_row_10_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); -void ff_hqdn3d_row_16_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +#include "vf_hqdn3d.h" #define LUT_BITS (depth==16 ? 8 : 4) #define LOAD(x) (((depth==8 ? src[x] : AV_RN16A(src+(x)*2)) << (16-depth)) + (((1<<(16-depth))-1)>>1)) @@ -311,12 +298,8 @@ static int config_input(AVFilterLink *inlink) return AVERROR(ENOMEM); } -#if HAVE_YASM - hqdn3d->denoise_row[ 8] = ff_hqdn3d_row_8_x86; - hqdn3d->denoise_row[ 9] = ff_hqdn3d_row_9_x86; - hqdn3d->denoise_row[10] = ff_hqdn3d_row_10_x86; - hqdn3d->denoise_row[16] = ff_hqdn3d_row_16_x86; -#endif + if (ARCH_X86) + ff_hqdn3d_init_x86(hqdn3d); return 0; } diff --git a/libavfilter/vf_hqdn3d.h b/libavfilter/vf_hqdn3d.h new file mode 100644 index 0000000000..dfc69e140f --- /dev/null +++ b/libavfilter/vf_hqdn3d.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2003 Daniel Moreno + * Copyright (c) 2010 Baptiste Coudurier + * Copyright (c) 2012 Loren Merritt + * + * This file is part of FFmpeg, ported from MPlayer. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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. + */ + +#ifndef AVFILTER_VF_HQDN3D_H +#define AVFILTER_VF_HQDN3D_H + +#include +#include + +typedef struct { + int16_t *coefs[4]; + uint16_t *line; + uint16_t *frame_prev[3]; + double strength[4]; + int hsub, vsub; + int depth; + void (*denoise_row[17])(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +} HQDN3DContext; + +void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d); + +#endif /* AVFILTER_VF_HQDN3D_H */ diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 6c87b3a8f0..e057d628ad 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -36,7 +36,7 @@ #include "libmpcodecs/vf.h" #include "libmpcodecs/img_format.h" #include "libmpcodecs/cpudetect.h" -#include "libmpcodecs/vd_ffmpeg.h" +#include "libmpcodecs/av_helpers.h" #include "libmpcodecs/vf_scale.h" #include "libmpcodecs/libvo/fastmemcpy.h" diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index bbd37b160c..5c146f208f 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -35,6 +35,7 @@ #include "libavutil/colorspace.h" #include "libavutil/avassert.h" #include "libavutil/imgutils.h" +#include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/mathematics.h" #include "drawutils.h" @@ -76,40 +77,61 @@ static int query_formats(AVFilterContext *ctx) } typedef struct { + const AVClass *class; int w, h; ///< output dimensions, a value of 0 will result in the input size int x, y; ///< offsets of the input area with respect to the padded area int in_w, in_h; ///< width and height for the padded input video, which has to be aligned to the chroma values in order to avoid chroma issues - char w_expr[256]; ///< width expression string - char h_expr[256]; ///< height expression string - char x_expr[256]; ///< width expression string - char y_expr[256]; ///< height expression string - + char *w_expr; ///< width expression string + char *h_expr; ///< height expression string + char *x_expr; ///< width expression string + char *y_expr; ///< height expression string + char *color_str; uint8_t rgba_color[4]; ///< color for the padding area FFDrawContext draw; FFDrawColor color; } PadContext; +#define OFFSET(x) offsetof(PadContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + +static const AVOption pad_options[] = { + { "width", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "w", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "height", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "h", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "x", "set the x offset expression for the input image position", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "y", "set the y offset expression for the input image position", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "color", "set the color of the padded area border", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = FLAGS }, + {NULL} +}; + +AVFILTER_DEFINE_CLASS(pad); + static av_cold int init(AVFilterContext *ctx, const char *args) { PadContext *pad = ctx->priv; - char color_string[128] = "black"; + static const char *shorthand[] = { "width", "height", "x", "y", "color", NULL }; + int ret; - av_strlcpy(pad->w_expr, "iw", sizeof(pad->w_expr)); - av_strlcpy(pad->h_expr, "ih", sizeof(pad->h_expr)); - av_strlcpy(pad->x_expr, "0" , sizeof(pad->w_expr)); - av_strlcpy(pad->y_expr, "0" , sizeof(pad->h_expr)); + pad->class = &pad_class; + av_opt_set_defaults(pad); - if (args) - sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%127s", - pad->w_expr, pad->h_expr, pad->x_expr, pad->y_expr, color_string); + if ((ret = av_opt_set_from_string(pad, args, shorthand, "=", ":")) < 0) + return ret; - if (av_parse_color(pad->rgba_color, color_string, -1, ctx) < 0) + if (av_parse_color(pad->rgba_color, pad->color_str, -1, ctx) < 0) return AVERROR(EINVAL); return 0; } +static av_cold void uninit(AVFilterContext *ctx) +{ + PadContext *pad = ctx->priv; + av_opt_free(pad); +} + static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; @@ -368,9 +390,11 @@ AVFilter avfilter_vf_pad = { .priv_size = sizeof(PadContext), .init = init, + .uninit = uninit, .query_formats = query_formats, .inputs = avfilter_vf_pad_inputs, .outputs = avfilter_vf_pad_outputs, + .priv_class = &pad_class, }; diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile index 47569cf642..59cefe8988 100644 --- a/libavfilter/x86/Makefile +++ b/libavfilter/x86/Makefile @@ -1,7 +1,8 @@ -OBJS-$(CONFIG_GRADFUN_FILTER) += x86/gradfun.o +OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o +OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d_init.o OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o -OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif_init.o +OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o -YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/hqdn3d.o +YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d.o YASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o -YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/yadif.o +YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o diff --git a/libavfilter/x86/gradfun.c b/libavfilter/x86/vf_gradfun.c similarity index 100% rename from libavfilter/x86/gradfun.c rename to libavfilter/x86/vf_gradfun.c diff --git a/libavfilter/x86/hqdn3d.asm b/libavfilter/x86/vf_hqdn3d.asm similarity index 100% rename from libavfilter/x86/hqdn3d.asm rename to libavfilter/x86/vf_hqdn3d.asm diff --git a/libavfilter/x86/vf_hqdn3d_init.c b/libavfilter/x86/vf_hqdn3d_init.c new file mode 100644 index 0000000000..4abb87888e --- /dev/null +++ b/libavfilter/x86/vf_hqdn3d_init.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2012 Loren Merritt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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. + */ + +#include +#include + +#include "libavutil/attributes.h" +#include "libavfilter/vf_hqdn3d.h" +#include "config.h" + +void ff_hqdn3d_row_8_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +void ff_hqdn3d_row_9_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +void ff_hqdn3d_row_10_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); +void ff_hqdn3d_row_16_x86(uint8_t *src, uint8_t *dst, uint16_t *line_ant, uint16_t *frame_ant, ptrdiff_t w, int16_t *spatial, int16_t *temporal); + +av_cold void ff_hqdn3d_init_x86(HQDN3DContext *hqdn3d) +{ +#if HAVE_YASM + hqdn3d->denoise_row[ 8] = ff_hqdn3d_row_8_x86; + hqdn3d->denoise_row[ 9] = ff_hqdn3d_row_9_x86; + hqdn3d->denoise_row[10] = ff_hqdn3d_row_10_x86; + hqdn3d->denoise_row[16] = ff_hqdn3d_row_16_x86; +#endif +} diff --git a/libavfilter/x86/yadif.asm b/libavfilter/x86/vf_yadif.asm similarity index 100% rename from libavfilter/x86/yadif.asm rename to libavfilter/x86/vf_yadif.asm diff --git a/libavfilter/x86/yadif_init.c b/libavfilter/x86/vf_yadif_init.c similarity index 100% rename from libavfilter/x86/yadif_init.c rename to libavfilter/x86/vf_yadif_init.c diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 5c2cf8b9b0..465d9e5792 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -943,7 +943,7 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ av_dlog(asf, "key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, asf->packet_frag_offset, asf->packet_replic_size); - if (rsize+asf->packet_replic_size > asf->packet_size_left) { + if (rsize+(int64_t)asf->packet_replic_size > asf->packet_size_left) { av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size); return AVERROR_INVALIDDATA; } diff --git a/libavformat/au.c b/libavformat/au.c index b3a793d7ff..db2ab27558 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -151,11 +151,21 @@ AVInputFormat ff_au_demuxer = { #include "rawenc.h" -/* AUDIO_FILE header */ -static int put_au_header(AVIOContext *pb, AVCodecContext *enc) +static int au_write_header(AVFormatContext *s) { - if (!enc->codec_tag) + AVIOContext *pb = s->pb; + AVCodecContext *enc = s->streams[0]->codec; + + if (s->nb_streams != 1) { + av_log(s, AV_LOG_ERROR, "only one stream is supported\n"); return AVERROR(EINVAL); + } + + enc->codec_tag = ff_codec_get_tag(codec_au_tags, enc->codec_id); + if (!enc->codec_tag) { + av_log(s, AV_LOG_ERROR, "unsupported codec\n"); + return AVERROR(EINVAL); + } ffio_wfourcc(pb, ".snd"); /* magic number */ avio_wb32(pb, AU_HEADER_SIZE); /* header size */ @@ -164,18 +174,6 @@ static int put_au_header(AVIOContext *pb, AVCodecContext *enc) avio_wb32(pb, enc->sample_rate); avio_wb32(pb, enc->channels); avio_wb64(pb, 0); /* annotation field */ - - return 0; -} - -static int au_write_header(AVFormatContext *s) -{ - AVIOContext *pb = s->pb; - int ret; - - if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0) - return ret; - avio_flush(pb); return 0; diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index e5d9b7626f..1e4dee1b00 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -226,7 +226,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts, } AVInputFormat ff_avisynth_demuxer = { - .name = "avs", + .name = "avisynth", .long_name = NULL_IF_CONFIG_SMALL("AVISynth"), .priv_data_size = sizeof(AVISynthContext), .read_header = avisynth_read_header, diff --git a/libavformat/bink.c b/libavformat/bink.c index c77a8f84e7..887f70a512 100644 --- a/libavformat/bink.c +++ b/libavformat/bink.c @@ -112,6 +112,7 @@ static int read_header(AVFormatContext *s) return AVERROR(EIO); } avpriv_set_pts_info(vst, 64, fps_den, fps_num); + vst->avg_frame_rate = av_inv_q(vst->time_base); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 09a77c4852..b57929eda1 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -713,13 +713,13 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) st = s->streams[i]; if (stream_type == FLV_STREAM_TYPE_AUDIO) { if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && - flv_same_audio_codec(st->codec, flags)) { + (s->audio_codec_id || flv_same_audio_codec(st->codec, flags))) { break; } } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && - flv_same_video_codec(st->codec, flags)) { + (s->video_codec_id || flv_same_video_codec(st->codec, flags))) { break; } } else if (stream_type == FLV_STREAM_TYPE_DATA) { diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c index 2a06fe12a7..d3a8dbd6cd 100644 --- a/libavformat/loasdec.c +++ b/libavformat/loasdec.c @@ -55,7 +55,6 @@ static int loas_probe(AVProbeData *p) if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; else if(max_frames>100)return AVPROBE_SCORE_MAX/2; else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; - else if(max_frames>=1) return 1; else return 0; } diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 394a62f9d3..519f881e89 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -66,6 +66,7 @@ const CodecTags ff_mkv_codec_tags[]={ {"S_ASS" , AV_CODEC_ID_SSA}, {"S_SSA" , AV_CODEC_ID_SSA}, {"S_VOBSUB" , AV_CODEC_ID_DVD_SUBTITLE}, + {"S_DVBSUB" , AV_CODEC_ID_DVB_SUBTITLE}, {"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE}, {"V_DIRAC" , AV_CODEC_ID_DIRAC}, diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c167c015fe..204d1b2394 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -530,12 +530,16 @@ static int mkv_write_tracks(AVFormatContext *s) MatroskaMuxContext *mkv = s->priv_data; AVIOContext *pb = s->pb; ebml_master tracks; - int i, j, ret; + int i, j, ret, default_stream_exists = 0; ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb)); if (ret < 0) return ret; tracks = start_ebml_master(pb, MATROSKA_ID_TRACKS, 0); + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT; + } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AVCodecContext *codec = st->codec; @@ -570,8 +574,9 @@ static int mkv_write_tracks(AVFormatContext *s) tag = av_dict_get(st->metadata, "language", NULL, 0); put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und"); - if (st->disposition) + if (default_stream_exists) { put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); + } if (st->disposition & AV_DISPOSITION_FORCED) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, 1); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1b851c03dd..08015b545c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -356,8 +356,7 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic else avio_w8(pb, 0x11); // flags (= Visualstream) - avio_w8(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits) - avio_wb16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB + avio_wb24(pb, track->enc->rc_buffer_size >> 3); // Buffersize DB avg_bitrate = compute_avg_bitrate(track); // maxbitrate (FIXME should be max rate in any 1 sec window) diff --git a/libavformat/mvi.c b/libavformat/mvi.c index 9184927a2f..6b74597f07 100644 --- a/libavformat/mvi.c +++ b/libavformat/mvi.c @@ -89,6 +89,7 @@ static int read_header(AVFormatContext *s) ast->codec->bit_rate = ast->codec->sample_rate * 8; avpriv_set_pts_info(vst, 64, msecs_per_frame, 1000000); + vst->avg_frame_rate = av_inv_q(vst->time_base); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = AV_CODEC_ID_MOTIONPIXELS; diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 31e28413e9..3d4519c1ac 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -402,7 +402,7 @@ static int ogg_build_opus_headers(AVCodecContext *avctx, static int ogg_write_header(AVFormatContext *s) { OGGContext *ogg = s->priv_data; - OGGStreamContext *oggstream; + OGGStreamContext *oggstream = NULL; int i, j; if (ogg->pref_size) diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 16bcaefd4d..0b52bc7c17 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -173,11 +173,15 @@ static unsigned int fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv, uint8_t **buf) { - int i,offset, len; + int i,offset, len, buf_len; unsigned char *ptr; len = priv->len[0] + priv->len[1] + priv->len[2]; - ptr = *buf = av_mallocz(len + len/255 + 64); + buf_len = len + len/255 + 64; + ptr = *buf = av_realloc(NULL, buf_len); + if (!*buf) + return 0; + memset(*buf, '\0', buf_len); ptr[0] = 2; offset = 1; diff --git a/libavformat/r3d.c b/libavformat/r3d.c index 35da81eff1..3b3ecce3d9 100644 --- a/libavformat/r3d.c +++ b/libavformat/r3d.c @@ -285,6 +285,10 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) dts = avio_rb32(s->pb); st->codec->sample_rate = avio_rb32(s->pb); + if (st->codec->sample_rate < 0) { + av_log(s, AV_LOG_ERROR, "negative sample rate\n"); + return AVERROR_INVALIDDATA; + } samples = avio_rb32(s->pb); @@ -312,7 +316,8 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom) pkt->stream_index = 1; pkt->dts = dts; - pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate); + if (st->codec->sample_rate) + pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate); av_dlog(s, "pkt dts %"PRId64" duration %d samples %d sample rate %d\n", pkt->dts, pkt->duration, samples, st->codec->sample_rate); diff --git a/libavformat/rtp.c b/libavformat/rtp.c index b76e521a8c..c4dcf6ae8d 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "libavutil/opt.h" #include "avformat.h" #include "rtp.h" diff --git a/libavformat/segment.c b/libavformat/segment.c index 7d7222922c..9c271eb3a8 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -219,8 +219,8 @@ static int segment_list_open(AVFormatContext *s) avio_printf(seg->list_pb, "#EXTM3U\n"); avio_printf(seg->list_pb, "#EXT-X-VERSION:3\n"); avio_printf(seg->list_pb, "#EXT-X-MEDIA-SEQUENCE:%d\n", seg->segment_list_entries->index); - avio_printf(seg->list_pb, "#EXT-X-ALLOWCACHE:%d\n", - !!(seg->list_flags & SEGMENT_LIST_FLAG_CACHE)); + avio_printf(seg->list_pb, "#EXT-X-ALLOW-CACHE:%s\n", + seg->list_flags & SEGMENT_LIST_FLAG_CACHE ? "YES" : "NO"); for (entry = seg->segment_list_entries; entry; entry = entry->next) max_duration = FFMAX(max_duration, entry->end_time - entry->start_time); diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index ff039bd37a..f34a4afce1 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -28,11 +28,6 @@ #define Y4M_FRAME_MAGIC "FRAME" #define Y4M_LINE_MAX 256 -struct frame_attributes { - int interlaced_frame; - int top_field_first; -}; - #if CONFIG_YUV4MPEGPIPE_MUXER static int yuv4_generate_header(AVFormatContext *s, char* buf) { @@ -58,6 +53,13 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) inter = 'p'; /* progressive is the default */ if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) inter = st->codec->coded_frame->top_field_first ? 't' : 'b'; + if (st->codec->field_order == AV_FIELD_PROGRESSIVE) { + inter = 'p'; + } else if (st->codec->field_order == AV_FIELD_TB || st->codec->field_order == AV_FIELD_TT) { + inter = 't'; + } else if (st->codec->field_order == AV_FIELD_BT || st->codec->field_order == AV_FIELD_BB) { + inter = 'b'; + } switch (st->codec->pix_fmt) { case AV_PIX_FMT_GRAY8: @@ -319,7 +321,7 @@ static int yuv4_read_header(AVFormatContext *s) { char header[MAX_YUV4_HEADER + 10]; // Include headroom for // the longest option - char *tokstart, *tokend, *header_end; + char *tokstart, *tokend, *header_end, interlaced = '?'; int i; AVIOContext *pb = s->pb; int width = -1, height = -1, raten = 0, @@ -327,7 +329,6 @@ static int yuv4_read_header(AVFormatContext *s) enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE; enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED; AVStream *st; - struct frame_attributes *s1 = s->priv_data; for (i = 0; i < MAX_YUV4_HEADER; i++) { header[i] = avio_r8(pb); @@ -343,8 +344,6 @@ static int yuv4_read_header(AVFormatContext *s) if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) return -1; - s1->interlaced_frame = 0; - s1->top_field_first = 0; header_end = &header[i + 1]; // Include space for (tokstart = &header[strlen(Y4M_MAGIC) + 1]; tokstart < header_end; tokstart++) { @@ -425,28 +424,7 @@ static int yuv4_read_header(AVFormatContext *s) tokstart++; break; case 'I': // Interlace type - switch (*tokstart++){ - case '?': - break; - case 'p': - s1->interlaced_frame = 0; - break; - case 't': - s1->interlaced_frame = 1; - s1->top_field_first = 1; - break; - case 'b': - s1->interlaced_frame = 1; - s1->top_field_first = 0; - break; - case 'm': - av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " - "interlaced and non-interlaced frames.\n"); - return -1; - default: - av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); - return -1; - } + interlaced = *tokstart++; break; case 'F': // Frame rate sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown @@ -547,6 +525,27 @@ static int yuv4_read_header(AVFormatContext *s) st->sample_aspect_ratio = (AVRational){ aspectn, aspectd }; st->codec->chroma_sample_location = chroma_sample_location; + switch (interlaced){ + case 'p': + st->codec->field_order = AV_FIELD_PROGRESSIVE; + break; + case 't': + st->codec->field_order = AV_FIELD_TB; + break; + case 'b': + st->codec->field_order = AV_FIELD_BT; + break; + case 'm': + av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed " + "interlaced and non-interlaced frames.\n"); + case '?': + st->codec->field_order = AV_FIELD_UNKNOWN; + break; + default: + av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n"); + return AVERROR(EINVAL); + } + return 0; } @@ -556,7 +555,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) char header[MAX_FRAME_HEADER+1]; int packet_size, width, height, ret; AVStream *st = s->streams[0]; - struct frame_attributes *s1 = s->priv_data; for (i = 0; i < MAX_FRAME_HEADER; i++) { header[i] = avio_r8(s->pb); @@ -588,11 +586,6 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) else if (ret != packet_size) return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); - if (st->codec->coded_frame) { - st->codec->coded_frame->interlaced_frame = s1->interlaced_frame; - st->codec->coded_frame->top_field_first = s1->top_field_first; - } - pkt->stream_index = 0; return 0; } @@ -610,7 +603,6 @@ static int yuv4_probe(AVProbeData *pd) AVInputFormat ff_yuv4mpegpipe_demuxer = { .name = "yuv4mpegpipe", .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe"), - .priv_data_size = sizeof(struct frame_attributes), .read_probe = yuv4_probe, .read_header = yuv4_read_header, .read_packet = yuv4_read_packet, diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 2f00374176..e2422c0a59 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -69,11 +69,11 @@ char *av_strnstr(const char *haystack, const char *needle, size_t hay_length) { size_t needle_len = strlen(needle); if (!needle_len) - return haystack; + return (char*)haystack; while (hay_length >= needle_len) { hay_length--; if (!memcmp(haystack, needle, needle_len)) - return haystack; + return (char*)haystack; haystack++; } return NULL; diff --git a/libavutil/dict.c b/libavutil/dict.c index 06f963cf62..967c9e2fff 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -94,10 +94,13 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags m->elems[m->count].value = (char*)(intptr_t)value; } else if (oldval && flags & AV_DICT_APPEND) { int len = strlen(oldval) + strlen(value) + 1; - if (!(oldval = av_realloc(oldval, len))) + char *newval = av_mallocz(len); + if (!newval) return AVERROR(ENOMEM); - av_strlcat(oldval, value, len); - m->elems[m->count].value = oldval; + av_strlcat(newval, oldval, len); + av_freep(&oldval); + av_strlcat(newval, value, len); + m->elems[m->count].value = newval; } else m->elems[m->count].value = av_strdup(value); m->count++; diff --git a/libavutil/eval.c b/libavutil/eval.c index 22b491fef3..712d2f2678 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -467,7 +467,7 @@ static int parse_dB(AVExpr **e, Parser *p, int *sign) for example, -3dB is not the same as -(3dB) */ if (*p->s == '-') { char *next; - strtod(p->s, &next); + double av_unused v = strtod(p->s, &next); if (next != p->s && next[0] == 'd' && next[1] == 'B') { *sign = 0; return parse_primary(e, p); diff --git a/libavutil/mips/float_dsp_mips.c b/libavutil/mips/float_dsp_mips.c index e39a4bf2bb..5211a265d4 100644 --- a/libavutil/mips/float_dsp_mips.c +++ b/libavutil/mips/float_dsp_mips.c @@ -106,6 +106,43 @@ static void vector_fmul_mips(float *dst, const float *src0, const float *src1, } } +static void vector_fmul_scalar_mips(float *dst, const float *src, float mul, + int len) +{ + float temp0, temp1, temp2, temp3; + float *local_src = (float*)src; + float *end = local_src + len; + + /* loop unrolled 4 times */ + __asm__ volatile( + ".set push \n\t" + ".set noreorder \n\t" + "1: \n\t" + "lwc1 %[temp0], 0(%[src]) \n\t" + "lwc1 %[temp1], 4(%[src]) \n\t" + "lwc1 %[temp2], 8(%[src]) \n\t" + "lwc1 %[temp3], 12(%[src]) \n\t" + "addiu %[dst], %[dst], 16 \n\t" + "mul.s %[temp0], %[temp0], %[mul] \n\t" + "mul.s %[temp1], %[temp1], %[mul] \n\t" + "mul.s %[temp2], %[temp2], %[mul] \n\t" + "mul.s %[temp3], %[temp3], %[mul] \n\t" + "addiu %[src], %[src], 16 \n\t" + "swc1 %[temp0], -16(%[dst]) \n\t" + "swc1 %[temp1], -12(%[dst]) \n\t" + "swc1 %[temp2], -8(%[dst]) \n\t" + "bne %[src], %[end], 1b \n\t" + " swc1 %[temp3], -4(%[dst]) \n\t" + ".set pop \n\t" + + : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), + [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [dst]"+r"(dst), [src]"+r"(local_src) + : [end]"r"(end), [mul]"f"(mul) + : "memory" + ); +} + static void vector_fmul_window_mips(float *dst, const float *src0, const float *src1, const float *win, int len) { @@ -216,11 +253,91 @@ static void vector_fmul_window_mips(float *dst, const float *src0, ); } } + +static void butterflies_float_mips(float *av_restrict v1, float *av_restrict v2, + int len) +{ + float temp0, temp1, temp2, temp3, temp4; + float temp5, temp6, temp7, temp8, temp9; + float temp10, temp11, temp12, temp13, temp14, temp15; + int pom; + pom = (len >> 2)-1; + + /* loop unrolled 4 times */ + __asm__ volatile ( + "lwc1 %[temp0], 0(%[v1]) \n\t" + "lwc1 %[temp1], 4(%[v1]) \n\t" + "lwc1 %[temp2], 8(%[v1]) \n\t" + "lwc1 %[temp3], 12(%[v1]) \n\t" + "lwc1 %[temp4], 0(%[v2]) \n\t" + "lwc1 %[temp5], 4(%[v2]) \n\t" + "lwc1 %[temp6], 8(%[v2]) \n\t" + "lwc1 %[temp7], 12(%[v2]) \n\t" + "beq %[pom], $zero, 2f \n\t" + "1: \n\t" + "sub.s %[temp8], %[temp0], %[temp4] \n\t" + "add.s %[temp9], %[temp0], %[temp4] \n\t" + "sub.s %[temp10], %[temp1], %[temp5] \n\t" + "add.s %[temp11], %[temp1], %[temp5] \n\t" + "sub.s %[temp12], %[temp2], %[temp6] \n\t" + "add.s %[temp13], %[temp2], %[temp6] \n\t" + "sub.s %[temp14], %[temp3], %[temp7] \n\t" + "add.s %[temp15], %[temp3], %[temp7] \n\t" + "addiu %[v1], %[v1], 16 \n\t" + "addiu %[v2], %[v2], 16 \n\t" + "addiu %[pom], %[pom], -1 \n\t" + "lwc1 %[temp0], 0(%[v1]) \n\t" + "lwc1 %[temp1], 4(%[v1]) \n\t" + "lwc1 %[temp2], 8(%[v1]) \n\t" + "lwc1 %[temp3], 12(%[v1]) \n\t" + "lwc1 %[temp4], 0(%[v2]) \n\t" + "lwc1 %[temp5], 4(%[v2]) \n\t" + "lwc1 %[temp6], 8(%[v2]) \n\t" + "lwc1 %[temp7], 12(%[v2]) \n\t" + "swc1 %[temp9], -16(%[v1]) \n\t" + "swc1 %[temp8], -16(%[v2]) \n\t" + "swc1 %[temp11], -12(%[v1]) \n\t" + "swc1 %[temp10], -12(%[v2]) \n\t" + "swc1 %[temp13], -8(%[v1]) \n\t" + "swc1 %[temp12], -8(%[v2]) \n\t" + "swc1 %[temp15], -4(%[v1]) \n\t" + "swc1 %[temp14], -4(%[v2]) \n\t" + "bgtz %[pom], 1b \n\t" + "2: \n\t" + "sub.s %[temp8], %[temp0], %[temp4] \n\t" + "add.s %[temp9], %[temp0], %[temp4] \n\t" + "sub.s %[temp10], %[temp1], %[temp5] \n\t" + "add.s %[temp11], %[temp1], %[temp5] \n\t" + "sub.s %[temp12], %[temp2], %[temp6] \n\t" + "add.s %[temp13], %[temp2], %[temp6] \n\t" + "sub.s %[temp14], %[temp3], %[temp7] \n\t" + "add.s %[temp15], %[temp3], %[temp7] \n\t" + "swc1 %[temp9], 0(%[v1]) \n\t" + "swc1 %[temp8], 0(%[v2]) \n\t" + "swc1 %[temp11], 4(%[v1]) \n\t" + "swc1 %[temp10], 4(%[v2]) \n\t" + "swc1 %[temp13], 8(%[v1]) \n\t" + "swc1 %[temp12], 8(%[v2]) \n\t" + "swc1 %[temp15], 12(%[v1]) \n\t" + "swc1 %[temp14], 12(%[v2]) \n\t" + + : [v1]"+r"(v1), [v2]"+r"(v2), [pom]"+r"(pom), [temp0] "=&f" (temp0), + [temp1]"=&f"(temp1), [temp2]"=&f"(temp2), [temp3]"=&f"(temp3), + [temp4]"=&f"(temp4), [temp5]"=&f"(temp5), [temp6]"=&f"(temp6), + [temp7]"=&f"(temp7), [temp8]"=&f"(temp8), [temp9]"=&f"(temp9), + [temp10]"=&f"(temp10), [temp11]"=&f"(temp11), [temp12]"=&f"(temp12), + [temp13]"=&f"(temp13), [temp14]"=&f"(temp14), [temp15]"=&f"(temp15) + : + : "memory" + ); +} #endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp) { #if HAVE_INLINE_ASM && HAVE_MIPSFPU fdsp->vector_fmul = vector_fmul_mips; + fdsp->vector_fmul_scalar = vector_fmul_scalar_mips; fdsp->vector_fmul_window = vector_fmul_window_mips; + fdsp->butterflies_float = butterflies_float_mips; #endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */ } diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index ca40569e6a..73e400ac62 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -109,6 +109,12 @@ static const VideoSizeAbbr video_size_abbrs[] = { { "hd480", 852, 480 }, { "hd720", 1280, 720 }, { "hd1080", 1920,1080 }, + { "2k", 2048,1080 }, /* Digital Cinema System Specification */ + { "2kflat", 1998,1080 }, + { "2kscope", 2048, 858 }, + { "4k", 4096,2160 }, /* Digital Cinema System Specification */ + { "4kflat", 3996,2160 }, + { "4kscope", 4096,1716 }, }; static const VideoRateAbbr video_rate_abbrs[]= { diff --git a/libavutil/version.h b/libavutil/version.h index 2b574f57ff..3d53261291 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -76,7 +76,7 @@ #define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MINOR 17 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/library.mak b/library.mak index b0d4151dbd..273b3d6e89 100644 --- a/library.mak +++ b/library.mak @@ -85,7 +85,7 @@ install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) $(Q)mkdir -p "$(INCINSTDIR)" $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" -install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc +install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc $(Q)mkdir -p "$(LIBDIR)/pkgconfig" $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig" @@ -99,7 +99,7 @@ uninstall-libs:: uninstall-headers:: $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS)) - $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc" + $(RM) "$(LIBDIR)/pkgconfig/lib$(FULLNAME).pc" -rmdir "$(INCINSTDIR)" endef diff --git a/libswresample/resample.c b/libswresample/resample.c index d3fe1a7479..fb9da7c354 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -142,7 +142,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap break; case AV_SAMPLE_FMT_S32P: for(i=0;ifilter_length; i++) - val += src[FFABS(sample_index + i)] * filter[i]; + val += src[FFABS(sample_index + i)] * (FELEM2)filter[i]; }else if(c->linear){ FELEM2 v2=0; for(i=0; ifilter_length; i++){ diff --git a/libswresample/swresample-test.c b/libswresample/swresample-test.c index 7f50cb48d0..379d385315 100644 --- a/libswresample/swresample-test.c +++ b/libswresample/swresample-test.c @@ -65,7 +65,7 @@ static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFor switch(f){ case AV_SAMPLE_FMT_U8 : ((uint8_t*)p)[index]= av_clip_uint8 (lrint((v+1.0)*127)); break; case AV_SAMPLE_FMT_S16: ((int16_t*)p)[index]= av_clip_int16 (lrint(v*32767)); break; - case AV_SAMPLE_FMT_S32: ((int32_t*)p)[index]= av_clipl_int32(lrint(v*2147483647)); break; + case AV_SAMPLE_FMT_S32: ((int32_t*)p)[index]= av_clipl_int32(llrint(v*2147483647)); break; case AV_SAMPLE_FMT_FLT: ((float *)p)[index]= v; break; case AV_SAMPLE_FMT_DBL: ((double *)p)[index]= v; break; default: av_assert2(0); diff --git a/libswresample/swresample.c b/libswresample/swresample.c index e55f9be150..b192bfdfa9 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -265,9 +265,41 @@ av_cold int swr_init(struct SwrContext *s){ return AVERROR(EINVAL); } + switch(s->engine){ +#if CONFIG_LIBSOXR + extern struct Resampler const soxr_resampler; + case SWR_ENGINE_SOXR: s->resampler = &soxr_resampler; break; +#endif + case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break; + default: + av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n"); + return AVERROR(EINVAL); + } + + if(!s->used_ch_count) + s->used_ch_count= s->in.ch_count; + + if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){ + av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n"); + s-> in_ch_layout= 0; + } + + if(!s-> in_ch_layout) + s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count); + if(!s->out_ch_layout) + s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count); + + s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 || + s->rematrix_custom; + if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){ if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){ s->int_sample_fmt= AV_SAMPLE_FMT_S16P; + }else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P + && av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P + && !s->rematrix + && s->engine != SWR_ENGINE_SOXR){ + s->int_sample_fmt= AV_SAMPLE_FMT_S32P; }else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){ s->int_sample_fmt= AV_SAMPLE_FMT_FLTP; }else{ @@ -284,17 +316,6 @@ av_cold int swr_init(struct SwrContext *s){ return AVERROR(EINVAL); } - switch(s->engine){ -#if CONFIG_LIBSOXR - extern struct Resampler const soxr_resampler; - case SWR_ENGINE_SOXR: s->resampler = &soxr_resampler; break; -#endif - case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break; - default: - av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n"); - return AVERROR(EINVAL); - } - set_audiodata_fmt(&s-> in, s-> in_sample_fmt); set_audiodata_fmt(&s->out, s->out_sample_fmt); @@ -326,22 +347,6 @@ av_cold int swr_init(struct SwrContext *s){ return -1; } - if(!s->used_ch_count) - s->used_ch_count= s->in.ch_count; - - if(s->used_ch_count && s-> in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){ - av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than the number of used channels, ignoring layout\n"); - s-> in_ch_layout= 0; - } - - if(!s-> in_ch_layout) - s-> in_ch_layout= av_get_default_channel_layout(s->used_ch_count); - if(!s->out_ch_layout) - s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count); - - s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0 || - s->rematrix_custom; - #define RSC 1 //FIXME finetune if(!s-> in.ch_count) s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout); diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 4d9bd89ce5..bb908191dc 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -632,8 +632,8 @@ static int swScale(SwsContext *c, const uint8_t *src[], } } } else if (yuv2packedX) { - av_assert1(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize * 2); - av_assert1(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize * 2); + av_assert1(lumSrcPtr + vLumFilterSize - 1 < (const int16_t **)lumPixBuf + vLumBufSize * 2); + av_assert1(chrUSrcPtr + vChrFilterSize - 1 < (const int16_t **)chrUPixBuf + vChrBufSize * 2); if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize <= 2) { // unscaled RGB int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1];