Browse code

ffplay: use new avformat_open_* API. (cherry picked from commit 44e83d0c976dd098455173877fc22b57ed212bed)

Anton Khirnov authored on 2011/06/09 17:58:23
Showing 1 changed files
... ...
@@ -27,6 +27,7 @@
27 27
 #include "libavutil/colorspace.h"
28 28
 #include "libavutil/pixdesc.h"
29 29
 #include "libavutil/imgutils.h"
30
+#include "libavutil/dict.h"
30 31
 #include "libavutil/parseutils.h"
31 32
 #include "libavutil/samplefmt.h"
32 33
 #include "libavutil/avassert.h"
... ...
@@ -2295,15 +2296,13 @@ static int decode_interrupt_cb(void)
2295 2295
 static int read_thread(void *arg)
2296 2296
 {
2297 2297
     VideoState *is = arg;
2298
-    AVFormatContext *ic;
2298
+    AVFormatContext *ic = NULL;
2299 2299
     int err, i, ret;
2300 2300
     int st_index[AVMEDIA_TYPE_NB];
2301 2301
     AVPacket pkt1, *pkt = &pkt1;
2302
-    AVFormatParameters params, *ap = &params;
2303 2302
     int eof=0;
2304 2303
     int pkt_in_play_range = 0;
2305
-
2306
-    ic = avformat_alloc_context();
2304
+    AVDictionaryEntry *t;
2307 2305
 
2308 2306
     memset(st_index, -1, sizeof(st_index));
2309 2307
     is->video_stream = -1;
... ...
@@ -2313,30 +2312,17 @@ static int read_thread(void *arg)
2313 2313
     global_video_state = is;
2314 2314
     avio_set_interrupt_cb(decode_interrupt_cb);
2315 2315
 
2316
-    memset(ap, 0, sizeof(*ap));
2317
-
2318
-    ap->prealloced_context = 1;
2319
-    ap->width = frame_width;
2320
-    ap->height= frame_height;
2321
-    ap->time_base= (AVRational){1, 25};
2322
-    ap->pix_fmt = frame_pix_fmt;
2323
-    ic->flags |= AVFMT_FLAG_PRIV_OPT;
2324
-
2325
-
2326
-    err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
2327
-    if (err >= 0) {
2328
-        set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL);
2329
-        err = av_demuxer_open(ic, ap);
2330
-        if(err < 0){
2331
-            avformat_free_context(ic);
2332
-            ic= NULL;
2333
-        }
2334
-    }
2316
+    err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
2335 2317
     if (err < 0) {
2336 2318
         print_error(is->filename, err);
2337 2319
         ret = -1;
2338 2320
         goto fail;
2339 2321
     }
2322
+    if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
2323
+        av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
2324
+        ret = AVERROR_OPTION_NOT_FOUND;
2325
+        goto fail;
2326
+    }
2340 2327
     is->ic = ic;
2341 2328
 
2342 2329
     if(genpts)