From a66ca247d7ad1d283b481f3408afcb36297f7734 Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Thu, 30 Sep 2021 01:55:08 +0300 Subject: [PATCH] lavf: Remove use of deprecated av_init_packet --- input/lavf.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/input/lavf.c b/input/lavf.c index 5bb4c6ed..927d6656 100644 --- a/input/lavf.c +++ b/input/lavf.c @@ -41,6 +41,7 @@ typedef struct AVFormatContext *lavf; AVCodecContext *lavc; AVFrame *frame; + AVPacket *pkt; int stream_id; int next_frame; int vfr_input; @@ -96,10 +97,7 @@ static int read_frame_internal( cli_pic_t *p_pic, lavf_hnd_t *h, int i_frame, vi return 0; } - AVPacket pkt; - av_init_packet( &pkt ); - pkt.data = NULL; - pkt.size = 0; + AVPacket *pkt = h->pkt; while( i_frame >= h->next_frame ) { @@ -109,15 +107,15 @@ static int read_frame_internal( cli_pic_t *p_pic, lavf_hnd_t *h, int i_frame, vi { 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 ) @@ -175,6 +173,9 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c 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; @@ -264,6 +265,7 @@ static int close_file( hnd_t handle ) 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; -- 2.40.0