mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
avcodec/utils: Optimize ff_color_frame() using memcpy()
4650975 -> 4493240 dezicycles This optimizes lines 2 and later. Line 1 still uses av_memcpy_backptr() This change originally fixed ossfuzz 10790 but this is now fixed by other optimizations already Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
3dce4d03d5
commit
95e5396919
1 changed files with 12 additions and 6 deletions
|
|
@ -421,13 +421,19 @@ void ff_color_frame(AVFrame *frame, const int c[4])
|
||||||
int is_chroma = p == 1 || p == 2;
|
int is_chroma = p == 1 || p == 2;
|
||||||
int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width;
|
int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width;
|
||||||
int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
|
int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
|
||||||
for (y = 0; y < height; y++) {
|
if (desc->comp[0].depth >= 9) {
|
||||||
if (desc->comp[0].depth >= 9) {
|
((uint16_t*)dst)[0] = c[p];
|
||||||
((uint16_t*)dst)[0] = c[p];
|
av_memcpy_backptr(dst + 2, 2, bytes - 2);
|
||||||
av_memcpy_backptr(dst + 2, 2, bytes - 2);
|
|
||||||
}else
|
|
||||||
memset(dst, c[p], bytes);
|
|
||||||
dst += frame->linesize[p];
|
dst += frame->linesize[p];
|
||||||
|
for (y = 1; y < height; y++) {
|
||||||
|
memcpy(dst, frame->data[p], 2*bytes);
|
||||||
|
dst += frame->linesize[p];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (y = 0; y < height; y++) {
|
||||||
|
memset(dst, c[p], bytes);
|
||||||
|
dst += frame->linesize[p];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue