-static int get_bi(ByteIOContext *bc)
-{
- int i, len, val = 0;
-
- len = get_v(bc);
- for (i = 0; i < len && i <= 4; i++)
- val |= get_byte(bc) << (i * 8);
- /* skip remaining bytes */
- url_fskip(bc, len-i);
-
- return val;
-}
-
-static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int prefix_length)
-{
- int64_t start, size, last_size;
- start= url_ftell(bc) - prefix_length;
-
- if(start != nut->packet_start + nut->written_packet_size){
- av_log(nut->avf, AV_LOG_ERROR, "get_packetheader called at weird position\n");
- return -1;
- }
-
- size= get_v(bc);
- last_size= get_v(bc);
- if(nut->written_packet_size != last_size){
- av_log(nut->avf, AV_LOG_ERROR, "packet size missmatch %d != %lld at %lld\n", nut->written_packet_size, last_size, start);
- return -1;
- }
-
- nut->last_packet_start = nut->packet_start;
- nut->packet_start = start;
- nut->written_packet_size= size;
-
- return size;
-}
-
-/**
- *
- */
-static int get_length(uint64_t val){
- int i;
-
- for (i=7; ; i+=7)
- if ((val>>i) == 0)
- return i;
-
- return 7; //not reached
-}
-
-#ifdef CONFIG_ENCODERS
-static int put_v(ByteIOContext *bc, uint64_t val)
-{
- int i;
-// if (bytes_left(s)*8 < 9)
-// return -1;
-
- if (bytes_left(bc) < 1)
- return -1;
-
- val &= 0x7FFFFFFFFFFFFFFFULL; // FIXME can only encode upto 63 bits currently
- i= get_length(val);
-
- for (i-=7; i>0; i-=7){
- put_byte(bc, 0x80 | (val>>i));
- }
-
- put_byte(bc, val&0x7f);
-
- return 0;
-}
-
-static int put_b(ByteIOContext *bc, char *data, int len)
-{
- int i;
-
- put_v(bc, len);
- for (i = 0; i < len; i++)
- put_byte(bc, data[i]);
-
- return 0;
-}
-
-static int put_bi(ByteIOContext *bc, int val)
-{
- put_v(bc, 4);
- put_le32(bc, val);
- return 0;
-}
-
-static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size)
-{
- put_flush_packet(bc);
- nut->last_packet_start= nut->packet_start;
- nut->packet_start+= nut->written_packet_size;
- nut->packet_size_pos = url_ftell(bc);
- nut->written_packet_size = max_size;
-
- /* packet header */
- put_v(bc, nut->written_packet_size); /* forward ptr */
- put_v(bc, nut->packet_start - nut->last_packet_start); /* backward ptr */
-
- return 0;
-}
-
-static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size){
- int64_t start= nut->packet_start;
- int64_t cur= url_ftell(bc);
- int size= cur - start + additional_size;
-
- if(size != nut->written_packet_size){
- int i;
-
- assert( size <= nut->written_packet_size );
-
- url_fseek(bc, nut->packet_size_pos, SEEK_SET);
- for(i=get_length(size); i < get_length(nut->written_packet_size); i+=7)
- put_byte(bc, 0x80);
- put_v(bc, size);
-
- url_fseek(bc, cur, SEEK_SET);
- nut->written_packet_size= size; //FIXME may fail if multiple updates with differing sizes, as get_length may differ
- }
-
- return 0;
-}
-
-static int nut_write_header(AVFormatContext *s)
-{
- NUTContext *nut = s->priv_data;
- ByteIOContext *bc = &s->pb;
- AVCodecContext *codec;
- int i, j;
-
- nut->avf= s;
-
- nut->stream =
- av_mallocz(sizeof(StreamContext)*s->nb_streams);
-
- av_set_pts_info(s, 60, 1, AV_TIME_BASE);
-
- /* main header */
- put_be64(bc, MAIN_STARTCODE);
- put_packetheader(nut, bc, 120+5*256);
- put_v(bc, 1); /* version */
- put_v(bc, s->nb_streams);
- put_v(bc, 3); /* checksum threshold */
-
- build_frame_code(s);
- assert(nut->frame_code['N'].flags == 1);
- for(i=0; i<256;){
- int tmp_flags = nut->frame_code[i].flags;
- int tmp_stream= nut->frame_code[i].stream_id_plus1;
- int tmp_mul = nut->frame_code[i].size_mul;
- int tmp_size = nut->frame_code[i].size_lsb;
- put_v(bc, tmp_flags);
- put_v(bc, tmp_stream);
- put_v(bc, tmp_mul);
- put_v(bc, tmp_size);
-
- for(j=0; i<256; j++,i++){
- if(nut->frame_code[i].flags != tmp_flags ) break;
- if(nut->frame_code[i].stream_id_plus1 != tmp_stream) break;
- if(nut->frame_code[i].size_mul != tmp_mul ) break;
- if(nut->frame_code[i].size_lsb != tmp_size ) break;
- if(++tmp_size >= tmp_mul){
- tmp_size=0;
- tmp_stream++;
- }
- }
- put_v(bc, j);
- }
-
- put_be32(bc, 0); /* FIXME: checksum */
-
- update_packetheader(nut, bc, 0);
-
- /* stream headers */
- for (i = 0; i < s->nb_streams; i++)
- {
- int nom, denom, gcd;
-
- codec = &s->streams[i]->codec;
-
- put_be64(bc, STREAM_STARTCODE);
- put_packetheader(nut, bc, 120);
- put_v(bc, i /*s->streams[i]->index*/);
- put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);
- if (codec->codec_tag)
- put_bi(bc, codec->codec_tag);
- else if (codec->codec_type == CODEC_TYPE_VIDEO)
- {
- int tmp = codec_get_bmp_tag(codec->codec_id);
- put_bi(bc, tmp);
- }
- else if (codec->codec_type == CODEC_TYPE_AUDIO)
- {
- int tmp = codec_get_wav_tag(codec->codec_id);
- put_bi(bc, tmp);
- }
-
- if (codec->codec_type == CODEC_TYPE_VIDEO)
- {
- nom = codec->frame_rate;
- denom = codec->frame_rate_base;
- }
- else
- {
- nom = codec->sample_rate;
- if(codec->frame_size>0)
- denom= codec->frame_size;
- else
- denom= 1; //unlucky
- }
- gcd= ff_gcd(nom, denom);
- nom /= gcd;
- denom /= gcd;
- nut->stream[i].rate_num= nom;
- nut->stream[i].rate_den= denom;
-
- put_v(bc, codec->bit_rate);
- put_v(bc, 0); /* no language code */
- put_v(bc, nom);
- put_v(bc, denom);
- if(nom / denom < 1000)
- nut->stream[i].msb_timestamp_shift = 7;
- else
- nut->stream[i].msb_timestamp_shift = 14;
- put_v(bc, nut->stream[i].msb_timestamp_shift);
- for(j=0; j<3; j++)
- put_v(bc, nut->stream[i].initial_pts_predictor[j]);
- for(j=0; j<2; j++)
- put_v(bc, nut->stream[i].initial_size_predictor[j]);
- put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
-
- if(codec->extradata_size){
- put_v(bc, 1);
- put_v(bc, codec->extradata_size);
- put_buffer(bc, codec->extradata, codec->extradata_size);
- }
- put_v(bc, 0); /* end of codec specific headers */
-
- switch(codec->codec_type)
- {
- case CODEC_TYPE_AUDIO:
- put_v(bc, (codec->sample_rate * denom) / nom);
- put_v(bc, codec->channels);
- break;
- case CODEC_TYPE_VIDEO:
- put_v(bc, codec->width);
- put_v(bc, codec->height);
- put_v(bc, codec->sample_aspect_ratio.num);
- put_v(bc, codec->sample_aspect_ratio.den);
- put_v(bc, 0); /* csp type -- unknown */
- break;
- default:
- break;
- }
- put_be32(bc, 0); /* FIXME: checksum */
- update_packetheader(nut, bc, 0);
- }
-
-#if 0
- /* info header */
- put_be64(bc, INFO_STARTCODE);
- put_packetheader(nut, bc, 16+strlen(s->author)+strlen(s->title)+
- strlen(s->comment)+strlen(s->copyright));
- if (s->author[0])
- {
- put_v(bc, 5); /* type */
- put_b(bc, s->author, strlen(s->author));
- }
- if (s->title[0])
- {
- put_v(bc, 6); /* type */
- put_b(bc, s->title, strlen(s->title));
- }
- if (s->comment[0])
- {
- put_v(bc, 7); /* type */
- put_b(bc, s->comment, strlen(s->comment));
- }
- if (s->copyright[0])
- {
- put_v(bc, 8); /* type */
- put_b(bc, s->copyright, strlen(s->copyright));
- }
- /* encoder */
- put_v(bc, 9); /* type */
- put_b(bc, LIBAVFORMAT_IDENT "\0", strlen(LIBAVFORMAT_IDENT));
-
- put_v(bc, 0); /* eof info */
-
- put_be32(bc, 0); /* FIXME: checksum */
- update_packetheader(nut, bc, 0);
-#endif
-
- put_flush_packet(bc);
-
- return 0;
-}
-
-static int nut_write_packet(AVFormatContext *s, int stream_index,
- const uint8_t *buf, int size, int64_t pts)
-{
- NUTContext *nut = s->priv_data;
- StreamContext *stream= &nut->stream[stream_index];
- ByteIOContext *bc = &s->pb;
- int key_frame = 0, full_pts=0;
- AVCodecContext *enc;
- int64_t lsb_pts, delta_pts;
- int frame_type, best_length, frame_code, flags, i, size_mul, size_lsb;
- const int64_t frame_start= url_ftell(bc);
-
- if (stream_index > s->nb_streams)
- return 1;
-
- pts= (av_rescale(pts, stream->rate_num, stream->rate_den) + AV_TIME_BASE/2) / AV_TIME_BASE;
-
- enc = &s->streams[stream_index]->codec;
- key_frame = enc->coded_frame->key_frame;
- delta_pts= pts - stream->last_pts;
-
- frame_type=0;
- if(frame_start + size + 20 - FFMAX(nut->last_frame_start[1], nut->last_frame_start[2]) > MAX_TYPE1_DISTANCE)
- frame_type=1;
- if(key_frame){
- if(frame_type==1 && frame_start + size - nut->last_frame_start[2] > MAX_TYPE2_DISTANCE)
- frame_type=2;
- if(!stream->last_key_frame)
- frame_type=2;
- }
-
- if(frame_type>0){
- update_packetheader(nut, bc, 0);
- reset(s);
- full_pts=1;
- }
- //FIXME ensure that the timestamp can be represented by either delta or lsb or full_pts=1
-
- lsb_pts = pts & ((1 << stream->msb_timestamp_shift)-1);
-
- best_length=INT_MAX;
- frame_code= -1;
- for(i=0; i<256; i++){
- int stream_id_plus1= nut->frame_code[i].stream_id_plus1;
- int fc_key_frame= stream->last_key_frame;
- int length=0;
- size_mul= nut->frame_code[i].size_mul;
- size_lsb= nut->frame_code[i].size_lsb;
- flags= nut->frame_code[i].flags;
-
- if(stream_id_plus1 == 0) length+= get_length(stream_index);
- else if(stream_id_plus1 - 1 != stream_index)
- continue;
- if(flags & FLAG_PRED_KEY_FRAME){
- if(flags & FLAG_KEY_FRAME)
- fc_key_frame= !fc_key_frame;
- }else{
- fc_key_frame= !!(flags & FLAG_KEY_FRAME);
- }
- assert(key_frame==0 || key_frame==1);
- if(fc_key_frame != key_frame)
- continue;
-
- if((!!(flags & FLAG_FRAME_TYPE)) != (frame_type > 0))
- continue;
-
- if(size_mul <= size_lsb){
- int p= stream->lru_size[size_lsb - size_mul];
- if(p != size)
- continue;
- }else{
- if(size % size_mul != size_lsb)
- continue;
- if(flags & FLAG_DATA_SIZE)
- length += get_length(size / size_mul);
- else if(size/size_mul)
- continue;
- }
-
- if(full_pts != ((flags & FLAG_PTS) && (flags & FLAG_FULL_PTS)))
- continue;
-
- if(flags&FLAG_PTS){
- if(flags&FLAG_FULL_PTS){
- length += get_length(pts);
- }else{
- length += get_length(lsb_pts);
- }
- }else{
- int delta= stream->lru_pts_delta[(flags & 12)>>2];
- if(delta != pts - stream->last_pts)
- continue;
- assert(frame_type == 0);
- }
-
- if(length < best_length){
- best_length= length;
- frame_code=i;
- }
-// av_log(s, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d %d %d\n", key_frame, frame_type, full_pts, size, stream_index, flags, size_mul, size_lsb, stream_id_plus1, length);
- }
-
- assert(frame_code != -1);
- flags= nut->frame_code[frame_code].flags;
- size_mul= nut->frame_code[frame_code].size_mul;
- size_lsb= nut->frame_code[frame_code].size_lsb;
-#if 0
- best_length /= 7;
- best_length ++; //frame_code
- if(frame_type>0){
- best_length += 4; //packet header
- if(frame_type>1)
- best_length += 8; // startcode
- }
- av_log(s, AV_LOG_DEBUG, "kf:%d ft:%d pt:%d fc:%2X len:%2d size:%d stream:%d flag:%d mul:%d lsb:%d s+1:%d pts_delta:%d\n", key_frame, frame_type, full_pts ? 2 : ((flags & FLAG_PTS) ? 1 : 0), frame_code, best_length, size, stream_index, flags, size_mul, size_lsb, nut->frame_code[frame_code].stream_id_plus1,(int)(pts - stream->last_pts));
-#endif
-
- if (frame_type==2)
- put_be64(bc, KEYFRAME_STARTCODE);
- put_byte(bc, frame_code);
-
- if(frame_type>0)
- put_packetheader(nut, bc, FFMAX(size+20, MAX_TYPE1_DISTANCE));
- if(nut->frame_code[frame_code].stream_id_plus1 == 0)
- put_v(bc, stream_index);
- if (flags & FLAG_PTS){
- if (flags & FLAG_FULL_PTS)
- put_v(bc, pts);
- else
- put_v(bc, lsb_pts);
- }
- if(flags & FLAG_DATA_SIZE)
- put_v(bc, size / size_mul);
- if(size > MAX_TYPE1_DISTANCE){
- assert(frame_type > 0);
- update_packetheader(nut, bc, size);
- }
-
- put_buffer(bc, buf, size);
-
- update(nut, stream_index, frame_start, frame_type, frame_code, key_frame, size, pts);
-
- return 0;
-}
-
-static int nut_write_trailer(AVFormatContext *s)
-{
- NUTContext *nut = s->priv_data;
- ByteIOContext *bc = &s->pb;
-
- update_packetheader(nut, bc, 0);
-
-#if 0
- int i;
-
- /* WRITE INDEX */
-
- for (i = 0; s->nb_streams; i++)
- {
- put_be64(bc, INDEX_STARTCODE);
- put_packetheader(nut, bc, 64);
- put_v(bc, s->streams[i]->id);
- put_v(bc, ...);
- put_be32(bc, 0); /* FIXME: checksum */
- update_packetheader(nut, bc, 0);
- }
-#endif
-
- put_flush_packet(bc);
-
- av_freep(&nut->stream);
-
- return 0;
-}
-#endif //CONFIG_ENCODERS
-
-static int nut_probe(AVProbeData *p)
-{
- int i;
- uint64_t code;
-
- code = 0xff;
- for (i = 0; i < p->buf_size; i++) {
- int c = p->buf[i];
- code = (code << 8) | c;
- if (code == MAIN_STARTCODE)
- return AVPROBE_SCORE_MAX;
- }
- return 0;
-}
-
-static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
-{
- NUTContext *nut = s->priv_data;
- ByteIOContext *bc = &s->pb;
- uint64_t tmp;
- int cur_stream, nb_streams, i, j;
-
- nut->avf= s;
-
- av_set_pts_info(s, 60, 1, AV_TIME_BASE);
-
- /* main header */
- tmp = get_be64(bc);
- if (tmp != MAIN_STARTCODE)
- av_log(s, AV_LOG_ERROR, "damaged? startcode!=1 (%Ld)\n", tmp);
- get_packetheader(nut, bc, 8);
-
- tmp = get_v(bc);
- if (tmp != 1)
- av_log(s, AV_LOG_ERROR, "bad version (%Ld)\n", tmp);
-
- nb_streams = get_v(bc);
- get_v(bc); //checksum threshold
-
- for(i=0; i<256;){
- int tmp_flags = get_v(bc);
- int tmp_stream= get_v(bc);
- int tmp_mul = get_v(bc);
- int tmp_size = get_v(bc);
- int count = get_v(bc);
-
- if(count == 0 || i+count > 256){
- av_log(s, AV_LOG_ERROR, "illegal count %d at %d\n", count, i);
- return -1;
- }
-
- if((tmp_flags & FLAG_FRAME_TYPE) && tmp_flags != 1){
- if(tmp_flags & FLAG_PRED_KEY_FRAME){
- av_log(s, AV_LOG_ERROR, "keyframe prediction in non 0 frame type\n");
- return -1;
- }
- if(!(tmp_flags & FLAG_PTS) || !(tmp_flags & FLAG_FULL_PTS) ){
- av_log(s, AV_LOG_ERROR, "no full pts in non 0 frame type\n");
- return -1;
- }
- }
-
- for(j=0; j<count; j++,i++){
- if(tmp_stream > nb_streams + 1){
- av_log(s, AV_LOG_ERROR, "illegal stream number\n");
- return -1;
- }
-
- nut->frame_code[i].flags = tmp_flags ;
- nut->frame_code[i].stream_id_plus1 = tmp_stream;
- nut->frame_code[i].size_mul = tmp_mul ;
- nut->frame_code[i].size_lsb = tmp_size ;
- if(++tmp_size >= tmp_mul){
- tmp_size=0;
- tmp_stream++;
- }
- }
- }
- if(nut->frame_code['N'].flags != 1){
- av_log(s, AV_LOG_ERROR, "illegal frame_code table\n");
- return -1;
- }
-
- get_be32(bc); /* checkusm */
-
- s->bit_rate = 0;
-
- nut->stream = av_malloc(sizeof(StreamContext)*nb_streams);
-
- /* stream header */
- for (cur_stream = 0; cur_stream < nb_streams; cur_stream++)
- {
- int class, nom, denom;
- AVStream *st;
-
- tmp = get_be64(bc);
- if (tmp != STREAM_STARTCODE)
- av_log(s, AV_LOG_ERROR, "damaged? startcode!=1 (%Ld)\n", tmp);
- get_packetheader(nut, bc, 8);
- st = av_new_stream(s, get_v(bc));
- if (!st)
- return AVERROR_NOMEM;
- class = get_v(bc);
- tmp = get_bi(bc);
- switch(class)
- {
- case 0:
- st->codec.codec_type = CODEC_TYPE_VIDEO;
- st->codec.codec_id = codec_get_bmp_id(tmp);
- if (st->codec.codec_id == CODEC_ID_NONE)
- av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
- break;
- case 32:
- st->codec.codec_type = CODEC_TYPE_AUDIO;
- st->codec.codec_id = codec_get_wav_id(tmp);
- if (st->codec.codec_id == CODEC_ID_NONE)
- av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
- break;
- default:
- av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class);
- return -1;
- }
- s->bit_rate += get_v(bc);
- get_b(bc, NULL, 0); /* language code */
- nom = get_v(bc);
- denom = get_v(bc);
- nut->stream[cur_stream].msb_timestamp_shift = get_v(bc);
- for(i=0; i<3; i++)
- nut->stream[cur_stream].initial_pts_predictor[i]= get_v(bc);
- for(i=0; i<2; i++)
- nut->stream[cur_stream].initial_size_predictor[i]= get_v(bc);
- get_byte(bc); /* flags */
-
- /* codec specific data headers */
- while(get_v(bc) != 0){
- st->codec.extradata_size= get_v(bc);
- st->codec.extradata= av_mallocz(st->codec.extradata_size);
- get_buffer(bc, st->codec.extradata, st->codec.extradata_size);
-// url_fskip(bc, get_v(bc));
- }
-
- if (class == 0) /* VIDEO */
- {
- st->codec.width = get_v(bc);
- st->codec.height = get_v(bc);
- st->codec.sample_aspect_ratio.num= get_v(bc);
- st->codec.sample_aspect_ratio.den= get_v(bc);
- get_v(bc); /* csp type */
-
- st->codec.frame_rate = nom;
- st->codec.frame_rate_base = denom;
- }
- if (class == 32) /* AUDIO */
- {
- st->codec.sample_rate = (get_v(bc) * nom) / denom;
- st->codec.channels = get_v(bc);
- }
- get_be32(bc); /* checksum */
- nut->stream[cur_stream].rate_num= nom;
- nut->stream[cur_stream].rate_den= denom;
- }
-
- return 0;
-}
-
-static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
- NUTContext *nut = s->priv_data;
- StreamContext *stream;
- ByteIOContext *bc = &s->pb;
- int size, frame_code, flags, size_mul, size_lsb, stream_id;
- int key_frame = 0;
- int frame_type= 0;
- int64_t pts = 0;
- const int64_t frame_start= url_ftell(bc);
-
- if (url_feof(bc))
- return -1;
-
- frame_code = get_byte(bc);
- if(frame_code == 'N'){
- uint64_t tmp= frame_code;
- tmp<<=8 ; tmp |= get_byte(bc);
- tmp<<=16; tmp |= get_be16(bc);
- tmp<<=32; tmp |= get_be32(bc);
- if (tmp == KEYFRAME_STARTCODE)
- {
- frame_code = get_byte(bc);
- frame_type = 2;
- }
- else
- av_log(s, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp);
- }
- flags= nut->frame_code[frame_code].flags;
- size_mul= nut->frame_code[frame_code].size_mul;
- size_lsb= nut->frame_code[frame_code].size_lsb;
- stream_id= nut->frame_code[frame_code].stream_id_plus1 - 1;
-
- if(flags & FLAG_FRAME_TYPE){
- reset(s);
- if(frame_type==2){
- get_packetheader(nut, bc, 8+1);
- }else{
- get_packetheader(nut, bc, 1);
- frame_type= 1;
- }
- }
-
- if(stream_id==-1)
- stream_id= get_v(bc);
- if(stream_id >= s->nb_streams){
- av_log(s, AV_LOG_ERROR, "illegal stream_id\n");
- return -1;
- }
- stream= &nut->stream[stream_id];
-
- if(flags & FLAG_PRED_KEY_FRAME){
- if(flags & FLAG_KEY_FRAME)
- key_frame= !stream->last_key_frame;
- else
- key_frame= stream->last_key_frame;
- }else{
- key_frame= !!(flags & FLAG_KEY_FRAME);
- }
-
- if(flags & FLAG_PTS){
- if(flags & FLAG_FULL_PTS){
- pts= get_v(bc);
- }else{
- int64_t mask = (1<<stream->msb_timestamp_shift)-1;
- int64_t delta= stream->last_pts - mask/2;
- pts= ((get_v(bc) - delta)&mask) + delta;
- }
- }else{
- pts= stream->last_pts + stream->lru_pts_delta[(flags&12)>>2];
- }
-
- if(size_mul <= size_lsb){
- size= stream->lru_size[size_lsb - size_mul];
- }else{
- if(flags & FLAG_DATA_SIZE)
- size= size_mul*get_v(bc) + size_lsb;
- else
- size= size_lsb;
- }
-
-//av_log(s, AV_LOG_DEBUG, "fs:%lld fc:%d ft:%d kf:%d pts:%lld\n", frame_start, frame_code, frame_type, key_frame, pts);
-
- av_new_packet(pkt, size);
- get_buffer(bc, pkt->data, size);
- pkt->stream_index = stream_id;
- if (key_frame)
- pkt->flags |= PKT_FLAG_KEY;
- pkt->pts = pts * AV_TIME_BASE * stream->rate_den / stream->rate_num;
-
- update(nut, stream_id, frame_start, frame_type, frame_code, key_frame, size, pts);
-
- return 0;
-}
-
-static int nut_read_close(AVFormatContext *s)
-{
- NUTContext *nut = s->priv_data;
- int i;
-
- for(i=0;i<s->nb_streams;i++) {
- av_freep(&s->streams[i]->codec.extradata);
- }
- av_freep(&nut->stream);
-
- return 0;
-}
-
-static AVInputFormat nut_iformat = {
- "nut",
- "nut format",
- sizeof(NUTContext),
- nut_probe,
- nut_read_header,
- nut_read_packet,
- nut_read_close,
-// nut_read_seek,
- .extensions = "nut",
-};
-
-#ifdef CONFIG_ENCODERS
-static AVOutputFormat nut_oformat = {
- "nut",
- "nut format",
- "video/x-nut",
- "nut",
- sizeof(NUTContext),
-#if 0 //#ifdef CONFIG_VORBIS
- CODEC_ID_VORBIS,
-#elif defined(CONFIG_MP3LAME)
- CODEC_ID_MP3,
-#else
- CODEC_ID_MP2, /* AC3 needs liba52 decoder */
-#endif
- CODEC_ID_MPEG4,
- nut_write_header,
- nut_write_packet,
- nut_write_trailer,
-};
-#endif //CONFIG_ENCODERS