Lines Matching full:decoder
176 void frag_dec_init(struct frag_decoder *decoder, size_t nb_frag, size_t frag_size) in frag_dec_init() argument
178 decoder->nb_frag = nb_frag; in frag_dec_init()
179 decoder->frag_size = frag_size; in frag_dec_init()
181 decoder->lost_frame_count = decoder->nb_frag; in frag_dec_init()
182 sys_bitarray_set_region(&lost_frames, decoder->nb_frag, 0); in frag_dec_init()
187 decoder->filled_lost_frame_count = 0; in frag_dec_init()
188 decoder->status = FRAG_DEC_STA_UNCODED; in frag_dec_init()
191 void frag_dec_frame_received(struct frag_decoder *decoder, uint16_t index) in frag_dec_frame_received() argument
199 decoder->lost_frame_count--; in frag_dec_frame_received()
227 int frag_dec(struct frag_decoder *decoder, uint16_t frag_counter, const uint8_t *buf, size_t len) in frag_dec() argument
236 if (decoder->status == FRAG_DEC_STA_DONE) { in frag_dec()
237 return decoder->lost_frame_count; in frag_dec()
240 if (len != decoder->frag_size) { in frag_dec()
246 if (frag_counter <= decoder->nb_frag && decoder->status == FRAG_DEC_STA_UNCODED) { in frag_dec()
248 frag_dec_frame_received(decoder, frag_counter - 1); in frag_dec()
250 frag_flash_write((frag_counter - 1) * decoder->frag_size, (uint8_t *)buf, in frag_dec()
251 decoder->frag_size); in frag_dec()
253 if (decoder->lost_frame_count == 0) { in frag_dec()
254 decoder->status = FRAG_DEC_STA_DONE; in frag_dec()
255 return decoder->lost_frame_count; in frag_dec()
260 decoder->status = FRAG_DEC_STA_CODED; in frag_dec()
263 bit_clear_all(&matched_lost_frm_bm0, decoder->lost_frame_count); in frag_dec()
264 bit_clear_all(&matched_lost_frm_bm1, decoder->lost_frame_count); in frag_dec()
267 memcpy(xor_row_data_buf, buf, decoder->frag_size); in frag_dec()
269 if (decoder->lost_frame_count > FRAG_TOLERANCE) { in frag_dec()
275 frag_dec_parity_matrix_vector(decoder->nb_frag, frag_counter - decoder->nb_frag, in frag_dec()
277 for (i = 0; i < decoder->nb_frag; i++) { in frag_dec()
292 frag_flash_read(i * decoder->frag_size, row_data_buf, decoder->frag_size); in frag_dec()
295 decoder->frag_size); in frag_dec()
306 ret = sys_bitarray_find_nth_set(&matched_lost_frm_bm0, 1, decoder->lost_frame_count, in frag_dec()
318 decoder->nb_frag, 0, &frame_index); in frag_dec()
328 lost_frame_index, decoder->lost_frame_count)) { in frag_dec()
330 &matched_lost_frm_bm0, decoder->lost_frame_count); in frag_dec()
331 frag_flash_write(frame_index * decoder->frag_size, xor_row_data_buf, in frag_dec()
332 decoder->frag_size); in frag_dec()
333 decoder->filled_lost_frame_count++; in frag_dec()
338 decoder->lost_frame_count); in frag_dec()
339 bit_xor(&matched_lost_frm_bm0, &matched_lost_frm_bm1, decoder->lost_frame_count); in frag_dec()
340 frag_flash_read(frame_index * decoder->frag_size, row_data_buf, decoder->frag_size); in frag_dec()
341 mem_xor_n(xor_row_data_buf, xor_row_data_buf, row_data_buf, decoder->frag_size); in frag_dec()
342 } while (!sys_bitarray_is_region_cleared(&matched_lost_frm_bm0, decoder->lost_frame_count, in frag_dec()
345 if (decoder->filled_lost_frame_count != decoder->lost_frame_count) { in frag_dec()
349 if (decoder->lost_frame_count < 2) { in frag_dec()
350 decoder->status = FRAG_DEC_STA_DONE; in frag_dec()
351 return decoder->lost_frame_count; in frag_dec()
355 for (i = (decoder->lost_frame_count - 2); i >= 0; i--) { in frag_dec()
356 ret = sys_bitarray_find_nth_set(&lost_frames, i + 1, decoder->nb_frag, 0, in frag_dec()
361 frag_flash_read(frame_index * decoder->frag_size, xor_row_data_buf, in frag_dec()
362 decoder->frag_size); in frag_dec()
364 decoder->lost_frame_count); in frag_dec()
365 for (j = (decoder->lost_frame_count - 1); j > i; j--) { in frag_dec()
369 ret = sys_bitarray_find_nth_set(&lost_frames, j + 1, decoder->nb_frag, 0, in frag_dec()
375 decoder->lost_frame_count); in frag_dec()
377 decoder->lost_frame_count); in frag_dec()
378 frag_flash_read(lost_frame_index * decoder->frag_size, row_data_buf, in frag_dec()
379 decoder->frag_size); in frag_dec()
381 decoder->frag_size); in frag_dec()
383 decoder->lost_frame_count); in frag_dec()
385 frag_flash_write(frame_index * decoder->frag_size, xor_row_data_buf, in frag_dec()
386 decoder->frag_size); in frag_dec()
388 decoder->status = FRAG_DEC_STA_DONE; in frag_dec()
389 return decoder->lost_frame_count; in frag_dec()