Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
953dd004
Commit
953dd004
authored
Jan 02, 2016
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packetizer: add AnnexB startcode helper
Improves startcode lookup by ~80% (statistically/zero dependent)
parent
0aebb95c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
6 deletions
+78
-6
modules/packetizer/Makefile.am
modules/packetizer/Makefile.am
+1
-1
modules/packetizer/h264.c
modules/packetizer/h264.c
+2
-1
modules/packetizer/hevc.c
modules/packetizer/hevc.c
+2
-1
modules/packetizer/mpeg4video.c
modules/packetizer/mpeg4video.c
+2
-1
modules/packetizer/mpegvideo.c
modules/packetizer/mpegvideo.c
+2
-1
modules/packetizer/startcode_helper.h
modules/packetizer/startcode_helper.h
+67
-0
modules/packetizer/vc1.c
modules/packetizer/vc1.c
+2
-1
No files found.
modules/packetizer/Makefile.am
View file @
953dd004
...
...
@@ -26,7 +26,7 @@ libpacketizer_avparser_plugin_la_CFLAGS = $(AVCODEC_CFLAGS) $(AVUTIL_CFLAGS) $(A
libpacketizer_avparser_plugin_la_LIBADD
=
$(AVCODEC_LIBS)
$(AVUTIL_LIBS)
$(LIBM)
noinst_HEADERS
+=
packetizer/packetizer_helper.h
noinst_HEADERS
+=
packetizer/packetizer_helper.h
packetizer/startcode_helper.h
packetizer_LTLIBRARIES
=
\
libpacketizer_mpegvideo_plugin.la
\
...
...
modules/packetizer/h264.c
View file @
953dd004
...
...
@@ -45,6 +45,7 @@
#include "hxxx_nal.h"
#include "hxxx_common.h"
#include "packetizer_helper.h"
#include "startcode_helper.h"
/*****************************************************************************
* Module descriptor
...
...
@@ -195,7 +196,7 @@ static int Open( vlc_object_t *p_this )
}
packetizer_Init
(
&
p_sys
->
packetizer
,
p_h264_startcode
,
sizeof
(
p_h264_startcode
),
NULL
,
p_h264_startcode
,
sizeof
(
p_h264_startcode
),
startcode_FindAnnexB
,
p_h264_startcode
,
1
,
5
,
PacketizeReset
,
PacketizeParse
,
PacketizeValidate
,
p_dec
);
...
...
modules/packetizer/hevc.c
View file @
953dd004
...
...
@@ -36,6 +36,7 @@
#include <vlc_block_helper.h>
#include "packetizer_helper.h"
#include "startcode_helper.h"
#include "hevc_nal.h"
#include "hxxx_nal.h"
#include "hxxx_common.h"
...
...
@@ -100,7 +101,7 @@ static int Open(vlc_object_t *p_this)
p_sys
->
pp_frame_last
=
&
p_sys
->
p_frame
;
packetizer_Init
(
&
p_dec
->
p_sys
->
packetizer
,
p_hevc_startcode
,
sizeof
(
p_hevc_startcode
),
NULL
,
p_hevc_startcode
,
sizeof
(
p_hevc_startcode
),
startcode_FindAnnexB
,
p_hevc_startcode
,
1
,
5
,
PacketizeReset
,
PacketizeParse
,
PacketizeValidate
,
p_dec
);
...
...
modules/packetizer/mpeg4video.c
View file @
953dd004
...
...
@@ -40,6 +40,7 @@
#include <vlc_bits.h>
#include <vlc_block_helper.h>
#include "packetizer_helper.h"
#include "startcode_helper.h"
/*****************************************************************************
* Module descriptor
...
...
@@ -142,7 +143,7 @@ static int Open( vlc_object_t *p_this )
/* Misc init */
packetizer_Init
(
&
p_sys
->
packetizer
,
p_mp4v_startcode
,
sizeof
(
p_mp4v_startcode
),
NULL
,
p_mp4v_startcode
,
sizeof
(
p_mp4v_startcode
),
startcode_FindAnnexB
,
NULL
,
0
,
4
,
PacketizeReset
,
PacketizeParse
,
PacketizeValidate
,
p_dec
);
...
...
modules/packetizer/mpegvideo.c
View file @
953dd004
...
...
@@ -53,6 +53,7 @@
#include <vlc_block_helper.h>
#include "../codec/cc.h"
#include "packetizer_helper.h"
#include "startcode_helper.h"
#define SYNC_INTRAFRAME_TEXT N_("Sync on Intra Frame")
#define SYNC_INTRAFRAME_LONGTEXT N_("Normally the packetizer would " \
...
...
@@ -168,7 +169,7 @@ static int Open( vlc_object_t *p_this )
/* Misc init */
packetizer_Init
(
&
p_sys
->
packetizer
,
p_mp2v_startcode
,
sizeof
(
p_mp2v_startcode
),
NULL
,
p_mp2v_startcode
,
sizeof
(
p_mp2v_startcode
),
startcode_FindAnnexB
,
NULL
,
0
,
4
,
PacketizeReset
,
PacketizeParse
,
PacketizeValidate
,
p_dec
);
...
...
modules/packetizer/startcode_helper.h
0 → 100644
View file @
953dd004
/*****************************************************************************
* startcode_helper.h: Startcodes helpers
*****************************************************************************
* Copyright (C) 2016 VideoLAN Authors
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _STARTCODE_HELPER_H
#define _STARTCODE_HELPER_H 1
/* Looks up efficiently for an AnnexB startcode 0x00 0x00 0x01
* by using a 4 times faster trick than single byte lookup.
*
* That code is adapted from libav's ff_avc_find_startcode_internal
* and i believe the trick originated from
* https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
*/
static
inline
const
uint8_t
*
startcode_FindAnnexB
(
const
uint8_t
*
p
,
const
uint8_t
*
end
)
{
const
uint8_t
*
a
=
p
+
4
-
((
intptr_t
)
p
&
3
);
for
(
end
-=
3
;
p
<
a
&&
p
<
end
;
p
++
)
{
if
(
p
[
0
]
==
0
&&
p
[
1
]
==
0
&&
p
[
2
]
==
1
)
return
p
;
}
for
(
end
-=
3
;
p
<
end
;
p
+=
4
)
{
uint32_t
x
=
*
(
const
uint32_t
*
)
p
;
if
((
x
-
0x01010101
)
&
(
~
x
)
&
0x80808080
)
{
/* matching DW isn't faster */
if
(
p
[
1
]
==
0
)
{
if
(
p
[
0
]
==
0
&&
p
[
2
]
==
1
)
return
p
;
if
(
p
[
2
]
==
0
&&
p
[
3
]
==
1
)
return
p
+
1
;
}
if
(
p
[
3
]
==
0
)
{
if
(
p
[
2
]
==
0
&&
p
[
4
]
==
1
)
return
p
+
2
;
if
(
p
[
4
]
==
0
&&
p
[
5
]
==
1
)
return
p
+
3
;
}
}
}
for
(
end
+=
3
;
p
<
end
;
p
++
)
{
if
(
p
[
0
]
==
0
&&
p
[
1
]
==
0
&&
p
[
2
]
==
1
)
return
p
;
}
return
NULL
;
}
#endif
modules/packetizer/vc1.c
View file @
953dd004
...
...
@@ -39,6 +39,7 @@
#include <vlc_block_helper.h>
#include "../codec/cc.h"
#include "packetizer_helper.h"
#include "startcode_helper.h"
/*****************************************************************************
* Module descriptor
...
...
@@ -155,7 +156,7 @@ static int Open( vlc_object_t *p_this )
return
VLC_ENOMEM
;
packetizer_Init
(
&
p_sys
->
packetizer
,
p_vc1_startcode
,
sizeof
(
p_vc1_startcode
),
NULL
,
p_vc1_startcode
,
sizeof
(
p_vc1_startcode
),
startcode_FindAnnexB
,
NULL
,
0
,
4
,
PacketizeReset
,
PacketizeParse
,
PacketizeValidate
,
p_dec
);
...
...
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