Commit Graph

259 Commits

Author SHA1 Message Date
Michael Niedermayer
4c42c66935 Merge commit 'ae05b4865514fd71b5e9431e93aa0d03d7ba7751'
* commit 'ae05b4865514fd71b5e9431e93aa0d03d7ba7751':
  hevc: eliminate the second call to hls_nal_unit()

Conflicts:
	libavcodec/hevc.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-12 22:55:47 +02:00
Michael Niedermayer
760304e4c3 Merge commit 'd7bebe4805193783f0b6f292f9127a75709fb7d9'
* commit 'd7bebe4805193783f0b6f292f9127a75709fb7d9':
  hevc: skip invalid/ignored NALUs when splitting the packet

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-12 22:46:06 +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
ae05b48655 hevc: eliminate the second call to hls_nal_unit()
Also, make hls_nal_unit() work only on the provided NAL unit, without
requiring a whole decoding context.

This will allow splitting this code for reuse by the parser.
2015-07-12 18:15:39 +02:00
Anton Khirnov
d7bebe4805 hevc: skip invalid/ignored NALUs when splitting the packet
There is no need to wait until actually decoding the NALU. This will
allow to get rid of the second hls_nal_unit() call later.
2015-07-12 18:15:39 +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
Andreas Cadhalpun
9f4c7397a2 hevc: check slice address length
It is used as get_bits argument and reading 0 bits doesn't make sense.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-07-12 18:15:39 +02:00
Andreas Cadhalpun
05cc8c8e4b hevc: check slice address length
It is used as get_bits argument and reading 0 bits isn't supported.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-07-10 21:28:56 +02:00
Michael Niedermayer
07ae8fa20e Merge commit '69ab9f53f901eac6a649e22d28cf093357870627'
* commit '69ab9f53f901eac6a649e22d28cf093357870627':
  hevc: split bitstream unescaping to a separate file

Conflicts:
	libavcodec/Makefile
	libavcodec/hevc.c

See: afa93d198a
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-09 05:06:48 +02:00
Michael Niedermayer
1d4194e696 Merge commit 'fd124d8357b1becfde3ac8d5e3320127cf97a5b7'
* commit 'fd124d8357b1becfde3ac8d5e3320127cf97a5b7':
  hevc_ps: split the code for parsing the SPS and exporting it into the context

Conflicts:
	libavcodec/hevc.c
	libavcodec/hevc_ps.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-09 04:50:00 +02:00
Anton Khirnov
69ab9f53f9 hevc: split bitstream unescaping to a separate file
It will be useful in the QSV HEVC encoder.
2015-07-08 23:38:32 +02:00
Anton Khirnov
fd124d8357 hevc_ps: split the code for parsing the SPS and exporting it into the context
This will be useful in the later commits, where we want to parse an SPS
without having a whole decoding context.
2015-07-08 23:36:22 +02:00
Philip Langdale
6e5e139fe3 avcodec/vdpau: Support for VDPAU accelerated HEVC decoding
This change introduces basic support for HEVC decoding through vdpau.
Right now, there are problems with the nvidia driver/library implementation
that mean that frames are incorrectly laid out in memory when they are
returned from the decoder, and it is normally impossible to recover the
complete decoded frame due to loss of data from alignment inconsistencies.

I obviously hope that nvidia will be fixing it in due course - I've verified
the problems exist with their example application.

As such, this support is not useful for any real world application, but I
believe that it is correct (with the caveat that the mangled frames may hide
problems) and will work properly once the nvidia problem is fixed.

Right now it appears that any file encoded by x265 or nvenc is decoded
correctly, but that's because these files don't use a bunch of HEVC
features.

Quick summary:

Features that seem to work:

1) Short Term References
2) Scaling Lists
3) Tiling

Features with known problems:

1) Long Term References

It's hard to tell what's going on here. After I read the nvidia example
app that does not set the IsLongTerm flag on LTRs, and changed my code,
a bunch of frames using LTR started to display correctly, but there
are still samples with glitches that are related to LTRs.

