[FFmpeg-devel] [PATCH 1/2] avfilter: change ff_inlink_make_frame_writable() to take AVFrame* argument
wm4
nfxjfg at googlemail.com
Sat Jan 28 17:37:41 EET 2017
On Sat, 28 Jan 2017 22:23:53 +0700
Muhammad Faiz <mfcc64 at gmail.com> wrote:
> so the behavior will be similar to
> av_frame_make_writable().
>
> Also use av_frame_copy() replacing
> av_image_copy()/av_samples_copy().
>
> Needed for the next patch.
>
> Suggested-by: wm4 <nfxjfg at googlemail.com>
> Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>
> ---
> libavfilter/avfilter.c | 26 ++++++--------------------
> libavfilter/filters.h | 2 +-
> 2 files changed, 7 insertions(+), 21 deletions(-)
>
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index c12d491..c8dafd2 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -1104,7 +1104,7 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
> filter_frame = default_filter_frame;
>
> if (dst->needs_writable) {
> - ret = ff_inlink_make_frame_writable(link, &frame);
> + ret = ff_inlink_make_frame_writable(link, frame);
> if (ret < 0)
> goto fail;
> }
> @@ -1556,9 +1556,8 @@ int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max,
> return 1;
> }
>
> -int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
> +int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame *frame)
> {
> - AVFrame *frame = *rframe;
> AVFrame *out;
> int ret;
>
> @@ -1585,23 +1584,10 @@ int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
> return ret;
> }
>
> - switch (link->type) {
> - case AVMEDIA_TYPE_VIDEO:
> - av_image_copy(out->data, out->linesize, (const uint8_t **)frame->data, frame->linesize,
> - frame->format, frame->width, frame->height);
> - break;
> - case AVMEDIA_TYPE_AUDIO:
> - av_samples_copy(out->extended_data, frame->extended_data,
> - 0, 0, frame->nb_samples,
> - av_frame_get_channels(frame),
> - frame->format);
> - break;
> - default:
> - av_assert0(!"reached");
> - }
> -
> - av_frame_free(&frame);
> - *rframe = out;
> + av_frame_copy(out, frame);
> + av_frame_unref(frame);
> + av_frame_move_ref(frame, out);
> + av_frame_free(&out);
> return 0;
> }
>
> diff --git a/libavfilter/filters.h b/libavfilter/filters.h
> index 2c78d60..5d32403 100644
> --- a/libavfilter/filters.h
> +++ b/libavfilter/filters.h
> @@ -101,7 +101,7 @@ int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max,
> * This is similar to av_frame_make_writable() except it uses the link's
> * buffer allocation callback, and therefore allows direct rendering.
> */
> -int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe);
> +int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame *frame);
>
> /**
> * Test and acknowledge the change of status on the link.
LGTM. Maybe you should wait for confirmation by Nicolas George or
someone else who knows this code well before you push this.
More information about the ffmpeg-devel
mailing list