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
5d5c248c
Commit
5d5c248c
authored
Dec 24, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s302m: decode directly to the user-provided AVFrame
parent
79fb2a1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
26 deletions
+8
-26
s302m.c
libavcodec/s302m.c
+8
-26
No files found.
libavcodec/s302m.c
View file @
5d5c248c
...
...
@@ -28,10 +28,6 @@
#define AES3_HEADER_LEN 4
typedef
struct
S302MDecodeContext
{
AVFrame
frame
;
}
S302MDecodeContext
;
static
int
s302m_parse_frame_header
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
int
buf_size
)
{
...
...
@@ -82,7 +78,7 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
static
int
s302m_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
S302MDecodeContext
*
s
=
avctx
->
priv_
data
;
AVFrame
*
frame
=
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int
block_size
,
ret
;
...
...
@@ -96,16 +92,16 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
/* get output buffer */
block_size
=
(
avctx
->
bits_per_coded_sample
+
4
)
/
4
;
s
->
frame
.
nb_samples
=
2
*
(
buf_size
/
block_size
)
/
avctx
->
channels
;
if
((
ret
=
ff_get_buffer
(
avctx
,
&
s
->
frame
))
<
0
)
{
frame
->
nb_samples
=
2
*
(
buf_size
/
block_size
)
/
avctx
->
channels
;
if
((
ret
=
ff_get_buffer
(
avctx
,
frame
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
ret
;
}
buf_size
=
(
s
->
frame
.
nb_samples
*
avctx
->
channels
/
2
)
*
block_size
;
buf_size
=
(
frame
->
nb_samples
*
avctx
->
channels
/
2
)
*
block_size
;
if
(
avctx
->
bits_per_coded_sample
==
24
)
{
uint32_t
*
o
=
(
uint32_t
*
)
s
->
frame
.
data
[
0
];
uint32_t
*
o
=
(
uint32_t
*
)
frame
->
data
[
0
];
for
(;
buf_size
>
6
;
buf_size
-=
7
)
{
*
o
++
=
(
ff_reverse
[
buf
[
2
]]
<<
24
)
|
(
ff_reverse
[
buf
[
1
]]
<<
16
)
|
...
...
@@ -117,7 +113,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
buf
+=
7
;
}
}
else
if
(
avctx
->
bits_per_coded_sample
==
20
)
{
uint32_t
*
o
=
(
uint32_t
*
)
s
->
frame
.
data
[
0
];
uint32_t
*
o
=
(
uint32_t
*
)
frame
->
data
[
0
];
for
(;
buf_size
>
5
;
buf_size
-=
6
)
{
*
o
++
=
(
ff_reverse
[
buf
[
2
]
&
0xf0
]
<<
28
)
|
(
ff_reverse
[
buf
[
1
]]
<<
20
)
|
...
...
@@ -128,7 +124,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
buf
+=
6
;
}
}
else
{
uint16_t
*
o
=
(
uint16_t
*
)
s
->
frame
.
data
[
0
];
uint16_t
*
o
=
(
uint16_t
*
)
frame
->
data
[
0
];
for
(;
buf_size
>
4
;
buf_size
-=
5
)
{
*
o
++
=
(
ff_reverse
[
buf
[
1
]]
<<
8
)
|
ff_reverse
[
buf
[
0
]];
...
...
@@ -139,29 +135,15 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
}
}
*
got_frame_ptr
=
1
;
*
(
AVFrame
*
)
data
=
s
->
frame
;
*
got_frame_ptr
=
1
;
return
avpkt
->
size
;
}
static
int
s302m_decode_init
(
AVCodecContext
*
avctx
)
{
S302MDecodeContext
*
s
=
avctx
->
priv_data
;
avcodec_get_frame_defaults
(
&
s
->
frame
);
avctx
->
coded_frame
=
&
s
->
frame
;
return
0
;
}
AVCodec
ff_s302m_decoder
=
{
.
name
=
"s302m"
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
AV_CODEC_ID_S302M
,
.
priv_data_size
=
sizeof
(
S302MDecodeContext
),
.
init
=
s302m_decode_init
,
.
decode
=
s302m_decode_frame
,
.
capabilities
=
CODEC_CAP_DR1
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SMPTE 302M"
),
...
...
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