| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 26 | #include "libavutil/intreadwrite.h" | ||
| 27 | #include "parser.h" | ||
| 28 | #include "parser_internal.h" | ||
| 29 | |||
| 30 | typedef struct AHXParseContext { | ||
| 31 | ParseContext pc; | ||
| 32 | uint32_t header; | ||
| 33 | int size; | ||
| 34 | } AHXParseContext; | ||
| 35 | |||
| 36 | ✗ | static int ahx_parse(AVCodecParserContext *s1, | |
| 37 | AVCodecContext *avctx, | ||
| 38 | const uint8_t **poutbuf, int *poutbuf_size, | ||
| 39 | const uint8_t *buf, int buf_size) | ||
| 40 | { | ||
| 41 | ✗ | AHXParseContext *s = s1->priv_data; | |
| 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 | |||
| 74 | const FFCodecParser ff_ahx_parser = { | ||
| 75 | PARSER_CODEC_LIST(AV_CODEC_ID_AHX), | ||
| 76 | .priv_data_size = sizeof(AHXParseContext), | ||
| 77 | .parse = ahx_parse, | ||
| 78 | .close = ff_parse_close, | ||
| 79 | }; | ||
| 80 |