In terms of real world files, both x265 and nvenc only use short term
refs from this list. The divx encoder seems similar.

Signed-off-by: Philip Langdale <philipl@overt.org>
2015-06-25 20:06:47 -07:00
Philip Langdale
1b19d0c632 avcodec/hevc: Track long and short term RPS size for VDPAU
Today, we track the short term RPS size for DXVA, but only if the
SliceHeader RPS is being used. Otherwise it's left uninitialized.

NVIDIA's VDPAU implementation requires that the size be accurately
tracked even if an SPS RPS is being used. In this case, it's really
counting the size of the RPS idx information, but you end up with
mangled output if the value is not accurate.

VDPAU also needs the size of the long term RPS.

Signed-off-by: Philip Langdale <philipl@overt.org>
2015-06-13 21:09:24 -07:00
Ronald S. Bultje
ade5684cda hevc: fix typo (mpv -> mvp).
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-06 12:57:20 +02:00
Michael Niedermayer
674b79148f hevc: Fix HWACCEL_MAX for D3D11
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-06-01 11:36:22 +03:00
Michael Niedermayer
688147cfe2 avcodec/hevc: Fix HWACCEL_MAX for D3D11
Found-by: philipl
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-26 05:23:29 +02:00
Michael Niedermayer
947b74ee7d Merge commit 'd8039ef8d221ea273aa4f1e62e5df21bf618c772'
* commit 'd8039ef8d221ea273aa4f1e62e5df21bf618c772':
  D3D11va: add a Direct3D11 video decoder similar to DXVA2

Conflicts:
	Changelog
	configure
	libavcodec/Makefile
	libavcodec/allcodecs.c
	libavcodec/dxva2_vc1.c
	libavcodec/version.h
	libavutil/pixdesc.c
	libavutil/pixfmt.h
	libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-25 22:24:34 +02:00
Steve Lhomme
d8039ef8d2 D3D11va: add a Direct3D11 video decoder similar to DXVA2
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-05-25 11:47:08 +02:00
Michael Niedermayer
6d1935d1b9 avcodec/hevc: Remove unused variable
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-20 18:15:22 +02:00
wm4
3efe0393e4 hevc: make avcodec_decode_video2() fail if get_format() fails
Personally, I need the decoder to back out if get_format() returns no
usable pixel format. This didn't work because the error code was not
propagated down the call chain. This in turn happened because the
variable declaration removed in this patch shadowed the variable, whose
value is returned at the end of the function. Consequently, failures of
decode_nal_unit() were ignored in this place.

Reviewed-by:  Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-19 18:59:06 +01:00
Michael Niedermayer
3051e7fa71 avcodec/hevc: Fix typo in num_entry_point_offsets check
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-15 23:46:10 +02:00
wm4
cc5e4bb484 hevc: make avcodec_decode_video2() fail if get_format() fails
Personally, I need the decoder to back out if get_format() returns no
usable pixel format. This didn't work because the error code was not
propagated down the call chain. This in turn happened because the
variable declaration removed in this patch shadowed the variable, whose
value is returned at the end of the function. Consequently, failures of
decode_nal_unit() were ignored in this place.

Reviewed-by:  Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-14 18:58:56 +02:00
Michael Niedermayer
6679d5f29a avcodec/hevc: Simplify entry_point_offset parsing
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-13 14:26:17 +02:00
Michael Niedermayer
1c6ae98d4a avcodec/hevc: Check num_entry_point_offsets
Fixes CID1239099 part 2

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-13 14:26:17 +02:00
Michael Niedermayer
3e9d5e16ad avcodec/hevc: Check offset_len
Fixes CID1239099 part 1

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-13 14:26:17 +02:00
Michael Niedermayer
3ecc063322 avcodec/hevc: Fix order of operations in hls_decode_neighbour()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-12 00:52:03 +02:00
Michael Niedermayer
0e7444f6e4 avcodec/hevc: Remove current_sps
The variable should not be needed anymore

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-28 00:04:58 +02:00
James Almer
ba625dd8a1 avcodec: use av_mod_uintp2() where useful
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-04-21 22:41:20 -03:00
Michael Niedermayer
d386a523ae Merge commit '7693ba0a0eecdcdba71b7fbd9a4a12d1ba7b82aa'
* commit '7693ba0a0eecdcdba71b7fbd9a4a12d1ba7b82aa':
  hevc: export stream parameters from extradata

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-03 21:29:54 +02:00
Michael Niedermayer
a7a6194ec4 Merge commit '1ae7afd256f9af1eb4f63f9adcf03d581ce4e2b5'
* commit '1ae7afd256f9af1eb4f63f9adcf03d581ce4e2b5':
  hevc: split out setting AVCodecContext parameters

