History

mjpegdec: fix overlapping memcpy with upscale_v

Michael Niedermayer committed 13 years ago

Commit bec402b1 parent 65755391 file · +7 −3Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/mjpegdec.c+7−3
@@ -1634,6 +1634,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, · 1633 unmodified lines
16341634 MJpegDecodeContext *s = avctx->priv_data;
16351635 const uint8_t *buf_end, *buf_ptr;
16361636 const uint8_t *unescaped_buf_ptr;
1637+ int hshift, vshift;
16371638 int unescaped_buf_size;
16381639 int start_code;
16391640 int i, index;
@@ -1815,6 +1816,9 @@ the_end: · 175 unmodified lines
18151816 }
18161817 if (s->upscale_v) {
18171818 uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]];
1819+ int w;
1820+ avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
1821+ w = s->width >> hshift;
18181822 av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
18191823 avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
18201824 avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
@@ -1823,16 +1827,16 @@ the_end: · 2 unmodified lines
18231827 uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[i / 2 * s->linesize[s->upscale_v]];
18241828 uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(i + 1) / 2 * s->linesize[s->upscale_v]];
18251829 if (src1 == src2) {
1826− memcpy(dst, src1, s->width);
1830+ memcpy(dst, src1, w);
18271831 } else {
1828− for (index = 0; index < s->width; index++)
1832+ for (index = 0; index < w; index++)
18291833 dst[index] = (src1[index] + src2[index]) >> 1;
18301834 }
18311835 dst -= s->linesize[s->upscale_v];
18321836 }
18331837 }
18341838 if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
1835− int hshift, vshift, j;
1839+ int j;
18361840 avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
18371841 for (index=0; index<4; index++) {
18381842 uint8_t *dst = s->picture_ptr->data[index];

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