Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
69ab9f53
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69ab9f53
编写于
6月 30, 2015
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hevc: split bitstream unescaping to a separate file
It will be useful in the QSV HEVC encoder.
上级
fd124d83
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
137 addition
and
103 deletion
+137
-103
libavcodec/Makefile
libavcodec/Makefile
+1
-1
libavcodec/hevc.c
libavcodec/hevc.c
+1
-102
libavcodec/hevc.h
libavcodec/hevc.h
+6
-0
libavcodec/hevc_parse.c
libavcodec/hevc_parse.c
+129
-0
未找到文件。
libavcodec/Makefile
浏览文件 @
69ab9f53
...
...
@@ -240,7 +240,7 @@ OBJS-$(CONFIG_HAP_DECODER) += hapdec.o
OBJS-$(CONFIG_HAP_ENCODER)
+=
hapenc.o
OBJS-$(CONFIG_HEVC_DECODER)
+=
hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o
\
hevc_cabac.o hevc_refs.o hevcpred.o
\
hevcdsp.o hevc_filter.o
hevcdsp.o hevc_filter.o
hevc_parse.o
OBJS-$(CONFIG_HEVC_NVENC_ENCODER)
+=
nvenc_hevc.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER)
+=
hnm4video.o
OBJS-$(CONFIG_HQ_HQA_DECODER)
+=
hq_hqa.o hq_hqadata.o hq_hqadsp.o
\
...
...
libavcodec/hevc.c
浏览文件 @
69ab9f53
...
...
@@ -2643,107 +2643,6 @@ fail:
return
0
;
}
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
* between these functions would be nice. */
static
int
extract_rbsp
(
const
uint8_t
*
src
,
int
length
,
HEVCNAL
*
nal
)
{
int
i
,
si
,
di
;
uint8_t
*
dst
;
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
/* startcode, so we must be past the end */
\
length = i; \
} \
break; \
}
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
if (i > 0 && !src[i]) \
i--; \
while (src[i]) \
i++
#if HAVE_FAST_64BIT
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
9
)
{
if
(
!
((
~
AV_RN64A
(
src
+
i
)
&
(
AV_RN64A
(
src
+
i
)
-
0x0100010001000101ULL
))
&
0x8000800080008080ULL
))
continue
;
FIND_FIRST_ZERO
;
STARTCODE_TEST
;
i
-=
7
;
}
#else
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
5
)
{
if
(
!
((
~
AV_RN32A
(
src
+
i
)
&
(
AV_RN32A
(
src
+
i
)
-
0x01000101U
))
&
0x80008080U
))
continue
;
FIND_FIRST_ZERO
;
STARTCODE_TEST
;
i
-=
3
;
}
#endif
/* HAVE_FAST_64BIT */
#else
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
2
)
{
if
(
src
[
i
])
continue
;
if
(
i
>
0
&&
src
[
i
-
1
]
==
0
)
i
--
;
STARTCODE_TEST
;
}
#endif
/* HAVE_FAST_UNALIGNED */
if
(
i
>=
length
-
1
)
{
// no escaped 0
nal
->
data
=
nal
->
raw_data
=
src
;
nal
->
size
=
nal
->
raw_size
=
length
;
return
length
;
}
av_fast_malloc
(
&
nal
->
rbsp_buffer
,
&
nal
->
rbsp_buffer_size
,
length
+
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
nal
->
rbsp_buffer
)
return
AVERROR
(
ENOMEM
);
dst
=
nal
->
rbsp_buffer
;
memcpy
(
dst
,
src
,
i
);
si
=
di
=
i
;
while
(
si
+
2
<
length
)
{
// remove escapes (very rare 1:2^22)
if
(
src
[
si
+
2
]
>
3
)
{
dst
[
di
++
]
=
src
[
si
++
];
dst
[
di
++
]
=
src
[
si
++
];
}
else
if
(
src
[
si
]
==
0
&&
src
[
si
+
1
]
==
0
)
{
if
(
src
[
si
+
2
]
==
3
)
{
// escape
dst
[
di
++
]
=
0
;
dst
[
di
++
]
=
0
;
si
+=
3
;
continue
;
}
else
// next start code
goto
nsc
;
}
dst
[
di
++
]
=
src
[
si
++
];
}
while
(
si
<
length
)
dst
[
di
++
]
=
src
[
si
++
];
nsc:
memset
(
dst
+
di
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
nal
->
data
=
dst
;
nal
->
size
=
di
;
nal
->
raw_data
=
src
;
nal
->
raw_size
=
si
;
return
si
;
}
static
int
decode_nal_units
(
HEVCContext
*
s
,
const
uint8_t
*
buf
,
int
length
)
{
int
i
,
consumed
,
ret
=
0
;
...
...
@@ -2800,7 +2699,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
}
nal
=
&
s
->
nals
[
s
->
nb_nals
++
];
consumed
=
extract_rbsp
(
buf
,
extract_length
,
nal
);
consumed
=
ff_hevc_
extract_rbsp
(
buf
,
extract_length
,
nal
);
if
(
consumed
<
0
)
{
ret
=
consumed
;
goto
fail
;
...
...
libavcodec/hevc.h
浏览文件 @
69ab9f53
...
...
@@ -1002,6 +1002,12 @@ void ff_hevc_pps_free(HEVCPPS **ppps);
void
ff_hevc_pred_init
(
HEVCPredContext
*
hpc
,
int
bit_depth
);
/**
* Extract the raw (unescaped) HEVC bitstream.
*/
int
ff_hevc_extract_rbsp
(
const
uint8_t
*
src
,
int
length
,
HEVCNAL
*
nal
);
extern
const
uint8_t
ff_hevc_qpel_extra_before
[
4
];
extern
const
uint8_t
ff_hevc_qpel_extra_after
[
4
];
extern
const
uint8_t
ff_hevc_qpel_extra
[
4
];
...
...
libavcodec/hevc_parse.c
0 → 100644
浏览文件 @
69ab9f53
/*
* HEVC common code
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include "config.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "hevc.h"
/* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
* between these functions would be nice. */
int
ff_hevc_extract_rbsp
(
const
uint8_t
*
src
,
int
length
,
HEVCNAL
*
nal
)
{
int
i
,
si
,
di
;
uint8_t
*
dst
;
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
/* startcode, so we must be past the end */
\
length = i; \
} \
break; \
}
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
if (i > 0 && !src[i]) \
i--; \
while (src[i]) \
i++
#if HAVE_FAST_64BIT
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
9
)
{
if
(
!
((
~
AV_RN64A
(
src
+
i
)
&
(
AV_RN64A
(
src
+
i
)
-
0x0100010001000101ULL
))
&
0x8000800080008080ULL
))
continue
;
FIND_FIRST_ZERO
;
STARTCODE_TEST
;
i
-=
7
;
}
#else
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
5
)
{
if
(
!
((
~
AV_RN32A
(
src
+
i
)
&
(
AV_RN32A
(
src
+
i
)
-
0x01000101U
))
&
0x80008080U
))
continue
;
FIND_FIRST_ZERO
;
STARTCODE_TEST
;
i
-=
3
;
}
#endif
/* HAVE_FAST_64BIT */
#else
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
2
)
{
if
(
src
[
i
])
continue
;
if
(
i
>
0
&&
src
[
i
-
1
]
==
0
)
i
--
;
STARTCODE_TEST
;
}
#endif
/* HAVE_FAST_UNALIGNED */
if
(
i
>=
length
-
1
)
{
// no escaped 0
nal
->
data
=
nal
->
raw_data
=
src
;
nal
->
size
=
nal
->
raw_size
=
length
;
return
length
;
}
av_fast_malloc
(
&
nal
->
rbsp_buffer
,
&
nal
->
rbsp_buffer_size
,
length
+
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
nal
->
rbsp_buffer
)
return
AVERROR
(
ENOMEM
);
dst
=
nal
->
rbsp_buffer
;
memcpy
(
dst
,
src
,
i
);
si
=
di
=
i
;
while
(
si
+
2
<
length
)
{
// remove escapes (very rare 1:2^22)
if
(
src
[
si
+
2
]
>
3
)
{
dst
[
di
++
]
=
src
[
si
++
];
dst
[
di
++
]
=
src
[
si
++
];
}
else
if
(
src
[
si
]
==
0
&&
src
[
si
+
1
]
==
0
)
{
if
(
src
[
si
+
2
]
==
3
)
{
// escape
dst
[
di
++
]
=
0
;
dst
[
di
++
]
=
0
;
si
+=
3
;
continue
;
}
else
// next start code
goto
nsc
;
}
dst
[
di
++
]
=
src
[
si
++
];
}
while
(
si
<
length
)
dst
[
di
++
]
=
src
[
si
++
];
nsc:
memset
(
dst
+
di
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
nal
->
data
=
dst
;
nal
->
size
=
di
;
nal
->
raw_data
=
src
;
nal
->
raw_size
=
si
;
return
si
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录