@@ -66,23 +66,19 @@ static int y4m_parse_tags(y4m_params_t *y4m, char *tags)
6666
6767 char * p ;
6868 char * q ;
69- char t_buff [20 ];
69+ char colorspace [20 ];
7070 int found_w = 0 , found_h = 0 , found_cf = 0 ;
7171 int fps_n , fps_d , pix_ratio_n , pix_ratio_d ;
7272
7373 for (p = tags ;; p = q ) {
74-
7574 /*Skip any leading spaces.*/
76- while (* p == ' ' )
77- p ++ ;
75+ while (* p == ' ' ) p ++ ;
7876
7977 /*If that's all we have, stop.*/
80- if (p [0 ] == '\0' )
81- break ;
78+ if (p [0 ] == '\0' ) break ;
8279
8380 /*Find the end of this tag.*/
84- for (q = p + 1 ; * q != '\0' && * q != ' ' ; q ++ ) {
85- }
81+ for (q = p + 1 ; * q != '\0' && * q != ' ' ; q ++ ) { }
8682
8783 /*Process the tag.*/
8884 switch (p [0 ]) {
@@ -117,8 +113,8 @@ static int y4m_parse_tags(y4m_params_t *y4m, char *tags)
117113 case 'C' : {
118114 if (q - p > 16 )
119115 return OAPV_ERR ;
120- memcpy (t_buff , p + 1 , q - p - 1 );
121- t_buff [q - p - 1 ] = '\0' ;
116+ memcpy (colorspace , p + 1 , q - p - 1 );
117+ colorspace [q - p - 1 ] = '\0' ;
122118 found_cf = 1 ;
123119 break ;
124120 }
@@ -130,41 +126,45 @@ static int y4m_parse_tags(y4m_params_t *y4m, char *tags)
130126 logerr ("Mandatory arugments are not found in y4m header" );
131127 return OAPV_ERR ;
132128 }
133- /* Setting default colorspace to yuv420 and input_bd to 8 if header info. is NA */
129+
134130 if (!found_cf ) {
135131 y4m -> color_format = OAPV_CF_YCBCR420 ;
136132 y4m -> bit_depth = 8 ;
137133 }
138134
139- if (strcmp (t_buff , "420jpeg" ) == 0 || strcmp (t_buff , "420" ) == 0 ||
140- strcmp (t_buff , "420mpeg2" ) == 0 || strcmp (t_buff , "420paidv" ) == 0 ) {
135+ if (strcmp (colorspace , "420jpeg" ) == 0 || strcmp (colorspace , "420" ) == 0 ||
136+ strcmp (colorspace , "420mpeg2" ) == 0 || strcmp (colorspace , "420paidv" ) == 0 ) {
141137 y4m -> color_format = OAPV_CF_YCBCR420 ;
142138 y4m -> bit_depth = 8 ;
143139 }
144- else if (strcmp (t_buff , "422" ) == 0 ) {
140+ else if (strcmp (colorspace , "422" ) == 0 ) {
145141 y4m -> color_format = OAPV_CF_YCBCR422 ;
146142 y4m -> bit_depth = 8 ;
147143 }
148- else if (strcmp (t_buff , "444" ) == 0 ) {
144+ else if (strcmp (colorspace , "444" ) == 0 ) {
149145 y4m -> color_format = OAPV_CF_YCBCR444 ;
150146 y4m -> bit_depth = 8 ;
151147 }
152- else if (strcmp (t_buff , "420p10" ) == 0 ) {
148+ else if (strcmp (colorspace , "420p10" ) == 0 ) {
153149 y4m -> color_format = OAPV_CF_YCBCR420 ;
154150 y4m -> bit_depth = 10 ;
155151 }
156- else if (strcmp (t_buff , "422p10" ) == 0 ) {
152+ else if (strcmp (colorspace , "422p10" ) == 0 ) {
157153 y4m -> color_format = OAPV_CF_YCBCR422 ;
158154 y4m -> bit_depth = 10 ;
159155 }
160- else if (strcmp (t_buff , "444p10" ) == 0 ) {
156+ else if (strcmp (colorspace , "444p10" ) == 0 ) {
161157 y4m -> color_format = OAPV_CF_YCBCR444 ;
162158 y4m -> bit_depth = 10 ;
163159 }
164- else if (strcmp (t_buff , "mono" ) == 0 ) {
160+ else if (strcmp (colorspace , "mono" ) == 0 ) {
165161 y4m -> color_format = OAPV_CF_YCBCR400 ;
166162 y4m -> bit_depth = 8 ;
167163 }
164+ else if (strcmp (colorspace , "mono10" ) == 0 ) {
165+ y4m -> color_format = OAPV_CF_YCBCR400 ;
166+ y4m -> bit_depth = 10 ;
167+ }
168168 else {
169169 y4m -> color_format = OAPV_CF_UNKNOWN ;
170170 y4m -> bit_depth = -1 ;
@@ -255,10 +255,12 @@ static int write_y4m_header(char *fname, oapv_imgb_t *imgb)
255255 else if (color_format == OAPV_CF_YCBCR400 ) {
256256 if (bit_depth == 8 )
257257 strcpy (c_buf , "mono" );
258+ else if (bit_depth == 10 )
259+ strcpy (c_buf , "mono10" );
258260 }
259261
260262 if (strlen (c_buf ) == 0 ) {
261- logerr ("Color format is not suuported by y4m" );
263+ logerr ("Color format is not suuported by y4m\n " );
262264 return -1 ;
263265 }
264266
0 commit comments