Lines Matching refs:priv

155 static int build_default_huffman_tables(struct jdec_private *priv)  in build_default_huffman_tables()  argument
158 if (priv->default_huffman_table_initialized) in build_default_huffman_tables()
162 priv->HTDC_valid[i] = 1; in build_default_huffman_tables()
163 memcpy(priv->HTDC[i].bits, default_huffman_table_param.huffman_table[i].num_dc_codes, 16); in build_default_huffman_tables()
164 memcpy(priv->HTDC[i].values, default_huffman_table_param.huffman_table[i].dc_values, 16); in build_default_huffman_tables()
165 priv->HTAC_valid[i] = 1; in build_default_huffman_tables()
166 memcpy(priv->HTAC[i].bits, default_huffman_table_param.huffman_table[i].num_ac_codes, 16); in build_default_huffman_tables()
167 memcpy(priv->HTAC[i].values, default_huffman_table_param.huffman_table[i].ac_values, 256); in build_default_huffman_tables()
169 priv->default_huffman_table_initialized = 1; in build_default_huffman_tables()
199 static int parse_DQT(struct jdec_private *priv, const unsigned char *stream) in parse_DQT() argument
217 memcpy(priv->Q_tables[qi&0x0F], stream, 64); in parse_DQT()
218 priv->Q_tables_valid[qi & 0x0f] = 1; in parse_DQT()
225 static int parse_SOF(struct jdec_private *priv, const unsigned char *stream) in parse_SOF() argument
237 priv->nf_components = nr_components; in parse_SOF()
255 c = &priv->component_infos[i]; in parse_SOF()
266 priv->width[scan_num] = width; in parse_SOF()
267 priv->height[scan_num] = height; in parse_SOF()
274 static int parse_SOS(struct jdec_private *priv, const unsigned char *stream) in parse_SOS() argument
281 priv->cur_sos.nr_components= nr_components; in parse_SOS()
287 priv->cur_sos.components[i].component_id = cid; in parse_SOS()
288 priv->cur_sos.components[i].dc_selector = ((table>>4)&0x0F); in parse_SOS()
289 priv->cur_sos.components[i].ac_selector = (table&0x0F); in parse_SOS()
295 if (cid != priv->component_infos[i].cid) in parse_SOS()
297 i, cid, i, priv->component_infos[i].cid); in parse_SOS()
301 priv->stream = stream+3; in parse_SOS()
306 int tinyjpeg_parse_SOS(struct jdec_private *priv, const unsigned char *stream) in tinyjpeg_parse_SOS() argument
308 return parse_SOS(priv, stream); in tinyjpeg_parse_SOS()
312 static int parse_DHT(struct jdec_private *priv, const unsigned char *stream) in parse_DHT() argument
329 memcpy(priv->HTAC[index & 0xf].bits, stream, 16); in parse_DHT()
332 memcpy(priv->HTDC[index & 0xf].bits, stream, 16); in parse_DHT()
349 memcpy(priv->HTAC[index & 0xf].values, stream, count); in parse_DHT()
350 priv->HTAC_valid[index & 0xf] = 1; in parse_DHT()
353 memcpy(priv->HTDC[index & 0xf].values, stream, count); in parse_DHT()
354 priv->HTDC_valid[index & 0xf] = 1; in parse_DHT()
365 static int parse_DRI(struct jdec_private *priv, const unsigned char *stream) in parse_DRI() argument
378 priv->restart_interval = be16_to_cpu(stream+2); in parse_DRI()
381 trace("Restart interval = %d\n", priv->restart_interval); in parse_DRI()
389 static int findEOI(struct jdec_private *priv,const unsigned char *stream) in findEOI() argument
391 …while (!(*stream == 0xff && *(stream+1) == 0xd9 )&& stream<=priv->stream_end) //searching for the… in findEOI()
396 priv->stream_scan=stream; in findEOI()
400 static int findSOI(struct jdec_private *priv,const unsigned char *stream) in findSOI() argument
404 if(stream<=priv->stream_end) in findSOI()
412 priv->stream=stream+2; in findSOI()
416 static int parse_JFIF(struct jdec_private *priv, const unsigned char *stream) in parse_JFIF() argument
425 next_image_found = findSOI(priv,stream); in parse_JFIF()
426 stream=priv->stream; in parse_JFIF()
428 while (!sos_marker_found && stream<=priv->stream_end) in parse_JFIF()
439 if (parse_SOF(priv, stream) < 0) in parse_JFIF()
443 if (parse_DQT(priv, stream) < 0) in parse_JFIF()
448 if (parse_SOS(priv, stream) < 0) in parse_JFIF()
453 if (parse_DHT(priv, stream) < 0) in parse_JFIF()
458 if (parse_DRI(priv, stream) < 0) in parse_JFIF()
472 build_default_huffman_tables(priv); in parse_JFIF()
479 if ( (priv->component_infos[cY].Hfactor < priv->component_infos[cCb].Hfactor) in parse_JFIF()
480 || (priv->component_infos[cY].Hfactor < priv->component_infos[cCr].Hfactor)) in parse_JFIF()
482 if ( (priv->component_infos[cY].Vfactor < priv->component_infos[cCb].Vfactor) in parse_JFIF()
483 || (priv->component_infos[cY].Vfactor < priv->component_infos[cCr].Vfactor)) in parse_JFIF()
485 if ( (priv->component_infos[cCb].Hfactor!=1) in parse_JFIF()
486 || (priv->component_infos[cCr].Hfactor!=1) in parse_JFIF()
487 || (priv->component_infos[cCb].Vfactor!=1) in parse_JFIF()
488 || (priv->component_infos[cCr].Vfactor!=1)) in parse_JFIF()
491 findEOI(priv,stream); in parse_JFIF()
513 struct jdec_private *priv; in tinyjpeg_init() local
515 priv = (struct jdec_private *)calloc(1, sizeof(struct jdec_private)); in tinyjpeg_init()
516 if (priv == NULL) in tinyjpeg_init()
518 return priv; in tinyjpeg_init()
526 void tinyjpeg_free(struct jdec_private *priv) in tinyjpeg_free() argument
528 free(priv); in tinyjpeg_free()
537 int tinyjpeg_parse_header(struct jdec_private *priv, const unsigned char *buf, unsigned int size) in tinyjpeg_parse_header() argument
545 priv->stream_begin = buf; in tinyjpeg_parse_header()
546 priv->stream_length = size; in tinyjpeg_parse_header()
547 priv->stream_end = priv->stream_begin + priv->stream_length; in tinyjpeg_parse_header()
549 priv->stream = priv->stream_begin; in tinyjpeg_parse_header()
550 ret = parse_JFIF(priv, priv->stream); in tinyjpeg_parse_header()
555 int tinyjpeg_decode(struct jdec_private *priv) in tinyjpeg_decode() argument
620 pic_param.picture_width = priv->width[scan_num]; in tinyjpeg_decode()
621 pic_param.picture_height = priv->height[scan_num]; in tinyjpeg_decode()
622 pic_param.num_components = priv->nf_components; in tinyjpeg_decode()
626 pic_param.components[i].component_id = priv->component_infos[i].cid; in tinyjpeg_decode()
627 pic_param.components[i].h_sampling_factor = priv->component_infos[i].Hfactor; in tinyjpeg_decode()
628 pic_param.components[i].v_sampling_factor = priv->component_infos[i].Vfactor; in tinyjpeg_decode()
629 … pic_param.components[i].quantiser_table_selector = priv->component_infos[i].quant_table_index; in tinyjpeg_decode()
703 priv->width[scan_num],priv->height[scan_num], //alignment? in tinyjpeg_decode()
709 priv->width[scan_num], priv->height[scan_num], // alignment? in tinyjpeg_decode()
729 if (!priv->Q_tables_valid[i]) in tinyjpeg_decode()
733 iq_matrix.quantiser_table[i][j] = priv->Q_tables[i][j]; in tinyjpeg_decode()
747 sizeof(priv->HTDC[0].bits)); in tinyjpeg_decode()
749 sizeof(priv->HTDC[0].values[0])); in tinyjpeg_decode()
751 if (!priv->HTDC_valid[i] || !priv->HTAC_valid[i]) in tinyjpeg_decode()
754 memcpy(huffman_table.huffman_table[i].num_dc_codes, priv->HTDC[i].bits, in tinyjpeg_decode()
756 memcpy(huffman_table.huffman_table[i].dc_values, priv->HTDC[i].values, in tinyjpeg_decode()
758 memcpy(huffman_table.huffman_table[i].num_ac_codes, priv->HTAC[i].bits, in tinyjpeg_decode()
760 memcpy(huffman_table.huffman_table[i].ac_values, priv->HTAC[i].values, in tinyjpeg_decode()
773 max_h_factor = priv->component_infos[0].Hfactor; in tinyjpeg_decode()
774 max_v_factor = priv->component_infos[0].Vfactor; in tinyjpeg_decode()
776 slice_param.slice_data_size = (priv->stream_scan - priv->stream); in tinyjpeg_decode()
781 slice_param.num_components = priv->cur_sos.nr_components; in tinyjpeg_decode()
783 …slice_param.components[i].component_selector = priv->cur_sos.components[i].component_id; /* FIXME:… in tinyjpeg_decode()
784 …slice_param.components[i].dc_table_selector = priv->cur_sos.components[i].dc_selector; /* FIXME: … in tinyjpeg_decode()
785 …slice_param.components[i].ac_table_selector = priv->cur_sos.components[i].ac_selector; /* FIXME: … in tinyjpeg_decode()
787 slice_param.restart_interval = priv->restart_interval; in tinyjpeg_decode()
788 slice_param.num_mcus = ((priv->width[scan_num]+max_h_factor*8-1)/(max_h_factor*8))* in tinyjpeg_decode()
789 … ((priv->height[scan_num]+max_v_factor*8-1)/(max_v_factor*8)); // ?? 720/16? in tinyjpeg_decode()
800 priv->stream_scan - priv->stream, in tinyjpeg_decode()
802 (void*)priv->stream, // jpeg_clip, in tinyjpeg_decode()
835 src_rect.width = priv->width[scan_num]; in tinyjpeg_decode()
836 src_rect.height = priv->height[scan_num]; in tinyjpeg_decode()
848 parse_JFIF(priv,priv->stream); in tinyjpeg_decode()
849 if(priv->width[scan_num] == 0 && priv->height[scan_num] == 0) in tinyjpeg_decode()
858 const char *tinyjpeg_get_errorstring(struct jdec_private *priv) in tinyjpeg_get_errorstring() argument
861 priv = priv; in tinyjpeg_get_errorstring()
864 void tinyjpeg_get_size(struct jdec_private *priv, unsigned int *width, unsigned int *height) in tinyjpeg_get_size() argument
866 *width = priv->width[scan_num]; in tinyjpeg_get_size()
867 *height = priv->height[scan_num]; in tinyjpeg_get_size()