if(pkt->size < 10) return -1;
static int film_read_packet(AVFormatContext *s,                            AVPacket *pkt){    FilmDemuxContext *film = (FilmDemuxContext *)s->priv_data;    ByteIOContext *pb = &s->pb;    film_sample_t *sample;    int ret = 0;    int i;    int left, right;    if (film->current_sample >= film->sample_count)        return AVERROR_IO;    sample = &film->sample_table[film->current_sample];    /* position the stream (will probably be there anyway) */    url_fseek(pb, sample->sample_offset, SEEK_SET);    /* do a special song and dance when loading FILM Cinepak chunks */    if ((sample->stream == film->video_stream_index) &&         (film->video_type == CODEC_ID_CINEPAK)) {        if (av_new_packet(pkt, sample->sample_size - film->cvid_extra_bytes))            return AVERROR_NOMEM;        ret = get_buffer(pb, pkt->data, 10);        /* skip the non-spec CVID bytes */        url_fseek(pb, film->cvid_extra_bytes, SEEK_CUR);        ret += get_buffer(pb, pkt->data + 10,             sample->sample_size - 10 - film->cvid_extra_bytes);        if (ret != sample->sample_size - film->cvid_extra_bytes)            ret = AVERROR_IO;    } else if ((sample->stream == film->audio_stream_index) &&        (film->audio_channels == 2)) {        /* stereo PCM needs to be interleaved */        if (av_new_packet(pkt, sample->sample_size))            return AVERROR_NOMEM;        /* make sure the interleave buffer is large enough */        if (sample->sample_size > film->stereo_buffer_size) {            av_free(film->stereo_buffer);            film->stereo_buffer_size = sample->sample_size;            film->stereo_buffer = av_malloc(film->stereo_buffer_size);        }        ret = get_buffer(pb, film->stereo_buffer, sample->sample_size);        if (ret != sample->sample_size)            ret = AVERROR_IO;        left = 0;        right = sample->sample_size / 2;        for (i = 0; i < sample->sample_size; ) {            if (film->audio_bits == 8) {                pkt->data[i++] = film->stereo_buffer[left++];                pkt->data[i++] = film->stereo_buffer[right++];            } else {                pkt->data[i++] = film->stereo_buffer[left++];                pkt->data[i++] = film->stereo_buffer[left++];                pkt->data[i++] = film->stereo_buffer[right++];                pkt->data[i++] = film->stereo_buffer[right++];            }        }    } else {        if (av_new_packet(pkt, sample->sample_size))            return AVERROR_NOMEM;        ret = get_buffer(pb, pkt->data, sample->sample_size);        if (ret != sample->sample_size)            ret = AVERROR_IO;    }    pkt->stream_index = sample->stream;    pkt->pts = sample->pts;    film->current_sample++;    return ret;}