History

avfilter/vf_zscale: realign output buffer if needed

Output buffer alignment might be different to ZIMG_ALIGNMENT or it may not be aligned at all if a downstream filter (e.g. vf_pad) intentionally misaligns it. Or maybe we should unconditionally always allocate output with av_frame_get_buffer() instead of ff_get_video_buffer()?

Marton Balint committed 4 years ago

Commit ea887ef1 parent d5722d51 file · +7 −4Browse files

Unified · Split

libavfilter/vf_zscale.c+7−4
@@ -632,7 +632,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des · 631 unmodified lines
632632 return 0;
633633 }
634634
635−static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame)
635+static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
636636 {
637637 AVFrame *aligned = NULL;
638638 int ret = 0, plane, planes;
@@ -654,10 +654,10 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame) · 15 unmodified lines
654654 if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0)
655655 goto fail;
656656
657− if ((ret = av_frame_copy(aligned, *frame)) < 0)
657+ if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
658658 goto fail;
659659
660− if ((ret = av_frame_copy_props(aligned, *frame)) < 0)
660+ if (needs_copy && (ret = av_frame_copy_props(aligned, *frame)) < 0)
661661 goto fail;
662662
663663 av_frame_free(frame);
@@ -786,9 +786,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 122 unmodified lines
786786 goto fail;
787787 }
788788
789+ if ((ret = realign_frame(odesc, &out, 0)) < 0)
790+ goto fail;
791+
789792 av_frame_copy_props(out, in);
790793
791− if ((ret = realign_frame(desc, &in)) < 0)
794+ if ((ret = realign_frame(desc, &in, 1)) < 0)
792795 goto fail;
793796
794797 snprintf(buf, sizeof(buf)-1, "%d", outlink->w);

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