Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
a7a672c8
Commit
a7a672c8
authored
May 28, 2019
by
Anton Khirnov
Committed by
James Almer
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dolby_e: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
441fe250
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
10 deletions
+55
-10
dolby_e.c
libavcodec/dolby_e.c
+46
-6
dolby_e.h
libavcodec/dolby_e.h
+2
-0
dolby_e_parser.c
libavcodec/dolby_e_parser.c
+7
-4
No files found.
libavcodec/dolby_e.c
View file @
a7a672c8
...
...
@@ -23,6 +23,7 @@
#include "libavutil/thread.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "internal.h"
#include "get_bits.h"
...
...
@@ -39,6 +40,11 @@
#define MAX_MSTR_EXP 2
#define MAX_BIAS_EXP 50
enum
DBEOutputChannelOrder
{
CHANNEL_ORDER_DEFAULT
,
CHANNEL_ORDER_CODED
,
};
typedef
struct
DBEGroup
{
uint8_t
nb_exponent
;
uint8_t
nb_bias_exp
[
MAX_MSTR_EXP
];
...
...
@@ -70,6 +76,7 @@ typedef struct DBEChannel {
}
DBEChannel
;
typedef
struct
DBEDecodeContext
{
const
AVClass
*
class
;
AVCodecContext
*
avctx
;
DBEContext
dectx
;
...
...
@@ -1057,7 +1064,7 @@ static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
reorder
=
ch_reorder_4
;
else
if
(
metadata
->
nb_channels
==
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
;
else
reorder
=
ch_reorder_n
;
...
...
@@ -1093,19 +1100,23 @@ static int dolby_e_decode_frame(AVCodecContext *avctx, void *data,
s
->
metadata
.
multi_prog_warned
=
1
;
}
av_channel_layout_uninit
(
&
avctx
->
ch_layout
);
switch
(
s
->
metadata
.
nb_channels
)
{
case
4
:
avctx
->
ch
annel_layout
=
AV_CH
_LAYOUT_4POINT0
;
avctx
->
ch
_layout
=
(
AVChannelLayout
)
AV_CHANNEL
_LAYOUT_4POINT0
;
break
;
case
6
:
avctx
->
ch
annel_layout
=
AV_CH
_LAYOUT_5POINT1
;
avctx
->
ch
_layout
=
(
AVChannelLayout
)
AV_CHANNEL
_LAYOUT_5POINT1
;
break
;
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
;
}
avctx
->
channels
=
s
->
metadata
.
nb_channels
;
avctx
->
sample_rate
=
s
->
metadata
.
sample_rate
;
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
)))
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
;
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
=
{
.
name
=
"dolby_e"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"Dolby E"
),
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
AV_CODEC_ID_DOLBY_E
,
.
priv_data_size
=
sizeof
(
DBEDecodeContext
),
.
priv_class
=
&
dolby_e_decoder_class
,
.
init
=
dolby_e_init
,
.
decode
=
dolby_e_decode_frame
,
.
close
=
dolby_e_close
,
...
...
libavcodec/dolby_e.h
View file @
a7a672c8
...
...
@@ -59,6 +59,8 @@ typedef struct DolbyEHeaderInfo {
*/
int
multi_prog_warned
;
int
output_channel_order
;
int
sample_rate
;
/** @} */
}
DolbyEHeaderInfo
;
...
...
libavcodec/dolby_e_parser.c
View file @
a7a672c8
...
...
@@ -42,17 +42,20 @@ static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx,
s2
->
duration
=
FRAME_SAMPLES
;
switch
(
s
->
metadata
.
nb_channels
)
{
case
4
:
avctx
->
ch
annel_layout
=
AV_CH
_LAYOUT_4POINT0
;
avctx
->
ch
_layout
=
(
AVChannelLayout
)
AV_CHANNEL
_LAYOUT_4POINT0
;
break
;
case
6
:
avctx
->
ch
annel_layout
=
AV_CH
_LAYOUT_5POINT1
;
avctx
->
ch
_layout
=
(
AVChannelLayout
)
AV_CHANNEL
_LAYOUT_5POINT1
;
break
;
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
;
}
avctx
->
channels
=
s
->
metadata
.
nb_channels
;
avctx
->
sample_rate
=
s
->
metadata
.
sample_rate
;
avctx
->
sample_fmt
=
AV_SAMPLE_FMT_FLTP
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment