add vicons
[goodguy/history.git] / cinelerra-5.0 / guicast / bcbitmap.C
index 6515d1853b9ba69557744cd9e8f8c3eaae0b2ab1..dedb03b49ec6f56a01362619ab4df399947edf28 100644 (file)
@@ -150,7 +150,7 @@ BC_XvShmImage::BC_XvShmImage(BC_Bitmap *bitmap, int index,
        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];
@@ -219,11 +219,13 @@ BC_XvImage::BC_XvImage(BC_Bitmap *bitmap, int index,
        int id = BC_CModels::bc_to_x(color_model);
        xv_image = XvCreateImage(display, bitmap->xv_portid, id, 0, w, h);
        dataSize = xv_image->data_size;
-       data = new unsigned char[dataSize + 8];
+       long data_sz = dataSize + 8;
+       data = new unsigned char[data_sz];
+       memset(data, 0, data_sz);
        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 )
@@ -250,7 +252,9 @@ BC_XImage::BC_XImage(BC_Bitmap *bitmap, int index,
        bytesPerLine = ximage->bytes_per_line;
        bitsPerPixel = ximage->bits_per_pixel;
        dataSize = h * bytesPerLine;
-       data = new unsigned char[dataSize + 8];
+       long data_sz = dataSize + 8;
+       data = new unsigned char[data_sz];
+       memset(data, 0, data_sz);
        ximage->data = (char*) data;
        row_data = new unsigned char*[h];
        for( int i=0; i<h; ++i )
@@ -319,6 +323,8 @@ int BC_Bitmap::initialize(BC_WindowBase *parent_window,
        this->parent_window = parent_window;
        this->top_level = parent_window->top_level;
        this->xv_portid = resources->use_xvideo ? top_level->xvideo_port_id : -1;
+       if( w < 1 ) w = 1;
+       if( h < 1 ) h = 1;
        this->w = w;
        this->h = h;
        this->color_model = color_model;
@@ -417,7 +423,6 @@ update_buffers(int count, int lock_avail)
                        BC_BitmapImage *buffer = buffers[i];
                        if( buffer == active_bfr ) active_bfr = 0;
                        if( buffer->is_avail() ) {
-                               avail.remove_pointer(buffer);
                                delete buffer;
                        }
                        else {
@@ -427,10 +432,10 @@ update_buffers(int count, int lock_avail)
                        ++i;
                }
        }
-       if( lock_avail ) avail_lock->unlock();
        delete [] buffers;
        buffers = new_buffers;
        buffer_count = count;
+       if( lock_avail ) avail_lock->unlock();
        //top_level->unlock_window();
 }
 
@@ -652,6 +657,7 @@ int BC_Bitmap::read_frame(VFrame *frame,
                        break;
                default:
                case BC_YUV422:
+               case BC_UVY422:
                        memcpy(get_data(), frame->get_data(), w * h + w * h);
                        break;
                }