[FFmpeg-devel] [PATCH] avcodec: add g732_1 parser

Paul B Mahol onemda at gmail.com
Sun Dec 23 12:38:15 EET 2018


On 12/19/18, Paul B Mahol <onemda at gmail.com> wrote:
> On 12/18/18, James Almer <jamrial at gmail.com> wrote:
>> On 12/18/2018 5:05 PM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>>> ---
>>>  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);
>>
>> Did you test this using a pipe from a raw container or anything that may
>> effectively require the parser to assemble a full frame?
>
> Yes I did.
>
>>
>> Also, the g723 demuxer seems to already propagate full frames using this
>> same check.
>
> This is not about that demuxer. This is mainly to properly fix
> duration of frames.
>

Will push ASAP.


More information about the ffmpeg-devel mailing list