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
7502a03b
Commit
7502a03b
authored
Mar 17, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mux: mp4: handle both short and long NALU startcodes (fix #14185)
parent
e9b6ca56
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
4 deletions
+47
-4
modules/mux/mp4.c
modules/mux/mp4.c
+47
-4
No files found.
modules/mux/mp4.c
View file @
7502a03b
...
@@ -215,6 +215,7 @@ static bo_t *GetMoovBox(sout_mux_t *p_mux);
...
@@ -215,6 +215,7 @@ static bo_t *GetMoovBox(sout_mux_t *p_mux);
static
block_t
*
ConvertSUBT
(
block_t
*
);
static
block_t
*
ConvertSUBT
(
block_t
*
);
static
block_t
*
ConvertFromAnnexB
(
block_t
*
);
static
block_t
*
ConvertFromAnnexB
(
block_t
*
);
static
const
char
avc1_short_start_code
[
3
]
=
{
0
,
0
,
1
};
static
const
char
avc1_start_code
[
4
]
=
{
0
,
0
,
0
,
1
};
static
const
char
avc1_start_code
[
4
]
=
{
0
,
0
,
0
,
1
};
/*****************************************************************************
/*****************************************************************************
...
@@ -735,17 +736,59 @@ static block_t *ConvertSUBT(block_t *p_block)
...
@@ -735,17 +736,59 @@ static block_t *ConvertSUBT(block_t *p_block)
static
block_t
*
ConvertFromAnnexB
(
block_t
*
p_block
)
static
block_t
*
ConvertFromAnnexB
(
block_t
*
p_block
)
{
{
uint8_t
*
last
=
p_block
->
p_buffer
;
/* Assume it starts with 0x00000001 */
if
(
p_block
->
i_buffer
<
4
)
{
block_Release
(
p_block
);
return
NULL
;
}
if
(
memcmp
(
p_block
->
p_buffer
,
avc1_start_code
,
4
))
{
if
(
!
memcmp
(
p_block
->
p_buffer
,
avc1_short_start_code
,
3
))
{
p_block
=
block_Realloc
(
p_block
,
1
,
p_block
->
i_buffer
);
if
(
!
p_block
)
return
NULL
;
}
else
/* No startcode on start */
{
block_Release
(
p_block
);
return
NULL
;
}
}
uint8_t
*
last
=
p_block
->
p_buffer
;
uint8_t
*
dat
=
&
p_block
->
p_buffer
[
4
];
uint8_t
*
dat
=
&
p_block
->
p_buffer
[
4
];
uint8_t
*
end
=
&
p_block
->
p_buffer
[
p_block
->
i_buffer
];
uint8_t
*
end
=
&
p_block
->
p_buffer
[
p_block
->
i_buffer
];
/* Replace the 4 bytes start code with 4 bytes size */
/* Replace the 4 bytes start code with 4 bytes size,
* FIXME are all startcodes 4 bytes ? (I don't think :(*/
while
(
dat
<
end
)
{
while
(
dat
<
end
)
{
while
(
dat
<
end
-
4
)
{
while
(
dat
<
end
-
4
)
{
if
(
!
memcmp
(
dat
,
avc1_start_code
,
4
))
if
(
!
memcmp
(
dat
,
avc1_start_code
,
4
))
{
break
;
}
else
if
(
!
memcmp
(
dat
,
avc1_short_start_code
,
3
))
{
/* save offsets as we don't know if realloc will replace buffer */
size_t
i_last
=
last
-
p_block
->
p_buffer
;
size_t
i_dat
=
dat
-
p_block
->
p_buffer
;
size_t
i_end
=
end
-
p_block
->
p_buffer
;
p_block
=
block_Realloc
(
p_block
,
0
,
p_block
->
i_buffer
+
1
);
if
(
!
p_block
)
return
NULL
;
/* restore offsets */
last
=
&
p_block
->
p_buffer
[
i_last
];
dat
=
&
p_block
->
p_buffer
[
i_dat
];
end
=
&
p_block
->
p_buffer
[
i_end
];
/* Shift data */
memmove
(
&
dat
[
4
],
&
dat
[
3
],
end
-
&
dat
[
3
]);
end
++
;
break
;
break
;
}
dat
++
;
dat
++
;
}
}
if
(
dat
>=
end
-
4
)
if
(
dat
>=
end
-
4
)
...
...
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