• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/ffmpeg/libavformat/

Lines Matching defs:nut

27 #include "nut.h"
92 static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_checksum, uint64_t startcode)
184 static int decode_main_header(NUTContext *nut){
185 AVFormatContext *s= nut->avf;
192 end= get_packetheader(nut, bc, 1, MAIN_STARTCODE);
198 nut->max_distance = ff_get_v(bc);
199 if(nut->max_distance > 65536){
200 av_log(s, AV_LOG_DEBUG, "max_distance %d\n", nut->max_distance);
201 nut->max_distance= 65536;
204 GET_V(nut->time_base_count, tmp>0 && tmp<INT_MAX / sizeof(AVRational))
205 nut->time_base= av_malloc(nut->time_base_count * sizeof(AVRational));
207 for(i=0; i<nut->time_base_count; i++){
208 GET_V(nut->time_base[i].num, tmp>0 && tmp<(1ULL<<31))
209 GET_V(nut->time_base[i].den, tmp>0 && tmp<(1ULL<<31))
210 if(av_gcd(nut->time_base[i].num, nut->time_base[i].den) != 1){
249 nut->frame_code[i].flags= FLAG_INVALID;
253 nut->frame_code[i].flags = tmp_flags ;
254 nut->frame_code[i].pts_delta = tmp_pts ;
255 nut->frame_code[i].stream_id = tmp_stream;
256 nut->frame_code[i].size_mul = tmp_mul ;
257 nut->frame_code[i].size_lsb = tmp_size+j;
258 nut->frame_code[i].reserved_count = tmp_res ;
259 nut->frame_code[i].header_idx = tmp_head_idx;
262 assert(nut->frame_code['N'].flags == FLAG_INVALID);
266 GET_V(nut->header_count, tmp<128U)
267 nut->header_count++;
268 for(i=1; i<nut->header_count; i++){
269 GET_V(nut->header_len[i], tmp>0 && tmp<256);
270 rem -= nut->header_len[i];
275 nut->header[i]= av_malloc(nut->header_len[i]);
276 get_buffer(bc, nut->header[i], nut->header_len[i]);
278 assert(nut->header_len[0]==0);
286 nut->stream = av_mallocz(sizeof(StreamContext)*stream_count);
294 static int decode_stream_header(NUTContext *nut){
295 AVFormatContext *s= nut->avf;
302 end= get_packetheader(nut, bc, 1, STREAM_STARTCODE);
305 GET_V(stream_id, tmp < s->nb_streams && !nut->stream[tmp].time_base);
306 stc= &nut->stream[stream_id];
340 GET_V(stc->time_base_id , tmp < nut->time_base_count);
372 stc->time_base= &nut->time_base[stc->time_base_id];
390 static int decode_info_header(NUTContext *nut){
391 AVFormatContext *s= nut->avf;
402 end= get_packetheader(nut, bc, 1, INFO_STARTCODE);
412 int64_t start= chapter_start / nut->time_base_count;
414 nut->time_base[chapter_start % nut->time_base_count],
467 static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
468 AVFormatContext *s= nut->avf;
472 nut->last_syncpoint_pos= url_ftell(bc)-8;
474 end= get_packetheader(nut, bc, 1, SYNCPOINT_STARTCODE);
478 *back_ptr= nut->last_syncpoint_pos - 16*ff_get_v(bc);
482 ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count);
489 *ts= tmp / s->nb_streams * av_q2d(nut->time_base[tmp % s->nb_streams])*AV_TIME_BASE;
490 ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
495 static int find_and_decode_index(NUTContext *nut){
496 AVFormatContext *s= nut->avf;
512 end= get_packetheader(nut, bc, 1, INDEX_STARTCODE);
594 NUTContext *nut = s->priv_data;
599 nut->avf= s;
609 }while(decode_main_header(nut) < 0);
619 if(decode_stream_header(nut) >= 0)
633 nut->next_startcode= startcode;
639 decode_info_header(nut);
646 find_and_decode_index(nut);
649 assert(nut->next_startcode == SYNCPOINT_STARTCODE);
654 static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, uint8_t *header_idx, int frame_code){
655 AVFormatContext *s= nut->avf;
661 if(url_ftell(bc) > nut->last_syncpoint_pos + nut->max_distance){
662 av_log(s, AV_LOG_ERROR, "Last frame must have been damaged %"PRId64" > %"PRId64" + %d\n", url_ftell(bc), nut->last_syncpoint_pos, nut->max_distance);
666 flags = nut->frame_code[frame_code].flags;
667 size_mul = nut->frame_code[frame_code].size_mul;
668 size = nut->frame_code[frame_code].size_lsb;
669 *stream_id = nut->frame_code[frame_code].stream_id;
670 pts_delta = nut->frame_code[frame_code].pts_delta;
671 reserved_count = nut->frame_code[frame_code].reserved_count;
672 *header_idx = nut->frame_code[frame_code].header_idx;
681 stc= &nut->stream[*stream_id];
703 if(*header_idx >= (unsigned)nut->header_count){
709 size -= nut->header_len[*header_idx];
713 }else if(size > 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){
724 static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
725 AVFormatContext *s= nut->avf;
732 size= decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
736 stc= &nut->stream[stream_id];
751 av_new_packet(pkt, size + nut->header_len[header_idx]);
752 memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
754 get_buffer(bc, pkt->data + nut->header_len[header_idx], size);
766 NUTContext *nut = s->priv_data;
773 uint64_t tmp= nut->next_startcode;
774 nut->next_startcode=0;
792 skip= get_packetheader(nut, bc, 0, tmp);
796 if(decode_info_header(nut)<0)
800 if(decode_syncpoint(nut, &ts, &back_ptr)<0)
804 ret= decode_frame(nut, pkt, frame_code);
812 tmp= find_any_startcode(bc, nut->last_syncpoint_pos+1);
816 nut->next_startcode= tmp;
822 NUTContext *nut = s->priv_data;
831 assert(nut->next_startcode == 0);
835 }while(decode_syncpoint(nut, &pts, &back_ptr) < 0);
837 assert(nut->last_syncpoint_pos == *pos_arg);
847 NUTContext *nut = s->priv_data;
863 av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pts_cmp,
873 av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
882 sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
896 nut->stream[i].skip_until_key_frame=1;
903 NUTContext *nut = s->priv_data;
906 av_freep(&nut->time_base);
907 av_freep(&nut->stream);
908 ff_nut_free_sp(nut);
909 for(i = 1; i < nut->header_count; i++)
910 av_freep(&nut->header[i]);
917 "nut",
925 .extensions = "nut",