mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-16 03:50:05 +01:00
Merge commit 'e3c4eb87e4d9650d76f6d8d790a9b749b325e973' into release/2.2
* commit 'e3c4eb87e4d9650d76f6d8d790a9b749b325e973':
avpacket: Check for and return errors in ff_interleave_add_packet()
Conflicts:
libavformat/audiointerleave.c
libavformat/internal.h
libavformat/mux.c
See: 4d7c71c364
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -104,7 +104,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
|
|||||||
int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
|
int (*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int),
|
||||||
int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
|
int (*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
|
||||||
{
|
{
|
||||||
int i;
|
int i, ret;
|
||||||
|
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
AVStream *st = s->streams[pkt->stream_index];
|
AVStream *st = s->streams[pkt->stream_index];
|
||||||
@@ -118,12 +118,10 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
|
|||||||
}
|
}
|
||||||
av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
|
av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
|
||||||
} else {
|
} else {
|
||||||
int ret;
|
|
||||||
// rewrite pts and dts to be decoded time line position
|
// rewrite pts and dts to be decoded time line position
|
||||||
pkt->pts = pkt->dts = aic->dts;
|
pkt->pts = pkt->dts = aic->dts;
|
||||||
aic->dts += pkt->duration;
|
aic->dts += pkt->duration;
|
||||||
ret = ff_interleave_add_packet(s, pkt, compare_ts);
|
if ((ret = ff_interleave_add_packet(s, pkt, compare_ts)) < 0)
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
pkt = NULL;
|
pkt = NULL;
|
||||||
@@ -133,10 +131,8 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
|
|||||||
AVStream *st = s->streams[i];
|
AVStream *st = s->streams[i];
|
||||||
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
AVPacket new_pkt;
|
AVPacket new_pkt;
|
||||||
int ret;
|
|
||||||
while ((ret = interleave_new_audio_packet(s, &new_pkt, i, flush)) > 0) {
|
while ((ret = interleave_new_audio_packet(s, &new_pkt, i, flush)) > 0) {
|
||||||
ret = ff_interleave_add_packet(s, &new_pkt, compare_ts);
|
if ((ret = ff_interleave_add_packet(s, &new_pkt, compare_ts)) < 0)
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i
|
|||||||
* @return 0, or < 0 on error
|
* @return 0, or < 0 on error
|
||||||
*/
|
*/
|
||||||
int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
|
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);
|
void ff_read_frame_flush(AVFormatContext *s);
|
||||||
|
|
||||||
|
|||||||
@@ -640,12 +640,12 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
|
|||||||
#define CHUNK_START 0x1000
|
#define CHUNK_START 0x1000
|
||||||
|
|
||||||
int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
|
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;
|
AVPacketList **next_point, *this_pktl;
|
||||||
AVStream *st = s->streams[pkt->stream_index];
|
AVStream *st = s->streams[pkt->stream_index];
|
||||||
int chunked = s->max_chunk_size || s->max_chunk_duration;
|
int chunked = s->max_chunk_size || s->max_chunk_duration;
|
||||||
int ret;
|
|
||||||
|
|
||||||
this_pktl = av_mallocz(sizeof(AVPacketList));
|
this_pktl = av_mallocz(sizeof(AVPacketList));
|
||||||
if (!this_pktl)
|
if (!this_pktl)
|
||||||
@@ -661,7 +661,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
|
av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
|
||||||
av_assert0(((AVFrame *)pkt->data)->buf);
|
av_assert0(((AVFrame *)pkt->data)->buf);
|
||||||
} else {
|
} 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) {
|
if ((ret = av_dup_packet(&this_pktl->pkt)) < 0) {
|
||||||
av_free(this_pktl);
|
av_free(this_pktl);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -716,6 +716,7 @@ next_non_null:
|
|||||||
|
|
||||||
s->streams[pkt->stream_index]->last_in_packet_buffer =
|
s->streams[pkt->stream_index]->last_in_packet_buffer =
|
||||||
*next_point = this_pktl;
|
*next_point = this_pktl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,12 +747,12 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
|
|||||||
AVPacket *pkt, int flush)
|
AVPacket *pkt, int flush)
|
||||||
{
|
{
|
||||||
AVPacketList *pktl;
|
AVPacketList *pktl;
|
||||||
int stream_count = 0, noninterleaved_count = 0;
|
int stream_count = 0;
|
||||||
|
int noninterleaved_count = 0;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts);
|
if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0)
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user