* Copyright (c) 2003 Alex Beregszaszi
* Copyright (c) 2004 Michael Niedermayer
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* Visit the official site at http://www.nut.hu/
#include <limits.h>
#include "avformat.h"
#include "mpegaudio.h"
-#include "avi.h"
+#include "riff.h"
+#include "adler32.h"
#undef NDEBUG
#include <assert.h>
{"Cover" , "PNG"},
};
-void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale);
-
static void update(NUTContext *nut, int stream_index, int64_t frame_start, int frame_type, int frame_code, int key_frame, int size, int64_t pts){
StreamContext *stream= &nut->stream[stream_index];
if (tmp&0x80)
val= (val<<7) + tmp - 0x80;
else{
-//av_log(NULL, AV_LOG_DEBUG, "get_v()= %lld\n", (val<<7) + tmp);
+//av_log(NULL, AV_LOG_DEBUG, "get_v()= %"PRId64"\n", (val<<7) + tmp);
return (val<<7) + tmp;
}
}
while(i--)
val = (val<<8) + get_byte(bc);
-//av_log(NULL, AV_LOG_DEBUG, "get_vb()= %lld\n", val);
+//av_log(NULL, AV_LOG_DEBUG, "get_vb()= %"PRId64"\n", val);
return val;
}
static inline uint64_t get_v_trace(ByteIOContext *bc, char *file, char *func, int line){
uint64_t v= get_v(bc);
- printf("get_v %5lld / %llX in %s %s:%d\n", v, v, file, func, line);
+ printf("get_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
return v;
}
static inline int64_t get_s_trace(ByteIOContext *bc, char *file, char *func, int line){
int64_t v= get_s(bc);
- printf("get_s %5lld / %llX in %s %s:%d\n", v, v, file, func, line);
+ printf("get_s %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
return v;
}
static inline uint64_t get_vb_trace(ByteIOContext *bc, char *file, char *func, int line){
uint64_t v= get_vb(bc);
- printf("get_vb %5lld / %llX in %s %s:%d\n", v, v, file, func, line);
+ printf("get_vb %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
return v;
}
#define get_v(bc) get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__)
size= get_v(bc);
- init_checksum(bc, calculate_checksum ? update_adler32 : NULL, 0);
+ init_checksum(bc, calculate_checksum ? av_adler32_update : NULL, 1);
nut->packet_start[2] = start;
nut->written_packet_size= size;
}
}
+static int64_t lsb2full(StreamContext *stream, int64_t lsb){
+ int64_t mask = (1<<stream->msb_timestamp_shift)-1;
+ int64_t delta= stream->last_pts - mask/2;
+ return ((lsb - delta)&mask) + delta;
+}
+
#ifdef CONFIG_MUXERS
static void put_v(ByteIOContext *bc, uint64_t val)
{
int i;
-//av_log(NULL, AV_LOG_DEBUG, "put_v()= %lld\n", val);
+//av_log(NULL, AV_LOG_DEBUG, "put_v()= %"PRId64"\n", val);
val &= 0x7FFFFFFFFFFFFFFFULL; // FIXME can only encode upto 63 bits currently
i= get_length(val);
#ifdef TRACE
static inline void put_v_trace(ByteIOContext *bc, uint64_t v, char *file, char *func, int line){
- printf("get_v %5lld / %llX in %s %s:%d\n", v, v, file, func, line);
+ printf("get_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
put_v(bc, v);
}
static inline void put_s_trace(ByteIOContext *bc, int64_t v, char *file, char *func, int line){
- printf("get_s %5lld / %llX in %s %s:%d\n", v, v, file, func, line);
+ printf("get_s %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
put_s(bc, v);
}
static inline void put_vb_trace(ByteIOContext *bc, uint64_t v, char *file, char *func, int line){
- printf("get_vb %5lld / %llX in %s %s:%d\n", v, v, file, func, line);
+ printf("get_vb %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line);
put_vb(bc, v);
}
put_v(bc, nut->written_packet_size); /* forward ptr */
if(calculate_checksum)
- init_checksum(bc, update_adler32, 0);
+ init_checksum(bc, av_adler32_update, 1);
return 0;
}
AVCodecContext *codec;
int i, j, tmp_time, tmp_flags,tmp_stream, tmp_mul, tmp_size, tmp_fields;
+ if (strcmp(s->filename, "./data/b-libav.nut")) {
+ av_log(s, AV_LOG_ERROR, " libavformat NUT is non-compliant and disabled\n");
+ return -1;
+ }
+
nut->avf= s;
nut->stream =
return 0;
}
-static int64_t lsb2full(StreamContext *stream, int64_t lsb){
- int64_t mask = (1<<stream->msb_timestamp_shift)-1;
- int64_t delta= stream->last_pts - mask/2;
- return ((lsb - delta)&mask) + delta;
-}
-
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
{
NUTContext *nut = s->priv_data;
if(frame_type==2){
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 pts:%lld fs:%lld\n", key_frame, frame_type, full_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), pts, frame_start);
+ 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 pts:%"PRId64" fs:%"PRId64"\n", key_frame, frame_type, full_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), pts, frame_start);
// av_log(s, AV_LOG_DEBUG, "%d %d %d\n", stream->lru_pts_delta[0], stream->lru_pts_delta[1], stream->lru_pts_delta[2]);
#endif
}
if(*key_frame_ret){
-// av_log(s, AV_LOG_DEBUG, "stream:%d start:%lld pts:%lld length:%lld\n",stream_id, frame_start, av_pts, frame_start - nut->stream[stream_id].last_sync_pos);
+// av_log(s, AV_LOG_DEBUG, "stream:%d start:%"PRId64" pts:%"PRId64" length:%"PRId64"\n",stream_id, frame_start, av_pts, frame_start - nut->stream[stream_id].last_sync_pos);
av_add_index_entry(
s->streams[stream_id],
frame_start,
pts,
+ 0,
frame_start - nut->stream[stream_id].last_sync_pos,
AVINDEX_KEYFRAME);
nut->stream[stream_id].last_sync_pos= frame_start;
size+= size_mul*get_v(bc);
#ifdef TRACE
-av_log(s, AV_LOG_DEBUG, "fs:%lld fc:%d ft:%d kf:%d pts:%lld size:%d mul:%d lsb:%d flags:%d delta:%d\n", frame_start, frame_code, frame_type, *key_frame_ret, pts, size, size_mul, size_lsb, flags, time_delta);
+av_log(s, AV_LOG_DEBUG, "fs:%"PRId64" fc:%d ft:%d kf:%d pts:%"PRId64" size:%d mul:%d lsb:%d flags:%d delta:%d\n", frame_start, frame_code, frame_type, *key_frame_ret, pts, size, size_mul, size_lsb, flags, time_delta);
#endif
if(frame_type==0 && url_ftell(bc) - nut->packet_start[2] + size > nut->max_distance){
for(i=1; i<8; i++)
tmp = (tmp<<8) + get_byte(bc);
}
-//av_log(s, AV_LOG_DEBUG, "before switch %llX at=%lld\n", tmp, pos);
+//av_log(s, AV_LOG_DEBUG, "before switch %"PRIX64" at=%"PRId64"\n", tmp, pos);
switch(tmp){
case MAIN_STARTCODE:
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 = {
+#ifdef CONFIG_NUT_DEMUXER
+AVInputFormat nut_demuxer = {
"nut",
"nut format",
sizeof(NUTContext),
nut_read_timestamp,
.extensions = "nut",
};
-
-#ifdef CONFIG_MUXERS
-static AVOutputFormat nut_oformat = {
+#endif
+#ifdef CONFIG_NUT_MUXER
+AVOutputFormat nut_muxer = {
"nut",
"nut format",
"video/x-nut",
sizeof(NUTContext),
#ifdef CONFIG_LIBVORBIS
CODEC_ID_VORBIS,
-#elif defined(CONFIG_MP3LAME)
+#elif defined(CONFIG_LIBMP3LAME)
CODEC_ID_MP3,
#else
CODEC_ID_MP2, /* AC3 needs liba52 decoder */
nut_write_trailer,
.flags = AVFMT_GLOBALHEADER,
};
-#endif //CONFIG_MUXERS
-
-int nut_init(void)
-{
- av_register_input_format(&nut_iformat);
-#ifdef CONFIG_MUXERS
- av_register_output_format(&nut_oformat);
-#endif //CONFIG_MUXERS
- return 0;
-}
+#endif