[FFmpeg-devel] [PATCH] CD+G Demuxer & Decoder

Michael Tison blackspike
Fri Dec 11 07:59:23 CET 2009


>> static int read_packet(AVFormatContext *s, AVPacket *pkt)
>> {
>> ? ? int ret;
>> ? ? ByteIOContext *pb = s->pb;
>>
>> ? ? ret = av_get_packet(pb, pkt, CDG_PACKET_SIZE);
>>
>> ? ? if (ret != CDG_PACKET_SIZE) {
>> ? ? ? av_free_packet(pkt);
>> ? ? ? return ret < 0 ? ret : AVERROR(EIO);
>> ? ? }
>>
>> ? ? pkt->stream_index = 0;
>> ? ? return 0;
>> }
>>
>
>> I've noticed in a few formats they call av_free_packet() after a
>> failed av_get_packet()
>
> which do this?

bethsoftvid.c, rpl.c, and thp.c do it

> If av_get_packet() failed then there is no packet to free.
> but not returning the size you want is not a failure from av_get_packets
> point of view.
>
> the correct thing to do is
>
> ret = av_get_packet(pb, pkt, CDG_PACKET_SIZE);
> return ret;
>
> or if you really want to discard the last packet of a truncated file
>
> ret = av_get_packet(pb, pkt, CDG_PACKET_SIZE);
> if(ret >= 0 && ret < CDG_PACKET_SIZE){
> ? ?av_free_packet(pkt);
> ? ?ret= AVERROR(EIO);
> }
> return ret;

Fixed.

Revised patch attached.

Thanks again!

Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cdgraphicsv7.patch
Type: text/x-diff
Size: 17861 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091210/a26cb8f0/attachment.patch>



More information about the ffmpeg-devel mailing list