1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-12 19:18:44 +02:00
Commit Graph

202 Commits

Author SHA1 Message Date
Andreas Rheinhardt
f58038d498 avcodec/avcodec: Avoid codec_desc.h, codec_par.h inclusions
Instead, use forward declarations; and in order not to affect
any user include these headers for them, but not internally.
This has the advantage of removing implicit inclusions of these
headers from almost all files providing codecs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-03 01:59:07 +02:00
Niklas Haas
0d596776c6 avcodec/decode: use ff_icc_profile_sanitize
Fixes: https://trac.ffmpeg.org/ticket/9673
2023-10-03 00:28:50 +02:00
James Almer
5ba06ad0b8 avcodec/decode: reduce scope of a variable in ff_decode_frame_props()
Signed-off-by: James Almer <jamrial@gmail.com>
2023-09-30 11:14:32 -03:00
Michael Niedermayer
42b20c93ae
avcodec/decode: EAGAIN is not fully supported in decode_simple_internal()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-19 20:24:46 +02:00
Andreas Rheinhardt
f8503b4c33 avutil/internal: Don't auto-include emms.h
Instead include emms.h wherever it is needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-04 11:04:45 +02: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
c92948de40 avcodec/decode: consistently set channel info when parsing param change side data
avctx->ch_layout was being left unchanged.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-25 14:13:42 -03:00
James Almer
31979127f8 avcodec/decode: factor out filling frame props
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-17 08:43:33 -03:00
Anton Khirnov
f264204de9 lavc: deprecate AV_CODEC_FLAG_DROPCHANGED
This decoding flag makes decoders drop all frames after a parameter
change, but what exactly constitutes a parameter change is not well
defined and will typically depend on the exact use case.
This functionality then does not belong in libavcodec, but rather in
user code
2023-07-15 10:19:33 +02:00
James Almer
74611cdb5c avcodec/decode: use the correct function name
Fixes compilation erros.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-14 13:59:40 -03:00
James Almer
dd7bdb40c4 avcodec/decode: fill missing frame fields for all decoders
And not just those with the old decode() API.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-14 13:58:10 -03:00
James Almer
94ac647559 avcodec/decode: check the output frame for discard samples with all decoders
And not just those with the old decode() API.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-14 13:58:10 -03:00
James Almer
7db4c3eaa6 avcodec/decode: simplify applying or exporting skip samples
Copy packet side data to the output frame in ff_decode_frame_props_from_pkt()
instead of in discard_samples(), having the latter only applying the skip if
required.
This will be useful for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-14 13:58:10 -03:00
James Almer
78c52a8ca4 avcodec/decode: move processing discard samples to its own function
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-14 13:58:10 -03:00
James Almer
e6954fd087 avcodec/decode: don't reject flush packets when buffer_pkt is not empty
Restores the behavior before commit a92dbeb9ae.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-12 10:34:42 -03:00
Andreas Rheinhardt
a92dbeb9ae avcodec/decode: Return EAGAIN instead of discarding unused packet
Should fix #10457, a regression caused by
69516ab3e9.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-10 16:25:46 +02:00
Anton Khirnov
b54603a26a lavc/decode: do not perform decoding when sending draining packets
This way decoding errors will not be returned when the user starts
draining the decoder, avoiding confusion over whether draining did or
did not start.

Fixes failures of fate-h264-attachment-631 for certain numbers of frame
threads (e.g. 5).
2023-07-07 12:07:24 +02:00
Anton Khirnov
69516ab3e9 lavc/decode: move submitting input packets to bitstream filters
Do it from ff_decode_get_packet() rather than from
avcodec_send_packet(). This way all nontrivial stages of the decoding
pipeline (i.e. other than just placing a packet at its entrance) are
pull-based rather than a mix of push an pull.
2023-07-07 12:07:24 +02:00
Anton Khirnov
c4332dfda9 lavc/decode: track whether the caller started draining with a separate flag
Decoding pipeline has multiple stages, some of which may have their own
delay (e.g. bitstream filters). The code currently uses
AVCodecInternal.draining to track all of them, but they do not have to
all be in sync.
2023-07-07 12:07:24 +02:00
Anton Khirnov
f2fb882b3f lavc: add generic-decode-layer private data
Move AVCodecInternal.nb_draining_errors to it, should should not be
visible outside of decode.c.
2023-07-07 12:07:23 +02:00
Anton Khirnov
21de4db402 lavc: reindent after previous commit 2023-07-07 12:07:23 +02:00
Anton Khirnov
6ff27024b8 lavc/avcodec: split flushing into decode- and encode-specific functions
Will allow making some state private to encoding/decoding in the future.
2023-07-07 12:07:23 +02:00
Anton Khirnov
5e7b5b0090 lavc: add a header for internal generic-layer APIs
The goal is to distinguish between APIs provided by the generic layer to
individual codecs and APIs internal to the generic layer.

Start by moving ff_{decode,encode}_receive_frame() and
ff_{decode,encode}_preinit() into this new header, as those functions
are called from generic code and should not be visible to individual
codecs.
2023-07-07 12:07:23 +02:00
Devin Heitmueller
695789eacc avcodec/decode: Preserve AFD side data when going from AVPacket to AVFrame
This is needed to ensure that AFD data continues to work when
capturing V210 video with the Decklink libavdevice input.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-07-02 19:57:45 +02:00
Lynne
be07145109
avcodec: add AVHWAccel.free_frame_priv callback 2023-05-29 00:41:56 +02:00
Lynne
b6a6e2b19d
lavc/decode: allow to allocate hwaccel_priv_data early 2023-05-29 00:41:27 +02:00
Anton Khirnov
3d2e1aa324
lavc/decode: stop duplicating code from hwaccel_uninit() 2023-05-29 00:41:27 +02:00
Anton Khirnov
a4611e3170
lavc/decode: pass AVHWAccel instead of AVCodecHWConfigInternal to hwaccel_init()
The only thing besides the hwaccel that this function uses from
AVCodecHWConfigInternal is the pixel format, which should always match
the hwaccel one.

