2021-01-25 14:11:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 foo86
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2021-06-12 01:10:58 +02:00
|
|
|
#include "libavutil/channel_layout.h"
|
2021-05-21 18:19:39 +02:00
|
|
|
#include "avcodec.h"
|
2021-01-25 16:29:27 +02:00
|
|
|
#include "dolby_e.h"
|
2021-01-25 14:11:37 +02:00
|
|
|
#include "get_bits.h"
|
|
|
|
#include "put_bits.h"
|
|
|
|
|
2021-01-25 16:29:27 +02:00
|
|
|
typedef struct DBEParseContext {
|
|
|
|
DBEContext dectx;
|
|
|
|
} DBEParseContext;
|
2021-01-25 14:11:37 +02:00
|
|
|
|
|
|
|
static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx,
|
|
|
|
const uint8_t **poutbuf, int *poutbuf_size,
|
|
|
|
const uint8_t *buf, int buf_size)
|
|
|
|
{
|
|
|
|
DBEParseContext *s1 = s2->priv_data;
|
|
|
|
DBEContext *s = &s1->dectx;
|
|
|
|
int ret;
|
|
|
|
|
2021-01-26 16:46:15 +02:00
|
|
|
if ((ret = ff_dolby_e_parse_header(s, buf, buf_size)) < 0)
|
2021-01-25 14:11:37 +02:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
s2->duration = FRAME_SAMPLES;
|
2021-01-26 16:46:15 +02:00
|
|
|
switch (s->metadata.nb_channels) {
|
2021-01-25 14:11:37 +02:00
|
|
|
case 4:
|
2019-05-28 22:26:08 +02:00
|
|
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0;
|
2021-01-25 14:11:37 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2019-05-28 22:26:08 +02:00
|
|
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1;
|
2021-01-25 14:11:37 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
2019-05-28 22:26:08 +02:00
|
|
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
|
|
|
|
avctx->ch_layout.nb_channels = s->metadata.nb_channels;
|
2021-01-25 14:11:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-01-26 18:14:05 +02:00
|
|
|
avctx->sample_rate = s->metadata.sample_rate;
|
2021-01-25 14:11:37 +02:00
|
|
|
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
|
|
|
|
|
|
|
end:
|
|
|
|
/* always return the full packet. this parser isn't doing any splitting or
|
|
|
|
combining, only packet analysis */
|
|
|
|
*poutbuf = buf;
|
|
|
|
*poutbuf_size = buf_size;
|
|
|
|
return buf_size;
|
|
|
|
}
|
|
|
|
|
2021-03-07 01:20:43 +02:00
|
|
|
const AVCodecParser ff_dolby_e_parser = {
|
2021-01-25 14:11:37 +02:00
|
|
|
.codec_ids = { AV_CODEC_ID_DOLBY_E },
|
|
|
|
.priv_data_size = sizeof(DBEParseContext),
|
|
|
|
.parser_parse = dolby_e_parse,
|
|
|
|
};
|