diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-07 00:09:10 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-12 09:42:27 +0200 |
commit | 423b6a7e493828dd91d5e590e0905236f1f46557 (patch) | |
tree | 2bdbe0020ba7ecab45e3f0909a7f3d862520a6c7 /libavfilter | |
parent | 5094d1f429e58a67c542f1c5940a3de5184c35ca (diff) | |
download | ffmpeg-423b6a7e493828dd91d5e590e0905236f1f46557.tar.gz |
avutil/imgutils: Add wrapper for av_image_copy() to avoid casts
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>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/lavfutils.c | 3 | ||||
-rw-r--r-- | libavfilter/vf_framepack.c | 28 | ||||
-rw-r--r-- | libavfilter/vf_pullup.c | 12 | ||||
-rw-r--r-- | libavfilter/yadif_common.c | 6 |
4 files changed, 21 insertions, 28 deletions
diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c index 9aa781ef7b..6130f21e7f 100644 --- a/libavfilter/lavfutils.c +++ b/libavfilter/lavfutils.c @@ -117,7 +117,8 @@ int ff_load_image(uint8_t *data[4], int linesize[4], goto end; ret = 0; - av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, *pix_fmt, *w, *h); + av_image_copy2(data, linesize, frame->data, frame->linesize, + *pix_fmt, *w, *h); end: avcodec_free_context(&codec_ctx); diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c index 8693ad6488..cbfcf1e036 100644 --- a/libavfilter/vf_framepack.c +++ b/libavfilter/vf_framepack.c @@ -234,22 +234,18 @@ static void horizontal_frame_pack(AVFilterLink *outlink, } else { for (i = 0; i < 2; i++) { const int psize = 1 + (s->depth > 8); - const uint8_t *src[4]; uint8_t *dst[4]; int sub_w = psize * s->input_views[i]->width >> s->pix_desc->log2_chroma_w; - src[0] = s->input_views[i]->data[0]; - src[1] = s->input_views[i]->data[1]; - src[2] = s->input_views[i]->data[2]; - dst[0] = out->data[0] + i * s->input_views[i]->width * psize; dst[1] = out->data[1] + i * sub_w; dst[2] = out->data[2] + i * sub_w; - av_image_copy(dst, out->linesize, src, s->input_views[i]->linesize, - s->input_views[i]->format, - s->input_views[i]->width, - s->input_views[i]->height); + av_image_copy2(dst, out->linesize, + s->input_views[i]->data, s->input_views[i]->linesize, + s->input_views[i]->format, + s->input_views[i]->width, + s->input_views[i]->height); } } } @@ -263,15 +259,10 @@ static void vertical_frame_pack(AVFilterLink *outlink, int i; for (i = 0; i < 2; i++) { - const uint8_t *src[4]; uint8_t *dst[4]; int linesizes[4]; int sub_h = s->input_views[i]->height >> s->pix_desc->log2_chroma_h; - src[0] = s->input_views[i]->data[0]; - src[1] = s->input_views[i]->data[1]; - src[2] = s->input_views[i]->data[2]; - dst[0] = out->data[0] + i * out->linesize[0] * (interleaved + s->input_views[i]->height * (1 - interleaved)); dst[1] = out->data[1] + i * out->linesize[1] * @@ -286,10 +277,11 @@ static void vertical_frame_pack(AVFilterLink *outlink, linesizes[2] = out->linesize[2] + interleaved * out->linesize[2]; - av_image_copy(dst, linesizes, src, s->input_views[i]->linesize, - s->input_views[i]->format, - s->input_views[i]->width, - s->input_views[i]->height); + av_image_copy2(dst, linesizes, + s->input_views[i]->data, s->input_views[i]->linesize, + s->input_views[i]->format, + s->input_views[i]->width, + s->input_views[i]->height); } } diff --git a/libavfilter/vf_pullup.c b/libavfilter/vf_pullup.c index 7245684085..14beb972c5 100644 --- a/libavfilter/vf_pullup.c +++ b/libavfilter/vf_pullup.c @@ -666,9 +666,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) goto end; } - av_image_copy(b->planes, s->planewidth, - (const uint8_t**)in->data, in->linesize, - inlink->format, inlink->w, inlink->h); + av_image_copy2(b->planes, s->planewidth, + in->data, in->linesize, + inlink->format, inlink->w, inlink->h); p = (in->flags & AV_FRAME_FLAG_INTERLACED) ? !(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 0; @@ -714,9 +714,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); - av_image_copy(out->data, out->linesize, - (const uint8_t**)f->buffer->planes, s->planewidth, - inlink->format, inlink->w, inlink->h); + av_image_copy2(out->data, out->linesize, + f->buffer->planes, s->planewidth, + inlink->format, inlink->w, inlink->h); ret = ff_filter_frame(outlink, out); pullup_release_frame(f); diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c index 561659e346..b26989f574 100644 --- a/libavfilter/yadif_common.c +++ b/libavfilter/yadif_common.c @@ -89,9 +89,9 @@ static void fixstride(AVFilterLink *link, AVFrame *f) if(!dst) return; av_frame_copy_props(dst, f); - av_image_copy(dst->data, dst->linesize, - (const uint8_t **)f->data, f->linesize, - dst->format, dst->width, dst->height); + av_image_copy2(dst->data, dst->linesize, + f->data, f->linesize, + dst->format, dst->width, dst->height); av_frame_unref(f); av_frame_move_ref(f, dst); av_frame_free(&dst); |