if(get_canvas() && !get_canvas()->get_video_on())
{
- if(refresh_frame)
+ if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0)
{
float in_x1, in_y1, in_x2, in_y2;
float out_x1, out_y1, out_x2, out_y2;
- if(refresh_frame)
+ if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0)
{
if(draw)
// Get color out of frame.
// Doesn't work during playback because that bypasses the refresh frame.
- if(refresh_frame)
+ if(refresh_frame && refresh_frame->get_w()>0 && refresh_frame->get_h()>0)
{
float cursor_x = get_cursor_x();
float cursor_y = get_cursor_y();
int best_height = config_height;
unsigned int best_format = 0;
int best_merit = 0;
- //int best_color_model = -1;
+ int best_color_model = -1;
int best_area = 1;
int driver = video_device->in_config->driver;
int cmodel = -1;
switch(fmt.pixelformat)
{
+ case V4L2_PIX_FMT_UYVY: cmodel = BC_UVY422; merit = 4; break;
case V4L2_PIX_FMT_YUYV: cmodel = BC_YUV422; merit = 4; break;
case V4L2_PIX_FMT_Y41P: cmodel = BC_YUV411P; merit = 1; break;
case V4L2_PIX_FMT_YVU420: cmodel = BC_YUV420P; merit = 3; break;
{
best_merit = merit;
best_format = fmt.pixelformat;
- //best_color_model = cmodel;
+ best_color_model = cmodel;
}
for( int n=0; n<20; ++n ) {
best_format = V4L2_PIX_FMT_MPEG;
break;
default:
+ best_color_model = color_model;
best_format = cmodel_to_device(color_model);
break;
}
perror("DeviceV4L2Base::v4l2_open VIDIOC_S_JPEGCOMP");
}
- this->color_model = color_model;
+ this->color_model = best_color_model;
return 0;
}
{
case BC_COMPRESSED: return V4L2_PIX_FMT_MJPEG;
case BC_YUV422: return V4L2_PIX_FMT_YUYV;
+ case BC_UVY422: return V4L2_PIX_FMT_UYVY;
case BC_YUV411P: return V4L2_PIX_FMT_Y41P;
case BC_YUV420P: return V4L2_PIX_FMT_YVU420;
case BC_YUV422P: return V4L2_PIX_FMT_YUV422P;
double Edit::picon_w()
{
- if(asset)
- return (double)edl->local_session->zoom_track *
- asset->width /
- asset->height;
- if(nested_edl)
- return (double)edl->local_session->zoom_track *
- nested_edl->session->output_w /
- nested_edl->session->output_h;
-
- return 0;
+ int w = 0, h = 0;
+ if(asset) {
+ w = asset->width;
+ h = asset->height;
+ }
+ else if(nested_edl) {
+ w = nested_edl->session->output_w;
+ h = nested_edl->session->output_h;
+ }
+ return w>0 && h>0 ? ((double)edl->local_session->zoom_track*w)/h : 0;
}
int Edit::picon_h()
int64_t picon_h = edit->picon_h();
-// Don't draw video if picon is bigger than edit
- if(picon_w > edit_w) return;
+// Don't draw video if picon is empty or bigger than edit
+ if( picon_w <= 0 || picon_w > edit_w ) return;
// pixels spanned by a frame
double frame_w = edit->frame_w();
int result = get_sources();
if( !result )
{
- device->channel->use_frequency = 1;
- device->channel->use_fine = 1;
+ ArrayList<Channel*> *inputs = device->get_inputs();
+ for( int i=0; i<inputs->size(); ++i ) {
+ if( inputs->get(i)->tuner ) {
+ device->channel->use_frequency = 1;
+ device->channel->use_fine = 1;
+ }
+ else
+ device->channel->use_input = 1;
+ }
}
return result;
}
VFrame *buffer = device_buffer(bfr);
//printf("VDeviceV4L2::read_buffer %d %p %p\n",
// __LINE__, frame->get_data(), buffer->get_data());
- frame->copy_from(buffer);
+ frame->transfer_from(buffer);
put_buffer(bfr);
}
else
// FileMOV needs to have write_frames called so the start codes get scanned.
return ((driver == CAPTURE_BUZ && use_fixed) ||
(driver == VIDEO4LINUX2JPEG && use_fixed) ||
- (driver == VIDEO4LINUX2MPEG && use_fixed) ||
(driver == CAPTURE_JPEG_WEBCAM && use_fixed) ||
driver == CAPTURE_LML ||
driver == CAPTURE_FIREWIRE ||
h = xv_image->height;
if(!XShmAttach(top_level->display, &shm_info))
perror("BC_XvShmImage::BC_XvShmImage XShmAttach");
- if( color_model == BC_YUV422 ) {
+ if( color_model == BC_YUV422 || color_model == BC_UVY422 ) {
bytesPerLine = w*2;
bitsPerPixel = 12;
row_data = new unsigned char*[h];
xv_image->data = (char *) data;
w = xv_image->width;
h = xv_image->height;
- if( color_model == BC_YUV422 ) {
+ if( color_model == BC_YUV422 || color_model == BC_UVY422 ) {
int bytesPerLine = w*2;
row_data = new unsigned char*[h];
for( int i=0; i<h; ++i )
break;
default:
case BC_YUV422:
+ case BC_UVY422:
memcpy(get_data(), frame->get_data(), w * h + w * h);
break;
}
},
},
+ "uyvy8888": {
+ "i8": {
+ "r": " int32_t u = inp[0], iy = inp[((i&1)<<1)+1], y = iy*0x010101u, v = inp[2];",
+ "w": " if( !(j&1) ) { *out++ = u; *out++ = y; *out++ = v; *out = y; }\n" +
+ " else { *out++= y; }",
+ },
+ "i16": {
+ "r": " int32_t u = inp[0]<<8, iy = inp[((i&1)<<1)+1], y = iy*0x010101u, v = inp[2]<<8;",
+ "w": " if( !(j&1) ) { *out++ = u>>8; *out++ = y>>8; *out++ = v>>8; *out = y>>8; }\n" +
+ " else { *out++= y>>8; }",
+ },
+ },
+
"yuv10101010": {
"i8": {
"r": " uint32_t it = *(uint32_t*)inp;\n" +
add_cmodel("bc_yuva16161616", "i16", "yuv161616", "a16")
add_cmodel("bc_yuv422", "i8", "yuyv8888")
+add_cmodel("bc_uvy422", "i8", "uyvy8888")
add_cmodel("bc_a8")
add_cmodel("bc_a16")
add_cmodel("bc_a_float")
def is_yuv(nm):
return nm in [ "bc_yuv888", "bc_yuva8888", "bc_yuv161616", \
- "bc_yuva16161616", "bc_yuv422", "bc_yuv101010", "bc_vyu888", \
- "bc_uyva8888", "bc_yuv420p", "bc_yuv422p", "bc_yuv444p", \
- "bc_yuv411p", "bc_yuv410p", ]
+ "bc_yuva16161616", "bc_yuv422", "bc_uvy422", "bc_yuv101010", \
+ "bc_vyu888", "bc_uyva8888", "bc_yuv420p", "bc_yuv422p", \
+ "bc_yuv444p", "bc_yuv411p", "bc_yuv410p", ]
def is_planar(nm):
return nm in [ "bc_yuv420p", "bc_yuv422p", "bc_yuv444p", \
case BC_YUV422P: return 1;
case BC_YUV444P: return 1;
case BC_YUV422: return 2;
+ case BC_UVY422: return 2;
case BC_YUV411P: return 1;
case BC_YUV410P: return 1;
case BC_RGB_FLOATP: return 4;
switch(color_model) {
case BC_YUV420P: return FOURCC_YV12;
case BC_YUV422: return FOURCC_YUV2;
+ case BC_UVY422: return FOURCC_UYVY;
}
return -1;
}
case BC_YUV161616:
case BC_YUVA16161616:
case BC_YUV422:
+ case BC_UVY422:
case BC_YUV101010:
case BC_VYU888:
case BC_UYVA8888:
#define BC_YUVA8888 14
#define BC_YUV161616 15
#define BC_YUVA16161616 16
+#define BC_UVY422 18
#define BC_YUV422 19
#define BC_A8 22
#define BC_A16 23
#define BC_RGBA_FLOAT 30
// Planar
#define BC_YUV420P 7
-#define BC_YUV422P 17
+#define BC_YUV422P 8
#define BC_YUV444P 27
-#define BC_YUV411P 18
+#define BC_YUV411P 17
#define BC_YUV410P 28
#define BC_RGB_FLOATP 32
#define BC_RGBA_FLOATP 33
// For communication with the X Server
#define FOURCC_YV12 0x32315659 /* YV12 YUV420P */
#define FOURCC_YUV2 0x32595559 /* YUV2 YUV422 */
+#define FOURCC_UYVY 0x59565955 /* UYVY UVY422 */
#define FOURCC_I420 0x30323449 /* I420 Intel Indeo 4 */
const char *cmdl[] = {
"transparency", "compressed", "rgb8", "rgb565", "bgr565", "bgr888", "bgr8888", "yuv420p",
- "none", "rgb888", "rgba8888", "rgb161616", "rgba16161616", "yuv888", "yuva8888", "yuv161616",
- "yuva16161616", "yuv422p", "yuv411p", "yuv422", "argb8888", "abgr8888", "a8", "a16",
+ "yuv422p", "rgb888", "rgba8888", "rgb161616", "rgba16161616", "yuv888", "yuva8888", "yuv161616",
+ "yuva16161616", "yuv411p", "uvy422", "yuv422", "argb8888", "abgr8888", "a8", "a16",
"yuv101010", "vyu888", "uyva8888", "yuv444p", "yuv410p", "rgb_float", "rgba_float", "a_float",
- "rgb_floatp",
+ "rgb_floatp", "rgba_floatp",
};
void write_pbm(uint8_t *tp, int w, int h, const char *fmt, ...)
return this->copy_from(that);
timestamp = that->timestamp;
+#if 0
BC_CModels::transfer(
this->get_rows(), that->get_rows(), // Packed data out/in
this->get_y(), this->get_u(), this->get_v(), // Planar data out/in
that->get_color_model(), this->get_color_model(), // Color models in/out
bg_color, // alpha blend bg_color
that->get_w(), this->get_w()); // rowspans (of luma for YUV)
+#else
+ unsigned char *in_ptrs[4], *out_ptrs[4];
+ unsigned char **inp, **outp;
+ if( BC_CModels::is_planar(that->get_color_model()) ) {
+ in_ptrs[0] = that->get_y();
+ in_ptrs[1] = that->get_u();
+ in_ptrs[2] = that->get_v();
+ in_ptrs[3] = that->get_a();
+ inp = in_ptrs;
+ }
+ else
+ inp = that->get_rows();
+ if( BC_CModels::is_planar(this->get_color_model()) ) {
+ out_ptrs[0] = this->get_y();
+ out_ptrs[1] = this->get_u();
+ out_ptrs[2] = this->get_v();
+ out_ptrs[3] = this->get_a();
+ outp = out_ptrs;
+ }
+ else
+ outp = this->get_rows();
+ BC_CModels::transfer(outp, this->get_color_model(),
+ 0, 0, this->get_w(), this->get_h(), this->get_w(),
+ inp, that->get_color_model(),
+ 0, 0, that->get_w(), that->get_h(), that->get_w(),
+ bg_color);
+#endif
return 0;
}
{
// prevent bounds errors on poorly dimensioned macro pixel formats
switch( in_colormodel ) {
+ case BC_UVY422:
case BC_YUV422: in_w &= ~1; break; // 2x1
case BC_YUV420P: in_w &= ~1; in_h &= ~1; break; // 2x2
case BC_YUV422P: in_w &= ~1; break; // 2x1
case BC_YUV411P: in_w &= ~3; break; // 4x1
}
switch( out_colormodel ) {
+ case BC_UVY422:
case BC_YUV422: out_w &= ~1; break;
case BC_YUV420P: out_w &= ~1; out_h &= ~1; break;
case BC_YUV422P: out_w &= ~1; break;
double hscale = (double)in_w/out_w;
for( int i=0; i<out_w; ++i ) {
column_table[i] = ((int)(hscale * i) + in_x) * in_pixelsize;
- if( in_colormodel == BC_YUV422 ) column_table[i] &= ~3;
+ if( in_colormodel == BC_YUV422 || in_colormodel == BC_UVY422 )
+ column_table[i] &= ~3;
}
double vscale = (double)in_h/out_h;
row_table = new int[out_h];
#define BC_YUVA8888 14
#define BC_YUV161616 15
#define BC_YUVA16161616 16
+#define BC_UVY422 18
#define BC_YUV422 19
#define BC_A8 22
#define BC_A16 23
#define BC_RGBA_FLOAT 30
// Planar
#define BC_YUV420P 7
-#define BC_YUV422P 17
-//#define BC_YUV411P 18 // broken
+#define BC_YUV422P 8
+//#define BC_YUV411P 17 // broken
#define BC_YUV444P 27
#define BC_YUV9P 28 // Disasterous cmodel from Sorenson
// For communication with the X Server
#define FOURCC_YV12 0x32315659 /* YV12 YUV420P */
#define FOURCC_YUV2 0x32595559 /* YUV2 YUV422 */
+#define FOURCC_UYVY 0x59565955 /* UYVY UVY422 */
#define FOURCC_I420 0x30323449 /* I420 Intel Indeo 4 */
#undef CLAMP