diff options
author | James Almer <jamrial@gmail.com> | 2017-07-26 01:28:35 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-07-26 11:31:17 -0300 |
commit | c220fe008c5a3f7c652dbd03ce2a58e392e59e19 (patch) | |
tree | cb722983ba5964a678f0088f7e19dace950a138e | |
parent | 5e4e9afaa127acbfa9ac445a8572b49dadb68b17 (diff) | |
download | ffmpeg-c220fe008c5a3f7c652dbd03ce2a58e392e59e19.tar.gz |
avcodec/webp: add support for ICCP chunks
Export the raw data as ICC Profile frame side data.
Reviwed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavcodec/webp.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/libavcodec/webp.c b/libavcodec/webp.c index a0d4d1812d..efa864a6f1 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -33,10 +33,10 @@ * * @author James Almer <jamrial@gmail.com> * Exif metadata + * ICC profile * * Unimplemented: * - Animation - * - ICC profile * - XMP metadata */ @@ -197,6 +197,7 @@ typedef struct WebPContext { uint8_t *alpha_data; /* alpha chunk data */ int alpha_data_size; /* alpha chunk data size */ int has_exif; /* set after an EXIF chunk has been processed */ + int has_iccp; /* set after an ICCP chunk has been processed */ int width; /* image width */ int height; /* image height */ int lossless; /* indicates lossless or lossy */ @@ -1381,6 +1382,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, *got_frame = 0; s->has_alpha = 0; s->has_exif = 0; + s->has_iccp = 0; bytestream2_init(&gb, avpkt->data, avpkt->size); if (bytestream2_get_bytes_left(&gb) < 12) @@ -1514,7 +1516,27 @@ exif_end: bytestream2_skip(&gb, chunk_size); break; } - case MKTAG('I', 'C', 'C', 'P'): + case MKTAG('I', 'C', 'C', 'P'): { + AVFrameSideData *sd; + + if (s->has_iccp) { + av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra ICCP chunk\n"); + bytestream2_skip(&gb, chunk_size); + break; + } + if (!(vp8x_flags & VP8X_FLAG_ICC)) + av_log(avctx, AV_LOG_WARNING, + "ICCP chunk present, but ICC Profile bit not set in the " + "VP8X header\n"); + + s->has_iccp = 1; + sd = av_frame_new_side_data(p, AV_FRAME_DATA_ICC_PROFILE, chunk_size); + if (!sd) + return AVERROR(ENOMEM); + + bytestream2_get_buffer(&gb, sd->data, chunk_size); + break; + } case MKTAG('A', 'N', 'I', 'M'): case MKTAG('A', 'N', 'M', 'F'): case MKTAG('X', 'M', 'P', ' '): |