static block_t *S16toFl32(filter_t *filter, block_t *bsrc) { block_t *bdst = block_Alloc(bsrc->i_buffer * 2); if (unlikely(bdst == NULL)) goto out; block_CopyProperties(bdst, bsrc); int16_t *src = (int16_t *)bsrc->p_buffer; float *dst = (float *)bdst->p_buffer; for (size_t i = bsrc->i_buffer / 2; i--;) #if 0 /* Slow version */ *dst++ = (float)*src++ / 32768.f; #else { /* This is Walken's trick based on IEEE float format. On my PIII * this takes 16 seconds to perform one billion conversions, instead * of 19 seconds for the above division. */ union { float f; int32_t i; } u; u.i = *src++ + 0x43c00000; *dst++ = u.f - 384.f; } #endif out: block_Release(bsrc); VLC_UNUSED(filter); return bdst; }
/***************************************************************************** * SendFrame: send a video frame to the stream output. *****************************************************************************/ static block_t *SendFrame( decoder_t *p_dec, block_t *p_block ) { decoder_sys_t *p_sys = p_dec->p_sys; p_block->i_dts = p_block->i_pts = date_Get( &p_sys->pts ); if( p_sys->b_invert ) { block_t *out = block_Alloc( p_block->i_buffer ); if( likely(out != NULL) ) { block_CopyProperties( out, p_block ); const uint8_t *p_src = p_block->p_buffer; uint8_t *p_pixels = out->p_buffer; for( unsigned i = 0; i < PICTURE_PLANE_MAX; i++ ) { unsigned pitch = p_sys->pitches[i]; unsigned lines = p_sys->lines[i]; uint8_t *p_dst = p_pixels + (pitch * lines); for( unsigned x = 0; x < lines; x++ ) { p_dst -= p_sys->pitches[i]; memcpy( p_dst, p_src, p_sys->pitches[i] ); p_src += p_sys->pitches[i]; } } } block_Release( p_block ); } return p_block; }
/*** from U8 ***/ static block_t *U8toS16(filter_t *filter, block_t *bsrc) { block_t *bdst = block_Alloc(bsrc->i_buffer * 2); if (unlikely(bdst == NULL)) goto out; block_CopyProperties(bdst, bsrc); uint8_t *src = (uint8_t *)bsrc->p_buffer; int16_t *dst = (int16_t *)bdst->p_buffer; for (size_t i = bsrc->i_buffer; i--;) *dst++ = ((*src++) - 128) << 8; out: block_Release(bsrc); VLC_UNUSED(filter); return bdst; }
static block_t *S32toFl64(filter_t *filter, block_t *bsrc) { block_t *bdst = block_Alloc(bsrc->i_buffer * 2); if (unlikely(bdst == NULL)) goto out; block_CopyProperties(bdst, bsrc); int32_t *src = (int32_t*)bsrc->p_buffer; double *dst = (double *)bdst->p_buffer; for (size_t i = bsrc->i_buffer / 4; i--;) *dst++ = (double)(*src++) / 2147483648.; out: VLC_UNUSED(filter); block_Release(bsrc); return bdst; }
static block_t *Fl32toFl64(filter_t *filter, block_t *bsrc) { block_t *bdst = block_Alloc(bsrc->i_buffer * 2); if (unlikely(bdst == NULL)) goto out; block_CopyProperties(bdst, bsrc); float *src = (float *)bsrc->p_buffer; double *dst = (double *)bdst->p_buffer; for (size_t i = bsrc->i_buffer / 4; i--;) *(dst++) = *(src++); out: block_Release(bsrc); VLC_UNUSED(filter); return bdst; }
static block_t *S16toFl64(filter_t *filter, block_t *bsrc) { block_t *bdst = block_Alloc(bsrc->i_buffer * 4); if (unlikely(bdst == NULL)) goto out; block_CopyProperties(bdst, bsrc); int16_t *src = (int16_t *)bsrc->p_buffer; float *dst = (float *)bdst->p_buffer; for (size_t i = bsrc->i_buffer / 2; i--;) *dst++ = (double)*src++ / 32768.; out: block_Release(bsrc); VLC_UNUSED(filter); return bdst; }
static block_t *S16toS32(filter_t *filter, block_t *bsrc) { block_t *bdst = block_Alloc(bsrc->i_buffer * 2); if (unlikely(bdst == NULL)) goto out; block_CopyProperties(bdst, bsrc); int16_t *src = (int16_t *)bsrc->p_buffer; int32_t *dst = (int32_t *)bdst->p_buffer; for (int i = bsrc->i_buffer / 2; i--;) *dst++ = *src++ << 16; out: block_Release(bsrc); VLC_UNUSED(filter); return bdst; }