Revision b07bcb88 chunker_player/player_core.c

View differences:

chunker_player/player_core.c
832 832
// Render a Frame to a YUV Overlay. Note that the Overlay is already bound to an SDL Surface
833 833
// Note that width, height would not be needed in new ffmpeg versions where this info is contained in AVFrame
834 834
// see: [FFmpeg-devel] [PATCH] lavc: add width and height fields to AVFrame
835
int RenderFrame2Overlay(AVFrame *pFrame, int frame_width, int frame_height, SDL_Overlay *YUVOverlay)
835
int RenderFrame2Overlay(AVFrame *pFrame, int frame_width, int frame_height, int tcrop, int bcrop,  SDL_Overlay *YUVOverlay)
836 836
{
837 837
	AVPicture pict;
838
	unsigned int ycrop = 50;
838 839
	static struct SwsContext *img_convert_ctx = NULL;	//if the function is used for more streams, this could be made part of some context passed as a parameter (to optimize performance)
839 840

  
840 841
					if(SDL_LockYUVOverlay(YUVOverlay) < 0) {
......
849 850
					pict.linesize[1] = YUVOverlay->pitches[2];
850 851
					pict.linesize[2] = YUVOverlay->pitches[1];
851 852

  
852
					img_convert_ctx = sws_getCachedContext(img_convert_ctx, frame_width, frame_height, PIX_FMT_YUV420P, YUVOverlay->w, YUVOverlay->h, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
853
					img_convert_ctx = sws_getCachedContext(img_convert_ctx, frame_width, frame_height - tcrop - bcrop, PIX_FMT_YUV420P, YUVOverlay->w, YUVOverlay->h, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
853 854
					if(img_convert_ctx == NULL) {
854 855
						fprintf(stderr, "Cannot initialize the conversion context!\n");
855 856
						exit(1);
856 857
					}
857 858

  
858 859
					// let's draw the data (*yuv[3]) on a SDL screen (*screen)
859
					sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, frame_height, pict.data, pict.linesize);
860
					sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, -tcrop, frame_height - bcrop, pict.data, pict.linesize);
860 861
					SDL_UnlockYUVOverlay(YUVOverlay);
861 862

  
862 863
	return 0;
......
1084 1085
						continue;
1085 1086

  
1086 1087
					SDL_LockMutex(OverlayMutex);
1087
					if (RenderFrame2Overlay(pFrame, pCodecCtx->width, pCodecCtx->height, YUVOverlay) < 0){
1088
					if (RenderFrame2Overlay(pFrame, pCodecCtx->width, pCodecCtx->height, 0, 0, YUVOverlay) < 0){
1088 1089
						SDL_UnlockMutex(OverlayMutex);
1089 1090
						continue;
1090 1091
					}

Also available in: Unified diff