1
0
Fork 0
Commit Graph

82 Commits

Author SHA1 Message Date
Andreas Rheinhardt a807e469d5 avcodec/hevcdec: Switch to ProgressFrames
Avoids implicit av_frame_ref() and therefore allocations
and error checks. It also avoids explicitly allocating
the AVFrames (done implicitly when getting the buffer).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-19 13:18:04 +02:00
Andreas Rheinhardt 8c4f95e1e1 avcodec/hevc_filter: Pass HEVCLocalContext when slice-threading
The HEVC decoder has both HEVCContext and HEVCLocalContext
structures. The latter is supposed to be the structure
containing the per-slicethread state.

Yet that is not how it is handled in practice: Each HEVCLocalContext
has a unique HEVCContext allocated for it and each of these
coincides with the main HEVCContext except in exactly one field:
The corresponding HEVCLocalContext.
This makes it possible to pass the HEVCContext everywhere where
logically a HEVCLocalContext should be used.

This commit stops doing this for lavc/hevc_filter.c; it also constifies
everything that is possible in order to ensure that no slice thread
accidentally modifies the main HEVCContext state.

There are places where this was not possible, namely with the SAOParams
in sao_filter_CTB() or with sao_pixels_buffer_h in copy_CTB_to_hv().
Both of these instances lead to data races, see
https://fate.ffmpeg.org/report.cgi?time=20220629145651&slot=x86_64-archlinux-gcc-tsan-slices

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-25 23:31:37 +02:00
Michael Niedermayer 009ef35d38 avcodec/hevc_filter: copy_CTB() only within width&height
Fixes: out of array access
Fixes: 49271/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5424984922652672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-22 17:25:25 +02:00
Andreas Rheinhardt c34e3920f2 avcodec/hevc_refs: Constify ff_hevc_get_ref_list()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:28:02 +02:00
Andreas Rheinhardt b3551b6072 avcodec/thread: Move ff_thread_(await|report)_progress to new header
This is in preparation for further commits that will stop
using ThreadFrame for frame-threaded codecs that don't use
ff_thread_(await|report)_progress(); the API for those codecs
having inter-frame depdendencies will live in threadframe.h.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:22:16 +01:00
Limin Wang 77970abb71 avcodec/hevc_filter: Correct indention
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:57:53 +08:00
Limin Wang 5a91850b61 avcodec/hevc_filter: remove unneeded headers
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:57:47 +08:00
sfan5 a428f2fcd9 libavcodec/hevc_filter: move AVDISCARD_NONREF switch-case into function
In preparation for implementation of skip_frame.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-08 20:02:16 +01:00
sfan5 942eafcf08 libavcodec/hevc_filter: support for all skip_loop_filter levels.
Continues where commit 52c75d486e left off.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-04 19:05:36 +01:00
Michael Niedermayer d7b3d5c3f2 avcodec/hevc_filter: Fix invalid shift
Fixes: runtime error: left shift of negative value -1

Fixes: 2299/clusterfuzz-testcase-minimized-4843509351710720

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-21 02:25:23 +02:00
Clément Bœsch 038e6aef7a Merge commit '4abe3b049d987420eb891f74a35af2cebbf52144'
* commit '4abe3b049d987420eb891f74a35af2cebbf52144':
  hevc: rename hevc.[ch] to hevcdec.[ch]

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:48:41 +01:00
James Almer 1e18548826 Merge commit 'ba479f3daafc7e4359ec1212164569ebe59f0bb7'
* commit 'ba479f3daafc7e4359ec1212164569ebe59f0bb7':
  hevc: Change type of array stride parameters to ptrdiff_t

Merged-by: James Almer <jamrial@gmail.com>
2017-03-21 15:49:09 -03:00
Anton Khirnov 4abe3b049d hevc: rename hevc.[ch] to hevcdec.[ch]
This is more consistent with the rest of libav and frees up the hevc.h
name for decoder-independent shared declarations.
2016-10-16 20:26:17 +02:00
Diego Biurrun ba479f3daa hevc: Change type of array stride parameters to ptrdiff_t
ptrdiff_t is the correct type for array strides and similar.
2016-09-29 17:54:23 +02:00
Clément Bœsch bef74ef367 Merge commit '4f81f8dba735c212efae077c4fec8ad4fe53b352'
* commit '4f81f8dba735c212efae077c4fec8ad4fe53b352':
  Drop unnecessary golomb.h #includes

Merged-by: Clément Bœsch <clement@stupeflix.com>
2016-06-29 11:54:54 +02:00
Diego Biurrun 4f81f8dba7 Drop unnecessary golomb.h #includes 2016-06-08 18:51:57 +02:00
Michael Niedermayer 29d147c94d Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'
* commit '059a934806d61f7af9ab3fd9f74994b838ea5eba':
  lavc: Consistently prefix input buffer defines

