From patchwork Thu Jan 19 20:05:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 2258 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp435872vsb; Thu, 19 Jan 2017 12:05:44 -0800 (PST) X-Received: by 10.223.161.130 with SMTP id u2mr10717912wru.127.1484856343971; Thu, 19 Jan 2017 12:05:43 -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 l66si248535wmb.111.2017.01.19.12.05.43; Thu, 19 Jan 2017 12:05:43 -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 sp=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 BDFFB68A4D3; Thu, 19 Jan 2017 22:05:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 88367689DEA for ; Thu, 19 Jan 2017 22:05:24 +0200 (EET) Received: by mail-wm0-f66.google.com with SMTP id r126so1493878wmr.3 for ; Thu, 19 Jan 2017 12:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=0OpHXy41d94XLO/htqPUsm58YSDsSbrBew/Y1umOzTU=; b=eJb3OdBW4Uu38vrFfMbeOZ5eFvd8h0gARlDvktQBJnf+BxSEb15Y9HjEjCqTVUER7C +AOx1F+xMN8gikjtfxAcXTmdc2oFr2YUXvXzJZBU3u2EOSZOaBn1ZTeUsDsHcrJB7bmD uqscoNUX2FVhIk84HJtPgh4Ixjh4QT54EuV+5QV88VLDfLzUDd9SpXMsP6A/DydyNM3G IZaLi6JZjlnV7Z3jhu5KvPGMHxI1kTTfZgWoc0KzG4fGh/Gn4zReuRnHUY8IZ/9L8RDp BJ4faeuzXLE4ifvUvDvCKKzcjZCNXC3jYOOseSE6CTVwTn4dEGvEkVw5+AUN5t0JqYuV abHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=0OpHXy41d94XLO/htqPUsm58YSDsSbrBew/Y1umOzTU=; b=N0HAK9EtHhyqaycnG7lpcPEkgVCwrikQmyTUp5DiuWtkWv3bXz7262ciPZ6zkyOTUn bsFzZ+dF12tERRd8I1FkmurE/2Py6higaVYEJ2cnw52kLThM1jvGstnueI8uzYn/FqgI Fc26WoBap2nMtS9HRoXZh59Db2LpY/hDRHIu5ufLfV7TP1wUzR3msw/Zm+xvxpcpjOFf HRH7/SysBqHQ6EKebh2Y30lMsufkmeKSTgqddhQh7xrz9xQLACd77EIoAbAPTgMiOFRS Ih+gTYnA0zIdJZmnJQOp5JfA+UGPYYHcrvTjYyucYl+CA0LvUvCBcT/PzS0grh7QRmMh ScNQ== X-Gm-Message-State: AIkVDXKJDVVpP/9c3A3O1Y5a2uVJRF5jcSJ2LI575yCAIZ9vXTzkYRE0ky7O7h6Avdw5cg== X-Received: by 10.28.91.19 with SMTP id p19mr240596wmb.49.1484856334961; Thu, 19 Jan 2017 12:05:34 -0800 (PST) Received: from localhost.localdomain ([109.227.48.244]) by smtp.gmail.com with ESMTPSA id c81sm483573wmf.22.2017.01.19.12.05.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 12:05:34 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Jan 2017 21:05:04 +0100 Message-Id: <20170119200506.7936-1-onemda@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec: add XMA2 parser 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/xma_parser.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 libavcodec/xma_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 01ffe07..43a6add 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -950,6 +950,7 @@ OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o +OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o # bitstream filters OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o aacadtsdec.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 703c552..f92b2b7 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -709,4 +709,5 @@ void avcodec_register_all(void) REGISTER_PARSER(VP3, vp3); REGISTER_PARSER(VP8, vp8); REGISTER_PARSER(VP9, vp9); + REGISTER_PARSER(XMA, xma); } diff --git a/libavcodec/xma_parser.c b/libavcodec/xma_parser.c new file mode 100644 index 0000000..0513679 --- /dev/null +++ b/libavcodec/xma_parser.c @@ -0,0 +1,62 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * XMA2 audio parser + */ + +#include "parser.h" + +typedef struct XMAParserContext{ + int skip_packets; +} XMAParserContext; + +static int xma_parse(AVCodecParserContext *s1, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + XMAParserContext *s = s1->priv_data; + + if (buf_size % 2048 == 0) { + int duration = 0, packet, nb_packets = buf_size / 2048; + + for (packet = 0; packet < nb_packets; packet++) { + if (s->skip_packets == 0) { + duration += buf[packet * 2048] * 128; + s->skip_packets = buf[packet * 2048 + 3] + 1; + } + s->skip_packets--; + } + + s1->duration = duration; + s1->key_frame = !!duration; + } + + /* always return the full packet. this parser isn't doing any splitting or + combining, only packet analysis */ + *poutbuf = buf; + *poutbuf_size = buf_size; + return buf_size; +} + +AVCodecParser ff_xma_parser = { + .codec_ids = { AV_CODEC_ID_XMA2 }, + .priv_data_size = sizeof(XMAParserContext), + .parser_parse = xma_parse, +};