[FFmpeg-devel] [Segmentation fault]:The recent modification on moving AVPacket from libavformat to libavcodec breaks Win32 shared build when AVStream.need_parsing is not AVSTREAM_PARSE_NONE

avcoder ffmpeg
Thu Apr 9 05:29:51 CEST 2009


Hello!

The broken is related on r18352~r18353Please check my comments in the
following

Should we revert the AVPacket modification?

if not, I will submit an hack to fix the bug

static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
    AVStream *st;
    int len, ret, i;

    av_init_packet(pkt);

    for(;;) {
        /* select current input stream component */
        st = s->cur_st;
        if (st) {
            if (!st->need_parsing || !st->parser) {
                /* no parsing needed: we just output the packet as is */
                /* raw data support */
                *pkt = st->cur_pkt; st->cur_pkt.data= NULL;
                compute_pkt_fields(s, st, NULL, pkt);
                s->cur_st = NULL;
                if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
                    (pkt->flags & PKT_FLAG_KEY) && pkt->dts !=
AV_NOPTS_VALUE) {
                    ff_reduce_index(s, st->index);
                    av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0,
AVINDEX_KEYFRAME);
                }
                break;
            } else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {
                len = av_parser_parse2(st->parser, st->codec, &pkt->data,
&pkt->size,
                                       st->cur_ptr, st->cur_len,
                                       st->cur_pkt.pts, st->cur_pkt.dts,
                                       st->cur_pkt.pos);
                st->cur_pkt.pts = AV_NOPTS_VALUE;
                st->cur_pkt.dts = AV_NOPTS_VALUE;
                /* increment read pointer */
                st->cur_ptr += len;
                st->cur_len -= len;

                /* return packet if any */
                if (pkt->size) {
                got_packet:
                    pkt->duration = 0;
                    pkt->stream_index = st->index;
                    pkt->pts = st->parser->pts;
                    pkt->dts = st->parser->dts;
                    pkt->pos = st->parser->pos;
//********************************************************************
// Note: av_destruct_packet_nofree is different from the one which is
implemented in libavcodec
// Becuase av_destruct_packet_nofree is an imported function which has a
thunk wrapper of the native av_destruct_packet_nofree implemented in
libavcodec
// Finally, it breaks the logic of av_dup_packet() which checks the
native av_destruct_packet_nofree in libavcodec
//
                    pkt->destruct = av_destruct_packet_nofree;
//
//********************************************************************
                    compute_pkt_fields(s, st, st->parser, pkt);

                    if((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
pkt->flags & PKT_FLAG_KEY){
                        ff_reduce_index(s, st->index);
                        av_add_index_entry(st, st->parser->frame_offset,
pkt->dts,
                                           0, 0, AVINDEX_KEYFRAME);
                    }

                    break;
....


-- 
----------------------------------------------
Inspired by http://ppnext.com
Your potential. Our passion.



More information about the ffmpeg-devel mailing list