34 #define NUT_MAX_STREAMS 256
47 string[
FFMIN(len, maxlen-1)]= 0;
58 if (v&1)
return -(v>>1);
71 static inline uint64_t get_v_trace(
AVIOContext *bc,
char *file,
char *func,
int line){
78 static inline int64_t get_s_trace(
AVIOContext *bc,
char *file,
char *func,
int line){
84 #define ffio_read_varlen(bc) get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
85 #define get_s(bc) get_s_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
115 state= (state<<8) |
avio_r8(bc);
116 if((state>>56) !=
'N')
140 if(startcode == code)
142 else if(startcode == 0)
153 code = (code << 8) | p->
buf[i];
160 #define GET_V(dst, check) \
161 tmp= ffio_read_varlen(bc);\
163 av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp);\
184 unsigned int stream_count;
185 int i, j, tmp_stream, tmp_mul, tmp_pts, tmp_size, count, tmp_res, tmp_head_idx;
190 GET_V(tmp , tmp >=2 && tmp <= 3)
217 if(tmp_fields>0) tmp_pts =
get_s(bc);
225 else count = tmp_mul - tmp_size;
226 if(tmp_fields>6)
get_s(bc);
229 while(tmp_fields-- > 8)
232 if(count == 0 || i+count > 256){
236 if(tmp_stream >= stream_count){
241 for(j=0; j<count; j++,i++){
281 for(i=0; i<stream_count; i++){
292 int class, stream_id;
300 stc= &nut->
stream[stream_id];
334 (
unsigned int)tmp, stream_id);
382 if (stream_id == i || stream_id == -1)
389 uint64_t tmp, chapter_start, chapter_len;
390 unsigned int stream_id_plus1, count;
393 char name[256], str_value[1024], type_str[256];
402 GET_V(stream_id_plus1, tmp <= s->nb_streams)
403 chapter_id =
get_s(bc);
408 if(chapter_id && !stream_id_plus1){
412 start, start + chapter_len,
NULL);
414 }
else if(stream_id_plus1) {
415 st= s->
streams[stream_id_plus1 - 1];
420 for(i=0; i<count; i++){
421 get_str(bc, name,
sizeof(name));
425 get_str(bc, str_value,
sizeof(str_value));
426 }
else if(value == -2){
427 get_str(bc, type_str,
sizeof(type_str));
429 get_str(bc, str_value,
sizeof(str_value));
430 }
else if(value == -3){
433 }
else if(value == -4){
436 }
else if(value < -4){
448 if(!strcmp(type,
"UTF-8")){
449 if(chapter_id==0 && !strcmp(name,
"Disposition")) {
498 int i, j, syncpoint_count;
501 int8_t *has_keyframe;
515 GET_V(syncpoint_count, tmp < INT_MAX/8 && tmp > 0)
516 syncpoints=
av_malloc(
sizeof(int64_t)*syncpoint_count);
517 has_keyframe=
av_malloc(
sizeof(int8_t)*(syncpoint_count+1));
518 for(i=0; i<syncpoint_count; i++){
520 if(syncpoints[i] <= 0)
523 syncpoints[i] += syncpoints[i-1];
527 int64_t last_pts= -1;
528 for(j=0; j<syncpoint_count;){
536 if(n+x >= syncpoint_count + 1){
541 has_keyframe[n++]= flag;
542 has_keyframe[n++]= !flag;
545 if(n>=syncpoint_count + 1){
549 has_keyframe[n++]= x&1;
557 assert(n<=syncpoint_count+1);
558 for(; j<n && j<syncpoint_count; j++){
596 int initialized_stream_count;
612 for(initialized_stream_count=0; initialized_stream_count < s->
nb_streams;){
619 initialized_stream_count++;
659 int size,
flags, size_mul, pts_delta, i, reserved_count;
680 GET_V(*stream_id, tmp < s->nb_streams)
682 stc= &nut->
stream[*stream_id];
701 for(i=0; i<reserved_count; i++)
728 int size, stream_id, discard;
729 int64_t pts, last_IP_pts;
737 stc= &nut->
stream[stream_id];
769 int i, frame_code=0, ret, skip;
770 int64_t ts, back_ptr;
783 if(frame_code ==
'N'){
825 int64_t pos, pts, back_ptr;
826 av_log(s,
AV_LOG_DEBUG,
"read_timestamp(X,%d,%"PRId64
",%"PRId64
")\n", stream_index, *pos_arg, pos_limit);
841 if (stream_index == -1)
return pts;
842 else if(stream_index == -2)
return back_ptr;
852 Syncpoint *
sp, *next_node[2]= {&nopts_sp, &nopts_sp};
853 int64_t pos, pos2, ts;
865 (
void **) next_node);
866 av_log(s,
AV_LOG_DEBUG,
"%"PRIu64
"-%"PRIu64
" %"PRId64
"-%"PRId64
"\n", next_node[0]->pos, next_node[1]->pos,
867 next_node[0]->ts , next_node[1]->ts);
873 next_node[1]= &nopts_sp;
875 (
void **) next_node);
893 if(pos2 > pos || pos2 + 15 < pos){
916 #if CONFIG_NUT_DEMUXER