packetizer: hevc: add poc debug
[vlc.git] / modules / meta_engine / ID3Text.h
blob9ca2af052ec690fcd442d88c4cc626da381a118c
1 /*****************************************************************************
2 * ID3Text.h : ID3v2 Text Helper
3 *****************************************************************************
4 * Copyright (C) 2016 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20 #ifndef ID3TEXT_H
21 #define ID3TEXT_H
23 #include <vlc_charset.h>
25 static const char * ID3TextConv( const uint8_t *p_buf, size_t i_buf,
26 uint8_t i_charset, char **ppsz_allocated )
28 char *p_alloc = NULL;
29 const char *psz = p_alloc;
30 if( i_buf > 0 && i_charset < 0x04 )
32 switch( i_charset )
34 case 0x00:
35 psz = p_alloc = FromCharset( "ISO_8859-1", p_buf, i_buf );
36 break;
37 case 0x01:
38 psz = p_alloc = FromCharset( "UTF-16LE", p_buf, i_buf );
39 break;
40 case 0x02:
41 psz = p_alloc = FromCharset( "UTF-16BE", p_buf, i_buf );
42 break;
43 default:
44 case 0x03:
45 if( p_buf[ i_buf - 1 ] != 0x00 )
47 psz = p_alloc = (char *) malloc( i_buf + 1 );
48 if( p_alloc )
50 memcpy( p_alloc, p_buf, i_buf - 1 );
51 p_alloc[i_buf] = '\0';
54 else
56 psz = (const char *) p_buf;
58 break;
61 *ppsz_allocated = p_alloc;
62 return psz;
65 static inline const char * ID3TextConvert( const uint8_t *p_buf, size_t i_buf,
66 char **ppsz_allocated )
68 if( i_buf == 0 )
70 *ppsz_allocated = NULL;
71 return NULL;
73 return ID3TextConv( &p_buf[1], i_buf - 1, p_buf[0], ppsz_allocated );
76 #endif