[vlc-devel] [PATCH 3/3] codec: avformat: handle SMPTE 436m (MXF CC)
Francois Cartegnie
fcvlcdev at free.fr
Tue Sep 26 23:24:27 CEST 2017
---
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 783220d..41a9c63 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -64,6 +64,11 @@ struct demux_sys_t
es_out_id_t **tk;
int64_t *tk_pcr;
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;
@@ -274,6 +279,7 @@ int OpenDemux( vlc_object_t *p_this )
p_sys->i_ssa_order = 0;
TAB_INIT( p_sys->i_attachments, p_sys->attachments);
p_sys->p_title = NULL;
+ 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 );
@@ -479,6 +485,20 @@ int 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_FOURCC('s', '4', '3', '6');
+ }
+ }
+ break;
+
default:
es_format_Init( &es_fmt, UNKNOWN_ES, 0 );
es_fmt.i_original_fourcc = CodecTagToFourcc( cp->codec_tag );
@@ -506,9 +526,6 @@ int 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;
@@ -524,7 +541,6 @@ int 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;
@@ -783,6 +799,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" ) )
{
@@ -803,6 +825,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 );
@@ -867,6 +895,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( int i = 0; i < p_sys->i_tk; i++ )
p_sys->tk_pcr[i] = i_time;
--
2.9.5
More information about the vlc-devel
mailing list