FFmpeg
dolby_e_parser.c
Go to the documentation of this file.
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 "dolby_e.h"
22 #include "get_bits.h"
23 #include "put_bits.h"
24 
25 typedef struct DBEParseContext {
28 
30  const uint8_t **poutbuf, int *poutbuf_size,
31  const uint8_t *buf, int buf_size)
32 {
34  DBEContext *s = &s1->dectx;
35  int ret;
36 
37  if ((ret = ff_dolby_e_parse_header(s, buf, buf_size)) < 0)
38  goto end;
39 
40  s2->duration = FRAME_SAMPLES;
41  switch (s->metadata.nb_channels) {
42  case 4:
44  break;
45  case 6:
47  break;
48  case 8:
50  break;
51  }
52 
53  avctx->channels = s->metadata.nb_channels;
54  avctx->sample_rate = s->metadata.sample_rate;
56 
57 end:
58  /* always return the full packet. this parser isn't doing any splitting or
59  combining, only packet analysis */
60  *poutbuf = buf;
61  *poutbuf_size = buf_size;
62  return buf_size;
63 }
64 
67  .priv_data_size = sizeof(DBEParseContext),
68  .parser_parse = dolby_e_parse,
69 };
float, planar
Definition: samplefmt.h:69
#define AV_CH_LAYOUT_7POINT1
Dolby E reading context used by decoder and parser.
Definition: dolby_e.h:70
int codec_ids[5]
Definition: avcodec.h:3545
#define AV_CH_LAYOUT_4POINT0
int duration
Duration of the current frame.
Definition: avcodec.h:3499
int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size)
Initialize DBEContext and parse Dolby E metadata.
Definition: dolby_e_parse.c:97
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1204
uint8_t
DolbyEHeaderInfo metadata
Definition: dolby_e.h:81
bitstream reader API header.
#define AV_CH_LAYOUT_5POINT1
static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
#define s2
Definition: regdef.h:39
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:1247
#define FRAME_SAMPLES
Definition: dolby_e.h:27
#define s(width, name)
Definition: cbs_vp9.c:257
DBEContext dectx
int sample_rate
samples per second
Definition: avcodec.h:1196
main external API structure.
Definition: avcodec.h:536
AVCodecParser ff_dolby_e_parser
#define s1
Definition: regdef.h:38
int channels
number of audio channels
Definition: avcodec.h:1197
bitstream writer API