]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/libnut.c
better warning
[ffmpeg] / libavformat / libnut.c
index 64cf89d3e901969f9717bd41c338a7491fdcdd15..d4e7201ab91f4c3155c976ee6e8d1000868f0be8 100644 (file)
@@ -11,41 +11,13 @@ typedef struct {
 } NUTContext;
 
 static const CodecTag nut_tags[] = {
-    { CODEC_ID_MPEG4,  MKTAG('m', 'p', '4', 's') },
+    { CODEC_ID_MPEG4,  MKTAG('m', 'p', '4', 'v') },
     { CODEC_ID_MP3,    MKTAG('m', 'p', '3', ' ') },
     { CODEC_ID_VORBIS, MKTAG('v', 'r', 'b', 's') },
     { 0, 0 },
 };
 
 #ifdef CONFIG_MUXERS
-frame_table_input_t ft_default[] = {
-    // There must be atleast this safety net:
-    //{ 4128,      3,   0,   1,      0,    0,     0 },
-    //{ flag, fields, pts, mul, stream, size, count }
-      { 8192,      0,   0,   1,      0,    0,     0 }, // invalid 0x00
-      {   56,      0,   0,   1,      0,    0,     0 }, // safety net non key frame
-      {   56,      0,   0,   1,      0,    0,     0 }, // safety net key frame
-      { 4128,      0,   0,   1,      0,    0,     0 }, // one more safety net
-      {   27,      0,   0,   1,      0,    0,     0 }, // EOR frame
-      {    1,      4,   1, 337,      1,  336,     0 }, // used 82427 times
-      {    1,      4,   1, 385,      1,  384,     0 }, // used 56044 times
-      {    0,      4,   2,   7,      0,    6,     0 }, // used 20993 times
-      {    0,      4,   1,   7,      0,    6,     0 }, // used 10398 times
-      {    1,      4,   1, 481,      1,  480,     0 }, // used 3527 times
-      {    1,      4,   1, 289,      1,  288,     0 }, // used 2042 times
-      {    1,      4,   1, 577,      1,  576,     0 }, // used 1480 times
-      {    1,      4,   1, 673,      1,  672,     0 }, // used 862 times
-      {    1,      4,   1, 769,      1,  768,     0 }, // used 433 times
-      {    1,      4,   1, 961,      1,  960,     0 }, // used 191 times
-      {   32,      3,   2, 101,      0,    0,     0 }, // "1.2.0" => 14187
-      {   32,      3,  -1,  40,      0,    0,     0 }, // "1.-1.0" => 5707
-      {   32,      3,   1,  81,      0,    0,     0 }, // "1.1.0" => 11159
-      {   33,      3,   1,  11,      0,    0,     0 }, // "1.1.1" => 1409
-      {  105,      3,   0,   6,      0,    0,     0 }, // checksum for video
-      { 8192,      2,   0,   1,      0,    0,     0 }, // invalid 0xFF
-      {   -1,      0,   0,   0,      0,    0,     0 }, // end
-};
-
 static int av_write(void * h, size_t len, const uint8_t * buf) {
     ByteIOContext * bc = h;
     put_buffer(bc, buf, len);
@@ -65,7 +37,7 @@ static int nut_write_header(AVFormatContext * avf) {
         .write_index = 1,
         .realtime_stream = 0,
         .max_distance = 32768,
-        .fti = ft_default
+        .fti = NULL,
     };
     nut_stream_header_t * s;
     int i;
@@ -198,14 +170,15 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
             .file_pos = 0,
         },
         .alloc = { av_malloc, av_realloc, av_free },
-        .read_index = 1
+        .read_index = 1,
+        .cache_syncpoints = 1,
     };
     nut_context_t * nut = priv->nut = nut_demuxer_init(&dopts);
     nut_stream_header_t * s;
     int ret, i;
 
     if ((ret = nut_read_headers(nut, &s, NULL))) {
-        if (ret < 0) av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret));
+        av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(ret));
         nut_demuxer_uninit(nut);
         return -1;
     }
@@ -261,10 +234,13 @@ static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) {
     nut_packet_t pd;
     int ret;
 
-    while ((ret = nut_read_next_packet(priv->nut, &pd)) < 0)
-        av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret));
+    ret = nut_read_next_packet(priv->nut, &pd);
 
-    if (ret || av_new_packet(pkt, pd.len) < 0) return -1;
+    if (ret || av_new_packet(pkt, pd.len) < 0) {
+        if (ret != NUT_ERR_EOF)
+            av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(ret));
+        return -1;
+    }
 
     if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY;
     pkt->pts = pd.pts;
@@ -290,7 +266,6 @@ static int nut_read_close(AVFormatContext *s) {
     NUTContext * priv = s->priv_data;
 
     nut_demuxer_uninit(priv->nut);
-    av_free(priv->s);
 
     return 0;
 }