[FFmpeg-devel] [PATCH 2/3] List MOV rawvideo codec tags in ff_raw_pix_fmt_tags before NUT tags, and make the nut encoder recognize also MOV audio and video codec tags.

Stefano Sabatini stefano.sabatini-lala
Sat Jun 12 02:02:25 CEST 2010


Valid MOV tags are also valid NUT tags, while is not true the reverse,
so it is required to give priority to the MOV tags, or the raw video
encoder will try to set a codec tag which is valid for NUT but not for
MOV if there is a pixel format with a NUT tag which is different from
the corresponding MOV tag.
---
 libavcodec/raw.c     |   30 +++++++++++++++---------------
 libavformat/nutdec.c |    7 +++++--
 libavformat/nutenc.c |    3 ++-
 3 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index 41f5c90..6986b5e 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -66,6 +66,21 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
     { PIX_FMT_NV12,    MKTAG('N', 'V', '1', '2') },
     { PIX_FMT_NV21,    MKTAG('N', 'V', '2', '1') },
 
+    /* quicktime */
+    { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
+    { PIX_FMT_UYVY422, MKTAG('2', 'V', 'u', 'y') },
+    { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */
+    { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') },
+    { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', 's') },
+    { PIX_FMT_PAL8,    MKTAG('W', 'R', 'A', 'W') },
+    { PIX_FMT_RGB555LE,MKTAG('L', '5', '5', '5') },
+    { PIX_FMT_RGB565LE,MKTAG('L', '5', '6', '5') },
+    { PIX_FMT_RGB565BE,MKTAG('B', '5', '6', '5') },
+    { PIX_FMT_BGR24,   MKTAG('2', '4', 'B', 'G') },
+    { PIX_FMT_BGRA,    MKTAG('B', 'G', 'R', 'A') },
+    { PIX_FMT_RGBA,    MKTAG('R', 'G', 'B', 'A') },
+    { PIX_FMT_ABGR,    MKTAG('A', 'B', 'G', 'R') },
+
     /* nut */
     { PIX_FMT_RGB555LE, MKTAG('R', 'G', 'B', 15) },
     { PIX_FMT_BGR555LE, MKTAG('B', 'G', 'R', 15) },
@@ -113,21 +128,6 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
     { PIX_FMT_YUVA420P,    MKTAG('Y', '4', 11 ,  8 ) },
     { PIX_FMT_Y400A,       MKTAG('Y', '2',  0 ,  8 ) },
 
-    /* quicktime */
-    { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
-    { PIX_FMT_UYVY422, MKTAG('2', 'V', 'u', 'y') },
-    { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */
-    { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', '2') },
-    { PIX_FMT_YUYV422, MKTAG('y', 'u', 'v', 's') },
-    { PIX_FMT_PAL8,    MKTAG('W', 'R', 'A', 'W') },
-    { PIX_FMT_RGB555LE,MKTAG('L', '5', '5', '5') },
-    { PIX_FMT_RGB565LE,MKTAG('L', '5', '6', '5') },
-    { PIX_FMT_RGB565BE,MKTAG('B', '5', '6', '5') },
-    { PIX_FMT_BGR24,   MKTAG('2', '4', 'B', 'G') },
-    { PIX_FMT_BGRA,    MKTAG('B', 'G', 'R', 'A') },
-    { PIX_FMT_RGBA,    MKTAG('R', 'G', 'B', 'A') },
-    { PIX_FMT_ABGR,    MKTAG('A', 'B', 'G', 'R') },
-
     /* special */
     { PIX_FMT_RGB565LE,MKTAG( 3 ,  0 ,  0 ,  0 ) }, /* flipped RGB565LE */
 
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index eed644c..7297d45 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -25,6 +25,7 @@
 #include "libavutil/bswap.h"
 #include "libavutil/tree.h"
 #include "nut.h"
+#include "isom.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -317,12 +318,14 @@ static int decode_stream_header(NUTContext *nut){
         case 0:
             st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codec->codec_id = av_codec_get_id(
-                (const AVCodecTag * const []) { ff_codec_bmp_tags, ff_nut_video_tags, 0 },
+                (const AVCodecTag * const []) { ff_codec_bmp_tags, ff_codec_movvideo_tags, ff_nut_video_tags, 0 },
                 tmp);
             break;
         case 1:
             st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-            st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, tmp);
+            st->codec->codec_id = av_codec_get_id(
+                (const AVCodecTag * const []) { ff_codec_wav_tags, ff_codec_movaudio_tags, 0 },
+                tmp);
             break;
         case 2:
             st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 061cd87..0cd4b16 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -23,6 +23,7 @@
 #include "libavutil/tree.h"
 #include "libavcodec/mpegaudiodata.h"
 #include "nut.h"
+#include "isom.h"
 #include "internal.h"
 
 static int find_expected_header(AVCodecContext *c, int size, int key_frame, uint8_t out[64]){
@@ -830,6 +831,6 @@ AVOutputFormat nut_muxer = {
     write_packet,
     write_trailer,
     .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
-    .codec_tag = (const AVCodecTag * const []){ ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 },
+    .codec_tag = (const AVCodecTag * const []){ ff_codec_bmp_tags, ff_codec_movvideo_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_codec_movaudio_tags, ff_nut_subtitle_tags, 0 },
     .metadata_conv = ff_nut_metadata_conv,
 };
-- 
1.7.1




More information about the ffmpeg-devel mailing list