|
|
@ -23,6 +23,7 @@ |
|
|
|
#include "libavutil/thread.h" |
|
|
|
#include "libavutil/thread.h" |
|
|
|
#include "libavutil/mem.h" |
|
|
|
#include "libavutil/mem.h" |
|
|
|
#include "libavutil/mem_internal.h" |
|
|
|
#include "libavutil/mem_internal.h" |
|
|
|
|
|
|
|
#include "libavutil/opt.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "internal.h" |
|
|
|
#include "internal.h" |
|
|
|
#include "get_bits.h" |
|
|
|
#include "get_bits.h" |
|
|
@ -39,6 +40,11 @@ |
|
|
|
#define MAX_MSTR_EXP 2 |
|
|
|
#define MAX_MSTR_EXP 2 |
|
|
|
#define MAX_BIAS_EXP 50 |
|
|
|
#define MAX_BIAS_EXP 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum DBEOutputChannelOrder { |
|
|
|
|
|
|
|
CHANNEL_ORDER_DEFAULT, |
|
|
|
|
|
|
|
CHANNEL_ORDER_CODED, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct DBEGroup { |
|
|
|
typedef struct DBEGroup { |
|
|
|
uint8_t nb_exponent; |
|
|
|
uint8_t nb_exponent; |
|
|
|
uint8_t nb_bias_exp[MAX_MSTR_EXP]; |
|
|
|
uint8_t nb_bias_exp[MAX_MSTR_EXP]; |
|
|
@ -70,6 +76,7 @@ typedef struct DBEChannel { |
|
|
|
} DBEChannel; |
|
|
|
} DBEChannel; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct DBEDecodeContext { |
|
|
|
typedef struct DBEDecodeContext { |
|
|
|
|
|
|
|
const AVClass *class; |
|
|
|
AVCodecContext *avctx; |
|
|
|
AVCodecContext *avctx; |
|
|
|
DBEContext dectx; |
|
|
|
DBEContext dectx; |
|
|
|
|
|
|
|
|
|
|
@ -1057,7 +1064,7 @@ static int filter_frame(DBEDecodeContext *s, AVFrame *frame) |
|
|
|
reorder = ch_reorder_4; |
|
|
|
reorder = ch_reorder_4; |
|
|
|
else if (metadata->nb_channels == 6) |
|
|
|
else if (metadata->nb_channels == 6) |
|
|
|
reorder = ch_reorder_6; |
|
|
|
reorder = ch_reorder_6; |
|
|
|
else if (metadata->nb_programs == 1 && !(s->avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE)) |
|
|
|
else if (metadata->nb_programs == 1 && metadata->output_channel_order == CHANNEL_ORDER_DEFAULT) |
|
|
|
reorder = ch_reorder_8; |
|
|
|
reorder = ch_reorder_8; |
|
|
|
else |
|
|
|
else |
|
|
|
reorder = ch_reorder_n; |
|
|
|
reorder = ch_reorder_n; |
|
|
@ -1093,19 +1100,23 @@ static int dolby_e_decode_frame(AVCodecContext *avctx, void *data, |
|
|
|
s->metadata.multi_prog_warned = 1; |
|
|
|
s->metadata.multi_prog_warned = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
av_channel_layout_uninit(&avctx->ch_layout); |
|
|
|
switch (s->metadata.nb_channels) { |
|
|
|
switch (s->metadata.nb_channels) { |
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
avctx->channel_layout = AV_CH_LAYOUT_4POINT0; |
|
|
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
case 6: |
|
|
|
avctx->channel_layout = AV_CH_LAYOUT_5POINT1; |
|
|
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 8: |
|
|
|
case 8: |
|
|
|
avctx->channel_layout = AV_CH_LAYOUT_7POINT1; |
|
|
|
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; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
avctx->channels = s->metadata.nb_channels; |
|
|
|
|
|
|
|
avctx->sample_rate = s->metadata.sample_rate; |
|
|
|
avctx->sample_rate = s->metadata.sample_rate; |
|
|
|
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
|
|
|
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
|
|
|
|
|
|
|
|
|
|
@ -1252,17 +1263,46 @@ static av_cold int dolby_e_init(AVCodecContext *avctx) |
|
|
|
if (!(s->fdsp = avpriv_float_dsp_alloc(0))) |
|
|
|
if (!(s->fdsp = avpriv_float_dsp_alloc(0))) |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
|
|
|
|
|
|
|
s->dectx.metadata.multi_prog_warned = !!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE); |
|
|
|
#if FF_API_OLD_CHANNEL_LAYOUT |
|
|
|
|
|
|
|
FF_DISABLE_DEPRECATION_WARNINGS |
|
|
|
|
|
|
|
if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) |
|
|
|
|
|
|
|
s->dectx.metadata.output_channel_order = CHANNEL_ORDER_CODED; |
|
|
|
|
|
|
|
FF_ENABLE_DEPRECATION_WARNINGS |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s->dectx.metadata.multi_prog_warned = s->dectx.metadata.output_channel_order == CHANNEL_ORDER_CODED; |
|
|
|
s->dectx.avctx = s->avctx = avctx; |
|
|
|
s->dectx.avctx = s->avctx = avctx; |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define OFFSET(x) offsetof(DBEDecodeContext, x) |
|
|
|
|
|
|
|
#define FLAGS (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM) |
|
|
|
|
|
|
|
static const AVOption options[] = { |
|
|
|
|
|
|
|
{ "channel_order", "Order in which the channels are to be exported", |
|
|
|
|
|
|
|
OFFSET(dectx.metadata.output_channel_order), AV_OPT_TYPE_INT, |
|
|
|
|
|
|
|
{ .i64 = CHANNEL_ORDER_DEFAULT }, 0, 1, FLAGS, "channel_order" }, |
|
|
|
|
|
|
|
{ "default", "normal libavcodec channel order", 0, AV_OPT_TYPE_CONST, |
|
|
|
|
|
|
|
{ .i64 = CHANNEL_ORDER_DEFAULT }, .flags = FLAGS, "channel_order" }, |
|
|
|
|
|
|
|
{ "coded", "order in which the channels are coded in the bitstream", |
|
|
|
|
|
|
|
0, AV_OPT_TYPE_CONST, { .i64 = CHANNEL_ORDER_CODED }, .flags = FLAGS, "channel_order" }, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ NULL }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const AVClass dolby_e_decoder_class = { |
|
|
|
|
|
|
|
.class_name = "Dolby E decoder", |
|
|
|
|
|
|
|
.item_name = av_default_item_name, |
|
|
|
|
|
|
|
.option = options, |
|
|
|
|
|
|
|
.version = LIBAVUTIL_VERSION_INT, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const AVCodec ff_dolby_e_decoder = { |
|
|
|
const AVCodec ff_dolby_e_decoder = { |
|
|
|
.name = "dolby_e", |
|
|
|
.name = "dolby_e", |
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("Dolby E"), |
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("Dolby E"), |
|
|
|
.type = AVMEDIA_TYPE_AUDIO, |
|
|
|
.type = AVMEDIA_TYPE_AUDIO, |
|
|
|
.id = AV_CODEC_ID_DOLBY_E, |
|
|
|
.id = AV_CODEC_ID_DOLBY_E, |
|
|
|
.priv_data_size = sizeof(DBEDecodeContext), |
|
|
|
.priv_data_size = sizeof(DBEDecodeContext), |
|
|
|
|
|
|
|
.priv_class = &dolby_e_decoder_class, |
|
|
|
.init = dolby_e_init, |
|
|
|
.init = dolby_e_init, |
|
|
|
.decode = dolby_e_decode_frame, |
|
|
|
.decode = dolby_e_decode_frame, |
|
|
|
.close = dolby_e_close, |
|
|
|
.close = dolby_e_close, |
|
|
|