From patchwork Mon Nov 21 20:44:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Vignali X-Patchwork-Id: 1519 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1832367vsb; Mon, 21 Nov 2016 12:45:08 -0800 (PST) X-Received: by 10.28.199.143 with SMTP id x137mr3293822wmf.0.1479761108542; Mon, 21 Nov 2016 12:45:08 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k1si21959558wjn.263.2016.11.21.12.45.07; Mon, 21 Nov 2016 12:45:08 -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; 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 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 20496689D31; Mon, 21 Nov 2016 22:45:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9DABB689CDD for ; Mon, 21 Nov 2016 22:44:55 +0200 (EET) Received: by mail-oi0-f53.google.com with SMTP id w63so31996376oiw.0 for ; Mon, 21 Nov 2016 12:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=ubdGvtmD1wvCpyFKelh867bnKshMt2vEM8tK6sqoB7c=; b=YUYGxhJP6FmoPI4xL11aBUriZmbkZF3G5GqALU7rPPBKo553z2UsQ7ik9CNAKGoLyB +qIha1kzOhcCZH8POQ48VEnNY/DwBjpTCaD/4mbJhG0cYnJYr6eVNNdJ0MpmGbTxWxcC lrWkEdQJM6pb6LFCQgIvomZvwOs1K1dvcq2umTmBEVQHAu7xEzNNELW7NNkpnuMBno3L V3z/D5jca3fn4untZjGUd7bY/09RVVgVrdI4sN8qAwxZifLhPEVseCq0ABJnH8hReSE4 VZ8qm1nK/8NnzZ2xWxFRIlONYvqnQuWfl0DioZVbFaD0aTcYmw0WAnd4mBS+5YzQ2dcu yapA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ubdGvtmD1wvCpyFKelh867bnKshMt2vEM8tK6sqoB7c=; b=igmy2VFeLwgrVo0Sp/AS9URY4KmjM8mQoaibdaDlfasZ1NlIPxAgAepqyV2oCMK2gQ 4pXDAAfcbnTL49iZOHTdWpsGyVOp6JwE5p+b5LwE0ruMpbFlOcnabxAK447Vzt7bbHcC tAf763Iu3mkJuySqY7HjVBF2CCc4O4L4UkXopYymPDo/i5ji0+zBcgPDolCN4q+C2Svt NmyZ86Pj84FBACzxFpkiq++Ixyag1cFxnklAViSaqtabBldZueMJPkZD4awnlqZZOGQC SpyG/P/xWX71QsfqAAorHTjkHOiMwu4oXC/XVYBcysWyu3WPWkb2zB1I1UUrOLrMOpWp KriA== X-Gm-Message-State: AKaTC01P1nBHM/d30gxrjGBxhS84xfVZ6us9TTEsFjYMWsdD0SOzBK1C2OpBv6VgvqLITEFlRwF82cSLRBwbpA== X-Received: by 10.157.2.72 with SMTP id 66mr9975888otb.118.1479761096491; Mon, 21 Nov 2016 12:44:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.202.196.141 with HTTP; Mon, 21 Nov 2016 12:44:55 -0800 (PST) In-Reply-To: References: <20160723180734.GA4887@nb4> <20160725004647.GV4887@nb4> <20160802112826.GP5460@nb4> <20160805102546.GU5460@nb4> <20160807001755.GK5460@nb4> From: Martin Vignali Date: Mon, 21 Nov 2016 21:44:55 +0100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] libavcodec : add psd image file decoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hello, New patchs in attach. Correction have been made followings comments from Andreas and Carl. @Rotislav : thanks for your answer. Martin From df98013ba80689fdd6f9f8074b23b64c915a1f2c Mon Sep 17 00:00:00 2001 From: Martin Vignali Date: Mon, 21 Nov 2016 21:39:23 +0100 Subject: [PATCH 2/2] libavformat : add Photoshop PSD demuxer. --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/img2dec.c | 32 ++++++++++++++++++++++++++++++++ libavformat/version.h | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index f93658d..f803d04 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -235,6 +235,7 @@ OBJS-$(CONFIG_IMAGE_PGM_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PICTOR_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PNG_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += img2dec.o img2.o +OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 6a216ef..9d77b9c 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -366,6 +366,7 @@ void av_register_all(void) REGISTER_DEMUXER (IMAGE_PICTOR_PIPE, image_pictor_pipe); REGISTER_DEMUXER (IMAGE_PNG_PIPE, image_png_pipe); REGISTER_DEMUXER (IMAGE_PPM_PIPE, image_ppm_pipe); + REGISTER_DEMUXER (IMAGE_PSD_PIPE, image_psd_pipe); REGISTER_DEMUXER (IMAGE_QDRAW_PIPE, image_qdraw_pipe); REGISTER_DEMUXER (IMAGE_SGI_PIPE, image_sgi_pipe); REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE, image_sunrast_pipe); diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index a920f46..f1a0e7f 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -822,6 +822,37 @@ static int png_probe(AVProbeData *p) return 0; } +static int psd_probe(AVProbeData *p) +{ + const uint8_t *b = p->buf; + int ret = 0; + uint16_t color_mode; + + if (AV_RL32(b) == MKTAG('8','B','P','S')) { + ret += 1; + } else { + return 0; + } + + if ((b[4] == 0) && (b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */ + ret += 1; + } else { + return 0; + } + + if ((AV_RL32(b+6) == 0) && (AV_RL16(b+10) == 0))/* reserved must be 0 */ + ret += 1; + + color_mode = AV_RB16(b+24); + if ((color_mode <= 9) && (color_mode != 5) && (color_mode != 6)) + ret += 1; + + if (ret) + return AVPROBE_SCORE_EXTENSION + ret; + + return 0; +} + static int sgi_probe(AVProbeData *p) { const uint8_t *b = p->buf; @@ -947,6 +978,7 @@ IMAGEAUTO_DEMUXER(pgmyuv, AV_CODEC_ID_PGMYUV) IMAGEAUTO_DEMUXER(pictor, AV_CODEC_ID_PICTOR) IMAGEAUTO_DEMUXER(png, AV_CODEC_ID_PNG) IMAGEAUTO_DEMUXER(ppm, AV_CODEC_ID_PPM) +IMAGEAUTO_DEMUXER(psd, AV_CODEC_ID_PSD) IMAGEAUTO_DEMUXER(qdraw, AV_CODEC_ID_QDRAW) IMAGEAUTO_DEMUXER(sgi, AV_CODEC_ID_SGI) IMAGEAUTO_DEMUXER(sunrast, AV_CODEC_ID_SUNRAST) diff --git a/libavformat/version.h b/libavformat/version.h index 24a7534..192b790 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 57 -#define LIBAVFORMAT_VERSION_MINOR 58 +#define LIBAVFORMAT_VERSION_MINOR 59 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 1.9.3 (Apple Git-50)