* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/tree.h"
+#include "libavcodec/mpegaudiodata.h"
#include "nut.h"
-#include "tree.h"
-#include "mpegaudiodata.h"
static int find_expected_header(AVCodecContext *c, int size, int key_frame, uint8_t out[64]){
int sample_rate= c->sample_rate;
header |= 1<<16; //no crc
AV_WB32(out, header);
if(size <= 0)
- return 2; //we guess theres no crc, if there is one the user clearly doesnt care about overhead
+ return 2; //we guess there is no crc, if there is one the user clearly does not care about overhead
if(bitrate_index == 30)
return -1; //something is wrong ...
header |= (bitrate_index&1)<<9;
return 2; //FIXME actually put the needed ones in build_elision_headers()
- return 3; //we guess that the private bit isnt set
-//FIXME the above asumtations should be checked, if these turn out false too often something should be done
+ return 3; //we guess that the private bit is not set
+//FIXME the above assumptions should be checked, if these turn out false too often something should be done
}
return 0;
}
switch(codec->codec_type){
case CODEC_TYPE_VIDEO: put_v(bc, 0); break;
case CODEC_TYPE_AUDIO: put_v(bc, 1); break;
-// case CODEC_TYPE_TEXT : put_v(bc, 2); break;
+ case CODEC_TYPE_SUBTITLE: put_v(bc, 2); break;
default : put_v(bc, 3); break;
}
put_v(bc, 4);
return 0;
}
+static int write_streaminfo(NUTContext *nut, ByteIOContext *bc, int stream_id){
+ AVFormatContext *s= nut->avf;
+ AVStream* st = s->streams[stream_id];
+ ByteIOContext *dyn_bc;
+ uint8_t *dyn_buf=NULL;
+ int count=0, dyn_size, i;
+ int ret = url_open_dyn_buf(&dyn_bc);
+ if(ret < 0)
+ return ret;
+
+ for (i=0; ff_nut_dispositions[i].flag; ++i) {
+ if (st->disposition & ff_nut_dispositions[i].flag)
+ count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str);
+ }
+ dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf);
+
+ if (count) {
+ put_v(bc, stream_id + 1); //stream_id_plus1
+ put_v(bc, 0); //chapter_id
+ put_v(bc, 0); //timestamp_start
+ put_v(bc, 0); //length
+
+ put_v(bc, count);
+
+ put_buffer(bc, dyn_buf, dyn_size);
+ }
+
+ av_free(dyn_buf);
+ return count;
+}
+
static int write_headers(NUTContext *nut, ByteIOContext *bc){
ByteIOContext *dyn_bc;
int i, ret;
write_globalinfo(nut, dyn_bc);
put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
+ for (i = 0; i < nut->avf->nb_streams; i++) {
+ ret = url_open_dyn_buf(&dyn_bc);
+ if(ret < 0)
+ return ret;
+ ret = write_streaminfo(nut, dyn_bc, i);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
+ else {
+ uint8_t* buf;
+ url_close_dyn_buf(dyn_bc, &buf);
+ av_free(buf);
+ }
+ }
+
nut->last_syncpoint_pos= INT_MIN;
nut->header_count++;
return 0;
int store_sp=0;
int ret;
+ if(pkt->pts < 0)
+ return -1;
+
if(1LL<<(20+3*nut->header_count) <= url_ftell(bc))
write_headers(nut, bc);
put_buffer(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
nus->last_flags= flags;
+ nus->last_pts= pkt->pts;
//FIXME just store one per syncpoint
if(flags & FLAG_KEY)
AVOutputFormat nut_muxer = {
"nut",
- "nut format",
+ NULL_IF_CONFIG_SMALL("NUT format"),
"video/x-nut",
"nut",
sizeof(NUTContext),
write_packet,
write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0},
+ .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, ff_nut_subtitle_tags, 0},
};