From patchwork Fri Aug 18 17:25:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 4744 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp1014927vsu; Fri, 18 Aug 2017 10:26:26 -0700 (PDT) X-Received: by 10.28.17.73 with SMTP id 70mr1783477wmr.44.1503077186039; Fri, 18 Aug 2017 10:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503077186; cv=none; d=google.com; s=arc-20160816; b=gzGAtYmN9IncXmIDutQwGSTgzsjxeajEFz7NJUzylXSh9uQc8ZJUsNT0c6ASlRIQ7i c9ZGbPgNut4jy0Zqhlb1jBBarbs3M4rqbvcS29U2G9fcH0tBB/sThCrfPbTUvxh2GDeB MRepMLHMgtTi7ntuHxkBE4+hPtPhBN+J02fVMG40dF/u/Gw8teJKNdIR+pgKtFzxa0Jz gHIBOiQcqPSUjMMinWzfMfw/DBaDXmPcsqlR3L7OlwgPHBTHVsnsLEAohd/K8RiYsJcY mXKa/VH7Quxbzkuws5p0h6+My+2lAJqgrfKF0r7tpmDpwGFbHgMl5YkiavriIu3z73zB WFqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=loHQvLsLp2U/BViuC3by7l/C7CxTO0DkdqOrQw04B2o=; b=gnkEhGUVPvj/jkd06K6N0h4KPJWSAD5zJGYTyRLfVjGpST3PTAOUKKzsgR7TfCmIUr YZNrZ3keeD8+WDW6OF3Dh/g0E4pGVuIwQZo+UP9WsC2JA7JGhEQhvA8rLN/8wgYGoIU4 o196nE3B3BNapZwBV+eMD+7lTFXqrjF+lu/Xw5kiYShjxgrLIASH1uq+UaNl4Tu1a5dK yr4PQ6GhJBQyslEYKtyrtkRrkbiwz86+p/dTD1H7olD2LJwS/8gdHSgY3vw/IP3AoRT3 4xovxQyTu25U0jSbY3FtRBF20XPgMvfkcW8ckp43zMUQJguFAsfG4Nw4Mv9xZoq9LqF+ gpmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=fRo50XmY; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y10si1492747wmd.19.2017.08.18.10.26.25; Fri, 18 Aug 2017 10:26:25 -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=@gmail.com header.s=20161025 header.b=fRo50XmY; 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 CBED06882B7; Fri, 18 Aug 2017 20:26:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk0-f51.google.com (mail-vk0-f51.google.com [209.85.213.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B334D680D34 for ; Fri, 18 Aug 2017 20:26:10 +0300 (EEST) Received: by mail-vk0-f51.google.com with SMTP id u133so34358733vke.3 for ; Fri, 18 Aug 2017 10:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=BLdQCFp+e9ASEjWu1LuNrxoOe4r9+xt8T1BtlaJqseI=; b=fRo50XmYF36B50ba6zUBzUmogtQGJY8hIoW29d38Aw5KBl9vdLM4QUpUkL/OwiRPlM GNYcpDVtUJ0C/PHe28BhwKpbx2TPY2IreTH6AGHeEMUG42ZJ0gVsZ6X1JlAfMEAGZtLw 6Cfyng091d46pZ56W96o8Lr6uTmCcsd0yD5k62yPaBVhtyZjkVwGX3FXJ0NXXYEoPafF xdcymhYNrk1a67LoOf523FOckWAT42LOPLEnTMMAPRf5rgVHvhkTGzsU1LArdIzas4Rp 1yE+Dq7k0nc4L4SJwREqvUf980g79xtt9xX1jy8tJrRoknMxnUW1XAcylwv1KG0IaUy6 xQoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BLdQCFp+e9ASEjWu1LuNrxoOe4r9+xt8T1BtlaJqseI=; b=YwLJny6tDFQedt7++6HG72+/gRZcGpENzxNM+ilJMmoC9yFtsI0k93YWlzV5eSvvqT HwMBHZH6KmkkuWdrAGFc25cU9FJFnlLHEivofKXMo7Ux6FBNgBRKp0cDQX3NOD3HZyj0 Gi5PD3bK3922mPgGAOUT7oxbQKXLgGsv43Fa9kpOKYcAp27TgLiRM0qAirM4eJ0zjUJp 6VI4KrpVNN8wWlcZlO5/AF6DTQLouQXGg+iGXPc1X0aUWuqk0ESsVtzDMLZoErQTs62C 8LhrLFZKCTt9NCOH8F53Na2Qc0ReC/B6j4fSnSwngx2TKfIBaeoFiYvIB/CWWTOf1cgi te9Q== X-Gm-Message-State: AHYfb5iL2t8pXEgG+YZVGBGhRXgSRmMWAwHiyFRzipjhq8YRViF0kzm1 EWFtLJePt7IyfkSgF4hpPu4hXe6VwA== X-Received: by 10.31.120.12 with SMTP id t12mr6188662vkc.29.1503077175044; Fri, 18 Aug 2017 10:26:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.55.141 with HTTP; Fri, 18 Aug 2017 10:25:54 -0700 (PDT) From: Carl Eugen Hoyos Date: Fri, 18 Aug 2017 19:25:54 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavf/g726: Add a raw little-endian G.726 demuxer 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" Hi! Attached patch allows to read files produced by the "ITU compatible binary G726 encoder" attached to ticket #6596. Please comment, Carl Eugen From a145fb0c3bade64d1aca40ea02a651f4e65ffb2f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 18 Aug 2017 19:10:56 +0200 Subject: [PATCH] lavf/g726: Demuxer for raw little-endian G.726 streams Compatible with the binary encoder attached to ticket #6596. --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/g726.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ libavformat/version.h | 2 +- 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 libavformat/g726.c diff --git a/libavformat/Makefile b/libavformat/Makefile index b0ef82c..5cc529b 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -188,6 +188,7 @@ OBJS-$(CONFIG_GSM_MUXER) += rawenc.o OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o OBJS-$(CONFIG_G722_DEMUXER) += g722.o rawdec.o +OBJS-$(CONFIG_G726LE_DEMUXER) += g726.o OBJS-$(CONFIG_G722_MUXER) += rawenc.o OBJS-$(CONFIG_G723_1_DEMUXER) += g723_1.o OBJS-$(CONFIG_G723_1_MUXER) += rawenc.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 1ebc142..5fce02a 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -132,6 +132,7 @@ static void register_all(void) REGISTER_DEMUXER (FRM, frm); REGISTER_DEMUXER (FSB, fsb); REGISTER_MUXDEMUX(G722, g722); + REGISTER_DEMUXER (G726LE, g726le); REGISTER_MUXDEMUX(G723_1, g723_1); REGISTER_DEMUXER (G729, g729); REGISTER_DEMUXER (GDV, gdv); diff --git a/libavformat/g726.c b/libavformat/g726.c new file mode 100644 index 0000000..7ee6313 --- /dev/null +++ b/libavformat/g726.c @@ -0,0 +1,82 @@ +/* + * G.726 raw demuxer + * Copyright 2017 Carl Eugen Hoyos + * + * 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 + */ + +#include "avformat.h" +#include "internal.h" +#include "libavutil/opt.h" + +typedef struct G726Context { + AVClass *class; + int code_size; + int sample_rate; +} G726Context; + +static int g726_read_header(AVFormatContext *s) +{ + G726Context *c = s->priv_data; + AVStream *st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = s->iformat->raw_codec_id; + + st->codecpar->sample_rate = c->sample_rate; + st->codecpar->bits_per_coded_sample = c->code_size; + st->codecpar->channels = 1; + + return 0; +} + +static int g726_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + int res; + res = av_get_packet(s->pb, pkt, 1020); // a size similar to RAW_PACKET_SIZE divisible by all code_size values + if (res < 0) + return res; + return 0; +} + +#define OFFSET(x) offsetof(G726Context, x) +static const AVOption options[] = { + { "code_size", "Bits per G.726 code", + OFFSET(code_size), AV_OPT_TYPE_INT, {.i64 = 4}, 2, 5, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", + OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 8000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass g726le_demuxer_class = { + .class_name = "G.726 little-endian demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_g726le_demuxer = { + .name = "g726le", + .long_name = NULL_IF_CONFIG_SMALL("raw little-endian G.726"), + .read_header = g726_read_header, + .read_packet = g726_read_packet, + .priv_data_size = sizeof(G726Context), + .priv_class = &g726le_demuxer_class, + .raw_codec_id = AV_CODEC_ID_ADPCM_G726LE, +}; diff --git a/libavformat/version.h b/libavformat/version.h index 48b81f2..a8cf4c1 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 76 +#define LIBAVFORMAT_VERSION_MINOR 77 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 1.7.10.4