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
dcad4677
Commit
dcad4677
authored
Jun 23, 2016
by
Rostislav Pehlivanov
Committed by
Rostislav Pehlivanov
Jul 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diracdec: do not allocate and free slice parameters every frame
Signed-off-by:
Rostislav Pehlivanov
<
rpehlivanov@obe.tv
>
parent
0eb0f931
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
14 deletions
+22
-14
diracdec.c
libavcodec/diracdec.c
+22
-14
No files found.
libavcodec/diracdec.c
View file @
dcad4677
...
@@ -121,6 +121,14 @@ typedef struct Plane {
...
@@ -121,6 +121,14 @@ typedef struct Plane {
SubBand
band
[
MAX_DWT_LEVELS
][
4
];
SubBand
band
[
MAX_DWT_LEVELS
][
4
];
}
Plane
;
}
Plane
;
/* Used by Low Delay and High Quality profiles */
typedef
struct
DiracSlice
{
GetBitContext
gb
;
int
slice_x
;
int
slice_y
;
int
bytes
;
}
DiracSlice
;
typedef
struct
DiracContext
{
typedef
struct
DiracContext
{
AVCodecContext
*
avctx
;
AVCodecContext
*
avctx
;
MpegvideoEncDSPContext
mpvencdsp
;
MpegvideoEncDSPContext
mpvencdsp
;
...
@@ -167,6 +175,9 @@ typedef struct DiracContext {
...
@@ -167,6 +175,9 @@ typedef struct DiracContext {
int
threads_num_buf
;
/* Current # of buffers allocated */
int
threads_num_buf
;
/* Current # of buffers allocated */
int
thread_buf_size
;
/* Each thread has a buffer this size */
int
thread_buf_size
;
/* Each thread has a buffer this size */
DiracSlice
*
slice_params_buf
;
int
slice_params_num_buf
;
struct
{
struct
{
unsigned
width
;
unsigned
width
;
unsigned
height
;
unsigned
height
;
...
@@ -417,6 +428,7 @@ static av_cold int dirac_decode_end(AVCodecContext *avctx)
...
@@ -417,6 +428,7 @@ static av_cold int dirac_decode_end(AVCodecContext *avctx)
av_frame_free
(
&
s
->
all_frames
[
i
].
avframe
);
av_frame_free
(
&
s
->
all_frames
[
i
].
avframe
);
av_freep
(
&
s
->
thread_buf
);
av_freep
(
&
s
->
thread_buf
);
av_freep
(
&
s
->
slice_params_buf
);
return
0
;
return
0
;
}
}
...
@@ -724,15 +736,6 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
...
@@ -724,15 +736,6 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
}
}
}
}
/* Used by Low Delay and High Quality profiles */
typedef
struct
DiracSlice
{
GetBitContext
gb
;
int
slice_x
;
int
slice_y
;
int
bytes
;
}
DiracSlice
;
/**
/**
* Dirac Specification ->
* Dirac Specification ->
* 13.5.2 Slices. slice(sx,sy)
* 13.5.2 Slices. slice(sx,sy)
...
@@ -904,9 +907,15 @@ static int decode_lowdelay(DiracContext *s)
...
@@ -904,9 +907,15 @@ static int decode_lowdelay(DiracContext *s)
SliceCoeffs
tmp
[
MAX_DWT_LEVELS
];
SliceCoeffs
tmp
[
MAX_DWT_LEVELS
];
int
slice_num
=
0
;
int
slice_num
=
0
;
slices
=
av_mallocz_array
(
s
->
num_x
,
s
->
num_y
*
sizeof
(
DiracSlice
));
if
(
s
->
slice_params_num_buf
!=
(
s
->
num_x
*
s
->
num_y
))
{
if
(
!
slices
)
s
->
slice_params_buf
=
av_realloc_f
(
s
->
thread_buf
,
s
->
num_x
*
s
->
num_y
,
sizeof
(
DiracSlice
));
return
AVERROR
(
ENOMEM
);
if
(
!
s
->
slice_params_buf
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"slice params buffer allocation failure
\n
"
);
return
AVERROR
(
ENOMEM
);
}
s
->
slice_params_num_buf
=
s
->
num_x
*
s
->
num_y
;
}
slices
=
s
->
slice_params_buf
;
/* 8 becacuse that's how much the golomb reader could overread junk data
/* 8 becacuse that's how much the golomb reader could overread junk data
* from another plane/slice at most, and 512 because SIMD */
* from another plane/slice at most, and 512 because SIMD */
...
@@ -941,7 +950,6 @@ static int decode_lowdelay(DiracContext *s)
...
@@ -941,7 +950,6 @@ static int decode_lowdelay(DiracContext *s)
}
}
if
(
bytes
>=
INT_MAX
||
bytes
*
8
>
bufsize
)
{
if
(
bytes
>=
INT_MAX
||
bytes
*
8
>
bufsize
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"too many bytes
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"too many bytes
\n
"
);
av_free
(
slices
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
...
@@ -998,7 +1006,7 @@ static int decode_lowdelay(DiracContext *s)
...
@@ -998,7 +1006,7 @@ static int decode_lowdelay(DiracContext *s)
intra_dc_prediction_8
(
&
s
->
plane
[
2
].
band
[
0
][
0
]);
intra_dc_prediction_8
(
&
s
->
plane
[
2
].
band
[
0
][
0
]);
}
}
}
}
av_free
(
slices
);
return
0
;
return
0
;
}
}
...
...
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