[FFmpeg-devel] [PATCH 3/3] avcodec/webp: add support for ICCP chunks

James Almer jamrial at gmail.com
Wed Jul 26 17:35:05 EEST 2017


On 7/26/2017 3:18 AM, Rostislav Pehlivanov wrote:
> On 26 July 2017 at 05:31, James Almer <jamrial at gmail.com> wrote:
> 
>> Export the raw data as ICC Profile frame side data.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>>  libavcodec/webp.c | 26 ++++++++++++++++++++++++--
>>  1 file 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 at 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', ' '):
>> --
>> 2.13.3
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
> 
> Can't find anything that could go wrong here and the specs don't mention
> anything special, so LGTM.

Pushed.


More information about the ffmpeg-devel mailing list