[vlc-commits] sout: sdi: reorder extracted captions
Francois Cartegnie
git at videolan.org
Wed Oct 10 09:47:11 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Oct 9 17:11:01 2018 +0200| [ca8bd065ea893362416e3bf89d16d3b0f903ac78] | committer: Francois Cartegnie
sout: sdi: reorder extracted captions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca8bd065ea893362416e3bf89d16d3b0f903ac78
---
modules/stream_out/sdi/SDIStream.cpp | 71 +++++++++++++++++++++++++++++++++++-
modules/stream_out/sdi/SDIStream.hpp | 20 +++++++++-
2 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/modules/stream_out/sdi/SDIStream.cpp b/modules/stream_out/sdi/SDIStream.cpp
index 9c477d34fa..0c5047dbaa 100644
--- a/modules/stream_out/sdi/SDIStream.cpp
+++ b/modules/stream_out/sdi/SDIStream.cpp
@@ -566,6 +566,71 @@ void AbstractRawStream::FlushQueued()
block_Release(p);
}
+
+AbstractReorderedStream::AbstractReorderedStream(vlc_object_t *p_obj, const StreamID &id,
+ AbstractStreamOutputBuffer *buffer)
+ : AbstractRawStream(p_obj, id, buffer)
+{
+ reorder_depth = 0;
+ do_reorder = false;
+}
+
+AbstractReorderedStream::~AbstractReorderedStream()
+{
+}
+
+int AbstractReorderedStream::Send(block_t *p_block)
+{
+ auto it = reorder.begin();
+ if(do_reorder)
+ {
+ for(; it != reorder.end(); ++it)
+ {
+ if((*it)->i_pts == VLC_TICK_INVALID)
+ continue;
+ if(p_block->i_pts < (*it)->i_pts)
+ {
+ /* found insertion point */
+ if(it == reorder.begin() &&
+ reorder_depth < 16 && reorder.size() < reorder_depth)
+ reorder_depth++;
+ break;
+ }
+ }
+
+ reorder.insert(it, p_block);
+
+ if(reorder.size() <= reorder_depth + 1)
+ return VLC_SUCCESS;
+
+ p_block = reorder.front();
+ reorder.pop_front();
+ }
+
+ return AbstractRawStream::Send(p_block);
+}
+
+void AbstractReorderedStream::Flush()
+{
+ Drain();
+ FlushQueued();
+}
+
+void AbstractReorderedStream::Drain()
+{
+ while(!reorder.empty())
+ {
+ AbstractRawStream::Send(reorder.front());
+ reorder.pop_front();
+ }
+}
+
+void AbstractReorderedStream::setReorder(size_t r)
+{
+ reorder_depth = r;
+ do_reorder = true;
+}
+
AudioCompressedStream::AudioCompressedStream(vlc_object_t *p_obj, const StreamID &id,
AbstractStreamOutputBuffer *buffer)
: AbstractRawStream(p_obj, id, buffer)
@@ -602,8 +667,9 @@ bool AudioCompressedStream::init(const es_format_t *fmt)
CaptionsStream::CaptionsStream(vlc_object_t *p_obj, const StreamID &id,
AbstractStreamOutputBuffer *buffer)
- : AbstractRawStream(p_obj, id, buffer)
+ : AbstractReorderedStream(p_obj, id, buffer)
{
+
}
CaptionsStream::~CaptionsStream()
@@ -612,5 +678,8 @@ CaptionsStream::~CaptionsStream()
bool CaptionsStream::init(const es_format_t *fmt)
{
+ if(fmt->subs.cc.i_reorder_depth >= 0)
+ setReorder(fmt->subs.cc.i_reorder_depth);
return (fmt->i_codec == VLC_CODEC_CEA608);
}
+
diff --git a/modules/stream_out/sdi/SDIStream.hpp b/modules/stream_out/sdi/SDIStream.hpp
index 4f962a247c..09ef279915 100644
--- a/modules/stream_out/sdi/SDIStream.hpp
+++ b/modules/stream_out/sdi/SDIStream.hpp
@@ -27,6 +27,7 @@
#include <queue>
#include <mutex>
#include <string>
+#include <list>
namespace sdi_sout
{
@@ -172,6 +173,23 @@ namespace sdi_sout
void FlushQueued();
};
+ class AbstractReorderedStream : public AbstractRawStream
+ {
+ public:
+ AbstractReorderedStream(vlc_object_t *, const StreamID &,
+ AbstractStreamOutputBuffer *);
+ virtual ~AbstractReorderedStream();
+ virtual int Send(block_t*); /* impl */
+ virtual void Flush(); /* impl */
+ virtual void Drain(); /* impl */
+ void setReorder(size_t);
+
+ protected:
+ std::list<block_t *> reorder;
+ size_t reorder_depth;
+ bool do_reorder;
+ };
+
class AudioCompressedStream : public AbstractRawStream
{
public:
@@ -182,7 +200,7 @@ namespace sdi_sout
virtual bool init(const es_format_t *); /* impl */
};
- class CaptionsStream : public AbstractRawStream
+ class CaptionsStream : public AbstractReorderedStream
{
public:
CaptionsStream(vlc_object_t *, const StreamID &,
More information about the vlc-commits
mailing list