diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c index 7f580b970d..80bf768579 100644 --- a/libavformat/audiointerleave.c +++ b/libavformat/audiointerleave.c @@ -105,7 +105,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int), int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *)) { - int i; + int i, ret; if (pkt) { AVStream *st = s->streams[pkt->stream_index]; @@ -119,12 +119,10 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt } av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL); } else { - int ret; // rewrite pts and dts to be decoded time line position pkt->pts = pkt->dts = aic->dts; aic->dts += pkt->duration; - ret = ff_interleave_add_packet(s, pkt, compare_ts); - if (ret < 0) + if ((ret = ff_interleave_add_packet(s, pkt, compare_ts)) < 0) return ret; } pkt = NULL; @@ -134,10 +132,8 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { AVPacket new_pkt; - int ret; while ((ret = interleave_new_audio_packet(s, &new_pkt, i, flush)) > 0) { - ret = ff_interleave_add_packet(s, &new_pkt, compare_ts); - if (ret < 0) + if ((ret = ff_interleave_add_packet(s, &new_pkt, compare_ts)) < 0) return ret; } if (ret < 0) diff --git a/libavformat/internal.h b/libavformat/internal.h index 66fb5d64af..467e25d830 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -93,7 +93,7 @@ void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i * @return 0, or < 0 on error */ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, - int (*compare)(AVFormatContext *, AVPacket *, AVPacket *)); + int (*compare)(AVFormatContext *, AVPacket *, AVPacket *)); void ff_read_frame_flush(AVFormatContext *s); diff --git a/libavformat/mux.c b/libavformat/mux.c index 687f7043da..308b255269 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -658,12 +658,12 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) #define CHUNK_START 0x1000 int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, - int (*compare)(AVFormatContext *, AVPacket *, AVPacket *)) + int (*compare)(AVFormatContext *, AVPacket *, AVPacket *)) { + int ret; AVPacketList **next_point, *this_pktl; AVStream *st = s->streams[pkt->stream_index]; int chunked = s->max_chunk_size || s->max_chunk_duration; - int ret; this_pktl = av_mallocz(sizeof(AVPacketList)); if (!this_pktl) @@ -681,7 +681,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE); av_assert0(((AVFrame *)pkt->data)->buf); } else { - // duplicate the packet if it uses non-allocated memory + // Duplicate the packet if it uses non-allocated memory if ((ret = av_dup_packet(&this_pktl->pkt)) < 0) { av_free(this_pktl); return ret; @@ -735,6 +735,7 @@ next_non_null: s->streams[pkt->stream_index]->last_in_packet_buffer = *next_point = this_pktl; + return 0; } @@ -765,12 +766,12 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) { AVPacketList *pktl; - int stream_count = 0, noninterleaved_count = 0; + int stream_count = 0; + int noninterleaved_count = 0; int i, ret; if (pkt) { - ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts); - if (ret < 0) + if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0) return ret; }