[FFmpeg-soc] [soc]: r4556 - in concat/libavformat: m3u.c playlist.c playlist.h
gkovacs
subversion at mplayerhq.hu
Wed Jul 1 03:45:05 CEST 2009
Author: gkovacs
Date: Wed Jul 1 03:45:05 2009
New Revision: 4556
Log:
seperate audio and video stream switching times
Modified:
concat/libavformat/m3u.c
concat/libavformat/playlist.c
concat/libavformat/playlist.h
Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c Wed Jul 1 03:25:57 2009 (r4555)
+++ concat/libavformat/m3u.c Wed Jul 1 03:45:05 2009 (r4556)
@@ -86,7 +86,7 @@ static int m3u_list_files(ByteIOContext
static int m3u_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- printf("m3u read header called\n");
+ int i;
PlaylistD *playld = ff_make_playlistd(s->filename);
m3u_list_files(s->pb,
&(playld->flist),
@@ -95,7 +95,9 @@ static int m3u_read_header(AVFormatConte
playld->pelist = av_malloc(playld->pelist_size * sizeof(PlayElem*));
memset(playld->pelist, 0, playld->pelist_size * sizeof(PlayElem*));
s->priv_data = playld;
- ff_playlist_populate_context(playld, s);
+ for (i = 0; i < playld->pe_curidxs_size; ++i) {
+ ff_playlist_populate_context(playld, s, i);
+ }
return 0;
}
@@ -104,12 +106,18 @@ static int m3u_read_packet(AVFormatConte
{
int i;
int ret;
+ int stream_index;
PlaylistD *playld;
AVFormatContext *ic;
playld = s->priv_data;
+ stream_index = 0;
retr:
- ic = playld->pelist[playld->pe_curidx]->ic;
+ ic = playld->pelist[playld->pe_curidxs[0]]->ic;
ret = ic->iformat->read_packet(ic, pkt);
+ if (pkt) {
+ stream_index = pkt->stream_index;
+ ic = playld->pelist[playld->pe_curidxs[stream_index]]->ic;
+ }
if (ret >= 0) {
if (pkt) {
pkt->dts += ff_conv_stream_time(ic, pkt->stream_index, playld->time_offsets[pkt->stream_index]);
@@ -117,7 +125,7 @@ static int m3u_read_packet(AVFormatConte
}
// TODO switch from AVERROR_EOF to AVERROR_EOS
// -32 AVERROR_EOF for avi, -51 for ogg
- else if (ret < 0 && playld->pe_curidx < playld->pelist_size - 1) {
+ else if (ret < 0 && playld->pe_curidxs[stream_index] < playld->pelist_size - 1) {
// TODO account for out-of-sync audio/video by using per-stream offsets
// using streams[]->duration slightly overestimates offset
// playld->dts_offset += ic->streams[0]->duration;
@@ -128,10 +136,12 @@ static int m3u_read_packet(AVFormatConte
for (i = 0; i < ic->nb_streams && i < playld->time_offsets_size; ++i) {
playld->time_offsets[i] += ff_get_duration(ic, i);
}
- ++playld->pe_curidx;
+ ++playld->pe_curidxs[stream_index];
// pkt->destruct(pkt);
pkt = av_malloc(sizeof(AVPacket));
- ff_playlist_populate_context(playld, s);
+// for (i = 0; i < playld->pe_curidxs_size; ++i) {
+ ff_playlist_populate_context(playld, s, stream_index);
+// }
goto retr;
}
else {
@@ -148,7 +158,7 @@ static int m3u_read_seek(AVFormatContext
PlaylistD *playld;
AVFormatContext *ic;
playld = s->priv_data;
- ic = playld->pelist[playld->pe_curidx]->ic;
+ ic = playld->pelist[playld->pe_curidxs[0]]->ic;
ic->iformat->read_seek(ic, stream_index, pts, flags);
}
@@ -158,7 +168,7 @@ static int m3u_read_play(AVFormatContext
PlaylistD *playld;
AVFormatContext *ic;
playld = s->priv_data;
- ic = playld->pelist[playld->pe_curidx]->ic;
+ ic = playld->pelist[playld->pe_curidxs[0]]->ic;
return av_read_play(ic);
}
@@ -168,7 +178,7 @@ static int m3u_read_pause(AVFormatContex
PlaylistD *playld;
AVFormatContext *ic;
playld = s->priv_data;
- ic = playld->pelist[playld->pe_curidx]->ic;
+ ic = playld->pelist[playld->pe_curidxs[0]]->ic;
return av_read_pause(ic);
}
@@ -178,7 +188,7 @@ static int m3u_read_close(AVFormatContex
PlaylistD *playld;
AVFormatContext *ic;
playld = s->priv_data;
- ic = playld->pelist[playld->pe_curidx]->ic;
+ ic = playld->pelist[playld->pe_curidxs[0]]->ic;
if (ic->iformat->read_close)
return ic->iformat->read_close(ic);
return 0;
@@ -193,7 +203,7 @@ static int m3u_read_timestamp(AVFormatCo
PlaylistD *playld;
AVFormatContext *ic;
playld = s->priv_data;
- ic = playld->pelist[playld->pe_curidx]->ic;
+ ic = playld->pelist[playld->pe_curidxs[0]]->ic;
if (ic->iformat->read_timestamp)
return ic->iformat->read_timestamp(ic, stream_index, pos, pos_limit);
return 0;
Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c Wed Jul 1 03:25:57 2009 (r4555)
+++ concat/libavformat/playlist.c Wed Jul 1 03:45:05 2009 (r4556)
@@ -85,7 +85,10 @@ PlaylistD* ff_make_playlistd(char *filen
playld->time_offsets = av_malloc(sizeof(playld->time_offsets) * playld->time_offsets_size);
for (i = 0; i < playld->time_offsets_size; ++i)
playld->time_offsets[i] = 0;
- playld->pe_curidx = 0;
+ playld->pe_curidxs_size = 2; // TODO don't assume we have just 2 streams
+ playld->pe_curidxs = av_malloc(sizeof(playld->pe_curidxs) * playld->pe_curidxs_size);
+ for (i = 0; i < playld->pe_curidxs_size; ++i)
+ playld->pe_curidxs[i] = 0;
ff_split_wd_fn(filename,
&playld->workingdir,
&playld->filename);
@@ -170,15 +173,16 @@ void ff_split_wd_fn(char *filepath,
}
int ff_playlist_populate_context(PlaylistD *playld,
- AVFormatContext *s)
+ AVFormatContext *s,
+ int stream_index)
{
int i;
AVFormatContext *ic;
AVFormatParameters *nap;
printf("playlist_populate_context called\n");
- playld->pelist[playld->pe_curidx] = ff_make_playelem(playld->flist[playld->pe_curidx]);
- ic = playld->pelist[playld->pe_curidx]->ic;
- nap = playld->pelist[playld->pe_curidx]->ap;
+ playld->pelist[playld->pe_curidxs[stream_index]] = ff_make_playelem(playld->flist[playld->pe_curidxs[stream_index]]);
+ ic = playld->pelist[playld->pe_curidxs[stream_index]]->ic;
+ nap = playld->pelist[playld->pe_curidxs[stream_index]]->ap;
ic->iformat->read_header(ic, 0);
s->nb_streams = ic->nb_streams;
for (i = 0; i < ic->nb_streams; ++i) {
@@ -231,16 +235,18 @@ int ff_playlist_populate_context(Playlis
return 0;
}
+/*
unsigned int ff_get_stream_offset(AVFormatContext *s)
{
PlaylistD *playld;
int i;
unsigned int snum = 0;
playld = s->priv_data;
- for (i = 0; i < playld->pe_curidx; ++i)
+ for (i = 0; i < playld->pe_curidxs[0]; ++i)
snum += playld->pelist[i]->ic->nb_streams;
return snum;
}
+*/
// converts duration to stream base
int64_t ff_conv_stream_time(AVFormatContext *ic, int stream_index, int64_t avt_duration)
Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h Wed Jul 1 03:25:57 2009 (r4555)
+++ concat/libavformat/playlist.h Wed Jul 1 03:45:05 2009 (r4556)
@@ -35,7 +35,9 @@ typedef struct PlaylistD {
// int flist_len;
PlayElem **pelist;
int pelist_size;
- int pe_curidx;
+ int *pe_curidxs;
+ int pe_curidxs_size;
+// int pe_curidx;
AVChapter **chlist;
int chlist_size;
int ch_curidx;
@@ -43,17 +45,13 @@ typedef struct PlaylistD {
char *filename;
int64_t *time_offsets;
int time_offsets_size;
-// int64_t pts_offset;
-// int64_t dts_offset;
-// int64_t pts_prevpacket;
-// int64_t dts_prevpacket;
} PlaylistD;
PlayElem* ff_make_playelem(char *filename);
PlaylistD* ff_make_playlistd(char *filename);
-int ff_playlist_populate_context(PlaylistD *playld, AVFormatContext *s);
+int ff_playlist_populate_context(PlaylistD *playld, AVFormatContext *s, int stream_index);
char* ff_conc_strings(char *string1, char *string2);
@@ -61,7 +59,7 @@ char* ff_buf_getline(ByteIOContext *s);
void ff_split_wd_fn(char *filepath, char **workingdir, char **filename);
-unsigned int ff_get_stream_offset(AVFormatContext *s);
+//unsigned int ff_get_stream_offset(AVFormatContext *s);
int64_t ff_conv_stream_time(AVFormatContext *ic, int stream_index, int64_t avt_duration);
More information about the FFmpeg-soc
mailing list