On 2/14/24 13:53, Andreas Rheinhardt wrote:
Leo Izen:
Write EXIF metadata exposed AV_FRAME_DATA_EXIF as an eXIf chunk
to PNG files, if present.

Signed-off-by: Leo Izen <leo.i...@gmail.com>
---
  libavcodec/pngenc.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 50689cb50c..a302c879da 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -413,6 +413,10 @@ static int encode_headers(AVCodecContext *avctx, const 
AVFrame *pict)
          }
      }
+ side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_EXIF);
+    if (side_data)
+        png_write_chunk(&s->bytestream, MKTAG('e', 'X', 'I', 'f'), 
side_data->data, FFMIN(side_data->size, INT_MAX));
+
      side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_ICC_PROFILE);
      if ((ret = png_write_iccp(s, side_data)))
          return ret;

If I see this correctly, then these patches can lead to a situation
where an input packet has rotation metadata in exif which gets exported
twice -- as displaymatrix and as exif metadata side data. If the user
changes the displaymatrix (e.g. applies the transformation to the image
data and removes the displaymatrix side data before reencoding), the
exif data (that the user would probably not be aware of) would still be
there and get propagated into the output, corrupting it.


Hm. This is true, but it's also currently how the mjpeg decoder functions (i.e. it attaches displaymatrix side data).

There are no encoders that currently save EXIF metadata, so there's no precedent.

How do you suggest this be reconciled?

- Leo Izen (Traneptora)

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to