[FFmpeg-devel] [PATCH] gxf only read valid audio samples
Baptiste Coudurier
baptiste.coudurier
Thu Sep 25 01:39:34 CEST 2008
Reimar D?ffinger wrote:
> Hello,
> On Wed, Sep 24, 2008 at 09:58:47AM -0700, Baptiste Coudurier wrote:
>> @@ -441,15 +442,29 @@
>> stream_index = get_sindex(s, track_id, track_type);
>> if (stream_index < 0)
>> return stream_index;
>> + st = s->streams[stream_index];
>> field_nr = get_be32(pb);
>> - get_be32(pb); // field information
>> + field_info = get_be32(pb);
>> get_be32(pb); // "timeline" field number
>> get_byte(pb); // flags
>> get_byte(pb); // reserved
>> - // NOTE: there is also data length information in the
>> - // field information, it might be better to take this into account
>> - // as well.
>> + if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
>> + st->codec->codec_id == CODEC_ID_PCM_S16LE) {
>> + int first = field_info >> 16;
>> + int last = field_info & 0xffff; // last is exclusive
>> + int bps = av_get_bits_per_sample(st->codec->codec_id)>>3;
>> + if (first > last || last*bps > pkt_len) {
>> + av_log(s, AV_LOG_ERROR, "invalid first and last sample values\n");
>> + goto read;
>> + }
>> + url_fskip(pb, first*bps);
>> + skip = pkt_len - last*bps;
>> + pkt_len = (last-first)*bps;
>> + }
>> + read:
>
> I am not particularly against goto, but is seems pointless to me here.
> if (first <= last && last*bps <= pkt_len) {
> ...
> } else
> av_log(...);
>
> Does not seem much worse.
> I suggested the condition this way (av_log in the else part) because it seemed
> nicer to me but I do not really care.
> If you make a version without goto, feel free to apply directly.
>
Thanks, did that and applied.
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Smartjog USA Inc. http://www.smartjog.com
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
More information about the ffmpeg-devel
mailing list