[FFmpeg-devel] [RFC]lavc/tiff: Support dng cropping
Anton Khirnov
anton at khirnov.net
Tue Nov 1 12:15:10 EET 2022
Quoting Carl Eugen Hoyos (2022-11-01 03:08:36)
> Am Mo., 31. Okt. 2022 um 13:39 Uhr schrieb Anton Khirnov <anton at khirnov.net>:
> >
> > Quoting Carl Eugen Hoyos (2022-10-23 20:46:57)
> > > Am So., 23. Okt. 2022 um 16:35 Uhr schrieb Carl Eugen Hoyos
> > > <ceffmpeg at gmail.com>:
> > > >
> > > > Hi!
> > > >
> > > > I tried to implement dng cropping, it unfortunately can only work with
> > > > -flags +unaligned, is there an alternative to simply print a warning
> > > > if the flag was not supplied?
> > >
> > > New patch with more parentheses attached.
> > >
> > > Please comment, Carl Eugen
> > >
> > > From 1bfe065564604659b7703e75b1bb750c031fdc81 Mon Sep 17 00:00:00 2001
> > > From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> > > Date: Sun, 23 Oct 2022 16:31:53 +0200
> > > Subject: [PATCH] lavc/tiff: Support dng cropping,
> >
> > A FATE test would be nice.
>
> The samples are big but will look into this once the patch is ok.
>
> > > needs -flags +unaligned
> >
> > AFAICT this is not entirely correct. Applying left cropping in
> > libavcodec might need AV_CODEC_FLAG_UNALIGNED, but not always.
>
> Of course, but evidence indicates that in nearly all cases, it is needed.
>
> > Users may also set apply_cropping=0 and apply cropping themselves.
>
> It should be possible to check this.
>
> > The decoder should not care about it in any case, since it's handled in
> > the generic code.
>
> Could you elaborate?
> The reason I added this check (and I would love to see that it is not
> necessary) is that there is no (working) generic code afaict and that
> decoding just breaks without a useful hint if the check is removed.
The generic code I'm talking about is apply_cropping() in
libavcodec/decode.c. If you want to add a warning, it should live there
and be added in a separate patch. Note how no other decoder has such a
warning internally, even though they set crop_left.
What will be slightly nontrivial is detecting when the warning is
appropriate, i.e. when av_frame_apply_croppying() is unable to apply the
cropping fully. What I'd do is change av_frame_apply_croppying() to
return 1 in such a case (it is currently documented to return >= 0, so
this is backwards compatible).
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list