Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avutil/frame: check return value for cropping offsets
@ 2025-01-21 12:34 Leo Izen
  2025-01-28 17:48 ` Leo Izen
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Izen @ 2025-01-21 12:34 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Leo Izen

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>
---
 libavutil/frame.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 10b59545f0..89c200bcc2 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -1095,6 +1095,7 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
 {
     const AVPixFmtDescriptor *desc;
     size_t offsets[4];
+    int ret;
 
     if (!(frame->width > 0 && frame->height > 0))
         return AVERROR(EINVAL);
@@ -1122,7 +1123,9 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
     }
 
     /* calculate the offsets for each plane */
-    calc_cropping_offsets(offsets, frame, desc);
+    ret = calc_cropping_offsets(offsets, frame, desc);
+    if (ret < 0)
+        return ret;
 
     /* adjust the offsets to avoid breaking alignment */
     if (!(flags & AV_FRAME_CROP_UNALIGNED)) {
@@ -1141,7 +1144,9 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
 
         if (min_log2_align < 5 && log2_crop_align != INT_MAX) {
             frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1);
-            calc_cropping_offsets(offsets, frame, desc);
+            ret = calc_cropping_offsets(offsets, frame, desc);
+            if (ret < 0)
+                return ret;
         }
     }
 
-- 
2.48.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/frame: check return value for cropping offsets
  2025-01-21 12:34 [FFmpeg-devel] [PATCH] avutil/frame: check return value for cropping offsets Leo Izen
@ 2025-01-28 17:48 ` Leo Izen
  0 siblings, 0 replies; 2+ messages in thread
From: Leo Izen @ 2025-01-28 17:48 UTC (permalink / raw)
  To: FFmpeg Development

On 1/21/25 7:34 AM, Leo Izen wrote:
> 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>
> ---
>   libavutil/frame.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 10b59545f0..89c200bcc2 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -1095,6 +1095,7 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
>   {
>       const AVPixFmtDescriptor *desc;
>       size_t offsets[4];
> +    int ret;
>   
>       if (!(frame->width > 0 && frame->height > 0))
>           return AVERROR(EINVAL);
> @@ -1122,7 +1123,9 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
>       }
>   
>       /* calculate the offsets for each plane */
> -    calc_cropping_offsets(offsets, frame, desc);
> +    ret = calc_cropping_offsets(offsets, frame, desc);
> +    if (ret < 0)
> +        return ret;
>   
>       /* adjust the offsets to avoid breaking alignment */
>       if (!(flags & AV_FRAME_CROP_UNALIGNED)) {
> @@ -1141,7 +1144,9 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
>   
>           if (min_log2_align < 5 && log2_crop_align != INT_MAX) {
>               frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1);
> -            calc_cropping_offsets(offsets, frame, desc);
> +            ret = calc_cropping_offsets(offsets, frame, desc);
> +            if (ret < 0)
> +                return ret;
>           }
>       }
>   

Will apply.

- Leo Izen (Traneptora)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-28 17:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-21 12:34 [FFmpeg-devel] [PATCH] avutil/frame: check return value for cropping offsets Leo Izen
2025-01-28 17:48 ` Leo Izen

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git