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
d962b826
Commit
d962b826
authored
Jul 29, 2015
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
omxil: split timestamp helper to re-useable header
parent
deb4ea2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
74 deletions
+102
-74
include/vlc_timestamp_helper.h
include/vlc_timestamp_helper.h
+101
-0
modules/codec/omxil/mediacodec.c
modules/codec/omxil/mediacodec.c
+1
-74
No files found.
include/vlc_timestamp_helper.h
0 → 100644
View file @
d962b826
/*****************************************************************************
* vlc_timestamp_helper.h : timestamp handling helpers
*****************************************************************************
* Copyright (C) 2014 VLC authors and VideoLAN
* $Id$
*
* Authors: Felix Abecassis <felix.abecassis@gmail.com>
*
* 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 VLC_TIMESTAMP_H
#define VLC_TIMESTAMP_H 1
/* Implementation of a circular buffer of timestamps with overwriting
* of older values. MediaCodec has only one type of timestamp, if a
* block has no PTS, we send the DTS instead. Some hardware decoders
* cannot cope with this situation and output the frames in the wrong
* order. As a workaround in this case, we use a FIFO of timestamps in
* order to remember which input packets had no PTS. Since an
* hardware decoder can silently drop frames, this might cause a
* growing desynchronization with the actual timestamp. Thus the
* circular buffer has a limited size and will overwrite older values.
*/
typedef
struct
{
uint32_t
begin
;
uint32_t
size
;
uint32_t
capacity
;
int64_t
*
buffer
;
}
timestamp_fifo_t
;
static
inline
timestamp_fifo_t
*
timestamp_FifoNew
(
uint32_t
capacity
)
{
timestamp_fifo_t
*
fifo
=
calloc
(
1
,
sizeof
(
*
fifo
));
if
(
!
fifo
)
return
NULL
;
fifo
->
buffer
=
malloc
(
capacity
*
sizeof
(
*
fifo
->
buffer
));
if
(
!
fifo
->
buffer
)
{
free
(
fifo
);
return
NULL
;
}
fifo
->
capacity
=
capacity
;
return
fifo
;
}
static
inline
void
timestamp_FifoRelease
(
timestamp_fifo_t
*
fifo
)
{
free
(
fifo
->
buffer
);
free
(
fifo
);
}
static
inline
bool
timestamp_FifoIsEmpty
(
timestamp_fifo_t
*
fifo
)
{
return
fifo
->
size
==
0
;
}
static
inline
bool
timestamp_FifoIsFull
(
timestamp_fifo_t
*
fifo
)
{
return
fifo
->
size
==
fifo
->
capacity
;
}
static
inline
void
timestamp_FifoEmpty
(
timestamp_fifo_t
*
fifo
)
{
fifo
->
size
=
0
;
}
static
inline
void
timestamp_FifoPut
(
timestamp_fifo_t
*
fifo
,
int64_t
ts
)
{
uint32_t
end
=
(
fifo
->
begin
+
fifo
->
size
)
%
fifo
->
capacity
;
fifo
->
buffer
[
end
]
=
ts
;
if
(
!
timestamp_FifoIsFull
(
fifo
))
fifo
->
size
+=
1
;
else
fifo
->
begin
=
(
fifo
->
begin
+
1
)
%
fifo
->
capacity
;
}
static
inline
int64_t
timestamp_FifoGet
(
timestamp_fifo_t
*
fifo
)
{
if
(
timestamp_FifoIsEmpty
(
fifo
))
return
VLC_TS_INVALID
;
int64_t
result
=
fifo
->
buffer
[
fifo
->
begin
];
fifo
->
begin
=
(
fifo
->
begin
+
1
)
%
fifo
->
capacity
;
fifo
->
size
-=
1
;
return
result
;
}
#endif
modules/codec/omxil/mediacodec.c
View file @
d962b826
...
...
@@ -38,6 +38,7 @@
#include <vlc_block_helper.h>
#include <vlc_cpu.h>
#include <vlc_memory.h>
#include <vlc_timestamp_helper.h>
#include "mediacodec.h"
#include "../../packetizer/h264_nal.h"
...
...
@@ -51,80 +52,6 @@
/* JNI functions to get/set an Android Surface object. */
extern
void
jni_EventHardwareAccelerationError
();
// TODO REMOVE
/* Implementation of a circular buffer of timestamps with overwriting
* of older values. MediaCodec has only one type of timestamp, if a
* block has no PTS, we send the DTS instead. Some hardware decoders
* cannot cope with this situation and output the frames in the wrong
* order. As a workaround in this case, we use a FIFO of timestamps in
* order to remember which input packets had no PTS. Since an
* hardware decoder can silently drop frames, this might cause a
* growing desynchronization with the actual timestamp. Thus the
* circular buffer has a limited size and will overwrite older values.
*/
typedef
struct
{
uint32_t
begin
;
uint32_t
size
;
uint32_t
capacity
;
int64_t
*
buffer
;
}
timestamp_fifo_t
;
static
timestamp_fifo_t
*
timestamp_FifoNew
(
uint32_t
capacity
)
{
timestamp_fifo_t
*
fifo
=
calloc
(
1
,
sizeof
(
*
fifo
));
if
(
!
fifo
)
return
NULL
;
fifo
->
buffer
=
malloc
(
capacity
*
sizeof
(
*
fifo
->
buffer
));
if
(
!
fifo
->
buffer
)
{
free
(
fifo
);
return
NULL
;
}
fifo
->
capacity
=
capacity
;
return
fifo
;
}
static
void
timestamp_FifoRelease
(
timestamp_fifo_t
*
fifo
)
{
free
(
fifo
->
buffer
);
free
(
fifo
);
}
static
bool
timestamp_FifoIsEmpty
(
timestamp_fifo_t
*
fifo
)
{
return
fifo
->
size
==
0
;
}
static
bool
timestamp_FifoIsFull
(
timestamp_fifo_t
*
fifo
)
{
return
fifo
->
size
==
fifo
->
capacity
;
}
static
void
timestamp_FifoEmpty
(
timestamp_fifo_t
*
fifo
)
{
fifo
->
size
=
0
;
}
static
void
timestamp_FifoPut
(
timestamp_fifo_t
*
fifo
,
int64_t
ts
)
{
uint32_t
end
=
(
fifo
->
begin
+
fifo
->
size
)
%
fifo
->
capacity
;
fifo
->
buffer
[
end
]
=
ts
;
if
(
!
timestamp_FifoIsFull
(
fifo
))
fifo
->
size
+=
1
;
else
fifo
->
begin
=
(
fifo
->
begin
+
1
)
%
fifo
->
capacity
;
}
static
int64_t
timestamp_FifoGet
(
timestamp_fifo_t
*
fifo
)
{
if
(
timestamp_FifoIsEmpty
(
fifo
))
return
VLC_TS_INVALID
;
int64_t
result
=
fifo
->
buffer
[
fifo
->
begin
];
fifo
->
begin
=
(
fifo
->
begin
+
1
)
%
fifo
->
capacity
;
fifo
->
size
-=
1
;
return
result
;
}
/* Codec Specific Data */
struct
csd
{
...
...
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