]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/img2.c
cosmetics: reindent
[ffmpeg] / libavformat / img2.c
index 770858406744131ed597cccc2255b77607c68e05..af17040fad1efb68d928aad4134a6ca9205c8285 100644 (file)
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
+#include "avstring.h"
 
 typedef struct {
     int img_first;
@@ -54,6 +55,8 @@ static const IdStrMap img_tags[] = {
     { CODEC_ID_GIF       , "gif"},
     { CODEC_ID_TARGA     , "tga"},
     { CODEC_ID_TIFF      , "tiff"},
+    { CODEC_ID_SGI       , "sgi"},
+    { CODEC_ID_PTX       , "ptx"},
     {0, NULL}
 };
 
@@ -154,7 +157,7 @@ static int find_image_range(int *pfirst_index, int *plast_index,
 
 static int image_probe(AVProbeData *p)
 {
-    if (av_str2id(img_tags, p->filename)) {
+    if (p->filename && av_str2id(img_tags, p->filename)) {
         if (av_filename_number_test(p->filename))
             return AVPROBE_SCORE_MAX;
         else
@@ -177,10 +180,10 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
 
     st = av_new_stream(s1, 0);
     if (!st) {
-        return -ENOMEM;
+        return AVERROR(ENOMEM);
     }
 
-    pstrcpy(s->path, sizeof(s->path), s1->filename);
+    av_strlcpy(s->path, s1->filename, sizeof(s->path));
     s->img_number = 0;
     s->img_count = 0;
 
@@ -189,7 +192,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
         s->is_pipe = 0;
     else{
         s->is_pipe = 1;
-        st->need_parsing= 1;
+        st->need_parsing = AVSTREAM_PARSE_FULL;
     }
 
     if (!ap->time_base.num) {
@@ -205,7 +208,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
 
     if (!s->is_pipe) {
         if (find_image_range(&first_index, &last_index, s->path) < 0)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         s->img_first = first_index;
         s->img_last = last_index;
         s->img_number = first_index;
@@ -246,10 +249,10 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
         }
         if (av_get_frame_filename(filename, sizeof(filename),
                                   s->path, s->img_number)<0 && s->img_number > 1)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         for(i=0; i<3; i++){
             if (url_fopen(f[i], filename, URL_RDONLY) < 0)
-                return AVERROR_IO;
+                return AVERROR(EIO);
             size[i]= url_fsize(f[i]);
 
             if(codec->codec_id != CODEC_ID_RAWVIDEO)
@@ -262,7 +265,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
     } else {
         f[0] = &s1->pb;
         if (url_feof(f[0]))
-            return AVERROR_IO;
+            return AVERROR(EIO);
         size[0]= 4096;
     }
 
@@ -283,7 +286,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
 
     if (ret[0] <= 0 || ret[1]<0 || ret[2]<0) {
         av_free_packet(pkt);
-        return AVERROR_IO; /* signal EOF */
+        return AVERROR(EIO); /* signal EOF */
     } else {
         s->img_count++;
         s->img_number++;
@@ -305,7 +308,7 @@ static int img_write_header(AVFormatContext *s)
     VideoData *img = s->priv_data;
 
     img->img_number = 1;
-    pstrcpy(img->path, sizeof(img->path), s->filename);
+    av_strlcpy(img->path, s->filename, sizeof(img->path));
 
     /* find format */
     if (s->oformat->flags & AVFMT_NOFILE)
@@ -327,10 +330,10 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (!img->is_pipe) {
         if (av_get_frame_filename(filename, sizeof(filename),
                                   img->path, img->img_number) < 0 && img->img_number>1)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         for(i=0; i<3; i++){
             if (url_fopen(pb[i], filename, URL_WRONLY) < 0)
-                return AVERROR_IO;
+                return AVERROR(EIO);
 
             if(codec->codec_id != CODEC_ID_RAWVIDEO)
                 break;