• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/libav-0.8.8/libavformat/

Lines Matching refs:nut

29 #include "nut.h"
96 static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_checksum, uint64_t startcode)
188 static int decode_main_header(NUTContext *nut){
189 AVFormatContext *s= nut->avf;
195 end= get_packetheader(nut, bc, 1, MAIN_STARTCODE);
201 nut->max_distance = ffio_read_varlen(bc);
202 if(nut->max_distance > 65536){
203 av_log(s, AV_LOG_DEBUG, "max_distance %d\n", nut->max_distance);
204 nut->max_distance= 65536;
207 GET_V(nut->time_base_count, tmp>0 && tmp<INT_MAX / sizeof(AVRational))
208 nut->time_base= av_malloc(nut->time_base_count * sizeof(AVRational));
210 for(i=0; i<nut->time_base_count; i++){
211 GET_V(nut->time_base[i].num, tmp>0 && tmp<(1ULL<<31))
212 GET_V(nut->time_base[i].den, tmp>0 && tmp<(1ULL<<31))
213 if(av_gcd(nut->time_base[i].num, nut->time_base[i].den) != 1){
251 nut->frame_code[i].flags= FLAG_INVALID;
255 nut->frame_code[i].flags = tmp_flags ;
256 nut->frame_code[i].pts_delta = tmp_pts ;
257 nut->frame_code[i].stream_id = tmp_stream;
258 nut->frame_code[i].size_mul = tmp_mul ;
259 nut->frame_code[i].size_lsb = tmp_size+j;
260 nut->frame_code[i].reserved_count = tmp_res ;
261 nut->frame_code[i].header_idx = tmp_head_idx;
264 assert(nut->frame_code['N'].flags == FLAG_INVALID);
268 GET_V(nut->header_count, tmp<128U)
269 nut->header_count++;
270 for(i=1; i<nut->header_count; i++){
271 GET_V(nut->header_len[i], tmp>0 && tmp<256);
272 rem -= nut->header_len[i];
277 nut->header[i]= av_malloc(nut->header_len[i]);
278 avio_read(bc, nut->header[i], nut->header_len[i]);
280 assert(nut->header_len[0]==0);
288 nut->stream = av_mallocz(sizeof(StreamContext)*stream_count);
296 static int decode_stream_header(NUTContext *nut){
297 AVFormatContext *s= nut->avf;
304 end= get_packetheader(nut, bc, 1, STREAM_STARTCODE);
307 GET_V(stream_id, tmp < s->nb_streams && !nut->stream[tmp].time_base);
308 stc= &nut->stream[stream_id];
344 GET_V(stc->time_base_id , tmp < nut->time_base_count);
376 stc->time_base= &nut->time_base[stc->time_base_id];
394 static int decode_info_header(NUTContext *nut){
395 AVFormatContext *s= nut->avf;
407 end= get_packetheader(nut, bc, 1, INFO_STARTCODE);
417 int64_t start= chapter_start / nut->time_base_count;
419 nut->time_base[chapter_start % nut->time_base_count],
474 static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
475 AVFormatContext *s= nut->avf;
479 nut->last_syncpoint_pos= avio_tell(bc)-8;
481 end= get_packetheader(nut, bc, 1, SYNCPOINT_STARTCODE);
485 *back_ptr= nut->last_syncpoint_pos - 16*ffio_read_varlen(bc);
489 ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count);
496 *ts= tmp / s->nb_streams * av_q2d(nut->time_base[tmp % s->nb_streams])*AV_TIME_BASE;
497 ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts);
502 static int find_and_decode_index(NUTContext *nut){
503 AVFormatContext *s= nut->avf;
519 end= get_packetheader(nut, bc, 1, INDEX_STARTCODE);
601 NUTContext *nut = s->priv_data;
606 nut->avf= s;
616 }while(decode_main_header(nut) < 0);
626 if(decode_stream_header(nut) >= 0)
640 nut->next_startcode= startcode;
646 decode_info_header(nut);
653 find_and_decode_index(nut);
656 assert(nut->next_startcode == SYNCPOINT_STARTCODE);
663 static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, uint8_t *header_idx, int frame_code){
664 AVFormatContext *s= nut->avf;
670 if(avio_tell(bc) > nut->last_syncpoint_pos + nut->max_distance){
671 av_log(s, AV_LOG_ERROR, "Last frame must have been damaged %"PRId64" > %"PRId64" + %d\n", avio_tell(bc), nut->last_syncpoint_pos, nut->max_distance);
675 flags = nut->frame_code[frame_code].flags;
676 size_mul = nut->frame_code[frame_code].size_mul;
677 size = nut->frame_code[frame_code].size_lsb;
678 *stream_id = nut->frame_code[frame_code].stream_id;
679 pts_delta = nut->frame_code[frame_code].pts_delta;
680 reserved_count = nut->frame_code[frame_code].reserved_count;
681 *header_idx = nut->frame_code[frame_code].header_idx;
690 stc= &nut->stream[*stream_id];
712 if(*header_idx >= (unsigned)nut->header_count){
718 size -= nut->header_len[*header_idx];
722 }else if(size > 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){
733 static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){
734 AVFormatContext *s= nut->avf;
741 size= decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
745 stc= &nut->stream[stream_id];
760 av_new_packet(pkt, size + nut->header_len[header_idx]);
761 memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
763 avio_read(bc, pkt->data + nut->header_len[header_idx], size);
775 NUTContext *nut = s->priv_data;
782 uint64_t tmp= nut->next_startcode;
783 nut->next_startcode=0;
801 skip= get_packetheader(nut, bc, 0, tmp);
805 if(decode_info_header(nut)<0)
809 if(decode_syncpoint(nut, &ts, &back_ptr)<0)
813 ret= decode_frame(nut, pkt, frame_code);
821 tmp= find_any_startcode(bc, nut->last_syncpoint_pos+1);
825 nut->next_startcode= tmp;
831 NUTContext *nut = s->priv_data;
840 assert(nut->next_startcode == 0);
844 }while(decode_syncpoint(nut, &pts, &back_ptr) < 0);
846 assert(nut->last_syncpoint_pos == *pos_arg);
856 NUTContext *nut = s->priv_data;
872 av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pts_cmp,
882 av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
891 sp= av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
905 nut->stream[i].skip_until_key_frame=1;
912 NUTContext *nut = s->priv_data;
915 av_freep(&nut->time_base);
916 av_freep(&nut->stream);
917 ff_nut_free_sp(nut);
918 for(i = 1; i < nut->header_count; i++)
919 av_freep(&nut->header[i]);
926 .name = "nut",
934 .extensions = "nut",