From patchwork Tue Dec 18 20:05:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 11464 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9BE4C44C4D4 for ; Tue, 18 Dec 2018 22:05:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C066868AB7D; Tue, 18 Dec 2018 22:05:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D074468A94F for ; Tue, 18 Dec 2018 22:05:52 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id v13so17194507wrw.5 for ; Tue, 18 Dec 2018 12:05:54 -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=MrAKszUkfQ3GQE+aw+1XDlwc1hQ25mRlJ5jQCDn4fz0=; b=Nu3ILsge+NYVoDQ50GWAC+NBClHvO26lIwxkR2NQ4weZk2aKcF904sJtv3tFDYlwhg nY0tTjFtje+x5Ujc/yw1hSmnZ7a3SALGunuWB4IJ/Ib9P6Yk5KRjHiNRUicLh5pVO1O0 Vx1HKoTKJEO3USn0UwwCZfLj4PuPUKYwcypXgLO2c54Umj3IPO+zw+0vG1YNx03iws5K 2QGfFvoVu4kHMET5dsXCG6Pur3tvFHmDylk5SHB0STr9a6jk5JkCEXm5zoyXxxKHO+/7 Btbv7txUKKl8zhmtwFdqg0LR++ZDCmypf5hkYIv4Dj8L/9KbVERu2lpnEmAzmuAoytiX aMbw== 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=MrAKszUkfQ3GQE+aw+1XDlwc1hQ25mRlJ5jQCDn4fz0=; b=dNzfjt4Wf3UwYbl9FVXr2chB0PGs2/yvqNrL1dh3t/LD1v0SKEF0xlizYcjlEj25Br aZtJh1cdOakInovOOe6nWZvUAXTB/jUegcOyFsq46G+xdDHhsYSzDt11Lbkj/Ksg3lgR 0Sqp8lLTAgUIRW7B8sr5Jls4G65zFV1r6f8pet2E3h56dW10XzCzvnXxBlJE4Kl2/Fyc BQOad184D7ckubDFk2i59nYU6lYrF5XP3zGwEza85WTMHpkN1LVAUS6Dvc06yXofXZvZ qmzpqwOsXVxS/UGKZhGNiX5lgzGAVBJnX2SXeGZtQXxgwLIEOlSoAOEjx7x+3kEheRHS f2vA== X-Gm-Message-State: AA+aEWYZgIeuDImAi081dq74CeaGVpO8EKjYxXaAy32Qov3uZFgpeim0 6gy9uTzI28e+ZyndWvDUyl1tI1cP X-Google-Smtp-Source: AFSGD/UX24uXiOT1TwS2wp0vU2JSMS8AgiHJu7j/MQ+VE59c86uJtGz4kZXAhgJsRGZ/3sE6JX0Oyg== X-Received: by 2002:a5d:6710:: with SMTP id o16mr16347389wru.152.1545163554090; Tue, 18 Dec 2018 12:05:54 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id 62sm4097228wra.30.2018.12.18.12.05.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 12:05:53 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Dec 2018 21:05:45 +0100 Message-Id: <20181218200545.5028-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec: add g732_1 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/g723_1_parser.c | 60 ++++++++++++++++++++++++++++++++++++++ libavcodec/parsers.c | 1 + libavcodec/utils.c | 2 -- 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 libavcodec/g723_1_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index d53b8ff330..08f89ae0b2 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1025,6 +1025,7 @@ OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o \ vorbis_data.o +OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o OBJS-$(CONFIG_G729_PARSER) += g729_parser.o OBJS-$(CONFIG_GIF_PARSER) += gif_parser.o OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o diff --git a/libavcodec/g723_1_parser.c b/libavcodec/g723_1_parser.c new file mode 100644 index 0000000000..0305ca329d --- /dev/null +++ b/libavcodec/g723_1_parser.c @@ -0,0 +1,60 @@ +/* + * 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 + * G723_1 audio parser + */ + +#include "parser.h" +#include "g723_1.h" + +typedef struct G723_1ParseContext { + ParseContext pc; +} G723_1ParseContext; + +static int g723_1_parse(AVCodecParserContext *s1, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + G723_1ParseContext *s = s1->priv_data; + ParseContext *pc = &s->pc; + int next = END_NOT_FOUND; + + if (buf_size > 0) + next = frame_size[buf[0] & 3] * FFMAX(1, avctx->channels); + + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } + + s1->duration = 240; + + *poutbuf = buf; + *poutbuf_size = buf_size; + return next; +} + +AVCodecParser ff_g723_1_parser = { + .codec_ids = { AV_CODEC_ID_G723_1 }, + .priv_data_size = sizeof(G723_1ParseContext), + .parser_parse = g723_1_parse, + .parser_close = ff_parse_close, +}; diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index eca95787ae..33a71de8a0 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -40,6 +40,7 @@ extern AVCodecParser ff_dvbsub_parser; extern AVCodecParser ff_dvdsub_parser; extern AVCodecParser ff_dvd_nav_parser; extern AVCodecParser ff_flac_parser; +extern AVCodecParser ff_g723_1_parser; extern AVCodecParser ff_g729_parser; extern AVCodecParser ff_gif_parser; extern AVCodecParser ff_gsm_parser; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 2fa811d499..d519b16092 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1599,8 +1599,6 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, return 256 * (frame_bytes / 64); if (id == AV_CODEC_ID_RA_144) return 160 * (frame_bytes / 20); - if (id == AV_CODEC_ID_G723_1) - return 240 * (frame_bytes / 24); if (bps > 0) { /* calc from frame_bytes and bits_per_coded_sample */