Browse code

Improve codec_tag guessing code. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/03/09 23:12:24
Showing 1 changed files
... ...
@@ -25,6 +25,7 @@
25 25
 #include "avio_internal.h"
26 26
 #include "internal.h"
27 27
 #include "libavcodec/internal.h"
28
+#include "libavcodec/raw.h"
28 29
 #include "libavutil/opt.h"
29 30
 #include "metadata.h"
30 31
 #include "id3v2.h"
... ...
@@ -2428,8 +2429,11 @@ int av_find_stream_info(AVFormatContext *ic)
2428 2428
                      (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
2429 2429
                       st->info->codec_info_duration*(int64_t)st->time_base.num, 60000);
2430 2430
         if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
2431
-            if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample)
2432
-                st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
2431
+            if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample){
2432
+                uint32_t tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
2433
+                if(ff_find_pix_fmt(ff_raw_pix_fmt_tags, tag) == st->codec->pix_fmt)
2434
+                    st->codec->codec_tag= tag;
2435
+            }
2433 2436
 
2434 2437
             // the check for tb_unreliable() is not completely correct, since this is not about handling
2435 2438
             // a unreliable/inexact time base, but a time base that is finer than necessary, as e.g.