[FFmpeg-devel] [RFC] LOAS (aka LATM) demuxer

Janne Grunau janne-ffmpeg
Tue Aug 3 13:32:04 CEST 2010


On Tue, Aug 03, 2010 at 11:34:18AM +0300, Martin Storsj? wrote:
> On Sun, 1 Aug 2010, Janne Grunau wrote:
> 
> > +static int latm_read_audio_mux_element_data(AVFormatContext *s,
> > +                                            AVPacket *pkt)
> > +{
> > +    struct latm_demux_context *ctx = s->priv_data;
> > +    struct latm_stream_config *cfg = &ctx->streams[ctx->cur_stream];
> > +    int j;
> > +
> > +    if (!ctx->audio_mux_version_A) {
> > +
> > +        pkt->pts  = pkt->dts = 2048 * ctx->pkt_cnt;
> > +        pkt->data = av_malloc(cfg->mux_slot_length);
> > +        pkt->size = cfg->mux_slot_length;
> > +        pkt->stream_index = ctx->cur_stream++;
> > +        //TODO: try to use byte copying
> > +        for (j = 0; j < cfg->mux_slot_length; j++)
> > +            pkt->data[j] = get_bits(ctx->gb, 8);
> > +        //av_hex_dump_log(s, AV_LOG_INFO, pkt->data, pkt->size);
> 
> This could use an av_init_packet(), to make sure all other fields are
> properly initialized.

at least all libavformat users inputformat->read_packet() call
av_init_packet before. So this shouldn't be necessary.

> Also, you need to set pkt->destruct =
> av_destruct_packet, otherwise the allocated data will be leaked.

Settled for av_new_packet()

Janne



More information about the ffmpeg-devel mailing list