]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/bktr.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavdevice / bktr.c
index 6e19a611036cec425b1f8a09d26bf9a068ce9689..2792fcf07fcca7b5b01752f6d93ccdb2c47fb101 100644 (file)
@@ -7,24 +7,23 @@
  * and
  *           simple_grab.c Copyright (c) 1999 Roger Hardiman
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * 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.1 of the License, or (at your option) any later version.
  *
- * Libav 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 Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavformat/avformat.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
@@ -48,6 +47,7 @@
 #include <signal.h>
 #include <stdint.h>
 #include <strings.h>
+#include "avdevice.h"
 
 typedef struct {
     AVClass *class;
@@ -248,22 +248,11 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     VideoData *s = s1->priv_data;
     AVStream *st;
     int width, height;
-    AVRational fps;
+    AVRational framerate;
     int ret = 0;
 
-#if FF_API_FORMAT_PARAMETERS
-    if (ap->standard) {
-        if (!strcasecmp(ap->standard, "pal"))
-            s->standard = PAL;
-        else if (!strcasecmp(ap->standard, "secam"))
-            s->standard = SECAM;
-        else if (!strcasecmp(ap->standard, "ntsc"))
-            s->standard = NTSC;
-    }
-#endif
-
     if ((ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
-        av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n");
+        av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n", s->video_size);
         goto out;
     }
 
@@ -277,18 +266,10 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
             ret = AVERROR(EINVAL);
             goto out;
         }
-    if ((ret = av_parse_video_rate(&fps, s->framerate)) < 0) {
-        av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n");
+    if ((ret = av_parse_video_rate(&framerate, s->framerate)) < 0) {
+        av_log(s1, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", s->framerate);
         goto out;
     }
-#if FF_API_FORMAT_PARAMETERS
-    if (ap->width > 0)
-        width = ap->width;
-    if (ap->height > 0)
-        height = ap->height;
-    if (ap->time_base.num)
-        fps = (AVRational){ap->time_base.den, ap->time_base.num};
-#endif
 
     st = av_new_stream(s1, 0);
     if (!st) {
@@ -299,15 +280,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
 
     s->width = width;
     s->height = height;
-    s->per_frame = ((uint64_t)1000000 * fps.den) / fps.num;
+    s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num;
 
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->pix_fmt = PIX_FMT_YUV420P;
     st->codec->codec_id = CODEC_ID_RAWVIDEO;
     st->codec->width = width;
     st->codec->height = height;
-    st->codec->time_base.den = fps.num;
-    st->codec->time_base.num = fps.den;
+    st->codec->time_base.den = framerate.num;
+    st->codec->time_base.num = framerate.den;
 
 
     if (bktr_init(s1->filename, width, height, s->standard,
@@ -320,8 +301,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     last_frame_time = 0;
 
 out:
-    av_freep(&s->video_size);
-    av_freep(&s->framerate);
     return ret;
 }