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
518b9ee3
Commit
518b9ee3
authored
Nov 21, 2017
by
Martin Vignali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/hapdec : reorganize code before adding multi-texture decoding
parent
ba98f846
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
9 deletions
+32
-9
hap.h
libavcodec/hap.h
+2
-0
hapdec.c
libavcodec/hapdec.c
+30
-9
No files found.
libavcodec/hap.h
View file @
518b9ee3
...
...
@@ -81,6 +81,8 @@ typedef struct HapContext {
int
slice_count
;
/* Number of slices for threaded operations */
int
texture_count
;
/* 2 for HAQA, 1 for other version */
/* Pointer to the selected compress or decompress function */
int
(
*
tex_fun
)(
uint8_t
*
dst
,
ptrdiff_t
stride
,
const
uint8_t
*
block
);
}
HapContext
;
...
...
libavcodec/hapdec.c
View file @
518b9ee3
...
...
@@ -266,8 +266,8 @@ static int decompress_chunks_thread(AVCodecContext *avctx, void *arg,
return
0
;
}
static
int
decompress_texture_thread
(
AVCodecContext
*
avctx
,
void
*
arg
,
int
slice
,
int
thread_nb
)
static
int
decompress_texture_thread
_internal
(
AVCodecContext
*
avctx
,
void
*
arg
,
int
slice
,
int
thread_nb
,
int
texture_num
)
{
HapContext
*
ctx
=
avctx
->
priv_data
;
AVFrame
*
frame
=
arg
;
...
...
@@ -295,34 +295,50 @@ static int decompress_texture_thread(AVCodecContext *avctx, void *arg,
uint8_t
*
p
=
frame
->
data
[
0
]
+
y
*
frame
->
linesize
[
0
]
*
TEXTURE_BLOCK_H
;
int
off
=
y
*
w_block
;
for
(
x
=
0
;
x
<
w_block
;
x
++
)
{
ctx
->
tex_fun
(
p
+
x
*
16
,
frame
->
linesize
[
0
],
d
+
(
off
+
x
)
*
ctx
->
tex_rat
);
if
(
texture_num
==
0
)
{
ctx
->
tex_fun
(
p
+
x
*
16
,
frame
->
linesize
[
0
],
d
+
(
off
+
x
)
*
ctx
->
tex_rat
);
}
}
}
return
0
;
}
static
int
decompress_texture_thread
(
AVCodecContext
*
avctx
,
void
*
arg
,
int
slice
,
int
thread_nb
)
{
return
decompress_texture_thread_internal
(
avctx
,
arg
,
slice
,
thread_nb
,
0
);
}
static
int
hap_decode
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
AVPacket
*
avpkt
)
{
HapContext
*
ctx
=
avctx
->
priv_data
;
ThreadFrame
tframe
;
int
ret
,
i
;
int
ret
,
i
,
t
;
int
tex_size
;
int
start_texture_section
=
0
;
int
tex_rat
[
2
]
=
{
0
,
0
};
bytestream2_init
(
&
ctx
->
gbc
,
avpkt
->
data
,
avpkt
->
size
);
/* Check for section header */
ret
=
hap_parse_frame_header
(
avctx
);
if
(
ret
<
0
)
return
ret
;
tex_rat
[
0
]
=
ctx
->
tex_rat
;
/* Get the output frame ready to receive data */
tframe
.
f
=
data
;
ret
=
ff_thread_get_buffer
(
avctx
,
&
tframe
,
0
);
if
(
ret
<
0
)
return
ret
;
for
(
t
=
0
;
t
<
ctx
->
texture_count
;
t
++
)
{
bytestream2_seek
(
&
ctx
->
gbc
,
start_texture_section
,
SEEK_SET
);
/* Check for section header */
ret
=
hap_parse_frame_header
(
avctx
);
if
(
ret
<
0
)
return
ret
;
if
(
avctx
->
codec
->
update_thread_context
)
ff_thread_finish_setup
(
avctx
);
...
...
@@ -357,7 +373,10 @@ static int hap_decode(AVCodecContext *avctx, void *data,
}
/* Use the decompress function on the texture, one block per thread */
if
(
t
==
0
){
avctx
->
execute2
(
avctx
,
decompress_texture_thread
,
tframe
.
f
,
NULL
,
ctx
->
slice_count
);
}
}
/* Frame is ready to be output */
tframe
.
f
->
pict_type
=
AV_PICTURE_TYPE_I
;
...
...
@@ -385,6 +404,8 @@ static av_cold int hap_init(AVCodecContext *avctx)
ff_texturedsp_init
(
&
ctx
->
dxtc
);
ctx
->
texture_count
=
1
;
switch
(
avctx
->
codec_tag
)
{
case
MKTAG
(
'H'
,
'a'
,
'p'
,
'1'
):
texture_name
=
"DXT1"
;
...
...
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