[vlc-devel] [PATCH 1/5] vout: update the format after filters
rom1v at videolabs.io
Wed Oct 21 11:28:40 CEST 2020
On Wed, Oct 21, 2020 at 07:42:04AM +0200, Steve Lhomme wrote:
> On 2020-10-20 16:20, Romain Vimont wrote:
> > On Tue, Oct 20, 2020 at 03:59:27PM +0200, Steve Lhomme wrote:
> > > > + /* Move vout_fmt to *target */
> > > > + video_format_Clean(target);
> > > > + memcpy(target, &vout_fmt, sizeof(*target));
> > >
> > > You should use video_format_Copy()
> > No, it's a "move" (in the Rust/C++ sense): target directly takes
> > ownership of the inner data of vout_fmt (and vout_fmt content is
> > considered undefined).
> > This avoids an unnecessary deep-copy followed by the destruction of the
> > source.
> Usually we do vout_fmt = *target for this.
(*target = vout_fmt)
Yes, I don't know why I used memcpy().
> But that's often for local copies
> that are known not to use the palette. Maybe a video_format_Move() could be
> added to handle that more gracefully (and never have to worry about the
I proposed video_format_Move() internally at Videolabs, but people were
against it because it's not obvious that the parameter is consumed and
that it must not be used anymore.
More information about the vlc-devel