1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

105 Commits

Author SHA1 Message Date
Martin Storsjö
a27f3c590f av1dec: Don't crash if decoding of some frames have failed
If decoding with hwaccel, but decoding fails, these pointers
are null at this point.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-04 22:57:03 +03:00
Jan Ekström
f9c5c5358c avcodec/videotoolbox: add AV1 hardware acceleration
Use AV1DecContext's current_obu to access the original OBUs, and
feed them to videotoolbox, rather than the bare slice data passed
via decode_slice.

This requires a small addition to AV1DecContext, for keeping track
of the current range of OBUs that belong to the current frame.

Co-authored-by: Ruslan Chernenko <ractyfree@gmail.com>
Co-authored-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Martin Storsjö <martin@martin.st>
2024-10-02 11:19:27 +03:00
James Almer
afb06aef7e avcodec/decode: remove unused argument from ff_frame_new_side_data_from_buf()
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-29 14:00:48 -03:00
Mark Thompson
6f56e0e7e5 av1dec: Add force_integer_mv derived field for decoder use
This is not the same as the syntax element value in the frame header
because the specification parsing tables override the value on intra
frames.
2024-05-06 20:17:50 +01:00
Michael Niedermayer
69b4d9736b
avcodec/av1dec: Change bit_depth to int
Suggested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-03 02:35:50 +02:00
Michael Niedermayer
fd7d24fa3f
avcodec/av1dec: bit_depth cannot be another values than 8,10,12
Fixes: CID1544265 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-03 02:35:50 +02:00
Andreas Rheinhardt
9fb3d640fb avcodec/av1dec: Always set ret before goto end
Before 0f8763fbea, av1_frame_ref()
and update_reference_list() could fail and therefore needed to
be checked, which incidentally set ret. This is no longer happening,
leading to a potential use of an uninitialized value which is
also the subject of Coverity ticket #1596605.

Fix this by always setting ret before goto end; do not return
some random ancient value.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-02 23:37:16 +02:00
Mark Thompson
ba6b08c75b av1dec: Fix RefFrameSignBias calculation 2024-04-22 21:41:50 +01:00
Niklas Haas
d0392619a7 avcodec/dovi_rpu: store entire config record
And make it public.

For encoding, users may also be interested in the configured level and
compatibility ID. So generalize the dv_profile field and just expose the
whole configuration record.

This makes the already rather reductive ff_dovi_update_cfg() function
almost wholly redundant, since users can just directly assign
DOVIContext.cfg.
2024-04-22 12:17:05 +02:00
Andreas Rheinhardt
20206e14d7 avcodec/av1dec: Make av1_frame_replace() out of av1_frame_ref()
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 16:31:42 +02:00
Andreas Rheinhardt
0f8763fbea avcodec/av1dec: Use ProgressFrames
AV1 can put a frame into multiple reference slots;
up until now, this involved creating a new reference
to the underlying AVFrame; therefore av1_frame_ref()
could fail.
This commit changes this by using the ProgressFrame API
to share the underlying AVFrames.

