Commit Graph

36 Commits

Author SHA1 Message Date
James Almer 4b053b8db1 avcodec/av1dec: honor the requested skip_frame level
This supports dropping non-intra, non-key, or all frames.

Tested-by: nevcairiel
Signed-off-by: James Almer <jamrial@gmail.com>
2022-01-11 09:51:58 -03:00
Fei Wang 7787cca180 lavc/av1dec: use frame split bsf
Split packed data in case of its contains multiple show frame in some
non-standard bitstream. This can benefit decoder which can decode
continuously instead of interrupt with unexpected error.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-07 14:05:58 +08:00
Fei Wang de7475b111 avcodec/av1dec: support setup shear process
Defined in spec 7.11.3.6/7.11.3.7.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
James Almer 9b05263ac1 avcodec/av1: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
Andreas Rheinhardt a247ac640d avcodec: Constify AVCodecs
Given that the AVCodec.next pointer has now been removed, most of the
AVCodecs are not modified at all any more and can therefore be made
const (as this patch does); the only exceptions are the very few codecs
for external libraries that have a init_static_data callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:15 -03:00
James Almer 5f9632e491 avcodec/av1dec: add an option to select an operating point
Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-04 16:28:29 -03:00
Andreas Rheinhardt 2c6f532e0a Mark some pointers as const
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-01 15:25:48 +01:00
James Almer 1a8e719f36 avcodec/av1dec: support exporting Film Grain params as frame side data
Signed-off-by: James Almer <jamrial@gmail.com>
2020-12-16 13:34:11 -03:00
Philip Langdale 67bb11b5f6 avcodec/nvdec: Add support for decoding monochrome av1
The nvidia hardware explicitly supports decoding monochrome content,
presumably for the AVIF alpha channel. Supporting this requires an
adjustment in av1dec and explicit monochrome detection in nvdec.

I'm not sure why the monochrome path in av1dec did what it did - it
seems non-functional - YUV440P doesn't seem a logical pix_fmt for
monochrome and conditioning on chroma sub-sampling doesn't make sense.
So I changed it.

I've tested 8bit content, but I haven't found a way to create a 10bit
sample, so that path is untested for now.
2020-12-06 14:59:24 -08:00
Andreas Rheinhardt e546d02919 avcodec/av1dec: Fix leak in case of failure
A reference to an AV1RawFrameHeader and consequently the
AV1RawFrameHeader itself and everything it has a reference to leak
if the hardware has no AV1 decoding capabilities or if some other error
happens. It happens e.g. in the cbs-av1-av1-1-b8-02-allintra FATE-test;
it has just been masked because the return value of ffmpeg (which
indicates failure when using Valgrind or ASAN) is ignored when doing
tests of type md5.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-05 00:29:09 +01:00
James Almer eee7ba8dba avcodec/av1dec: infer and store film grain param values in AV1Frame
They are not always coded in the bistream for each frame. In some cases, the
values need to be taken from a reference frame.

See section 6.8.20 from the AV1 spec.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-11-30 19:12:39 -03:00
Jan Ekström 8fbc139e61 avcodec/av1{dec,parser}: move to ff_cbs_read_extradata_from_codec
This lets us re-utilize the extradata-related checks in the CBS
to add support for passing the AV1CodecConfigurationRecord
as extradata as-is without further filtering.
2020-11-24 10:13:55 +02:00
James Almer 5d4a6bbd4b avcodec/av1dec: remove order_hint from AV1Frame
We now have access to the raw frame header, so use that

Signed-off-by: James Almer <jamrial@gmail.com>
2020-11-13 10:38:18 -03:00
James Almer f5517be32a avcodec/av1dec: add a reference to the raw frame header to AV1Frames
Signed-off-by: James Almer <jamrial@gmail.com>
2020-11-13 10:38:18 -03:00
Hendrik Leppkes 8f4aec719e avcodec/dxva2: add AV1 decode support
Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
2020-11-12 15:55:16 +01:00
Timo Rothenpieler ac5b45abab avcodec/nvdec: add av1 hwaccel
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Co-authored-by: James Almer <jamrial@gmail.com>
2020-11-11 18:36:09 +01:00
Timo Rothenpieler 5868f1c66b avcodec/av1dec: expose coded_lossless
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Co-authored-by: James Almer <jamrial@gmail.com>
2020-11-11 18:36:09 +01:00
Timo Rothenpieler e1efff8906 avcodec/av1dec: expose skip mode frame index
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Co-authored-by: James Almer <jamrial@gmail.com>
2020-11-11 18:36:09 +01:00
Fei Wang 3308bbf776 avcodec: add av1 VAAPI decoder
Example cmdline:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -v verbose \
-c:v av1 -i input.ivf -pix_fmt yuv420p -vsync passthrough -f md5     \
-y out.md5

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2020-11-02 22:57:23 +00:00
James Almer fec1b4738f avcodec/av1dec: fix loading PrevGmParams for frames with primary_ref_frame none
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-28 11:26:25 -03:00
James Almer 7dac8ddb20 avcodec/av1dec: don't derive loop filter delta parameters
This is now handled by CBS.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-28 11:26:25 -03:00
Michael Niedermayer 718e862da3 avcodec/av1dec: Check for unset obu instead of crashing
Fixes: NULL pointer dereference
Fixes: 26550/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5417762807349248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-26 19:27:53 +01:00
James Almer 0ed455b84e avcodec/av1dec: add cur_frame.spatial_id and temporal_id to AV1Frame
Will be used by hwaccels, which have access to a frame's AV1RawFrameHeader but not
its AV1RawOBUHeader.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-16 13:34:31 -03:00
James Almer 214998c55f avcodec/av1dec: avoid probing with av1dec
av1dec should no longer attempt to output empty frames if another decoder
was used for probing and it sucessfully set a pix_fmt ever since 05872c67a4,
so we can re-add the AV_CODEC_CAP_AVOID_PROBING cap.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-06 11:28:12 -03:00
James Almer 05872c67a4 avcodec/av1dec: partially clean state on frame decoding errors
Fixes: member access within null pointer of type 'TileGroupInfo' (aka 'struct TileGroupInfo')
Fixes: 25725/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5166692706287616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-04 10:34:15 -03:00
James Almer aa5e49e46d avcodec/av1dec: call ff_cbs_flush() on decoder flush
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-29 21:38:27 -03:00
James Almer 3392c1b05e avcodec/av1dec: fix check for active sequence header
We clear the AV1RawSequenceHeader pointer on flush, not the relevant AVBufferRef.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-29 21:38:27 -03:00
James Almer ea4b10249d avcodec/av1dec: parse dimensions from the sequence header in extradata
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-29 21:38:27 -03:00
Andreas Rheinhardt 93b7f9312d avcodec/av1dec: Check tiles sizes, fix assert, don't read bytes bitwise
Tiles have a size field with a length from one to four bytes. As such it
is not possible to read it all at once with a call to get_bits() as this
only allows to read up to 25 bits; this is guarded by an av_assert2. Yet
this is done by the AV1 decoder in get_tiles_info(). It has been done
despite said size fields being byte-aligned. This commit fixes this by
using the bytestream2 API instead.

Furthermore, it is now explicitly checked whether the data is
consistent, i.e. whether the data that is supposed to be there extends
beyond the end of the data actually present.

Reviewed-by: Wang, Fei W <fei.w.wang@intel.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-18 02:34:55 +02:00
Andreas Rheinhardt 3e057dd8b1 avcodec/av1dec: Remove redundant second free
The AV1 decoder has the FF_CODEC_CAP_INIT_CLEANUP flag set and yet
the decoder's close function is called manually on some error paths.
This is unnecessary and has been removed in this commit.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-17 05:47:06 +02:00
Andreas Rheinhardt 92b578e1d6 avcodec/av1dec: Fix segfault upon allocation error
Up until now, the AV1 decoder always checks before calling its wrapper
around ff_thread_release_buffer() whether the ThreadFrame was used at
all, i.e. it checked whether the first data buffer of the AVFrame
contained therein is NULL or not. Yet this presumes that the AVFrame has
been successfully allocated, even though this can of course fail; and if
it did, one would encounter a segfault.
Fix this by removing the checks altogether: ff_thread_release_buffer()
can handle both unallocated as well as empty frames (since commit
f6774f905f).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-17 05:46:24 +02:00
James Almer e46f34e85b avcodec/av1dec: fix setting pix_fmt
Fill the array with the software pix_fmt and move the avctx->hwaccel
check back to the proper place.
Also remove the avoid probing flag to ensure an external av1 decoder
will not set a pix_fmt we don't want during format probing.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-12 17:39:45 -03:00
James Almer 9c6026bc72 avcodec/av1dec: update reference frame state on show_existing_frame
As defined in Section 7.4

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-12 13:10:16 -03:00
James Almer b80c66bb6b avcodec/av1dec: set chroma_sample_location
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-12 13:10:16 -03:00
James Almer b7a06885f1 avcodec/av1dec: use av_cmp_q() to compare aspect ratio
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-12 13:10:16 -03:00
Fei Wang 47be5a5056 avcodec: add AV1 hardware accelerated decoder
This AV1 decoder is currently only used for hardware accelerated decoding.
It can be extended into a native decoder in the future, so set its name to
"av1" and temporarily give it the lowest priority in the codec list.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-12 13:08:34 -03:00