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);
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()
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;
slicers.lock("BC_Xfer::xfer_slices");
for( int i=0; i<slices1; y0=y1 ) {
Slicer *slicer = slicers.get_slicer(this);
+ if( !slicer ) { slices1 = i; break; }
active[i] = slicer;
y1 = out_h * ++i / slices;
slicer->slice(this, y0, y1);
for( int i=0; i<slices1; ++i )
slicers.append(active[i]);
slicers.unlock();
- slicers.waiting->unlock();
}
}