diff mbox series

[FFmpeg-devel] avfilter/src_movie: stop using AVPacket on stack

Message ID 20230520024005.4743-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avfilter/src_movie: stop using AVPacket on stack | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer May 20, 2023, 2:40 a.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavfilter/src_movie.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Paul B Mahol May 20, 2023, 9:41 a.m. UTC | #1
Why you doing this to me?
I already did this in my patch, that you ignored.
James Almer May 20, 2023, 11:18 a.m. UTC | #2
On 5/20/2023 6:41 AM, Paul B Mahol wrote:
> Why you doing this to me?
> I already did this in my patch, that you ignored.

You did it in the activate patch, that i did not look at because i could 
not review it, sorry.

Patch dropped then.
Paul B Mahol May 20, 2023, 11:43 a.m. UTC | #3
On 5/20/23, James Almer <jamrial@gmail.com> wrote:
> On 5/20/2023 6:41 AM, Paul B Mahol wrote:
>> Why you doing this to me?
>> I already did this in my patch, that you ignored.
>
> You did it in the activate patch, that i did not look at because i could
> not review it, sorry.
>
> Patch dropped then.

I can push this your patch, and just rebase mine, if you prefer that approach.

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
James Almer May 20, 2023, noon UTC | #4
On 5/20/2023 8:43 AM, Paul B Mahol wrote:
> On 5/20/23, James Almer <jamrial@gmail.com> wrote:
>> On 5/20/2023 6:41 AM, Paul B Mahol wrote:
>>> Why you doing this to me?
>>> I already did this in my patch, that you ignored.
>>
>> You did it in the activate patch, that i did not look at because i could
>> not review it, sorry.
>>
>> Patch dropped then.
> 
> I can push this your patch, and just rebase mine, if you prefer that approach.

No, your set predates this, so just push your activate patch with these 
changes whenever is ready.
diff mbox series

Patch

diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 5937613d13..b55c2bcb6e 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -72,6 +72,7 @@  typedef struct MovieContext {
     int dec_threads;
 
     AVFormatContext *format_ctx;
+    AVPacket *pkt;
 
     int max_stream_index; /**< max stream # actually used for output */
     MovieStream *st; /**< array of all streams, one per output */
@@ -279,6 +280,10 @@  static av_cold int movie_common_init(AVFilterContext *ctx)
     for (i = 0; i < movie->format_ctx->nb_streams; i++)
         movie->format_ctx->streams[i]->discard = AVDISCARD_ALL;
 
+    movie->pkt = av_packet_alloc();
+    if (!movie->pkt)
+        return AVERROR(ENOMEM);
+
     movie->st = av_calloc(nb_streams, sizeof(*movie->st));
     if (!movie->st)
         return AVERROR(ENOMEM);
@@ -348,6 +353,7 @@  static av_cold void movie_uninit(AVFilterContext *ctx)
     av_freep(&movie->out_index);
     if (movie->format_ctx)
         avformat_close_input(&movie->format_ctx);
+    av_packet_free(&movie->pkt);
 }
 
 static int movie_query_formats(AVFilterContext *ctx)
@@ -459,11 +465,11 @@  static int rewind_file(AVFilterContext *ctx)
 static int movie_decode_packet(AVFilterContext *ctx)
 {
     MovieContext *movie = ctx->priv;
-    AVPacket pkt = { 0 };
+    AVPacket *pkt = movie->pkt;
     int pkt_out_id, ret;
 
     /* read a new packet from input stream */
-    ret = av_read_frame(movie->format_ctx, &pkt);
+    ret = av_read_frame(movie->format_ctx, pkt);
     if (ret == AVERROR_EOF) {
         /* EOF -> set all decoders for flushing */
         for (int i = 0; i < ctx->nb_outputs; i++) {
@@ -477,11 +483,11 @@  static int movie_decode_packet(AVFilterContext *ctx)
         return ret;
 
     /* send the packet to its decoder, if any */
-    pkt_out_id = pkt.stream_index > movie->max_stream_index ? -1 :
-                 movie->out_index[pkt.stream_index];
+    pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 :
+                 movie->out_index[pkt->stream_index];
     if (pkt_out_id >= 0)
-        ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, &pkt);
-    av_packet_unref(&pkt);
+        ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, pkt);
+    av_packet_unref(pkt);
 
     return ret;
 }