[FFmpeg-cvslog] ffplay: only use hardware accelerated SDL texture formats

Marton Balint git at videolan.org
Sun Nov 12 23:16:41 EET 2017


ffmpeg | branch: release/3.4 | Marton Balint <cus at passwd.hu> | Sat Oct 28 22:46:08 2017 +0200| [46aa734646279ac481e5583d005c8c15b348a244] | committer: Marton Balint

ffplay: only use hardware accelerated SDL texture formats

Typically only a small subset of the SDL texture formats are supported directly
by the SDL renderer drivers, the rest is software emulated. It's better if
libswscale does the format conversion to a hardware-accelerated texture format
instead of SDL.

This should fix video render slowdowns with some texture formats after
3bd2228d05a05eab5f91ac00b01efac9cb07649b.

Signed-off-by: Marton Balint <cus at passwd.hu>
(cherry picked from commit 415038f2bd321a3b41564d4e0c6c17d7a096c397)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46aa734646279ac481e5583d005c8c15b348a244
---

 fftools/ffplay.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index c8f90d4f3b..982340f073 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -1828,10 +1828,18 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
     AVCodecParameters *codecpar = is->video_st->codecpar;
     AVRational fr = av_guess_frame_rate(is->ic, is->video_st, NULL);
     AVDictionaryEntry *e = NULL;
-    int i;
+    int nb_pix_fmts = 0;
+    int i, j;
 
-    for (i = 0; i < FF_ARRAY_ELEMS(pix_fmts); i++)
-        pix_fmts[i] = sdl_texture_format_map[i].format;
+    for (i = 0; i < renderer_info.num_texture_formats; i++) {
+        for (j = 0; j < FF_ARRAY_ELEMS(sdl_texture_format_map) - 1; j++) {
+            if (renderer_info.texture_formats[i] == sdl_texture_format_map[j].texture_fmt) {
+                pix_fmts[nb_pix_fmts++] = sdl_texture_format_map[j].format;
+                break;
+            }
+        }
+    }
+    pix_fmts[nb_pix_fmts] = AV_PIX_FMT_NONE;
 
     while ((e = av_dict_get(sws_dict, "", e, AV_DICT_IGNORE_SUFFIX))) {
         if (!strcmp(e->key, "sws_flags")) {
@@ -3748,7 +3756,7 @@ int main(int argc, char **argv)
                     av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", renderer_info.name);
             }
         }
-        if (!window || !renderer) {
+        if (!window || !renderer || !renderer_info.num_texture_formats) {
             av_log(NULL, AV_LOG_FATAL, "Failed to create window or renderer: %s", SDL_GetError());
             do_exit(NULL);
         }



More information about the ffmpeg-cvslog mailing list