* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <strings.h>
#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
+#include "libavutil/dict.h"
+#include "libavutil/mathematics.h"
#include "libavutil/tree.h"
#include "avio_internal.h"
#include "nut.h"
#undef NDEBUG
#include <assert.h>
-#if FF_API_MAX_STREAMS
-#define NUT_MAX_STREAMS MAX_STREAMS
-#else
#define NUT_MAX_STREAMS 256 /* arbitrary sanity check value */
-#endif
static int get_str(AVIOContext *bc, char *string, unsigned int maxlen){
unsigned int len= ffio_read_varlen(bc);
startcode= av_be2ne64(startcode);
startcode= ff_crc04C11DB7_update(0, (uint8_t*)&startcode, 8);
- init_checksum(bc, ff_crc04C11DB7_update, startcode);
+ ffio_init_checksum(bc, ff_crc04C11DB7_update, startcode);
size= ffio_read_varlen(bc);
if(size > 4096)
avio_rb32(bc);
- if(get_checksum(bc) && size > 4096)
+ if(ffio_get_checksum(bc) && size > 4096)
return -1;
- init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
+ ffio_init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
return size;
}
uint64_t tmp, end;
unsigned int stream_count;
int i, j, tmp_stream, tmp_mul, tmp_pts, tmp_size, count, tmp_res, tmp_head_idx;
- int64_t tmp_match;
end= get_packetheader(nut, bc, 1, MAIN_STARTCODE);
end += avio_tell(bc);
tmp_pts=0;
tmp_mul=1;
tmp_stream=0;
- tmp_match= 1-(1LL<<62);
tmp_head_idx= 0;
for(i=0; i<256;){
int tmp_flags = ffio_read_varlen(bc);
else tmp_res = 0;
if(tmp_fields>5) count = ffio_read_varlen(bc);
else count = tmp_mul - tmp_size;
- if(tmp_fields>6) tmp_match = get_s(bc);
+ if(tmp_fields>6) get_s(bc);
if(tmp_fields>7) tmp_head_idx= ffio_read_varlen(bc);
while(tmp_fields-- > 8)
assert(nut->header_len[0]==0);
}
- if(skip_reserved(bc, end) || get_checksum(bc)){
+ if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "main header checksum mismatch\n");
return AVERROR_INVALIDDATA;
}
nut->stream = av_mallocz(sizeof(StreamContext)*stream_count);
for(i=0; i<stream_count; i++){
- av_new_stream(s, i);
+ avformat_new_stream(s, NULL);
}
return 0;
ffio_read_varlen(bc); // samplerate_den
GET_V(st->codec->channels, tmp > 0)
}
- if(skip_reserved(bc, end) || get_checksum(bc)){
+ if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "stream header %d checksum mismatch\n", stream_id);
return -1;
}
stc->time_base= &nut->time_base[stc->time_base_id];
- av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den);
+ avpriv_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den);
return 0;
}
const char *type;
AVChapter *chapter= NULL;
AVStream *st= NULL;
- AVMetadata **metadata = NULL;
+ AVDictionary **metadata = NULL;
end= get_packetheader(nut, bc, 1, INFO_STARTCODE);
end += avio_tell(bc);
if(chapter_id && !stream_id_plus1){
int64_t start= chapter_start / nut->time_base_count;
- chapter= ff_new_chapter(s, chapter_id,
+ chapter= avpriv_new_chapter(s, chapter_id,
nut->time_base[chapter_start % nut->time_base_count],
start, start + chapter_len, NULL);
metadata = &chapter->metadata;
set_disposition_bits(s, str_value, stream_id_plus1 - 1);
continue;
}
- if(metadata && strcasecmp(name,"Uses")
- && strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
- av_metadata_set2(metadata, name, str_value, 0);
+ if(metadata && av_strcasecmp(name,"Uses")
+ && av_strcasecmp(name,"Depends") && av_strcasecmp(name,"Replaces"))
+ av_dict_set(metadata, name, str_value, 0);
}
}
- if(skip_reserved(bc, end) || get_checksum(bc)){
+ if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
return -1;
}
ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count);
- if(skip_reserved(bc, end) || get_checksum(bc)){
+ if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
return -1;
}
}
}
- if(skip_reserved(bc, end) || get_checksum(bc)){
+ if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
goto fail;
}
s->data_offset= pos-8;
- if(!url_is_streamed(bc)){
+ if(bc->seekable){
int64_t orig_pos= avio_tell(bc);
find_and_decode_index(nut);
avio_seek(bc, orig_pos, SEEK_SET);
(void **) next_node);
av_log(s, AV_LOG_DEBUG, "%"PRIu64"-%"PRIu64" %"PRId64"-%"PRId64"\n", next_node[0]->pos, next_node[1]->pos,
next_node[0]->ts , next_node[1]->ts);
- pos= av_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos,
- next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
+ pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos,
+ next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
if(!(flags & AVSEEK_FLAG_BACKWARD)){
dummy.pos= pos+16;
next_node[1]= &nopts_sp;
av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
(void **) next_node);
- pos2= av_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos,
- next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
+ pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos,
+ next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
if(pos2>=0)
pos= pos2;
//FIXME dir but I think it does not matter
#if CONFIG_NUT_DEMUXER
AVInputFormat ff_nut_demuxer = {
- "nut",
- NULL_IF_CONFIG_SMALL("NUT format"),
- sizeof(NUTContext),
- nut_probe,
- nut_read_header,
- nut_read_packet,
- nut_read_close,
- read_seek,
+ .name = "nut",
+ .long_name = NULL_IF_CONFIG_SMALL("NUT format"),
+ .priv_data_size = sizeof(NUTContext),
+ .read_probe = nut_probe,
+ .read_header = nut_read_header,
+ .read_packet = nut_read_packet,
+ .read_close = nut_read_close,
+ .read_seek = read_seek,
.extensions = "nut",
.codec_tag = (const AVCodecTag * const []) { ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 },
};