aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/frame.c
Commit message (Collapse)AuthorAgeFilesLines
* avutil/frame: Fix av_realloc_array() argument orderAndreas Rheinhardt2025-06-061-2/+2
| | | | | | This is not a real bug, but mostly cosmetic. Fixes ticket #11620. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: Use av_memdup() for duplicating extended data arrayAndreas Rheinhardt2025-06-061-3/+2
| | | | | | | | | Just do it like av_frame_replace(). Also "fixes" the swapped order or arguments to av_malloc_array() (the first is supposed to be the number of elements, the second the size of an element) and therefore part of ticket #11620. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: Always return error upon errorAndreas Rheinhardt2025-06-061-4/+1
| | | | | | | | (I don't know whether this can be triggered for a file with nonnegative channel count, given that src's extended data can't have been allocated in this case.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: Port AVFrame.private_ref to RefStruct APIAndreas Rheinhardt2025-03-281-8/+4
| | | | | | | | | This is possible without deprecation period, because said field is documented as only for our libav* libraries and not the general public. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_PALETTE_HAS_CHANGEDJames Almer2025-03-281-5/+0
| | | | | | Deprecated since 2023-05-18. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_FRAME_KEYJames Almer2025-03-281-5/+0
| | | | | | Deprecated since 2023-05-04. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_INTERLACED_FRAMEJames Almer2025-03-281-6/+0
| | | | | | Deprecated since 2023-05-04. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_FRAME_PKTJames Almer2025-03-281-12/+0
| | | | | | Deprecated since 2023-03-20. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: move side data helpers to a new fileJames Almer2025-03-031-311/+7
| | | | | | | Should reduce clutter in frame.c, plus allow us to make opaque changes to side data handling. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: Fix direct pointer compare between different arrayZhao Zhili2025-02-171-4/+8
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avutil/frame: check return value for cropping offsetsLeo Izen2025-01-281-2/+7
| | | | | | | | This function can return AVERROR_BUG in theory if something went wrong, but so can the caller, so we should propagate that error message upward in that case. Signed-off-by: Leo Izen <leo.izen@gmail.com>
* avutil/frame: add a side data prop to signal channel layout dependent typesJames Almer2025-01-251-2/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add AV_FRAME_SIDE_DATA_FLAG_NEW_REFJames Almer2025-01-101-9/+8
| | | | | | | The flag is documented but did not exist. So introduce it as it can be useful. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add missing size dependent prop to LCEVC payload side dataJames Almer2024-12-231-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add av_frame_side_data_remove_by_props()Niklas Haas2024-12-231-0/+16
| | | | | | | | | | As discussed in the previous commit, we often need a convenient way of stripping all side data related to a certain aspect of the frame. This helper accomplishes just that. I considered also adding a way to match only side data matching *all* properties, but I think this is sufficiently useless in practise to not warrant inclusion in the API.
* avutil/frame: add AV_SIDE_DATA_PROP_{SIZE,COLOR}_DEPENDENTNiklas Haas2024-12-231-13/+13
| | | | | | | | | | | | | | | | | | Many filters modify certain aspects of frame data, e.g. through resizing (vf_*scale* family), color volume mapping (vf_lut*, vf_tonemap*), or possibly others. When this happens, we should strip all frame side data that will no longer be correct/relevant after the operation. For example, changing the image size should invalidate AV_FRAME_DATA_PANSCAN because the crop window (given in pixels) no longer corresponds to the actual image size. For another example, tone-mapping filters (e.g. from HDR to SDR) should strip all of the dynamic HDR related metadata. Since there are a lot of different side data types that are affected by such operations, it makes sense to establish this information in a common, easily accessible way. The existing side data properties enum is a perfect fit for this.
* avutil/frame: add AVSideDataDescriptor for AV_FRAME_DATA_VIDEO_HINTNiklas Haas2024-12-231-0/+1
| | | | This entry was seemingly missing.
* avutil/frame: also align data pointers in av_frame_get_buffer()Pavel Koshevoy2024-11-221-5/+16
| | | | | | | | | | | | | | | This avoids unpleasant surprises to av_frame_get_buffer callers that explicitly specified 64-byte alignment and didn't get AVFrame.data pointers that are 64-byte aligned. For example, see https://github.com/sekrit-twc/zimg/issues/212 Although the zscale issue has already been resolved by other means it would still be prudent to improve the behavior of av_frame_get_buffer to fix any unknown and future instances of similar issues. Co-authored-by: James Almer <jamrial@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: fix setting plane_paddingJames Almer2024-11-221-4/+5
| | | | | | | STRIDE_ALIGN is a lavc define and is not necessarely 32. And align may be <= 0 at the point plane_padding is being set. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: use size_t for total_size in get_video_buffer()James Almer2024-11-221-3/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavu/frame: add side data storing view ID for multi-view videoAnton Khirnov2024-09-231-0/+1
|
* avutil/frame: add an LCEVC enhancement data payload side data typeJames Almer2024-09-191-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: use the maximum compile time supported alignment for stridesJames Almer2024-08-071-1/+3
| | | | | | | | | | | | This puts lavu frame buffer allocator helpers in sync with lavc's decoder frame buffer allocator's STRIDE_ALIGN define. Remove the comment about av_cpu_max_align() while at it as using it is not ideal when CPU flags can be changed mid process. Should fix ticket #11116. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: Check log2_crop_alignMichael Niedermayer2024-07-211-1/+1
| | | | | | | Fixes: CID1604586 Overflowed constant Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/frame: free the old side data buffer before replacing itJames Almer2024-04-111-0/+1
| | | | | | | Fixes memleaks reported by ASAN/Valgrind. Reported-by: Sean McGovern <gseanmcg@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add helper to remove side data of a given type from an arrayJames Almer2024-04-111-0/+6
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add a flag to allow overwritting existing entriesJames Almer2024-04-111-3/+56
| | | | | | Enable it only for side data types that don't allow more than one entry. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add helper for adding side data w/ AVBufferRef to arrayJames Almer2024-04-111-0/+19
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: use the same data information as the source entry when cloning ↵James Almer2024-03-301-10/+20
| | | | | | | | side data src->{data,size} does not need to match src->buf->{data,size}. Signed-off-by: James Almer <jamrial@gmail.com>
* lavu/frame: add side data descriptorsAnton Khirnov2024-03-271-30/+40
| | | | They allow exporting extended information about side data types.
* avutil/frame: Use av_realloc_array(), improve overflow checkAndreas Rheinhardt2024-03-221-2/+3
| | | | | | | | Also use sizeof of the proper type, namely sizeof(**sd) and not sizeof(*sd). Reviewed-by: Jan Ekström <jeebjp@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: Rename av_frame_side_data_get and add wrapper for itAndreas Rheinhardt2024-03-221-4/+4
| | | | | | | | | | | | | | | | | | | av_frame_side_data_get() has a const AVFrameSideData * const *sd parameter; so calling it with an AVFramesSideData **sd like AVCodecContext.decoded_side_data (or with a AVFramesSideData * const *sd) is safe, but the conversion is not performed automatically in C. All users of this function therefore resort to a cast. This commit changes this: av_frame_side_data_get() is renamed to av_frame_side_data_get_c(); furthermore, a static inline wrapper for it name av_frame_side_data_get() is added that accepts an AVFramesSideData * const * and converts this to const AVFramesSideData * const * in a Wcast-qual safe way. This also allows to remove the casts from the current users. Reviewed-by: Jan Ekström <jeebjp@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: Constify av_frame_side_data_get()Andreas Rheinhardt2024-03-221-1/+1
| | | | | Reviewed-by: Jan Ekström <jeebjp@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: add helper for getting side data from arrayJan Ekström2024-03-201-5/+15
|
* avutil/frame: add helper for adding existing side data to arrayJan Ekström2024-03-201-0/+49
|
* avutil/frame: add helper for adding side data to arrayJan Ekström2024-03-201-0/+17
| | | | | Additionally, add an API test to check that the no-duplicates addition works after duplicates have been inserted.
* avutil/frame: split side data removal out to non-AVFrame functionJan Ekström2024-03-201-8/+16
| | | | This will make it possible to reuse logic in further commits.
* avutil/frame: split side_data_from_buf to base and AVFrame funcJan Ekström2024-03-201-8/+17
|
* avutil/frame: add helper for freeing arrays of side dataJan Ekström2024-03-201-0/+5
|
* avutil/frame: split side data list wiping out to non-AVFrame functionJan Ekström2024-03-201-9/+14
| | | | This will make it possible to to reuse logic in further commits.
* avutil: remove deprecated FF_API_FRAME_PICTURE_NUMBERJames Almer2024-03-071-6/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_REORDERED_OPAQUEJames Almer2024-03-071-5/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_PKT_DURATIONJames Almer2024-03-071-10/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-071-121/+6
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/imgutils: Add wrapper for av_image_copy() to avoid castsAndreas Rheinhardt2023-09-121-5/+3
| | | | | | | | | | | | av_image_copy() accepts const uint8_t* const * as source; lots of user have uint8_t* const * and therefore either cast (the majority) or copy the array of pointers. This commit changes this by adding a static inline wrapper for av_image_copy() that casts between the two types so that we do not need to add casts everywhere else. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/frame: remove one layer of indirection in av_frame_replace()James Almer2023-05-181-1/+3
| | | | | | And don't force copy side data. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: add av_frame_replaceJames Almer2023-05-181-0/+125
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: deprecate palette_has_changedJames Almer2023-05-181-0/+4
| | | | | | | | Not only this is information that relies on the concept of a sequence of frames, which is completely out of place as a field in AVFrame, but there are no known or intended uses of this field. Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: deprecate key_frameJames Almer2023-05-041-1/+4
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/frame: deprecate interlaced_frame and top_field_firstJames Almer2023-05-041-0/+4
| | | | Signed-off-by: James Almer <jamrial@gmail.com>