Commit Graph

44 Commits

Author SHA1 Message Date
Michael Niedermayer
fa6fa2162b avcodec/cabac: support UNCHECKED_BITSTREAM_READER = 0
Fixes overreads in HEVC
Fixes Ticket3070
Also fixed remaining issues from Ticket3075 and Ticket3076

Some lines of code taken from  0c5f839693da2276c2da23400f67a67be4ea0af1:libavcodec/x86/cabac.h
and                            0c5f839693da2276c2da23400f67a67be4ea0af1:libavcodec/cabac_functions.h

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-31 11:13:27 +01:00
Michael Niedermayer
41efb8d9a7 avcodec/x86/cabac: include get_cabac_bypass_sign_x86() under #if !BROKEN_COMPILER
this might fix Ticket2999 as well as some fate clients
untested as the original patch submitter no longer has the environment to test
this should be reverted if it does not fix the issues

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-26 15:06:55 +02:00
Thilo Borgmann
d814a839ac Reinstate proper FFmpeg license for all files. 2013-08-30 15:47:38 +00:00
Michael Niedermayer
66537c7efd avcodec/x86/cabac: Disable get_cabac_bypass_x86() on broken llvm/clang
This should fix fate on these platforms

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-06 16:24:27 +02:00
Michael Niedermayer
32de28053d avcodec/x86/cabac: factorize broken llvm/clang check out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-06 16:24:27 +02:00
Michael Niedermayer
cced6f4d58 Merge commit 'e6d8acf6a8fba4743eb56eabe72a741d1bbee3cb'
* commit 'e6d8acf6a8fba4743eb56eabe72a741d1bbee3cb':
  indeo: use a typedef for the mc function pointer
  cabac: x86 version of get_cabac_bypass
  aic: use chroma scan tables while decoding luma component in progressive mode

Conflicts:
	libavcodec/aic.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-05 11:41:30 +02:00
Jason Garrett-Glaser
d222f6e39e cabac: x86 version of get_cabac_bypass
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-07-04 16:06:10 +02:00
Michael Niedermayer
b3ab281027 avcodec/x86/cabac: workaround llvm 4.2.1 bug
x86_64 is affected by this too
Fixes Ticket2156

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-22 03:43:29 +01:00
Michael Niedermayer
66bdc58550 get_cabac_inline_x86: workaround clang bug with disabled optimizations
gcc produces binary identical output relative to before this change

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-18 00:45:29 +02:00
Michael Niedermayer
7427d1ca4a Merge remote-tracking branch 'qatar/master'
* qatar/master:
  g723.1: simplify scale_vector()
  g723.1: simplify normalize_bits()
  vda: cosmetics: fix Doxygen comment formatting
  vda: better frame allocation
  vda: Merge implementation into one file
  vda: support synchronous decoding
  vda: Reuse the bitstream buffer and reallocate it only if needed
  build: Factor out mpegvideo encoding dependencies to CONFIG_MPEGVIDEOENC
  avprobe: Include libm.h for the log2 fallback
  proresenc: use the edge emulation buffer
  rtmp: handle bytes read reports
  configure: Fix typo in mpeg2video/svq1 decoder dependency declaration
  Use log2(x) instead of log(x) / log(2)
  x86: swscale: fix fragile memory accesses
  x86: swscale: remove disabled code
  x86: yadif: fix asm with suncc
  x86: cabac: allow building with suncc
  x86: mlpdsp: avoid taking address of void
  ARM: intmath: use native-size return types for clipping functions

Conflicts:
	configure
	ffprobe.c
	libavcodec/Makefile
	libavcodec/g723_1.c
	libavcodec/v210dec.h
	libavcodec/vda.h
	libavcodec/vda_h264.c
	libavcodec/x86/cabac.h
	libavfilter/x86/yadif_template.c
	libswscale/x86/rgb2rgb_template.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-14 15:34:39 +02:00
Mans Rullgard
8ec0204ee4 x86: cabac: allow building with suncc
This fixes two issues preventing suncc from building this code.

The undocumented 'a' operand modifier, causing gcc to omit a $ in
front of immediate operands (as required in addresses), is not
supported by suncc.  Luckily, the also undocumented 'c' modifer
has the same effect and is supported.

On some asm statements with a large number of operands, suncc for no
obvious reason fails to correctly substitute some of the operands.
Fortunately, some of the operands in these statements are plain
numbers which can be inserted directly into the code block instead
of passed as operands.

With these changes, the code builds correctly with both gcc and
suncc.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-08-13 14:51:52 +01:00
Michael Niedermayer
9f088a1ed4 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  mpegvideo: reduce excessive inlining of mpeg_motion()
  mpegvideo: convert mpegvideo_common.h to a .c file
  build: factor out mpegvideo.o dependencies to CONFIG_MPEGVIDEO
  Move MASK_ABS macro to libavcodec/mathops.h
  x86: move MANGLE() and related macros to libavutil/x86/asm.h
  x86: rename libavutil/x86_cpu.h to libavutil/x86/asm.h
  aacdec: Don't fall back to the old output configuration when no old configuration is present.
  rtmp: Add message tracking
  rtsp: Support mpegts in raw udp packets
  rtsp: Support receiving plain data over UDP without any RTP encapsulation
  rtpdec: Remove an unused include
  rtpenc: Remove an av_abort() that depends on user-supplied data
  vsrc_movie: discourage its use with avconv.
  avconv: allow no input files.
  avconv: prevent invalid reads in transcode_init()
  avconv: rename OutputStream.is_past_recording_time to finished.

Conflicts:
	configure
	doc/filters.texi
	ffmpeg.c
	ffmpeg.h
	libavcodec/Makefile
	libavcodec/aacdec.c
	libavcodec/mpegvideo.c
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-09 19:31:56 +02:00
Mans Rullgard
c318626ce2 x86: rename libavutil/x86_cpu.h to libavutil/x86/asm.h
This puts x86-specific things in the x86/ subdirectory where they
belong.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-08-09 00:58:20 +01:00
Michael Niedermayer
a6ff8514a9 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  wtv: Check the return value from gmtime
  x86: fft: convert sse inline asm to yasm
  x86: place some inline asm under #if HAVE_INLINE_ASM

Conflicts:
	libavcodec/x86/fft_sse.c
	libavformat/wtv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-25 16:55:31 +02:00
Ronald S. Bultje
8123e0901f x86: place some inline asm under #if HAVE_INLINE_ASM
Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-06-25 13:23:12 +01:00
Roland Scheidegger
82c71913e4 h264: new assembly version of get_cabac for x86_64 with PIC
This adds a hand-optimized assembly version for get_cabac much like the
existing one, but it works if the table offsets are RIP-relative.
Compared to the non-RIP-relative version this adds 2 lea instructions
and it needs one extra register.
There is a surprisingly large performance improvement over the c version (more
so than the generated assembly seems to suggest) just in get_cabac, I measured
roughly 40% faster for get_cabac on a K8. However, overall the difference is
not that big, I measured roughly 5% on a test clip on a K8 and a Core2.
Hopefully it still compiles on x86 32bit...
Now that only one table is used, there's some chance even darwin as compiles
this (apparently the label arithmetic used previously doesn't work if it
involves symbols defined in a different file, thanks to Ronald S. Bultje for
helping me with this).

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-28 20:02:27 +02:00
Roland Scheidegger
7f668cd2b5 h264: use one table instead of several for cabac functions
The reason is this is easier for PIC code (in particular on darwin...).
Keep the old names as pointers (static in cabac_functions.h so gcc
knows these are just immediate offsets) so the c code can nicely stay the same
(alternatively could use offsets directly in the functions needing the
tables). This should produce the same code as before with non-pic and better
code (confirmed) with pic.

The assembly uses the new table but still won't work for PIC case.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-28 20:02:27 +02:00
Roland Scheidegger
5520df6a8f h264: (trivial) remove unneeded macro argument in x86/cabac.h
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-28 20:02:27 +02:00
Roland Scheidegger
9b9df1cdff h264: new assembly version of get_cabac for x86_64 with PIC
This adds a hand-optimized assembly version for get_cabac much like the
existing one, but it works if the table offsets are RIP-relative.
Compared to the non-RIP-relative version this adds 2 lea instructions
and it needs one extra register. get_cabac() gets about 40% faster, for
an overall speedup of about 5%.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2012-04-28 09:43:25 -07:00
Roland Scheidegger
14e9ffc1e4 h264: use one table instead of several for cabac functions
The reason is this is easier for PIC code (in particular on darwin...).
Keep the old names as pointers (static in cabac_functions.h so gcc
knows these are just immediate offsets) so the c code can nicely stay the same
(alternatively could use offsets directly in the functions needing the
tables). This should produce the same code as before with non-pic and better
code (confirmed) with pic.

The assembly uses the new table but still won't work for PIC case.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2012-04-28 08:26:12 -07:00
Roland Scheidegger
444f47b55c h264: (trivial) remove unneeded macro argument in x86/cabac.h
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2012-04-28 08:24:56 -07:00
Michael Niedermayer
9849515214 Revert "h264: assembly version of get_cabac for x86_64 with PIC (v4)"
This broke compilation on darwin, revert until a better solution is found.

This reverts commit a812b599b5.
2012-04-21 02:09:27 +02:00
Roland Scheidegger
a812b599b5 h264: assembly version of get_cabac for x86_64 with PIC (v4)
This adds a hand-optimized assembly version for get_cabac much like the
existing one, but it works if the table offsets are RIP-relative.
Compared to the non-RIP-relative version this adds 2 lea instructions
and it needs one extra register.
There is a surprisingly large performance improvement over the c version (more
so than the generated assembly seems to suggest) just in get_cabac, I measured
roughly 40% faster for get_cabac on a K8. However, overall the difference is
not that big, I measured roughly 5% on a test clip on a K8 and a Core2.
Hopefully it still compiles on x86 32bit...
v2: incorporated feedback from Loren Merritt to avoid rip-relative movs
for every table, and got rid of unnecessary @GOTPCREL.
v3: apply similar fixes to the the decode_significance functions, and use
same macro arguments for non-pic case.
v4: prettify inline asm arguments, add a non-fast-cmov version (as I expect
the c code to be faster otherwise since both cmov and sbb suck hard on a
Prescott, even can't construct the mask with a 64bit shift as that's just as
terrible - it's quite difficult to find usable instructions on that chip...).
This is tested to work but not on a P4, in theory it _should_ be fast there.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-21 00:27:06 +02:00
Michael Niedermayer
d40ff29cac Merge remote-tracking branch 'qatar/master'
* qatar/master:
  asf: only set index_read if the index contained entries.
  cabac: add overread protection to BRANCHLESS_GET_CABAC().
  cabac: increment jump locations by one in callers of BRANCHLESS_GET_CABAC().
  cabac: remove unused argument from BRANCHLESS_GET_CABAC_UPDATE().
  cabac: use struct+offset instead of memory operand in BRANCHLESS_GET_CABAC().
  h264: add overread protection to get_cabac_bypass_sign_x86().
  h264: reindent get_cabac_bypass_sign_x86().
  h264: use struct offsets in get_cabac_bypass_sign_x86().
  h264: fix overreads in cabac reader.
  wmall: fix seeking.
  lagarith: fix buffer overreads.
  dvdec: drop unnecessary dv_tablegen.h #include
  build: fix doc generation errors in parallel builds
  Replace memset(0) by zero initializations.
  faandct: Remove FAAN_POSTSCALE define and related code.
  dvenc: print allowed profiles if the video doesn't conform to any of them.
  avcodec_encode_{audio,video}: only reallocate output packet when it has non-zero size.
  FATE: add a test for vp8 with changing frame size.
  fate: add kgv1 fate test.
  oggdec: calculate correct timestamps in Ogg/FLAC

Conflicts:
	libavcodec/4xm.c
	libavcodec/cook.c
	libavcodec/dvdata.c
	libavcodec/dvdsubdec.c
	libavcodec/lagarith.c
	libavcodec/lagarithrac.c
	libavcodec/utils.c
	tests/fate/video.mak

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-29 04:11:10 +02:00
Ronald S. Bultje
a940198130 cabac: add overread protection to BRANCHLESS_GET_CABAC().
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
2012-03-28 08:01:29 -07:00
Ronald S. Bultje
16f6e83f74 cabac: remove unused argument from BRANCHLESS_GET_CABAC_UPDATE(). 2012-03-28 08:01:29 -07:00
Ronald S. Bultje
951014e5bb cabac: use struct+offset instead of memory operand in BRANCHLESS_GET_CABAC(). 2012-03-28 08:01:29 -07:00
Ronald S. Bultje
a0bdcb019e h264: add overread protection to get_cabac_bypass_sign_x86(). 2012-03-28 08:01:29 -07:00
Ronald S. Bultje
95bfa4ead7 h264: reindent get_cabac_bypass_sign_x86(). 2012-03-28 08:01:29 -07:00
Ronald S. Bultje
db025929f2 h264: use struct offsets in get_cabac_bypass_sign_x86(). 2012-03-28 08:01:29 -07:00
Michael Niedermayer
5387f9917f cabac: Try to disable problematic ASM for gcc-llvm 4.2.1
This should fix compilation with gcc-llvm (see darwin fate box)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-11 22:30:21 +01:00
Michael Niedermayer
f247f4cf47 cabac: 3rd try at working around a compiler bug in clang.
Switch to a broader detection of versions.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-09 16:04:26 +01:00
Michael Niedermayer
444632eae6 cabac: Disable get_cabac_inline_x86() for clang 2.9 on x86_32
This should finally fix the compilation issue on darwin

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-09 03:43:56 +01:00
Michael Niedermayer
2138a89e71 Revert "Revert commit 599b4c6efddaed33b1667c386b34b07729ba732b"
This reverts commit c4f237a981.
This didnt fix compilation on darwin with current clang.
2012-01-09 03:32:06 +01:00
Michael Niedermayer
c4f237a981 Revert commit 599b4c6efd
Author: Mans Rullgard <mans@mansr.com>
	Date:   Sun Dec 11 21:41:59 2011 +0000

    	x86: cabac: replace explicit memory references with "m" operands

    	This replaces the explicit offset(reg) memory references with
    	"m" operands for the same locations.  As a result, one fewer
    	register operand is needed for these inline asm statements.

This change appears to have broken compilation on darwin, and subsequent
fixes by martin (which did not fix compilation) removed the register
advantage, thus this change seems not a good idea to keep.
See: http://fate.ffmpeg.org/log.cgi?time=20120103122446&log=compile&slot=i386-darwin-llvm-gcc-4.2.1

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-06 01:46:51 +01:00
Martin Storsjö
8349dbfe46 x86: Require 7 registers for the cabac asm
The change in 599b4c6ef didn't turn out to work properly on
i386 on OS X, where it broke building with PIC enabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit f1dba9e498)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-12 15:39:37 +01:00
Martin Storsjö
f1dba9e498 x86: Require 7 registers for the cabac asm
The change in 599b4c6ef didn't turn out to work properly on
i386 on OS X, where it broke building with PIC enabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
2011-12-12 15:36:20 +02:00
Mans Rullgard
599b4c6efd x86: cabac: replace explicit memory references with "m" operands
This replaces the explicit offset(reg) memory references with
"m" operands for the same locations.  As a result, one fewer
register operand is needed for these inline asm statements.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-12-11 22:29:22 +00:00
Diego Biurrun
276b995d85 x86: drop pointless ARCH_X86 #ifdef from files in x86 subdirectory 2011-11-08 17:52:55 +01:00
Mans Rullgard
3ad1684126 x86: cabac: add operand size suffixes missing from 6c32576
This fixes build with clang.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-28 18:59:23 -07:00
Mans Rullgard
f5f004bc5a x86: cabac: don't load/store context values in asm
Inspection of compiled code shows gcc handles these fine on its own.
Benchmarking also shows no measurable speed difference.

Removing the remaining cases in get_cabac_bypass_sign_x86() does
cause more substantial changes to the compiled code with uncertain
impact.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-28 22:25:21 +01:00
Jason Garrett-Glaser
6c32576548 H.264: optimize CABAC x86 asm for Atom 2011-07-28 13:06:13 -07:00
Mans Rullgard
c5ee740745 x86: cabac: fix register constraints for 32-bit mode
Some operands need to be accessed in byte mode, which restricts the
available registers in 32-bit mode.  Using the 'q' constraint selects
a suitable register.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-06-20 23:36:40 +01:00
Mans Rullgard
2143d69bdd cabac: move x86 asm to libavcodec/x86/cabac.h
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-06-20 22:36:31 +01:00