Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
be187388
Commit
be187388
authored
Mar 24, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get audio_service_type for AC-3 based on bitstream mode in the AC-3 parser
and decoder, and vice-versa for the AC-3 encoder.
parent
c70a6a41
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
3 deletions
+29
-3
aac_ac3_parser.c
libavcodec/aac_ac3_parser.c
+1
-0
aac_ac3_parser.h
libavcodec/aac_ac3_parser.h
+1
-0
ac3.h
libavcodec/ac3.h
+1
-0
ac3_parser.c
libavcodec/ac3_parser.c
+4
-1
ac3dec.c
libavcodec/ac3dec.c
+5
-0
ac3dec.h
libavcodec/ac3dec.h
+1
-0
ac3enc.c
libavcodec/ac3enc.c
+15
-1
eac3dec.c
libavcodec/eac3dec.c
+1
-1
No files found.
libavcodec/aac_ac3_parser.c
View file @
be187388
...
...
@@ -94,6 +94,7 @@ get_next:
avctx
->
channel_layout
=
s
->
channel_layout
;
}
avctx
->
frame_size
=
s
->
samples
;
avctx
->
audio_service_type
=
s
->
service_type
;
}
avctx
->
bit_rate
=
s
->
bit_rate
;
...
...
libavcodec/aac_ac3_parser.h
View file @
be187388
...
...
@@ -49,6 +49,7 @@ typedef struct AACAC3ParseContext {
int
bit_rate
;
int
samples
;
int64_t
channel_layout
;
int
service_type
;
int
remaining_size
;
uint64_t
state
;
...
...
libavcodec/ac3.h
View file @
be187388
...
...
@@ -87,6 +87,7 @@ typedef struct {
uint16_t
crc1
;
uint8_t
sr_code
;
uint8_t
bitstream_id
;
uint8_t
bitstream_mode
;
uint8_t
channel_mode
;
uint8_t
lfe_on
;
uint8_t
frame_type
;
...
...
libavcodec/ac3_parser.c
View file @
be187388
...
...
@@ -69,7 +69,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
skip_bits
(
gbc
,
5
);
// skip bsid, already got it
skip_bits
(
gbc
,
3
);
// skip bitstream mode
hdr
->
bitstream_mode
=
get_bits
(
gbc
,
3
);
hdr
->
channel_mode
=
get_bits
(
gbc
,
3
);
if
(
hdr
->
channel_mode
==
AC3_CHMODE_STEREO
)
{
...
...
@@ -151,6 +151,9 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
hdr_info
->
channels
=
hdr
.
channels
;
hdr_info
->
channel_layout
=
hdr
.
channel_layout
;
hdr_info
->
samples
=
hdr
.
num_blocks
*
256
;
hdr_info
->
service_type
=
hdr
.
bitstream_mode
;
if
(
hdr
.
bitstream_mode
==
0x7
&&
hdr
.
channels
>
1
)
hdr_info
->
service_type
=
AV_AUDIO_SERVICE_TYPE_KARAOKE
;
if
(
hdr
.
bitstream_id
>
10
)
hdr_info
->
codec_id
=
CODEC_ID_EAC3
;
else
if
(
hdr_info
->
codec_id
==
CODEC_ID_NONE
)
...
...
libavcodec/ac3dec.c
View file @
be187388
...
...
@@ -273,6 +273,7 @@ static int parse_frame_header(AC3DecodeContext *s)
/* get decoding parameters from header info */
s
->
bit_alloc_params
.
sr_code
=
hdr
.
sr_code
;
s
->
bitstream_mode
=
hdr
.
bitstream_mode
;
s
->
channel_mode
=
hdr
.
channel_mode
;
s
->
channel_layout
=
hdr
.
channel_layout
;
s
->
lfe_on
=
hdr
.
lfe_on
;
...
...
@@ -1399,6 +1400,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
if
(
s
->
out_channels
<
s
->
channels
)
s
->
output_mode
=
s
->
out_channels
==
1
?
AC3_CHMODE_MONO
:
AC3_CHMODE_STEREO
;
}
/* set audio service type based on bitstream mode for AC-3 */
avctx
->
audio_service_type
=
s
->
bitstream_mode
;
if
(
s
->
bitstream_mode
==
0x7
&&
s
->
channels
>
1
)
avctx
->
audio_service_type
=
AV_AUDIO_SERVICE_TYPE_KARAOKE
;
/* decode the audio blocks */
channel_map
=
ff_ac3_dec_channel_map
[
s
->
output_mode
&
~
AC3_OUTPUT_LFEON
][
s
->
lfe_on
];
...
...
libavcodec/ac3dec.h
View file @
be187388
...
...
@@ -79,6 +79,7 @@ typedef struct {
int
bit_rate
;
///< stream bit rate, in bits-per-second
int
sample_rate
;
///< sample frequency, in Hz
int
num_blocks
;
///< number of audio blocks
int
bitstream_mode
;
///< bitstream mode (bsmod)
int
channel_mode
;
///< channel mode (acmod)
int
channel_layout
;
///< channel layout
int
lfe_on
;
///< lfe channel in use
...
...
libavcodec/ac3enc.c
View file @
be187388
...
...
@@ -1657,6 +1657,18 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
if
(
s
->
cutoff
>
(
s
->
sample_rate
>>
1
))
s
->
cutoff
=
s
->
sample_rate
>>
1
;
/* validate audio service type / channels combination */
if
((
avctx
->
audio_service_type
==
AV_AUDIO_SERVICE_TYPE_KARAOKE
&&
avctx
->
channels
==
1
)
||
((
avctx
->
audio_service_type
==
AV_AUDIO_SERVICE_TYPE_COMMENTARY
||
avctx
->
audio_service_type
==
AV_AUDIO_SERVICE_TYPE_EMERGENCY
||
avctx
->
audio_service_type
==
AV_AUDIO_SERVICE_TYPE_VOICE_OVER
)
&&
avctx
->
channels
>
1
))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid audio service type for the "
"specified number of channels
\n
"
);
return
AVERROR
(
EINVAL
);
}
return
0
;
}
...
...
@@ -1799,7 +1811,9 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx)
return
ret
;
s
->
bitstream_id
=
8
+
s
->
bit_alloc
.
sr_shift
;
s
->
bitstream_mode
=
0
;
/* complete main audio service */
s
->
bitstream_mode
=
avctx
->
audio_service_type
;
if
(
s
->
bitstream_mode
==
AV_AUDIO_SERVICE_TYPE_KARAOKE
)
s
->
bitstream_mode
=
0x7
;
s
->
frame_size_min
=
2
*
ff_ac3_frame_size_tab
[
s
->
frame_size_code
][
s
->
bit_alloc
.
sr_code
];
s
->
bits_written
=
0
;
...
...
libavcodec/eac3dec.c
View file @
be187388
...
...
@@ -410,7 +410,7 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
/* informational metadata */
if
(
get_bits1
(
gbc
))
{
s
kip_bits
(
gbc
,
3
);
// skip bit stream mode
s
->
bitstream_mode
=
get_bits
(
gbc
,
3
);
skip_bits
(
gbc
,
2
);
// skip copyright bit and original bitstream bit
if
(
s
->
channel_mode
==
AC3_CHMODE_STEREO
)
{
skip_bits
(
gbc
,
4
);
// skip Dolby surround and headphone mode
...
...
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