mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
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>
This commit is contained in:
parent
888a02a126
commit
118b36f418
@ -2770,28 +2770,18 @@ the_end:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s->flipped && !s->rgb) {
|
if (s->flipped && !s->rgb) {
|
||||||
int j;
|
|
||||||
ret = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
|
ret = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
|
||||||
if (ret)
|
if (ret)
|
||||||
return 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++) {
|
for (index=0; index<s->nb_components; index++) {
|
||||||
uint8_t *dst = s->picture_ptr->data[index];
|
int h = frame->height;
|
||||||
int w = s->picture_ptr->width;
|
if (index && index < 3)
|
||||||
int h = s->picture_ptr->height;
|
|
||||||
if(index && index<3){
|
|
||||||
w = AV_CEIL_RSHIFT(w, hshift);
|
|
||||||
h = AV_CEIL_RSHIFT(h, vshift);
|
h = AV_CEIL_RSHIFT(h, vshift);
|
||||||
}
|
if (frame->data[index]) {
|
||||||
if(dst){
|
frame->data[index] += (h - 1) * frame->linesize[index];
|
||||||
uint8_t *dst2 = dst + s->picture_ptr->linesize[index]*(h-1);
|
frame->linesize[index] *= -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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user