From patchwork Tue Nov 1 23:23:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Gregan X-Patchwork-Id: 1255 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.71.4 with SMTP id u4csp863641vsa; Tue, 1 Nov 2016 16:23:34 -0700 (PDT) X-Received: by 10.28.63.6 with SMTP id m6mr47091wma.22.1478042614052; Tue, 01 Nov 2016 16:23:34 -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 fg2si4821109wjb.134.2016.11.01.16.23.33; Tue, 01 Nov 2016 16:23:34 -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; dkim=neutral (body hash did not verify) header.i=@flim.org; 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 12A26689962; Wed, 2 Nov 2016 01:23:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from flim.org (flim.org [65.99.223.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9CD3F68981B for ; Wed, 2 Nov 2016 01:23:21 +0200 (EET) Received: from localhost (unknown [121.98.48.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by flim.org (Postfix) with ESMTPSA id D655414190 for ; Tue, 1 Nov 2016 23:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flim.org; s=default; t=1478042603; bh=kL16H70Xz+14yJJB350iAhndzYGB0GxWXOl1nVJt3yw=; h=Date:From:To:Subject:References:In-Reply-To:From; b=CTHsfCcy1Tl80Ogv5m4L/UZo573dUA1ViHkF0royrVIv2BYcf6Fx4TjPguVZY+fWG Ub2RhYcKD0xoJMR4CVtxOoF5eMkT5cLotHuIqlE8OkhpVQI0oXEnrXmqdUAQegrSBQ eYWx8rmBKO+Gl2d8udh4WPXkEZTSKO1fKLwJxezw= Date: Wed, 2 Nov 2016 12:23:20 +1300 From: Matthew Gregan To: ffmpeg-devel@ffmpeg.org Message-ID: <20161101232320.GE8366@brak.lan> Mail-Followup-To: ffmpeg-devel@ffmpeg.org References: <82396c770b2569fa6b0398e311a58e5c6fa39fa3.1477894999.git.kinetik@flim.org> <152c24cd4b70afb52b5606cd6dfffc14d41f22e0.1477894999.git.kinetik@flim.org> <691e7215-46e1-c8f9-f30e-1f660e018804@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <691e7215-46e1-c8f9-f30e-1f660e018804@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [FFmpeg-devel] [PATCH 2/2] Add experimental demuxing support for FLAC in ISO BMFF (MP4). 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" At 2016-11-01T18:07:07-0300, James Almer wrote: > Just include libavcodec/flac.h which already defines it. > > With the above header you'll also be able to use the inline function > flac_parse_block_header() for this. See flac and matroska demuxers. > > INVALIDDATA errors would ideally also throw an error message. > > Use ff_get_extradata(), which combines these two into a single function. Thanks for the feedback. Updated patch attached with these addressed. From 7f08d03c7c73105098e3c398f10e5127b17eb368 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Fri, 21 Oct 2016 16:10:43 +1300 Subject: [PATCH 2/2] Add experimental demuxing support for FLAC in ISO BMFF (MP4). Based on the draft spec at https://git.xiph.org/?p=flac.git;a=blob;f=doc/isoflac.txt Signed-off-by: Matthew Gregan --- libavformat/mov.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 4222088..6f00f12 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -44,6 +44,7 @@ #include "libavutil/sha.h" #include "libavutil/timecode.h" #include "libavcodec/ac3tab.h" +#include "libavcodec/flac.h" #include "libavcodec/mpegaudiodecheader.h" #include "avformat.h" #include "internal.h" @@ -4684,6 +4685,43 @@ static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + AVStream *st; + int last, type, size, ret; + uint8_t buf[4]; + + if (c->fc->nb_streams < 1) + return 0; + st = c->fc->streams[c->fc->nb_streams-1]; + + if ((uint64_t)atom.size > (1<<30) || atom.size < 42) + return AVERROR_INVALIDDATA; + + /* Check FlacSpecificBox version. */ + if (avio_r8(pb) != 0) + return AVERROR_INVALIDDATA; + + avio_rb24(pb); /* Flags */ + + avio_read(pb, buf, sizeof(buf)); + flac_parse_block_header(buf, &last, &type, &size); + + if (type != FLAC_METADATA_TYPE_STREAMINFO || size != FLAC_STREAMINFO_SIZE) { + av_log(c->fc, AV_LOG_ERROR, "STREAMINFO must be first FLACMetadataBlock\n"); + return AVERROR_INVALIDDATA; + } + + ret = ff_get_extradata(c->fc, st->codecpar, pb, size); + if (ret < 0) + return ret; + + if (!last) + av_log(c->fc, AV_LOG_WARNING, "non-STREAMINFO FLACMetadataBlock(s) ignored\n"); + + return 0; +} + static int cenc_filter(MOVContext *c, MOVStreamContext *sc, uint8_t *input, int size) { uint32_t encrypted_bytes; @@ -4858,6 +4896,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('f','r','m','a'), mov_read_frma }, { MKTAG('s','e','n','c'), mov_read_senc }, { MKTAG('s','a','i','z'), mov_read_saiz }, +{ MKTAG('d','f','L','a'), mov_read_dfla }, { 0, NULL } }; -- 2.10.1