# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_demux.h>
#include <vlc_stream.h>
#include <vlc_meta.h>
# include <libavformat/avformat.h>
#elif defined(HAVE_FFMPEG_AVFORMAT_H)
# include <ffmpeg/avformat.h>
-#elif defined(HAVE_LIBAVFORMAT_TREE)
-# include <avformat.h>
#endif
-#include "ffmpeg.h"
+#include "fourcc.h"
+#include "chroma.h"
//#define AVFORMAT_DEBUG 1
/* Version checking */
-#if defined(HAVE_LIBSWSCALE_SWSCALE_H) || defined(HAVE_LIBSWSCALE_SWSCALE_H) || defined(HAVE_FFMPEG_SWSCALE_H) || defined(HAVE_LIBSWSCALE_TREE)
+#if defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_AVFORMAT_H)
/*****************************************************************************
* demux_sys_t: demux descriptor
/*****************************************************************************
* Open
*****************************************************************************/
-int E_(OpenDemux)( vlc_object_t *p_this )
+int OpenDemux( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
AVProbeData pd;
AVInputFormat *fmt;
- int i;
- vlc_bool_t b_avfmt_nofile;
+ unsigned int i;
+ bool b_avfmt_nofile;
/* Init Probe data */
pd.filename = p_demux->psz_path;
{
msg_Err( p_demux, "av_open_input_stream failed" );
if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
- E_(CloseDemux)( p_this );
+ CloseDemux( p_this );
return VLC_EGENERIC;
}
{
msg_Err( p_demux, "av_find_stream_info failed" );
if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
- E_(CloseDemux)( p_this );
+ CloseDemux( p_this );
return VLC_EGENERIC;
}
if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
es_format_t fmt;
vlc_fourcc_t fcc;
- if( !E_(GetVlcFourcc)( cc->codec_id, NULL, &fcc, NULL ) )
+ if( !GetVlcFourcc( cc->codec_id, NULL, &fcc, NULL ) )
{
fcc = VLC_FOURCC( 'u', 'n', 'd', 'f' );
if( cc->codec_id == CODEC_ID_RAWVIDEO )
{
msg_Dbg( p_demux, "raw video, pixel format: %i", cc->pix_fmt );
- fcc = E_(GetVlcChroma)( cc->pix_fmt );
+ fcc = GetVlcChroma( cc->pix_fmt );
}
}
msg_Dbg( p_demux, "AVFormat supported stream" );
msg_Dbg( p_demux, " - format = %s (%s)",
p_sys->fmt->name, p_sys->fmt->long_name );
- msg_Dbg( p_demux, " - start time = "I64Fd,
+ msg_Dbg( p_demux, " - start time = %"PRId64,
( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE ) ?
p_sys->ic->start_time * 1000000 / AV_TIME_BASE : -1 );
- msg_Dbg( p_demux, " - duration = "I64Fd,
+ msg_Dbg( p_demux, " - duration = %"PRId64,
( p_sys->ic->duration != (int64_t)AV_NOPTS_VALUE ) ?
p_sys->ic->duration * 1000000 / AV_TIME_BASE : -1 );
/*****************************************************************************
* Close
*****************************************************************************/
-void E_(CloseDemux)( vlc_object_t *p_this )
+void CloseDemux( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
- vlc_bool_t b_avfmt_nofile;
+ bool b_avfmt_nofile;
FREENULL( p_sys->tk );
if( p_sys->ic ) av_close_input_file( p_sys->ic );
if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
- if( p_sys->io_buffer ) free( p_sys->io_buffer );
+ free( p_sys->io_buffer );
free( p_sys );
}
memcpy( p_frame->p_buffer, pkt.data, pkt.size );
+ if( pkt.flags & PKT_FLAG_KEY )
+ p_frame->i_flags |= BLOCK_FLAG_TYPE_I;
+
i_start_time = ( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE ) ?
- p_sys->ic->start_time : 0;
+ ( p_sys->ic->start_time / AV_TIME_BASE ) : 0;
p_frame->i_dts = ( pkt.dts == (int64_t)AV_NOPTS_VALUE ) ?
0 : (pkt.dts - i_start_time) * 1000000 *
p_sys->ic->streams[pkt.stream_index]->time_base.den;
#ifdef AVFORMAT_DEBUG
- msg_Dbg( p_demux, "tk[%d] dts="I64Fd" pts="I64Fd,
+ msg_Dbg( p_demux, "tk[%d] dts=%"PRId64" pts=%"PRId64,
pkt.stream_index, p_frame->i_dts, p_frame->i_pts );
#endif
if( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE )
i64 += p_sys->ic->start_time;
- msg_Warn( p_demux, "DEMUX_SET_POSITION: "I64Fd, i64 );
+ msg_Warn( p_demux, "DEMUX_SET_POSITION: %"PRId64, i64 );
/* If we have a duration, we prefer to seek by time
but if we don't, or if the seek fails, try BYTE seeking */
int64_t i_size = stream_Size( p_demux->s );
i64 = (int64_t)i_size * f;
- msg_Warn( p_demux, "DEMUX_SET_BYTE_POSITION: "I64Fd, i64 );
+ msg_Warn( p_demux, "DEMUX_SET_BYTE_POSITION: %"PRId64, i64 );
if( av_seek_frame( p_sys->ic, -1, i64, AVSEEK_FLAG_BYTE ) < 0 )
return VLC_EGENERIC;
}
if( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE )
i64 += p_sys->ic->start_time;
- msg_Warn( p_demux, "DEMUX_SET_TIME: "I64Fd, i64 );
+ msg_Warn( p_demux, "DEMUX_SET_TIME: %"PRId64, i64 );
if( av_seek_frame( p_sys->ic, -1, i64, 0 ) < 0 )
{
int64_t i_size = stream_Size( p_demux->s );
#ifdef AVFORMAT_DEBUG
- msg_Warn( p_demux, "IOSeek offset: "I64Fd", whence: %i", offset, whence );
+ msg_Warn( p_demux, "IOSeek offset: %"PRId64", whence: %i", offset, whence );
#endif
switch( whence )
}
if( i_absolute < 0 )
i_absolute = 0;
- if( i_size && i_absolute > i_size )
- i_absolute = i_size;
+ if( i_size )
+ {
+ if( i_absolute > i_size )
+ i_absolute = i_size;
+ if( stream_Tell( p_demux->s ) >= i_size )
+ {
+ msg_Err( p_demux, "Seeking too far : EOF?" );
+ return -1;
+ }
+ }
if( stream_Seek( p_demux->s, i_absolute ) )
{