diff mbox series

[FFmpeg-devel,v2,3/3] avcodec/pngenc: write eXIf chunks

Message ID 20240916144344.390716-4-leo.izen@gmail.com
State New
Headers show
Series Exif Overhaul | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Leo Izen Sept. 16, 2024, 2:43 p.m. UTC
Write EXIF metadata exposed AV_FRAME_DATA_EXIF as an eXIf chunk
to PNG files, if present.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
 libavcodec/pngenc.c                      | 4 ++++
 tests/ref/fate/cover-art-mp3-id3v2-remux | 6 +++---
 tests/ref/fate/mov-cover-image           | 6 +++---
 3 files changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index cb79c04e11..02996bfed8 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -414,6 +414,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;
diff --git a/tests/ref/fate/cover-art-mp3-id3v2-remux b/tests/ref/fate/cover-art-mp3-id3v2-remux
index 52b7e72a56..60802490f1 100644
--- a/tests/ref/fate/cover-art-mp3-id3v2-remux
+++ b/tests/ref/fate/cover-art-mp3-id3v2-remux
@@ -1,5 +1,5 @@ 
-94946f0efd5f9bb0061ac1fbff7d731f *tests/data/fate/cover-art-mp3-id3v2-remux.mp3
-399346 tests/data/fate/cover-art-mp3-id3v2-remux.mp3
+0643e306430fbadeb1c89da6ab36a303 *tests/data/fate/cover-art-mp3-id3v2-remux.mp3
+399414 tests/data/fate/cover-art-mp3-id3v2-remux.mp3
 #tb 0: 1/14112000
 #media_type 0: audio
 #codec_id 0: mp3
@@ -23,7 +23,7 @@ 
 0,    -353590,    -353590,   368640,      417, 0x15848290, S=1,       10
 1,          0,          0,        0,   208350, 0x291b44d1
 2,          0,          0,        0,    15760, 0x71d5c418
-3,          0,          0,        0,   165671, 0x7c1c8070
+3,          0,          0,        0,   165739, 0x2e108b69
 0,      15050,      15050,   368640,      418, 0x46f684a4
 0,     383690,     383690,   368640,      418, 0x46f684a4
 0,     752330,     752330,   368640,      418, 0x46f684a4
diff --git a/tests/ref/fate/mov-cover-image b/tests/ref/fate/mov-cover-image
index 5f65c630ea..7721b88001 100644
--- a/tests/ref/fate/mov-cover-image
+++ b/tests/ref/fate/mov-cover-image
@@ -1,5 +1,5 @@ 
-54a8870d5d1e6cc4da28ae422aa70898 *tests/data/fate/mov-cover-image.mp4
-1011919 tests/data/fate/mov-cover-image.mp4
+371e01af72ce3bc8339429068455b920 *tests/data/fate/mov-cover-image.mp4
+1012013 tests/data/fate/mov-cover-image.mp4
 #extradata 0:        2, 0x00340022
 #tb 0: 1/44100
 #media_type 0: audio
@@ -20,7 +20,7 @@ 
 0,      -1088,      -1088,     1024,        6, 0x027e00e8, F=0x5
 0,        -64,        -64,     1024,        6, 0x027e00e8
 1,          0,          0,        0,    25441, 0xe82503b0
-2,          0,          0,        0,    32657, 0x080255d2
+2,          0,          0,        0,    32751, 0x410d5f1d
 0,        960,        960,     1024,        6, 0x027e00e8
 0,       1984,       1984,     1024,        6, 0x027e00e8
 0,       3008,       3008,     1024,        6, 0x027e00e8