ffplay: remove existing AVPicture usage

It is deprecated.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2015-12-08 22:33:31 +01:00
parent 9f82506c79
commit c413d9e635
1 changed files with 27 additions and 24 deletions

View File

@ -858,7 +858,7 @@ static void fill_border(int xleft, int ytop, int width, int height, int x, int y
#define BPP 1 #define BPP 1
static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh) static void blend_subrect(uint8_t **data, int *linesize, const AVSubtitleRect *rect, int imgw, int imgh)
{ {
int x, y, Y, U, V, A; int x, y, Y, U, V, A;
uint8_t *lum, *cb, *cr; uint8_t *lum, *cb, *cr;
@ -869,9 +869,9 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw,
dsth = av_clip(rect->h, 0, imgh); dsth = av_clip(rect->h, 0, imgh);
dstx = av_clip(rect->x, 0, imgw - dstw); dstx = av_clip(rect->x, 0, imgw - dstw);
dsty = av_clip(rect->y, 0, imgh - dsth); dsty = av_clip(rect->y, 0, imgh - dsth);
lum = dst->data[0] + dstx + dsty * dst->linesize[0]; lum = data[0] + dstx + dsty * linesize[0];
cb = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1]; cb = data[1] + dstx/2 + (dsty >> 1) * linesize[1];
cr = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2]; cr = data[2] + dstx/2 + (dsty >> 1) * linesize[2];
for (y = 0; y<dsth; y++) { for (y = 0; y<dsth; y++) {
for (x = 0; x<dstw; x++) { for (x = 0; x<dstw; x++) {
@ -880,7 +880,7 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw,
lum[0] = ALPHA_BLEND(A, lum[0], Y, 0); lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);
lum++; lum++;
} }
lum += dst->linesize[0] - dstw; lum += linesize[0] - dstw;
} }
for (y = 0; y<dsth/2; y++) { for (y = 0; y<dsth/2; y++) {
@ -896,8 +896,8 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw,
cb++; cb++;
cr++; cr++;
} }
cb += dst->linesize[1] - dstw/2; cb += linesize[1] - dstw/2;
cr += dst->linesize[2] - dstw/2; cr += linesize[2] - dstw/2;
} }
} }
@ -944,7 +944,6 @@ static void video_image_display(VideoState *is)
{ {
Frame *vp; Frame *vp;
Frame *sp; Frame *sp;
AVPicture pict;
SDL_Rect rect; SDL_Rect rect;
int i; int i;
@ -955,18 +954,21 @@ static void video_image_display(VideoState *is)
sp = frame_queue_peek(&is->subpq); sp = frame_queue_peek(&is->subpq);
if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 1000)) { if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 1000)) {
uint8_t *data[4];
int linesize[4];
SDL_LockYUVOverlay (vp->bmp); SDL_LockYUVOverlay (vp->bmp);
pict.data[0] = vp->bmp->pixels[0]; data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2]; data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1]; data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0]; linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2]; linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1]; linesize[2] = vp->bmp->pitches[1];
for (i = 0; i < sp->sub.num_rects; i++) for (i = 0; i < sp->sub.num_rects; i++)
blend_subrect(&pict, sp->subrects[i], blend_subrect(data, linesize, sp->subrects[i],
vp->bmp->w, vp->bmp->h); vp->bmp->w, vp->bmp->h);
SDL_UnlockYUVOverlay (vp->bmp); SDL_UnlockYUVOverlay (vp->bmp);
@ -1760,22 +1762,23 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double
/* if the frame is not skipped, then display it */ /* if the frame is not skipped, then display it */
if (vp->bmp) { if (vp->bmp) {
AVPicture pict = { { 0 } }; uint8_t *data[4];
int linesize[4];
/* get a pointer on the bitmap */ /* get a pointer on the bitmap */
SDL_LockYUVOverlay (vp->bmp); SDL_LockYUVOverlay (vp->bmp);
pict.data[0] = vp->bmp->pixels[0]; data[0] = vp->bmp->pixels[0];
pict.data[1] = vp->bmp->pixels[2]; data[1] = vp->bmp->pixels[2];
pict.data[2] = vp->bmp->pixels[1]; data[2] = vp->bmp->pixels[1];
pict.linesize[0] = vp->bmp->pitches[0]; linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2]; linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1]; linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER #if CONFIG_AVFILTER
// FIXME use direct rendering // FIXME use direct rendering
av_picture_copy(&pict, (AVPicture *)src_frame, av_image_copy(data, linesize, (const uint8_t **)src_frame->data, src_frame->linesize,
src_frame->format, vp->width, vp->height); src_frame->format, vp->width, vp->height);
#else #else
{ {
@ -1798,7 +1801,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double
exit(1); exit(1);
} }
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize, sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, pict.data, pict.linesize); 0, vp->height, data, linesize);
#endif #endif
/* workaround SDL PITCH_WORKAROUND */ /* workaround SDL PITCH_WORKAROUND */
duplicate_right_border_pixels(vp->bmp); duplicate_right_border_pixels(vp->bmp);