Will be useful in following commits.
2023-05-29 00:41:25 +02:00
Anton Khirnov
51d6ae099f lavc/decode: drop a useless warning
Decoders will currently warn if an audio decoder not marked with
AV_CODEC_CAP_SUBFRAMES consumes less than the whole packet, but
* this happens for regular files
* this has no negative consequences
* there is no meeaningful action that can or should be taken in response

The warning is thus useless noise.
2023-05-15 10:24:54 +02:00
James Almer
3e06f6f040 avutil/frame: deprecate key_frame
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 19:20:03 -03: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
James Almer
599abc0f3a avutil/frame: deprecate interlaced_frame and top_field_first
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:15:00 -03:00
James Almer
2f561ba953 avcodec: use the new AVFrame interlace flags in all decoders and encoders
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:14:02 -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
Andreas Rheinhardt
590d169bdb avcodec/decode: Reset MMX state for receive_frame decoders, too
FFmpeg's assembly code currently does not abide by the
plattform-specific ABIs wrt its handling of the X86 MMX flag:
Resetting the MMX state is deferred to avoid doing it multiple times
instead of ensuring that the CPU is in floating point state
upon return from any function.

Furthermore, resetting said state is sometimes done generically,
namely for all the decoders using the ordinary decode callback;
yet this is not done for the decoders using the receive_frame API.

This led to problems when MJPEG (and the MJPEG-based decoders)
were switched to the receive_frame API in commit
e9a2a87773, because ff_mjpeg_decode_sos()
only resets the MMX state on success, not on failure.
Such issues are probably still possible with SMVJPEG, which still
uses the receive_frame API. See issue #10210.

This commit therefore also resets the MMX state for
the receive_frame API to avoid any more surprises of this sort.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-03-18 05:10:24 +01:00
Anton Khirnov
a3bf63c26e lavc/decode: stop mangling last_pkt_props->opaque
It is currently abused to store packet size, which breaks
AV_CODEC_FLAG_COPY_OPAQUE.

Use stream_index instead, which is unused in libavcodec and has the
same type as size.

Found-by: Martin Storsjö
2023-03-11 11:37:48 +01:00
Marton Balint
6b6f7db819 avcodec: add AVCodecContext.frame_num as 64 bit variant to frame_number
Frame counters can overflow relatively easily (INT_MAX number of frames is
slightly more than 1 year for 60 fps content), so make sure we use 64 bit
values for them.

Also deprecate the old 32 bit frame_number attribute.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-02-13 00:36:46 +01:00
James Almer
3ceffe7839 avcodec: remove FF_API_FLAG_TRUNCATED
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer
5f9e848e68 avcodec: remove FF_API_AVCTX_TIMEBASE
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:08 +01:00
James Almer
e0786a8eeb avcodec: remove FF_API_THREAD_SAFE_CALLBACKS
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:16 +01:00
Andreas Rheinhardt
868a31b42d avcodec: Make avcodec_decode_subtitle2 accept a const AVPacket*
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
Anton Khirnov
bdc76f467f lavu/frame: deprecate reordered_opaque
It is only used in libavcodec, where it's been superseded by
AV_CODEC_CAP_COPY_OPAQUE.
2023-02-04 13:40:20 +01:00
Anton Khirnov
d02340b9e3 lavc/decode: allow using AV_CODEC_FLAG_COPY_OPAQUE for decoding
Use it to propagate AVPacket.opaque[_ref] to corresponding AVFrame
fields. This is a more convenient alternative to reordered_opaque.
2023-02-04 13:14:20 +01:00
Anton Khirnov
f566032bfd lavc/decode: validate frames output by decoders
Make sure no frames with invalid parameters will be seen by the caller.
2023-01-10 11:47:29 +01:00
Anton Khirnov
a1eec66867 lavc/decode: deduplicate cleanup in ff_decode_receive_frame() 2023-01-10 11:47:29 +01:00
James Almer
56966f2eb2 avcodec/decode: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-12 18:31:28 -03:00
James Almer
bff86f31cc avcodec/decode: add a function to set frame props from a user provided packet
It will be useful for decoders that don't rely on last_pkt_props to set frame
props.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-12 18:31:28 -03:00
James Almer
0afdc398ce avcodec/decode: don't set last_pkt_props->size
Use the opaque field instead to keep this value.
No functional change, but removes the hack that made the packet technically
invalid, allowing the safe usage of functions like av_packet_ref() on it
if required.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-07 08:55:38 -03:00
James Almer
b1fdb0b347 Revert "avcodec/decode: use a packet list to store packet properties"
The idea behind last_pkt_props was to store the properties of the last packet
fed to the decoder. Any sort of queueing required by CODEC_CAP_DELAY decoders
that consume several packets before they start outputting frames should be done
by the decoders in question. An example of this is libdav1d.

This is required for the following commits that will fix last_pkt_props in
frame threading scenarios, as well as maintain its contents during flush.

This revers commit 022a12b306.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-07 08:55:33 -03:00