[FFmpeg-devel] [PATCH 2/3] ffprobe, libavformat: Remove unnecessary initializations and reset

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sun Dec 1 12:05:45 EET 2019


av_read_frame() can handle uninitialized input packets and it already
returns clean packets on error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 fftools/ffprobe.c    | 2 --
 libavformat/hls.c    | 1 -
 libavformat/mpegts.c | 2 +-
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a95d74346d..a2956cca90 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2356,8 +2356,6 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile,
     int64_t start = -INT64_MAX, end = interval->end;
     int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
 
-    av_init_packet(&pkt);
-
     av_log(NULL, AV_LOG_VERBOSE, "Processing read interval ");
     log_read_interval(interval, NULL, AV_LOG_VERBOSE);
 
diff --git a/libavformat/hls.c b/libavformat/hls.c
index f60396f246..a2d01c2165 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2106,7 +2106,6 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
                 if (ret < 0) {
                     if (!avio_feof(&pls->pb) && ret != AVERROR_EOF)
                         return ret;
-                    reset_packet(&pls->pkt);
                     break;
                 } else {
                     /* stream_index check prevents matching picture attachments etc. */
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 587ed33327..864cae850d 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3262,7 +3262,7 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
     while(pos < pos_limit) {
         int ret;
         AVPacket pkt;
-        av_init_packet(&pkt);
+
         ret = av_read_frame(s, &pkt);
         if (ret < 0)
             return AV_NOPTS_VALUE;
-- 
2.20.1



More information about the ffmpeg-devel mailing list