From: Good Guy Date: Tue, 17 May 2016 21:20:55 +0000 (-0600) Subject: improve ffmpeg use of xfer X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=9df45f6232e108a5f36ba415ff7da8a51ca9dbdc;p=goodguy%2Fhistory.git improve ffmpeg use of xfer --- diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index bfd2364a..37a99929 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -862,12 +862,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); diff --git a/cinelerra-5.1/guicast/xfer.C b/cinelerra-5.1/guicast/xfer.C index 87ad6bdd..13f49f82 100644 --- a/cinelerra-5.1/guicast/xfer.C +++ b/cinelerra-5.1/guicast/xfer.C @@ -265,14 +265,12 @@ BC_Xfer::SlicerList BC_Xfer::slicers; BC_Xfer::SlicerList::SlicerList() { - waiting = new Condition(0, "BC_Xfer::SlicerList", 1); count = 0; } BC_Xfer::SlicerList::~SlicerList() { reset(); - delete waiting; } void BC_Xfer::SlicerList::reset() @@ -285,24 +283,24 @@ void BC_Xfer::SlicerList::reset() BC_Xfer::Slicer *BC_Xfer::SlicerList::get_slicer(BC_Xfer *xp) { - while( !first ) { + Slicer *slicer = first; + if( !slicer ) { if( count < BC_Resources::machine_cpus ) { - append(new Slicer(xp)); + slicer = new Slicer(xp); ++count; } - else - waiting->lock("BC_Xfer::SlicerList::get_slicer"); } - Slicer *slicer = first; - remove_pointer(slicer); + else + remove_pointer(slicer); return slicer; } void BC_Xfer::xfer_slices(int slices) { if( !xfn ) return; - int max_slices = BC_Resources::machine_cpus/2+1; + int max_slices = BC_Resources::machine_cpus/2; if( slices > max_slices ) slices = max_slices; + if( slices < 1 ) slices = 1; Slicer *active[slices]; unsigned y0 = 0, y1 = out_h; int slices1 = slices-1; @@ -310,6 +308,7 @@ void BC_Xfer::xfer_slices(int slices) slicers.lock("BC_Xfer::xfer_slices"); for( int i=0; islice(this, y0, y1); @@ -324,7 +323,6 @@ void BC_Xfer::xfer_slices(int slices) for( int i=0; iunlock(); } } diff --git a/cinelerra-5.1/guicast/xfer.h b/cinelerra-5.1/guicast/xfer.h index bb69407f..e6e0aba4 100644 --- a/cinelerra-5.1/guicast/xfer.h +++ b/cinelerra-5.1/guicast/xfer.h @@ -285,7 +285,6 @@ public: class SlicerList : public List, public Mutex { public: int count; - Condition *waiting; Slicer *get_slicer(BC_Xfer *xp); void reset(); SlicerList();