[soc]: r4796 - in concat/libavformat: concatgen.c playlist.c playlist.h
Author: gkovacs Date: Fri Jul 24 02:03:09 2009 New Revision: 4796 Log: removed PlayElem Modified: concat/libavformat/concatgen.c concat/libavformat/playlist.c concat/libavformat/playlist.h Modified: concat/libavformat/concatgen.c ============================================================================== --- concat/libavformat/concatgen.c Fri Jul 24 01:29:45 2009 (r4795) +++ concat/libavformat/concatgen.c Fri Jul 24 02:03:09 2009 (r4796) @@ -43,11 +43,10 @@ int ff_concatgen_read_packet(AVFormatCon ctx = s->priv_data; stream_index = 0; retr: - ic = ctx->pelist[ctx->pe_curidx]->ic; + ic = ctx->icl[ctx->pe_curidx]; ret = ic->iformat->read_packet(ic, pkt); if (pkt) { stream_index = pkt->stream_index; - ic = ctx->pelist[ctx->pe_curidx]->ic; pkt->stream = ic->streams[pkt->stream_index]; } if (ret >= 0) { @@ -83,7 +82,7 @@ int ff_concatgen_read_seek(AVFormatConte PlaylistContext *ctx; AVFormatContext *ic; ctx = s->priv_data; - ic = ctx->pelist[ctx->pe_curidx]->ic; + ic = ctx->icl[ctx->pe_curidx]; return ic->iformat->read_seek(ic, stream_index, pts, flags); } @@ -95,7 +94,7 @@ int ff_concatgen_read_timestamp(AVFormat PlaylistContext *ctx; AVFormatContext *ic; ctx = s->priv_data; - ic = ctx->pelist[ctx->pe_curidx]->ic; + ic = ctx->icl[ctx->pe_curidx]; if (ic->iformat->read_timestamp) return ic->iformat->read_timestamp(ic, stream_index, pos, pos_limit); return 0; @@ -106,7 +105,7 @@ int ff_concatgen_read_close(AVFormatCont PlaylistContext *ctx; AVFormatContext *ic; ctx = s->priv_data; - ic = ctx->pelist[ctx->pe_curidx]->ic; + ic = ctx->icl[ctx->pe_curidx]; if (ic->iformat->read_close) return ic->iformat->read_close(ic); return 0; @@ -117,7 +116,7 @@ int ff_concatgen_read_play(AVFormatConte PlaylistContext *ctx; AVFormatContext *ic; ctx = s->priv_data; - ic = ctx->pelist[ctx->pe_curidx]->ic; + ic = ctx->icl[ctx->pe_curidx]; return av_read_play(ic); } @@ -126,6 +125,6 @@ int ff_concatgen_read_pause(AVFormatCont PlaylistContext *ctx; AVFormatContext *ic; ctx = s->priv_data; - ic = ctx->pelist[ctx->pe_curidx]->ic; + ic = ctx->icl[ctx->pe_curidx]; return av_read_pause(ic); } Modified: concat/libavformat/playlist.c ============================================================================== --- concat/libavformat/playlist.c Fri Jul 24 01:29:45 2009 (r4795) +++ concat/libavformat/playlist.c Fri Jul 24 02:03:09 2009 (r4796) @@ -34,16 +34,17 @@ #include "playlist.h" #include "internal.h" -void ff_playlist_init_playelem(PlayElem *pe) +AVFormatContext *ff_playlist_alloc_formatcontext(char *filename) { int err; - pe->ic = av_mallocz(sizeof(*(pe->ic))); - err = av_open_input_file(&(pe->ic), pe->filename, pe->ic->iformat, 0, NULL); + AVFormatContext *ic = av_mallocz(sizeof(*ic)); + err = av_open_input_file(&(ic), filename, ic->iformat, 0, NULL); if (err < 0) - av_log(pe->ic, AV_LOG_ERROR, "Error during av_open_input_file\n"); - err = av_find_stream_info(pe->ic); + av_log(ic, AV_LOG_ERROR, "Error during av_open_input_file\n"); + err = av_find_stream_info(ic); if (err < 0) - av_log(pe->ic, AV_LOG_ERROR, "Could not find stream info\n"); + av_log(ic, AV_LOG_ERROR, "Could not find stream info\n"); + return ic; } void ff_playlist_populate_context(AVFormatContext *s) @@ -51,8 +52,8 @@ void ff_playlist_populate_context(AVForm int i; AVFormatContext *ic; PlaylistContext *ctx = s->priv_data; - ff_playlist_init_playelem(ctx->pelist[ctx->pe_curidx]); - ic = ctx->pelist[ctx->pe_curidx]->ic; + ctx->icl = av_realloc(ctx->icl, sizeof(*(ctx->icl)) * (ctx->pe_curidx+1)); + ic = ctx->icl[ctx->pe_curidx] = ff_playlist_alloc_formatcontext(ctx->flist[ctx->pe_curidx]); ic->iformat->read_header(ic, 0); s->nb_streams = ic->nb_streams; for (i = 0; i < ic->nb_streams; ++i) @@ -78,10 +79,10 @@ void ff_playlist_set_context(AVFormatCon AVStream *ff_playlist_get_stream(PlaylistContext *ctx, int pe_idx, int stream_index) { - if (ctx && pe_idx < ctx->pelist_size && ctx->pelist && ctx->pelist[pe_idx] && - ctx->pelist[pe_idx]->ic && stream_index < ctx->pelist[pe_idx]->ic->nb_streams && - ctx->pelist[pe_idx]->ic->streams && ctx->pelist[pe_idx]->ic->streams[stream_index]) - return ctx->pelist[pe_idx]->ic->streams[stream_index]; + if (ctx && pe_idx < ctx->pelist_size && ctx->icl && ctx->icl[pe_idx] && + ctx->icl[pe_idx] && stream_index < ctx->icl[pe_idx]->nb_streams && + ctx->icl[pe_idx]->streams && ctx->icl[pe_idx]->streams[stream_index]) + return ctx->icl[pe_idx]->streams[stream_index]; else return NULL; } @@ -132,10 +133,8 @@ PlaylistContext *ff_playlist_from_encode void ff_playlist_add_path(PlaylistContext *ctx, char *itempath) { - ctx->pelist_size++; - ctx->pelist = av_realloc(ctx->pelist, ctx->pelist_size * sizeof(PlayElem*)); - ctx->pelist[ctx->pelist_size-1] = av_mallocz(sizeof(*(ctx->pelist[ctx->pelist_size-1]))); - ctx->pelist[ctx->pelist_size-1]->filename = itempath; + ctx->flist = av_realloc(ctx->flist, sizeof(*(ctx->flist)) * ++ctx->pelist_size); + ctx->flist[ctx->pelist_size-1] = itempath; } // converts list of mixed absolute and relative paths into all absolute paths Modified: concat/libavformat/playlist.h ============================================================================== --- concat/libavformat/playlist.h Fri Jul 24 01:29:45 2009 (r4795) +++ concat/libavformat/playlist.h Fri Jul 24 02:03:09 2009 (r4796) @@ -37,29 +37,22 @@ #include "riff.h" #include <libgen.h> -/** @struct PlayElem - * @brief Represents each input file on a playlist. - */ -typedef struct PlayElem { - AVFormatContext *ic; /**< AVFormatContext for this playlist item */ - char *filename; /**< Filename with absolute path of this playlist item */ -} PlayElem; - /** @struct PlaylistContext * @brief Represents the playlist and contains PlayElem for each playlist item. */ typedef struct PlaylistContext { - PlayElem **pelist; /**< List of PlayElem, with each representing a playlist item */ + char **flist; /**< List of file names for each playlist item */ + AVFormatContext **icl; /**< List of FormatContext for each playlist items */ int pelist_size; /**< Number of PlayElem stored in pelist */ int pe_curidx; /**< Index of the PlayElem that packets are being read from */ int64_t time_offset; /**< Time offset, in 10^-6 seconds, for all multimedia streams */ } PlaylistContext; -/** @fn int ff_playlist_init_playelem(PlayElem* pe) - * @brief Opens file, codecs, and streams associated with PlayElem. - * @param pe PlayElem to open. It should already be allocated. +/** @fn int ff_playlist_alloc_playelem(PlayElem* pe) + * @brief Allocates and opens file, codecs, and streams associated with filename. + * @param filename Null-terminated string of file to open. */ -void ff_playlist_init_playelem(PlayElem* pe); +AVFormatContext *ff_playlist_alloc_formatcontext(char *filename); /** @fn void ff_playlist_populate_context(PlaylistContext *playlc, AVFormatContext *s, int stream_index) * @brief Opens the current PlayElem from the PlaylistContext.
participants (1)
-
gkovacs