[FFmpeg-devel] [PATCH 2/3] avcodec: replace all uses of av_shrink_packet() with av_packet_resize()

James Almer jamrial at gmail.com
Thu Mar 11 17:50:10 EET 2021


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/aliaspixenc.c    | 2 +-
 libavcodec/cfhdenc.c        | 2 +-
 libavcodec/exrenc.c         | 2 +-
 libavcodec/hapenc.c         | 2 +-
 libavcodec/libopenjpegenc.c | 2 +-
 libavcodec/libopusenc.c     | 2 +-
 libavcodec/libtwolame.c     | 2 +-
 libavcodec/rpzaenc.c        | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index a9ba00cd29..57dea147bd 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -103,7 +103,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     /* Total length */
-    av_shrink_packet(pkt, buf - pkt->data);
+    av_packet_resize(pkt, buf - pkt->data);
     pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
 
diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 42bbf99c96..109b42009a 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -785,7 +785,7 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     bytestream2_put_be16(pby, GroupTrailer);
     bytestream2_put_be16(pby, 0);
 
-    av_shrink_packet(pkt, bytestream2_tell_p(pby));
+    av_packet_resize(pkt, bytestream2_tell_p(pby));
 
     pkt->flags |= AV_PKT_FLAG_KEY;
 
diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c
index db9000a85c..60680ccdac 100644
--- a/libavcodec/exrenc.c
+++ b/libavcodec/exrenc.c
@@ -504,7 +504,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         av_assert0(0);
     }
 
-    av_shrink_packet(pkt, bytestream2_tell_p(pb));
+    av_packet_resize(pkt, bytestream2_tell_p(pb));
 
     pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c
index 3a1bc870b1..544836e4e6 100644
--- a/libavcodec/hapenc.c
+++ b/libavcodec/hapenc.c
@@ -227,7 +227,7 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
     /* Write header at the start. */
     hap_write_frame_header(ctx, pkt->data, final_data_size + header_length);
 
-    av_shrink_packet(pkt, final_data_size + header_length);
+    av_packet_resize(pkt, final_data_size + header_length);
     pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
     return 0;
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index e4641235f5..8791cc72a6 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -707,7 +707,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         goto done;
     }
 
-    av_shrink_packet(pkt, writer.pos);
+    av_packet_resize(pkt, writer.pos);
 
     pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 70d17f802b..879b8a57e3 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -502,7 +502,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
         return ff_opus_error_to_averror(ret);
     }
 
-    av_shrink_packet(avpkt, ret);
+    av_packet_resize(avpkt, ret);
 
     ff_af_queue_remove(&opus->afq, opus->opts.packet_size,
                        &avpkt->pts, &avpkt->duration);
diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c
index 5ceb3d9f3f..da7a250507 100644
--- a/libavcodec/libtwolame.c
+++ b/libavcodec/libtwolame.c
@@ -167,7 +167,7 @@ static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     if (avpkt->pts != AV_NOPTS_VALUE)
         s->next_pts = avpkt->pts + avpkt->duration;
 
-    av_shrink_packet(avpkt, ret);
+    av_packet_resize(avpkt, ret);
     *got_packet_ptr = 1;
     return 0;
 }
diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
index baf067c205..c87fe59985 100644
--- a/libavcodec/rpzaenc.c
+++ b/libavcodec/rpzaenc.c
@@ -802,7 +802,7 @@ static int rpza_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     flush_put_bits(&s->pb);
 
-    av_shrink_packet(pkt, put_bits_count(&s->pb) >> 3);
+    av_packet_resize(pkt, put_bits_count(&s->pb) >> 3);
     buf = pkt->data;
 
     // write header opcode
-- 
2.30.2



More information about the ffmpeg-devel mailing list