myinline const char* ArpMessage::GetIndirect(const char *name, const char* def, int32 index) const { if( this ) { const char* res; if( FindIndirect(name, index, &res) != B_NO_ERROR ) return def; return res; } return def; #if 0 if( this ) { const char* res = NULL; ssize_t bytes = 0; if( FindData(name, ARP_INDIRECT_TYPE, index, (const void**)&res, &bytes) != B_NO_ERROR ) return def; if( !res ) return def; ArpD(cdb << ADH << "Got indirect: " << res << " for " << name << " (" << bytes << " bytes)" << endl); if( res[bytes-1] != '\0' ) { printf("Oops!\n"); return def; } return res; } return def; #endif }
status_t ArpMessage::FindIndirect(const char *name, const char** ind) const { return FindIndirect(name,(int32)0,ind); }
static int Open(vlc_object_t *object) { filter_t *filter = (filter_t *)object; const es_format_t *src = &filter->fmt_in; es_format_t *dst = &filter->fmt_out; if (!AOUT_FMTS_SIMILAR(&src->audio, &dst->audio)) return VLC_EGENERIC; if (src->i_codec == dst->i_codec) return VLC_EGENERIC; cvt_direct_t direct = FindDirect(src->i_codec, dst->i_codec); if (direct) { filter->pf_audio_filter = direct; filter->p_sys = NULL; goto end; } /* */ filter_sys_t *sys = malloc(sizeof(*sys)); if (!sys) return VLC_ENOMEM; /* Find the cost minimal conversion */ for (unsigned mask = 0; mask <= 0x07; mask++) { memset(sys, 0, sizeof(*sys)); vlc_fourcc_t fsrc = src->i_codec; vlc_fourcc_t fdst = dst->i_codec; if (mask & 0x01) { sys->pre = FindSwap(&fsrc, fsrc); if (!sys->pre) continue; } if (mask & 0x02) { sys->post = FindSwap(&fdst, fdst); if (!sys->post) continue; } const bool has_middle = mask & 0x04; for (int i = 0; fsrc != fdst && i < 1 + has_middle; i++) { /* XXX Hardcoded middle format: native 16 bits */ vlc_fourcc_t ftarget = has_middle && i == 0 ? VLC_CODEC_S16N : fdst; sys->directs[i] = FindDirect(fsrc, ftarget); if (!sys->directs[i]) { sys->indirects[i] = FindIndirect(fsrc, ftarget); if (!sys->indirects[i]) break; sys->indirects_ratio[i][0] = aout_BitsPerSample(fsrc) / 8; sys->indirects_ratio[i][1] = aout_BitsPerSample(ftarget) / 8; } fsrc = ftarget; } if (fsrc != fdst) continue; /* We have a full conversion */ filter->pf_audio_filter = Filter; filter->p_sys = sys; goto end; } free(sys); return VLC_EGENERIC; end: dst->audio = src->audio; dst->audio.i_format = dst->i_codec; aout_FormatPrepare(&dst->audio); msg_Dbg(filter, "%4.4s->%4.4s, bits per sample: %i->%i", (char *)&src->i_codec, (char *)&dst->i_codec, src->audio.i_bitspersample, dst->audio.i_bitspersample); return VLC_SUCCESS; }