[FFmpeg-devel] [PATCH] ffmpeg: port sub2video to AVFrame.
Stefano Sabatini
stefasab at gmail.com
Sun Mar 10 12:18:11 CET 2013
On date Sunday 2013-03-10 11:54:07 +0100, Nicolas George encoded:
> And re-enable the FATE test.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> ffmpeg.c | 41 ++++++++++++++++++++++++++---------------
> ffmpeg.h | 2 +-
> ffmpeg_filter.c | 16 +++-------------
> tests/fate/ffmpeg.mak | 2 +-
> 4 files changed, 31 insertions(+), 30 deletions(-)
>
>
> Note: I intend to push this one at the same time:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2013-February/139782.html
> if nobody objects.
>
> Note 2: all the AV_BUFFERSRC_FLAG_ need to be repared: I am on it now.
>
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 33d5783..039f957 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -168,7 +168,20 @@ static int restore_tty;
> This is a temporary solution until libavfilter gets real subtitles support.
> */
>
> +static int sub2video_get_blank_frame(InputStream *ist)
> +{
> + int ret;
> + AVFrame *frame = ist->sub2video.frame;
>
> + av_frame_unref(frame);
> + ist->sub2video.frame->width = ist->sub2video.w;
> + ist->sub2video.frame->height = ist->sub2video.h;
> + ist->sub2video.frame->format = AV_PIX_FMT_RGB32;
> + if ((ret = av_frame_get_buffer(frame, 32)) < 0)
> + return ret;
> + memset(frame->data[0], 0, frame->height * frame->linesize[0]);
> + return 0;
> +}
>
> static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h,
> AVSubtitleRect *r)
> @@ -201,28 +214,25 @@ static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h,
>
> static void sub2video_push_ref(InputStream *ist, int64_t pts)
> {
> - AVFilterBufferRef *ref = ist->sub2video.ref;
> + AVFrame *frame = ist->sub2video.frame;
> int i;
>
> - ist->sub2video.last_pts = ref->pts = pts;
> + av_assert1(frame->data[0]);
> + ist->sub2video.last_pts = frame->pts = pts;
> for (i = 0; i < ist->nb_filters; i++)
> - av_buffersrc_add_ref(ist->filters[i]->filter,
> - avfilter_ref_buffer(ref, ~0),
> - AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT |
> - AV_BUFFERSRC_FLAG_NO_COPY |
> - AV_BUFFERSRC_FLAG_PUSH);
> + av_buffersrc_write_frame(ist->filters[i]->filter, frame);
> }
>
> static void sub2video_update(InputStream *ist, AVSubtitle *sub)
> {
> int w = ist->sub2video.w, h = ist->sub2video.h;
> - AVFilterBufferRef *ref = ist->sub2video.ref;
> + AVFrame *frame = ist->sub2video.frame;
> int8_t *dst;
> int dst_linesize;
> int num_rects, i;
> int64_t pts, end_pts;
>
> - if (!ref)
> + if (!frame)
> return;
> if (sub) {
> pts = av_rescale_q(sub->pts + sub->start_display_time * 1000,
> @@ -235,9 +245,10 @@ static void sub2video_update(InputStream *ist, AVSubtitle *sub)
> end_pts = INT64_MAX;
> num_rects = 0;
> }
> - dst = ref->data [0];
> - dst_linesize = ref->linesize[0];
> - memset(dst, 0, h * dst_linesize);
> + if (sub2video_get_blank_frame(ist) < 0)
> + return;
You may add a warning here in case of failure. LGTM otherwise and
thanks.
[...]
--
FFmpeg = Furious & Forgiving Maxi Pitiful Exuberant Guru
More information about the ffmpeg-devel
mailing list