Current code segfaults since the deprecation of AVSubtitleRect.pict because it frees/reallocs AVSubtitleRect.pict.data by itself.
Signed-off-by: Marton Balint <c...@passwd.hu> --- ffplay.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ffplay.c b/ffplay.c index 4a084b4..f888da2 100644 --- a/ffplay.c +++ b/ffplay.c @@ -860,7 +860,7 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int x, y, Y, U, V, A; uint8_t *lum, *cb, *cr; int dstx, dsty, dstw, dsth; - const AVPicture *src = &rect->pict; + const AVSubtitleRect *src = rect; dstw = av_clip(rect->w, 0, imgw); dsth = av_clip(rect->h, 0, imgh); @@ -2304,31 +2304,33 @@ static int subtitle_thread(void *arg) int subh = is->subdec.avctx->height ? is->subdec.avctx->height : is->viddec_height; int out_w = is->viddec_width ? in_w * is->viddec_width / subw : in_w; int out_h = is->viddec_height ? in_h * is->viddec_height / subh : in_h; - AVPicture newpic; + uint8_t* newpic_data[4]; + int newpic_linesize[4]; //can not use avpicture_alloc as it is not compatible with avsubtitle_free() - av_image_fill_linesizes(newpic.linesize, AV_PIX_FMT_YUVA420P, out_w); - newpic.data[0] = av_malloc(newpic.linesize[0] * out_h); - newpic.data[3] = av_malloc(newpic.linesize[3] * out_h); - newpic.data[1] = av_malloc(newpic.linesize[1] * ((out_h+1)/2)); - newpic.data[2] = av_malloc(newpic.linesize[2] * ((out_h+1)/2)); + av_image_fill_linesizes(newpic_linesize, AV_PIX_FMT_YUVA420P, out_w); + newpic_data[0] = av_malloc(newpic_linesize[0] * out_h); + newpic_data[3] = av_malloc(newpic_linesize[3] * out_h); + newpic_data[1] = av_malloc(newpic_linesize[1] * ((out_h+1)/2)); + newpic_data[2] = av_malloc(newpic_linesize[2] * ((out_h+1)/2)); is->sub_convert_ctx = sws_getCachedContext(is->sub_convert_ctx, in_w, in_h, AV_PIX_FMT_PAL8, out_w, out_h, AV_PIX_FMT_YUVA420P, sws_flags, NULL, NULL, NULL); - if (!is->sub_convert_ctx || !newpic.data[0] || !newpic.data[3] || - !newpic.data[1] || !newpic.data[2] + if (!is->sub_convert_ctx || !newpic_data[0] || !newpic_data[3] || + !newpic_data[1] || !newpic_data[2] ) { av_log(NULL, AV_LOG_FATAL, "Cannot initialize the sub conversion context\n"); exit(1); } sws_scale(is->sub_convert_ctx, - (void*)sp->sub.rects[i]->pict.data, sp->sub.rects[i]->pict.linesize, - 0, in_h, newpic.data, newpic.linesize); + (void*)sp->sub.rects[i]->data, sp->sub.rects[i]->linesize, + 0, in_h, newpic_data, newpic_linesize); - av_free(sp->sub.rects[i]->pict.data[0]); - av_free(sp->sub.rects[i]->pict.data[1]); - sp->sub.rects[i]->pict = newpic; + av_free(sp->sub.rects[i]->data[0]); + av_free(sp->sub.rects[i]->data[1]); + memcpy(sp->sub.rects[i]->data, newpic_data, sizeof(newpic_data)); + memcpy(sp->sub.rects[i]->linesize, newpic_linesize, sizeof(newpic_linesize)); sp->sub.rects[i]->w = out_w; sp->sub.rects[i]->h = out_h; sp->sub.rects[i]->x = sp->sub.rects[i]->x * out_w / in_w; -- 2.1.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel