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
5620ed35
Commit
5620ed35
authored
Jul 12, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/hevc: Remove skipped_bytes_nal, simplify code
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
93aa84c1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
19 deletions
+13
-19
hevc.c
libavcodec/hevc.c
+7
-7
hevc.h
libavcodec/hevc.h
+2
-2
hevc_parse.c
libavcodec/hevc_parse.c
+4
-10
No files found.
libavcodec/hevc.c
View file @
5620ed35
...
@@ -2422,8 +2422,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
...
@@ -2422,8 +2422,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
return
0
;
return
0
;
}
}
static
int
hls_slice_data_wpp
(
HEVCContext
*
s
,
const
uint8_t
*
nal
,
int
length
)
static
int
hls_slice_data_wpp
(
HEVCContext
*
s
,
const
HEVCNAL
*
nal
)
{
{
const
uint8_t
*
data
=
nal
->
data
;
int
length
=
nal
->
size
;
HEVCLocalContext
*
lc
=
s
->
HEVClc
;
HEVCLocalContext
*
lc
=
s
->
HEVClc
;
int
*
ret
=
av_malloc_array
(
s
->
sh
.
num_entry_point_offsets
+
1
,
sizeof
(
int
));
int
*
ret
=
av_malloc_array
(
s
->
sh
.
num_entry_point_offsets
+
1
,
sizeof
(
int
));
int
*
arg
=
av_malloc_array
(
s
->
sh
.
num_entry_point_offsets
+
1
,
sizeof
(
int
));
int
*
arg
=
av_malloc_array
(
s
->
sh
.
num_entry_point_offsets
+
1
,
sizeof
(
int
));
...
@@ -2452,7 +2454,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
...
@@ -2452,7 +2454,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
offset
=
(
lc
->
gb
.
index
>>
3
);
offset
=
(
lc
->
gb
.
index
>>
3
);
for
(
j
=
0
,
cmpt
=
0
,
startheader
=
offset
+
s
->
sh
.
entry_point_offset
[
0
];
j
<
s
->
skipped_bytes
;
j
++
)
{
for
(
j
=
0
,
cmpt
=
0
,
startheader
=
offset
+
s
->
sh
.
entry_point_offset
[
0
];
j
<
nal
->
skipped_bytes
;
j
++
)
{
if
(
s
->
skipped_bytes_pos
[
j
]
>=
offset
&&
s
->
skipped_bytes_pos
[
j
]
<
startheader
)
{
if
(
s
->
skipped_bytes_pos
[
j
]
>=
offset
&&
s
->
skipped_bytes_pos
[
j
]
<
startheader
)
{
startheader
--
;
startheader
--
;
cmpt
++
;
cmpt
++
;
...
@@ -2462,7 +2464,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
...
@@ -2462,7 +2464,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
for
(
i
=
1
;
i
<
s
->
sh
.
num_entry_point_offsets
;
i
++
)
{
for
(
i
=
1
;
i
<
s
->
sh
.
num_entry_point_offsets
;
i
++
)
{
offset
+=
(
s
->
sh
.
entry_point_offset
[
i
-
1
]
-
cmpt
);
offset
+=
(
s
->
sh
.
entry_point_offset
[
i
-
1
]
-
cmpt
);
for
(
j
=
0
,
cmpt
=
0
,
startheader
=
offset
for
(
j
=
0
,
cmpt
=
0
,
startheader
=
offset
+
s
->
sh
.
entry_point_offset
[
i
];
j
<
s
->
skipped_bytes
;
j
++
)
{
+
s
->
sh
.
entry_point_offset
[
i
];
j
<
nal
->
skipped_bytes
;
j
++
)
{
if
(
s
->
skipped_bytes_pos
[
j
]
>=
offset
&&
s
->
skipped_bytes_pos
[
j
]
<
startheader
)
{
if
(
s
->
skipped_bytes_pos
[
j
]
>=
offset
&&
s
->
skipped_bytes_pos
[
j
]
<
startheader
)
{
startheader
--
;
startheader
--
;
cmpt
++
;
cmpt
++
;
...
@@ -2478,7 +2480,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
...
@@ -2478,7 +2480,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
s
->
sh
.
offset
[
s
->
sh
.
num_entry_point_offsets
-
1
]
=
offset
;
s
->
sh
.
offset
[
s
->
sh
.
num_entry_point_offsets
-
1
]
=
offset
;
}
}
s
->
data
=
nal
;
s
->
data
=
data
;
for
(
i
=
1
;
i
<
s
->
threads_number
;
i
++
)
{
for
(
i
=
1
;
i
<
s
->
threads_number
;
i
++
)
{
s
->
sList
[
i
]
->
HEVClc
->
first_qp_group
=
1
;
s
->
sList
[
i
]
->
HEVClc
->
first_qp_group
=
1
;
...
@@ -2720,7 +2722,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
...
@@ -2720,7 +2722,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
goto
fail
;
goto
fail
;
}
else
{
}
else
{
if
(
s
->
threads_number
>
1
&&
s
->
sh
.
num_entry_point_offsets
>
0
)
if
(
s
->
threads_number
>
1
&&
s
->
sh
.
num_entry_point_offsets
>
0
)
ctb_addr_ts
=
hls_slice_data_wpp
(
s
,
nal
->
data
,
nal
->
size
);
ctb_addr_ts
=
hls_slice_data_wpp
(
s
,
nal
);
else
else
ctb_addr_ts
=
hls_slice_data
(
s
);
ctb_addr_ts
=
hls_slice_data
(
s
);
if
(
ctb_addr_ts
>=
(
s
->
ps
.
sps
->
ctb_width
*
s
->
ps
.
sps
->
ctb_height
))
{
if
(
ctb_addr_ts
>=
(
s
->
ps
.
sps
->
ctb_width
*
s
->
ps
.
sps
->
ctb_height
))
{
...
@@ -2779,7 +2781,6 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
...
@@ -2779,7 +2781,6 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
/* decode the NAL units */
/* decode the NAL units */
for
(
i
=
0
;
i
<
s
->
pkt
.
nb_nals
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
pkt
.
nb_nals
;
i
++
)
{
s
->
skipped_bytes
=
s
->
skipped_bytes_nal
[
i
];
s
->
skipped_bytes_pos
=
s
->
skipped_bytes_pos_nal
[
i
];
s
->
skipped_bytes_pos
=
s
->
skipped_bytes_pos_nal
[
i
];
ret
=
decode_nal_unit
(
s
,
&
s
->
pkt
.
nals
[
i
]);
ret
=
decode_nal_unit
(
s
,
&
s
->
pkt
.
nals
[
i
]);
...
@@ -2974,7 +2975,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
...
@@ -2974,7 +2975,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
av_freep
(
&
s
->
skipped_bytes_pos_nal
[
i
]);
av_freep
(
&
s
->
skipped_bytes_pos_nal
[
i
]);
}
}
av_freep
(
&
s
->
skipped_bytes_pos_size_nal
);
av_freep
(
&
s
->
skipped_bytes_pos_size_nal
);
av_freep
(
&
s
->
skipped_bytes_nal
);
av_freep
(
&
s
->
skipped_bytes_pos_nal
);
av_freep
(
&
s
->
skipped_bytes_pos_nal
);
av_freep
(
&
s
->
cabac_state
);
av_freep
(
&
s
->
cabac_state
);
...
...
libavcodec/hevc.h
View file @
5620ed35
...
@@ -759,6 +759,8 @@ typedef struct HEVCNAL {
...
@@ -759,6 +759,8 @@ typedef struct HEVCNAL {
enum
NALUnitType
type
;
enum
NALUnitType
type
;
int
temporal_id
;
int
temporal_id
;
int
skipped_bytes
;
}
HEVCNAL
;
}
HEVCNAL
;
/* an input packet split into unescaped NAL units */
/* an input packet split into unescaped NAL units */
...
@@ -897,11 +899,9 @@ typedef struct HEVCContext {
...
@@ -897,11 +899,9 @@ typedef struct HEVCContext {
int
enable_parallel_tiles
;
int
enable_parallel_tiles
;
int
wpp_err
;
int
wpp_err
;
int
skipped_bytes
;
int
*
skipped_bytes_pos
;
int
*
skipped_bytes_pos
;
int
skipped_bytes_pos_size
;
int
skipped_bytes_pos_size
;
int
*
skipped_bytes_nal
;
int
**
skipped_bytes_pos_nal
;
int
**
skipped_bytes_pos_nal
;
int
*
skipped_bytes_pos_size_nal
;
int
*
skipped_bytes_pos_size_nal
;
...
...
libavcodec/hevc_parse.c
View file @
5620ed35
...
@@ -36,7 +36,7 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
...
@@ -36,7 +36,7 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
uint8_t
*
dst
;
uint8_t
*
dst
;
if
(
s
)
if
(
s
)
s
->
skipped_bytes
=
0
;
nal
->
skipped_bytes
=
0
;
#define STARTCODE_TEST \
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
if (src[i + 2] != 3) { \
...
@@ -111,8 +111,8 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
...
@@ -111,8 +111,8 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
si
+=
3
;
si
+=
3
;
if
(
s
)
{
if
(
s
)
{
s
->
skipped_bytes
++
;
nal
->
skipped_bytes
++
;
if
(
s
->
skipped_bytes_pos_size
<
s
->
skipped_bytes
)
{
if
(
s
->
skipped_bytes_pos_size
<
nal
->
skipped_bytes
)
{
s
->
skipped_bytes_pos_size
*=
2
;
s
->
skipped_bytes_pos_size
*=
2
;
av_reallocp_array
(
&
s
->
skipped_bytes_pos
,
av_reallocp_array
(
&
s
->
skipped_bytes_pos
,
s
->
skipped_bytes_pos_size
,
s
->
skipped_bytes_pos_size
,
...
@@ -121,7 +121,7 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
...
@@ -121,7 +121,7 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
if
(
s
->
skipped_bytes_pos
)
if
(
s
->
skipped_bytes_pos
)
s
->
skipped_bytes_pos
[
s
->
skipped_bytes
-
1
]
=
di
-
1
;
s
->
skipped_bytes_pos
[
nal
->
skipped_bytes
-
1
]
=
di
-
1
;
}
}
continue
;
continue
;
}
else
// next start code
}
else
// next start code
...
@@ -218,11 +218,6 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
...
@@ -218,11 +218,6 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
memset
(
pkt
->
nals
+
pkt
->
nals_allocated
,
0
,
memset
(
pkt
->
nals
+
pkt
->
nals_allocated
,
0
,
(
new_size
-
pkt
->
nals_allocated
)
*
sizeof
(
*
pkt
->
nals
));
(
new_size
-
pkt
->
nals_allocated
)
*
sizeof
(
*
pkt
->
nals
));
tmp
=
av_realloc_array
(
s
->
skipped_bytes_nal
,
new_size
,
sizeof
(
*
s
->
skipped_bytes_nal
));
if
(
!
tmp
)
return
AVERROR
(
ENOMEM
);
s
->
skipped_bytes_nal
=
tmp
;
tmp
=
av_realloc_array
(
s
->
skipped_bytes_pos_size_nal
,
new_size
,
sizeof
(
*
s
->
skipped_bytes_pos_size_nal
));
tmp
=
av_realloc_array
(
s
->
skipped_bytes_pos_size_nal
,
new_size
,
sizeof
(
*
s
->
skipped_bytes_pos_size_nal
));
if
(
!
tmp
)
if
(
!
tmp
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
...
@@ -248,7 +243,6 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
...
@@ -248,7 +243,6 @@ int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, in
if
(
consumed
<
0
)
if
(
consumed
<
0
)
return
consumed
;
return
consumed
;
s
->
skipped_bytes_nal
[
pkt
->
nb_nals
]
=
s
->
skipped_bytes
;
s
->
skipped_bytes_pos_size_nal
[
pkt
->
nb_nals
]
=
s
->
skipped_bytes_pos_size
;
s
->
skipped_bytes_pos_size_nal
[
pkt
->
nb_nals
]
=
s
->
skipped_bytes_pos_size
;
s
->
skipped_bytes_pos_nal
[
pkt
->
nb_nals
++
]
=
s
->
skipped_bytes_pos
;
s
->
skipped_bytes_pos_nal
[
pkt
->
nb_nals
++
]
=
s
->
skipped_bytes_pos
;
...
...
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