Conflicts:
	libavcodec/hevc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-03 21:11:19 +02:00
Anton Khirnov
7693ba0a0e hevc: export stream parameters from extradata
This allows the callers to have a hint of the probable stream parameters
without actually decoding anything.
2015-04-03 13:10:03 +02:00
Anton Khirnov
1ae7afd256 hevc: split out setting AVCodecContext parameters
Additionally always set the software pixel format, so it's available
even if ff_get_format() is not called later. This will be useful for
exporting stream parameters from init().
2015-04-03 13:10:02 +02:00
Rainer Hochecker
786032cad8 hevc: avoid unnecessary calls to get_format
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-16 20:48:14 +01:00
Michael Niedermayer
12cf61c3b2 avcodec/hevc: Fix undefined shifts
Found-by: Clang -fsanitize=shift
Reported-by: Thierry Foucu <tfoucu@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-16 14:27:11 +01:00
Rainer Hochecker
31816eae32 hevc: delay ff_thread_finish_setup for hwaccel
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-12 14:49:41 +01:00
Michael Niedermayer
114a2eb272 avcodec: Use av_clip_uintp2() where possible
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-21 15:50:03 +01:00
Michael Niedermayer
3e2714992b Merge commit 'eea769df322fac2601a96db195fa7dc8d12a8fbc'
* commit 'eea769df322fac2601a96db195fa7dc8d12a8fbc':
  hevc: Use generic av_clip function, not C implementation

Conflicts:
	libavcodec/hevc.c
	libavcodec/hevc_filter.c
	libavcodec/hevc_mvs.c

See: 83976e40e8
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-13 12:34:18 +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
Michael Niedermayer
43b1fd5bb4 avcodec/hevc: drop redundant ifs()
Found-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-05 22:29:55 +01:00
Christophe Gisquet
9a2f5d825a hevc: free sao buffers when receiving a new SPS
The buffer pointers would be otherwise overwritten, causing a
leak on e.g. PERSIST_RPARAM_A_RExt_Sony_1.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-05 21:50:35 +01: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
Christophe Gisquet
00fe77855b avcodec/hevc: Do not zero is_pcm on allocation
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-04 01:54:13 +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
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
bff7feb328 x86: hevc/sao: aligned source buffers
Usefull for at least band filter, for which:
- Band filter call only:
           32      64
Before:  16556    54015
After:   16497    52355
- Whole case:
           32      64
Before:  37031   103008
After:   32045    93952
2015-02-01 20:22:54 -03:00
Michael Niedermayer
2b215b7f5a avcodec/hevc: Check for av_malloc failure
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-30 00:44:51 +01:00
Michael Niedermayer
5008605bf2 avcodec/hevc: Replace more mallocs by av_malloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-30 00:44:50 +01:00
Michael Niedermayer
a7fa1b9aa1 Merge commit '443b71928b2f36362e805c037751e6c3c79ea4e8'
* commit '443b71928b2f36362e805c037751e6c3c79ea4e8':
  hevc: unref the current frame if frame_start() fails

Conflicts:
	libavcodec/hevc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-27 13:15:06 +01:00
Hendrik Leppkes
36962ad233 Add DXVA2 HEVC HWAccel
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-27 12:37:34 +01:00