[x264-devel] [Git][videolan/x264][master] lavf: Remove use of deprecated av_init_packet
Anton Mitrofanov (@BugMaster)
gitlab at videolan.org
Tue Dec 7 13:16:11 UTC 2021
Anton Mitrofanov pushed to branch master at VideoLAN / x264
Commits:
a66ca247 by Anton Mitrofanov at 2021-12-07T13:04:52+00:00
lavf: Remove use of deprecated av_init_packet
- - - - -
1 changed file:
- input/lavf.c
Changes:
=====================================
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;
View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/a66ca247d7ad1d283b481f3408afcb36297f7734
--
View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/a66ca247d7ad1d283b481f3408afcb36297f7734
You're receiving this email because of your account on code.videolan.org.
More information about the x264-devel
mailing list