summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_lavf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpdemux/demux_lavf.c')
-rw-r--r--libmpdemux/demux_lavf.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index a718fe6a54..921f9decc4 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -22,8 +22,10 @@
#include <stdlib.h>
// #include <unistd.h>
#include <limits.h>
+#include <stdbool.h>
#include "config.h"
+#include "options.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "av_opts.h"
@@ -46,9 +48,6 @@
#define INITIAL_PROBE_SIZE (32*1024)
#define PROBE_BUF_SIZE (2*1024*1024)
-extern char *audio_lang;
-extern char *dvdsub_lang;
-extern int dvdsub_id;
static unsigned int opt_probesize = 0;
static unsigned int opt_analyzeduration = 0;
static char *opt_format;
@@ -236,8 +235,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
AVStream *st= avfc->streams[i];
AVCodecContext *codec= st->codec;
AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0);
- int g, override_tag = av_codec_get_tag(mp_codecid_override_taglists,
- codec->codec_id);
+ int g, override_tag = mp_av_codec_get_tag(mp_codecid_override_taglists,
+ codec->codec_id);
// For some formats (like PCM) always trust CODEC_ID_* more than codec_tag
if (override_tag)
codec->codec_tag = override_tag;
@@ -247,7 +246,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
WAVEFORMATEX *wf;
sh_audio_t* sh_audio;
sh_audio=new_sh_audio(demuxer, i);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "lavf", i);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "lavf", i);
if(!sh_audio)
break;
priv->astreams[priv->audio_streams] = i;
@@ -257,7 +256,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
if(codec->codec_tag == MKTAG('m', 'p', '4', 'a'))
codec->codec_tag= 0;
if(!codec->codec_tag)
- codec->codec_tag= av_codec_get_tag(mp_wav_taglists, codec->codec_id);
+ codec->codec_tag= mp_av_codec_get_tag(mp_wav_taglists, codec->codec_id);
wf->wFormatTag= codec->codec_tag;
wf->nChannels= codec->channels;
wf->nSamplesPerSec= codec->sample_rate;
@@ -322,7 +321,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
sh_video_t* sh_video;
BITMAPINFOHEADER *bih;
sh_video=new_sh_video(demuxer, i);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "lavf", i);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "lavf", i);
if(!sh_video) break;
priv->vstreams[priv->video_streams] = i;
priv->video_streams++;
@@ -335,7 +334,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
}
}
if(!codec->codec_tag)
- codec->codec_tag= av_codec_get_tag(mp_bmp_taglists, codec->codec_id);
+ codec->codec_tag= mp_av_codec_get_tag(mp_bmp_taglists, codec->codec_id);
bih->biSize= sizeof(BITMAPINFOHEADER) + codec->extradata_size;
bih->biWidth= codec->width;
bih->biHeight= codec->height;
@@ -402,7 +401,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
else
break;
sh_sub = new_sh_sub_sid(demuxer, i, priv->sub_streams);
- mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_SubtitleID, "lavf", priv->sub_streams);
+ mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Subtitle stream found, -sid %d\n", "lavf", priv->sub_streams);
if(!sh_sub) break;
priv->sstreams[priv->sub_streams] = i;
sh_sub->type = type;
@@ -422,8 +421,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
}
case CODEC_TYPE_ATTACHMENT:{
if (st->codec->codec_id == CODEC_ID_TTF)
- demuxer_add_attachment(demuxer, st->filename,
- "application/x-truetype-font",
+ demuxer_add_attachment(demuxer, st->filename, INT_MAX,
+ "application/x-truetype-font", INT_MAX,
codec->extradata, codec->extradata_size);
break;
}
@@ -433,6 +432,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
}
static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
+ struct MPOpts *opts = demuxer->opts;
AVFormatContext *avfc;
AVFormatParameters ap;
const AVOption *opt;
@@ -449,7 +449,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
if (opt_cryptokey)
parse_cryptokey(avfc, opt_cryptokey);
- if (user_correct_pts != 0)
+ if (opts->user_correct_pts != 0)
avfc->flags |= AVFMT_FLAG_GENPTS;
if (index_mode == 0)
avfc->flags |= AVFMT_FLAG_IGNIDX;
@@ -505,7 +505,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
uint64_t start = av_rescale_q(c->start, c->time_base, (AVRational){1,1000});
uint64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,1000});
t = av_metadata_get(c->metadata, "title", NULL, 0);
- demuxer_add_chapter(demuxer, t ? t->value : NULL, start, end);
+ demuxer_add_chapter(demuxer, t ? t->value : NULL, INT_MAX, start, end);
}
for(i=0; i<avfc->nb_streams; i++)
@@ -531,6 +531,8 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
demuxer->video->id=-2; // audio-only
} //else if (best_video > 0 && demuxer->video->id == -1) demuxer->video->id = best_video;
+ demuxer->accurate_seek = true;
+
return demuxer;
}
@@ -606,10 +608,14 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, float audio
mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %f, %d)\n", demuxer, rel_seek_secs, audio_delay, flags);
if (flags & SEEK_ABSOLUTE) {
- priv->last_pts = priv->avfc->start_time;
+ priv->last_pts = 0;
} else {
if (rel_seek_secs < 0) avsflags = AVSEEK_FLAG_BACKWARD;
}
+ if (flags & SEEK_FORWARD)
+ avsflags = 0;
+ else if (flags & SEEK_BACKWARD)
+ avsflags = AVSEEK_FLAG_BACKWARD;
if (flags & SEEK_FACTOR) {
if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)
return;
@@ -629,9 +635,6 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
switch (cmd) {
case DEMUXER_CTRL_CORRECT_PTS:
- if (!strcmp("matroska", priv->avif->name) ||
- !strcmp("mpegts", priv->avif->name))
- return DEMUXER_CTRL_NOTIMPL;
return DEMUXER_CTRL_OK;
case DEMUXER_CTRL_GET_TIME_LENGTH:
if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)