[vlc-devel] [PATCH 3/3] codec: avformat: handle SMPTE 436m (MXF CC)
Francois Cartegnie
fcvlcdev at free.fr
Tue Mar 6 11:39:12 CET 2018
---
modules/demux/avformat/demux.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 2538f79f15..18212a5796 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -69,6 +69,11 @@ struct demux_sys_t
struct avformat_track_s *tracks;
int64_t i_pcr;
+ struct
+ {
+ int64_t i_dts; /* keep track of frame as there's no timing for data */
+ int64_t i_pts;
+ } metadata;
unsigned i_ssa_order;
@@ -280,6 +285,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
p_sys->p_title = NULL;
p_sys->i_seekpoint = 0;
p_sys->i_update = 0;
+ p_sys->metadata.i_dts = p_sys->metadata.i_pts = VLC_TS_INVALID;
/* Create I/O wrapper */
unsigned char * p_io_buffer = av_malloc( AVFORMAT_IOBUFFER_SIZE );
@@ -511,6 +517,20 @@ int avformat_OpenDemux( vlc_object_t *p_this )
psz_type = "subtitle";
break;
+ case AVMEDIA_TYPE_DATA:
+ {
+ es_format_Init( &es_fmt, DATA_ES, 0 );
+ psz_type = "data";
+ AVDictionaryEntry *meta = av_dict_get(s->metadata, "data_type", NULL, AV_DICT_MATCH_CASE );
+ if( meta && meta->value && !strcmp( meta->value, "vbi_vanc_smpte_436M" ) )
+ {
+ es_fmt.psz_description = strdup( meta->value );
+ psz_type = meta->value;
+ es_fmt.i_codec = VLC_CODEC_SMPTE_436M;
+ }
+ }
+ break;
+
default:
es_format_Init( &es_fmt, UNKNOWN_ES, 0 );
es_fmt.i_original_fourcc = CodecTagToFourcc( cp->codec_tag );
@@ -538,9 +558,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
else
#endif
{
- if( cp->codec_type == AVMEDIA_TYPE_DATA )
- psz_type = "data";
-
msg_Warn( p_demux, "unsupported track type (%u:%u) in avformat demux", cp->codec_type, cp->codec_id );
}
break;
@@ -556,7 +573,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
#ifdef HAVE_AVUTIL_CODEC_ATTACHMENT
if( cp->codec_type != AVMEDIA_TYPE_ATTACHMENT )
#endif
- if( cp->codec_type != AVMEDIA_TYPE_DATA )
{
const bool b_ogg = !strcmp( p_sys->fmt->name, "ogg" );
const uint8_t *p_extra = cp->extradata;
@@ -826,6 +842,12 @@ static int Demux( demux_t *p_demux )
p_stream->time_base.num /
p_stream->time_base.den;
+ if( p_stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO )
+ {
+ p_sys->metadata.i_dts = p_frame->i_dts;
+ p_sys->metadata.i_pts = p_frame->i_pts;
+ }
+
/* Add here notoriously bugged file formats/samples */
if( !strcmp( p_sys->fmt->name, "flv" ) )
{
@@ -846,6 +868,12 @@ static int Demux( demux_t *p_demux )
}
}
}
+ else if( p_stream->codecpar->codec_type == AVMEDIA_TYPE_DATA &&
+ p_frame->i_dts == VLC_TS_INVALID )
+ {
+ p_frame->i_dts = p_sys->metadata.i_dts;
+ p_frame->i_pts = p_sys->metadata.i_dts;
+ }
#ifdef AVFORMAT_DEBUG
msg_Dbg( p_demux, "tk[%d] dts=%"PRId64" pts=%"PRId64,
pkt.stream_index, p_frame->i_dts, p_frame->i_pts );
@@ -915,6 +943,7 @@ static void ResetTime( demux_t *p_demux, int64_t i_time )
else if( i_time == 0 )
i_time = 1;
+ p_sys->metadata.i_dts = p_sys->metadata.i_pts = VLC_TS_INVALID;
p_sys->i_pcr = i_time;
for( unsigned i = 0; i < p_sys->ic->nb_streams; i++ )
p_sys->tracks[i].i_pcr = VLC_TS_INVALID;
--
2.14.3
More information about the vlc-devel
mailing list