[FFmpeg-devel] [PATCH] fix missing blue channel when switching from/to fullscren on OSX and libsdl 1.2.14. Fixes issue 548

Marton Balint cus at passwd.hu
Thu Oct 20 00:54:54 CEST 2011


> Updated
> ---
> ffplay.c |   34 ++++++++++++++++++++++++++--------
> 1 files changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/ffplay.c b/ffplay.c
> index ffd6ae5..9d8c96a 100644
> --- a/ffplay.c
> +++ b/ffplay.c
> @@ -101,7 +101,7 @@ typedef struct VideoPicture {
>     int skip;
>     SDL_Overlay *bmp;
>     int width, height; /* source height & width */
> -    int allocated;
> +    int allocated, fullscreentoggled;
>     enum PixelFormat pix_fmt;
>
> #if CONFIG_AVFILTER
> @@ -863,15 +863,9 @@ static void video_audio_display(VideoState *s)
>     }
> }
>
> -static void stream_close(VideoState *is)
> -{
> +static void free_all_pictures(VideoState *is){
>     VideoPicture *vp;
>     int i;
> -    /* XXX: use a special url_shutdown call to abort parse cleanly */
> -    is->abort_request = 1;
> -    SDL_WaitThread(is->read_tid, NULL);
> -    SDL_WaitThread(is->refresh_tid, NULL);
> -
>     /* free all pictures */
>     for(i=0;i<VIDEO_PICTURE_QUEUE_SIZE; i++) {
>         vp = &is->pictq[i];
> @@ -886,6 +880,17 @@ static void stream_close(VideoState *is)
>             vp->bmp = NULL;
>         }
>     }
> +}
> +
> +static void stream_close(VideoState *is)
> +{
> +    /* XXX: use a special url_shutdown call to abort parse cleanly */
> +    is->abort_request = 1;
> +    SDL_WaitThread(is->read_tid, NULL);
> +    SDL_WaitThread(is->refresh_tid, NULL);
> +
> +    free_all_pictures(is);
> +
>     SDL_DestroyMutex(is->pictq_mutex);
>     SDL_DestroyCond(is->pictq_cond);
>     SDL_DestroyMutex(is->subpq_mutex);
> @@ -1342,6 +1347,11 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_
>
>     vp->duration = frame_delay;
>
> +    if(vp->fullscreentoggled){
> +        free_all_pictures(is);
> +        vp->fullscreentoggled = 0;
> +    }

That is not what I had in mind. Freeing all pictures here is also 
problematic because of the other thread may be using the pictq[rindex] 
picture.

> +
>     /* alloc or resize hardware picture buffer */
>     if (!vp->bmp ||
> #if CONFIG_AVFILTER
> @@ -2707,8 +2717,16 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
>
> static void toggle_full_screen(VideoState *is)
> {
> +    VideoPicture *vp;
>     is_full_screen = !is_full_screen;
> +
> +#if defined(__APPLE__) && SDL_VERSION_ATLEAST(1, 2, 14)
> +    /* OSX needs to empty the picture_queue */
> +    vp = &is->pictq[is->pictq_windex];
> +    vp->fullscreentoggled = 1;
> +#else
>     video_open(is);
> +#endif

I don't understand why video_open is not allowed for APPLE here. It should 
not make any difference, because sooner or later we will do the video_open 
call. (next alloc picture calls it for example). Or am I missing 
something?

> }
>
> static void toggle_pause(VideoState *is)
> -- 
> 1.7.7

Please check the attached patch, that is what I meant by making the queue 
picture function allocate (and call ALLOC EVENT to free) the old SDL 
overlays.

I wonder if it fixes the problem. If it does not, then please check it 
with video_open in the #else part of the #if as well, like you proposed.

Regards,
Marton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: realloc_on_fullscreen.patch
Type: text/x-patch
Size: 1457 bytes
Desc: 
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111020/1585bc13/attachment.bin>


More information about the ffmpeg-devel mailing list