aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-04-14 16:43:53 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-20 01:55:29 +0200
commit118b36f418fb050aebecd0c868b04bdc45293012 (patch)
treee085d2c9f8972a7c5179d3f07c7ea762b29fe100 /libavcodec
parent888a02a126522ad1da802eb1f4e4571afc09a14d (diff)
downloadffmpeg-118b36f418fb050aebecd0c868b04bdc45293012.tar.gz
avcodec/mjpegdec: Avoid copying data when flipping image
Basically reverts af15c17daa5d8d2940c0263ba4d3ecec761c11ee. Flipping a picture by modifying the pointers is so common that even users of direct rendering should take it into account. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mjpegdec.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 65337360b0..ca7e752f16 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2770,28 +2770,18 @@ the_end:
}
}
if (s->flipped && !s->rgb) {
- int j;
ret = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
if (ret)
return ret;
- av_assert0(s->nb_components == av_pix_fmt_count_planes(s->picture_ptr->format));
+ av_assert0(s->nb_components == av_pix_fmt_count_planes(frame->format));
for (index=0; index<s->nb_components; index++) {
- uint8_t *dst = s->picture_ptr->data[index];
- int w = s->picture_ptr->width;
- int h = s->picture_ptr->height;
- if(index && index<3){
- w = AV_CEIL_RSHIFT(w, hshift);
+ int h = frame->height;
+ if (index && index < 3)
h = AV_CEIL_RSHIFT(h, vshift);
- }
- if(dst){
- uint8_t *dst2 = dst + s->picture_ptr->linesize[index]*(h-1);
- for (i=0; i<h/2; i++) {
- for (j=0; j<w; j++)
- FFSWAP(int, dst[j], dst2[j]);
- dst += s->picture_ptr->linesize[index];
- dst2 -= s->picture_ptr->linesize[index];
- }
+ if (frame->data[index]) {
+ frame->data[index] += (h - 1) * frame->linesize[index];
+ frame->linesize[index] *= -1;
}
}
}