FFmpeg
Loading...
Searching...
No Matches
g723_1_parser.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/**
20 * @file
21 * G723_1 audio parser
22 */
23
24#include "parser.h"
25#include "g723_1.h"
26#include "parser_internal.h"
27
31
33 const uint8_t **poutbuf, int *poutbuf_size,
34 const uint8_t *buf, int buf_size)
35{
37 ParseContext *pc = &s->pc;
38 int next = END_NOT_FOUND;
39
40 if (buf_size > 0)
41 next = frame_size[buf[0] & 3] * FFMAX(1, avctx->ch_layout.nb_channels);
42
43 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
44 *poutbuf = NULL;
45 *poutbuf_size = 0;
46 return buf_size;
47 }
48
49 s1->duration = 240;
50
51 *poutbuf = buf;
52 *poutbuf_size = buf_size;
53 return next;
54}
55
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition apv_parser.c:92
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
G.723.1 types, functions and data tables.
static const uint8_t frame_size[4]
Definition g723_1.h:222
const FFCodecParser ff_g723_1_parser
static int g723_1_parse(AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
@ AV_CODEC_ID_G723_1
Definition codec_id.h:505
#define FFMAX(a, b)
Definition macros.h:47
av_cold void ff_parse_close(AVCodecParserContext *s)
Definition parser.c:300
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
Definition parser.c:213
#define END_NOT_FOUND
Definition parser.h:40
#define PARSER_CODEC_LIST(...)
int nb_channels
Number of channels in this layout.
main external API structure.
Definition avcodec.h:443
AVChannelLayout ch_layout
Audio channel layout.
Definition avcodec.h:1055
int duration
Duration of the current frame.
Definition avcodec.h:2731