FFmpeg
dcadec.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 #ifndef AVCODEC_DCADEC_H
22 #define AVCODEC_DCADEC_H
23 
24 #include <stdint.h>
25 
26 #include "libavutil/crc.h"
27 #include "libavutil/float_dsp.h"
28 #include "libavutil/log.h"
29 
30 #include "avcodec.h"
31 #include "get_bits.h"
32 #include "dca.h"
33 #include "dcadsp.h"
34 #include "dca_core.h"
35 #include "dca_exss.h"
36 #include "dca_xll.h"
37 #include "dca_lbr.h"
38 
39 #define DCA_PACKET_CORE 0x01
40 #define DCA_PACKET_EXSS 0x02
41 #define DCA_PACKET_XLL 0x04
42 #define DCA_PACKET_LBR 0x08
43 #define DCA_PACKET_MASK 0x0f
44 
45 #define DCA_PACKET_RECOVERY 0x10 ///< Sync error recovery flag
46 #define DCA_PACKET_RESIDUAL 0x20 ///< Core valid for residual decoding
47 
51 };
52 
53 typedef struct DCAContext {
54  const AVClass *class; ///< class for AVOptions
56 
57  DCACoreDecoder core; ///< Core decoder context
58  DCAExssParser exss; ///< EXSS parser context
59  DCAXllDecoder xll; ///< XLL decoder context
60  DCALbrDecoder lbr; ///< LBR decoder context
61 
63 
64  const AVCRC *crctab;
65 
66  uint8_t *buffer; ///< Packet buffer
67  unsigned int buffer_size;
68 
69  int packet; ///< Packet flags
70 
71  int request_channel_layout; ///< Converted from avctx.request_channel_layout
72  int core_only; ///< Core only decoding flag
75 } DCAContext;
76 
77 int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask);
78 
80  int *coeff_l, int nsamples, int ch_mask);
82  int *coeff_l, int nsamples, int ch_mask);
84  enum DCADownMixType downmix_type,
85  int output_mask, const int *coeff_l);
86 
87 static inline int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s,
88  int p1, int p2)
89 {
90  DCAContext *dca = avctx->priv_data;
91 
92  if (!(avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)))
93  return 0;
94  if (((p1 | p2) & 7) || p1 < 0 || p2 > s->size_in_bits || p2 - p1 < 16)
95  return -1;
96  if (av_crc(dca->crctab, 0xffff, s->buffer + p1 / 8, (p2 - p1) / 8))
97  return -1;
98  return 0;
99 }
100 
101 static inline int ff_dca_seek_bits(GetBitContext *s, int p)
102 {
103  if (p < get_bits_count(s) || p > s->size_in_bits)
104  return -1;
106  return 0;
107 }
108 
109 #endif
skip_bits_long
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:280
AV_EF_CAREFUL
#define AV_EF_CAREFUL
consider things that violate the spec, are fast to calculate and have not been seen in the wild as er...
Definition: defs.h:54
DCAContext::output_channel_order
int output_channel_order
Definition: dcadec.h:73
CHANNEL_ORDER_CODED
@ CHANNEL_ORDER_CODED
Definition: dcadec.h:50
DCAContext::crctab
const AVCRC * crctab
Definition: dcadec.h:64
dca.h
AVCRC
uint32_t AVCRC
Definition: crc.h:46
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1416
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:254
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:472
DCAContext::request_channel_layout
int request_channel_layout
Converted from avctx.request_channel_layout.
Definition: dcadec.h:71
DCAExssParser
Definition: dca_exss.h:71
ff_dca_seek_bits
static int ff_dca_seek_bits(GetBitContext *s, int p)
Definition: dcadec.h:101
ff_dca_check_crc
static int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s, int p1, int p2)
Definition: dcadec.h:87
crc.h
DCAContext::core_only
int core_only
Core only decoding flag.
Definition: dcadec.h:72
GetBitContext
Definition: get_bits.h:109
dca_core.h
DCACoreDecoder
Definition: dca_core.h:99
DCAContext::lbr
DCALbrDecoder lbr
LBR decoder context.
Definition: dcadec.h:60
DCAContext::exss
DCAExssParser exss
EXSS parser context.
Definition: dcadec.h:58
DCAContext::dcadsp
DCADSPContext dcadsp
Definition: dcadec.h:62
DCAContext::packet
int packet
Packet flags.
Definition: dcadec.h:69
DCAContext::buffer
uint8_t * buffer
Packet buffer.
Definition: dcadec.h:66
get_bits.h
dca_exss.h
DCALbrDecoder
Definition: dca_lbr.h:56
ff_dca_downmix_to_stereo_fixed
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
Definition: dcadec.c:97
DCAContext::avctx
AVCodecContext * avctx
Definition: dcadec.h:55
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
ff_dca_export_downmix_matrix
int ff_dca_export_downmix_matrix(AVCodecContext *avctx, AVFrame *frame, enum DCADownMixType downmix_type, int output_mask, const int *coeff_l)
Definition: dcadec.c:162
DCAContext::xll
DCAXllDecoder xll
XLL decoder context.
Definition: dcadec.h:59
AV_EF_CRCCHECK
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
Definition: defs.h:48
ff_dca_set_channel_layout
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
Definition: dcadec.c:48
DCADSPContext
Definition: dcadsp.h:30
CHANNEL_ORDER_DEFAULT
@ CHANNEL_ORDER_DEFAULT
Definition: dcadec.h:49
float_dsp.h
DCAContext::downmix_layout
AVChannelLayout downmix_layout
Definition: dcadec.h:74
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
AVFloatDSPContext
Definition: float_dsp.h:24
DCADownMixType
DCADownMixType
Definition: dca.h:185
dcadsp.h
DCAContext
Definition: dcadec.h:53
log.h
s
uint8_t s
Definition: llvidencdsp.c:39
avcodec.h
DCAXllDecoder
Definition: dca_xll.h:103
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
DCAOutputChannelOrder
DCAOutputChannelOrder
Definition: dcadec.h:48
AVCodecContext
main external API structure.
Definition: avcodec.h:443
dca_xll.h
av_crc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:421
DCAContext::buffer_size
unsigned int buffer_size
Definition: dcadec.h:67
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:470
int32_t
int32_t
Definition: audioconvert.c:56
DCAContext::core
DCACoreDecoder core
Core decoder context.
Definition: dcadec.h:57
dca_lbr.h
ff_dca_downmix_to_stereo_float
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
Definition: dcadec.c:128