* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/intreadwrite.h"
#include "libavutil/tree.h"
#include "libavcodec/mpegaudiodata.h"
#include "nut.h"
int i;
//FIXME this is lame
//FIXME write a 2pass mode to find the maximal headers
- const static uint8_t headers[][5]={
+ static const uint8_t headers[][5]={
{3, 0x00, 0x00, 0x01},
{4, 0x00, 0x00, 0x01, 0xB6},
{2, 0xFF, 0xFA}, //mp3+crc
put_byte(bc, val&127);
}
-static void put_t(NUTContext *nut, StreamContext *nus, ByteIOContext *bc, uint64_t val){
+static void put_tt(NUTContext *nut, StreamContext *nus, ByteIOContext *bc, uint64_t val){
val *= nut->time_base_count;
val += nus->time_base - nut->time_base;
put_v(bc, val);
}
}
-static int write_streamheader(NUTContext *nut, ByteIOContext *bc, AVCodecContext *codec, int i){
+static int write_streamheader(NUTContext *nut, ByteIOContext *bc, AVStream *st, int i){
+ AVCodecContext *codec = st->codec;
put_v(bc, i);
switch(codec->codec_type){
case CODEC_TYPE_VIDEO: put_v(bc, 0); break;
put_v(bc, codec->width);
put_v(bc, codec->height);
- if(codec->sample_aspect_ratio.num<=0 || codec->sample_aspect_ratio.den<=0){
+ if(st->sample_aspect_ratio.num<=0 || st->sample_aspect_ratio.den<=0){
put_v(bc, 0);
put_v(bc, 0);
}else{
- put_v(bc, codec->sample_aspect_ratio.num);
- put_v(bc, codec->sample_aspect_ratio.den);
+ put_v(bc, st->sample_aspect_ratio.num);
+ put_v(bc, st->sample_aspect_ratio.den);
}
put_v(bc, 0); /* csp type -- unknown */
break;
static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){
AVFormatContext *s= nut->avf;
+ AVMetadataTag *title, *author, *copyright;
ByteIOContext *dyn_bc;
uint8_t *dyn_buf=NULL;
int count=0, dyn_size;
if(ret < 0)
return ret;
- if(s->title [0]) count+= add_info(dyn_bc, "Title" , s->title);
- if(s->author [0]) count+= add_info(dyn_bc, "Author" , s->author);
- if(s->copyright[0]) count+= add_info(dyn_bc, "Copyright", s->copyright);
+ title = av_metadata_get(s->metadata, "Title" , NULL, 0);
+ author = av_metadata_get(s->metadata, "Author" , NULL, 0);
+ copyright = av_metadata_get(s->metadata, "Copyright", NULL, 0);
+
+ if(title ) count+= add_info(dyn_bc, "Title" , title->value);
+ if(author ) count+= add_info(dyn_bc, "Author" , author->value);
+ if(copyright) count+= add_info(dyn_bc, "Copyright", copyright->value);
if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
count+= add_info(dyn_bc, "Encoder" , LIBAVFORMAT_IDENT);
put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE);
for (i=0; i < nut->avf->nb_streams; i++){
- AVCodecContext *codec = nut->avf->streams[i]->codec;
-
ret = url_open_dyn_buf(&dyn_bc);
if(ret < 0)
return ret;
- write_streamheader(nut, dyn_bc, codec, i);
+ write_streamheader(nut, dyn_bc, nut->avf->streams[i], i);
put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE);
}
//FIXME: Ensure store_sp is 1 in the first place.
if(store_sp){
- syncpoint_t *sp, dummy= {.pos= INT64_MAX};
+ Syncpoint *sp, dummy= {.pos= INT64_MAX};
ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
for(i=0; i<s->nb_streams; i++){
ret = url_open_dyn_buf(&dyn_bc);
if(ret < 0)
return ret;
- put_t(nut, nus, dyn_bc, pkt->dts);
+ put_tt(nut, nus, dyn_bc, pkt->dts);
put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);
put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
"video/x-nut",
"nut",
sizeof(NUTContext),
-#ifdef CONFIG_LIBVORBIS
+#if CONFIG_LIBVORBIS
CODEC_ID_VORBIS,
-#elif defined(CONFIG_LIBMP3LAME)
+#elif CONFIG_LIBMP3LAME
CODEC_ID_MP3,
#else
CODEC_ID_MP2,
write_header,
write_packet,
write_trailer,
- .flags = AVFMT_GLOBALHEADER,
- .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, ff_nut_subtitle_tags, 0},
+ .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
+ .codec_tag= (const AVCodecTag* const []){codec_bmp_tags, codec_wav_tags, ff_nut_subtitle_tags, 0},
};