[FFmpeg-devel] [PATCH] several EA demuxer fixes, issue 956
Reimar Döffinger
Reimar.Doeffinger
Thu Apr 9 17:45:46 CEST 2009
Hello,
attached patch fixes several issues:
1) it returns partial packets, e.g. at the end of badly cut files. This
I think is the normal behaviour for FFmpeg, if not av_get_packet should
be changed instead.
2) as an unavoidable side effect of 1) this fixes memleaks with partial
packets since pkt was not free if av_get_packet succeeded and we still
returned with an error (issue 956)
3) since it is simple to do, along with 1) we also return the correct
error code we got from av_get_packet instead of always AVERROR_IO or
AVERROR(EIO).
These IMO should be applied as one patch, splitting does not really make
sense.
The second patch is just another minor simplification after that.
-------------- next part --------------
Index: libavformat/electronicarts.c
===================================================================
--- libavformat/electronicarts.c (revision 18386)
+++ libavformat/electronicarts.c (working copy)
@@ -470,9 +470,8 @@
chunk_size -= 12;
}
ret = av_get_packet(pb, pkt, chunk_size);
- if (ret != chunk_size)
- ret = AVERROR(EIO);
- else {
+ if (ret < 0)
+ return ret;
pkt->stream_index = ea->audio_stream_index;
pkt->pts = 90000;
pkt->pts *= ea->audio_frame_counter;
@@ -493,7 +492,6 @@
ea->audio_frame_counter += chunk_size /
(ea->bytes * ea->num_channels);
}
- }
packet_read = 1;
break;
@@ -531,12 +529,10 @@
case MV0F_TAG:
get_video_packet:
ret = av_get_packet(pb, pkt, chunk_size);
- if (ret != chunk_size)
- ret = AVERROR_IO;
- else {
+ if (ret < 0)
+ return ret;
pkt->stream_index = ea->video_stream_index;
pkt->flags |= key;
- }
packet_read = 1;
break;
-------------- next part --------------
--- electronicarts.c 2009-04-09 17:43:34.000000000 +0200
+++ electronicarts.c.2 2009-04-09 17:42:52.000000000 +0200
@@ -440,13 +440,13 @@
{
EaDemuxContext *ea = s->priv_data;
ByteIOContext *pb = s->pb;
- int ret = 0;
int packet_read = 0;
unsigned int chunk_type, chunk_size;
int key = 0;
int av_uninit(num_samples);
while (!packet_read) {
+ int ret;
chunk_type = get_le32(pb);
chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8;
@@ -502,9 +502,7 @@
case SCEl_TAG:
case SEND_TAG:
case SEEN_TAG:
- ret = AVERROR(EIO);
- packet_read = 1;
- break;
+ return AVERROR(EIO);
case MVIh_TAG:
case kVGT_TAG:
@@ -542,7 +540,7 @@
}
}
- return ret;
+ return 0;
}
AVInputFormat ea_demuxer = {
More information about the ffmpeg-devel
mailing list