]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/nut.c
bring back h264 build
[ffmpeg] / libavformat / nut.c
index 09bd12082d3c115cff0977b61836c72db9d33a1c..31114c5f6ebc9aaf3087680fa7fb9c4e2d5c5400 100644 (file)
@@ -3,23 +3,23 @@
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2004 Michael Niedermayer
  *
- * This library is free software; you can redistribute it and/or
+ * Visit the official site at http://www.nut-container.org/.
+ *
+ * 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
+ * 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/
- *
  */
 
 /*
@@ -33,7 +33,8 @@
 #include <limits.h>
 #include "avformat.h"
 #include "mpegaudio.h"
-#include "avi.h"
+#include "riff.h"
+#include "adler32.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -82,7 +83,7 @@ typedef struct {
     int64_t packet_start[3]; //0-> startcode less, 1-> short startcode 2-> long startcodes
     FrameCode frame_code[256];
     unsigned int stream_count;
-    uint64_t next_startcode;     ///< stores the next startcode if it has alraedy been parsed but the stream isnt seekable
+    uint64_t next_startcode;     ///< stores the next startcode if it has already been parsed but the stream is not seekable
     StreamContext *stream;
     int max_distance;
     int max_short_distance;
@@ -111,8 +112,6 @@ static char *info_table[][2]={
         {"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];
 
@@ -249,7 +248,7 @@ static uint64_t get_v(ByteIOContext *bc)
         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;
         }
     }
@@ -292,7 +291,7 @@ static uint64_t get_vb(ByteIOContext *bc){
     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;
 }
 
@@ -300,21 +299,21 @@ static uint64_t get_vb(ByteIOContext *bc){
 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__)
@@ -330,7 +329,7 @@ static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_ch
 
     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;
@@ -358,7 +357,7 @@ static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){
     uint64_t state=0;
 
     if(pos >= 0)
-        url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream isnt seekable, but that shouldnt matter, as in this case we simply start where we are currently
+        url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we are currently
 
     while(!url_feof(bc)){
         state= (state<<8) | get_byte(bc);
@@ -406,7 +405,7 @@ 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);
 
@@ -444,19 +443,19 @@ static void put_vb(ByteIOContext *bc, uint64_t 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);
 }
@@ -475,7 +474,7 @@ static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size, in
     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;
 }
@@ -795,7 +794,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
     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
 
@@ -1192,7 +1191,7 @@ static int decode_frame_header(NUTContext *nut, int *key_frame_ret, int64_t *pts
     }
 
     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,
@@ -1210,7 +1209,7 @@ static int decode_frame_header(NUTContext *nut, int *key_frame_ret, int64_t *pts
         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){
@@ -1357,7 +1356,7 @@ av_log(s, AV_LOG_DEBUG, "read_timestamp(X,%d,%"PRId64",%"PRId64")\n", stream_ind
             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:
@@ -1442,7 +1441,7 @@ AVOutputFormat nut_muxer = {
     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 */