[{"id":24051,"web_url":"https://patchwork.libcamera.org/comment/24051/","msgid":"<Ytpf08faifnfcrOg@pendragon.ideasonboard.com>","date":"2022-07-22T08:29:07","subject":"Re: [libcamera-devel] [PATCH v2 1/1] Fix Android adaptor thumbnail\n\tbuffer lifetime","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Harvey,\n\nThank you for the patch.\n\nOn Fri, Jul 22, 2022 at 07:06:00AM +0000, Harvey Yang via libcamera-devel wrote:\n> Previously the thumbnail buffer is destructed before even being used in\n> Exif. This patch moves the buffer into class Exif, so that the developer\n> won't need to worry about its lifetime.\n> \n> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/android/jpeg/exif.cpp                | 13 +++++--------\n>  src/android/jpeg/exif.h                  |  5 ++++-\n>  src/android/jpeg/post_processor_jpeg.cpp |  2 +-\n>  3 files changed, 10 insertions(+), 10 deletions(-)\n> \n> diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp\n> index 3220b458..6b1d0f1f 100644\n> --- a/src/android/jpeg/exif.cpp\n> +++ b/src/android/jpeg/exif.cpp\n> @@ -430,16 +430,13 @@ void Exif::setOrientation(int orientation)\n>  \tsetShort(EXIF_IFD_0, EXIF_TAG_ORIENTATION, value);\n>  }\n>  \n> -/*\n> - * The thumbnail data should remain valid until the Exif object is destroyed.\n> - * Failing to do so, might result in no thumbnail data being set even after a\n> - * call to Exif::setThumbnail().\n> - */\n> -void Exif::setThumbnail(Span<const unsigned char> thumbnail,\n> +void Exif::setThumbnail(std::vector<unsigned char> &&thumbnail,\n>  \t\t\tCompression compression)\n>  {\n> -\tdata_->data = const_cast<unsigned char *>(thumbnail.data());\n> -\tdata_->size = thumbnail.size();\n> +\tthumbnailData_ = std::move(thumbnail);\n> +\n> +\tdata_->data = thumbnailData_.data();\n> +\tdata_->size = thumbnailData_.size();\n>  \n>  \tsetShort(EXIF_IFD_0, EXIF_TAG_COMPRESSION, compression);\n>  }\n> diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h\n> index 2ff8fb78..e68716f3 100644\n> --- a/src/android/jpeg/exif.h\n> +++ b/src/android/jpeg/exif.h\n> @@ -10,6 +10,7 @@\n>  #include <chrono>\n>  #include <string>\n>  #include <time.h>\n> +#include <vector>\n>  \n>  #include <libexif/exif-data.h>\n>  \n> @@ -60,7 +61,7 @@ public:\n>  \n>  \tvoid setOrientation(int orientation);\n>  \tvoid setSize(const libcamera::Size &size);\n> -\tvoid setThumbnail(libcamera::Span<const unsigned char> thumbnail,\n> +\tvoid setThumbnail(std::vector<unsigned char> &&thumbnail,\n>  \t\t\t  Compression compression);\n>  \tvoid setTimestamp(time_t timestamp, std::chrono::milliseconds msec);\n>  \n> @@ -106,4 +107,6 @@ private:\n>  \n>  \tunsigned char *exifData_;\n>  \tunsigned int size_;\n> +\n> +\tstd::vector<unsigned char> thumbnailData_;\n>  };\n> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n> index d72ebc3c..0cf56716 100644\n> --- a/src/android/jpeg/post_processor_jpeg.cpp\n> +++ b/src/android/jpeg/post_processor_jpeg.cpp\n> @@ -166,7 +166,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu\n>  \t\t\tstd::vector<unsigned char> thumbnail;\n>  \t\t\tgenerateThumbnail(source, thumbnailSize, quality, &thumbnail);\n>  \t\t\tif (!thumbnail.empty())\n> -\t\t\t\texif.setThumbnail(thumbnail, Exif::Compression::JPEG);\n> +\t\t\t\texif.setThumbnail(std::move(thumbnail), Exif::Compression::JPEG);\n>  \t\t}\n>  \n>  \t\tresultMetadata->addEntry(ANDROID_JPEG_THUMBNAIL_SIZE, data, 2);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 92912BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jul 2022 08:29:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6F3663311;\n\tFri, 22 Jul 2022 10:29:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B3536330B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 10:29:09 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EFC556D5;\n\tFri, 22 Jul 2022 10:29:08 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658478551;\n\tbh=tndwct7Y3K3sClvw09x5b1BfSnN3xySJqjyndUIVGA0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=xDyr9H3rJMLdlZzkc+Z/dT4MJesf6eE0uz6yh+CggxdVbfaW5EOH2BmOPgJdBxoy/\n\tm9pqx2dpOd7gQv/s5AKLA+nK0rrIqv83LBFqHW2spMJnBEClfpAO5OKrOmtQczsDSf\n\tZbk+WdOV0sRj2YdamuzQRoPS0zxAjIG5ZVGOAeW8jAandNFemd0tV8t5xZpkD9E3LN\n\tswqDwO2N8yhKNPYnJzV/QbtIIUmj8kpL/syheiNM4LIqdYsVHhPe/SAVqlUbDL0JXo\n\tFYTB8RLJLVuK/QmJi1RuiEmmmXgFvvltu3NrbEWvm/1vw5aHeMbgsIakKg9IWlVLp+\n\t5eSb6kLaOXKaA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658478549;\n\tbh=tndwct7Y3K3sClvw09x5b1BfSnN3xySJqjyndUIVGA0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=DyS5nutwx862Zitj+d6Di1AMXhKr58sZzF9qUxCzRn0dAVjRvjeofD3xf/CpbfOJZ\n\tVh05QCONGf4ThBR6y5pVT24ZitDBkv4D8yM9asziYCwQPN/DPxcEAUcvprUGW9R80P\n\tK6FBhY5yogrcEXgmBohneYNKgOdD81OK7o8PU9u4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DyS5nutw\"; dkim-atps=neutral","Date":"Fri, 22 Jul 2022 11:29:07 +0300","To":"Harvey Yang <chenghaoyang@chromium.org>","Message-ID":"<Ytpf08faifnfcrOg@pendragon.ideasonboard.com>","References":"<20220722070600.2949278-1-chenghaoyang@google.com>\n\t<20220722070600.2949278-2-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220722070600.2949278-2-chenghaoyang@google.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/1] Fix Android adaptor thumbnail\n\tbuffer lifetime","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Harvey Yang <chenghaoyang@google.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24055,"web_url":"https://patchwork.libcamera.org/comment/24055/","msgid":"<165b2dd0-4229-9104-6cd2-e5049e0728a2@ideasonboard.com>","date":"2022-07-22T12:43:33","subject":"Re: [libcamera-devel] [PATCH v2 1/1] Fix Android adaptor thumbnail\n\tbuffer lifetime","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hello,\n\nThank you for other version.\n\nI would re-write the subject line with:\n\n     android: exif: Fix thumbnail buffer lifetime\n\nIt can be handled during integration, no need for v3.\n\nOn 7/22/22 13:59, Laurent Pinchart via libcamera-devel wrote:\n> Hi Harvey,\n>\n> Thank you for the patch.\n>\n> On Fri, Jul 22, 2022 at 07:06:00AM +0000, Harvey Yang via libcamera-devel wrote:\n>> Previously the thumbnail buffer is destructed before even being used in\n>> Exif. This patch moves the buffer into class Exif, so that the developer\n>> won't need to worry about its lifetime.\n>>\n>> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nAgain,\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n>\n>> ---\n>>   src/android/jpeg/exif.cpp                | 13 +++++--------\n>>   src/android/jpeg/exif.h                  |  5 ++++-\n>>   src/android/jpeg/post_processor_jpeg.cpp |  2 +-\n>>   3 files changed, 10 insertions(+), 10 deletions(-)\n>>\n>> diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp\n>> index 3220b458..6b1d0f1f 100644\n>> --- a/src/android/jpeg/exif.cpp\n>> +++ b/src/android/jpeg/exif.cpp\n>> @@ -430,16 +430,13 @@ void Exif::setOrientation(int orientation)\n>>   \tsetShort(EXIF_IFD_0, EXIF_TAG_ORIENTATION, value);\n>>   }\n>>   \n>> -/*\n>> - * The thumbnail data should remain valid until the Exif object is destroyed.\n>> - * Failing to do so, might result in no thumbnail data being set even after a\n>> - * call to Exif::setThumbnail().\n>> - */\n>> -void Exif::setThumbnail(Span<const unsigned char> thumbnail,\n>> +void Exif::setThumbnail(std::vector<unsigned char> &&thumbnail,\n>>   \t\t\tCompression compression)\n>>   {\n>> -\tdata_->data = const_cast<unsigned char *>(thumbnail.data());\n>> -\tdata_->size = thumbnail.size();\n>> +\tthumbnailData_ = std::move(thumbnail);\n>> +\n>> +\tdata_->data = thumbnailData_.data();\n>> +\tdata_->size = thumbnailData_.size();\n>>   \n>>   \tsetShort(EXIF_IFD_0, EXIF_TAG_COMPRESSION, compression);\n>>   }\n>> diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h\n>> index 2ff8fb78..e68716f3 100644\n>> --- a/src/android/jpeg/exif.h\n>> +++ b/src/android/jpeg/exif.h\n>> @@ -10,6 +10,7 @@\n>>   #include <chrono>\n>>   #include <string>\n>>   #include <time.h>\n>> +#include <vector>\n>>   \n>>   #include <libexif/exif-data.h>\n>>   \n>> @@ -60,7 +61,7 @@ public:\n>>   \n>>   \tvoid setOrientation(int orientation);\n>>   \tvoid setSize(const libcamera::Size &size);\n>> -\tvoid setThumbnail(libcamera::Span<const unsigned char> thumbnail,\n>> +\tvoid setThumbnail(std::vector<unsigned char> &&thumbnail,\n>>   \t\t\t  Compression compression);\n>>   \tvoid setTimestamp(time_t timestamp, std::chrono::milliseconds msec);\n>>   \n>> @@ -106,4 +107,6 @@ private:\n>>   \n>>   \tunsigned char *exifData_;\n>>   \tunsigned int size_;\n>> +\n>> +\tstd::vector<unsigned char> thumbnailData_;\n>>   };\n>> diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\n>> index d72ebc3c..0cf56716 100644\n>> --- a/src/android/jpeg/post_processor_jpeg.cpp\n>> +++ b/src/android/jpeg/post_processor_jpeg.cpp\n>> @@ -166,7 +166,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu\n>>   \t\t\tstd::vector<unsigned char> thumbnail;\n>>   \t\t\tgenerateThumbnail(source, thumbnailSize, quality, &thumbnail);\n>>   \t\t\tif (!thumbnail.empty())\n>> -\t\t\t\texif.setThumbnail(thumbnail, Exif::Compression::JPEG);\n>> +\t\t\t\texif.setThumbnail(std::move(thumbnail), Exif::Compression::JPEG);\n>>   \t\t}\n>>   \n>>   \t\tresultMetadata->addEntry(ANDROID_JPEG_THUMBNAIL_SIZE, data, 2);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 742C7BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jul 2022 12:43:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D25736330F;\n\tFri, 22 Jul 2022 14:43:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E722601B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 14:43:40 +0200 (CEST)","from [IPV6:2401:4900:1f3f:a2d:c6dd:7a7c:3d3c:dbb9] (unknown\n\t[IPv6:2401:4900:1f3f:a2d:c6dd:7a7c:3d3c:dbb9])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A40CA6D5;\n\tFri, 22 Jul 2022 14:43:38 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658493821;\n\tbh=TpFBW01d0SLU5wpWP/V10c9U8msXDF7e4Xdxi4uIdCc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=BGf098quHlbVZiVRuursHuOEy9M8yAeNUNZfN13EDcB20Ali8dVN0/ZPHEWdv6CYE\n\tI5RS1eztaWa8KaCBW2Uy7E5q6p+RqRzoVdZUbKvgRtoyiLKQ6oRkc3VGUrYe3vK4MK\n\tT/5DcJKAVs/TArVFmDJ2OQCHr65LA5gw9/zOkqdihpcxq30te0z8ojsv07myiWeatS\n\t+O+wAkFqEsN1j7g15ABOhTilk3kiI7l3zEvz55KHBF29v4E71sMlf7Kr1/W+ijK60X\n\tDxpdsinqsSh6PWVwVrszbge3WSG/mBLhZGjnXqIxlOmo4tU+L/F29di+0liP5w2gDM\n\tBRN2E8nkUWsiA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658493819;\n\tbh=TpFBW01d0SLU5wpWP/V10c9U8msXDF7e4Xdxi4uIdCc=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=rC+tQFL4AwzLOPdY49I6sROW2br2mPsc0ulv4Rx1rh5369QiUgliGYaedcSzxL5S5\n\t4oOANkueIT7vF3tA+msH09lTxIjDOot2cOqdt5P25NDKQE9eWsIG3N0MRcHgMYYYTD\n\tEoicBLtMnfEsrrcKqqOuYJStBPhURJsBNDE0+yuo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"rC+tQFL4\"; dkim-atps=neutral","Message-ID":"<165b2dd0-4229-9104-6cd2-e5049e0728a2@ideasonboard.com>","Date":"Fri, 22 Jul 2022 18:13:33 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.4.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tHarvey Yang <chenghaoyang@chromium.org>","References":"<20220722070600.2949278-1-chenghaoyang@google.com>\n\t<20220722070600.2949278-2-chenghaoyang@google.com>\n\t<Ytpf08faifnfcrOg@pendragon.ideasonboard.com>","In-Reply-To":"<Ytpf08faifnfcrOg@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2 1/1] Fix Android adaptor thumbnail\n\tbuffer lifetime","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"Harvey Yang <chenghaoyang@google.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24062,"web_url":"https://patchwork.libcamera.org/comment/24062/","msgid":"<CAEB1ahvM_fKNRstfoAA-FnbhjpHwZa6Gg+DyPp67zddW_DMFmQ@mail.gmail.com>","date":"2022-07-22T16:04:17","subject":"Re: [libcamera-devel] [PATCH v2 1/1] Fix Android adaptor thumbnail\n\tbuffer lifetime","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/people/117/","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"content":"Sure and thanks, Umang!\n\nBR,\nHarvey\n\nOn Fri, Jul 22, 2022 at 8:43 PM Umang Jain <umang.jain@ideasonboard.com>\nwrote:\n\n> Hello,\n>\n> Thank you for other version.\n>\n> I would re-write the subject line with:\n>\n>      android: exif: Fix thumbnail buffer lifetime\n>\n> It can be handled during integration, no need for v3.\n>\n> On 7/22/22 13:59, Laurent Pinchart via libcamera-devel wrote:\n> > Hi Harvey,\n> >\n> > Thank you for the patch.\n> >\n> > On Fri, Jul 22, 2022 at 07:06:00AM +0000, Harvey Yang via\n> libcamera-devel wrote:\n> >> Previously the thumbnail buffer is destructed before even being used in\n> >> Exif. This patch moves the buffer into class Exif, so that the developer\n> >> won't need to worry about its lifetime.\n> >>\n> >> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> Again,\n>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n>\n> >\n> >> ---\n> >>   src/android/jpeg/exif.cpp                | 13 +++++--------\n> >>   src/android/jpeg/exif.h                  |  5 ++++-\n> >>   src/android/jpeg/post_processor_jpeg.cpp |  2 +-\n> >>   3 files changed, 10 insertions(+), 10 deletions(-)\n> >>\n> >> diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp\n> >> index 3220b458..6b1d0f1f 100644\n> >> --- a/src/android/jpeg/exif.cpp\n> >> +++ b/src/android/jpeg/exif.cpp\n> >> @@ -430,16 +430,13 @@ void Exif::setOrientation(int orientation)\n> >>      setShort(EXIF_IFD_0, EXIF_TAG_ORIENTATION, value);\n> >>   }\n> >>\n> >> -/*\n> >> - * The thumbnail data should remain valid until the Exif object is\n> destroyed.\n> >> - * Failing to do so, might result in no thumbnail data being set even\n> after a\n> >> - * call to Exif::setThumbnail().\n> >> - */\n> >> -void Exif::setThumbnail(Span<const unsigned char> thumbnail,\n> >> +void Exif::setThumbnail(std::vector<unsigned char> &&thumbnail,\n> >>                      Compression compression)\n> >>   {\n> >> -    data_->data = const_cast<unsigned char *>(thumbnail.data());\n> >> -    data_->size = thumbnail.size();\n> >> +    thumbnailData_ = std::move(thumbnail);\n> >> +\n> >> +    data_->data = thumbnailData_.data();\n> >> +    data_->size = thumbnailData_.size();\n> >>\n> >>      setShort(EXIF_IFD_0, EXIF_TAG_COMPRESSION, compression);\n> >>   }\n> >> diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h\n> >> index 2ff8fb78..e68716f3 100644\n> >> --- a/src/android/jpeg/exif.h\n> >> +++ b/src/android/jpeg/exif.h\n> >> @@ -10,6 +10,7 @@\n> >>   #include <chrono>\n> >>   #include <string>\n> >>   #include <time.h>\n> >> +#include <vector>\n> >>\n> >>   #include <libexif/exif-data.h>\n> >>\n> >> @@ -60,7 +61,7 @@ public:\n> >>\n> >>      void setOrientation(int orientation);\n> >>      void setSize(const libcamera::Size &size);\n> >> -    void setThumbnail(libcamera::Span<const unsigned char> thumbnail,\n> >> +    void setThumbnail(std::vector<unsigned char> &&thumbnail,\n> >>                        Compression compression);\n> >>      void setTimestamp(time_t timestamp, std::chrono::milliseconds\n> msec);\n> >>\n> >> @@ -106,4 +107,6 @@ private:\n> >>\n> >>      unsigned char *exifData_;\n> >>      unsigned int size_;\n> >> +\n> >> +    std::vector<unsigned char> thumbnailData_;\n> >>   };\n> >> diff --git a/src/android/jpeg/post_processor_jpeg.cpp\n> b/src/android/jpeg/post_processor_jpeg.cpp\n> >> index d72ebc3c..0cf56716 100644\n> >> --- a/src/android/jpeg/post_processor_jpeg.cpp\n> >> +++ b/src/android/jpeg/post_processor_jpeg.cpp\n> >> @@ -166,7 +166,7 @@ void\n> PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu\n> >>                      std::vector<unsigned char> thumbnail;\n> >>                      generateThumbnail(source, thumbnailSize, quality,\n> &thumbnail);\n> >>                      if (!thumbnail.empty())\n> >> -                            exif.setThumbnail(thumbnail,\n> Exif::Compression::JPEG);\n> >> +                            exif.setThumbnail(std::move(thumbnail),\n> Exif::Compression::JPEG);\n> >>              }\n> >>\n> >>              resultMetadata->addEntry(ANDROID_JPEG_THUMBNAIL_SIZE,\n> data, 2);\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BD62FBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jul 2022 16:04:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CB65F6330F;\n\tFri, 22 Jul 2022 18:04:32 +0200 (CEST)","from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com\n\t[IPv6:2a00:1450:4864:20::12a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C523601B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 18:04:30 +0200 (CEST)","by mail-lf1-x12a.google.com with SMTP id y11so8321387lfs.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 09:04:30 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658505872;\n\tbh=uRE3H8nzTaWalDqWxHPkXx5oiOot9qAQJrO+CBvhrO8=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=2b0Kyqyj3sLgrX1gJwmvGnY8H5BRAupgDVmgNpAUd0mRUBzAM4ta5ECm+nHhYuBlt\n\tJp2eyXgXbmQDrL8sDs3oMjHvjnqFMCCpxiipcmFYjtoPidjGaCIjtAISlh3MCo0Eyx\n\thwBQ6XgfpjPH0FZeyn/GO0eOXjXo756Tv8jHzzBPp15qCcGDrmslvzA0myXG+zBEvw\n\tELpQpbArCqJRqcG/oLagYI17WpdVsMmbGtLlB0vnbBUU7+CU/w50s8cjQiluNfRwD7\n\tqe1cBbgBRqPB/Iiyzh0aaBYhMCRbGXWaFprMNohCbBVRq3UlZ53Xbug7t1B5I22qto\n\t29Or86J/z2/EA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=s5beaWi3KjjMJmJUuMMc+LFx5P/11O9/dZ9tzU01hRI=;\n\tb=htO52iJMpRapWXEgebm/4oJQHGbInbM4ZhzqSLG2SpW/0ejJnZvsf5OVT815MH/4vV\n\tIxebEBpfK0fh9XlMiLT5qywODENl9M2fRIPMhm8iXDrv4nZN5D4qst/NyPOL5l5mTQWg\n\tiApa3EtVo1mqohaiWMZv8OSM0W7CMAMKli+ys="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"htO52iJM\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=s5beaWi3KjjMJmJUuMMc+LFx5P/11O9/dZ9tzU01hRI=;\n\tb=hxGHTrEN9IX9DmXq92CCskG6v9U3l2S6m2TZ7oMyBk9ACl3bqNd6sbesrKoiJWs25c\n\tuhOl/X0AQw70i6KwhvQrQ+EnjCyVoPli7wLcTgBw7OdO9/Ro2E4xqoiWNvUiwwEJp90W\n\tL/M/AVNchIXzZpeli1o7kr37hoDGZ56z9g3IGp4uVGAQCS4mM58qcPFMgjgdNEQWqeVL\n\tBWAvZUdRCYZb4/9fJtLOPIVZ4GPy72GbP7pgOkTi0vvMpk3OD0yAiORUS86wT8MLvz0B\n\t77Dew6MxWYh06eJ5nMH8ja8dPXSyB1Dx4palehfBQNPwhDF73A/rgJeh/taLEYCO2apE\n\tnq6Q==","X-Gm-Message-State":"AJIora8FU1Ftq9WOkTaqhkNPR6z6OBFDJjir55EIySFYIxJkmibhaTqN\n\tuYaY+iv5w1QMz4iy43BnsBDZNf8S1PksZzZkSG2WWg==","X-Google-Smtp-Source":"AGRyM1tRGWG77Z0d9NGc0Jd6zqsVcknl41AISmYxZX57z4mO5Ow51/6eRcfwdpzccDe0Z8GPiVgINIc1nOMkEJwWsbM=","X-Received":"by 2002:a05:6512:ad3:b0:489:ec0d:761e with SMTP id\n\tn19-20020a0565120ad300b00489ec0d761emr304056lfu.2.1658505869205;\n\tFri, 22 Jul 2022 09:04:29 -0700 (PDT)","MIME-Version":"1.0","References":"<20220722070600.2949278-1-chenghaoyang@google.com>\n\t<20220722070600.2949278-2-chenghaoyang@google.com>\n\t<Ytpf08faifnfcrOg@pendragon.ideasonboard.com>\n\t<165b2dd0-4229-9104-6cd2-e5049e0728a2@ideasonboard.com>","In-Reply-To":"<165b2dd0-4229-9104-6cd2-e5049e0728a2@ideasonboard.com>","Date":"Sat, 23 Jul 2022 00:04:17 +0800","Message-ID":"<CAEB1ahvM_fKNRstfoAA-FnbhjpHwZa6Gg+DyPp67zddW_DMFmQ@mail.gmail.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000031428c05e466fd9c\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/1] Fix Android adaptor thumbnail\n\tbuffer lifetime","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Cheng-Hao Yang via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Cheng-Hao Yang <chenghaoyang@chromium.org>","Cc":"Harvey Yang <chenghaoyang@google.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]