]> git.sesse.net Git - ffmpeg/commitdiff
lavc, lavfi: fix counting number of planes in AVBufferRef wrappers
authorAnton Khirnov <anton@khirnov.net>
Sat, 16 Mar 2013 21:36:56 +0000 (22:36 +0100)
committerAnton Khirnov <anton@khirnov.net>
Tue, 19 Mar 2013 10:12:17 +0000 (11:12 +0100)
Number of planes is not always equal to the number of components even
for formats marked with PIX_FMT_PLANAR -- e.g. NV12 has three components
in two planes.

libavcodec/utils.c
libavfilter/buffersrc.c

index 4d57865629120f1ffc7b315c9b413c70a9099e6a..e18f42d99a8eb7442c9c79737d334e7312e1ce3b 100644 (file)
@@ -660,11 +660,11 @@ do {                                                                    \
         if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
             const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
 
-            if (!desc) {
+            planes = av_pix_fmt_count_planes(frame->format);
+            if (!desc || planes <= 0) {
                 ret = AVERROR(EINVAL);
                 goto fail;
             }
-            planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
 
             for (i = 0; i < planes; i++) {
                 int v_shift    = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
index 65cacf7d8514e14b8d5fb10eb27cc74876252509..19419e6d25194f9f7d53d1f163342778e2d45e09 100644 (file)
@@ -186,11 +186,11 @@ do {                                                                    \
     if (ctx->outputs[0]->type  == AVMEDIA_TYPE_VIDEO) {
         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
 
-        if (!desc) {
+        planes = av_pix_fmt_count_planes(frame->format);
+        if (!desc || planes <= 0) {
             ret = AVERROR(EINVAL);
             goto fail;
         }
-        planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1;
 
         for (i = 0; i < planes; i++) {
             int v_shift    = (i == 1 || i == 2) ? desc->log2_chroma_w : 0;