mirror of https://git.ffmpeg.org/ffmpeg.git
avfilter/vf_zscale: align the frame buffers
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
00cf3df03f
commit
c8e5c684b3
|
@ -660,7 +660,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
|
static int realign_frame(AVFilterLink *link, const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
|
||||||
{
|
{
|
||||||
AVFrame *aligned = NULL;
|
AVFrame *aligned = NULL;
|
||||||
int ret = 0, plane, planes;
|
int ret = 0, plane, planes;
|
||||||
|
@ -670,17 +670,9 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int ne
|
||||||
for (plane = 0; plane < planes; plane++) {
|
for (plane = 0; plane < planes; plane++) {
|
||||||
int p = desc->comp[plane].plane;
|
int p = desc->comp[plane].plane;
|
||||||
if ((uintptr_t)(*frame)->data[p] % ZIMG_ALIGNMENT || (*frame)->linesize[p] % ZIMG_ALIGNMENT) {
|
if ((uintptr_t)(*frame)->data[p] % ZIMG_ALIGNMENT || (*frame)->linesize[p] % ZIMG_ALIGNMENT) {
|
||||||
if (!(aligned = av_frame_alloc())) {
|
aligned = ff_default_get_video_buffer2(link, (*frame)->width, (*frame)->height, ZIMG_ALIGNMENT);
|
||||||
ret = AVERROR(ENOMEM);
|
if (!aligned)
|
||||||
goto fail;
|
return AVERROR(ENOMEM);
|
||||||
}
|
|
||||||
|
|
||||||
aligned->format = (*frame)->format;
|
|
||||||
aligned->width = (*frame)->width;
|
|
||||||
aligned->height = (*frame)->height;
|
|
||||||
|
|
||||||
if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
|
if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -809,20 +801,17 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
|
||||||
(s->src_format.pixel_type !=s->dst_format.pixel_type) ||
|
(s->src_format.pixel_type !=s->dst_format.pixel_type) ||
|
||||||
(s->src_format.transfer_characteristics !=s->dst_format.transfer_characteristics)
|
(s->src_format.transfer_characteristics !=s->dst_format.transfer_characteristics)
|
||||||
){
|
){
|
||||||
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
|
out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, ZIMG_ALIGNMENT);
|
||||||
if (!out) {
|
if (!out) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = realign_frame(odesc, &out, 0)) < 0)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
av_frame_copy_props(out, in);
|
av_frame_copy_props(out, in);
|
||||||
out->colorspace = outlink->colorspace;
|
out->colorspace = outlink->colorspace;
|
||||||
out->color_range = outlink->color_range;
|
out->color_range = outlink->color_range;
|
||||||
|
|
||||||
if ((ret = realign_frame(desc, &in, 1)) < 0)
|
if ((ret = realign_frame(link, desc, &in, 1)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
|
snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
|
||||||
|
|
Loading…
Reference in New Issue