(Hint: vaapi_av1_surface_id() checked whether the AV1Frames
contained in the AV1DecContext were NULL or not (of course
they were not); this has been changed to actually check for
whether said AV1Frame is blank or not.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-21 16:31:42 +02:00
Mark Thompson
22ced1edc6 lavc/av1: Record reference ordering information for each frame
This is needed by Vulkan.  Constructing this can't be delegated to CBS
because packets might contain multiple frames (when non-shown frames are
present) but we need separate snapshots immediately before each frame
for the decoder.
2024-04-14 21:05:05 +01:00
Niklas Haas
b90c18b38c avcodec/dovi_rpu: verify RPU data CRC32
The Dolby Vision RPU contains a CRC32 to validate the payload against.
The implementation is CRC32/MPEG-2.

The CRC is only verified with the AV_EF_CRCCHECK flag.

Co-authored-by: quietvoid <tcChlisop0@gmail.com>
2024-04-03 16:16:53 +02:00
Andreas Rheinhardt
790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Niklas Haas
511f297680 avcodec/av1dec: signal new AVFilmGrainParams members
Not directly signalled by AV1, but we should still set this accordingly
so that users will know what the original intended video characteristics
and chroma resolution were.
2024-03-23 18:54:36 +01:00
James Almer
4ca5d45193 avcodec/av1dec: use named constants for ITU-T T.35 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-19 09:44:59 -03:00
Niklas Haas
da39a19aad avcodec/av1dec: parse DV profile 10 T.35 OBU
See previous commit.
2024-03-11 11:40:09 +01:00
Anton Khirnov
6169bd0fea lavc/*dec: use side data preference for mastering display/content light metadata 2024-03-08 07:38:38 +01:00
Niklas Haas
01056078ed avcodec/av1dec: respect side data preference 2024-03-08 07:37:56 +01:00
James Almer
194414f62d avcodec/av1dec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
Fixes errors when opening streams with no extradata (like those from raw OBU
sources). It also calls get_format() on new Sequence Headers when required.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-29 14:48:00 -03:00
Fei Wang
57fbe929f3 avcodec/av1dec: Return error for unsupported tile list OBU
Otherwise decoding maybe successful but output result is incorrect.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-02-29 13:36:41 +08:00
Fei Wang
3f7e50f539 avcodec/av1dec: Move message of OBU info back to the beginning
So that can show OBU info even it doesn't have decomposed content. And
add OBU content status into the message.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-02-29 13:36:41 +08:00
Jan Ekström
37936b09ce avcodec/av1dec: fix matrix coefficients exposed by codec context
`colorspace` in avcodec terms means `matrix coefficients`.

Reviewed-by: James Almer <jamrial@gmail.com>
2024-02-20 20:54:17 +02:00
Anton Khirnov
08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Andreas Rheinhardt
0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Wu Jianhua
b16fd96c5f avcodec: add D3D12VA hardware accelerated AV1 decoding
The command below is how to enable d3d12va:
ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2023-12-21 16:15:23 +08:00
Michael Niedermayer
22daf2148f
avcodec/av1dec: Fix resolving zero divisor
Fixes: Out of array read
Fixes: global-buffer-overflow-AV1

Found-by: "Leonelli, Matteo" <matteo.leonelli@cispa.de>
Tested-by: "Wang, Fei W" <fei.w.wang@intel.com>
Reviewed-by: "Wang, Fei W" <fei.w.wang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-05 12:38:16 +01:00
Andreas Rheinhardt
6e4030a07b avcodec/av1dec, vaapi_av1: Remove excessive logmessages
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-22 22:11:37 +02:00
Andreas Rheinhardt
315c956cbd avcodec/pthread_frame: Remove ff_thread_release_buffer()
It is unnecessary since the removal of non-thread-safe callbacks
in e0786a8eeb. Since then, the
AVCodecContext has only been used as logcontext.

Removing ff_thread_release_buffer() allowed to remove AVCodecContext*
parameters from several other functions (not only unref functions,
but also e.g. ff_h264_ref_picture() which calls ff_h264_unref_picture()
on error).

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-22 22:09:59 +02:00
Andreas Rheinhardt
f8252d6ce3 avcodec/decode: Use RefStruct API for hwaccel_picture_private
Avoids allocations and therefore error checks: Syncing
hwaccel_picture_private across threads can't fail any more.
Also gets rid of an unnecessary pointer in structures and
in the parameter list of ff_hwaccel_frame_priv_alloc().

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Reviewed-by: Lynne <dev@lynne.ee>
Tested-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-07 22:35:22 +02:00
Andreas Rheinhardt
3e9b8d14e5 avcodec/cbs: Use RefStruct-API for unit content
This avoids allocations and error checks etc. as well
as duplicate pointer lists in the CodedBitstreamFooContexts.
It also avoids casting const away for use as opaque,
as the RefStruct API supports const opaques.

The fact that some of the units are not refcounted
(i.e. they are sometimes part of an encoding context
like VAAPIEncodeH264Context) meant that CodedBitstreamUnit
still contains two pointers, one to the content
and another ownership pointer, replacing the AVBufferRef* pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-07 22:35:05 +02:00
Andreas Rheinhardt
6434e44003 avcodec/thread: Remove ff_thread_get_format define
Unnecessary since FF_API_THREAD_SAFE_CALLBACKS is no more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-13 22:04:22 +02:00
Andreas Rheinhardt
0058f6013f avcodec/av1dec: Don't rely on AV_PIX_FMT_NONE == -1
Since fb548fba04,
this return -1 is in a function returning enum AVPixelFormat
whose caller checks for AV_PIX_FMT_NONE for failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-13 22:04:22 +02:00
Andreas Rheinhardt
c38693b4b0 avcodec/av1dec: Pass AVCodecContext* as logctx in get_sw_pixel_format()
It indicates to the reader that said function does not modify
any state.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-13 22:04:11 +02:00
James Almer
fb548fba04 avcodec/av1dec: export pixel format even if no hardware decoder is present
And remove the AVOID_PROBING flag, given it's the last av1 decoder to be tested
either way.
This fixes a regression introduced in 1652f2492f,
where even if forcing the native av1 decoder, if another decoder was present,
like libdav1d or libaom-av1, they'd be used for probing and some fate tests
would have different results.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-09-08 09:42:25 -03:00
James Almer
1652f2492f avcodec/av1dec: don't set aspect ratio when it's not yet known
Makes the output of the native decoder consistent with external decoders like
libdav1d with fate-enhanced-flv-av1.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-09-06 14:37:15 -03:00
Andreas Rheinhardt
e35dfe864d avcodec/avcodec: Add FFHWAccel, hide internals of AVHWAccel
This commit is the AVHWAccel analogue of commit
20f9727018: It moves the private fields
of AVHWAccel to a new struct FFHWAccel extending AVHWAccel
in an internal header (namely hwaccel_internal.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:50:29 +02:00
Andreas Rheinhardt
c48cc9c6e9 avcodec/decode: Extend ff_hwaccel_frame_priv_alloc()'s task
All usages of ff_hwaccel_frame_priv_alloc() have the same pattern:
Check for whether a hwaccel is in use; check whether it needs
private frame-specific data; allocate the AVBuffer and set
it.

This commit modifies ff_hwaccel_frame_priv_alloc() to perform
this task on its own.

(It also seems that the H.264 decoder did not perform proper
cleanup in case the buffer could not be allocated. This has been
changed.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:50:29 +02:00
James Almer
62cb9d97c1 avcodec/av1dec: remove FF_CODEC_CAP_SETS_PKT_DTS flag
It has no effect on receive_frame() decoders.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-11 14:26:43 -03:00
James Almer
4da14c302f avcodec/av1dec: reset the fragment on extradata reading failure
Signed-off-by: James Almer <jamrial@gmail.com>
2023-06-02 14:07:20 -03:00
James Almer
8c6b931f4c avcodec/av1dec: reset the fragment on reading failure
Fixes: NULL pointer dereference
Fixes: 59359/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-6726080594313216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2023-06-02 14:01:10 -03:00
Lynne
77478f6793
av1dec: add Vulkan hwaccel 2023-05-29 00:42:00 +02:00
Dave Airlie
e49b8b48cd
av1: set skip mode frames properly
There are circumstances where the flag isn't set but the skip mode
frames are. So don't use the inferred bit which has other inputs
when deciding to pass the skip mode frames to the device.

This fixes some decoding bugs on intel av1
2023-05-29 00:41:58 +02:00
Lynne
6733a1a456
avcodec: add AVHWAccel.flush callback 2023-05-29 00:41:57 +02:00
Lynne
be07145109
avcodec: add AVHWAccel.free_frame_priv callback 2023-05-29 00:41:56 +02:00
James Almer
97f4263457 avcodec/av1dec: convert to receive_frame()
This removes the overhead of inserting the av1_frame_split bsf as part of the
decoding process.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-25 11:21:35 -03:00
Anton Khirnov
e10a5b91bc lavc/av1*: fix exporting framerate
* take num_ticks_per_picture_minus_1 into account, since that is a part
  of the framerate computation
* stop exporting num_ticks_per_picture_minus_1 into
  AVCodecContext.ticks_per_frame, as that field is used for other
  purposes (in conjunction with repeat_pict, which is not used at all by
  av1)
2023-05-15 14:17:49 +02:00
James Almer
dc7bd7c5a5 avcodec: use the new AVFrame key_frame flag in all decoders and encoders
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:48:22 -03:00
Raphaël Zumer
6f2413a203 avcodec/avutil: move dynamic HDR10+ metadata parsing to libavutil
Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-03-21 13:52:36 -03:00
Anton Khirnov
27f8c9b27b lavu/frame: deprecate AVFrame.pkt_{pos,size}
These fields are supposed to store information about the packet the
frame was decoded from, specifically the byte offset it was stored at
and its size.

However,
- the fields are highly ad-hoc - there is no strong reason why
  specifically those (and not any other) packet properties should have a
  dedicated field in AVFrame; unlike e.g. the timestamps, there is no
  fundamental link between coded packet offset/size and decoded frames
- they only make sense for frames produced by decoding demuxed packets,
  and even then it is not always the case that the encoded data was
  stored in the file as a contiguous sequence of bytes (in order for pos
  to be well-defined)
- pkt_pos was added without much explanation, apparently to allow
  passthrough of this information through lavfi in order to handle byte
  seeking in ffplay. That is now implemented using arbitrary user data
  passthrough in AVFrame.opaque_ref.
- several filters use pkt_pos as a variable available to user-supplied
  expressions, but there seems to be no established motivation for using them.
- pkt_size was added for use in ffprobe, but that too is now handled
  without using this field. Additonally, the values of this field
  produced by libavcodec are flawed, as described in the previous
  ffprobe conversion commit.

In summary - these fields are ill-defined and insufficiently motivated,
so deprecate them.
2023-03-20 10:42:09 +01:00