Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package

int av_read_frame ( AVFormatContext s,
AVPacket *  pkt 

Returns the next frame of a stream.

The returned packet is valid until the next av_read_frame() or until av_close_input_file() and must be freed with av_free_packet. For video, the packet contains exactly one frame. For audio, it contains an integer number of frames if each frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames have a variable size (e.g. MPEG audio), then it contains one frame.

pkt->pts, pkt->dts and pkt->duration are always set to correct values in AVStream.time_base units (and guessed if the format cannot provide them). pkt->pts can be AV_NOPTS_VALUE if the video format has B-frames, so it is better to rely on pkt->dts if you do not decompress the payload.

0 if OK, < 0 on error or end of file

Definition at line 1140 of file utils.c.

References av_free(), AVFormatContext::flags, AVFormatContext::packet_buffer, and AVFormatContext::packet_buffer_end.

    AVPacketList *pktl;
    int eof=0;
    const int genpts= s->flags & AVFMT_FLAG_GENPTS;

        pktl = s->packet_buffer;
        if (pktl) {
            AVPacket *next_pkt= &pktl->pkt;

            if(genpts && next_pkt->dts != AV_NOPTS_VALUE){
                while(pktl && next_pkt->pts == AV_NOPTS_VALUE){
                    if(   pktl->pkt.stream_index == next_pkt->stream_index
                       && next_pkt->dts < pktl->pkt.dts
                       && pktl->pkt.pts != pktl->pkt.dts //not b frame
                       /*&& pktl->pkt.dts != AV_NOPTS_VALUE*/){
                        next_pkt->pts= pktl->pkt.dts;
                    pktl= pktl->next;
                pktl = s->packet_buffer;

            if(   next_pkt->pts != AV_NOPTS_VALUE
               || next_pkt->dts == AV_NOPTS_VALUE
               || !genpts || eof){
                /* read packet from packet buffer, if there is data */
                *pkt = *next_pkt;
                s->packet_buffer = pktl->next;
                return 0;
            int ret= av_read_frame_internal(s, pkt);
                if(pktl && ret != AVERROR(EAGAIN)){
                    return ret;

            if(av_dup_packet(add_to_pktbuf(&s->packet_buffer, pkt,
                                           &s->packet_buffer_end)) < 0)
                return AVERROR(ENOMEM);
            return av_read_frame_internal(s, pkt);

Generated by  Doxygen 1.6.0   Back to index