From patchwork Fri Jan 7 09:01:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Izen X-Patchwork-Id: 33150 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp209748iog; Fri, 7 Jan 2022 01:02:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrEjDNp/PFuWGXr2NQJ+bs1UY/YSpt/R2y62uXyzfbJ/3RWRpQb5vtRIqr3VZYnOhYf4As X-Received: by 2002:a50:ef11:: with SMTP id m17mr8863130eds.77.1641546166110; Fri, 07 Jan 2022 01:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641546166; cv=none; d=google.com; s=arc-20160816; b=qCvw3xuiEGm38LuU7WtKdkKMzEeIK9359s3RH+EVkOvRAzmLoUiSk9qm1XDyM1RpY5 VxesMWwxEXbCjGKvj5zEYhxIjnx9QAfgoNqGXjlhVcVp0U5bmbYTvTuPlzBVUSFNs55W xEmNCpeBP/abVFZvbbT5Kh9/lTspf55wUrRij6oO5EojFtpKHK/No3MRbDN1laMx5h1f wtrLnoDQ0we9o3xMGhGxjkQS4gYB/aW50Q7LRVHXyTl7udovydJaaZ+gROUFmJITqmNO l9JaEnhyW05Z+NygoQGWSeMXrirKVLKe0QGjgrfNfBUkCWboOz1K/bb0V8c5loqMK0MZ OWoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=CQSxiofB9UwuarmyxEcwi4KOZTscUvBcI/TIqoFSrjI=; b=DVNzmLZXzYeA2sEy9VCEMXSXeaa5IdB82voaDfKbHqriNxPUKlOkqBrCLm8fC7Jy4X MmMm9E5q+A796V/Ei/FJajJ6+tz6arMaxY6Nk9Pz1wSDFZb2EIHwQ3lN1TFnahwfwZvb F6tVRtaWJb8Pg9AKD8YyUmqE8ZhoDRSCuhZnlnacz3XNObuvD6MOMqo3s9Ljolj4XfW5 5AZkeCSmfvYKAFvqRrY1vs3KuYexpcS92Zc6YFjIkA7OMvN3z8eau0ChhKEXAxjNtGHv JvnC1daka0+iwjM3sK3lH/5/r1CN6vcVH0VZ0hT62C/C20lYH4fdRTSOD1EY7uhSYqUD Kd8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=W9yaHOY2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eg50si1019282edb.339.2022.01.07.01.02.45; Fri, 07 Jan 2022 01:02:46 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=W9yaHOY2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A22868AE72; Fri, 7 Jan 2022 11:02:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E11BD68A927 for ; Fri, 7 Jan 2022 11:01:55 +0200 (EET) Received: by mail-qk1-f176.google.com with SMTP id f138so5315603qke.10 for ; Fri, 07 Jan 2022 01:01:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rEApeLgCxRFtfvakiFX4XMaMIgCBXx3pLDyrgNBQ/xw=; b=W9yaHOY2eO63xMIZaG4XX2twhQYKqZ/6DYUxQMvn0vcgLyZsmEZhrEeT0L9gbRdC1p xHNiDfYAca3yJHY80qNrOySMZDxAeM1OOXa6PKNu7ztAFPlkP9BQMCIZ8VYZCjwA+6Bs nIFHu4YOniOU271PDDRsqbgimSYsakRYM02dzFVsxCHitSV+tKPsh1Goc76z8jId44aA WWYopTrbcaJHQHop6B3FdsVntvwUtVhfpSL9EuVb+n4T/1yh4FwrkkNuJ0VfE7Z7k5/r BPCJGH0HdGUBJVsCyNxznjtKK9a5PJIoRWu+6I5Qe5VZXEgYmp0SHHPQrF9dEteKNuJ+ ZF8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rEApeLgCxRFtfvakiFX4XMaMIgCBXx3pLDyrgNBQ/xw=; b=miXK5Urd3eVPydAV5+f+qmtuqgAIzJPYBesJWtzLsSkoyCq5Dakd3Z1TKjC7NitwBS 2gGkBzScohn5C2S3dixwYut534ATIsBr8NIlWF1z0jmp/i40OTW9b2z5IDS1P4udT9zA HPKjleLvOv4+Lv7cPRsaTjYC5XP+9LfusdcIXCjX2x0nsb30m1lG6BtmHvAibzEZMoYH keX9tggAoviVJ7jG3CMvqhQvkeSPBpcHYpxEQuGs5cUPR5AoH7tlmJBkXFZZpb//YUL+ Yt6KNT8StDKXoax3kF6s6aM60fn/7x2RSoGzxC/s5Uow+ahc2Y9TbjZoKs3lHfsckUXv Uh8Q== X-Gm-Message-State: AOAM5306gGMvDHYs5ZpE+0IXBcENqaTXNIiIL4bGei0nefT0rKIisHOt hMmdYD2ylNp+xz+D9TczgbvKSI7g4wk= X-Received: by 2002:a37:5545:: with SMTP id j66mr44200715qkb.705.1641546114765; Fri, 07 Jan 2022 01:01:54 -0800 (PST) Received: from gauss.local (c-68-41-54-207.hsd1.mi.comcast.net. [68.41.54.207]) by smtp.gmail.com with ESMTPSA id u17sm3077071qki.2.2022.01.07.01.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 01:01:54 -0800 (PST) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jan 2022 04:01:10 -0500 Message-Id: <20220107090111.243853-5-leo.izen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220107090111.243853-1-leo.izen@gmail.com> References: <20220107090111.243853-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 4/5] avformat/image2: add Jpeg XL as image2 format 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: TOYCr23NzinK This commit adds support to libavformat for muxing and demuxing Jpeg XL images as image2 streams. --- libavformat/allformats.c | 1 + libavformat/img2.c | 1 + libavformat/img2dec.c | 19 +++++++++++++++++++ libavformat/img2enc.c | 6 +++--- libavformat/mov.c | 1 + libavformat/version.h | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d066a7745b..24e0dd3389 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -508,6 +508,7 @@ extern const AVInputFormat ff_image_gif_pipe_demuxer; extern const AVInputFormat ff_image_j2k_pipe_demuxer; extern const AVInputFormat ff_image_jpeg_pipe_demuxer; extern const AVInputFormat ff_image_jpegls_pipe_demuxer; +extern const AVInputFormat ff_image_jpegxl_pipe_demuxer; extern const AVInputFormat ff_image_pam_pipe_demuxer; extern const AVInputFormat ff_image_pbm_pipe_demuxer; extern const AVInputFormat ff_image_pcx_pipe_demuxer; diff --git a/libavformat/img2.c b/libavformat/img2.c index 4153102c92..13b1b997b8 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -87,6 +87,7 @@ const IdStrMap ff_img_tags[] = { { AV_CODEC_ID_GEM, "img" }, { AV_CODEC_ID_GEM, "ximg" }, { AV_CODEC_ID_GEM, "timg" }, + { AV_CODEC_ID_JPEGXL, "jxl" }, { AV_CODEC_ID_NONE, NULL } }; diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index a6084ceef0..44336d812d 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -30,6 +30,7 @@ #include "libavutil/parseutils.h" #include "libavutil/intreadwrite.h" #include "libavcodec/gif.h" +#include "libavcodec/jpegxl.h" #include "avformat.h" #include "avio_internal.h" #include "internal.h" @@ -834,6 +835,23 @@ static int jpegls_probe(const AVProbeData *p) return 0; } +static int jpegxl_probe(const AVProbeData *p) +{ + const uint8_t *b = p->buf; + + /* ISOBMFF-based container */ + /* 0x4a584c20 == "JXL " */ + if (AV_RL64(b) == FF_JPEGXL_CONTAINER_SIGNATURE_LE) + return AVPROBE_SCORE_EXTENSION + 1; + /* Raw codestreams all start with 0xff0a */ + if (AV_RL16(b) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE) + return 0; + if (avpriv_jpegxl_verify_codestream_header(NULL, p->buf, p->buf_size, 5) == 0) + return AVPROBE_SCORE_MAX - 2; + else + return 0; +} + static int pcx_probe(const AVProbeData *p) { const uint8_t *b = p->buf; @@ -1153,6 +1171,7 @@ IMAGEAUTO_DEMUXER(gif, AV_CODEC_ID_GIF) IMAGEAUTO_DEMUXER(j2k, AV_CODEC_ID_JPEG2000) IMAGEAUTO_DEMUXER(jpeg, AV_CODEC_ID_MJPEG) IMAGEAUTO_DEMUXER(jpegls, AV_CODEC_ID_JPEGLS) +IMAGEAUTO_DEMUXER(jpegxl, AV_CODEC_ID_JPEGXL) IMAGEAUTO_DEMUXER(pam, AV_CODEC_ID_PAM) IMAGEAUTO_DEMUXER(pbm, AV_CODEC_ID_PBM) IMAGEAUTO_DEMUXER(pcx, AV_CODEC_ID_PCX) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index ded91d6b98..6ac430c6dd 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -261,9 +261,9 @@ static const AVClass img2mux_class = { const AVOutputFormat ff_image2_muxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), - .extensions = "bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png," - "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24," - "sunras,xbm,xface,pix,y", + .extensions = "bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv," + "png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8," + "im24,sunras,xbm,xface,pix,y", .priv_data_size = sizeof(VideoMuxData), .video_codec = AV_CODEC_ID_MJPEG, .write_header = write_header, diff --git a/libavformat/mov.c b/libavformat/mov.c index e401cd39b5..226495cf1f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7431,6 +7431,7 @@ static int mov_probe(const AVProbeData *p) if (tag == MKTAG('f','t','y','p') && ( AV_RL32(p->buf + offset + 8) == MKTAG('j','p','2',' ') || AV_RL32(p->buf + offset + 8) == MKTAG('j','p','x',' ') + || AV_RL32(p->buf + offset + 8) == MKTAG('j','x','l',' ') )) { score = FFMAX(score, 5); } else { diff --git a/libavformat/version.h b/libavformat/version.h index 77f4b46712..9083bb1a29 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 17 +#define LIBAVFORMAT_VERSION_MINOR 18 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \