Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
bc057f75
Commit
bc057f75
authored
Dec 04, 2011
by
Hendrik Leppkes
Committed by
Justin Ruggles
Dec 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm-mpeg: implement new audio decoding api
Signed-off-by:
Justin Ruggles
<
justin.ruggles@gmail.com
>
parent
8b03d7fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
17 deletions
+35
-17
pcm-mpeg.c
libavcodec/pcm-mpeg.c
+35
-17
No files found.
libavcodec/pcm-mpeg.c
View file @
bc057f75
...
@@ -119,17 +119,30 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
...
@@ -119,17 +119,30 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
return
0
;
return
0
;
}
}
static
int
pcm_bluray_decode_frame
(
AVCodecContext
*
avctx
,
typedef
struct
PCMBRDecode
{
void
*
data
,
AVFrame
frame
;
int
*
data_size
,
}
PCMBRDecode
;
AVPacket
*
avpkt
)
static
av_cold
int
pcm_bluray_decode_init
(
AVCodecContext
*
avctx
)
{
PCMBRDecode
*
s
=
avctx
->
priv_data
;
avcodec_get_frame_defaults
(
&
s
->
frame
);
avctx
->
coded_frame
=
&
s
->
frame
;
return
0
;
}
static
int
pcm_bluray_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
const
uint8_t
*
src
=
avpkt
->
data
;
const
uint8_t
*
src
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
PCMBRDecode
*
s
=
avctx
->
priv_data
;
int
num_source_channels
,
channel
,
retval
;
int
num_source_channels
,
channel
,
retval
;
int
sample_size
,
samples
,
output_size
;
int
sample_size
,
samples
;
int16_t
*
dst16
=
data
;
int16_t
*
dst16
;
int32_t
*
dst32
=
data
;
int32_t
*
dst32
;
if
(
buf_size
<
4
)
{
if
(
buf_size
<
4
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"PCM packet too small
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"PCM packet too small
\n
"
);
...
@@ -146,15 +159,14 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
...
@@ -146,15 +159,14 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
sample_size
=
(
num_source_channels
*
avctx
->
bits_per_coded_sample
)
>>
3
;
sample_size
=
(
num_source_channels
*
avctx
->
bits_per_coded_sample
)
>>
3
;
samples
=
buf_size
/
sample_size
;
samples
=
buf_size
/
sample_size
;
output_size
=
samples
*
avctx
->
channels
*
/* get output buffer */
(
avctx
->
sample_fmt
==
AV_SAMPLE_FMT_S32
?
4
:
2
);
s
->
frame
.
nb_samples
=
samples
;
if
(
output_size
>
*
data_size
)
{
if
((
retval
=
avctx
->
get_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
"Insufficient output buffer space (%d bytes, needed %d bytes)
\n
"
,
return
retval
;
*
data_size
,
output_size
);
return
-
1
;
}
}
*
data_size
=
output_size
;
dst16
=
(
int16_t
*
)
s
->
frame
.
data
[
0
];
dst32
=
(
int32_t
*
)
s
->
frame
.
data
[
0
];
if
(
samples
)
{
if
(
samples
)
{
switch
(
avctx
->
channel_layout
)
{
switch
(
avctx
->
channel_layout
)
{
...
@@ -165,7 +177,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
...
@@ -165,7 +177,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
samples
*=
num_source_channels
;
samples
*=
num_source_channels
;
if
(
AV_SAMPLE_FMT_S16
==
avctx
->
sample_fmt
)
{
if
(
AV_SAMPLE_FMT_S16
==
avctx
->
sample_fmt
)
{
#if HAVE_BIGENDIAN
#if HAVE_BIGENDIAN
memcpy
(
dst16
,
src
,
output
_size
);
memcpy
(
dst16
,
src
,
buf
_size
);
#else
#else
do
{
do
{
*
dst16
++
=
bytestream_get_be16
(
&
src
);
*
dst16
++
=
bytestream_get_be16
(
&
src
);
...
@@ -289,10 +301,13 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
...
@@ -289,10 +301,13 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
}
}
}
}
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
s
->
frame
;
retval
=
src
-
avpkt
->
data
;
retval
=
src
-
avpkt
->
data
;
if
(
avctx
->
debug
&
FF_DEBUG_BITSTREAM
)
if
(
avctx
->
debug
&
FF_DEBUG_BITSTREAM
)
av_dlog
(
avctx
,
"pcm_bluray_decode_frame: decoded %d -> %d bytes
\n
"
,
av_dlog
(
avctx
,
"pcm_bluray_decode_frame: decoded %d -> %d bytes
\n
"
,
retval
,
*
data
_size
);
retval
,
buf
_size
);
return
retval
;
return
retval
;
}
}
...
@@ -300,7 +315,10 @@ AVCodec ff_pcm_bluray_decoder = {
...
@@ -300,7 +315,10 @@ AVCodec ff_pcm_bluray_decoder = {
.
name
=
"pcm_bluray"
,
.
name
=
"pcm_bluray"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
CODEC_ID_PCM_BLURAY
,
.
id
=
CODEC_ID_PCM_BLURAY
,
.
priv_data_size
=
sizeof
(
PCMBRDecode
),
.
init
=
pcm_bluray_decode_init
,
.
decode
=
pcm_bluray_decode_frame
,
.
decode
=
pcm_bluray_decode_frame
,
.
capabilities
=
CODEC_CAP_DR1
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_S32
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_S32
,
AV_SAMPLE_FMT_NONE
},
AV_SAMPLE_FMT_NONE
},
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PCM signed 16|20|24-bit big-endian for Blu-ray media"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"PCM signed 16|20|24-bit big-endian for Blu-ray media"
),
...
...
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