FFmpeg
Loading...
Searching...
No Matches
misc4_parser.c
Go to the documentation of this file.
1/*
2 * Micronas SC-4 parser
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "parser.h"
22#include "parser_internal.h"
23
24typedef struct MISC4Context {
27
29 const uint8_t **poutbuf, int *poutbuf_size,
30 const uint8_t *buf, int buf_size)
31{
32 MISC4Context *ctx = s->priv_data;
33 uint32_t state = ctx->pc.state;
34 int next = END_NOT_FOUND, i = 0;
35
36 *poutbuf_size = 0;
37 *poutbuf = NULL;
38
39 if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
40 next = buf_size;
41 } else {
42 uint32_t marker = 0;
43
44 switch (avctx->sample_rate) {
45 case 8000:
46 case 11025:
47 marker = 0x11b;
48 break;
49 case 16000:
50 case 32000:
51 marker = 0x2b2;
52 break;
53 }
54
55 for (; i < buf_size; i++) {
56 state = (state << 8) | buf[i];
57 if (state == marker && i > 3) {
58 next = i - 3;
59 break;
60 }
61 }
62
63 ctx->pc.state = state;
64 if (ff_combine_frame(&ctx->pc, next, &buf, &buf_size) < 0) {
65 *poutbuf = NULL;
66 *poutbuf_size = 0;
67 return buf_size;
68 }
69 }
70
71 *poutbuf = buf;
72 *poutbuf_size = buf_size;
73
74 return next;
75}
76
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 PARSER_FLAG_COMPLETE_FRAMES
Definition avcodec.h:2651
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
static struct @346255127015250356166251341105367306144006377143 state
@ AV_CODEC_ID_MISC4
Definition codec_id.h:551
static int misc4_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
const FFCodecParser ff_misc4_parser
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(...)
main external API structure.
Definition avcodec.h:443
int sample_rate
samples per second
Definition avcodec.h:1040
ParseContext pc
static AVFormatContext * ctx
Definition movenc.c:49