From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9E828495B9 for ; Tue, 13 Feb 2024 21:25:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A69968D19A; Tue, 13 Feb 2024 23:25:10 +0200 (EET) Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 030A468C4E1 for ; Tue, 13 Feb 2024 23:25:02 +0200 (EET) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3be110bbff9so1416098b6e.1 for ; Tue, 13 Feb 2024 13:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707859500; x=1708464300; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uVhqDlK8gauvT38E5XzDPqYApJ0R68fVXpc7QAfsy44=; b=BY3dpkF8S9Z/8TdSVnrL5jEUzLRMEBlGSJnP8DaXzvfomEcCWceWXjy/Wvj3JpysRT 9FHPE+IKUdY2psH4YYcrY/eJoAmOtiuj+awWxzrRBk1bNc/xGVqLf2gCsn17yQK3UN/E yN0hcQuVUyE8f1qvqrBUN6xYCGuzOEss+pu2IhN3sLDH8utimOMN/c8Xgmm10DTgRJv9 Fh1zV4mm2ucFDFVpV8oXwwQy5fvhDFF5RtMWQot/YHaUiFxnrKoVlqKjIn8FQL5RP2cc amvP2G0br01Udrd8zaZFgUy2TAwHv0/n8/a76y5ktoTeqGeBJp/2M2z28nWXJbF0aZa3 tpqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707859500; x=1708464300; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uVhqDlK8gauvT38E5XzDPqYApJ0R68fVXpc7QAfsy44=; b=Z4e0EQgKp61mFCstAllPgLF0r8k1aqKUSKUooLMUntny2zDopnpxBH4LvPCmDgHnDK 13FJc9VN/osG/Ri46gYypG8VsPGy12ChXKKMRFQSDu2sLVha4nk8IJijYKsHYUQ9haDr HsLlknUgmPtQIUQeDZl7aDiNn88LXcQ/Hhmi12sR7msZQDChkdorQjHyPM1RBaOkUfqf AWVa7hFkmqeYg74EYpBkrObjg6xlh2yHqINH4+P1G5vALvdsoroC3SbHuDc4UhSYT+gB IXQHlaVml3q/PcAyyj3OhOg2NXhD7s/5jawKmNLtpWj3N+X1iZWrV4lU1kAJZEnZagUY q9LQ== X-Gm-Message-State: AOJu0Yw4JHlCNfebmP80ReUGt1AYQnmDcvzFfkP1V6PQ0HrxmN/NF/4k tbtIK8XFEQ9g8+xgo1VT7Ls/VMY54vuaRrm/3QApdO6ndstdt2Rnv3ufYDZG X-Google-Smtp-Source: AGHT+IFMzHE8keY57HfrzFDTV3wSFtAxzMsSNhu3ymnR0UABOuQuWJq0CIu9olp8K5LC/+oAzP7/5g== X-Received: by 2002:a05:6870:9e85:b0:21a:3083:5118 with SMTP id pu5-20020a0568709e8500b0021a30835118mr204677oab.1.1707859500069; Tue, 13 Feb 2024 13:25:00 -0800 (PST) Received: from gauss.local (c-68-56-149-176.hsd1.mi.comcast.net. [68.56.149.176]) by smtp.gmail.com with ESMTPSA id g5-20020a37e205000000b007861bea2972sm1523016qki.6.2024.02.13.13.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:24:59 -0800 (PST) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Feb 2024 16:24:55 -0500 Message-ID: <20240213212456.167386-3-leo.izen@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213212456.167386-1-leo.izen@gmail.com> References: <20240213212456.167386-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/pngdec: parse eXIf chunk X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Leo Izen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Add support to parse eXIf chunks using the new EXIF framework. Signed-off-by: Leo Izen --- libavcodec/pngdec.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 026da30c25..e7951d1802 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -38,6 +38,7 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" +#include "exif_internal.h" #include "apng.h" #include "png.h" #include "pngdsp.h" @@ -123,6 +124,7 @@ typedef struct PNGDecContext { int pass_row_size; /* decompress row size of the current pass */ int y; FFZStream zstream; + AVBufferRef *exif_data; } PNGDecContext; /* Mask to determine which pixels are valid in a pass */ @@ -652,6 +654,26 @@ static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s, return 0; } +static int decode_exif_chunk(AVCodecContext *avctx, PNGDecContext *s, + GetByteContext *gb) +{ + if (!(s->hdr_state & PNG_IHDR)) { + av_log(avctx, AV_LOG_ERROR, "eXIf before IHDR\n"); + return AVERROR_INVALIDDATA; + } + if (s->pic_state & PNG_IDAT) { + av_log(avctx, AV_LOG_ERROR, "eXIf after IDAT\n"); + return AVERROR_INVALIDDATA; + } + av_buffer_unref(&s->exif_data); + s->exif_data = av_buffer_alloc(bytestream2_get_bytes_left(gb)); + if (!s->exif_data) + return AVERROR(ENOMEM); + bytestream2_get_buffer(gb, s->exif_data->data, s->exif_data->size); + + return 0; +} + /* * This populates AVCodecContext fields so it must be called before * ff_thread_finish_setup() to avoid a race condition with respect to the @@ -890,6 +912,12 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s, p->flags |= AV_FRAME_FLAG_KEY; p->flags |= AV_FRAME_FLAG_INTERLACED * !!s->interlace_type; + if (s->exif_data) { + ret = ff_exif_attach(avctx, p, &s->exif_data); + if (ret < 0) + return ret; + } + if ((ret = populate_avctx_color_fields(avctx, p)) < 0) return ret; ff_thread_finish_setup(avctx); @@ -1571,6 +1599,12 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, s->mdvc_max_lum = bytestream2_get_be32u(&gb_chunk); s->mdvc_min_lum = bytestream2_get_be32u(&gb_chunk); break; + case MKTAG('e', 'X', 'I', 'f'): { + ret = decode_exif_chunk(avctx, s, &gb_chunk); + if (ret < 0) + goto fail; + break; + } case MKTAG('I', 'E', 'N', 'D'): if (!(s->pic_state & PNG_ALLIMAGE)) av_log(avctx, AV_LOG_ERROR, "IEND without all image\n"); @@ -1907,6 +1941,7 @@ static av_cold int png_dec_end(AVCodecContext *avctx) s->tmp_row_size = 0; av_freep(&s->iccp_data); + av_buffer_unref(&s->exif_data); av_dict_free(&s->frame_metadata); ff_inflate_end(&s->zstream); -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".