@@ -235,6 +235,44 @@ int ff_stream_side_data_copy(AVStream *dst, const AVStream *src)
return 0;
}
+int ff_stream_params_copy(AVStream *dst, const AVStream *src)
+{
+ int ret;
+
+ dst->id = src->id;
+ dst->index = src->index;
+ dst->time_base = src->time_base;
+ dst->start_time = src->start_time;
+ dst->duration = src->duration;
+ dst->nb_frames = src->nb_frames;
+ dst->disposition = src->disposition;
+ dst->discard = src->discard;
+ dst->sample_aspect_ratio = src->sample_aspect_ratio;
+ dst->avg_frame_rate = src->avg_frame_rate;
+ dst->event_flags = src->event_flags;
+ dst->r_frame_rate = src->r_frame_rate;
+ dst->pts_wrap_bits = src->pts_wrap_bits;
+
+ av_dict_free(&dst->metadata);
+ ret = av_dict_copy(&dst->metadata, src->metadata, 0);
+ if (ret < 0)
+ return ret;
+
+ ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
+ if (ret < 0)
+ return ret;
+
+ ret = ff_stream_side_data_copy(dst, src);
+ if (ret < 0)
+ return ret;
+
+ ret = av_packet_ref(&dst->attached_pic, &src->attached_pic);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
AVProgram *av_new_program(AVFormatContext *ac, int id)
{
AVProgram *program = NULL;
@@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat,
if (!st)
return AVERROR(ENOMEM);
- ret = ff_stream_encode_params_copy(st, avf->streams[i]);
+ ret = ff_stream_params_copy(st, avf->streams[i]);
if (ret < 0)
return ret;
}
@@ -625,6 +625,15 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
*/
int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);
+/**
+ * Copy all stream parameters from source to destination stream
+ *
+ * @param dst pointer to destination AVStream
+ * @param src pointer to source AVStream
+ * @return >=0 on success, AVERROR code on error
+ */
+int ff_stream_params_copy(AVStream *dst, const AVStream *src);
+
/**
* Wrap ffurl_move() and log if error happens.
*
@@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size)
*/
int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options);
-/**
- * Copy encoding parameters from source to destination stream
- *
- * @param dst pointer to destination AVStream
- * @param src pointer to source AVStream
- * @return >=0 on success, AVERROR code on error
- */
-int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
-
/**
* Parse creation_time in AVFormatContext metadata if exists and warn if the
* parsing fails.
@@ -121,34 +121,6 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op
return 0;
}
-int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src)
-{
- int ret;
-
- dst->id = src->id;
- dst->time_base = src->time_base;
- dst->nb_frames = src->nb_frames;
- dst->disposition = src->disposition;
- dst->sample_aspect_ratio = src->sample_aspect_ratio;
- dst->avg_frame_rate = src->avg_frame_rate;
- dst->r_frame_rate = src->r_frame_rate;
-
- av_dict_free(&dst->metadata);
- ret = av_dict_copy(&dst->metadata, src->metadata, 0);
- if (ret < 0)
- return ret;
-
- ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
- if (ret < 0)
- return ret;
-
- ret = ff_stream_side_data_copy(dst, src);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
{
AVDictionaryEntry *entry;
@@ -169,7 +169,7 @@ static int segment_mux_init(AVFormatContext *s)
if (!(st = avformat_new_stream(oc, NULL)))
return AVERROR(ENOMEM);
- ret = ff_stream_encode_params_copy(st, ist);
+ ret = ff_stream_params_copy(st, ist);
if (ret < 0)
return ret;
opar = st->codecpar;
@@ -289,7 +289,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
goto end;
}
- ret = ff_stream_encode_params_copy(st2, st);
+ ret = ff_stream_params_copy(st2, st);
if (ret < 0)
goto end;
}
@@ -94,7 +94,7 @@ static int webm_chunk_init(AVFormatContext *s)
if (!(st = avformat_new_stream(oc, NULL)))
return AVERROR(ENOMEM);
- if ((ret = ff_stream_encode_params_copy(st, ost)) < 0)
+ if ((ret = ff_stream_params_copy(st, ost)) < 0)
return ret;
if (wc->http_method)
From: Pierre-Anthony Lemieux <pal@palemieux.com> As discussed at https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html --- libavformat/avformat.c | 38 ++++++++++++++++++++++++++++++++++++++ libavformat/fifo.c | 2 +- libavformat/internal.h | 9 +++++++++ libavformat/mux.h | 9 --------- libavformat/mux_utils.c | 28 ---------------------------- libavformat/segment.c | 2 +- libavformat/tee.c | 2 +- libavformat/webm_chunk.c | 2 +- 8 files changed, 51 insertions(+), 41 deletions(-)