Conflicts:
	doc/examples/decoding_encoding.c
	libavcodec/4xm.c
	libavcodec/aac_adtstoasc_bsf.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.h
	libavcodec/asvenc.c
	libavcodec/avcodec.h
	libavcodec/avpacket.c
	libavcodec/dvdec.c
	libavcodec/ffv1enc.c
	libavcodec/g2meet.c
	libavcodec/gif.c
	libavcodec/h264.c
	libavcodec/h264_mp4toannexb_bsf.c
	libavcodec/huffyuvdec.c
	libavcodec/huffyuvenc.c
	libavcodec/jpeglsenc.c
	libavcodec/libxvid.c
	libavcodec/mdec.c
	libavcodec/motionpixels.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/noise_bsf.c
	libavcodec/nuv.c
	libavcodec/nvenc.c
	libavcodec/options.c
	libavcodec/parser.c
	libavcodec/pngenc.c
	libavcodec/proresenc_kostya.c
	libavcodec/qsvdec.c
	libavcodec/svq1enc.c
	libavcodec/tiffenc.c
	libavcodec/truemotion2.c
	libavcodec/utils.c
	libavcodec/utvideoenc.c
	libavcodec/vc1dec.c
	libavcodec/wmalosslessdec.c
	libavformat/adxdec.c
	libavformat/aiffdec.c
	libavformat/apc.c
	libavformat/apetag.c
	libavformat/avidec.c
	libavformat/bink.c
	libavformat/cafdec.c
	libavformat/flvdec.c
	libavformat/id3v2.c
	libavformat/isom.c
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/mpc.c
	libavformat/mpc8.c
	libavformat/mpegts.c
	libavformat/mvi.c
	libavformat/mxfdec.c
	libavformat/mxg.c
	libavformat/nutdec.c
	libavformat/oggdec.c
	libavformat/oggparsecelt.c
	libavformat/oggparseflac.c
	libavformat/oggparseopus.c
	libavformat/oggparsespeex.c
	libavformat/omadec.c
	libavformat/rawdec.c
	libavformat/riffdec.c
	libavformat/rl2.c
	libavformat/rmdec.c
	libavformat/rtpdec_latm.c
	libavformat/rtpdec_mpeg4.c
	libavformat/rtpdec_qdm2.c
	libavformat/rtpdec_svq3.c
	libavformat/sierravmd.c
	libavformat/smacker.c
	libavformat/smush.c
	libavformat/spdifenc.c
	libavformat/takdec.c
	libavformat/tta.c
	libavformat/utils.c
	libavformat/vqf.c
	libavformat/westwood_vqa.c
	libavformat/xmv.c
	libavformat/xwma.c
	libavformat/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 23:15:19 +02:00
Nicolas George 52c75d486e lavc/hevc: rudimentary support for skip_loop_filter.
+~9% speed on Core i5 on test sample.

All frames are treated as ref frames, skipping only applies
at level "all". The following mail contains information on
how to improve that:
http://ffmpeg.org/pipermail/ffmpeg-devel/2015-July/176116.html
2015-07-23 16:26:14 +02:00
Michael Niedermayer d5fcca83b9 Merge commit 'b11acd57326db6c2cc1475dd0bea2a06fbc85aa2'
* commit 'b11acd57326db6c2cc1475dd0bea2a06fbc85aa2':
  hevc: remove HEVCContext usage from hevc_ps

Conflicts:
	libavcodec/hevc.c
	libavcodec/hevc_cabac.c
	libavcodec/hevc_filter.c
	libavcodec/hevc_mvs.c
	libavcodec/hevc_ps.c
	libavcodec/hevc_refs.c
	libavcodec/hevcpred_template.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-12 22:28:54 +02:00
Anton Khirnov b11acd5732 hevc: remove HEVCContext usage from hevc_ps
Factor out the parameter sets into a separate struct and use it instead.

This will allow us to reuse this code in the parser.
2015-07-12 18:15:39 +02:00
Christophe Gisquet efd3f407e5 hevc/sao: use unaligned copy
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-02 19:32:23 +01:00
Peter Meerwald eea769df32 hevc: Use generic av_clip function, not C implementation
hevc seems to be the only place where the C implementation
of the av_clip function is explicitly selected, precluding
platform-specific optimizations

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-02-13 08:37:13 +01:00
Christophe Gisquet 97996eff4f hevc/sao: do in-place band filtering when possible
The copies are only needed when data must be restored, so skip them
when it must not be.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-07 18:04:25 +01:00
James Almer 042c1159fc x86/hevcdsp: add ff_hevc_sao_edge_filter_8_{ssse3,avx2}
Original x86 intrinsics code and initial yasm port by Pierre-Edouard Lepere.
Refactoring and optimizations by James Almer.

