packetizer: hxxx: fix DirectTV extraction
[vlc.git] / src / audio_output / common.c
blob391abf0557c4bd10cf69b35a572292ac4261b4e5
1 /*****************************************************************************
2 * common.c : audio output management of common data structures
3 *****************************************************************************
4 * Copyright (C) 2002-2007 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
28 #include <limits.h>
29 #include <assert.h>
31 #include <vlc_common.h>
32 #include <vlc_aout.h>
33 #include "aout_internal.h"
36 * Formats management (internal and external)
39 /*****************************************************************************
40 * aout_BitsPerSample : get the number of bits per sample
41 *****************************************************************************/
42 unsigned int aout_BitsPerSample( vlc_fourcc_t i_format )
44 switch( vlc_fourcc_GetCodec( AUDIO_ES, i_format ) )
46 case VLC_CODEC_U8:
47 case VLC_CODEC_S8:
48 case VLC_CODEC_ALAW:
49 case VLC_CODEC_MULAW:
50 return 8;
52 case VLC_CODEC_U16L:
53 case VLC_CODEC_S16L:
54 case VLC_CODEC_U16B:
55 case VLC_CODEC_S16B:
56 return 16;
58 case VLC_CODEC_U24L:
59 case VLC_CODEC_S24L:
60 case VLC_CODEC_U24B:
61 case VLC_CODEC_S24B:
62 return 24;
64 case VLC_CODEC_S24L32:
65 case VLC_CODEC_S24B32:
66 case VLC_CODEC_U32L:
67 case VLC_CODEC_U32B:
68 case VLC_CODEC_S32L:
69 case VLC_CODEC_S32B:
70 case VLC_CODEC_F32L:
71 case VLC_CODEC_F32B:
72 return 32;
74 case VLC_CODEC_F64L:
75 case VLC_CODEC_F64B:
76 return 64;
78 default:
79 /* For these formats the caller has to indicate the parameters
80 * by hand. */
81 return 0;
85 /*****************************************************************************
86 * aout_FormatPrepare : compute the number of bytes per frame & frame length
87 *****************************************************************************/
88 void aout_FormatPrepare( audio_sample_format_t * p_format )
91 unsigned i_channels = aout_FormatNbChannels( p_format );
92 if( i_channels > 0 )
93 p_format->i_channels = i_channels;
94 p_format->i_bitspersample = aout_BitsPerSample( p_format->i_format );
95 if( p_format->i_bitspersample > 0 )
97 p_format->i_bytes_per_frame = ( p_format->i_bitspersample / 8 )
98 * p_format->i_channels;
99 p_format->i_frame_length = 1;
103 /*****************************************************************************
104 * aout_FormatPrintChannels : print a channel in a human-readable form
105 *****************************************************************************/
106 const char * aout_FormatPrintChannels( const audio_sample_format_t * p_format )
108 if (p_format->channel_type == AUDIO_CHANNEL_TYPE_AMBISONICS)
109 return "Ambisonics";
111 /* AUDIO_CHANNEL_TYPE_BITMAP */
112 switch ( p_format->i_physical_channels )
114 case AOUT_CHAN_LEFT:
115 case AOUT_CHAN_RIGHT:
116 case AOUT_CHAN_CENTER:
117 if ( (p_format->i_physical_channels & AOUT_CHAN_CENTER)
118 || (p_format->i_physical_channels
119 & (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) )
120 return "Mono";
121 else if ( p_format->i_physical_channels & AOUT_CHAN_LEFT )
122 return "Left";
123 return "Right";
124 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT:
125 if ( p_format->i_chan_mode & AOUT_CHANMODE_DOLBYSTEREO )
126 return "Dolby";
127 else if ( p_format->i_chan_mode & AOUT_CHANMODE_DUALMONO )
128 return "Dual-mono";
129 else if ( p_format->i_physical_channels == AOUT_CHAN_CENTER )
130 return "Stereo/Mono";
131 else if ( !(p_format->i_physical_channels & AOUT_CHAN_RIGHT) )
132 return "Stereo/Left";
133 else if ( !(p_format->i_physical_channels & AOUT_CHAN_LEFT) )
134 return "Stereo/Right";
135 return "Stereo";
136 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER:
137 return "3F";
138 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARCENTER:
139 return "2F1R";
140 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
141 | AOUT_CHAN_REARCENTER:
142 return "3F1R";
143 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
144 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT:
145 return "2F2R";
146 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
147 | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT:
148 return "2F2M";
149 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
150 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT:
151 return "3F2R";
152 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
153 | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT:
154 return "3F2M";
156 case AOUT_CHAN_CENTER | AOUT_CHAN_LFE:
157 if ( (p_format->i_physical_channels & AOUT_CHAN_CENTER)
158 || (p_format->i_physical_channels
159 & (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) )
160 return "Mono/LFE";
161 else if ( p_format->i_physical_channels & AOUT_CHAN_LEFT )
162 return "Left/LFE";
163 return "Right/LFE";
164 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_LFE:
165 if ( p_format->i_chan_mode & AOUT_CHANMODE_DOLBYSTEREO )
166 return "Dolby/LFE";
167 else if ( p_format->i_chan_mode & AOUT_CHANMODE_DUALMONO )
168 return "Dual-mono/LFE";
169 else if ( p_format->i_physical_channels == AOUT_CHAN_CENTER )
170 return "Mono/LFE";
171 else if ( !(p_format->i_physical_channels & AOUT_CHAN_RIGHT) )
172 return "Stereo/Left/LFE";
173 else if ( !(p_format->i_physical_channels & AOUT_CHAN_LEFT) )
174 return "Stereo/Right/LFE";
175 return "Stereo/LFE";
176 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_LFE:
177 return "3F/LFE";
178 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARCENTER
179 | AOUT_CHAN_LFE:
180 return "2F1R/LFE";
181 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
182 | AOUT_CHAN_REARCENTER | AOUT_CHAN_LFE:
183 return "3F1R/LFE";
184 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
185 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE:
186 return "2F2R/LFE";
187 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
188 | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_LFE:
189 return "2F2M/LFE";
190 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
191 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE:
192 return "3F2R/LFE";
193 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
194 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARCENTER
195 | AOUT_CHAN_LFE:
196 return "3F3R/LFE";
197 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
198 | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_LFE:
199 return "3F2M/LFE";
200 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
201 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_MIDDLELEFT
202 | AOUT_CHAN_MIDDLERIGHT:
203 return "3F2M2R";
204 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
205 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_MIDDLELEFT
206 | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_LFE:
207 return "3F2M2R/LFE";
208 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
209 | AOUT_CHAN_REARCENTER | AOUT_CHAN_MIDDLELEFT
210 | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_LFE:
211 return "3F2M1R/LFE";
212 case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
213 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARCENTER
214 | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_LFE:
215 return "3F2M3R/LFE";
218 return "Unknown-chan-mask";
221 #undef aout_FormatPrint
223 * Prints an audio sample format in a human-readable form.
225 void aout_FormatPrint( vlc_object_t *obj, const char *psz_text,
226 const audio_sample_format_t *p_format )
228 msg_Dbg( obj, "%s '%4.4s' %d Hz %s frame=%d samples/%d bytes", psz_text,
229 (char *)&p_format->i_format, p_format->i_rate,
230 aout_FormatPrintChannels( p_format ),
231 p_format->i_frame_length, p_format->i_bytes_per_frame );
234 #undef aout_FormatsPrint
236 * Prints two formats in a human-readable form
238 void aout_FormatsPrint( vlc_object_t *obj, const char * psz_text,
239 const audio_sample_format_t * p_format1,
240 const audio_sample_format_t * p_format2 )
242 msg_Dbg( obj, "%s '%4.4s'->'%4.4s' %d Hz->%d Hz %s->%s",
243 psz_text,
244 (char *)&p_format1->i_format, (char *)&p_format2->i_format,
245 p_format1->i_rate, p_format2->i_rate,
246 aout_FormatPrintChannels( p_format1 ),
247 aout_FormatPrintChannels( p_format2 ) );
250 /*****************************************************************************
251 * aout_CheckChannelReorder : Check if we need to do some channel re-ordering
252 *****************************************************************************/
253 unsigned aout_CheckChannelReorder( const uint32_t *chans_in,
254 const uint32_t *chans_out,
255 uint32_t mask, uint8_t *restrict table )
257 static_assert(AOUT_CHAN_MAX <= (sizeof (mask) * CHAR_BIT), "Missing bits");
259 unsigned channels = 0;
261 if( chans_in == NULL )
262 chans_in = pi_vlc_chan_order_wg4;
263 if( chans_out == NULL )
264 chans_out = pi_vlc_chan_order_wg4;
266 for( unsigned i = 0; chans_in[i]; i++ )
268 const uint32_t chan = chans_in[i];
269 if( !(mask & chan) )
270 continue;
272 unsigned index = 0;
273 for( unsigned j = 0; chan != chans_out[j]; j++ )
274 if( mask & chans_out[j] )
275 index++;
277 table[channels++] = index;
280 for( unsigned i = 0; i < channels; i++ )
281 if( table[i] != i )
282 return channels;
283 return 0;
287 * Reorders audio samples within a block of linear audio interleaved samples.
288 * \param ptr start address of the block of samples
289 * \param bytes size of the block in bytes (must be a multiple of the product
290 * of the channels count and the sample size)
291 * \param channels channels count (also length of the chans_table table)
292 * \param chans_table permutation table to reorder the channels
293 * (usually computed by aout_CheckChannelReorder())
294 * \param fourcc sample format (must be a linear sample format)
295 * \note The samples must be naturally aligned in memory.
297 void aout_ChannelReorder( void *ptr, size_t bytes, uint8_t channels,
298 const uint8_t *restrict chans_table, vlc_fourcc_t fourcc )
300 if( unlikely(bytes == 0) )
301 return;
303 assert( channels != 0 );
305 /* The audio formats supported in audio output are inlined. For other
306 * formats (used in demuxers and muxers), memcpy() is used to avoid
307 * breaking type punning. */
308 #define REORDER_TYPE(type) \
309 do { \
310 const size_t frames = (bytes / sizeof (type)) / channels; \
311 type *buf = ptr; \
313 for( size_t i = 0; i < frames; i++ ) \
315 type tmp[AOUT_CHAN_MAX]; \
317 for( size_t j = 0; j < channels; j++ ) \
318 tmp[chans_table[j]] = buf[j]; \
319 memcpy( buf, tmp, sizeof (type) * channels ); \
320 buf += channels; \
322 } while(0)
324 if( likely(channels <= AOUT_CHAN_MAX) )
326 switch( fourcc )
328 case VLC_CODEC_U8: REORDER_TYPE(uint8_t); return;
329 case VLC_CODEC_S16N: REORDER_TYPE(int16_t); return;
330 case VLC_CODEC_FL32: REORDER_TYPE(float); return;
331 case VLC_CODEC_S32N: REORDER_TYPE(int32_t); return;
332 case VLC_CODEC_FL64: REORDER_TYPE(double); return;
336 unsigned size = aout_BitsPerSample( fourcc ) / 8;
337 assert( size != 0 && size <= 8 );
339 const size_t frames = bytes / (size * channels);
340 unsigned char *buf = ptr;
342 for( size_t i = 0; i < frames; i++ )
344 unsigned char tmp[256 * 8];
346 for( size_t j = 0; j < channels; j++ )
347 memcpy( tmp + size * chans_table[j], buf + size * j, size );
348 memcpy( buf, tmp, size * channels );
349 buf += size * channels;
354 * Interleaves audio samples within a block of samples.
355 * \param dst destination buffer for interleaved samples
356 * \param srcv source buffers (one per plane) of uninterleaved samples
357 * \param samples number of samples (per channel/per plane)
358 * \param chans channels/planes count
359 * \param fourcc sample format (must be a linear sample format)
360 * \note The samples must be naturally aligned in memory.
361 * \warning Destination and source buffers MUST NOT overlap.
363 void aout_Interleave( void *restrict dst, const void *const *srcv,
364 unsigned samples, unsigned chans, vlc_fourcc_t fourcc )
366 #define INTERLEAVE_TYPE(type) \
367 do { \
368 type *d = dst; \
369 for( size_t i = 0; i < chans; i++ ) { \
370 const type *s = srcv[i]; \
371 for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
372 d[k] = *(s++); \
373 d++; \
375 } while(0)
377 switch( fourcc )
379 case VLC_CODEC_U8: INTERLEAVE_TYPE(uint8_t); break;
380 case VLC_CODEC_S16N: INTERLEAVE_TYPE(uint16_t); break;
381 case VLC_CODEC_FL32: INTERLEAVE_TYPE(float); break;
382 case VLC_CODEC_S32N: INTERLEAVE_TYPE(int32_t); break;
383 case VLC_CODEC_FL64: INTERLEAVE_TYPE(double); break;
384 default: vlc_assert_unreachable();
386 #undef INTERLEAVE_TYPE
390 * Deinterleaves audio samples within a block of samples.
391 * \param dst destination buffer for planar samples
392 * \param src source buffer with interleaved samples
393 * \param samples number of samples (per channel/per plane)
394 * \param chans channels/planes count
395 * \param fourcc sample format (must be a linear sample format)
396 * \note The samples must be naturally aligned in memory.
397 * \warning Destination and source buffers MUST NOT overlap.
399 void aout_Deinterleave( void *restrict dst, const void *restrict src,
400 unsigned samples, unsigned chans, vlc_fourcc_t fourcc )
402 #define DEINTERLEAVE_TYPE(type) \
403 do { \
404 type *d = dst; \
405 const type *s = src; \
406 for( size_t i = 0; i < chans; i++ ) { \
407 for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
408 *(d++) = s[k]; \
409 s++; \
411 } while(0)
413 switch( fourcc )
415 case VLC_CODEC_U8: DEINTERLEAVE_TYPE(uint8_t); break;
416 case VLC_CODEC_S16N: DEINTERLEAVE_TYPE(uint16_t); break;
417 case VLC_CODEC_FL32: DEINTERLEAVE_TYPE(float); break;
418 case VLC_CODEC_S32N: DEINTERLEAVE_TYPE(int32_t); break;
419 case VLC_CODEC_FL64: DEINTERLEAVE_TYPE(double); break;
420 default: vlc_assert_unreachable();
422 #undef DEINTERLEAVE_TYPE
425 /*****************************************************************************
426 * aout_ChannelExtract:
427 *****************************************************************************/
428 static inline void ExtractChannel( uint8_t *pi_dst, int i_dst_channels,
429 const uint8_t *pi_src, int i_src_channels,
430 int i_sample_count,
431 const int *pi_selection, int i_bytes )
433 for( int i = 0; i < i_sample_count; i++ )
435 for( int j = 0; j < i_dst_channels; j++ )
436 memcpy( &pi_dst[j * i_bytes], &pi_src[pi_selection[j] * i_bytes], i_bytes );
437 pi_dst += i_dst_channels * i_bytes;
438 pi_src += i_src_channels * i_bytes;
442 void aout_ChannelExtract( void *p_dst, int i_dst_channels,
443 const void *p_src, int i_src_channels,
444 int i_sample_count, const int *pi_selection, int i_bits_per_sample )
446 /* It does not work in place */
447 assert( p_dst != p_src );
449 /* Force the compiler to inline for the specific cases so it can optimize */
450 if( i_bits_per_sample == 8 )
451 ExtractChannel( p_dst, i_dst_channels, p_src, i_src_channels, i_sample_count, pi_selection, 1 );
452 else if( i_bits_per_sample == 16 )
453 ExtractChannel( p_dst, i_dst_channels, p_src, i_src_channels, i_sample_count, pi_selection, 2 );
454 else if( i_bits_per_sample == 32 )
455 ExtractChannel( p_dst, i_dst_channels, p_src, i_src_channels, i_sample_count, pi_selection, 4 );
456 else if( i_bits_per_sample == 64 )
457 ExtractChannel( p_dst, i_dst_channels, p_src, i_src_channels, i_sample_count, pi_selection, 8 );
460 bool aout_CheckChannelExtraction( int *pi_selection,
461 uint32_t *pi_layout, int *pi_channels,
462 const uint32_t pi_order_dst[AOUT_CHAN_MAX],
463 const uint32_t *pi_order_src, int i_channels )
465 static_assert(AOUT_CHAN_MAX <= (sizeof (*pi_order_dst) * CHAR_BIT),
466 "Missing bits");
468 uint32_t i_layout = 0;
469 int i_out = 0;
470 int pi_index[AOUT_CHAN_MAX];
472 /* */
473 if( !pi_order_dst )
474 pi_order_dst = pi_vlc_chan_order_wg4;
476 /* */
477 for( int i = 0; i < i_channels; i++ )
479 /* Ignore unknown or duplicated channels or not present in output */
480 if( !pi_order_src[i] || (i_layout & pi_order_src[i]) )
481 continue;
483 for( int j = 0; j < AOUT_CHAN_MAX; j++ )
485 if( pi_order_dst[j] == pi_order_src[i] )
487 assert( i_out < AOUT_CHAN_MAX );
488 pi_index[i_out++] = i;
489 i_layout |= pi_order_src[i];
490 break;
495 /* */
496 for( int i = 0, j = 0; i < AOUT_CHAN_MAX; i++ )
498 for( int k = 0; k < i_out; k++ )
500 if( pi_order_dst[i] == pi_order_src[pi_index[k]] )
502 pi_selection[j++] = pi_index[k];
503 break;
508 *pi_layout = i_layout;
509 *pi_channels = i_out;
511 for( int i = 0; i < i_out; i++ )
513 if( pi_selection[i] != i )
514 return true;
516 return i_out != i_channels;
519 /* Return the order in which filters should be inserted */
520 static int FilterOrder( const char *psz_name )
522 static const struct {
523 const char psz_name[10];
524 int i_order;
525 } filter[] = {
526 { "equalizer", 0 },
528 for( unsigned i = 0; i < ARRAY_SIZE(filter); i++ )
530 if( !strcmp( filter[i].psz_name, psz_name ) )
531 return filter[i].i_order;
533 return INT_MAX;
536 /* This function will add or remove a module from a string list (colon
537 * separated). It will return true if there is a modification
538 * In case p_aout is NULL, we will use configuration instead of variable */
539 bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
540 const char *psz_variable,
541 const char *psz_name, bool b_add )
543 if( *psz_name == '\0' )
544 return false;
546 char *psz_list;
547 if( p_aout )
549 psz_list = var_GetString( p_aout, psz_variable );
551 else
553 psz_list = var_InheritString( p_obj, psz_variable );
556 /* Split the string into an array of filters */
557 int i_count = 1;
558 for( char *p = psz_list; p && *p; p++ )
559 i_count += *p == ':';
560 i_count += b_add;
562 const char **ppsz_filter = calloc( i_count, sizeof(*ppsz_filter) );
563 if( !ppsz_filter )
565 free( psz_list );
566 return false;
568 bool b_present = false;
569 i_count = 0;
570 for( char *p = psz_list; p && *p; )
572 char *psz_end = strchr(p, ':');
573 if( psz_end )
574 *psz_end++ = '\0';
575 else
576 psz_end = p + strlen(p);
577 if( *p )
579 b_present |= !strcmp( p, psz_name );
580 ppsz_filter[i_count++] = p;
582 p = psz_end;
584 if( b_present == b_add )
586 free( ppsz_filter );
587 free( psz_list );
588 return false;
591 if( b_add )
593 int i_order = FilterOrder( psz_name );
594 int i;
595 for( i = 0; i < i_count; i++ )
597 if( FilterOrder( ppsz_filter[i] ) > i_order )
598 break;
600 if( i < i_count )
601 memmove( &ppsz_filter[i+1], &ppsz_filter[i], (i_count - i) * sizeof(*ppsz_filter) );
602 ppsz_filter[i] = psz_name;
603 i_count++;
605 else
607 for( int i = 0; i < i_count; i++ )
609 if( !strcmp( ppsz_filter[i], psz_name ) )
610 ppsz_filter[i] = "";
613 size_t i_length = 0;
614 for( int i = 0; i < i_count; i++ )
615 i_length += 1 + strlen( ppsz_filter[i] );
617 char *psz_new = malloc( i_length + 1 );
619 if( unlikely( !psz_new ) )
621 free( ppsz_filter );
622 free( psz_list );
623 return false;
626 *psz_new = '\0';
627 for( int i = 0; i < i_count; i++ )
629 if( *ppsz_filter[i] == '\0' )
630 continue;
631 if( *psz_new )
632 strcat( psz_new, ":" );
633 strcat( psz_new, ppsz_filter[i] );
635 free( ppsz_filter );
636 free( psz_list );
638 var_SetString( p_obj, psz_variable, psz_new );
639 if( p_aout )
640 var_SetString( p_aout, psz_variable, psz_new );
641 free( psz_new );
643 return true;