aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-02-17 21:51:19 +0100
committerAnton Khirnov <anton@khirnov.net>2024-03-08 07:37:56 +0100
commited3cc8fc6594224aeec34ba6fc5536d116a505dc (patch)
treea2cca8a53168f074dfea3fb23422943e9b0648e5
parent62f40d0e3856954a6b2bc20dc70bea52e57c31ad (diff)
downloadffmpeg-ed3cc8fc6594224aeec34ba6fc5536d116a505dc.tar.gz
avcodec/mjpegdec: respect side data preference
-rw-r--r--libavcodec/mjpegdec.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 81f724d230..43b36d0a8f 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2840,16 +2840,18 @@ the_end:
for (i = 0; i < s->iccnum; i++)
total_size += s->iccentries[i].length;
- sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, total_size);
- if (!sd) {
+ ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_ICC_PROFILE, total_size, &sd);
+ if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate frame side data\n");
- return AVERROR(ENOMEM);
+ return ret;
}
- /* Reassemble the parts, which are now in-order. */
- for (i = 0; i < s->iccnum; i++) {
- memcpy(sd->data + offset, s->iccentries[i].data, s->iccentries[i].length);
- offset += s->iccentries[i].length;
+ if (sd) {
+ /* Reassemble the parts, which are now in-order. */
+ for (i = 0; i < s->iccnum; i++) {
+ memcpy(sd->data + offset, s->iccentries[i].data, s->iccentries[i].length);
+ offset += s->iccentries[i].length;
+ }
}
}