WriteXmlOutcome CRTF_SectionMarker::WriteRedlineMLStart(CComPtr<IXmlWriter>& xmlWriter, RedlineMLWriterContext& context) { if (m_bDeletion && m_bMatched) // synthetic section break for something like redline summary - not wanted in redlineML return (WriteXmlOutcome) (WroteNothing + ProcessedChildren); CHECKHREX(xmlWriter->WriteStartElement(NULL, L"sectionMarker", NULL)); if (!GetBridge()) WriteInsertedOrDeletedRedlineML(xmlWriter); if (!m_bDeletion) { for (int i=0; i<GetHdrFtrCount(); i++) { if (theHdrFtrs[i] == NULL) continue; int iType = GetHdrFtrType(i); if (IsFooter(iType) && context.m_pOptions->m_pOverrideFooter) continue; CHECKHREX(xmlWriter->WriteStartElement(NULL, GetElementName(iType), NULL)); CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"type", NULL, GetHdrFtrTypeAttrVal(iType))); bool isDummy = theDummyFlags[i]; bool otherIsDummy = false; if (GetBridge()) { CRTF_SectionMarker* pBridge = (CRTF_SectionMarker*) GetBridge(); for (int i=0; i<pBridge->GetHdrFtrCount(); i++) { if (pBridge->GetHdrFtrType(i) == iType) { otherIsDummy = pBridge->theDummyFlags[i]; break; } } } if (isDummy && !otherIsDummy) CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"isDeleted", NULL, L"true")); if (otherIsDummy && ! isDummy) CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"isInserted", NULL, L"true")); GetHdrFtrAt(i)->WriteRedlineMLChain(xmlWriter, context); CHECKHREX(xmlWriter->WriteEndElement()); } if (context.m_pOptions->m_pOverrideFooter) { CHECKHREX(xmlWriter->WriteStartElement(NULL, GetElementName(RTFhdrftr::foot), NULL)); CHECKHREX(xmlWriter->WriteAttributeString(NULL, L"type", NULL, GetHdrFtrTypeAttrVal(RTFhdrftr::foot))); context.m_pOptions->m_pOverrideFooter->WriteRedlineMLChain(xmlWriter, context); CHECKHREX(xmlWriter->WriteEndElement()); } } CHECKHREX(xmlWriter->WriteEndElement()); return (WriteXmlOutcome) (WroteStartTag + WroteEndTag + ProcessedChildren); }
static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p_fmt ) { sout_stream_sys_t *p_sys = p_stream->p_sys; bridge_t *p_bridge; bridged_es_t *p_es; char *psz_chain; int i; if( p_sys->b_inited || p_fmt->i_cat != VIDEO_ES ) return NULL; /* Create decoder object */ p_sys->p_decoder = vlc_object_create( p_stream, sizeof( decoder_t ) ); if( !p_sys->p_decoder ) return NULL; p_sys->p_decoder->p_module = NULL; p_sys->p_decoder->fmt_in = *p_fmt; p_sys->p_decoder->b_frame_drop_allowed = true; p_sys->p_decoder->fmt_out = p_sys->p_decoder->fmt_in; p_sys->p_decoder->fmt_out.i_extra = 0; p_sys->p_decoder->fmt_out.p_extra = 0; p_sys->p_decoder->pf_decode_video = 0; p_sys->p_decoder->pf_vout_format_update = video_update_format_decoder; p_sys->p_decoder->pf_vout_buffer_new = video_new_buffer_decoder; p_sys->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) ); if( !p_sys->p_decoder->p_owner ) { vlc_object_release( p_sys->p_decoder ); return NULL; } p_sys->p_decoder->p_owner->video = p_fmt->video; //p_sys->p_decoder->p_cfg = p_sys->p_video_cfg; p_sys->p_decoder->p_module = module_need( p_sys->p_decoder, "decoder", "$codec", false ); if( !p_sys->p_decoder->p_module || !p_sys->p_decoder->pf_decode_video ) { if( p_sys->p_decoder->p_module ) { msg_Err( p_stream, "instanciated a non video decoder" ); module_unneed( p_sys->p_decoder, p_sys->p_decoder->p_module ); } else { msg_Err( p_stream, "cannot find decoder" ); } free( p_sys->p_decoder->p_owner ); vlc_object_release( p_sys->p_decoder ); return NULL; } p_sys->b_inited = true; vlc_global_lock( VLC_MOSAIC_MUTEX ); p_bridge = GetBridge( p_stream ); if ( p_bridge == NULL ) { vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->obj.libvlc ); vlc_value_t val; p_bridge = xmalloc( sizeof( bridge_t ) ); var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS ); val.p_address = p_bridge; var_Set( p_libvlc, "mosaic-struct", val ); p_bridge->i_es_num = 0; p_bridge->pp_es = NULL; } for ( i = 0; i < p_bridge->i_es_num; i++ ) { if ( p_bridge->pp_es[i]->b_empty ) break; } if ( i == p_bridge->i_es_num ) { p_bridge->pp_es = xrealloc( p_bridge->pp_es, (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) ); p_bridge->i_es_num++; p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) ); } p_sys->p_es = p_es = p_bridge->pp_es[i]; p_es->i_alpha = var_GetInteger( p_stream, CFG_PREFIX "alpha" ); p_es->i_x = var_GetInteger( p_stream, CFG_PREFIX "x" ); p_es->i_y = var_GetInteger( p_stream, CFG_PREFIX "y" ); //p_es->fmt = *p_fmt; p_es->psz_id = p_sys->psz_id; p_es->p_picture = NULL; p_es->pp_last = &p_es->p_picture; p_es->b_empty = false; vlc_global_unlock( VLC_MOSAIC_MUTEX ); if ( p_sys->i_height || p_sys->i_width ) { p_sys->p_image = image_HandlerCreate( p_stream ); } else { p_sys->p_image = NULL; } msg_Dbg( p_stream, "mosaic bridge id=%s pos=%d", p_es->psz_id, i ); /* Create user specified video filters */ psz_chain = var_GetNonEmptyString( p_stream, CFG_PREFIX "vfilter" ); msg_Dbg( p_stream, "psz_chain: %s", psz_chain ); if( psz_chain ) { filter_owner_t owner = { .sys = p_sys->p_decoder->p_owner, .video = { .buffer_new = video_new_buffer_filter, }, }; p_sys->p_vf2 = filter_chain_NewVideo( p_stream, false, &owner ); es_format_t fmt; es_format_Copy( &fmt, &p_sys->p_decoder->fmt_out ); if( p_sys->i_chroma ) fmt.video.i_chroma = p_sys->i_chroma; filter_chain_Reset( p_sys->p_vf2, &fmt, &fmt ); filter_chain_AppendFromString( p_sys->p_vf2, psz_chain ); free( psz_chain ); } else {
/***************************************************************************** * Filter *****************************************************************************/ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) { filter_sys_t *p_sys = p_filter->p_sys; bridge_t *p_bridge; subpicture_t *p_spu; int i_index, i_real_index, i_row, i_col; int i_greatest_real_index_used = p_sys->i_order_length - 1; unsigned int col_inner_width, row_inner_height; subpicture_region_t *p_region; subpicture_region_t *p_region_prev = NULL; /* Allocate the subpicture internal data. */ p_spu = filter_NewSubpicture( p_filter ); if( !p_spu ) return NULL; /* Initialize subpicture */ p_spu->i_channel = 0; p_spu->i_start = date; p_spu->i_stop = 0; p_spu->b_ephemer = true; p_spu->i_alpha = p_sys->i_alpha; p_spu->b_absolute = false; vlc_mutex_lock( &p_sys->lock ); vlc_global_lock( VLC_MOSAIC_MUTEX ); p_bridge = GetBridge( p_filter ); if ( p_bridge == NULL ) { vlc_global_unlock( VLC_MOSAIC_MUTEX ); vlc_mutex_unlock( &p_sys->lock ); return p_spu; } if ( p_sys->i_position == position_offsets ) { /* If we have either too much or not enough offsets, fall-back * to automatic positioning. */ if ( p_sys->i_offsets_length != p_sys->i_order_length ) { msg_Err( p_filter, "Number of specified offsets (%d) does not match number " "of input substreams in mosaic-order (%d), falling back " "to mosaic-position=0", p_sys->i_offsets_length, p_sys->i_order_length ); p_sys->i_position = position_auto; } } if ( p_sys->i_position == position_auto ) { int i_numpics = p_sys->i_order_length; /* keep slots and all */ for ( i_index = 0; i_index < p_bridge->i_es_num; i_index++ ) { bridged_es_t *p_es = p_bridge->pp_es[i_index]; if ( !p_es->b_empty ) { i_numpics ++; if( p_sys->i_order_length && p_es->psz_id != NULL ) { /* We also want to leave slots for images given in * mosaic-order that are not available in p_vout_picture */ int i; for( i = 0; i < p_sys->i_order_length ; i++ ) { if( !strcmp( p_sys->ppsz_order[i], p_es->psz_id ) ) { i_numpics--; break; } } } } } p_sys->i_rows = ceil(sqrt( (double)i_numpics )); p_sys->i_cols = ( i_numpics % p_sys->i_rows == 0 ? i_numpics / p_sys->i_rows : i_numpics / p_sys->i_rows + 1 ); } col_inner_width = ( ( p_sys->i_width - ( p_sys->i_cols - 1 ) * p_sys->i_borderw ) / p_sys->i_cols ); row_inner_height = ( ( p_sys->i_height - ( p_sys->i_rows - 1 ) * p_sys->i_borderh ) / p_sys->i_rows ); i_real_index = 0; for ( i_index = 0; i_index < p_bridge->i_es_num; i_index++ ) { bridged_es_t *p_es = p_bridge->pp_es[i_index]; video_format_t fmt_in, fmt_out; picture_t *p_converted; memset( &fmt_in, 0, sizeof( video_format_t ) ); memset( &fmt_out, 0, sizeof( video_format_t ) ); if ( p_es->b_empty ) continue; while ( p_es->p_picture != NULL && p_es->p_picture->date + p_sys->i_delay < date ) { if ( p_es->p_picture->p_next != NULL ) { picture_t *p_next = p_es->p_picture->p_next; picture_Release( p_es->p_picture ); p_es->p_picture = p_next; } else if ( p_es->p_picture->date + p_sys->i_delay + BLANK_DELAY < date ) { /* Display blank */ picture_Release( p_es->p_picture ); p_es->p_picture = NULL; p_es->pp_last = &p_es->p_picture; break; } else { msg_Dbg( p_filter, "too late picture for %s (%"PRId64 ")", p_es->psz_id, date - p_es->p_picture->date - p_sys->i_delay ); break; } } if ( p_es->p_picture == NULL ) continue; if ( p_sys->i_order_length == 0 ) { i_real_index++; } else { int i; for ( i = 0; i <= p_sys->i_order_length; i++ ) { if ( i == p_sys->i_order_length ) break; if ( strcmp( p_es->psz_id, p_sys->ppsz_order[i] ) == 0 ) { i_real_index = i; break; } } if ( i == p_sys->i_order_length ) i_real_index = ++i_greatest_real_index_used; } i_row = ( i_real_index / p_sys->i_cols ) % p_sys->i_rows; i_col = i_real_index % p_sys->i_cols ; if ( !p_sys->b_keep ) { /* Convert the images */ fmt_in.i_chroma = p_es->p_picture->format.i_chroma; fmt_in.i_height = p_es->p_picture->format.i_height; fmt_in.i_width = p_es->p_picture->format.i_width; if( fmt_in.i_chroma == VLC_CODEC_YUVA || fmt_in.i_chroma == VLC_CODEC_RGBA ) fmt_out.i_chroma = VLC_CODEC_YUVA; else fmt_out.i_chroma = VLC_CODEC_I420; fmt_out.i_width = col_inner_width; fmt_out.i_height = row_inner_height; if( p_sys->b_ar ) /* keep aspect ratio */ { if( (float)fmt_out.i_width / (float)fmt_out.i_height > (float)fmt_in.i_width / (float)fmt_in.i_height ) { fmt_out.i_width = ( fmt_out.i_height * fmt_in.i_width ) / fmt_in.i_height; } else { fmt_out.i_height = ( fmt_out.i_width * fmt_in.i_height ) / fmt_in.i_width; } } fmt_out.i_visible_width = fmt_out.i_width; fmt_out.i_visible_height = fmt_out.i_height; p_converted = image_Convert( p_sys->p_image, p_es->p_picture, &fmt_in, &fmt_out ); if( !p_converted ) { msg_Warn( p_filter, "image resizing and chroma conversion failed" ); continue; } } else { p_converted = p_es->p_picture; fmt_in.i_width = fmt_out.i_width = p_converted->format.i_width; fmt_in.i_height = fmt_out.i_height = p_converted->format.i_height; fmt_in.i_chroma = fmt_out.i_chroma = p_converted->format.i_chroma; fmt_out.i_visible_width = fmt_out.i_width; fmt_out.i_visible_height = fmt_out.i_height; } p_region = subpicture_region_New( &fmt_out ); /* FIXME the copy is probably not needed anymore */ if( p_region ) picture_Copy( p_region->p_picture, p_converted ); if( !p_sys->b_keep ) picture_Release( p_converted ); if( !p_region ) { msg_Err( p_filter, "cannot allocate SPU region" ); p_filter->pf_sub_buffer_del( p_filter, p_spu ); vlc_global_unlock( VLC_MOSAIC_MUTEX ); vlc_mutex_unlock( &p_sys->lock ); return p_spu; } if( p_es->i_x >= 0 && p_es->i_y >= 0 ) { p_region->i_x = p_es->i_x; p_region->i_y = p_es->i_y; } else if( p_sys->i_position == position_offsets ) { p_region->i_x = p_sys->pi_x_offsets[i_real_index]; p_region->i_y = p_sys->pi_y_offsets[i_real_index]; } else { if( fmt_out.i_width > col_inner_width || p_sys->b_ar || p_sys->b_keep ) { /* we don't have to center the video since it takes the whole rectangle area or it's larger than the rectangle */ p_region->i_x = p_sys->i_xoffset + i_col * ( p_sys->i_width / p_sys->i_cols ) + ( i_col * p_sys->i_borderw ) / p_sys->i_cols; } else { /* center the video in the dedicated rectangle */ p_region->i_x = p_sys->i_xoffset + i_col * ( p_sys->i_width / p_sys->i_cols ) + ( i_col * p_sys->i_borderw ) / p_sys->i_cols + ( col_inner_width - fmt_out.i_width ) / 2; } if( fmt_out.i_height > row_inner_height || p_sys->b_ar || p_sys->b_keep ) { /* we don't have to center the video since it takes the whole rectangle area or it's taller than the rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows; } else { /* center the video in the dedicated rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows + ( row_inner_height - fmt_out.i_height ) / 2; } } p_region->i_align = p_sys->i_align; p_region->i_alpha = p_es->i_alpha; if( p_region_prev == NULL ) { p_spu->p_region = p_region; } else { p_region_prev->p_next = p_region; } p_region_prev = p_region; } vlc_global_unlock( VLC_MOSAIC_MUTEX ); vlc_mutex_unlock( &p_sys->lock ); return p_spu; }
HRESULT CRTF_SectionMarker::WriteRtf(RtfWriterData&rwd, RtfWriterInfo& info) { if (m_bDeletion) { info.m_theLastOrigSection.ApplyStyle(GetFormat()); return S_OK; } info.m_theLastModSection.ApplyStyle(GetFormat()); if (GetBridge()) { info.m_theLastOrigSection.ApplyStyle(((CRTF_SectionMarker*)GetBridge())->GetFormat()); } CHECK_ALGORITHM_INTEGRITY(!GetFormat()->IsAlreadyWritten()); if(GetFormat()->IsAlreadyWritten()) { return E_FAIL; } int iCount = (x64_int_cast)theHdrFtrs.size(); for (int i = 0; i < iCount ; i++) { bool bDontWrite = false; if (!rwd.NonDestructiveSave() && rwd.pOptions->m_pOverrideFooter) { enum RTFhdrftr::eType Type = (RTFhdrftr::eType) theHdrFtrTypes[i]; switch (Type) { case RTFhdrftr::foot: case RTFhdrftr::footl: case RTFhdrftr::footr: case RTFhdrftr::foot1: bDontWrite = true; break; } } if (!bDontWrite) { if (theHdrFtrs[i]) { RTFhdrftr* pHdrFtr = new RTFhdrftr(GetFileContext()); HRESULT hr = rwd.WriteSubChain(pHdrFtr, theHdrFtrs[i]); pHdrFtr->SetHdrFtrType(theHdrFtrTypes[i]); GetFormat()->AddHdrFtr(pHdrFtr); } } } if (!rwd.NonDestructiveSave() && rwd.pOptions->m_pOverrideFooter) { RTFhdrftr* pHdrFtr = new RTFhdrftr(GetFileContext()); HRESULT hr = rwd.WriteSubChain(pHdrFtr, rwd.pOptions->m_pOverrideFooter); pHdrFtr->SetHdrFtrType((int) RTFhdrftr::foot); GetFormat()->AddHdrFtr(pHdrFtr); } rwd.AddObject(GetFormat()); if (IsInCell()) { RTFPCData* pcdata = new RTFPCData(GetFileContext()); CWideString cws=" "; pcdata->SetContent(cws); rwd.AddObject(pcdata); } return S_OK; }
/***************************************************************************** * Filter *****************************************************************************/ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) { filter_sys_t *p_sys = p_filter->p_sys; bridge_t *p_bridge; subpicture_t *p_spu; int i_index, i_real_index, i_row, i_col; int i_greatest_real_index_used = p_sys->i_order_length - 1; unsigned int col_inner_width, row_inner_height; subpicture_region_t *p_region; subpicture_region_t *p_region_prev = NULL; /* Allocate the subpicture internal data. */ p_spu = p_filter->pf_sub_buffer_new( p_filter ); if( !p_spu ) { return NULL; } /* Initialize subpicture */ p_spu->i_channel = 0; p_spu->i_start = date; p_spu->i_stop = 0; p_spu->b_ephemer = VLC_TRUE; p_spu->i_alpha = p_sys->i_alpha; p_spu->i_flags = p_sys->i_align; p_spu->b_absolute = VLC_FALSE; vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( p_sys->p_lock ); p_bridge = GetBridge( p_filter ); if ( p_bridge == NULL ) { vlc_mutex_unlock( p_sys->p_lock ); vlc_mutex_unlock( &p_sys->lock ); return p_spu; } if ( p_sys->i_position == 0 ) /* use automatic positioning */ { int i_numpics = p_sys->i_order_length; /* keep slots and all */ for ( i_index = 0; i_index < p_bridge->i_es_num; i_index++ ) { bridged_es_t *p_es = p_bridge->pp_es[i_index]; if ( !p_es->b_empty ) { i_numpics ++; if( p_sys->i_order_length && p_es->psz_id != 0 ) { /* We also want to leave slots for images given in * mosaic-order that are not available in p_vout_picture */ int i; for( i = 0; i < p_sys->i_order_length ; i++ ) { if( !strcmp( p_sys->ppsz_order[i], p_es->psz_id ) ) { i_numpics--; break; } } } } } p_sys->i_rows = ((int)ceil(sqrt( (float)i_numpics ))); p_sys->i_cols = ( i_numpics % p_sys->i_rows == 0 ? i_numpics / p_sys->i_rows : i_numpics / p_sys->i_rows + 1 ); } col_inner_width = ( ( p_sys->i_width - ( p_sys->i_cols - 1 ) * p_sys->i_borderw ) / p_sys->i_cols ); row_inner_height = ( ( p_sys->i_height - ( p_sys->i_rows - 1 ) * p_sys->i_borderh ) / p_sys->i_rows ); i_real_index = 0; for ( i_index = 0; i_index < p_bridge->i_es_num; i_index++ ) { bridged_es_t *p_es = p_bridge->pp_es[i_index]; video_format_t fmt_in = {0}, fmt_out = {0}; picture_t *p_converted; if ( p_es->b_empty ) continue; while ( p_es->p_picture != NULL && p_es->p_picture->date + p_sys->i_delay < date ) { if ( p_es->p_picture->p_next != NULL ) { picture_t *p_next = p_es->p_picture->p_next; p_es->p_picture->pf_release( p_es->p_picture ); p_es->p_picture = p_next; } else if ( p_es->p_picture->date + p_sys->i_delay + BLANK_DELAY < date ) { /* Display blank */ p_es->p_picture->pf_release( p_es->p_picture ); p_es->p_picture = NULL; p_es->pp_last = &p_es->p_picture; break; } else { msg_Dbg( p_filter, "too late picture for %s (" I64Fd ")", p_es->psz_id, date - p_es->p_picture->date - p_sys->i_delay ); break; } } if ( p_es->p_picture == NULL ) continue; if ( p_sys->i_order_length == 0 ) { i_real_index++; } else { int i; for ( i = 0; i <= p_sys->i_order_length; i++ ) { if ( i == p_sys->i_order_length ) break; if ( strcmp( p_es->psz_id, p_sys->ppsz_order[i] ) == 0 ) { i_real_index = i; break; } } if ( i == p_sys->i_order_length ) i_real_index = ++i_greatest_real_index_used; } i_row = ( i_real_index / p_sys->i_cols ) % p_sys->i_rows; i_col = i_real_index % p_sys->i_cols ; if ( !p_sys->b_keep ) { /* Convert the images */ fmt_in.i_chroma = p_es->p_picture->format.i_chroma; fmt_in.i_height = p_es->p_picture->format.i_height; fmt_in.i_width = p_es->p_picture->format.i_width; fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A'); fmt_out.i_width = col_inner_width; fmt_out.i_height = row_inner_height; if( p_sys->b_ar ) /* keep aspect ratio */ { if( (float)fmt_out.i_width / (float)fmt_out.i_height > (float)fmt_in.i_width / (float)fmt_in.i_height ) { fmt_out.i_width = ( fmt_out.i_height * fmt_in.i_width ) / fmt_in.i_height; } else { fmt_out.i_height = ( fmt_out.i_width * fmt_in.i_height ) / fmt_in.i_width; } } fmt_out.i_visible_width = fmt_out.i_width; fmt_out.i_visible_height = fmt_out.i_height; p_converted = image_Convert( p_sys->p_image, p_es->p_picture, &fmt_in, &fmt_out ); if( !p_converted ) { msg_Warn( p_filter, "image resizing and chroma conversion failed" ); continue; } /* Bluescreen stuff */ if( p_sys->b_bs ) { int i,j; int i_lines = p_converted->p[ A_PLANE ].i_lines; int i_pitch = p_converted->p[ A_PLANE ].i_pitch; uint8_t *p_a = p_converted->p[ A_PLANE ].p_pixels; uint8_t *p_at = malloc( i_lines * i_pitch * sizeof( uint8_t ) ); uint8_t *p_u = p_converted->p[ U_PLANE ].p_pixels; uint8_t *p_v = p_converted->p[ V_PLANE ].p_pixels; uint8_t umin, umax, vmin, vmax; umin = p_sys->i_bsu - p_sys->i_bsut >= 0x00 ? p_sys->i_bsu - p_sys->i_bsut : 0x00; umax = p_sys->i_bsu + p_sys->i_bsut <= 0xff ? p_sys->i_bsu + p_sys->i_bsut : 0xff; vmin = p_sys->i_bsv - p_sys->i_bsvt >= 0x00 ? p_sys->i_bsv - p_sys->i_bsvt : 0x00; vmax = p_sys->i_bsv + p_sys->i_bsvt <= 0xff ? p_sys->i_bsv + p_sys->i_bsvt : 0xff; for( i = 0; i < i_lines*i_pitch; i++ ) { if( p_u[i] < umax && p_u[i] > umin && p_v[i] < vmax && p_v[i] > vmin ) { p_at[i] = 0x00; } else { p_at[i] = 0xff; } } /* Gaussian convolution to make it look cleaner */ memset( p_a, 0, 2 * i_pitch ); for( i = 2; i < i_lines - 2; i++ ) { p_a[i*i_pitch] = 0x00; p_a[i*i_pitch+1] = 0x00; for( j = 2; j < i_pitch - 2; j ++ ) { p_a[i*i_pitch+j] = (uint8_t)(( /* 2 rows up */ ( p_at[(i-2)*i_pitch+j-2]<<1 ) + ( p_at[(i-2)*i_pitch+j-1]<<2 ) + ( p_at[(i-2)*i_pitch+j]<<2 ) + ( p_at[(i-2)*i_pitch+j+1]<<2 ) + ( p_at[(i-2)*i_pitch+j+2]<<1 ) /* 1 row up */ + ( p_at[(i-1)*i_pitch+j-1]<<3 ) + ( p_at[(i-1)*i_pitch+j-2]<<2 ) + ( p_at[(i-1)*i_pitch+j]*12 ) + ( p_at[(i-1)*i_pitch+j+1]<<3 ) + ( p_at[(i-1)*i_pitch+j+2]<<2 ) /* */ + ( p_at[i*i_pitch+j-2]<<2 ) + ( p_at[i*i_pitch+j-1]*12 ) + ( p_at[i*i_pitch+j]<<4 ) + ( p_at[i*i_pitch+j+1]*12 ) + ( p_at[i*i_pitch+j+2]<<2 ) /* 1 row down */ + ( p_at[(i+1)*i_pitch+j-2]<<2 ) + ( p_at[(i+1)*i_pitch+j-1]<<3 ) + ( p_at[(i+1)*i_pitch+j]*12 ) + ( p_at[(i+1)*i_pitch+j+1]<<3 ) + ( p_at[(i+1)*i_pitch+j+2]<<2 ) /* 2 rows down */ + ( p_at[(i+2)*i_pitch+j-2]<<1 ) + ( p_at[(i+2)*i_pitch+j-1]<<2 ) + ( p_at[(i+2)*i_pitch+j]<<2 ) + ( p_at[(i+2)*i_pitch+j+1]<<2 ) + ( p_at[(i+2)*i_pitch+j+2]<<1 ) )/152); if( p_a[i*i_pitch+j] < 0xbf ) p_a[i*i_pitch+j] = 0x00; } } free( p_at ); } } else { p_converted = p_es->p_picture; p_converted->i_refcount++; fmt_in.i_width = fmt_out.i_width = p_converted->format.i_width; fmt_in.i_height = fmt_out.i_height = p_converted->format.i_height; fmt_in.i_chroma = fmt_out.i_chroma = p_converted->format.i_chroma; fmt_out.i_visible_width = fmt_out.i_width; fmt_out.i_visible_height = fmt_out.i_height; } p_region = p_spu->pf_make_region( VLC_OBJECT(p_filter), &fmt_out, p_converted ); if( !p_region ) { msg_Err( p_filter, "cannot allocate SPU region" ); p_filter->pf_sub_buffer_del( p_filter, p_spu ); vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( p_sys->p_lock ); return p_spu; } /* HACK ALERT : let's fix the pointers to avoid picture duplication. * This is necessary because p_region->picture is not a pointer * as it ought to be. */ if( !p_sys->b_keep ) { free( p_converted ); } else { /* Keep a pointer to the original picture (and its refcount...). */ p_region->picture.p_sys = (picture_sys_t *)p_converted; p_region->picture.pf_release = MosaicReleasePicture; } if( fmt_out.i_width > col_inner_width || p_sys->b_ar || p_sys->b_keep ) { /* we don't have to center the video since it takes the whole rectangle area or it's larger than the rectangle */ p_region->i_x = p_sys->i_xoffset + i_col * ( p_sys->i_width / p_sys->i_cols ) + ( i_col * p_sys->i_borderw ) / p_sys->i_cols; } else { /* center the video in the dedicated rectangle */ p_region->i_x = p_sys->i_xoffset + i_col * ( p_sys->i_width / p_sys->i_cols ) + ( i_col * p_sys->i_borderw ) / p_sys->i_cols + ( col_inner_width - fmt_out.i_width ) / 2; } if( fmt_out.i_height < row_inner_height || p_sys->b_ar || p_sys->b_keep ) { /* we don't have to center the video since it takes the whole rectangle area or it's taller than the rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows; } else { /* center the video in the dedicated rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows + ( row_inner_height - fmt_out.i_height ) / 2; } if( p_region_prev == NULL ) { p_spu->p_region = p_region; } else { p_region_prev->p_next = p_region; } p_region_prev = p_region; } vlc_mutex_unlock( p_sys->p_lock ); vlc_mutex_unlock( &p_sys->lock ); return p_spu; }
static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) { VLC_UNUSED(id); sout_stream_sys_t *p_sys = p_stream->p_sys; bridge_t *p_bridge; bridged_es_t *p_es; bool b_last_es = true; int i; if( !p_sys->b_inited ) return VLC_SUCCESS; if( p_sys->p_decoder != NULL ) { decoder_owner_sys_t *p_owner = p_sys->p_decoder->p_owner; if( p_sys->p_decoder->p_module ) module_unneed( p_sys->p_decoder, p_sys->p_decoder->p_module ); if( p_sys->p_decoder->p_description ) vlc_meta_Delete( p_sys->p_decoder->p_description ); vlc_object_release( p_sys->p_decoder ); free( p_owner ); } /* Destroy user specified video filters */ if( p_sys->p_vf2 ) filter_chain_Delete( p_sys->p_vf2 ); vlc_global_lock( VLC_MOSAIC_MUTEX ); p_bridge = GetBridge( p_stream ); p_es = p_sys->p_es; p_es->b_empty = true; while ( p_es->p_picture ) { picture_t *p_next = p_es->p_picture->p_next; picture_Release( p_es->p_picture ); p_es->p_picture = p_next; } for ( i = 0; i < p_bridge->i_es_num; i++ ) { if ( !p_bridge->pp_es[i]->b_empty ) { b_last_es = false; break; } } if ( b_last_es ) { vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc ); for ( i = 0; i < p_bridge->i_es_num; i++ ) free( p_bridge->pp_es[i] ); free( p_bridge->pp_es ); free( p_bridge ); var_Destroy( p_libvlc, "mosaic-struct" ); } vlc_global_unlock( VLC_MOSAIC_MUTEX ); if ( p_sys->p_image ) { image_HandlerDelete( p_sys->p_image ); } p_sys->b_inited = false; return VLC_SUCCESS; }
void Map::PaintBridge( int row1, int column1, int row2, int column2 ) { float column_width; float row_height; if( mNumColumn > 1 ) { column_width = mWidth/( mNumColumn - 1 ); } else { column_width = 0; } if( mNumRow > 1 ) { row_height = mHeight/( mNumRow - 1 ); } else { row_height = 0; } int bridge12 = GetBridge( row1, column1, row2, column2 ); int bridge21 = GetBridge( row2, column2, row1, column1 ); if( bridge12 == TWO_WAY_ALWAYS_ON ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK ); } else if( bridge12 == ONE_WAY_ALWAYS_ON ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_LINK ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_UNLINK ); } else if( bridge12 == TWO_WAY_ONE_TIME ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK_ONE_TIME ); } else if( bridge12 == ONE_WAY_ONE_TIME ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_LINK_ONE_TIME ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_UNLINK ); } else if( bridge12 == TWO_WAY_ONOFF_ON ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK_ONOFF_ON ); } else if( bridge12 == TWO_WAY_ONOFF_OFF ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK_ONOFF_OFF ); } else if( bridge12 == ONE_WAY_ONOFF_ON ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_LINK_ONOFF_ON ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_UNLINK ); } else if( bridge12 == ONE_WAY_ONOFF_OFF ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_LINK_ONOFF_OFF ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_UNLINK ); } //-------------------------------------- else if( bridge21 == ONE_WAY_ALWAYS_ON ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_UNLINK ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK ); } else if( bridge21 == ONE_WAY_ONE_TIME ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_UNLINK ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK_ONE_TIME ); } else if( bridge21 == ONE_WAY_ONOFF_ON ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_UNLINK ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK_ONOFF_ON ); } else if( bridge21 == ONE_WAY_ONOFF_OFF ) { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, COLOR_UNLINK ); DrawLine ( ( ( column2 * column_width + mXPos ) + ( column1 * column_width + mXPos ) ) / 2, ( ( row2 * row_height + mYPos ) + ( row1 * row_height + mYPos ) ) / 2, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_LINK_ONOFF_OFF ); } else /*if( bridge12 == UNBRIDGE && bridge21 == UNBRIDGE )*/ { DrawLine ( column1 * column_width + mXPos, row1 * row_height + mYPos, column2 * column_width + mXPos, row2 * row_height + mYPos, COLOR_UNLINK ); } }