summaryrefslogtreecommitdiffstats
path: root/video/img_format.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-10 22:13:52 +0200
committerwm4 <wm4@nowhere>2015-09-10 22:13:52 +0200
commit9e04e319061495356277f647c1ce154e6b6cb6a4 (patch)
treeab55b0d8ddeced86cf34c903f73b8c837f57706a /video/img_format.c
parenta8eae12af5064a823976e264b33c5a37bd447ef8 (diff)
downloadmpv-9e04e319061495356277f647c1ce154e6b6cb6a4.tar.bz2
mpv-9e04e319061495356277f647c1ce154e6b6cb6a4.tar.xz
video: do not use deprecated libavutil pixdesc fields
These were normalized and are saner now. We want to use the new fields, and also get rid of the deprecation warnings, so use them. There's no release yet which uses these, so some ifdeffery is unfortunately needed.
Diffstat (limited to 'video/img_format.c')
-rw-r--r--video/img_format.c20
1 files changed, 15 insertions, 5 deletions
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;
}