[FFmpeg-cvslog] lavc, lavfi: fix counting number of planes in AVBufferRef wrappers

Anton Khirnov git at videolan.org
Wed Mar 20 11:37:57 CET 2013


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Mar 16 22:36:56 2013 +0100| [c977039e585bfff28ecc037ef827c6c3d1ed88aa] | committer: Anton Khirnov

lavc, lavfi: fix counting number of planes in AVBufferRef wrappers

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c977039e585bfff28ecc037ef827c6c3d1ed88aa
---

 libavcodec/utils.c      |    4 ++--
 libavfilter/buffersrc.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4d57865..e18f42d 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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;
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 65cacf7..19419e6 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -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;



More information about the ffmpeg-cvslog mailing list