summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xTOOLS/old-configure6
-rw-r--r--video/img_format.c20
-rw-r--r--wscript6
3 files changed, 27 insertions, 5 deletions
diff --git a/TOOLS/old-configure b/TOOLS/old-configure
index 5f4e8e7061..cdb65b0d7d 100755
--- a/TOOLS/old-configure
+++ b/TOOLS/old-configure
@@ -798,6 +798,12 @@ api_statement_check \
libavutil/avutil.h \
'const char *x = av_version_info()'
+api_statement_check \
+ "libavutil new pixdesc fields" \
+ HAVE_AV_NEW_PIXDESC \
+ libavutil/pixdesc.h \
+ 'AVComponentDescriptor d; int x = d.depth'
+
check_pkg_config "libavfilter" $_libavfilter LIBAVFILTER 'libavfilter >= 5.0.0'
check_pkg_config "libavdevice" $_libavdevice LIBAVDEVICE 'libavdevice >= 55.0.0'
diff --git a/video/img_format.c b/video/img_format.c
index 5defa6662e..bb6f106e1a 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -22,6 +22,8 @@
#include <libavutil/pixfmt.h>
#include <libavutil/pixdesc.h>
+#include "config.h"
+
#include "video/img_format.h"
#include "video/mp_image.h"
#include "video/fmt-conversion.h"
@@ -142,7 +144,6 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
.avformat = fmt,
.chroma_xs = pd->log2_chroma_w,
.chroma_ys = pd->log2_chroma_h,
- .component_bits = pd->comp[0].depth_minus1 + 1,
};
int planedepth[4] = {0};
@@ -150,12 +151,21 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
bool need_endian = false; // single component is spread over >1 bytes
for (int c = 0; c < pd->nb_components; c++) {
AVComponentDescriptor d = pd->comp[c];
+#if HAVE_AV_NEW_PIXDESC
+ int depth = d.depth;
+ int step = d.step;
+#else
+ int depth = d.depth_minus1 + 1;
+ int step = d.step_minus1 + 1;
+#endif
// multiple components per plane -> Y is definitive, ignore chroma
if (!desc.bpp[d.plane])
- desc.bpp[d.plane] = (d.step_minus1 + 1) * el_size;
- planedepth[d.plane] += d.depth_minus1 + 1;
- need_endian |= (d.depth_minus1 + 1 + d.shift) > 8;
- if (d.depth_minus1 + 1 != desc.component_bits)
+ desc.bpp[d.plane] = step * el_size;
+ planedepth[d.plane] += depth;
+ need_endian |= (depth + d.shift) > 8;
+ if (c == 0)
+ desc.component_bits = depth;
+ if (depth != desc.component_bits)
desc.component_bits = 0;
}
diff --git a/wscript b/wscript
index e6b89494e9..981f55b163 100644
--- a/wscript
+++ b/wscript
@@ -447,6 +447,12 @@ FFmpeg/Libav libraries. You need at least {0}. Aborting.".format(libav_versions_
'func': check_statement('libavutil/avutil.h',
'const char *x = av_version_info()',
use='libav'),
+ }, {
+ 'name': 'av-new-pixdesc',
+ 'desc': 'libavutil new pixdesc fields',
+ 'func': check_statement('libavutil/pixdesc.h',
+ 'AVComponentDescriptor d; int x = d.depth',
+ use='libav'),
}
]