AVFormatContext *lavf;
AVCodecContext *lavc;
AVFrame *frame;
+ AVPacket *pkt;
int stream_id;
int next_frame;
int vfr_input;
return 0;
}
- AVPacket pkt;
- av_init_packet( &pkt );
- pkt.data = NULL;
- pkt.size = 0;
+ AVPacket *pkt = h->pkt;
while( i_frame >= h->next_frame )
{
{
if( ret == AVERROR(EAGAIN) )
{
- while( !(ret = av_read_frame( h->lavf, &pkt )) && pkt.stream_index != h->stream_id )
- av_packet_unref( &pkt );
+ while( !(ret = av_read_frame( h->lavf, pkt )) && pkt->stream_index != h->stream_id )
+ av_packet_unref( pkt );
if( ret )
ret = avcodec_send_packet( h->lavc, NULL );
else
{
- ret = avcodec_send_packet( h->lavc, &pkt );
- av_packet_unref( &pkt );
+ ret = avcodec_send_packet( h->lavc, pkt );
+ av_packet_unref( pkt );
}
}
else if( ret == AVERROR_EOF )
h->frame = av_frame_alloc();
if( !h->frame )
return -1;
+ h->pkt = av_packet_alloc();
+ if( !h->pkt )
+ return -1;
/* if resolution was passed in, place it and colorspace into options. this allows raw video support */
AVDictionary *options = NULL;
lavf_hnd_t *h = handle;
avcodec_free_context( &h->lavc );
avformat_close_input( &h->lavf );
+ av_packet_free( &h->pkt );
av_frame_free( &h->frame );
free( h );
return 0;