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){
85 static inline uint64_t get_vb_trace(
AVIOContext *bc,
char *file,
char *func,
int line){
86 uint64_t
v= get_vb(bc);
91 #define ffio_read_varlen(bc) get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
92 #define get_s(bc) get_s_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
93 #define get_vb(bc) get_vb_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
123 state= (state<<8) |
avio_r8(bc);
124 if((state>>56) !=
'N')
148 if(startcode == code)
150 else if(startcode == 0)
161 code = (code << 8) | p->
buf[i];
168 #define GET_V(dst, check) \
169 tmp= ffio_read_varlen(bc);\
171 av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp);\
192 unsigned int stream_count;
193 int i, j, tmp_stream, tmp_mul, tmp_pts, tmp_size, count, tmp_res, tmp_head_idx;
198 GET_V(tmp , tmp >=2 && tmp <= 3)
225 if(tmp_fields>0) tmp_pts =
get_s(bc);
233 else count = tmp_mul - tmp_size;
234 if(tmp_fields>6)
get_s(bc);
237 while(tmp_fields-- > 8)
240 if(count == 0 || i+count > 256){
244 if(tmp_stream >= stream_count){
249 for(j=0; j<count; j++,i++){
289 for(i=0; i<stream_count; i++){
300 int class, stream_id;
308 stc= &nut->
stream[stream_id];
342 (
unsigned int)tmp, stream_id);
390 if (stream_id == i || stream_id == -1)
397 uint64_t tmp, chapter_start, chapter_len;
398 unsigned int stream_id_plus1, count;
401 char name[256], str_value[1024], type_str[256];
410 GET_V(stream_id_plus1, tmp <= s->nb_streams)
411 chapter_id =
get_s(bc);
416 if(chapter_id && !stream_id_plus1){
420 start, start + chapter_len,
NULL);
422 }
else if(stream_id_plus1) {
423 st= s->
streams[stream_id_plus1 - 1];
428 for(i=0; i<count; i++){
429 get_str(bc, name,
sizeof(name));
433 get_str(bc, str_value,
sizeof(str_value));
434 }
else if(value == -2){
435 get_str(bc, type_str,
sizeof(type_str));
437 get_str(bc, str_value,
sizeof(str_value));
438 }
else if(value == -3){
441 }
else if(value == -4){
444 }
else if(value < -4){
456 if(!strcmp(type,
"UTF-8")){
457 if(chapter_id==0 && !strcmp(name,
"Disposition")) {
506 int i, j, syncpoint_count;
509 int8_t *has_keyframe;
523 GET_V(syncpoint_count, tmp < INT_MAX/8 && tmp > 0)
524 syncpoints=
av_malloc(
sizeof(int64_t)*syncpoint_count);
525 has_keyframe=
av_malloc(
sizeof(int8_t)*(syncpoint_count+1));
526 for(i=0; i<syncpoint_count; i++){
528 if(syncpoints[i] <= 0)
531 syncpoints[i] += syncpoints[i-1];
535 int64_t last_pts= -1;
536 for(j=0; j<syncpoint_count;){
544 if(n+x >= syncpoint_count + 1){
549 has_keyframe[n++]= flag;
550 has_keyframe[n++]= !flag;
553 if(n>=syncpoint_count + 1){
557 has_keyframe[n++]= x&1;
565 assert(n<=syncpoint_count+1);
566 for(; j<n && j<syncpoint_count; j++){
604 int initialized_stream_count;
620 for(initialized_stream_count=0; initialized_stream_count < s->
nb_streams;){
627 initialized_stream_count++;
667 int size,
flags, size_mul, pts_delta, i, reserved_count;
688 GET_V(*stream_id, tmp < s->nb_streams)
690 stc= &nut->
stream[*stream_id];
709 for(i=0; i<reserved_count; i++)
736 int size, stream_id, discard;
737 int64_t pts, last_IP_pts;
745 stc= &nut->
stream[stream_id];
777 int i, frame_code=0, ret, skip;
778 int64_t ts, back_ptr;
791 if(frame_code ==
'N'){
833 int64_t pos, pts, back_ptr;
834 av_log(s,
AV_LOG_DEBUG,
"read_timestamp(X,%d,%"PRId64
",%"PRId64
")\n", stream_index, *pos_arg, pos_limit);
849 if (stream_index == -1)
return pts;
850 else if(stream_index == -2)
return back_ptr;
860 Syncpoint *
sp, *next_node[2]= {&nopts_sp, &nopts_sp};
861 int64_t pos, pos2, ts;
873 (
void **) next_node);
874 av_log(s,
AV_LOG_DEBUG,
"%"PRIu64
"-%"PRIu64
" %"PRId64
"-%"PRId64
"\n", next_node[0]->pos, next_node[1]->pos,
875 next_node[0]->ts , next_node[1]->ts);
881 next_node[1]= &nopts_sp;
883 (
void **) next_node);
901 if(pos2 > pos || pos2 + 15 < pos){
924 #if CONFIG_NUT_DEMUXER