32#define AES3_HEADER_LEN 4
62 bits = ((
h >> 4) & 0x0003) * 4 + 16;
101 int *got_frame_ptr,
AVPacket *avpkt)
104 const uint8_t *buf = avpkt->
data;
105 int buf_size = avpkt->
size;
108 int non_pcm_data_type = -1;
125 32 * 48000 /
frame->nb_samples;
129 uint32_t *o = (uint32_t *)
frame->data[0];
130 for (; buf_size > 6; buf_size -= 7) {
134 *o++ = ((unsigned)
ff_reverse[buf[6] & 0xf0] << 28) |
140 o = (uint32_t *)
frame->data[0];
142 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
143 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
145 if (o[
i+4] == 0x96F87200U && o[
i+5] == 0xA54E1F00) {
146 non_pcm_data_type = (o[
i+6] >> 16) & 0x1F;
151 uint32_t *o = (uint32_t *)
frame->data[0];
152 for (; buf_size > 5; buf_size -= 6) {
153 *o++ = ((unsigned)
ff_reverse[buf[2] & 0xf0] << 28) |
156 *o++ = ((unsigned)
ff_reverse[buf[5] & 0xf0] << 28) |
161 o = (uint32_t *)
frame->data[0];
163 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
164 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
166 if (o[
i+4] == 0x6F872000U && o[
i+5] == 0x54E1F000) {
167 non_pcm_data_type = (o[
i+6] >> 16) & 0x1F;
172 uint16_t *o = (uint16_t *)
frame->data[0];
173 for (; buf_size > 4; buf_size -= 5) {
181 o = (uint16_t *)
frame->data[0];
183 for (
i=0;
i<
frame->nb_samples * 2 - 6;
i+=2) {
184 if (o[
i] || o[
i+1] || o[
i+2] || o[
i+3])
186 if (o[
i+4] == 0xF872U && o[
i+5] == 0x4E1F) {
187 non_pcm_data_type = (o[
i+6] & 0x1F);
193 if (non_pcm_data_type != -1) {
194 if (
s->non_pcm_mode == 3) {
196 "S302 non PCM mode with data type %d not supported\n",
200 if (
s->non_pcm_mode & 1) {
212#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_DECODING_PARAM
214 {
"non_pcm_mode",
"Chooses what to do with NON-PCM", offsetof(
S302Context, non_pcm_mode),
AV_OPT_TYPE_INT, {.i64 = 3}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
215 {
"copy" ,
"Pass NON-PCM through unchanged" , 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
217 {
"decode_copy" ,
"Decode if possible else passthrough", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
218 {
"decode_drop" ,
"Decode if possible else drop" , 0,
AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 3,
FLAGS, .unit =
"non_pcm_mode"},
223 .class_name =
"SMPTE 302M Decoder",
const FFCodec ff_s302m_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static const uint8_t bits[8]
static const uint8_t frame_size[4]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_CH_LAYOUT_5POINT1_BACK
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define AV_CHANNEL_LAYOUT_5POINT1_BACK
#define AV_CHANNEL_LAYOUT_STEREO
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define AV_CHANNEL_LAYOUT_QUAD
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define LIBAVUTIL_VERSION_INT
const uint8_t ff_reverse[256]
static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
static const AVOption s302m_options[]
static int s302m_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static const AVClass s302m_class
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int64_t bit_rate
the average bitrate
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int sample_rate
samples per second
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.