| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (C) 2017 foo86 | ||
| 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 "libavutil/channel_layout.h" | ||
| 22 | #include "avcodec.h" | ||
| 23 | #include "dolby_e.h" | ||
| 24 | #include "parser_internal.h" | ||
| 25 | |||
| 26 | typedef struct DBEParseContext { | ||
| 27 | DBEContext dectx; | ||
| 28 | } DBEParseContext; | ||
| 29 | |||
| 30 | 385 | static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx, | |
| 31 | const uint8_t **poutbuf, int *poutbuf_size, | ||
| 32 | const uint8_t *buf, int buf_size) | ||
| 33 | { | ||
| 34 | 385 | DBEParseContext *s1 = s2->priv_data; | |
| 35 | 385 | DBEContext *s = &s1->dectx; | |
| 36 | int ret; | ||
| 37 | |||
| 38 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 384 times.
|
385 | if ((ret = ff_dolby_e_parse_header(s, buf, buf_size)) < 0) |
| 39 | 1 | goto end; | |
| 40 | |||
| 41 | 384 | s2->duration = FRAME_SAMPLES; | |
| 42 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
384 | switch (s->metadata.nb_channels) { |
| 43 | ✗ | case 4: | |
| 44 | ✗ | avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0; | |
| 45 | ✗ | break; | |
| 46 | 384 | case 6: | |
| 47 | 384 | avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1; | |
| 48 | 384 | break; | |
| 49 | ✗ | case 8: | |
| 50 | ✗ | avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1; | |
| 51 | ✗ | break; | |
| 52 | ✗ | default: | |
| 53 | ✗ | avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; | |
| 54 | ✗ | avctx->ch_layout.nb_channels = s->metadata.nb_channels; | |
| 55 | ✗ | break; | |
| 56 | } | ||
| 57 | |||
| 58 | 384 | avctx->sample_rate = s->metadata.sample_rate; | |
| 59 | 384 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; | |
| 60 | |||
| 61 | 385 | end: | |
| 62 | /* always return the full packet. this parser isn't doing any splitting or | ||
| 63 | combining, only packet analysis */ | ||
| 64 | 385 | *poutbuf = buf; | |
| 65 | 385 | *poutbuf_size = buf_size; | |
| 66 | 385 | return buf_size; | |
| 67 | } | ||
| 68 | |||
| 69 | const FFCodecParser ff_dolby_e_parser = { | ||
| 70 | PARSER_CODEC_LIST(AV_CODEC_ID_DOLBY_E), | ||
| 71 | .priv_data_size = sizeof(DBEParseContext), | ||
| 72 | .parse = dolby_e_parse, | ||
| 73 | }; | ||
| 74 |