From patchwork Thu Oct 13 14:41:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?St=C3=A5le_kristoffersen?= X-Patchwork-Id: 986 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp246672vsd; Thu, 13 Oct 2016 07:41:13 -0700 (PDT) X-Received: by 10.28.184.74 with SMTP id i71mr2428465wmf.49.1476369673043; Thu, 13 Oct 2016 07:41:13 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g10si18084071wje.143.2016.10.13.07.41.12; Thu, 13 Oct 2016 07:41:12 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE09B689BEA; Thu, 13 Oct 2016 17:41:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ext5.uio.no (mail-ext5.uio.no [129.240.10.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 75FB1687EE5 for ; Thu, 13 Oct 2016 17:41:02 +0300 (EEST) Received: from mail-mx2.uio.no ([129.240.10.30]) by mail-out5.uio.no with esmtp (Exim 4.80.1) (envelope-from ) id 1buhBu-00051D-NE for ffmpeg-devel@ffmpeg.org; Thu, 13 Oct 2016 16:41:02 +0200 Received: from putsch.kolbu.ws ([158.36.191.193]) by mail-mx2.uio.no with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.80) (envelope-from ) id 1buhBt-0007LF-El for ffmpeg-devel@ffmpeg.org; Thu, 13 Oct 2016 16:41:02 +0200 Received: from chiller by putsch.kolbu.ws with local (Exim 4.87 (FreeBSD)) (envelope-from ) id 1buhBs-000Of0-SX for ffmpeg-devel@ffmpeg.org; Thu, 13 Oct 2016 16:41:00 +0200 Date: Thu, 13 Oct 2016 16:41:00 +0200 From: =?utf-8?B?U3TDpWxl?= Kristoffersen To: FFmpeg development discussions and patches Message-ID: <20161013144100.GB75318@putsch.kolbu.ws> References: <20161011135233.GA99438@putsch.kolbu.ws> <20161011142712.GC4602@nb4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-UiO-SPF-Received: X-UiO-Ratelimit-Test: rcpts/h 1 msgs/h 1 sum rcpts/h 1 sum msgs/h 1 total rcpts 324 max rcpts/h 10 ratelimit 0 X-UiO-Spam-info: not spam, SpamAssassin (score=-5.0, required=5.0, autolearn=disabled, UIO_MAIL_IS_INTERNAL=-5, uiobl=NO, uiouri=NO) X-UiO-Scanned: 9D55CC3B2084D7C0A66E3B5E8D90DB866C301EC1 X-UiO-SPAM-Test: remote_host: 158.36.191.193 spam_score: -49 maxlevel 80 minaction 2 bait 0 mail/h: 5 total 35728 max/h 377 blacklist 0 greylist 0 ratelimit 0 Subject: Re: [FFmpeg-devel] [PATCH] libavf: Auto-detect mjpeg 2000 in mpeg-ts 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" On 2016-10-12 at 13:57, Carl Eugen Hoyos wrote: > 2016-10-11 16:27 GMT+02:00 Michael Niedermayer : > > > also the img2 demuxer for mjpeg2000 from img2dec.c does not work > > for this ? > > We separated the jpg from the mjpeg probe, jpg makes sure that the > sample starts like a jpg image and contains an end marker and can > be decoded, mjpeg probe is less strict but requires more than one > frame. > Same could be argued for j2k or was our reasoning bad? Since nobody chimed in on this, I have created two new patches, one containing a separate mjpeg 2000 probe (0001-libavf-Auto-detect-mjpeg-2000-in-mpeg-ts2.patch), and one that incorporates it into the img2dec jpeg 2000 probe (0001-libavf-Make-jpeg-2000-probe-work-for-mjpeg-2000.patch). I think it is best to have them separated, as that matches the mjpeg behaviour. From 8e6aa5935e33f1f8dd747ce4d9e785bd0dcc1e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A5le=20Kristoffersen?= Date: Thu, 13 Oct 2016 15:55:35 +0200 Subject: [PATCH] libavf: Make jpeg 2000 probe work for mjpeg 2000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it possible to decode motion jpeg 2000 encoded in a transport stream without a correct PMT/PAT. Signed-off-by: Ståle Kristoffersen --- libavformat/img2dec.c | 20 ++++++++++++++++++++ libavformat/utils.c | 1 + 2 files changed, 21 insertions(+) diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index a920f46..bb22302 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -678,10 +678,30 @@ static int exr_probe(AVProbeData *p) static int j2k_probe(AVProbeData *p) { const uint8_t *b = p->buf; + int i, marker, marker_size; + int frames = 0, invalid = 0; if (AV_RB64(b) == 0x0000000c6a502020 || AV_RB32(b) == 0xff4fff51) return AVPROBE_SCORE_EXTENSION + 1; + for (i = 0; i < p->buf_size - 5; i++) { + if (AV_RB32(b) == 0xff4fff51){ + marker_size = AV_RB16(b+4); + if (marker_size + i < p->buf_size - 4) { + marker = AV_RB8(b+4+marker_size); + if (marker == 0xff) + frames++; + else + invalid++; + } + } + b += 1; + } + if (invalid*4 + 1 < frames) { + if (invalid == 0 && frames > 2) + return AVPROBE_SCORE_EXTENSION / 2; + return AVPROBE_SCORE_EXTENSION / 4; + } return 0; } diff --git a/libavformat/utils.c b/libavformat/utils.c index 8a51aea..5070935 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -328,6 +328,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, { "hevc", AV_CODEC_ID_HEVC, AVMEDIA_TYPE_VIDEO }, { "loas", AV_CODEC_ID_AAC_LATM, AVMEDIA_TYPE_AUDIO }, { "m4v", AV_CODEC_ID_MPEG4, AVMEDIA_TYPE_VIDEO }, + { "j2k_pipe", AV_CODEC_ID_JPEG2000, AVMEDIA_TYPE_VIDEO }, { "mp3", AV_CODEC_ID_MP3, AVMEDIA_TYPE_AUDIO }, { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO }, { "truehd", AV_CODEC_ID_TRUEHD, AVMEDIA_TYPE_AUDIO }, -- 2.1.4