Benchmarks of BQTerrace_1920x1080_60_qp22.bin with an Intel Core i5-4200U

Width 32
158583 decicycles in edge, sao_edge_filter_8 runs, 0 skips
5205 decicycles in ff_hevc_sao_edge_filter_32_8_ssse3, 32767 runs, 1 skips
2942 decicycles in ff_hevc_sao_edge_filter_32_8_avx2, 32767 runs, 1 skips

Width 64
705639 decicycles in sao_edge_filter_8, 262144 runs, 0 skips
19224 decicycles in ff_hevc_sao_edge_filter_64_8_ssse3, 262111 runs, 33 skips
10433 decicycles in ff_hevc_sao_edge_filter_64_8_avx2, 262115 runs, 29 skips

Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-05 15:02:27 -03:00
James Almer 1f1c7c8a57 hevcdsp: remove compilation-time-fixed parameter from sao_edge_filter
The stride_src parameter is always 2 * MAX_PB_SIZE + FF_INPUT_BUFFER_PADDING_SIZE.

Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-05 15:02:22 -03:00
James Almer 7457afc64d hevcdsp: replace the SAOParams struct parameter from sao_edge_filter
As with sao_band_filter, pass instead the two variables from the struct needed in the function.
This simplifies writing asm optimized versions.

Reviewed-by: Mickaël Raulet <mraulet@insa-rennes.fr>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-04 17:53:04 -03:00
Seppo Tomperi 4386e1fd94 hevcdsp: simplified sao_edge_filter
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Reviewed-by: Mickaël Raulet <mraulet@insa-rennes.fr>
2015-02-04 17:52:54 -03:00
Seppo Tomperi 74d7faf400 hevcdsp: separated sao edge filter and pixel restore funcs
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Reviewed-by: Mickaël Raulet <mraulet@insa-rennes.fr>
2015-02-04 17:52:49 -03:00
Christophe Gisquet 52f2adc015 avcodec/hevc: Update the USE_SAO_SMALL_BUFFER case for the alignment requirements in FFmpeg
Use edge emu buffers
And enable the code unconditionally

Speed difference without USE_SAO_SMALL_BUFFER and with the new code:
Decicycles: 26772->26220 (BO32),  83803->80942 (BO64)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-04 01:54:22 +01:00
Fabrice Bellard da81cc38e8 avcodec/hevc: reduce memory for SAO
cherry picked from commit 5d9f79edef2c11b915bdac3a025b59a32082f409

SAO edge filter uses pre-SAO pixel data on the left and top of the ctb, so
this data must be kept available. This was done previously by having 2
copies of the frame, one before and one after SAO.

This commit reduces the storage to just that, instead of the previous whole
frame.

Commit message taken from patch by Christophe Gisquet <christophe.gisquet@gmail.com>

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-04 01:54:01 +01:00
Michael Niedermayer d525b45fde avcodec/hevc_filter: Fix indention
Found-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-02 19:56:44 +01:00
Mickaël Raulet 7cf6a67ef9 avcodec/hevc: adding support for monochrome sequences in hevc
cherry picked from commit 8e50557707d2ec11ccad657470b2e140f314348e

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-02 18:10:57 +01:00
Christophe Gisquet 6a6aeb538b hevc/sao: use aligned copies
For band filter, source and destination are aligned (except for 16x16 ctbs),
and otherwise, they are most often aligned. Overall, the total width is also
too small for amortizing memcpy.

Timings (using an intrinsic version of edge filters):
          B/32     B/64     E/32     E/64
Before:  32045    93952    38925    126896
After:   26772    83803    33942    117182
2015-02-01 20:23:03 -03:00
James Almer fa3eccb4f9 x86/hevc: add ff_hevc_sao_band_filter_{8,10,12}_{sse2,avx,avx2}
Original x86 intrinsics code and initial 8bit yasm port by Pierre-Edouard Lepere.
10/12bit yasm ports, refactoring and optimizations by James Almer

Benchmarks of BQTerrace_1920x1080_60_qp22.bin with an Intel Core i5-4200U

width 32
40338 decicycles in sao_band_filter_0_8, 2048 runs, 0 skips
8056 decicycles in ff_hevc_sao_band_filter_8_32_sse2, 2048 runs, 0 skips
7458 decicycles in ff_hevc_sao_band_filter_8_32_avx, 2048 runs, 0 skips
4504 decicycles in ff_hevc_sao_band_filter_8_32_avx2, 2048 runs, 0 skips

