Commit 3f760214 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '68b46774'

* commit '68b46774':
  lavf: Make probe_codec return an error code

Conflicts:
	libavformat/utils.c

A failure to reallocate should not free the array as it is used
to probe the codec. And failure to reallocate if the following
probe succeeds isnt a fatal error for probe_codec(). Thus this
is only partially merged to ensure probing still is attempted
with the data available.
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 4149981b 68b46774
...@@ -579,7 +579,7 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st) ...@@ -579,7 +579,7 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st)
} }
} }
static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
{ {
if(st->request_probe>0){ if(st->request_probe>0){
AVProbeData *pd = &st->probe_data; AVProbeData *pd = &st->probe_data;
...@@ -622,11 +622,12 @@ no_packet: ...@@ -622,11 +622,12 @@ no_packet:
force_codec_ids(s, st); force_codec_ids(s, st);
} }
} }
return 0;
} }
int ff_read_packet(AVFormatContext *s, AVPacket *pkt) int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
int ret, i; int ret, i, err;
AVStream *st; AVStream *st;
for(;;){ for(;;){
...@@ -635,8 +636,10 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -635,8 +636,10 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
if (pktl) { if (pktl) {
*pkt = pktl->pkt; *pkt = pktl->pkt;
st = s->streams[pkt->stream_index]; st = s->streams[pkt->stream_index];
if (s->raw_packet_buffer_remaining_size <= 0) if (s->raw_packet_buffer_remaining_size <= 0) {
probe_codec(s, st, NULL); if ((err = probe_codec(s, st, NULL)) < 0)
return err;
}
if(st->request_probe <= 0){ if(st->request_probe <= 0){
s->raw_packet_buffer = pktl->next; s->raw_packet_buffer = pktl->next;
s->raw_packet_buffer_remaining_size += pkt->size; s->raw_packet_buffer_remaining_size += pkt->size;
...@@ -655,7 +658,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -655,7 +658,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i = 0; i < s->nb_streams; i++) { for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i]; st = s->streams[i];
if (st->probe_packets) { if (st->probe_packets) {
probe_codec(s, st, NULL); if ((err = probe_codec(s, st, NULL)) < 0)
return err;
} }
av_assert0(st->request_probe <= 0); av_assert0(st->request_probe <= 0);
} }
...@@ -695,7 +699,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -695,7 +699,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end); add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end);
s->raw_packet_buffer_remaining_size -= pkt->size; s->raw_packet_buffer_remaining_size -= pkt->size;
probe_codec(s, st, pkt); if ((err = probe_codec(s, st, pkt)) < 0)
return err;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment