From patchwork Mon Feb 28 21:12:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Izen X-Patchwork-Id: 34547 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp3080300nkx; Mon, 28 Feb 2022 13:13:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi5iAG5Tte45g5usEHJVlLbnNT78y3w2k4/MzB/chjcWFqfthtfkEN/8ueAxUI6BiCbkmk X-Received: by 2002:a17:906:7e09:b0:6d6:80f5:e00f with SMTP id e9-20020a1709067e0900b006d680f5e00fmr8396322ejr.192.1646082833681; Mon, 28 Feb 2022 13:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646082833; cv=none; d=google.com; s=arc-20160816; b=mag3tdYy/dlVZTwPG3BJWQl4TSAzd6yyiqMbeS8rQ4f6hd5Pm35Jq5VQYp4515/Z26 WTiG9HYa8lqRaBkfgx4m2kSkyGBpsKmbwQ5ZAJvQsVcTAlDQOR79x7sCgEJg10+BI8eC hwQWUZdQDgSrjSliu9h6W14GJP1khP22AkBzk7kouWy3+a1zNWpwOCrj66CFN55zCzUw t4LRvi4O5xwBY/B5P2V2k/iC+/Dlf4/usP4gnPv+AWc9h79TjLIyU4ByJVdQnH50KlD9 WJ2W31qRJQMYJtADIhNlBSxK1FKsxIwCe2xIgmqRKbAUL6ChCkYlgivLLnIT86nzW9HJ EEfA== 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=HUWYEDeWguft82helNHnJujfV0K/HTN9gY/IQuOYDyU=; b=WYsietPVtkA1d6cRLFummcckd6JbA0JTKJywps7G//Nw+d0Q5Px2lRxZ+lOqOZJB00 x3gMIMpiNLtRcw89nb5vZOLhOegpFFF0xVy67L52xyI4RElNFfnjFmrwldGMXl6UbsU1 oboRuIhRC+UsXXme8kLoILycN9F8xpeqlD0iO+11laLG9iK4zP8Yw7qnas5O8dFdaQQu ahrcLnBoGsQMttDsTbjlkVEpIkfuOA/bAk317TTjWFyXaQWfT0c9If956GmBB0mAym7y t2H0QPL2vgC5ydA87tyYMmKqHVG7Q3F4x3mT1Ks70pWIVif7MzdanpdJqizrx5NsAwRM bTkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=UrCu7zUu; 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 8-20020a170906024800b006ac3d8b2389si6962720ejl.847.2022.02.28.13.13.53; Mon, 28 Feb 2022 13:13:53 -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=UrCu7zUu; 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 4E34568B02F; Mon, 28 Feb 2022 23:13:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B0A968B026 for ; Mon, 28 Feb 2022 23:13:42 +0200 (EET) Received: by mail-qv1-f44.google.com with SMTP id d3so14801768qvb.5 for ; Mon, 28 Feb 2022 13:13:42 -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=D8GF3gdvNNvdCao5GxqF4MfOIYSOUh+UjniTCDw/Hhg=; b=UrCu7zUuyaDFJKtjnfSQVhIH1+Ae8tQY2LBO5i7IsVt/dyfuyJZ+YAlGUD1G2dUHUf /8/rqIFvWnKyg1TP2wa36rucb5z2BSlic1qIOFyxCf56mK7B23DoRYQC8kQ2+Q6vXi+F vs6GP06tmqLptlx0DJY2zunKmcr4JnFJGf8444oexBuAr2q7B+bMYiSW9WxjGJnfg53V Otf+5DZA9kb7g1AKnQ9RiG123tZuaaclvKmpfmnEeUWTcoPN+4QygGILtIaeygPs6kRE Ul158fGLWnSz8Qq613R8wuBpxLCH7Tloh4EwDYY/dSjevcdR/s1dMkeSnhs1ah2d7h0Y 149Q== 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=D8GF3gdvNNvdCao5GxqF4MfOIYSOUh+UjniTCDw/Hhg=; b=e+KK7Y0l3J8bRsOlc/EYF5MTNTf2uLm/xeJL2rgcVDXiq+tZBPv9J+kLtAgbkoy9oe NYIbpZQiHglm8gjwqu0qKYEex/6THhvq3jg0UBm8dBfScRtV3GxrWu0exEyw2jFqYlkC h1dbp2XLH2iq+AjEsn+ACNBi4Mdd57T0eKT8IIyS3fpuj2DKWqS2XbgpDfNMkv/TolEe iBwZfSqpWFBqI5gYHY9s/ajzls94SMCSu8J6kjVTDFtjq8gg9NnJkVEveDTPls8cAZ49 4rd8r126KkOWOboI8VzVpy0PWflzOZKdCn+uKhQLHz4Ui40kLHCHWkOULMVOjEh5HHG/ DQ+Q== X-Gm-Message-State: AOAM532rSfDd/M+lohebC/9IVhqgHmy04KQkhLCjUgQkgHwOzikPSa2o oodu7K2KDX042UmeVfnunfVwt3rsVQg= X-Received: by 2002:a05:622a:20d:b0:2e0:155:74c7 with SMTP id b13-20020a05622a020d00b002e0015574c7mr7809177qtx.255.1646082820584; Mon, 28 Feb 2022 13:13:40 -0800 (PST) Received: from localhost.localdomain (96-85-112-126-static.hfc.comcastbusiness.net. [96.85.112.126]) by smtp.gmail.com with ESMTPSA id s19-20020ac85cd3000000b002de4e165ae0sm7772218qta.75.2022.02.28.13.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 13:13:40 -0800 (PST) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Feb 2022 16:12:31 -0500 Message-Id: <20220228211232.4152-4-leo.izen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228211232.4152-1-leo.izen@gmail.com> References: <20220228211232.4152-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v6 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: XZKEC49+lT03 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 | 26 ++++++++++++++++++++++++++ libavformat/img2enc.c | 6 +++--- libavformat/mov.c | 1 + libavformat/version.h | 4 ++-- 6 files changed, 34 insertions(+), 5 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 8608252d83..33818e256a 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -30,6 +30,9 @@ #include "libavutil/parseutils.h" #include "libavutil/intreadwrite.h" #include "libavcodec/gif.h" +#if CONFIG_JPEGXL_PARSER +#include "libavcodec/jpegxl.h" +#endif /* CONFIG_JPEGXL_PARSER */ #include "avformat.h" #include "avio_internal.h" #include "internal.h" @@ -834,6 +837,26 @@ static int jpegls_probe(const AVProbeData *p) return 0; } +#if CONFIG_JPEGXL_PARSER +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; +} +#endif /* CONFIG_JPEGXL_PARSER */ + + static int pcx_probe(const AVProbeData *p) { const uint8_t *b = p->buf; @@ -1163,6 +1186,9 @@ IMAGEAUTO_DEMUXER(gif, GIF) IMAGEAUTO_DEMUXER_EXT(j2k, JPEG2000, J2K) IMAGEAUTO_DEMUXER_EXT(jpeg, MJPEG, JPEG) IMAGEAUTO_DEMUXER(jpegls, JPEGLS) +#if CONFIG_JPEGXL_PARSER +IMAGEAUTO_DEMUXER(jpegxl, JPEGXL) +#endif /* CONFIG_JPEGXL_PARSER */ IMAGEAUTO_DEMUXER(pam, PAM) IMAGEAUTO_DEMUXER(pbm, PBM) IMAGEAUTO_DEMUXER(pcx, 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 5e26267810..dbe6c85105 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7435,6 +7435,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 26234573b8..0f89af47e6 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // 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_MICRO 102 +#define LIBAVFORMAT_VERSION_MINOR 18 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \