summaryrefslogtreecommitdiff
path: root/libavcodec/av1dec.c
Commit message (Collapse)AuthorAge
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Make FFCodec.decode use AVFrame*Andreas Rheinhardt2022-04-05
| | | | | | | | This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVFrame *frame = data;" line for non-subtitle decoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "avcodec/av1dec: Check tile_cols"James Almer2022-03-23
| | | | | | | | This reverts commit 4fdfe430c12225e819f68993474bd2f473c7e8b1. The previous commit ensures this field will never be zero. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1: only set the private context pix_fmt field if ↵James Almer2022-03-23
| | | | | | | | | | | | | | | | | get_pixel_format() succeeds Otherwise get_pixel_format() will not be called when parsing a subsequent Sequence Header in non hwaccel enabled scenarios, allowing frame parsing when it shouldn't. This prevents the scenario seqhdr -> frame_hdr/redundant_frame_hdr -> seqhdr -> redundant_frame_hdr from having the latter redundant frame header parsed as if it was a frame header by the decoder because the former was discarded. Since CBS did not discard it, the latter redundant frame header is output with a zeroed AV1RawFrameHeader struct, which can have undesired results, like division by zero with fields normally guaranteed to be anything else. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: Check tile_colsMichael Niedermayer2022-03-21
| | | | | | | | | Fixes: division by zero Fixes: 43769/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5392562205097984 Fixes: 43950/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5769210217758720 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-21
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/thread: Don't use ThreadFrame when unnecessaryAndreas Rheinhardt2022-02-09
| | | | | | | | | | | | | | | | | | | | | | | The majority of frame-threaded decoders (mainly the intra-only) need exactly one part of ThreadFrame: The AVFrame. They don't need the owners nor the progress, yet they had to use it because ff_thread_(get|release)_buffer() requires it. This commit changes this and makes these functions work with ordinary AVFrames; the decoders that need the extra fields for progress use ff_thread_(get|release)_ext_buffer() which work exactly as ff_thread_(get|release)_buffer() used to do. This also avoids some unnecessary allocations of progress AVBuffers, namely for H.264 and HEVC film grain frames: These frames are not used for synchronization and therefore don't need a ThreadFrame. Also move the ThreadFrame structure as well as ff_thread_ref_frame() to threadframe.h, the header for frame-threaded decoders with inter-frame dependencies. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/av1dec: honor the requested skip_frame levelJames Almer2022-01-11
| | | | | | | This supports dropping non-intra, non-key, or all frames. Tested-by: nevcairiel Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/av1dec: use frame split bsfFei Wang2022-01-07
| | | | | | | | | 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>
* avcodec/av1dec: support setup shear processFei Wang2021-10-16
| | | | | | Defined in spec 7.11.3.6/7.11.3.7. Signed-off-by: Fei Wang <fei.w.wang@intel.com>
* avcodec/av1: signal the presence of Film Grain in the decoder contextJames Almer2021-08-24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | 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>
* avcodec/av1dec: add an option to select an operating pointJames Almer2021-01-04
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* Mark some pointers as constAndreas Rheinhardt2021-01-01
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/av1dec: support exporting Film Grain params as frame side dataJames Almer2020-12-16
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/nvdec: Add support for decoding monochrome av1Philip Langdale2020-12-06
| | | | | | | | | | | | | | 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.
* avcodec/av1dec: Fix leak in case of failureAndreas Rheinhardt2020-12-05
| | | | | | | | | | | | | 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>
* avcodec/av1dec: infer and store film grain param values in AV1FrameJames Almer2020-11-30
| | | | | | | | | 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>
* avcodec/av1{dec,parser}: move to ff_cbs_read_extradata_from_codecJan Ekström2020-11-24
| | | | | | 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.
* avcodec/av1dec: remove order_hint from AV1FrameJames Almer2020-11-13
| | | | | | We now have access to the raw frame header, so use that Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: add a reference to the raw frame header to AV1FramesJames Almer2020-11-13
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/dxva2: add AV1 decode supportHendrik Leppkes2020-11-12
| | | | Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
* avcodec/nvdec: add av1 hwaccelTimo Rothenpieler2020-11-11
| | | | | Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org> Co-authored-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: expose coded_losslessTimo Rothenpieler2020-11-11
| | | | | Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org> Co-authored-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: expose skip mode frame indexTimo Rothenpieler2020-11-11
| | | | | Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org> Co-authored-by: James Almer <jamrial@gmail.com>
* avcodec: add av1 VAAPI decoderFei Wang2020-11-02
| | | | | | | | | 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>
* avcodec/av1dec: fix loading PrevGmParams for frames with primary_ref_frame noneJames Almer2020-10-28
| | | | | Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: don't derive loop filter delta parametersJames Almer2020-10-28
| | | | | | This is now handled by CBS. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: Check for unset obu instead of crashingMichael Niedermayer2020-10-26
| | | | | | | | | 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>
* avcodec/av1dec: add cur_frame.spatial_id and temporal_id to AV1FrameJames Almer2020-10-16
| | | | | | | 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>
* avcodec/av1dec: avoid probing with av1decJames Almer2020-10-06
| | | | | | | | 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>
* avcodec/av1dec: partially clean state on frame decoding errorsJames Almer2020-10-04
| | | | | | | | 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>
* avcodec/av1dec: call ff_cbs_flush() on decoder flushJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: fix check for active sequence headerJames Almer2020-09-29
| | | | | | We clear the AV1RawSequenceHeader pointer on flush, not the relevant AVBufferRef. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: parse dimensions from the sequence header in extradataJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: Check tiles sizes, fix assert, don't read bytes bitwiseAndreas Rheinhardt2020-09-18
| | | | | | | | | | | | | | | | | 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>
* avcodec/av1dec: Remove redundant second freeAndreas Rheinhardt2020-09-17
| | | | | | | | | 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>
* avcodec/av1dec: Fix segfault upon allocation errorAndreas Rheinhardt2020-09-17
| | | | | | | | | | | | | | | 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 f6774f905fb3cfdc319523ac640be30b14c1bc55). Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/av1dec: fix setting pix_fmtJames Almer2020-09-12
| | | | | | | | | 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>
* avcodec/av1dec: update reference frame state on show_existing_frameJames Almer2020-09-12
| | | | | | As defined in Section 7.4 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: set chroma_sample_locationJames Almer2020-09-12
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1dec: use av_cmp_q() to compare aspect ratioJames Almer2020-09-12
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: add AV1 hardware accelerated decoderFei Wang2020-09-12
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>