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

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

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
632 return 0;632 return 0;
633}633}
634 634
635static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame)635static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
636{636{
637 AVFrame *aligned = NULL;637 AVFrame *aligned = NULL;
638 int ret = 0, plane, planes;638 int ret = 0, plane, planes;
@@ -654,10 +654,10 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame) · 15 unmodified lines
654 if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0)654 if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0)
655 goto fail;655 goto fail;
656 656
657 if ((ret = av_frame_copy(aligned, *frame)) < 0)657 if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
658 goto fail;658 goto fail;
659 659
660 if ((ret = av_frame_copy_props(aligned, *frame)) < 0)660 if (needs_copy && (ret = av_frame_copy_props(aligned, *frame)) < 0)
661 goto fail;661 goto fail;
662 662
663 av_frame_free(frame);663 av_frame_free(frame);
@@ -786,9 +786,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 122 unmodified lines
786 goto fail;786 goto fail;
787 }787 }
788 788
789 if ((ret = realign_frame(odesc, &out, 0)) < 0)
790 goto fail;
791
789 av_frame_copy_props(out, in);792 av_frame_copy_props(out, in);
790 793
791 if ((ret = realign_frame(desc, &in)) < 0)794 if ((ret = realign_frame(desc, &in, 1)) < 0)
792 goto fail;795 goto fail;
793 796
794 snprintf(buf, sizeof(buf)-1, "%d", outlink->w);797 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