You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavfi/deshake: Check alignment before calling asm init function.
Do this for every frame to make sure dynamic filters do not cause crashes. Fixes ticket #7078.
This commit is contained in:
@@ -342,10 +342,6 @@ static av_cold int init(AVFilterContext *ctx)
|
|||||||
{
|
{
|
||||||
DeshakeContext *deshake = ctx->priv;
|
DeshakeContext *deshake = ctx->priv;
|
||||||
|
|
||||||
deshake->sad = av_pixelutils_get_sad_fn(4, 4, 1, deshake); // 16x16, 2nd source unaligned
|
|
||||||
if (!deshake->sad)
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
|
|
||||||
deshake->refcount = 20; // XXX: add to options?
|
deshake->refcount = 20; // XXX: add to options?
|
||||||
deshake->blocksize /= 2;
|
deshake->blocksize /= 2;
|
||||||
deshake->blocksize = av_clip(deshake->blocksize, 4, 128);
|
deshake->blocksize = av_clip(deshake->blocksize, 4, 128);
|
||||||
@@ -424,6 +420,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
|
|||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
|
||||||
const int chroma_width = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w);
|
const int chroma_width = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w);
|
||||||
const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h);
|
const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h);
|
||||||
|
int aligned;
|
||||||
|
|
||||||
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
|
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
|
||||||
if (!out) {
|
if (!out) {
|
||||||
@@ -432,6 +429,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
|
|||||||
}
|
}
|
||||||
av_frame_copy_props(out, in);
|
av_frame_copy_props(out, in);
|
||||||
|
|
||||||
|
aligned = !((intptr_t)in->data[0] & 15 | in->linesize[0] & 15);
|
||||||
|
deshake->sad = av_pixelutils_get_sad_fn(4, 4, aligned, deshake); // 16x16, 2nd source unaligned
|
||||||
|
if (!deshake->sad)
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) {
|
if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) {
|
||||||
// Find the most likely global motion for the current frame
|
// Find the most likely global motion for the current frame
|
||||||
find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t);
|
find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t);
|
||||||
|
Reference in New Issue
Block a user