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
495db0e3
Commit
495db0e3
authored
Jun 03, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ttadec: frame multi-threading support
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
9300de04
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
15 deletions
+30
-15
tta.c
libavcodec/tta.c
+30
-15
No files found.
libavcodec/tta.c
View file @
495db0e3
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "ttadata.h"
#include "ttadata.h"
#include "avcodec.h"
#include "avcodec.h"
#include "get_bits.h"
#include "get_bits.h"
#include "thread.h"
#include "unary.h"
#include "unary.h"
#include "internal.h"
#include "internal.h"
#include "libavutil/crc.h"
#include "libavutil/crc.h"
...
@@ -127,6 +128,25 @@ static uint64_t tta_check_crc64(uint8_t *pass)
...
@@ -127,6 +128,25 @@ static uint64_t tta_check_crc64(uint8_t *pass)
return
crc
^
UINT64_MAX
;
return
crc
^
UINT64_MAX
;
}
}
static
int
allocate_buffers
(
AVCodecContext
*
avctx
)
{
TTAContext
*
s
=
avctx
->
priv_data
;
if
(
s
->
bps
<
3
)
{
s
->
decode_buffer
=
av_mallocz
(
sizeof
(
int32_t
)
*
s
->
frame_length
*
s
->
channels
);
if
(
!
s
->
decode_buffer
)
return
AVERROR
(
ENOMEM
);
}
else
s
->
decode_buffer
=
NULL
;
s
->
ch_ctx
=
av_malloc
(
avctx
->
channels
*
sizeof
(
*
s
->
ch_ctx
));
if
(
!
s
->
ch_ctx
)
{
av_freep
(
&
s
->
decode_buffer
);
return
AVERROR
(
ENOMEM
);
}
return
0
;
}
static
av_cold
int
tta_decode_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
tta_decode_init
(
AVCodecContext
*
avctx
)
{
{
TTAContext
*
s
=
avctx
->
priv_data
;
TTAContext
*
s
=
avctx
->
priv_data
;
...
@@ -209,30 +229,19 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
...
@@ -209,30 +229,19 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
av_log
(
avctx
,
AV_LOG_ERROR
,
"frame_length too large
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"frame_length too large
\n
"
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
if
(
s
->
bps
<
3
)
{
s
->
decode_buffer
=
av_mallocz
(
sizeof
(
int32_t
)
*
s
->
frame_length
*
s
->
channels
);
if
(
!
s
->
decode_buffer
)
return
AVERROR
(
ENOMEM
);
}
else
s
->
decode_buffer
=
NULL
;
s
->
ch_ctx
=
av_malloc
(
avctx
->
channels
*
sizeof
(
*
s
->
ch_ctx
));
if
(
!
s
->
ch_ctx
)
{
av_freep
(
&
s
->
decode_buffer
);
return
AVERROR
(
ENOMEM
);
}
}
else
{
}
else
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Wrong extradata present
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Wrong extradata present
\n
"
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
return
0
;
return
allocate_buffers
(
avctx
)
;
}
}
static
int
tta_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
static
int
tta_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
int
*
got_frame_ptr
,
AVPacket
*
avpkt
)
{
{
AVFrame
*
frame
=
data
;
AVFrame
*
frame
=
data
;
ThreadFrame
tframe
=
{
.
f
=
data
};
const
uint8_t
*
buf
=
avpkt
->
data
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int
buf_size
=
avpkt
->
size
;
TTAContext
*
s
=
avctx
->
priv_data
;
TTAContext
*
s
=
avctx
->
priv_data
;
...
@@ -251,7 +260,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -251,7 +260,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
/* get output buffer */
/* get output buffer */
frame
->
nb_samples
=
framelen
;
frame
->
nb_samples
=
framelen
;
if
((
ret
=
ff_
get_buffer
(
avctx
,
frame
,
0
))
<
0
)
if
((
ret
=
ff_
thread_get_buffer
(
avctx
,
&
t
frame
,
0
))
<
0
)
return
ret
;
return
ret
;
// decode directly to output buffer for 24-bit sample format
// decode directly to output buffer for 24-bit sample format
...
@@ -399,6 +408,11 @@ error:
...
@@ -399,6 +408,11 @@ error:
return
ret
;
return
ret
;
}
}
static
int
init_thread_copy
(
AVCodecContext
*
avctx
)
{
return
allocate_buffers
(
avctx
);
}
static
av_cold
int
tta_decode_close
(
AVCodecContext
*
avctx
)
{
static
av_cold
int
tta_decode_close
(
AVCodecContext
*
avctx
)
{
TTAContext
*
s
=
avctx
->
priv_data
;
TTAContext
*
s
=
avctx
->
priv_data
;
...
@@ -432,7 +446,8 @@ AVCodec ff_tta_decoder = {
...
@@ -432,7 +446,8 @@ AVCodec ff_tta_decoder = {
.
init
=
tta_decode_init
,
.
init
=
tta_decode_init
,
.
close
=
tta_decode_close
,
.
close
=
tta_decode_close
,
.
decode
=
tta_decode_frame
,
.
decode
=
tta_decode_frame
,
.
capabilities
=
CODEC_CAP_DR1
,
.
init_thread_copy
=
init_thread_copy
,
.
capabilities
=
CODEC_CAP_DR1
|
CODEC_CAP_FRAME_THREADS
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"TTA (True Audio)"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"TTA (True Audio)"
),
.
priv_class
=
&
tta_decoder_class
,
.
priv_class
=
&
tta_decoder_class
,
};
};
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