1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| SDL_Surface *screen;
static const Uint32 FLAGS_DEFAULT_VALUE =
SDL_HWSURFACE |
SDL_DOUBLEBUF |
SDL_ASYNCBLIT |
SDL_HWACCEL |
SDL_RESIZABLE;
screen = SDL_SetVideoMode(width, height, 24, FLAGS_DEFAULT_VALUE);
SDL_Overlay *bmp;
bmp = SDL_CreateYUVOverlay(width, height, SDL_YV12_OVERLAY, screen);
SDL_Rect rect;
SDL_Color noir;
noir.r = 0;
noir.g = 0;
noir.b = 0;
TTF_Font* police = TTF_OpenFont("arial.ttf", 60);
SDL_Surface* texte = TTF_RenderUTF8_Blended(police, "Test", noir);
while (true) {
decompressor.readNextFrame();
SDL_LockYUVOverlay(bmp);
AVPicture pict;
pict.data[0] = bmp->pixels[0];
pict.data[1] = bmp->pixels[2];
pict.data[2] = bmp->pixels[1];
pict.linesize[0] = bmp->pitches[0];
pict.linesize[1] = bmp->pitches[2];
pict.linesize[2] = bmp->pitches[1];
AVPictureAdapter* source = new AVPictureAdapter(decompressor.getDecoderStruct().pFrame);
AVPictureAdapter* dest = new AVPictureAdapter(&pict);
FormatConverter::convert(
source,
decompressor.getDecoderStruct().pCodecCtx->pix_fmt,
PIX_FMT_YUV420P,
height,
width,
dest
);
source->setMember(NULL);
dest->setMember(NULL);
delete source;
delete dest;
SDL_UnlockYUVOverlay(bmp);
rect.x = 0;
rect.y = 0;
rect.w = width;
rect.h = height;
SDL_DisplayYUVOverlay(bmp, &rect);
SDL_BlitSurface(texte, NULL, screen, NULL);
SDL_Flip(screen);
}
return EXIT_SUCCESS;
} |
Partager