History

avutil/frame: check return value for cropping offsets

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.

Leo Izen committed 1 year ago

Commit 3380c0d1 parent 4401e4b1 file · +7 −2Browse files

Unified · Split

libavutil/frame.c+7−2
@@ -1095,6 +1095,7 @@ int av_frame_apply_cropping(AVFrame *frame, int flags) · 1094 unmodified lines
1095{1095{
1096 const AVPixFmtDescriptor *desc;1096 const AVPixFmtDescriptor *desc;
1097 size_t offsets[4];1097 size_t offsets[4];
1098 int ret;
1098 1099
1099 if (!(frame->width > 0 && frame->height > 0))1100 if (!(frame->width > 0 && frame->height > 0))
1100 return AVERROR(EINVAL);1101 return AVERROR(EINVAL);
@@ -1122,7 +1123,9 @@ int av_frame_apply_cropping(AVFrame *frame, int flags) · 21 unmodified lines
1122 }1123 }
1123 1124
1124 /* calculate the offsets for each plane */1125 /* calculate the offsets for each plane */
1125 calc_cropping_offsets(offsets, frame, desc);1126 ret = calc_cropping_offsets(offsets, frame, desc);
1127 if (ret < 0)
1128 return ret;
1126 1129
1127 /* adjust the offsets to avoid breaking alignment */1130 /* adjust the offsets to avoid breaking alignment */
1128 if (!(flags & AV_FRAME_CROP_UNALIGNED)) {1131 if (!(flags & AV_FRAME_CROP_UNALIGNED)) {
@@ -1141,7 +1144,9 @@ int av_frame_apply_cropping(AVFrame *frame, int flags) · 12 unmodified lines
1141 1144
1142 if (min_log2_align < 5 && log2_crop_align != INT_MAX) {1145 if (min_log2_align < 5 && log2_crop_align != INT_MAX) {
1143 frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1);1146 frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1);
1144 calc_cropping_offsets(offsets, frame, desc);1147 ret = calc_cropping_offsets(offsets, frame, desc);
1148 if (ret < 0)
1149 return ret;
1145 }1150 }
1146 }1151 }
1147 1152

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t