width 64
136046 decicycles in sao_band_filter_0_8, 16384 runs, 0 skips
28576 decicycles in ff_hevc_sao_band_filter_8_32_sse2, 16384 runs, 0 skips
26707 decicycles in ff_hevc_sao_band_filter_8_32_avx, 16384 runs, 0 skips
14387 decicycles in ff_hevc_sao_band_filter_8_32_avx2, 16384 runs, 0 skips

Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-01 20:22:35 -03:00
James Almer 2929e56006 hevcdsp: replace the SAOParams struct parameter from sao_band_filter
Pass instead the two variables from the struct needed in the function.
This simplifies writing asm optimized versions of the function

Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-01 15:45:20 -03:00
James Almer 65e6ab0c5a hevcdsp: remove unused parameter from sao_band_filter
Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-01 15:45:14 -03:00
Michael Niedermayer 499ff6a052 Merge commit '7acdd3a1275bcd9cad48f9632169f6bbaeb39d84'
* commit '7acdd3a1275bcd9cad48f9632169f6bbaeb39d84':
  hevc_filter: avoid excessive calls to ff_hevc_get_ref_list()

Conflicts:
	libavcodec/hevc_filter.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-09 21:49:55 +02:00
Michael Niedermayer 8d7c4cc082 Merge commit 'a7a17e3f1915ce69b787dc58c5d8dba0910fc0a4'
* commit 'a7a17e3f1915ce69b787dc58c5d8dba0910fc0a4':
  hevc_filter: move some conditions out of loops

Conflicts:
	libavcodec/hevc_filter.c

This is possibly less readable than the variant used before.
Thus please take a look and if people agree its worse, dont
hesitate to revert.

See: 83976e40e8
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-09 21:29:33 +02:00
Anton Khirnov 7acdd3a127 hevc_filter: avoid excessive calls to ff_hevc_get_ref_list()
1) each of the loops run within a single CTB, so the relevant reference
list is constant
2) when that CTB is, or lies on the same slice as, the current one, we
can use a simple access instead of a relatively expensive call to
ff_hevc_get_ref_list()
2014-08-09 16:15:51 +00:00
Anton Khirnov a7a17e3f19 hevc_filter: move some conditions out of loops 2014-08-09 16:15:11 +00:00
Anton Khirnov 70211539a3 hevc: deobfuscate slice/tile boundary handling for DBF
Use named constants instead of magic numbers, avoid using variables with
inverse meaning from what their name implies.
2014-08-09 16:13:48 +00:00
Anton Khirnov 5501971578 hevc_filter: drop more redundant checks
The if() around those loops ensures this condition is always false.
2014-08-09 16:13:37 +00:00
Anton Khirnov 65b8b6c476 hevc_filter: drop redundant checks
ff_hevc_deblocking_boundary_strengths() is never called if the
deblocking filter is disabled for the slice.
2014-08-09 16:13:24 +00:00
Christophe Gisquet 6786848585 hevc_deblock: change tc type
The x86 asm expects int32_t so use that type.

Reviewed-by: Mickaël Raulet <mraulet@insa-rennes.fr>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-06 12:38:26 +02:00
Christophe Gisquet 65746bfbae hevc_filter: run vertical and horizontal together
This should help cache locality. On win64:
Before: 1397x cycles, 16216 bytes
After:  1369x cycles, 16040 bytes

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-29 03:56:43 +02:00
Anton Khirnov a5c621aa85 hevc: rename variable in boundary strength to b more explicit
Signed-off-by: Mickaël Raulet <mraulet@insa-rennes.fr>

cherry picked from commit 348bebedc0012aae201419669fca1eb61ec93ca6
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-28 14:20:19 +02:00
Mickaël Raulet 3b777db132 hevc: remove non necessary parameters to ff_hevc_set_qpy
cherry picked from commit 6f58c111ad9920d983bb18eacf901193bac5d937

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-28 00:39:13 +02:00
Michael Niedermayer 226b290f9f Merge commit '73bb8f61d48dbf7237df2e9cacd037f12b84b00a'
* commit '73bb8f61d48dbf7237df2e9cacd037f12b84b00a':
  hevcdsp: remove an unneeded variable in the loop filter

Conflicts:
	libavcodec/hevc_filter.c

See: d7e162d46b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-26 23:53:31 +02:00
Anton Khirnov 73bb8f61d4 hevcdsp: remove an unneeded variable in the loop filter
beta0 and beta1 will always be the same
2014-07-26 15:00:11 +00:00
Anton Khirnov d7e162d46b hevcdsp: remove an unneeded variable in the loop filter
beta0 and beta1 will always be the same within a CU

Signed-off-by: Mickaël Raulet <mraulet@insa-rennes.fr>

cherry picked from commit 4a23d824741a289c7d2d2f2871d1e2621b63fa1b
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-22 16:27:26 +02:00