avformat/mpeg: demux ivtv captions
[ffmpeg.git] / libavcodec / dolby_e_parser.c
blobd2566e5446ff8fb8ba5d211c452dce7cb7d07e79
1 /*
2 * Copyright (C) 2017 foo86
4 * This file is part of FFmpeg.
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.
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.
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
21 #include "libavutil/channel_layout.h"
22 #include "avcodec.h"
23 #include "dolby_e.h"
25 typedef struct DBEParseContext {
26 DBEContext dectx;
27 } DBEParseContext;
29 static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx,
30 const uint8_t **poutbuf, int *poutbuf_size,
31 const uint8_t *buf, int buf_size)
33 DBEParseContext *s1 = s2->priv_data;
34 DBEContext *s = &s1->dectx;
35 int ret;
37 if ((ret = ff_dolby_e_parse_header(s, buf, buf_size)) < 0)
38 goto end;
40 s2->duration = FRAME_SAMPLES;
41 switch (s->metadata.nb_channels) {
42 case 4:
43 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0;
44 break;
45 case 6:
46 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1;
47 break;
48 case 8:
49 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1;
50 break;
51 default:
52 avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
53 avctx->ch_layout.nb_channels = s->metadata.nb_channels;
54 break;
57 avctx->sample_rate = s->metadata.sample_rate;
58 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
60 end:
61 /* always return the full packet. this parser isn't doing any splitting or
62 combining, only packet analysis */
63 *poutbuf = buf;
64 *poutbuf_size = buf_size;
65 return buf_size;
68 const AVCodecParser ff_dolby_e_parser = {
69 .codec_ids = { AV_CODEC_ID_DOLBY_E },
70 .priv_data_size = sizeof(DBEParseContext),
71 .parser_parse = dolby_e_parse,