memory leaks and tweaks, sams histeq icon
[goodguy/history.git] / cinelerra-5.1 / cinelerra / fileffmpeg.C
index 99fa71193af683c2df5194f7f67911ccf2bfeea9..82a810d61794dad65817b130262023ed5d40ea91 100644 (file)
@@ -335,38 +335,33 @@ int FileFFMPEG::colormodel_supported(int colormodel)
        return colormodel;
 }
 
-int FileFFMPEG::get_best_colormodel(Asset *asset, int driver)
+
+int FileFFMPEG::get_best_colormodel(int driver, int vstream)
 {
+       if( vstream < 0 ) vstream = 0;
+       int is_mpeg = !ff ? 0 : ff->ff_video_mpeg_color_range(vstream);
+
        switch(driver) {
        case PLAYBACK_X11:
-               return BC_RGB888;
-       case PLAYBACK_X11_XV:
-       case PLAYBACK_ASYNCHRONOUS:
-               return BC_YUV888;
-       case PLAYBACK_X11_GL:
-               return BC_YUV888;
-       case PLAYBACK_DV1394:
-       case PLAYBACK_FIREWIRE:
-               return BC_YUV422P;
-       case VIDEO4LINUX2:
-               return BC_RGB888;
-       case VIDEO4LINUX2JPEG:
-               return BC_COMPRESSED;
-       case CAPTURE_DVB:
-       case VIDEO4LINUX2MPEG:
-               return BC_YUV422P;
-       case CAPTURE_JPEG_WEBCAM:
-               return BC_COMPRESSED;
-       case CAPTURE_YUYV_WEBCAM:
-               return BC_YUV422;
-       case CAPTURE_FIREWIRE:
-       case CAPTURE_IEC61883:
-               return BC_YUV422P;
+       case PLAYBACK_X11_GL: return is_mpeg ? BC_YUV888 : BC_RGB888;
+       case PLAYBACK_X11_XV: return BC_YUV420P;
        }
 
        return BC_RGB888;
 }
 
+int FileFFMPEG::get_best_colormodel(Asset *asset, int driver)
+{
+       switch(driver) {
+// the direct X11 color model requires scaling in the codec
+       case PLAYBACK_X11:
+       case PLAYBACK_X11_GL: return BC_RGB888;
+       case PLAYBACK_X11_XV: return BC_YUV420P;
+       }
+
+       return BC_YUV420P;
+}
+
 int FileFFMPEG::can_render(const char *fformat, const char *type)
 {
        FileSystem fs;