diff -Nru gstreamer1.0-libde265-0.1.11/common/m4/Makefile.in gstreamer1.0-libde265-0.1.12/common/m4/Makefile.in --- gstreamer1.0-libde265-0.1.11/common/m4/Makefile.in 2014-08-29 08:35:17.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/common/m4/Makefile.in 2015-07-15 15:36:12.000000000 +0000 @@ -73,6 +73,8 @@ GREP = @GREP@ GST010_CFLAGS = @GST010_CFLAGS@ GST010_LIBS = @GST010_LIBS@ +GST_AUDIO_TAG_CFLAGS = @GST_AUDIO_TAG_CFLAGS@ +GST_AUDIO_TAG_LIBS = @GST_AUDIO_TAG_LIBS@ GST_CFLAGS = @GST_CFLAGS@ GST_LDFLAGS = @GST_LDFLAGS@ GST_LIBS = @GST_LIBS@ diff -Nru gstreamer1.0-libde265-0.1.11/common/Makefile.in gstreamer1.0-libde265-0.1.12/common/Makefile.in --- gstreamer1.0-libde265-0.1.11/common/Makefile.in 2014-08-29 08:35:17.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/common/Makefile.in 2015-07-15 15:36:12.000000000 +0000 @@ -114,6 +114,8 @@ GREP = @GREP@ GST010_CFLAGS = @GST010_CFLAGS@ GST010_LIBS = @GST010_LIBS@ +GST_AUDIO_TAG_CFLAGS = @GST_AUDIO_TAG_CFLAGS@ +GST_AUDIO_TAG_LIBS = @GST_AUDIO_TAG_LIBS@ GST_CFLAGS = @GST_CFLAGS@ GST_LDFLAGS = @GST_LDFLAGS@ GST_LIBS = @GST_LIBS@ diff -Nru gstreamer1.0-libde265-0.1.11/configure gstreamer1.0-libde265-0.1.12/configure --- gstreamer1.0-libde265-0.1.11/configure 2014-08-29 08:35:18.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/configure 2015-07-15 15:36:13.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for gstreamer-libde265 0.1.11. +# Generated by GNU Autoconf 2.68 for gstreamer-libde265 0.1.12. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -567,8 +567,8 @@ # Identity of this package. PACKAGE_NAME='gstreamer-libde265' PACKAGE_TARNAME='gstreamer-libde265' -PACKAGE_VERSION='0.1.11' -PACKAGE_STRING='gstreamer-libde265 0.1.11' +PACKAGE_VERSION='0.1.12' +PACKAGE_STRING='gstreamer-libde265 0.1.12' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -620,6 +620,8 @@ bz2_CFLAGS zlib_LIBS zlib_CFLAGS +GST_AUDIO_TAG_LIBS +GST_AUDIO_TAG_CFLAGS INCLUDE_MP4_DEMUXER_FALSE INCLUDE_MP4_DEMUXER_TRUE INCLUDE_MATROSKA_DEMUXER_FALSE @@ -784,6 +786,8 @@ GST_PLUGIN_LIBS GST010_CFLAGS GST010_LIBS +GST_AUDIO_TAG_CFLAGS +GST_AUDIO_TAG_LIBS zlib_CFLAGS zlib_LIBS libde265_CFLAGS @@ -1330,7 +1334,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures gstreamer-libde265 0.1.11 to adapt to many kinds of systems. +\`configure' configures gstreamer-libde265 0.1.12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1401,7 +1405,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of gstreamer-libde265 0.1.11:";; + short | recursive ) echo "Configuration of gstreamer-libde265 0.1.12:";; esac cat <<\_ACEOF @@ -1454,6 +1458,10 @@ GST010_CFLAGS C compiler flags for GST010, overriding pkg-config GST010_LIBS linker flags for GST010, overriding pkg-config + GST_AUDIO_TAG_CFLAGS + C compiler flags for GST_AUDIO_TAG, overriding pkg-config + GST_AUDIO_TAG_LIBS + linker flags for GST_AUDIO_TAG, overriding pkg-config zlib_CFLAGS C compiler flags for zlib, overriding pkg-config zlib_LIBS linker flags for zlib, overriding pkg-config libde265_CFLAGS @@ -1527,7 +1535,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -gstreamer-libde265 configure 0.1.11 +gstreamer-libde265 configure 0.1.12 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2073,7 +2081,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by gstreamer-libde265 $as_me 0.1.11, which was +It was created by gstreamer-libde265 $as_me 0.1.12, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2896,7 +2904,7 @@ # Define the identity of the package. PACKAGE='gstreamer-libde265' - VERSION='0.1.11' + VERSION='0.1.12' cat >>confdefs.h <<_ACEOF @@ -12603,6 +12611,138 @@ if eval "test $USE_GSTREAMER_VERSION != 1.4" ; then pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GST_AUDIO_TAG" >&5 +$as_echo_n "checking for GST_AUDIO_TAG... " >&6; } + +if test -n "$GST_AUDIO_TAG_CFLAGS"; then + pkg_cv_GST_AUDIO_TAG_CFLAGS="$GST_AUDIO_TAG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" + gstreamer-audio-\$GSTREAMER_VERSION >= \$GST_REQUIRED + gstreamer-tag-\$GSTREAMER_VERSION >= \$GST_REQUIRED + \""; } >&5 + ($PKG_CONFIG --exists --print-errors " + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + ") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GST_AUDIO_TAG_CFLAGS=`$PKG_CONFIG --cflags " + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + " 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$GST_AUDIO_TAG_LIBS"; then + pkg_cv_GST_AUDIO_TAG_LIBS="$GST_AUDIO_TAG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" + gstreamer-audio-\$GSTREAMER_VERSION >= \$GST_REQUIRED + gstreamer-tag-\$GSTREAMER_VERSION >= \$GST_REQUIRED + \""; } >&5 + ($PKG_CONFIG --exists --print-errors " + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + ") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GST_AUDIO_TAG_LIBS=`$PKG_CONFIG --libs " + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + " 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + GST_AUDIO_TAG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + " 2>&1` + else + GST_AUDIO_TAG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + " 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$GST_AUDIO_TAG_PKG_ERRORS" >&5 + + + as_fn_error $? " + Can't find the following GStreamer development packages: + + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + + Please make sure you have the necessary GStreamer-$GSTREAMER_VERSION + development headers installed. + + On debian/Ubuntu systems you will probably need to install the + 'libgstreamer$GSTREAMER_VERSION-dev' and 'libgstreamer-plugins-base$GSTREAMER_VERSION-dev' packages. + + On RPM-based systems you will probably need to install the + 'gstreamer-devel-$GSTREAMER_VERSION' package. + " "$LINENO" 5 + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + as_fn_error $? " + Can't find the following GStreamer development packages: + + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + + Please make sure you have the necessary GStreamer-$GSTREAMER_VERSION + development headers installed. + + On debian/Ubuntu systems you will probably need to install the + 'libgstreamer$GSTREAMER_VERSION-dev' and 'libgstreamer-plugins-base$GSTREAMER_VERSION-dev' packages. + + On RPM-based systems you will probably need to install the + 'gstreamer-devel-$GSTREAMER_VERSION' package. + " "$LINENO" 5 + +else + GST_AUDIO_TAG_CFLAGS=$pkg_cv_GST_AUDIO_TAG_CFLAGS + GST_AUDIO_TAG_LIBS=$pkg_cv_GST_AUDIO_TAG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + GST_CFLAGS="$GST_CFLAGS $GST_AUDIO_TAG_CFLAGS" + GST_LIBS="$GST_LIBS $GST_AUDIO_TAG_LIBS" + GST_LDFLAGS="$GST_LDFLAGS $GST_AUDIO_TAG_LDFLAGS" + +fi + + +pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5 $as_echo_n "checking for zlib... " >&6; } @@ -13420,7 +13560,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by gstreamer-libde265 $as_me 0.1.11, which was +This file was extended by gstreamer-libde265 $as_me 0.1.12, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13486,7 +13626,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -gstreamer-libde265 config.status 0.1.11 +gstreamer-libde265 config.status 0.1.12 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff -Nru gstreamer1.0-libde265-0.1.11/configure.ac gstreamer1.0-libde265-0.1.12/configure.ac --- gstreamer1.0-libde265-0.1.11/configure.ac 2014-08-29 08:34:44.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/configure.ac 2015-07-15 15:36:09.000000000 +0000 @@ -1,7 +1,7 @@ dnl required version of autoconf AC_PREREQ([2.53]) -AC_INIT([gstreamer-libde265],[0.1.11]) +AC_INIT([gstreamer-libde265],[0.1.12]) dnl required versions of gstreamer GST_REQUIRED=1.0.0 @@ -187,6 +187,31 @@ AM_CONDITIONAL([INCLUDE_MP4_DEMUXER], [test "$USE_GSTREAMER_VERSION" != "1.4"]) if eval "test $USE_GSTREAMER_VERSION != 1.4" ; then + PKG_CHECK_MODULES(GST_AUDIO_TAG, [ + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + ], [ + GST_CFLAGS="$GST_CFLAGS $GST_AUDIO_TAG_CFLAGS" + GST_LIBS="$GST_LIBS $GST_AUDIO_TAG_LIBS" + GST_LDFLAGS="$GST_LDFLAGS $GST_AUDIO_TAG_LDFLAGS" + ], [ + AC_MSG_ERROR([ + Can't find the following GStreamer development packages: + + gstreamer-audio-$GSTREAMER_VERSION >= $GST_REQUIRED + gstreamer-tag-$GSTREAMER_VERSION >= $GST_REQUIRED + + Please make sure you have the necessary GStreamer-$GSTREAMER_VERSION + development headers installed. + + On debian/Ubuntu systems you will probably need to install the + 'libgstreamer$GSTREAMER_VERSION-dev' and 'libgstreamer-plugins-base$GSTREAMER_VERSION-dev' packages. + + On RPM-based systems you will probably need to install the + 'gstreamer-devel-$GSTREAMER_VERSION' package. + ]) + ]) + PKG_CHECK_MODULES(zlib, [zlib], [ AC_SUBST(zlib_CFLAGS) AC_SUBST(zlib_LIBS) diff -Nru gstreamer1.0-libde265-0.1.11/debian/changelog gstreamer1.0-libde265-0.1.12/debian/changelog --- gstreamer1.0-libde265-0.1.11/debian/changelog 2014-08-29 11:06:32.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/debian/changelog 2015-07-15 15:47:34.000000000 +0000 @@ -1,4 +1,13 @@ -gstreamer1.0-libde265 (0.1.11-2ppa1~trusty1) precise; urgency=low +gstreamer1.0-libde265 (0.1.12-1ppa1~trusty1) unstable; urgency=low + + * Explicitly link against -audio and -tag libraries if Matroska/MP4 + part is enabled. + * Support additional bit depths with libde265 1.0.0. + * Require libde265 >= 1.0.2. + + -- Joachim Bauch Wed, 15 Jul 2015 17:43:21 +0200 + +gstreamer1.0-libde265 (0.1.11-2ppa1) precise; urgency=low * Fixed build dependencies. diff -Nru gstreamer1.0-libde265-0.1.11/debian/control gstreamer1.0-libde265-0.1.12/debian/control --- gstreamer1.0-libde265-0.1.11/debian/control 2014-08-29 11:06:18.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/debian/control 2015-07-15 15:47:10.000000000 +0000 @@ -9,7 +9,7 @@ pkg-config, libz-dev, libbz2-dev, - libde265-dev (>= 0.7), + libde265-dev (>= 1.0.2), libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev, libgstreamer-plugins-good1.0-dev, diff -Nru gstreamer1.0-libde265-0.1.11/examples/Makefile.in gstreamer1.0-libde265-0.1.12/examples/Makefile.in --- gstreamer1.0-libde265-0.1.11/examples/Makefile.in 2014-08-29 08:35:17.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/examples/Makefile.in 2015-07-15 15:36:12.000000000 +0000 @@ -104,6 +104,8 @@ GREP = @GREP@ GST010_CFLAGS = @GST010_CFLAGS@ GST010_LIBS = @GST010_LIBS@ +GST_AUDIO_TAG_CFLAGS = @GST_AUDIO_TAG_CFLAGS@ +GST_AUDIO_TAG_LIBS = @GST_AUDIO_TAG_LIBS@ GST_CFLAGS = @GST_CFLAGS@ GST_LDFLAGS = @GST_LDFLAGS@ GST_LIBS = @GST_LIBS@ diff -Nru gstreamer1.0-libde265-0.1.11/Makefile.in gstreamer1.0-libde265-0.1.12/Makefile.in --- gstreamer1.0-libde265-0.1.11/Makefile.in 2014-08-29 08:35:17.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/Makefile.in 2015-07-15 15:36:13.000000000 +0000 @@ -132,6 +132,8 @@ GREP = @GREP@ GST010_CFLAGS = @GST010_CFLAGS@ GST010_LIBS = @GST010_LIBS@ +GST_AUDIO_TAG_CFLAGS = @GST_AUDIO_TAG_CFLAGS@ +GST_AUDIO_TAG_LIBS = @GST_AUDIO_TAG_LIBS@ GST_CFLAGS = @GST_CFLAGS@ GST_LDFLAGS = @GST_LDFLAGS@ GST_LIBS = @GST_LIBS@ diff -Nru gstreamer1.0-libde265-0.1.11/src/libde265-dec.c gstreamer1.0-libde265-0.1.12/src/libde265-dec.c --- gstreamer1.0-libde265-0.1.11/src/libde265-dec.c 2014-08-29 08:21:08.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/src/libde265-dec.c 2015-07-06 12:59:16.000000000 +0000 @@ -30,6 +30,11 @@ #error "You need libde265 0.7 or newer to compile this plugin." #endif +#if LIBDE265_NUMERIC_VERSION < 0x01000000 +// libde265 < 1.0 only supported 8 bits per pixel +#define de265_get_bits_per_pixel(image, plane) 8 +#endif + // use two decoder threads if no information about // available CPU cores can be retrieved #define DEFAULT_THREAD_COUNT 2 @@ -113,7 +118,7 @@ static GstFlowReturn gst_libde265_dec_handle_frame (VIDEO_DECODER_BASE * parse, VIDEO_FRAME * frame); static GstFlowReturn _gst_libde265_image_available (VIDEO_DECODER_BASE * parse, - int width, int height); + int width, int height, GstVideoFormat format); static void gst_libde265_dec_class_init (GstLibde265DecClass * klass) @@ -275,6 +280,99 @@ } } +static inline GstVideoFormat +_gst_libde265_get_video_format (enum de265_chroma chroma, int bits_per_pixel) +{ + GstVideoFormat result = GST_VIDEO_FORMAT_UNKNOWN; + switch (chroma) { + case de265_chroma_mono: + result = GST_VIDEO_FORMAT_GRAY8; + break; + case de265_chroma_420: +#if GST_CHECK_VERSION(1,0,0) + switch (bits_per_pixel) { + case 8: + result = GST_VIDEO_FORMAT_I420; + break; + case 9: + result = GST_VIDEO_FORMAT_I420_10LE; + break; + case 10: + result = GST_VIDEO_FORMAT_I420_10LE; + break; + default: + if (bits_per_pixel > 10 && bits_per_pixel <= 16) { + result = GST_VIDEO_FORMAT_I420_10LE; + } else { + GST_DEBUG + ("Unsupported output colorspace %d with %d bits per pixel", + chroma, bits_per_pixel); + } + break; + } +#else + result = GST_VIDEO_FORMAT_I420; +#endif + break; + case de265_chroma_422: +#if GST_CHECK_VERSION(1,0,0) + switch (bits_per_pixel) { + case 8: + result = GST_VIDEO_FORMAT_Y42B; + break; + case 9: + result = GST_VIDEO_FORMAT_I422_10LE; + break; + case 10: + result = GST_VIDEO_FORMAT_I422_10LE; + break; + default: + if (bits_per_pixel > 10 && bits_per_pixel <= 16) { + result = GST_VIDEO_FORMAT_I422_10LE; + } else { + GST_DEBUG + ("Unsupported output colorspace %d with %d bits per pixel", + chroma, bits_per_pixel); + } + break; + } +#else + result = GST_VIDEO_FORMAT_Y42B; +#endif + break; + case de265_chroma_444: +#if GST_CHECK_VERSION(1,0,0) + switch (bits_per_pixel) { + case 8: + result = GST_VIDEO_FORMAT_Y444; + break; + case 9: + result = GST_VIDEO_FORMAT_Y444_10LE; + break; + case 10: + result = GST_VIDEO_FORMAT_Y444_10LE; + break; + default: + if (bits_per_pixel > 10 && bits_per_pixel <= 16) { + result = GST_VIDEO_FORMAT_Y444_10LE; + } else { + GST_DEBUG + ("Unsupported output colorspace %d with %d bits per pixel", + chroma, bits_per_pixel); + } + break; + } +#else + result = GST_VIDEO_FORMAT_Y444; +#endif + break; + default: + GST_DEBUG ("Unsupported output colorspace %d", chroma); + break; + } + return result; +} + /* * Direct rendering code needs GStreamer 1.0 * to have support for refcounted frames. @@ -289,6 +387,24 @@ int mapped; }; +static inline enum de265_chroma +_gst_libde265_image_format_to_chroma (enum de265_image_format format) +{ + switch (format) { + case de265_image_format_mono8: + return de265_chroma_mono; + case de265_image_format_YUV420P8: + return de265_chroma_420; + case de265_image_format_YUV422P8: + return de265_chroma_422; + case de265_image_format_YUV444P8: + return de265_chroma_444; + default: + g_assert (0); + return 0; + } +} + static void gst_libde265_dec_release_frame_ref (struct GstLibde265FrameRef *ref) { @@ -319,18 +435,48 @@ GST_VIDEO_CODEC_FRAME_FLAG_UNSET (frame, GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY); - int width = spec->width; + int width = + (spec->width + spec->alignment - 1) / spec->alignment * spec->alignment; int height = spec->height; - if (width % spec->alignment) { - width += spec->alignment - (width % spec->alignment); - } if (width != spec->visible_width || height != spec->visible_height) { // clipping not supported for now goto fallback; } - GstFlowReturn ret = _gst_libde265_image_available (base, width, height); + enum de265_chroma chroma = + _gst_libde265_image_format_to_chroma (spec->format); + if (chroma != de265_chroma_mono) { + if (de265_get_bits_per_pixel (img, 0) != de265_get_bits_per_pixel (img, 1) + || de265_get_bits_per_pixel (img, 0) != de265_get_bits_per_pixel (img, + 2) + || de265_get_bits_per_pixel (img, 1) != de265_get_bits_per_pixel (img, + 2)) { + GST_DEBUG_OBJECT (dec, + "input format has multiple bits per pixel (%d/%d/%d)", + de265_get_bits_per_pixel (img, 0), de265_get_bits_per_pixel (img, 1), + de265_get_bits_per_pixel (img, 2)); + goto fallback; + } + } + + int bits_per_pixel = de265_get_bits_per_pixel (img, 0); + GstVideoFormat format = + _gst_libde265_get_video_format (chroma, bits_per_pixel); + if (format == GST_VIDEO_FORMAT_UNKNOWN) { + goto fallback; + } + + const GstVideoFormatInfo *format_info = gst_video_format_get_info (format); + if (GST_VIDEO_FORMAT_INFO_BITS (format_info) != bits_per_pixel) { + GST_DEBUG_OBJECT (dec, + "output format doesn't provide enough bits per pixel (%d/%d)", + GST_VIDEO_FORMAT_INFO_BITS (format_info), bits_per_pixel); + goto fallback; + } + + GstFlowReturn ret = _gst_libde265_image_available (base, width, height, + format); if (G_UNLIKELY (ret != GST_FLOW_OK)) { GST_ERROR_OBJECT (dec, "Failed to notify about available image"); goto fallback; @@ -531,14 +677,14 @@ static GstFlowReturn _gst_libde265_image_available (VIDEO_DECODER_BASE * parse, - int width, int height) + int width, int height, GstVideoFormat format) { GstLibde265Dec *dec = GST_LIBDE265_DEC (parse); if (G_UNLIKELY (width != dec->width || height != dec->height)) { #if GST_CHECK_VERSION(1,0,0) GstVideoCodecState *state = - gst_video_decoder_set_output_state (parse, GST_VIDEO_FORMAT_I420, width, + gst_video_decoder_set_output_state (parse, format, width, height, dec->input_state); g_assert (state != NULL); if (dec->fps_n > 0) { @@ -560,7 +706,7 @@ #else GstVideoState *state = gst_base_video_decoder_get_state (parse); g_assert (state != NULL); - state->format = GST_VIDEO_FORMAT_I420; + state->format = format; state->width = width; state->height = height; if (dec->fps_n > 0) { @@ -866,9 +1012,21 @@ GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY); #endif + int bits_per_pixel = MAX (MAX (de265_get_bits_per_pixel (img, 0), + de265_get_bits_per_pixel (img, 1)), de265_get_bits_per_pixel (img, + 2)); + + GstVideoFormat format = + _gst_libde265_get_video_format (de265_get_chroma_format (img), + bits_per_pixel); + if (format == GST_VIDEO_FORMAT_UNKNOWN) { + GST_ERROR_OBJECT (dec, "Unsupported image format"); + return GST_FLOW_ERROR; + } + GstFlowReturn result = _gst_libde265_image_available (parse, de265_get_image_width (img, 0), - de265_get_image_height (img, 0)); + de265_get_image_height (img, 0), format); if (result != GST_FLOW_OK) { GST_ERROR_OBJECT (dec, "Failed to notify about available image"); return result; @@ -892,20 +1050,97 @@ dest = GST_BUFFER_DATA (frame->src_buffer); #endif +#if GST_CHECK_VERSION(1,0,0) + const GstVideoFormatInfo *format_info = gst_video_format_get_info (format); + int max_bits_per_pixel = GST_VIDEO_FORMAT_INFO_BITS (format_info); +#else + int max_bits_per_pixel = 8; +#endif + int plane; for (plane = 0; plane < 3; plane++) { int stride; + int pos; int width = de265_get_image_width (img, plane); int height = de265_get_image_height (img, plane); const uint8_t *src = de265_get_image_plane (img, plane, &stride); - if (stride == width) { - memcpy (dest, src, height * stride); - dest += (height * stride); - } else { + int dst_stride = width * ((max_bits_per_pixel + 7) / 8); + int plane_bits_per_pixel = de265_get_bits_per_pixel (img, plane); + if (plane_bits_per_pixel > max_bits_per_pixel && max_bits_per_pixel > 8) { + // More bits per pixel in this plane than supported by the output format + int shift = (plane_bits_per_pixel - max_bits_per_pixel); + int size = MIN (stride, dst_stride); + while (height--) { + uint16_t *s = (uint16_t *) src; + uint16_t *d = (uint16_t *) dest; + for (pos = 0; pos < size / 2; pos++) { + *d = *s >> shift; + d++; + s++; + } + src += stride; + dest += dst_stride; + } + } else if (plane_bits_per_pixel > max_bits_per_pixel + && max_bits_per_pixel == 8) { + // More bits per pixel in this plane than supported by the output format + int shift = (plane_bits_per_pixel - max_bits_per_pixel); + int size = MIN (stride, dst_stride); + while (height--) { + uint16_t *s = (uint16_t *) src; + uint8_t *d = (uint8_t *) dest; + for (pos = 0; pos < size; pos++) { + *d = *s >> shift; + d++; + s++; + } + src += stride; + dest += dst_stride; + } + } else if (plane_bits_per_pixel < max_bits_per_pixel + && plane_bits_per_pixel > 8) { + // Less bits per pixel in this plane than the rest of the picture + // but more than 8bpp. + int shift = (plane_bits_per_pixel - max_bits_per_pixel); + int size = MIN (stride, dst_stride); + while (height--) { + uint16_t *s = (uint16_t *) src; + uint16_t *d = (uint16_t *) dest; + for (pos = 0; pos < size / 2; pos++) { + *d = *s >> shift; + d++; + s++; + } + src += stride; + dest += dst_stride; + } + } else if (plane_bits_per_pixel < max_bits_per_pixel + && plane_bits_per_pixel == 8) { + // 8 bits per pixel in this plane, which is less than the rest of the picture. + int shift = (max_bits_per_pixel - plane_bits_per_pixel); + int size = MIN (stride, dst_stride); while (height--) { - memcpy (dest, src, width); + uint8_t *s = (uint8_t *) src; + uint16_t *d = (uint16_t *) dest; + for (pos = 0; pos < size; pos++) { + *d = *s << shift; + d++; + s++; + } src += stride; - dest += width; + dest += dst_stride; + } + } else { + // Bits per pixel of image match output format. + if (stride == width) { + memcpy (dest, src, height * stride); + dest += (height * stride); + } else { + while (height--) { + memcpy (dest, src, width); + src += stride; + dest += width; + } } } } diff -Nru gstreamer1.0-libde265-0.1.11/src/Makefile.in gstreamer1.0-libde265-0.1.12/src/Makefile.in --- gstreamer1.0-libde265-0.1.11/src/Makefile.in 2014-08-29 08:37:59.000000000 +0000 +++ gstreamer1.0-libde265-0.1.12/src/Makefile.in 2015-07-15 15:36:13.000000000 +0000 @@ -285,6 +285,8 @@ GREP = @GREP@ GST010_CFLAGS = @GST010_CFLAGS@ GST010_LIBS = @GST010_LIBS@ +GST_AUDIO_TAG_CFLAGS = @GST_AUDIO_TAG_CFLAGS@ +GST_AUDIO_TAG_LIBS = @GST_AUDIO_TAG_LIBS@ GST_CFLAGS = @GST_CFLAGS@ GST_LDFLAGS = @GST_LDFLAGS@ GST_LIBS = @GST_LIBS@