late fix for canvas fullscreen, update ver yet again
[goodguy/history.git] / cinelerra-5.1 / cinelerra / ffmpeg.C
index 25cfbe70fc6f89dba9877d0d8d4405816dd4f0c7..fb5ef21016313563b27fd5f0fd5e6f6a550121ad 100644 (file)
@@ -831,6 +831,9 @@ AVPixelFormat FFVideoConvert::color_model_to_pix_fmt(int color_model)
        case BC_RGBA8888:       return AV_PIX_FMT_RGBA;
        case BC_BGR8888:        return AV_PIX_FMT_BGR0;
        case BC_BGR888:         return AV_PIX_FMT_BGR24;
+       case BC_ARGB8888:       return AV_PIX_FMT_ARGB;
+       case BC_ABGR8888:       return AV_PIX_FMT_ABGR;
+       case BC_RGB8:           return AV_PIX_FMT_RGB8;
        case BC_YUV420P:        return AV_PIX_FMT_YUV420P;
        case BC_YUV422P:        return AV_PIX_FMT_YUV422P;
        case BC_YUV444P:        return AV_PIX_FMT_YUV444P;
@@ -852,6 +855,9 @@ int FFVideoConvert::pix_fmt_to_color_model(AVPixelFormat pix_fmt)
        case AV_PIX_FMT_RGBA:           return BC_RGBA8888;
        case AV_PIX_FMT_BGR0:           return BC_BGR8888;
        case AV_PIX_FMT_BGR24:          return BC_BGR888;
+       case AV_PIX_FMT_ARGB:           return BC_ARGB8888;
+       case AV_PIX_FMT_ABGR:           return BC_ABGR8888;
+       case AV_PIX_FMT_RGB8:           return BC_RGB8;
        case AV_PIX_FMT_YUV420P:        return BC_YUV420P;
        case AV_PIX_FMT_YUV422P:        return BC_YUV422P;
        case AV_PIX_FMT_YUV444P:        return BC_YUV444P;
@@ -862,12 +868,26 @@ int FFVideoConvert::pix_fmt_to_color_model(AVPixelFormat pix_fmt)
        default: break;
        }
 
-       return BC_TRANSPARENCY;
+       return -1;
 }
 
 int FFVideoConvert::convert_picture_vframe(VFrame *frame,
                AVFrame *ip, AVPixelFormat ifmt, int iw, int ih)
 {
+       // try bc_xfer methods
+       int imodel = pix_fmt_to_color_model(ifmt);
+       if( imodel >= 0 ) {
+               long y_ofs = 0, u_ofs = 0, v_ofs = 0;
+               uint8_t *data = ip->data[0];
+               if( BC_CModels::is_yuv(imodel) ) {
+                       u_ofs = ip->data[1] - data;
+                       v_ofs = ip->data[2] - data;
+               }
+               VFrame iframe(data, -1, y_ofs, u_ofs, v_ofs, iw, ih, imodel, ip->linesize[0]);
+               frame->transfer_from(&iframe);
+               return 0;
+       }
+       // try sws methods
        AVFrame opic;
        int cmodel = frame->get_color_model();
        AVPixelFormat ofmt = color_model_to_pix_fmt(cmodel);
@@ -1120,13 +1140,15 @@ AVRational FFMPEG::to_time_base(int sample_rate)
 
 void FFMPEG::set_option_path(char *path, const char *fmt, ...)
 {
-       get_exe_path(path);
-       strcat(path, "/ffmpeg/");
+       char *ep = path + BCTEXTLEN-1;
+       strncpy(path, File::get_cindat_path(), ep-path);
+       strncat(path, "/ffmpeg/", ep-path);
        path += strlen(path);
        va_list ap;
        va_start(ap, fmt);
-       vsprintf(path, fmt, ap);
+       path += vsnprintf(path, ep-path, fmt, ap);
        va_end(ap);
+       *path = 0;
 }
 
 void FFMPEG::get_option_path(char *path, const char *type, const char *spec)
@@ -1161,11 +1183,17 @@ int FFMPEG::get_codec(char *codec, const char *path, const char *spec)
        if( !fp ) return 1;
        int ret = 0;
        if( !fgets(line, sizeof(line), fp) ) ret = 1;
+       fclose(fp);
        if( !ret ) {
                line[sizeof(line)-1] = 0;
                ret = scan_option_line(line, format, codec);
        }
-       fclose(fp);
+       if( !ret ) {
+               char *vp = codec, *ep = vp+BCTEXTLEN-1;
+               while( vp < ep && *vp && *vp != '|' ) ++vp;
+               if( *vp == '|' ) --vp;
+               while( vp > codec && (*vp==' ' || *vp=='\t') ) *vp-- = 0;
+       }
        return ret;
 }