FFmpeg
Loading...
Searching...
No Matches
ahx_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 * AHX audio parser
22 *
23 * Splits packets into individual blocks.
24 */
25
27#include "parser.h"
28#include "parser_internal.h"
29
30typedef struct AHXParseContext {
32 uint32_t header;
33 int size;
35
37 AVCodecContext *avctx,
38 const uint8_t **poutbuf, int *poutbuf_size,
39 const uint8_t *buf, int buf_size)
40{
42 ParseContext *pc = &s->pc;
43 uint32_t state = pc->state;
44 int next = END_NOT_FOUND;
45
46 for (int i = 0; i < buf_size; i++) {
47 state = (state << 8) | buf[i];
48 s->size++;
49 if (s->size == 4 && !s->header)
50 s->header = state;
51 if (s->size > 4 && state == s->header) {
52 next = i - 3;
53 s->size = 0;
54 break;
55 }
56 }
57 pc->state = state;
58
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 s1->duration = 1152;
66 s1->key_frame = 1;
67
68 *poutbuf = buf;
69 *poutbuf_size = buf_size;
70
71 return next;
72}
73
76 .priv_data_size = sizeof(AHXParseContext),
79};
static int ahx_parse(AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition ahx_parser.c:36
const FFCodecParser ff_ahx_parser
Definition ahx_parser.c:74
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 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_AHX
Definition codec_id.h:561
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(...)
ParseContext pc
Definition ahx_parser.c:31
uint32_t header
Definition ahx_parser.c:32
main external API structure.
Definition avcodec.h:443
int duration
Duration of the current frame.
Definition avcodec.h:2731
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
Definition avcodec.h:2666
uint32_t state
contains the last few bytes in MSB order
Definition parser.h:33