Line |
Branch |
Exec |
Source |
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 |
|
|
|
23 |
|
|
typedef struct MISC4Context { |
24 |
|
|
ParseContext pc; |
25 |
|
|
} MISC4Context; |
26 |
|
|
|
27 |
|
✗ |
static int misc4_parse(AVCodecParserContext *s, AVCodecContext *avctx, |
28 |
|
|
const uint8_t **poutbuf, int *poutbuf_size, |
29 |
|
|
const uint8_t *buf, int buf_size) |
30 |
|
|
{ |
31 |
|
✗ |
MISC4Context *ctx = s->priv_data; |
32 |
|
✗ |
uint32_t state = ctx->pc.state; |
33 |
|
✗ |
int next = END_NOT_FOUND, i = 0; |
34 |
|
|
|
35 |
|
✗ |
*poutbuf_size = 0; |
36 |
|
✗ |
*poutbuf = NULL; |
37 |
|
|
|
38 |
|
✗ |
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { |
39 |
|
✗ |
next = buf_size; |
40 |
|
|
} else { |
41 |
|
✗ |
uint32_t marker = 0; |
42 |
|
|
|
43 |
|
✗ |
switch (avctx->sample_rate) { |
44 |
|
✗ |
case 8000: |
45 |
|
|
case 11025: |
46 |
|
✗ |
marker = 0x11b; |
47 |
|
✗ |
break; |
48 |
|
✗ |
case 16000: |
49 |
|
|
case 32000: |
50 |
|
✗ |
marker = 0x2b2; |
51 |
|
✗ |
break; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
✗ |
for (; i < buf_size; i++) { |
55 |
|
✗ |
state = (state << 8) | buf[i]; |
56 |
|
✗ |
if (state == marker && i > 3) { |
57 |
|
✗ |
next = i - 3; |
58 |
|
✗ |
break; |
59 |
|
|
} |
60 |
|
|
} |
61 |
|
|
|
62 |
|
✗ |
ctx->pc.state = state; |
63 |
|
✗ |
if (ff_combine_frame(&ctx->pc, next, &buf, &buf_size) < 0) { |
64 |
|
✗ |
*poutbuf = NULL; |
65 |
|
✗ |
*poutbuf_size = 0; |
66 |
|
✗ |
return buf_size; |
67 |
|
|
} |
68 |
|
|
} |
69 |
|
|
|
70 |
|
✗ |
*poutbuf = buf; |
71 |
|
✗ |
*poutbuf_size = buf_size; |
72 |
|
|
|
73 |
|
✗ |
return next; |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
const AVCodecParser ff_misc4_parser = { |
77 |
|
|
.codec_ids = { AV_CODEC_ID_MISC4 }, |
78 |
|
|
.priv_data_size = sizeof(MISC4Context), |
79 |
|
|
.parser_parse = misc4_parse, |
80 |
|
|
.parser_close = ff_parse_close, |
81 |
|
|
}; |
82 |
|
|
|