static void dirac_AddBlockEncap( block_t **pp_block, dirac_block_encap_t *p_dbe ) { /* must not fail, fixby: adding a p_priv to block_t */ fake_block_t *p_fake = xcalloc( 1, sizeof( *p_fake ) ); block_t *in = *pp_block, *out = &p_fake->fake; block_Init( out, in->p_buffer, in->i_buffer ); out->i_flags = in->i_flags; out->i_nb_samples = in->i_nb_samples; out->i_pts = in->i_pts; out->i_dts = in->i_dts; out->i_length = in->i_length; out->pf_release = dirac_ReleaseBlockAndEncap; p_fake->p_orig = in; p_fake->p_dbe = p_dbe; *pp_block = out; }
static block_t *vlc_av_frame_Wrap(AVFrame *frame) { for (unsigned i = 1; i < AV_NUM_DATA_POINTERS; i++) assert(frame->linesize[i] == 0); /* only packed frame supported */ if (av_frame_make_writable(frame)) /* TODO: read-only block_t */ return NULL; vlc_av_frame_t *b = malloc(sizeof (*b)); if (unlikely(b == NULL)) return NULL; block_t *block = &b->self; block_Init(block, frame->extended_data[0], frame->linesize[0]); block->i_nb_samples = frame->nb_samples; block->pf_release = vlc_av_frame_Release; b->frame = frame; return block; }
static block_t *CaptureBlockNew( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; screen_data_t *p_data = p_sys->p_data; struct block_sys_t *p_block; void *p_buffer; int i_buffer; HBITMAP hbmp; if( p_data->bmi.bmiHeader.biSize == 0 ) { int i_val; /* Create the bitmap info header */ p_data->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); p_data->bmi.bmiHeader.biWidth = p_sys->fmt.video.i_width; p_data->bmi.bmiHeader.biHeight = - p_sys->fmt.video.i_height; p_data->bmi.bmiHeader.biPlanes = 1; p_data->bmi.bmiHeader.biBitCount = p_sys->fmt.video.i_bits_per_pixel; p_data->bmi.bmiHeader.biCompression = BI_RGB; p_data->bmi.bmiHeader.biSizeImage = 0; p_data->bmi.bmiHeader.biXPelsPerMeter = 0; p_data->bmi.bmiHeader.biYPelsPerMeter = 0; p_data->bmi.bmiHeader.biClrUsed = 0; p_data->bmi.bmiHeader.biClrImportant = 0; i_val = var_CreateGetInteger( p_demux, "screen-fragment-size" ); p_data->i_fragment_size = i_val > 0 ? i_val : (int)p_sys->fmt.video.i_height; p_data->i_fragment_size = i_val > (int)p_sys->fmt.video.i_height ? (int)p_sys->fmt.video.i_height : p_data->i_fragment_size; p_sys->f_fps *= (p_sys->fmt.video.i_height/p_data->i_fragment_size); p_sys->i_incr = 1000000 / p_sys->f_fps; p_data->i_fragment = 0; p_data->p_block = 0; } /* Create the bitmap storage space */ hbmp = CreateDIBSection( p_data->hdc_dst, &p_data->bmi, DIB_RGB_COLORS, &p_buffer, NULL, 0 ); if( !hbmp || !p_buffer ) { msg_Err( p_demux, "cannot create bitmap" ); goto error; } /* Select the bitmap into the compatible DC */ if( !p_data->hgdi_backup ) p_data->hgdi_backup = SelectObject( p_data->hdc_dst, hbmp ); else SelectObject( p_data->hdc_dst, hbmp ); if( !p_data->hgdi_backup ) { msg_Err( p_demux, "cannot select bitmap" ); goto error; } /* Build block */ if( !(p_block = (block_sys_t *)malloc( sizeof( block_t ) + sizeof( struct block_sys_t ) )) ) // sunqueen modify goto error; /* Fill all fields */ i_buffer = (p_sys->fmt.video.i_bits_per_pixel + 7) / 8 * p_sys->fmt.video.i_width * p_sys->fmt.video.i_height; block_Init( &p_block->self, p_buffer, i_buffer ); p_block->self.pf_release = CaptureBlockRelease; p_block->hbmp = hbmp; return &p_block->self; error: if( hbmp ) DeleteObject( hbmp ); return NULL; }