mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 02:20:07 +01:00
fftools/ffmpeg_mux: embed OutputStream in a MuxStream
This is now possible since OutputStream is a child of OutputFile and the code allocating it can access MuxStream. Avoids the overhead and extra complexity of allocating two objects instead of one. Similar to what was previously done for OutputFile/Muxer.
This commit is contained in:
@@ -168,6 +168,7 @@ static OutputStream *new_output_stream(Muxer *mux, OptionsContext *o,
|
||||
enum AVMediaType type, int source_index)
|
||||
{
|
||||
AVFormatContext *oc = mux->fc;
|
||||
MuxStream *ms;
|
||||
OutputStream *ost;
|
||||
const AVCodec *enc;
|
||||
AVStream *st = avformat_new_stream(oc, NULL);
|
||||
@@ -183,7 +184,14 @@ static OutputStream *new_output_stream(Muxer *mux, OptionsContext *o,
|
||||
if (oc->nb_streams - 1 < o->nb_streamid_map)
|
||||
st->id = o->streamid_map[oc->nb_streams - 1];
|
||||
|
||||
ost = ALLOC_ARRAY_ELEM(mux->of.streams, mux->of.nb_streams);
|
||||
ms = allocate_array_elem(&mux->of.streams, sizeof(MuxStream),
|
||||
&mux->of.nb_streams);
|
||||
ost = &ms->ost;
|
||||
|
||||
ms->muxing_queue = av_fifo_alloc2(8, sizeof(AVPacket*), 0);
|
||||
if (!ms->muxing_queue)
|
||||
report_and_exit(AVERROR(ENOMEM));
|
||||
ms->last_mux_dts = AV_NOPTS_VALUE;
|
||||
|
||||
ost->file_index = nb_output_files - 1;
|
||||
ost->index = idx;
|
||||
@@ -1900,19 +1908,6 @@ int of_open(OptionsContext *o, const char *filename)
|
||||
|
||||
of->url = filename;
|
||||
|
||||
mux->streams = av_calloc(oc->nb_streams, sizeof(*mux->streams));
|
||||
if (!mux->streams)
|
||||
return AVERROR(ENOMEM);
|
||||
mux->nb_streams = oc->nb_streams;
|
||||
|
||||
for (int i = 0; i < mux->nb_streams; i++) {
|
||||
MuxStream *ms = &mux->streams[i];
|
||||
ms->muxing_queue = av_fifo_alloc2(8, sizeof(AVPacket*), 0);
|
||||
if (!ms->muxing_queue)
|
||||
return AVERROR(ENOMEM);
|
||||
ms->last_mux_dts = AV_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
/* write the header for files with no streams */
|
||||
if (of->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
|
||||
int ret = mux_check_init(mux);
|
||||
|
||||
Reference in New Issue
Block a user