FFmpeg
Loading...
Searching...
No Matches
sipr_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 * Sipr audio parser
22 */
23
24#include "parser.h"
25#include "parser_internal.h"
26
30
31static int sipr_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
32{
33 int next;
34
35 switch (avctx->block_align) {
36 case 20:
37 case 19:
38 case 29:
39 case 37: next = avctx->block_align; break;
40 default:
41 if (avctx->bit_rate > 12200) next = 20;
42 else if (avctx->bit_rate > 7500 ) next = 19;
43 else if (avctx->bit_rate > 5750 ) next = 29;
44 else next = 37;
45 }
46
47 return FFMIN(next, buf_size);
48}
49
51 const uint8_t **poutbuf, int *poutbuf_size,
52 const uint8_t *buf, int buf_size)
53{
55 ParseContext *pc = &s->pc;
56 int next;
57
58 next = sipr_split(avctx, buf, buf_size);
59 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
60 *poutbuf = NULL;
61 *poutbuf_size = 0;
62 return buf_size;
63 }
64
65 *poutbuf = buf;
66 *poutbuf_size = buf_size;
67 return next;
68}
69
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
@ AV_CODEC_ID_SIPR
Definition codec_id.h:494
#define FFMIN(a, b)
Definition macros.h:49
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 PARSER_CODEC_LIST(...)
const FFCodecParser ff_sipr_parser
Definition sipr_parser.c:70
static int sipr_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Definition sipr_parser.c:31
static int sipr_parse(AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition sipr_parser.c:50
main external API structure.
Definition avcodec.h:443
int64_t bit_rate
the average bitrate
Definition avcodec.h:493
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition avcodec.h:1075
ParseContext pc
Definition sipr_parser.c:28