From: Paul B Mahol <onemda@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] avfilter/src_movie: dr support Date: Mon, 15 May 2023 23:18:28 +0200 Message-ID: <CAPYw7P6awCb5zWFGC8euPRHRY_8gcZ+S2OSn7PT6E4nLgDxToQ@mail.gmail.com> (raw) [-- Attachment #1: Type: text/plain, Size: 10 bytes --] Attached. [-- Attachment #2: 0002-avfilter-src_movie-dr-support.patch --] [-- Type: text/x-patch, Size: 2429 bytes --] From 6fddad6ea2abf91a7378fb367a439441ef8f32b4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol <onemda@gmail.com> Date: Mon, 15 May 2023 21:54:25 +0200 Subject: [PATCH 2/3] avfilter/src_movie: dr support Signed-off-by: Paul B Mahol <onemda@gmail.com> --- libavfilter/src_movie.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index a7d7c188e6..0629030f91 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -23,7 +23,6 @@ * @file * movie video source * - * @todo use direct rendering (no allocation of a new frame) * @todo support a PTS correction mechanism */ @@ -158,6 +157,31 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) return found; } +static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) +{ + AVFrame *new; + + if (flags & AV_GET_BUFFER_FLAG_REF) + return avcodec_default_get_buffer2(avctx, frame, flags); + + switch (avctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: + new = ff_get_video_buffer(frame->opaque, frame->width, frame->height); + break; + case AVMEDIA_TYPE_AUDIO: + new = ff_get_audio_buffer(frame->opaque, frame->nb_samples); + break; + default: + return -1; + } + + av_frame_unref(frame); + av_frame_move_ref(frame, new); + av_frame_free(&new); + + return 0; +} + static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) { const AVCodec *codec; @@ -173,6 +197,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) if (!st->codec_ctx) return AVERROR(ENOMEM); + st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE; + st->codec_ctx->get_buffer2 = get_buffer; ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar); if (ret < 0) return ret; @@ -480,8 +506,10 @@ static int movie_decode_packet(AVFilterContext *ctx) /* 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]; - if (pkt_out_id >= 0) + if (pkt_out_id >= 0) { + pkt.opaque = ctx->outputs[pkt_out_id]; ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, &pkt); + } av_packet_unref(&pkt); return ret; -- 2.39.1 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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".
next reply other threads:[~2023-05-15 21:19 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-15 21:18 Paul B Mahol [this message] 2023-05-15 21:45 ` James Almer 2023-05-16 16:48 ` Paul B Mahol 2023-05-16 16:59 ` James Almer 2023-05-16 17:58 ` Paul B Mahol 2023-05-16 18:03 ` James Almer 2023-05-16 18:11 ` Paul B Mahol 2023-05-16 19:05 ` James Almer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAPYw7P6awCb5zWFGC8euPRHRY_8gcZ+S2OSn7PT6E4nLgDxToQ@mail.gmail.com \ --to=onemda@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git