WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
See the License for the specific language governing permissions and\r
limitations under the License.\r
-\r
-\r
-\r
AC_SUBST(MMLOG_CFLAGS)
AC_SUBST(MMLOG_LIBS)
-PKG_CHECK_MODULES(MMTA, mm-ta)
-AC_SUBST(MMTA_CFLAGS)
-AC_SUBST(MMTA_LIBS)
-
PKG_CHECK_MODULES(GLIB, glib-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS)
+PKG_CHECK_MODULES(MEDIA, capi-media-tool)
+AC_SUBST(MEDIA_CFLAGS)
+AC_SUBST(MEDIA_LIBS)
+
+PKG_CHECK_MODULES(TBM, libtbm)
+AC_SUBST(TBM_CFLAGS)
+AC_SUBST(TBM_LIBS)
+
+PKG_CHECK_MODULES(SYSTEMINFO, capi-system-info)
+AC_SUBST(SYSTEMINFO_CFLAGS)
+AC_SUBST(SYSTEMINFO_LIBS)
+
#tz-platform-config lib
PKG_CHECK_MODULES(TZ_PLATFORM_CONFIG, libtzplatform-config)
AC_SUBST(TZ_PLATFORM_CONFIG_CFLAGS)
jpeg/mmutil-jpeg.pc
test/Makefile
])
-AC_OUTPUT
+AC_OUTPUT
+++ /dev/null
-#! /bin/sh
-# depcomp - compile a program generating dependencies as side-effects
-
-scriptversion=2007-03-29.01
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
-# Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
- depmode Dependency tracking mode.
- source Source file read by `PROGRAMS ARGS'.
- object Object file output by `PROGRAMS ARGS'.
- DEPDIR directory where to store dependencies.
- depfile Dependency file to output.
- tmpdepfile Temporary file to use when outputing dependencies.
- libtool Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "depcomp $scriptversion"
- exit $?
- ;;
-esac
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
- echo "depcomp: Variables source, object and depmode must be set" 1>&2
- exit 1
-fi
-
-# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
-depfile=${depfile-`echo "$object" |
- sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags. We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write. Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
- # HP compiler uses -M and no extra arg.
- gccflag=-M
- depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
- # This is just like dashmstdout with a different argument.
- dashmflag=-xM
- depmode=dashmstdout
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want. Yay! Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff. Hmm.
-## Unfortunately, FreeBSD c89 acceptance of flags depends upon
-## the command line argument order; so add the flags where they
-## appear in depend2.am. Note that the slowdown incurred here
-## affects only configure: in makefiles, %FASTDEP% shortcuts this.
- for arg
- do
- case $arg in
- -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
- *) set fnord "$@" "$arg" ;;
- esac
- shift # fnord
- shift # $arg
- done
- "$@"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- mv "$tmpdepfile" "$depfile"
- ;;
-
-gcc)
-## There are various ways to get dependency output from gcc. Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-## up in a subdir. Having to rename by hand is ugly.
-## (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-## -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-## than renaming).
- if test -z "$gccflag"; then
- gccflag=-MD,
- fi
- "$@" -Wp,"$gccflag$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
- sed -e 's/^[^:]*: / /' \
- -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header). We avoid this by adding
-## dummy dependencies for each header file. Too bad gcc doesn't do
-## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp)
- # This case exists only to let depend.m4 do its work. It works by
- # looking at the text of this script. This case will never be run,
- # since it is checked for above.
- exit 1
- ;;
-
-sgi)
- if test "$libtool" = yes; then
- "$@" "-Wp,-MDupdate,$tmpdepfile"
- else
- "$@" -MDupdate "$tmpdepfile"
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
-
- if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
- echo "$object : \\" > "$depfile"
-
- # Clip off the initial element (the dependent). Don't try to be
- # clever and replace this with sed code, as IRIX sed won't handle
- # lines with more than a fixed number of characters (4096 in
- # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
- # dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> $depfile
- echo >> $depfile
-
- # The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
- >> $depfile
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-aix)
- # The C for AIX Compiler uses -M and outputs the dependencies
- # in a .u file. In older versions, this file always lives in the
- # current directory. Also, the AIX compiler puts `$object:' at the
- # start of each line; $object doesn't have directory information.
- # Version 6 uses the directory in both cases.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
- if test "$libtool" = yes; then
- tmpdepfile1=$dir$base.u
- tmpdepfile2=$base.u
- tmpdepfile3=$dir.libs/$base.u
- "$@" -Wc,-M
- else
- tmpdepfile1=$dir$base.u
- tmpdepfile2=$dir$base.u
- tmpdepfile3=$dir$base.u
- "$@" -M
- fi
- stat=$?
-
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- # Each line is of the form `foo.o: dependent.h'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-icc)
- # Intel's C compiler understands `-MD -MF file'. However on
- # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
- # ICC 7.0 will fill foo.d with something like
- # foo.o: sub/foo.c
- # foo.o: sub/foo.h
- # which is wrong. We want:
- # sub/foo.o: sub/foo.c
- # sub/foo.o: sub/foo.h
- # sub/foo.c:
- # sub/foo.h:
- # ICC 7.1 will output
- # foo.o: sub/foo.c sub/foo.h
- # and will wrap long lines using \ :
- # foo.o: sub/foo.c ... \
- # sub/foo.h ... \
- # ...
-
- "$@" -MD -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- # Each line is of the form `foo.o: dependent.h',
- # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
- # Some versions of the HPUX 10.20 sed can't process this invocation
- # correctly. Breaking it into two sed invocations is a workaround.
- sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
- sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp2)
- # The "hp" stanza above does not work with aCC (C++) and HP's ia64
- # compilers, which have integrated preprocessors. The correct option
- # to use with these is +Maked; it writes dependencies to a file named
- # 'foo.d', which lands next to the object file, wherever that
- # happens to be.
- # Much of this is similar to the tru64 case; see comments there.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
- if test "$libtool" = yes; then
- tmpdepfile1=$dir$base.d
- tmpdepfile2=$dir.libs/$base.d
- "$@" -Wc,+Maked
- else
- tmpdepfile1=$dir$base.d
- tmpdepfile2=$dir$base.d
- "$@" +Maked
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
- # Add `dependent.h:' lines.
- sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile" "$tmpdepfile2"
- ;;
-
-tru64)
- # The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
- # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
- # Subdirectories are respected.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
- if test "$libtool" = yes; then
- # With Tru64 cc, shared objects can also be used to make a
- # static library. This mechanism is used in libtool 1.4 series to
- # handle both shared and static libraries in a single compilation.
- # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
- #
- # With libtool 1.5 this exception was removed, and libtool now
- # generates 2 separate objects for the 2 libraries. These two
- # compilations output dependencies in $dir.libs/$base.o.d and
- # in $dir$base.o.d. We have to check for both files, because
- # one of the two compilations can be disabled. We should prefer
- # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
- # automatically cleaned when .libs/ is deleted, while ignoring
- # the former would cause a distcleancheck panic.
- tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
- tmpdepfile2=$dir$base.o.d # libtool 1.5
- tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
- tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
- "$@" -Wc,-MD
- else
- tmpdepfile1=$dir$base.o.d
- tmpdepfile2=$dir$base.d
- tmpdepfile3=$dir$base.d
- tmpdepfile4=$dir$base.d
- "$@" -MD
- fi
-
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-#nosideeffect)
- # This comment above is used by automake to tell side-effect
- # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- test -z "$dashmflag" && dashmflag=-M
- # Require at least two characters before searching for `:'
- # in the target name. This is to cope with DOS-style filenames:
- # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
- "$@" $dashmflag |
- sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-dashXmstdout)
- # This case only exists to satisfy depend.m4. It is never actually
- # run, as this mode is specially recognized in the preamble.
- exit 1
- ;;
-
-makedepend)
- "$@" || exit $?
- # Remove any Libtool call
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
- # X makedepend
- shift
- cleared=no
- for arg in "$@"; do
- case $cleared in
- no)
- set ""; shift
- cleared=yes ;;
- esac
- case "$arg" in
- -D*|-I*)
- set fnord "$@" "$arg"; shift ;;
- # Strip any option that makedepend may not understand. Remove
- # the object too, otherwise makedepend will parse it as a source file.
- -*|$object)
- ;;
- *)
- set fnord "$@" "$arg"; shift ;;
- esac
- done
- obj_suffix="`echo $object | sed 's/^.*\././'`"
- touch "$tmpdepfile"
- ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile" "$tmpdepfile".bak
- ;;
-
-cpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- "$@" -E |
- sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
- -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
- sed '$ s: \\$::' > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- cat < "$tmpdepfile" >> "$depfile"
- sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-msvisualcpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- "$@" || exit $?
- IFS=" "
- for arg
- do
- case "$arg" in
- "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
- set fnord "$@"
- shift
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift
- shift
- ;;
- esac
- done
- "$@" -E |
- sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-none)
- exec "$@"
- ;;
-
-*)
- echo "Unknown depmode $depmode" 1>&2
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
noinst_HEADERS = include/mm_util_imgp_internal.h
libmmutil_imgp_la_SOURCES = mm_util_imgp.c
-
+
libmmutil_imgp_la_CFLAGS = -I$(srcdir)/include \
+ -I$(includedir)/drm \
$(MMCOMMON_CFLAGS) \
- $(MMTA_CFLAGS) \
$(GLIB_CFLAGS) \
$(GMODULE_CFLAGS) \
+ $(DRM_CFLAGS) \
+ $(DRM_DEVEL_CFLAGS) \
+ $(MEDIA_CFLAGS) \
+ $(XFIXES_CFLAGS) \
+ $(DRI2PROTO_CFLAGS) \
+ $(DRI2_CFLAGS) \
+ $(TBM_CFLAGS) \
$(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\"
-
+
libmmutil_imgp_la_LIBADD = $(MMCOMMON_LIBS) \
- $(MMTA_LIBS) \
$(GLIB_LIBS) \
$(GMODULE_LIBS) \
+ $(DRM_LIBS) \
+ $(DRM_DEVEL_LIBS) \
+ $(MEDIA_LIBS) \
+ $(XFIXES_LIBS) \
+ $(DRI2PROTO_LIBS) \
+ $(DRI2_LIBS) \
+ $(TBM_LIBS) \
$(MMLOG_LIBS)
-libmmutil_imgp_la_CFLAGS += $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -DLIBPREFIX=\"$(libdir)\"
+libmmutil_imgp_la_CFLAGS += -lcapi-media-tool $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -DLIBPREFIX=\"$(libdir)\"
pcfiles = mmutil-imgp.pc
pkgconfigdir = $(libdir)/pkgconfig
extern "C" {
#endif
+#include <mm_types.h>
+#include <media_packet.h>
+
+typedef bool (*mm_util_completed_callback)(media_packet_h *dst, int error, void *user_param);
/**
@addtogroup UTILITY
@{
MM_UTIL_IMG_FMT_BGRX8888, /**<BGRX8888 pixel format */
/* non-standard format */
MM_UTIL_IMG_FMT_NV12_TILED, /**< Customized color format in s5pc110 */
+ MM_UTIL_IMG_FMT_NV16, /**<NV16 pixel format */
+ MM_UTIL_IMG_FMT_NV61, /**<NV61 pixel format */
MM_UTIL_IMG_FMT_NUM, /**< Number of image formats */
} mm_util_img_format;
mm_util_get_image_size(mm_util_img_format format, unsigned int width, unsigned int height, unsigned int *size);
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int
+mm_util_create(MMHandleType* MMHandle);
+
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+ * @param mode [in] User can use the accelerated image processing
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int
+mm_util_set_hardware_acceleration(MMHandleType MMHandle, bool mode);
+
+
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+ * @param colorspace [in] colorspace The colorspace of the destination image buffer
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int
+mm_util_set_colorspace_convert(MMHandleType MMHandle, mm_util_img_format colorspace);
+
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+ * @param width [in] width The width of destination image buffer
+ * @param height [in] height The height of destination image buffer
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int
+mm_util_set_resolution(MMHandleType MMHandle, unsigned int width, unsigned int height);
+
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+ * @param rotation [in] dest_rotation The rotation value of destination image buffer
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int
+mm_util_set_rotation(MMHandleType MMHandle, mm_util_img_rotate_type rotation);
+
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+ * @param start_x [in] The start x position of cropped image buffer
+ * @param start_y [in] The start y position of cropped image buffer
+ * @param end_x [in] The start x position of cropped image buffer
+ * @param end_y [in] The start y position of cropped image buffer
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+int
+mm_util_set_crop_area(MMHandleType MMHandle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y);
+
+/**
+ *
+ * @remark Transform Handle Creation
+ *
+ * @param MMHandle [in] MMHandleType pointer
+ * @param is_completed [in/out] Users can obtain the value of the conversion about whether to complete
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle creation succeed
+ * else if the result is -1, then handle creation failed
+ */
+
+int
+mm_transform_is_completed(MMHandleType MMHandle, bool *is_completed);
+
+/**
+ *
+ * @remark Image Transform Pipeline
+ *
+ * @param MMHandle [in] MMHandleType
+ * @param completed_callback [in] Completed_callback
+ * @param user_param [in] User parameter which is received from user when callback function was set
+
+ * @return This function returns transcode processor result value
+ * if the result is 0, then you can use output_Filename pointer(char** value)
+ * else if the result is -1, then do not execute when the colopsapce converter is not supported
+ */
+int
+mm_util_transform(MMHandleType MMHandle, media_packet_h src, mm_util_completed_callback completed_callback, void * user_data);
+
+
+/**
+ *
+ * @remark Transform Handle Destory
+ *
+ * @param MMHandle [in] MMHandleType
+
+ * @return This function returns transform processor result value
+ * if the result is 0, then handle destory succeed
+ * else if the result is -1, then handle destory failed
+ */
+int
+mm_util_destroy(MMHandleType MMHandle);
+
+
/**
* This function convert the pixel format from source format to destination format.
*
#endif
#endif /*__MM_UTILITY_IMGP_H__*/
-
#include <gmodule.h>
#include <mm_debug.h>
+#include <mm_types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+/* tbm */
+#include <tbm_surface_internal.h>
#define PATH_NEON_LIB LIBPREFIX "/libmmutil_imgp_neon.so"
#define PATH_GSTCS_LIB LIBPREFIX "/libmmutil_imgp_gstcs.so"
#define IMGP_FUNC_NAME "mm_imgp"
-#define IMAGE_FORMAT_LABEL_BUFFER_SIZE 9
#define IMGP_FREE(src) { if(src) {g_free(src); src = NULL;} }
+#define SCMN_IMGB_MAX_PLANE (4)
+#define MAX_SRC_BUF_NUM 12 /* Max number of upstream src plugins's buffer */
+#define MAX_DST_BUF_NUM 12
+#define SCMN_Y_PLANE 0
+#define SCMN_CB_PLANE 1
+#define SCMN_CR_PLANE 2
+#define MM_UTIL_DST_WIDTH_DEFAULT 0
+#define MM_UTIL_DST_WIDTH_MIN 0
+#define MM_UTIL_DST_WIDTH_MAX 32767
+#define MM_UTIL_DST_HEIGHT_DEFAULT 0
+#define MM_UTIL_DST_HEIGHT_MIN 0
+#define MM_UTIL_DST_HEIGHT_MAX 32767
+#define MM_UTIL_DST_BUFFER_MIN 2
+#define MM_UTIL_DST_BUFFER_DEFAULT 3
+#define MM_UTIL_DST_BUFFER_MAX 12
+#define MAX_IPP_EVENT_BUFFER_SIZE 1024
+
+/* macro for align ***********************************************************/
+#define ALIGN_TO_2B(x) ((((x) + (1 << 1) - 1) >> 1) << 1)
+#define ALIGN_TO_4B(x) ((((x) + (1 << 2) - 1) >> 2) << 2)
+#define ALIGN_TO_8B(x) ((((x) + (1 << 3) - 1) >> 3) << 3)
+#define ALIGN_TO_16B(x) ((((x) + (1 << 4) - 1) >> 4) << 4)
+#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
+#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
+#define ALIGN_TO_2KB(x) ((((x) + (1 << 11) - 1) >> 11) << 11)
+#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
+#define ALIGN_TO_64KB(x) ((((x) + (1 << 16) - 1) >> 16) << 16)
+
/**
* Image Process Info for dlopen
*/
typedef struct _imgp_info_s
{
- unsigned char *src;
char *input_format_label;
mm_util_img_format src_format;
unsigned int src_width;
unsigned int src_height;
- unsigned char *dst;
char *output_format_label;
mm_util_img_format dst_format;
unsigned int dst_width;
IMGP_NEON = 0,
IMGP_GSTCS,
} imgp_plugin_type_e;
-#ifdef __cplusplus
-}
-#endif
+typedef enum
+{
+ MM_UTIL_ROTATION_NONE = 0, /**< None */
+ MM_UTIL_ROTATION_90 = 1, /**< Rotation 90 degree */
+ MM_UTIL_ROTATION_180, /**< Rotation 180 degree */
+ MM_UTIL_ROTATION_270, /**< Rotation 270 degree */
+ MM_UTIL_ROTATION_FLIP_HORZ, /**< Flip horizontal */
+ MM_UTIL_ROTATION_FLIP_VERT, /**< Flip vertical */
+} mm_util_rotation_e;
+
+typedef struct
+{
+ void *user_data;
+ mm_util_completed_callback completed_cb;
+} mm_util_cb_s;
+
+typedef enum {
+ GEM_FOR_SRC = 0,
+ GEM_FOR_DST = 1,
+} ConvertGemCreateType;
+
+typedef enum {
+ MM_UTIL_IPP_CTRL_STOP = 0,
+ MM_UTIL_IPP_CTRL_START = 1,
+} ConvertIppCtrl;
+typedef struct
+{
+ gint drm_fd;
+ media_packet_h src_packet;
+ void *src;
+ mm_util_img_format src_format;
+ unsigned int src_width;
+ unsigned int src_height;
+ tbm_surface_h surface;
+ media_packet_h dst_packet;
+ void *dst;
+ mm_util_img_format dst_format;
+ media_format_mimetype_e dst_format_mime;
+ unsigned int start_x;
+ unsigned int start_y;
+ unsigned int dst_width;
+ unsigned int dst_height;
+ mm_util_rotation_e dst_rotation;
+
+ bool hardware_acceleration;
+ mm_util_cb_s *_util_cb;
+ bool is_completed;
+
+ tbm_bufmgr tbm;
+ tbm_bo src_bo;
+ unsigned int src_key;
+ tbm_bo_handle src_bo_handle;
+ tbm_bo dst_bo;
+ unsigned int dst_key;
+ tbm_bo_handle dst_bo_handle;
+
+ /* Src paramters */
+ guint src_buf_size; /**< for a standard colorspace format */
+ /* Dst paramters */
+ guint dst_buf_size;
+
+ /* Properties */
+
+ /* DRM/GEM information */
+ guint src_buf_idx;
+ guint dst_buf_idx;
+
+ /* for multi instance */
+ GMutex * instance_lock;
+ GMutex *fd_lock;
+ GMutex *buf_idx_lock;
+} mm_util_s;
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
#define GST "gstcs"
-typedef gboolean(*IMGPInfoFunc) (imgp_info_s*, imgp_plugin_type_e);
-/*########################################################################################*/
-#define setup_image_size_I420(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height) + MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height) /2); \
- return size; \
-}
-
-#define setup_image_size_Y42B(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width) * height + MM_UTIL_ROUND_UP_8 (width) * height); \
- return size; \
-}
-
-#define setup_image_size_Y444(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width) * height * 3); \
- return size; \
-}
-
-#define setup_image_size_UYVY(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_2 (width) * 2 * height); \
- return size; \
-}
-
-#define setup_image_size_YUYV(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_2 (width) * 2 * height); \
- return size; \
-}
-
-#define setup_image_size_YV12(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height)+ MM_UTIL_ROUND_UP_8 (width) * MM_UTIL_ROUND_UP_2 (height) / 2); \
- return size; \
-}
-
-#define setup_image_size_NV12(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height) *1.5); \
- return size; \
-}
-
-#define setup_image_size_RGB565(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width * 2) *height); \
- return size; \
-}
-
-#define setup_image_size_RGB888(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width*3) * height); \
- return size; \
-}
-
-#define setup_image_size_BGR888(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_4 (width*3) * height); \
- return size; \
-}
-
-#define setup_image_size_SN12(width, height) { \
- int size=0; \
- size = MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height) *1.5; \
- return size; \
-}
-
-#define setup_image_size_ST12(width, height) { \
- int size=0; \
- size = MM_UTIL_ROUND_UP_4 (width) * MM_UTIL_ROUND_UP_2 (height) *1.5; \
- return size; \
-}
-
-#define setup_image_size_UYVY(width, height) { \
- int size=0; \
- size = (MM_UTIL_ROUND_UP_2 (width) * 2 * height); \
- return size; \
-}
-
-#define setup_image_size_BGRX888(width, height) { \
- int size=0; \
- size = MM_UTIL_ROUND_UP_4 (width*3) * height); \
- return size; \
-}
-
-/*########################################################################################*/
+typedef gboolean(*IMGPInfoFunc) (imgp_info_s*, const unsigned char*, unsigned char*, imgp_plugin_type_e);
static int
check_valid_picture_size(int width, int height)
return MM_ERROR_IMAGE_INVALID_VALUE;
}
-static int
-_mm_setup_image_size(const char* _format_label, int width, int height)
-{
- int size=0;
- if(strcmp(_format_label, "I420") == 0) {
- setup_image_size_I420(width, height); /* width * height *1.5; */
- }else if(strcmp(_format_label, "Y42B") == 0) {
- setup_image_size_Y42B(width, height); /* width * height *2; */
- }else if(strcmp(_format_label, "YUV422") == 0) {
- setup_image_size_Y42B(width, height); /* width * height *2; */
- }else if(strcmp(_format_label, "Y444") == 0) {
- setup_image_size_Y444(width, height); /* width * height *3; */
- }else if(strcmp(_format_label, "YV12") == 0) {
- setup_image_size_YV12(width, height); /* width * height *1.5; width must be 8 multiple */
- }else if(strcmp(_format_label, "NV12") == 0) {
- setup_image_size_NV12(width, height) /* width * height *1.5; */
- }else if(strcmp(_format_label, "ST12") == 0) {
- setup_image_size_ST12(width, height); /* width * height *1.5; */
- }else if(strcmp(_format_label, "SN12") == 0) {
- setup_image_size_SN12(width, height) /* width * height *1.5; */
- }else if(strcmp(_format_label, "UYVY") == 0) {
- setup_image_size_UYVY(width, height); /* width * height *2; */
- }else if(strcmp(_format_label, "YUYV") == 0) {
- setup_image_size_YUYV(width, height); /* width * height *2; */
- }else if(strcmp(_format_label, "RGB565") == 0) {
- setup_image_size_RGB565(width, height); /* width * height *2; */
- }else if(strcmp(_format_label, "RGB888") == 0) {
- setup_image_size_RGB888(width, height); /* width * height *3; */
- }else if(strcmp(_format_label, "BGR888") == 0) {
- setup_image_size_BGR888(width, height);/* width * height *3; */
- }else if(strcmp(_format_label, "ARGB8888") == 0) {
- size = width * height *4; debug_log("file_size: %d\n", size);
- }else if(strcmp(_format_label, "BGRA8888") == 0) {
- size = width * height *4; debug_log("file_size: %d\n", size);
- }else if(strcmp(_format_label, "RGBA8888") == 0) {
- size = width * height *4; debug_log("file_size: %d\n", size);
- }else if(strcmp(_format_label, "ABGR8888") == 0) {
- size = width * height *4; debug_log("file_size: %d\n", size);
- }else if(strcmp(_format_label, "BGRX") == 0) {
- size = width * height *4; debug_log("file_size: %d\n", size);
- }
- return size;
-}
-
static gboolean
_mm_cannot_convert_format(mm_util_img_format src_format, mm_util_img_format dst_format )
{
gboolean _bool=FALSE;
- debug_log("src_format: %d, dst_format:%d", src_format, dst_format);
- if(((src_format == MM_UTIL_IMG_FMT_YUV422) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ debug_log("src_format: %d, dst_format:%d", src_format, dst_format);
+ if((dst_format == MM_UTIL_IMG_FMT_NV16) || (dst_format == MM_UTIL_IMG_FMT_NV61) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUV422) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+
+ ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ ((src_format == MM_UTIL_IMG_FMT_BGRX8888) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_BGRX8888) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUV422)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_UYVY)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUYV)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRX8888)) ) {
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUV422)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_UYVY)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUYV)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRX8888)) ) {
_bool = TRUE;
}
gboolean _bool = FALSE;
debug_log("Format label: %s",__format_label);
if(strcmp(__format_label, "AYUV") == 0
- || strcmp(__format_label, "UYVY") == 0 ||strcmp(__format_label, "Y800") == 0 || strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0
+ || strcmp(__format_label, "I420") == 0 || strcmp(__format_label, "YV12") == 0
|| strcmp(__format_label, "RGB888") == 0 || strcmp(__format_label, "RGB565") == 0 || strcmp(__format_label, "BGR888") == 0 || strcmp(__format_label, "RGBA8888") == 0
|| strcmp(__format_label, "ARGB8888") == 0 ||strcmp(__format_label, "BGRA8888") == 0 ||strcmp(__format_label, "ABGR8888") == 0 ||strcmp(__format_label, "RGBX") == 0
- ||strcmp(__format_label, "XRGB") == 0 ||strcmp(__format_label, "BGRX") == 0 ||strcmp(__format_label, "XBGR") == 0 ||strcmp(__format_label, "Y444") == 0
- ||strcmp(__format_label, "Y42B") == 0 ||strcmp(__format_label, "YUY2") == 0 ||strcmp(__format_label, "YUYV") == 0 ||strcmp(__format_label, "UYVY") == 0
- ||strcmp(__format_label, "Y41B") == 0 ||strcmp(__format_label, "Y16") == 0 ||strcmp(__format_label, "Y800") == 0 ||strcmp(__format_label, "Y8") == 0
- ||strcmp(__format_label, "GREY") == 0 ||strcmp(__format_label, "AY64") == 0 || strcmp(__format_label, "YUV422") == 0) {
+ || strcmp(__format_label, "XRGB") == 0 ||strcmp(__format_label, "BGRX") == 0 ||strcmp(__format_label, "XBGR") == 0 ||strcmp(__format_label, "Y444") == 0
+ || strcmp(__format_label, "Y42B") == 0 ||strcmp(__format_label, "YUY2") == 0 ||strcmp(__format_label, "YUYV") == 0 ||strcmp(__format_label, "UYVY") == 0
+ || strcmp(__format_label, "Y41B") == 0 ||strcmp(__format_label, "Y16") == 0 ||strcmp(__format_label, "Y800") == 0 ||strcmp(__format_label, "Y8") == 0
+ || strcmp(__format_label, "GREY") == 0 ||strcmp(__format_label, "AY64") == 0 || strcmp(__format_label, "YUV422") == 0) {
_bool=TRUE;
}
_mm_select_convert_plugin(mm_util_img_format src_format, mm_util_img_format dst_format )
{
gboolean _bool=FALSE;
- debug_log("src_format: %d, dst_format:%d", src_format, dst_format);
- if(((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) || ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) || ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ debug_log("src_format: %d, dst_format:%d", src_format, dst_format);
+ if(((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) || ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) || ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUV420) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) || ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) || ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
+ ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
+ ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) || ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) || ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_I420) && (dst_format == MM_UTIL_IMG_FMT_NV12_TILED)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) || ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) || ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) || ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) || ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) || ((src_format == MM_UTIL_IMG_FMT_UYVY) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) || ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) || ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) || ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_YUYV) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
-
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
+ ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_RGB565) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
- ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888))) {
+ ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_RGB888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
+
+ ((src_format == MM_UTIL_IMG_FMT_ARGB8888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_ARGB8888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_ARGB8888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
+
+ ((src_format == MM_UTIL_IMG_FMT_BGRA8888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_BGRA8888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_BGRA8888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) ||
+
+ ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_RGBA8888) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
+
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_YUV420)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_I420)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_NV12)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGB565)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGB888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_ARGB8888)) || ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_BGRA8888)) ||
+ ((src_format == MM_UTIL_IMG_FMT_NV12_TILED) && (dst_format == MM_UTIL_IMG_FMT_RGBA8888))) {
_bool = TRUE;
}
debug_log("_format: %d (angle: %d)", _format, angle);
if((_format == MM_UTIL_IMG_FMT_YUV420) || (_format == MM_UTIL_IMG_FMT_I420) || (_format == MM_UTIL_IMG_FMT_NV12)
- ||(( _format == MM_UTIL_IMG_FMT_RGB888 ||_format == MM_UTIL_IMG_FMT_RGB565) && angle == MM_UTIL_ROTATE_90)) { /* constraint of image processing because MM_UTIL_ROTATE_180 may be twice MM_UTIL_ROTATE_90 */
+ ||(_format == MM_UTIL_IMG_FMT_RGB888 ||_format == MM_UTIL_IMG_FMT_RGB565)) {
return TRUE;
}
}
static int
-_mm_set_format_label(char* format_label, mm_util_img_format _format)
+_mm_set_format_label(imgp_info_s * _imgp_info_s, mm_util_img_format src_format, mm_util_img_format dst_format)
{
int ret = MM_ERROR_NONE;
- if(format_label == NULL) {
- debug_error("format_label: %s", format_label);
+ char *src_fmt_lable = NULL;
+ char *dst_fmt_lable = NULL;
+ if(_imgp_info_s == NULL) {
+ debug_error("_imgp_info_s: 0x%2x", _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if(_format == MM_UTIL_IMG_FMT_YUV420) {
- strncpy(format_label, "YV12", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format == MM_UTIL_IMG_FMT_YUV422) {
- strncpy(format_label, "Y42B", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format == MM_UTIL_IMG_FMT_I420) {
- strncpy(format_label, "I420", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format == MM_UTIL_IMG_FMT_NV12) {
- strncpy(format_label, "NV12", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format == MM_UTIL_IMG_FMT_UYVY) {
- strncpy(format_label, "UYVY", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format == MM_UTIL_IMG_FMT_YUYV) {
- strncpy(format_label, "YUYV", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_RGB565) {
- strncpy(format_label, "RGB565", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_RGB888) {
- strncpy(format_label, "RGB888", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_ARGB8888) {
- strncpy(format_label, "ARGB8888", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_BGRA8888) {
- strncpy(format_label, "BGRA8888", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_RGBA8888) {
- strncpy(format_label, "RGBA8888", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_BGRX8888) {
- strncpy(format_label, "BGRX", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else if(_format ==MM_UTIL_IMG_FMT_NV12_TILED) {
- strncpy(format_label, "NV12T", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- }else {
- debug_error("ERROR - You check mm_util_img_format");
+ switch(src_format) {
+ case MM_UTIL_IMG_FMT_YUV420:
+ src_fmt_lable = "YV12";
+ break;
+ case MM_UTIL_IMG_FMT_YUV422:
+ src_fmt_lable = "Y42B";
+ break;
+ case MM_UTIL_IMG_FMT_I420:
+ src_fmt_lable = "I420";
+ break;
+ case MM_UTIL_IMG_FMT_NV12:
+ src_fmt_lable = "NV12";
+ break;
+ case MM_UTIL_IMG_FMT_UYVY:
+ src_fmt_lable = "UYVY";
+ break;
+ case MM_UTIL_IMG_FMT_YUYV:
+ src_fmt_lable = "YUYV";
+ break;
+ case MM_UTIL_IMG_FMT_RGB565:
+ src_fmt_lable = "RGB565";
+ break;
+ case MM_UTIL_IMG_FMT_RGB888:
+ src_fmt_lable = "RGB888";
+ break;
+ case MM_UTIL_IMG_FMT_ARGB8888:
+ src_fmt_lable = "ARGB8888";
+ break;
+ case MM_UTIL_IMG_FMT_BGRA8888:
+ src_fmt_lable = "BGRA8888";
+ break;
+ case MM_UTIL_IMG_FMT_RGBA8888:
+ src_fmt_lable = "RGBA8888";
+ break;
+ case MM_UTIL_IMG_FMT_BGRX8888:
+ src_fmt_lable = "BGRX";
+ break;
+ default:
+ debug_log("[%d] Not supported format", src_fmt_lable);
+ break;
}
- debug_log("format_label: %s", format_label);
+ switch(dst_format) {
+ case MM_UTIL_IMG_FMT_YUV420:
+ dst_fmt_lable = "YV12";
+ break;
+ case MM_UTIL_IMG_FMT_YUV422:
+ dst_fmt_lable = "Y42B";
+ break;
+ case MM_UTIL_IMG_FMT_I420:
+ dst_fmt_lable = "I420";
+ break;
+ case MM_UTIL_IMG_FMT_NV12:
+ dst_fmt_lable = "NV12";
+ break;
+ case MM_UTIL_IMG_FMT_UYVY:
+ dst_fmt_lable = "UYVY";
+ break;
+ case MM_UTIL_IMG_FMT_YUYV:
+ dst_fmt_lable = "YUYV";
+ break;
+ case MM_UTIL_IMG_FMT_RGB565:
+ dst_fmt_lable = "RGB565";
+ break;
+ case MM_UTIL_IMG_FMT_RGB888:
+ dst_fmt_lable = "RGB888";
+ break;
+ case MM_UTIL_IMG_FMT_ARGB8888:
+ dst_fmt_lable = "ARGB8888";
+ break;
+ case MM_UTIL_IMG_FMT_BGRA8888:
+ dst_fmt_lable = "BGRA8888";
+ break;
+ case MM_UTIL_IMG_FMT_RGBA8888:
+ dst_fmt_lable = "RGBA8888";
+ break;
+ case MM_UTIL_IMG_FMT_BGRX8888:
+ dst_fmt_lable = "BGRX";
+ break;
+ default:
+ debug_error("[%d] Not supported format", dst_format);
+ break;
+ }
+
+ if(src_fmt_lable && dst_fmt_lable) {
+ debug_log("src_fmt_lable: %s dst_fmt_lable: %s", src_fmt_lable, dst_fmt_lable);
+ _imgp_info_s->input_format_label = (char*)malloc(strlen(src_fmt_lable) + 1);
+ if(_imgp_info_s->input_format_label == NULL) {
+ debug_error("[input] input_format_label is null");
+ return MM_ERROR_IMAGE_NO_FREE_SPACE;
+ }
+ memset(_imgp_info_s->input_format_label, 0, strlen(src_fmt_lable) + 1);
+ strncpy(_imgp_info_s->input_format_label, src_fmt_lable, strlen(src_fmt_lable));
+
+ _imgp_info_s->output_format_label = (char*)malloc(strlen(dst_fmt_lable) + 1);
+ if(_imgp_info_s->output_format_label == NULL) {
+ debug_error("[input] input_format_label is null");
+ IMGP_FREE(_imgp_info_s->input_format_label);
+ return MM_ERROR_IMAGE_NO_FREE_SPACE;
+ }
+ memset(_imgp_info_s->output_format_label, 0, strlen(dst_fmt_lable) + 1);
+ strncpy(_imgp_info_s->output_format_label, dst_fmt_lable, strlen(dst_fmt_lable));
+
+ debug_log("input_format_label: %s output_format_label: %s", _imgp_info_s->input_format_label, _imgp_info_s->output_format_label);
+ }else {
+ debug_error("[error] src_fmt_lable && dst_fmt_lable");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
return ret;
}
static int
-_mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, unsigned char *src, mm_util_img_format src_format, unsigned int src_width, unsigned int src_height, mm_util_img_format dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
+_mm_set_imgp_info_s(imgp_info_s * _imgp_info_s, mm_util_img_format src_format, unsigned int src_width, unsigned int src_height, mm_util_img_format dst_format, unsigned int dst_width, unsigned int dst_height, mm_util_img_rotate_type angle)
{
int ret = MM_ERROR_NONE;
- if(_imgp_info_s == NULL || src == NULL) {
- debug_error("_imgp_info_s || src is NULL");
+ if(_imgp_info_s == NULL) {
+ debug_error("_imgp_info_s is NULL");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- unsigned int src_size=0;
- unsigned int src_real_size=0;
- unsigned int dst_size=0;
-
- char input_format_label[IMAGE_FORMAT_LABEL_BUFFER_SIZE];
- char output_format_label[IMAGE_FORMAT_LABEL_BUFFER_SIZE];
-
- ret=_mm_set_format_label(input_format_label, src_format);
+ ret=_mm_set_format_label(_imgp_info_s, src_format, dst_format);
if(ret != MM_ERROR_NONE) {
debug_error("[input] mm_set_format_label error");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret=_mm_set_format_label(output_format_label, dst_format);
- if(ret != MM_ERROR_NONE) {
- debug_error("[output] mm_set_format_label error");
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
-
- _imgp_info_s->input_format_label = (char*)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- if(_imgp_info_s->input_format_label == NULL) {
- debug_error("[output] input_format_label is null");
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
-
- memset(_imgp_info_s->input_format_label, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- strncpy(_imgp_info_s->input_format_label, input_format_label, strlen(input_format_label));
- debug_log("[_imgp_info_s->input_format_label] %s", _imgp_info_s->input_format_label);
- mm_util_get_image_size(src_format, src_width, src_height, &src_size);
- if(src_size != _mm_setup_image_size(input_format_label, src_width, src_height)) {
- debug_error("src image size error");
- }
- _imgp_info_s->src=(unsigned char*)malloc(sizeof(unsigned char) * src_size);
- if(_imgp_info_s->src == NULL) {
- debug_error("_imgp_info_s->src is NULL");
- IMGP_FREE(_imgp_info_s->input_format_label);
- return MM_ERROR_IMAGE_FILEOPEN;
- }
-
- if(src_format == MM_UTIL_IMG_FMT_RGB888 && src_width % 4 != 0) { /* Because there is difference between jpeg-turbo and gstreamer in RGB */
- src_real_size = src_width * src_height * 3;
- } else {
- src_real_size = src_size;
- }
-
- debug_log("[memcpy] src_size: %d src_real_size: %d\n", src_size, src_real_size);
- memcpy(_imgp_info_s->src, src, src_real_size);
- debug_log("[memcpy] #Success#");
_imgp_info_s->src_format=src_format;
_imgp_info_s->src_width = src_width;
_imgp_info_s->src_height= src_height;
- _imgp_info_s->output_format_label = (char*)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- if(_imgp_info_s->output_format_label == NULL) {
- IMGP_FREE(_imgp_info_s->input_format_label);
- IMGP_FREE(_imgp_info_s->src);
- debug_error("[output] input_format_label is null");
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
-
- memset(_imgp_info_s->output_format_label, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- strncpy(_imgp_info_s->output_format_label, output_format_label, strlen(output_format_label));
- debug_log("[_imgp_info_s->input_format_label] %s", _imgp_info_s->input_format_label);
- mm_util_get_image_size(dst_format, dst_width, dst_height, &dst_size);
- if(dst_size != _mm_setup_image_size(output_format_label,dst_width, dst_height)) {
- debug_error("dst image size error");
- }
- debug_log("dst_size: %d\n", dst_size);
- _imgp_info_s->dst=(unsigned char*)malloc(sizeof(unsigned char) * dst_size);
- if(_imgp_info_s->dst == NULL) {
- debug_error("_imgp_info_s->src is NULL");
- IMGP_FREE(_imgp_info_s->input_format_label);
- IMGP_FREE(_imgp_info_s->src);
- IMGP_FREE(_imgp_info_s->output_format_label);
- return MM_ERROR_IMAGE_FILEOPEN;
- }
_imgp_info_s->dst_format=dst_format;
_imgp_info_s->dst_width = dst_width;
_imgp_info_s->dst_height = dst_height;
_imgp_info_s->angle= angle;
- debug_log("[input] format label: %s src: %p width: %d height: %d [output] format label: %s width: %d height: %d rotation_value: %d",
- _imgp_info_s->input_format_label, _imgp_info_s->src, _imgp_info_s->src_width, _imgp_info_s->src_height,
+ debug_log("[input] format label: %s width: %d height: %d [output] format label: %s width: %d height: %d rotation_value: %d",
+ _imgp_info_s->input_format_label, _imgp_info_s->src_width, _imgp_info_s->src_height,
_imgp_info_s->output_format_label, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->angle);
return ret;
debug_error("%s | %s module open failed", PATH_NEON_LIB, PATH_GSTCS_LIB);
return NULL;
}
- debug_log("module: %p, g_module_name: %s", module, g_module_name (module));
+ debug_log("module: %p, g_module_name: %s", module, g_module_name (module));
return module;
}
module = NULL;
}else {
debug_error("#module is NULL#");
- return MM_ERROR_IMAGE_INVALID_VALUE;
+ ret = MM_ERROR_IMAGE_INVALID_VALUE;
}
- if(_imgp_info_s) {
- IMGP_FREE(_imgp_info_s->src);
- debug_log("#Success _imgp_info_s->src#");
- IMGP_FREE(_imgp_info_s->dst);
- debug_log("#Success _imgp_info_s->dst#");
- IMGP_FREE(_imgp_info_s);
- debug_log("#Success _imgp_info_s#");
- }else {
- debug_error("#_imgp_info_s is NULL#");
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
+ IMGP_FREE(_imgp_info_s->input_format_label);
+ IMGP_FREE(_imgp_info_s->output_format_label);
+ IMGP_FREE(_imgp_info_s);
+
return ret;
}
static int
-_mm_util_crop_rgba32(unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+_mm_util_crop_rgba32(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
}
static int
-_mm_util_crop_rgb888(unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+_mm_util_crop_rgb888(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
}
static int
-_mm_util_crop_rgb565(unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+_mm_util_crop_rgb565(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
}
static int
-_mm_util_crop_yuv420(unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
+_mm_util_crop_yuv420(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format,
unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
{
int ret = MM_ERROR_NONE;
int start_y = crop_start_y;
debug_log("[Input] src: 0x%2x src, src_width: %d src_height: %d src_format: %d crop_start_x: %d crop_start_y: %d crop_dest_width: %d crop_dest_height: %d\n",
src, src_width, src_height, src_format, crop_start_x, crop_start_y, crop_dest_width, crop_dest_height);
- unsigned char *_src = src + start_y * src_width + start_x;
+ const unsigned char *_src = src + start_y * src_width + start_x;
/* Y */
for (i = 0; i < crop_dest_height; i++) {
return ret;
}
+static bool
+_mm_util_check_resolution(unsigned int width, unsigned int height)
+{
+ if(width == 0)
+ {
+ debug_error("invalid width [%d]", width);
+ return false;
+ }
+
+ if(height == 0)
+ {
+ debug_error("invalid height [%d]", height);
+ return false;
+ }
+
+ return true;
+}
+
+static int
+_mm_util_handle_init(mm_util_s *handle)
+{
+ int ret = MM_ERROR_NONE;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ /* private values init */
+ handle->src = 0;
+ handle->dst = 0;
+ handle->drm_fd = -1;
+ handle->dst_format = -1;
+ handle->dst_format_mime = -1;
+ handle->src_buf_idx = 0;
+ handle->dst_buf_idx = 0;
+
+ handle->start_x = -1;
+ handle->start_y = -1;
+ handle->is_completed = FALSE;
+
+ return ret;
+}
+
+
+media_format_mimetype_e
+_mm_util_mapping_imgp_format_to_mime(mm_util_img_format format)
+{
+ media_format_mimetype_e mimetype = -1;
+
+ switch(format) {
+ case MM_UTIL_IMG_FMT_NV12 :
+ mimetype = MEDIA_FORMAT_NV12;
+ break;
+ case MM_UTIL_IMG_FMT_NV16 :
+ mimetype = MEDIA_FORMAT_NV16;
+ break;
+ case MM_UTIL_IMG_FMT_YUYV :
+ mimetype = MEDIA_FORMAT_YUYV;
+ break;
+ case MM_UTIL_IMG_FMT_UYVY :
+ mimetype = MEDIA_FORMAT_UYVY;
+ break;
+ case MM_UTIL_IMG_FMT_YUV422 :
+ mimetype = MEDIA_FORMAT_422P;
+ break;
+ case MM_UTIL_IMG_FMT_I420 :
+ mimetype = MEDIA_FORMAT_I420;
+ break;
+ case MM_UTIL_IMG_FMT_YUV420 :
+ mimetype = MEDIA_FORMAT_YV12;
+ break;
+ case MM_UTIL_IMG_FMT_RGB565 :
+ mimetype = MEDIA_FORMAT_RGB565;
+ break;
+ case MM_UTIL_IMG_FMT_RGB888 :
+ mimetype = MEDIA_FORMAT_RGB888;
+ break;
+ case MM_UTIL_IMG_FMT_RGBA8888 :
+ mimetype = MEDIA_FORMAT_RGBA;
+ break;
+ case MM_UTIL_IMG_FMT_ARGB8888 :
+ mimetype = MEDIA_FORMAT_ARGB;
+ break;
+ case MM_UTIL_IMG_FMT_BGRA8888 :
+ case MM_UTIL_IMG_FMT_BGRX8888 :
+ case MM_UTIL_IMG_FMT_NV61 :
+ case MM_UTIL_IMG_FMT_NUM :
+ mimetype = -1;
+ debug_error("Not Supported Format");
+ break;
+ case MM_UTIL_IMG_FMT_NV12_TILED :
+ mimetype = MEDIA_FORMAT_NV12T;
+ break;
+ }
+
+ debug_log("imgp fmt: %d mimetype fmt: %d", format, mimetype);
+ return mimetype;
+}
+
+mm_util_img_format
+_mm_util_mapping_mime_format_to_imgp(media_format_mimetype_e mimetype)
+{
+ mm_util_img_format format = -1;
+
+ switch(mimetype) {
+ case MEDIA_FORMAT_NV12 :
+ format = MM_UTIL_IMG_FMT_NV12;
+ break;
+ case MEDIA_FORMAT_NV16 :
+ format = MM_UTIL_IMG_FMT_NV16;
+ break;
+ case MEDIA_FORMAT_YUYV :
+ format = MM_UTIL_IMG_FMT_YUYV;
+ break;
+ case MEDIA_FORMAT_UYVY :
+ format = MM_UTIL_IMG_FMT_UYVY;
+ break;
+ case MEDIA_FORMAT_422P :
+ format = MM_UTIL_IMG_FMT_YUV422;
+ break;
+ case MEDIA_FORMAT_I420 :
+ format = MM_UTIL_IMG_FMT_I420;
+ break;
+ case MEDIA_FORMAT_YV12 :
+ format = MM_UTIL_IMG_FMT_YUV420;
+ break;
+ case MEDIA_FORMAT_RGB565 :
+ format = MM_UTIL_IMG_FMT_RGB565;
+ break;
+ case MEDIA_FORMAT_RGB888 :
+ format = MM_UTIL_IMG_FMT_RGB888;
+ break;
+ case MEDIA_FORMAT_RGBA :
+ format = MM_UTIL_IMG_FMT_RGBA8888;
+ break;
+ case MEDIA_FORMAT_ARGB :
+ format = MM_UTIL_IMG_FMT_ARGB8888;
+ break;
+ case MEDIA_FORMAT_NV21 :
+ case MEDIA_FORMAT_H261 :
+ case MEDIA_FORMAT_H263 :
+ case MEDIA_FORMAT_H263P :
+ case MEDIA_FORMAT_H264_SP :
+ case MEDIA_FORMAT_H264_MP :
+ case MEDIA_FORMAT_H264_HP :
+ case MEDIA_FORMAT_MJPEG :
+ case MEDIA_FORMAT_MPEG1 :
+ case MEDIA_FORMAT_MPEG2_SP :
+ case MEDIA_FORMAT_MPEG2_MP :
+ case MEDIA_FORMAT_MPEG2_HP :
+ case MEDIA_FORMAT_MPEG4_SP :
+ case MEDIA_FORMAT_MPEG4_ASP :
+ case MEDIA_FORMAT_L16:
+ case MEDIA_FORMAT_PCM :
+ case MEDIA_FORMAT_PCMA :
+ case MEDIA_FORMAT_ALAW :
+ case MEDIA_FORMAT_PCMU :
+ case MEDIA_FORMAT_ULAW :
+ case MEDIA_FORMAT_AMR :
+ case MEDIA_FORMAT_G729 :
+ case MEDIA_FORMAT_AAC:
+ case MEDIA_FORMAT_MP3:
+ case MEDIA_FORMAT_MAX :
+ format = -1;
+ debug_error("Not Supported Format");
+ break;
+ case MEDIA_FORMAT_NV12T :
+ format = MM_UTIL_IMG_FMT_NV12_TILED;
+ break;
+ }
+ debug_log("mimetype: %d imgp fmt: %d", mimetype, format);
+ return format;
+}
+
+bool
+_mm_transform_completed_cb(media_packet_h *dst, int error, void *user_param)
+{
+ if (!user_param) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ mm_util_s * handle = (mm_util_s *)user_param;
+ if(error == MM_ERROR_NONE) {
+ handle->is_completed = TRUE;
+ debug_log("completed");
+ } else {
+ debug_error("[ERROR] complete cb");
+ }
+
+ return TRUE;
+}
+
+int _mm_util_processing(mm_util_s *handle)
+{
+ int ret = MM_ERROR_NONE;
+
+ if(handle == NULL) {
+ debug_error ("Invalid arguments [tag null]\n");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(handle->src_packet == NULL) {
+ debug_error ("[src] media_packet_h");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(handle->dst_packet == NULL) {
+ debug_error ("[dst] media_packet_h");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(handle->src_buf_size) {
+ handle->src = NULL;
+ if(media_packet_get_buffer_data_ptr(handle->src_packet, &handle->src) != MM_ERROR_NONE) {
+ debug_error ("[src] media_packet_get_extra");
+ IMGP_FREE(handle->src);
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ debug_log("src buffer pointer: %p", handle->src);
+ }
+
+ if(handle->dst_buf_size) {
+ handle->dst = NULL;
+ if(media_packet_get_buffer_data_ptr(handle->dst_packet, &handle->dst) != MM_ERROR_NONE) {
+ IMGP_FREE(handle->src);
+ IMGP_FREE(handle->dst);
+ debug_error ("[dst] media_packet_get_extra");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ }
+
+ debug_log("src: %p, dst: %p", handle->src, handle->dst);
+
+ if(handle->src_format == handle->dst_format) {
+ if((handle->src_width == handle->dst_width) && (handle->src_height == handle->dst_height)) {
+ if(handle->dst_rotation !=MM_UTIL_ROTATION_NONE) {
+ ret = mm_util_rotate_image(handle->src, handle->src_width, handle->src_height,handle->src_format, handle->dst, &handle->dst_width, &handle->dst_height, handle->dst_rotation);
+ if (ret != MM_ERROR_NONE) {
+ IMGP_FREE(handle->src);
+ IMGP_FREE(handle->dst);
+ debug_error("mm_util_rotate_image failed");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+ } else {
+ IMGP_FREE(handle->src);
+ IMGP_FREE(handle->dst);
+ debug_error("[Error] rotate info");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ } else {
+ ret = mm_util_resize_image(handle->src, handle->src_width, handle->src_height,handle->src_format, handle->dst, &handle->dst_width, &handle->dst_height);
+ if (ret != MM_ERROR_NONE) {
+ debug_error("mm_util_resize_image failed");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+ }
+ } else if(handle->src_format != handle->dst_format){
+ if((handle->src_width == handle->dst_width) && (handle->src_height == handle->dst_height)) {
+ if(handle->start_x == -1 && handle->start_y == -1) {
+ ret = mm_util_convert_colorspace(handle->src, handle->src_width, handle->src_height,handle->src_format, handle->dst, handle->dst_format);
+ if (ret != MM_ERROR_NONE) {
+ IMGP_FREE(handle->src);
+ IMGP_FREE(handle->dst);
+ debug_error("mm_util_convert_colorspace failed");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+ } else {
+ ret = mm_util_crop_image(handle->src, handle->src_width, handle->src_height, handle->src_format,
+ handle->start_x, handle->start_y, &handle->dst_width, &handle->dst_height, handle->dst);
+ if (ret != MM_ERROR_NONE) {
+ IMGP_FREE(handle->src);
+ IMGP_FREE(handle->dst);
+ debug_error("mm_util_convert_colorspace failed");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+ }
+ } else {
+ IMGP_FREE(handle->src);
+ IMGP_FREE(handle->dst);
+ debug_error("[Error] Not supported");
+ return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ }
+ }
+
+ debug_log("End processing");
+ return ret;
+}
+
+static int
+_mm_util_handle_finalize(mm_util_s *handle)
+{
+ int ret = MM_ERROR_NONE;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ return ret;
+}
+
+int
+mm_util_create(MMHandleType* MMHandle)
+{
+ int ret = MM_ERROR_NONE;
+
+ if(MMHandle == NULL) {
+ debug_error ("Invalid arguments [tag null]\n");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ mm_util_s *_handle = calloc(1,sizeof(mm_util_s));
+ if (!_handle) {
+ debug_error("[ERROR] - _handle");
+ ret = MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ ret = _mm_util_handle_init (_handle);
+ if(ret != MM_ERROR_NONE) {
+ debug_error("_mm_util_handle_init failed");
+ IMGP_FREE(_handle);
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ *MMHandle = (MMHandleType)_handle;
+
+ return ret;
+}
+
+int
+mm_util_set_hardware_acceleration(MMHandleType MMHandle, bool mode)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ handle->hardware_acceleration = mode;
+
+ return ret;
+}
+
+int
+mm_util_set_colorspace_convert(MMHandleType MMHandle, mm_util_img_format colorspace)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ handle->dst_format = colorspace;
+ handle->dst_format_mime = _mm_util_mapping_imgp_format_to_mime(colorspace);
+ debug_log("imgp fmt: %d mimetype: %d", handle->dst_format, handle->dst_format_mime);
+
+ return ret;
+}
+
+int
+mm_util_set_resolution(MMHandleType MMHandle, unsigned int width, unsigned int height)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ handle->dst_width = width;
+ handle->dst_height = height;
+
+ return ret;
+}
+
+int
+mm_util_set_rotation(MMHandleType MMHandle, mm_util_img_rotate_type rotation)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ if(rotation == MM_UTIL_ROTATE_0 || rotation == MM_UTIL_ROTATE_180 || rotation == MM_UTIL_ROTATE_FLIP_HORZ || rotation == MM_UTIL_ROTATE_FLIP_VERT) {
+ handle->dst_width = handle->src_width;
+ handle->dst_height = handle->src_height;
+ } else if(rotation == MM_UTIL_ROTATE_90 || rotation == MM_UTIL_ROTATE_270) {
+ handle->dst_width = handle->src_height;
+ handle->dst_height = handle->src_width;
+ }
+
+ handle->dst_rotation = rotation;
+
+ return ret;
+}
+
+int
+mm_util_set_crop_area(MMHandleType MMHandle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+
+ unsigned int dest_width = end_x -start_x;
+ unsigned int dest_height = end_y - start_y;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ handle->start_x = start_x;
+ handle->start_y = start_y;
+ handle->dst_width = dest_width;
+ handle->dst_height = dest_height;
+
+ return ret;
+}
+
+int
+mm_util_transform(MMHandleType MMHandle, media_packet_h src_packet, mm_util_completed_callback completed_callback, void * user_data)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+ media_format_h src_fmt;
+ media_format_h dst_fmt;
+ media_format_mimetype_e src_mimetype;
+ int src_width, src_height, src_avg_bps, src_max_bps;
+ uint64_t size = 0;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INTERNAL;
+ }
+
+ if(!src_packet) {
+ debug_error("[ERROR] - src_packet");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ } else {
+ debug_log("src: %p", src_packet);
+ }
+
+ if(!completed_callback) {
+ debug_error("[ERROR] - completed_callback");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ handle->_util_cb = (mm_util_cb_s *)malloc(sizeof(mm_util_cb_s));
+ if(handle->_util_cb) {
+ handle->_util_cb->completed_cb= completed_callback;
+ handle->_util_cb->user_data = user_data;
+ } else {
+ debug_error("[ERROR] _util_cb_s");
+ }
+
+ if(media_packet_get_format(src_packet, &src_fmt) != MM_ERROR_NONE) {
+ debug_error("Imedia_packet_get_format)");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_get_video_info(src_fmt, &src_mimetype, &src_width, &src_height, &src_avg_bps, &src_max_bps) == MEDIA_FORMAT_ERROR_NONE) {
+ debug_log("[Fotmat: %d] W x H : %d x %d", src_mimetype, src_width, src_height);
+ }
+
+ if(_mm_util_check_resolution(src_width, src_height)) {
+ /* src */
+ handle->src_packet = src_packet;
+ debug_log("src_packet: %p handle->src_packet: %p 0x%2x [W X H] %d X %d", src_packet, handle->src_packet, src_fmt, src_width, src_height);
+ if(handle->src_packet) {
+ handle->src_format = _mm_util_mapping_mime_format_to_imgp(src_mimetype);
+ handle->src_width = src_width;
+ handle->src_height = src_height;
+ } else {
+ debug_error("[Error] handle->src");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+
+ if(media_packet_get_buffer_size(handle->src_packet, &size) == MM_ERROR_NONE) {
+ handle->src_buf_size = (guint)size;
+ debug_log("src buffer(%p) %d size: %d", handle->src_packet, handle->src_packet, handle->src_buf_size);
+ } else {
+ debug_error("Error buffer size");
+ }
+
+ if(handle->dst_format == -1) {
+ handle->dst_format = handle->src_format;
+ handle->dst_format_mime = src_mimetype;
+ }
+
+ debug_log("src: %p handle->src_packet: %p (%d),(%d X %d)", src_packet, handle->src_packet, handle->src_packet, handle->src_width, handle->src_height);
+ if(handle->dst_width ==0 && handle->dst_height ==0) {
+ switch(handle->dst_rotation) {
+ case MM_UTIL_ROTATION_90:
+ case MM_UTIL_ROTATION_270:
+ handle->dst_width = handle->src_height;
+ handle->dst_height = handle->src_width;
+ break;
+ case MM_UTIL_ROTATION_NONE:
+ case MM_UTIL_ROTATION_180:
+ case MM_UTIL_ROTATION_FLIP_HORZ:
+ case MM_UTIL_ROTATION_FLIP_VERT:
+ handle->dst_width = handle->src_width;
+ handle->dst_height = handle->src_height;
+ break;
+ }
+ }
+ debug_log("dst (%d X %d)", handle->dst_width, handle->dst_height);
+ if(media_format_make_writable(src_fmt, &dst_fmt) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(src_fmt);
+ debug_error("[Error] Writable - dst format");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_set_video_mime(dst_fmt, handle->dst_format_mime) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(src_fmt);
+ media_format_unref(dst_fmt);
+ debug_error("[Error] Set - video mime");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_set_video_width(dst_fmt, handle->dst_width) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(src_fmt);
+ media_format_unref(dst_fmt);
+ debug_error("[Error] Set - video width");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_set_video_height(dst_fmt, handle->dst_height) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(src_fmt);
+ media_format_unref(dst_fmt);
+ debug_error("[Error] Set - video height");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_set_video_avg_bps(dst_fmt, src_avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(src_fmt);
+ media_format_unref(dst_fmt);
+ debug_error("[Error] Set - video avg bps");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_set_video_max_bps(dst_fmt, src_max_bps) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(src_fmt);
+ media_format_unref(dst_fmt);
+ debug_error("[Error] Set - video max bps");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ if(media_packet_create_alloc(dst_fmt, (media_packet_finalize_cb)NULL, NULL, &handle->dst_packet) != MM_ERROR_NONE) {
+ debug_error("Imedia_packet_get_format)");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ } else {
+ debug_log("Success - dst media packet");
+ if(media_packet_get_buffer_size(handle->dst_packet, &size) != MM_ERROR_NONE) {
+ debug_error("Imedia_packet_get_format)");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ handle->dst_buf_size = (guint)size;
+ debug_log("handle->src_packet: %p [%d] %d X %d (%d) => handle->dst_packet: %p [%d] %d X %d (%d)",
+ handle->src_packet, handle->src_format, handle->src_width, handle->src_height, handle->src_buf_size,
+ handle->dst_packet, handle->dst_format,handle->dst_width, handle->dst_height, handle->dst_buf_size);
+ }
+ }else {
+ debug_error("%d %d", src_width, src_height);
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ ret = _mm_util_processing(handle);
+
+ if(ret == MM_ERROR_NONE) {
+ if(handle->_util_cb->completed_cb) {
+ debug_log("completed_cb");
+ handle->_util_cb->completed_cb(&handle->dst_packet, MM_ERROR_NONE, handle->_util_cb->user_data);
+ debug_log("completed_cb %p", &handle->dst);
+ }
+ debug_log("Success - Transform");
+ } else {
+ debug_error("Error - Transform");
+ }
+ media_format_unref(src_fmt);
+ media_format_unref(dst_fmt);
+
+ return ret;
+}
+
+int
+mm_transform_is_completed(MMHandleType MMHandle, bool *is_completed)
+{
+ int ret = MM_ERROR_NONE;
+
+ mm_util_s *handle = (mm_util_s *) MMHandle;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if (!is_completed) {
+ debug_error("[ERROR] - is_completed");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ *is_completed = handle->is_completed;
+ debug_log("[Transform....] %d", *is_completed);
+
+ return ret;
+}
+
+int
+mm_util_destroy(MMHandleType MMHandle)
+{
+ int ret = MM_ERROR_NONE;
+ mm_util_s *handle = (mm_util_s*) MMHandle;
+
+ if (!handle) {
+ debug_error("[ERROR] - handle");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+
+ /* Close */
+ if(_mm_util_handle_finalize(handle) != MM_ERROR_NONE) {
+ debug_error("_mm_util_handle_finalize)");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ IMGP_FREE(handle->_util_cb);
+ IMGP_FREE(handle);
+
+ return ret;
+}
+
EXPORT_API int
mm_util_convert_colorspace(unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, mm_util_img_format dst_format)
{
int ret = MM_ERROR_NONE;
- if (!src || !dst) {
+ if(!src || !dst) {
debug_error("invalid mm_util_convert_colorspace\n");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
if( (src_format < MM_UTIL_IMG_FMT_YUV420) || (src_format > MM_UTIL_IMG_FMT_NUM) || (dst_format < MM_UTIL_IMG_FMT_YUV420) || (dst_format > MM_UTIL_IMG_FMT_NUM) ) {
- debug_error("#ERROR# src_format: %d || dst_format:%d value ", src_format, dst_format);
+ debug_error("#ERROR# src_format: %d || dst_format:%d value ", src_format, dst_format);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
debug_log("#START#");
- if (_mm_cannot_convert_format(src_format, dst_format)) {
+ if(_mm_cannot_convert_format(src_format, dst_format)) {
debug_error("#ERROR# Cannot Support Image Format Convert");
- return MM_ERROR_IMAGE_INVALID_VALUE;
+ return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
debug_log("[src] 0x%2x (%d x %d) [dst] 0x%2x", src, src_width, src_height, dst);
- imgp_info_s* _imgp_info_s=(imgp_info_s*)malloc(sizeof(imgp_info_s));
- unsigned int dst_size=0;
- IMGPInfoFunc _mm_util_imgp_func = NULL;
- GModule *_module = NULL;
- imgp_plugin_type_e _imgp_plugin_type_e=-1;
+ imgp_info_s* _imgp_info_s=(imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
+ if(_imgp_info_s == NULL) {
+ debug_error("ERROR - alloc handle");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+ IMGPInfoFunc _mm_util_imgp_func = NULL;
+ GModule *_module = NULL;
+ imgp_plugin_type_e _imgp_plugin_type_e = 0;
/* Initialize */
- if( _mm_select_convert_plugin(src_format, dst_format)) {
+ if(_mm_select_convert_plugin(src_format, dst_format)) {
_imgp_plugin_type_e = IMGP_NEON;
}else {
_imgp_plugin_type_e = IMGP_GSTCS;
}
+ debug_log("plugin type: %d", _imgp_plugin_type_e);
_module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
-
- if(_module == NULL) { /* when IMGP_NEON is NULL */
+ debug_log("_mm_util_imgp_init: %p", _module);
+ if(_module == NULL) { /* when IMGP_NEON is NULL */
_imgp_plugin_type_e = IMGP_GSTCS;
debug_log("You use %s module", PATH_GSTCS_LIB);
_module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
}
debug_log("mm_util_imgp_func: %p", _module);
- ret=_mm_set_imgp_info_s(_imgp_info_s, src, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
- if(ret != MM_ERROR_NONE) {
+ ret=_mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, dst_format, src_width, src_height, MM_UTIL_ROTATE_0);
+ if(ret != MM_ERROR_NONE) {
debug_error("_mm_set_imgp_info_s failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
debug_log("Sucess _mm_set_imgp_info_s");
debug_log("Sucess _mm_util_imgp_process");
if(_mm_util_imgp_func) {
- ret=_mm_util_imgp_func(_imgp_info_s, IMGP_CSC);
+ ret=_mm_util_imgp_func(_imgp_info_s, src, dst, IMGP_CSC);
if (ret != MM_ERROR_NONE)
{
debug_error("image processing failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
}else {
debug_error("g_module_symbol failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
/* Output result*/
- mm_util_get_image_size(_imgp_info_s->dst_format, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &dst_size);
- debug_log("dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
- _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
-
- memcpy(dst, _imgp_info_s->dst, dst_size);
+ debug_log("dst: %p dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
+ dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
+ debug_log("#Success# dst");
/* Finalize */
ret = _mm_util_imgp_finalize(_module, _imgp_info_s);
mm_util_resize_image(unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_img_format src_format, unsigned char *dst, unsigned int *dst_width, unsigned int *dst_height)
{
int ret = MM_ERROR_NONE;
- if (!src || !dst) {
- debug_error("nvalid argument\n");
+ if(!src || !dst) {
+ debug_error("invalid argument\n");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if( (src_width < 0) || (src_height < 0)) {
- debug_error("#ERROR# src_width || src_height value ");
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
-
debug_log("[src] 0x%2x (%d x %d) [dst] 0x%2x", src, src_width, src_height, dst);
- imgp_info_s* _imgp_info_s=(imgp_info_s*)malloc(sizeof(imgp_info_s));
- unsigned int dst_size=0;
- IMGPInfoFunc _mm_util_imgp_func = NULL;
- GModule *_module = NULL;
- imgp_plugin_type_e _imgp_plugin_type_e=-1;
+ imgp_info_s* _imgp_info_s=(imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
+ if(_imgp_info_s == NULL) {
+ debug_error("ERROR - alloc handle");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+ IMGPInfoFunc _mm_util_imgp_func = NULL;
+ GModule *_module = NULL;
+ imgp_plugin_type_e _imgp_plugin_type_e = 0;
/* Initialize */
- if( _mm_select_resize_plugin(src_format)) {
+ if(_mm_select_resize_plugin(src_format)) {
_imgp_plugin_type_e = IMGP_NEON;
}else {
_imgp_plugin_type_e = IMGP_GSTCS;
}
+ debug_log("plugin type: %d", _imgp_plugin_type_e);
_module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
debug_log("_mm_util_imgp_init: %p", _module);
- if(_module == NULL) /* when IMGP_NEON is NULL */
+ if(_module == NULL) /* when IMGP_NEON is NULL */
{
_imgp_plugin_type_e = IMGP_GSTCS;
debug_log("You use %s module", PATH_GSTCS_LIB);
_module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
}
debug_log("_mm_set_imgp_info_s");
- ret=_mm_set_imgp_info_s(_imgp_info_s, src, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
+ ret=_mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, MM_UTIL_ROTATE_0);
debug_log("_mm_set_imgp_info_s ret: %d", ret);
if(ret != MM_ERROR_NONE) {
debug_error("_mm_set_imgp_info_s failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
debug_log("Sucess _mm_set_imgp_info_s");
_mm_util_imgp_func = _mm_util_imgp_process(_module);
debug_log("Sucess _mm_util_imgp_process");
if(_mm_util_imgp_func) {
- ret=_mm_util_imgp_func(_imgp_info_s, IMGP_RSZ);
+ ret=_mm_util_imgp_func(_imgp_info_s, src, dst, IMGP_RSZ);
debug_log("_mm_util_imgp_func, ret: %d", ret);
if (ret != MM_ERROR_NONE)
{
debug_error("image processing failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
}else {
debug_error("g_module_symbol failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
/* Output result*/
- mm_util_get_image_size(_imgp_info_s->dst_format, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &dst_size);
- debug_log("dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
- _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
-
- memcpy(dst, _imgp_info_s->dst, dst_size);
- debug_log("#Success# memcpy");
+ debug_log("dst: %p dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d",
+ dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation);
+ debug_log("#Success# dst");
*dst_width = _imgp_info_s->dst_width;
*dst_height = _imgp_info_s->dst_height;
/* Finalize */
ret = _mm_util_imgp_finalize(_module, _imgp_info_s);
- if(ret != MM_ERROR_NONE) {
+ if(ret != MM_ERROR_NONE) {
debug_error("_mm_util_imgp_finalize failed");
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
{
int ret = MM_ERROR_NONE;
- if (!src || !dst) {
+ if(!src || !dst) {
debug_error("invalid argument\n");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if( (src_width < 0) || (src_height < 0)) {
- debug_error("#ERROR# src_width || src_height value ");
- return MM_ERROR_IMAGE_INVALID_VALUE;
- }
-
if( (angle < MM_UTIL_ROTATE_0) || (angle > MM_UTIL_ROTATE_NUM) ) {
debug_error("#ERROR# angle vaule");
return MM_ERROR_IMAGE_INVALID_VALUE;
debug_log("[src] 0x%2x (%d x %d) [dst] 0x%2x", src, src_width, src_height, dst);
debug_log("#START#");
- imgp_info_s* _imgp_info_s=(imgp_info_s*)malloc(sizeof(imgp_info_s));
+ imgp_info_s* _imgp_info_s=(imgp_info_s*)g_malloc0(sizeof(imgp_info_s));
+ if(_imgp_info_s == NULL) {
+ debug_error("ERROR - alloc handle");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
unsigned int dst_size=0;
- IMGPInfoFunc _mm_util_imgp_func = NULL;
+ IMGPInfoFunc _mm_util_imgp_func = NULL;
GModule *_module = NULL;
- imgp_plugin_type_e _imgp_plugin_type_e=-1;
+ imgp_plugin_type_e _imgp_plugin_type_e = 0;
/* Initialize */
if( _mm_select_rotate_plugin(src_format, src_width, src_height, angle)) {
}else {
_imgp_plugin_type_e = IMGP_GSTCS;
}
+ debug_log("plugin type: %d", _imgp_plugin_type_e);
_module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
debug_log("_mm_util_imgp_func: %p", _module);
- if(_module == NULL) { /* when IMGP_NEON is NULL */
+ if(_module == NULL) { /* when IMGP_NEON is NULL */
_imgp_plugin_type_e = IMGP_GSTCS;
debug_log("You use %s module", PATH_GSTCS_LIB);
_module = _mm_util_imgp_initialize(_imgp_plugin_type_e);
ret=_mm_confirm_dst_width_height(src_width, src_height, dst_width, dst_height, angle);
if(ret != MM_ERROR_NONE) {
debug_error("dst_width || dest_height size Error");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret=_mm_set_imgp_info_s(_imgp_info_s, src, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle);
+ ret=_mm_set_imgp_info_s(_imgp_info_s, src_format, src_width, src_height, src_format, *dst_width, *dst_height, angle);
debug_log("_mm_set_imgp_info_s");
if(ret != MM_ERROR_NONE) {
debug_error("_mm_set_imgp_info_s failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
debug_log("Sucess _mm_set_imgp_info_s");
_mm_util_imgp_func = _mm_util_imgp_process(_module);
debug_log("Sucess _mm_util_imgp_process");
if(_mm_util_imgp_func) {
- ret=_mm_util_imgp_func(_imgp_info_s, IMGP_ROT);
+ ret=_mm_util_imgp_func(_imgp_info_s, src, dst, IMGP_ROT);
if (ret!= MM_ERROR_NONE) {
debug_error("image processing failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
}else {
debug_error("g_module_symbol failed");
+ _mm_util_imgp_finalize(_module, _imgp_info_s);
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
/* Output result*/
- mm_util_get_image_size(_imgp_info_s->dst_format, _imgp_info_s->dst_width, _imgp_info_s->dst_height, &dst_size);
- debug_log("dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d, dst_size: %d",
- _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation,dst_size);
+ debug_log("dst: %p dst_width: %d, dst_height: %d, output_stride: %d, output_elevation: %d, dst_size: %d",
+ dst, _imgp_info_s->dst_width, _imgp_info_s->dst_height, _imgp_info_s->output_stride, _imgp_info_s->output_elevation,dst_size);
+ debug_log("#Success# dst");
- memcpy(dst, _imgp_info_s->dst, dst_size);
- debug_log("#Success# memcpy");
*dst_width = _imgp_info_s->dst_width;
*dst_height = _imgp_info_s->dst_height;
case MM_UTIL_IMG_FMT_YUV422:
case MM_UTIL_IMG_FMT_YUYV:
case MM_UTIL_IMG_FMT_UYVY:
+ case MM_UTIL_IMG_FMT_NV16:
+ case MM_UTIL_IMG_FMT_NV61:
stride = MM_UTIL_ROUND_UP_4 (width * 2);
size = stride * height;
*imgsize = size;
Name : mmutil-imgp
Description : Multimedia Framework Utility Library
-Requires : @IMGP_REQPKG@
+Requires : @IMGP_REQPKG@ capi-media-tool mm-common
Version : @VERSION@
Libs : -L${libdir} -lmmutil_imgp
Cflags : -I${includedir}/mmf -DLIBPREFIX=\"${libdir}\"
mm_util_imgp_testsuite_SOURCES = mm_util_imgp_testsuite.c
mm_util_imgp_testsuite_CFLAGS = -I$(srcdir)/../include \
- $(MMTA_CFLAGS) \
+ -I$(includedir)/drm \
$(MMCOMMON_CFLAGS) \
$(MMCAMCORDER_CFLAGS) \
+ $(DRM_CFLAGS) \
+ $(DRM_DEVEL_CFLAGS) \
+ $(MEDIA_CFLAGS) \
+ $(XFIXES_CFLAGS) \
+ $(DRI2PROTO_CFLAGS) \
+ $(DRI2_CFLAGS) \
+ $(TBM_CFLAGS) \
$(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -D_INTERNAL_SESSION_MANAGER_
############################################
-mm_util_imgp_testsuite_DEPENDENCIES = $(srcdir)/../libmmutil_imgp.la
-
+mm_util_imgp_testsuite_DEPENDENCIES = $(srcdir)/../libmmutil_imgp.la
+
mm_util_imgp_testsuite_LDADD = $(srcdir)/../libmmutil_imgp.la \
- $(MMTA_LIBS) \
$(MMCOMMON_LIBS) \
$(MMCAMCORDER_LIBS) \
+ $(DRM_LIBS) \
+ $(DRM_DEVEL_LIBS) \
+ $(MEDIA_LIBS) \
+ $(XFIXES_LIBS) \
+ $(DRI2PROTO_LIBS) \
+ $(DRI2_LIBS) \
+ $(TBM_LIBS) \
$(MMLOG_LIBS)
* limitations under the License.
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "mm_util_imgp.h"
#include "mm_util_imgp_internal.h"
-#include "mm_log.h"
-#include "mm_debug.h"
-#include <mm_ta.h>
-#include <unistd.h>
#include <mm_error.h>
+#define ONE_ALL 0
+#define IMAGE_FORMAT_LABEL_BUFFER_SIZE 4
+MMHandleType MMHandle = 0;
+
+bool
+transform_completed_cb(media_packet_h *packet, int error, void *user_param)
+{
+ uint64_t size = 0;
+ char output_file[25] = {};
+ debug_log("MMHandle: 0x%2x", MMHandle);
+
+ media_format_h dst_fmt;
+ media_format_mimetype_e dst_mimetype;
+ int dst_width, dst_height, dst_avg_bps, dst_max_bps;
+ char *output_fmt = (char*)malloc(sizeof(char) * IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ if(output_fmt) {
+ if(media_packet_get_format(*packet, &dst_fmt) != MM_ERROR_NONE) {
+ debug_error("Imedia_packet_get_format");
+ IMGP_FREE(output_fmt);
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+
+ if(media_format_get_video_info(dst_fmt, &dst_mimetype, &dst_width, &dst_height, &dst_avg_bps, &dst_max_bps) ==MEDIA_FORMAT_ERROR_NONE) {
+ memset(output_fmt, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ if(dst_mimetype ==MEDIA_FORMAT_YV12 || dst_mimetype == MEDIA_FORMAT_422P ||dst_mimetype == MEDIA_FORMAT_I420
+ || dst_mimetype == MEDIA_FORMAT_NV12 || dst_mimetype == MEDIA_FORMAT_UYVY ||dst_mimetype == MEDIA_FORMAT_YUYV) {
+ strncpy(output_fmt, "yuv", strlen("yuv"));
+ } else {
+ strncpy(output_fmt,"rgb", strlen("rgb"));
+ }
+ debug_log("[mimetype: %d] W x H : %d x %d", dst_mimetype, dst_width, dst_height);
+ sprintf(output_file, "result_%dx%d.%s", dst_width,dst_height, output_fmt);
+ }
+ }
+
+ if(error == MM_ERROR_NONE) {
+ debug_log("completed");
+ } else {
+ debug_error("[ERROR] complete cb");
+ GThread * destroy_thread = g_thread_new(NULL, mm_util_destroy, MMHandle);
+ g_thread_unref(destroy_thread);
+ }
+
+ FILE *fpout = fopen(output_file, "w");
+ if(fpout) {
+ media_packet_get_buffer_size(*packet, &size);
+ void *dst = NULL;
+ if(media_packet_get_buffer_data_ptr(*packet, &dst) != MM_ERROR_NONE) {
+ IMGP_FREE(dst);
+ IMGP_FREE(output_fmt);
+ fclose(fpout);
+ debug_error ("[dst] media_packet_get_extra");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
+ debug_log("dst: %p [%d]", dst, size);
+ fwrite(dst, 1, size, fpout);
+ debug_log("FREE");
+ fclose(fpout);
+ }
+
+ debug_log("write result");
+ debug_log("Free (output_fmt)");
+ media_packet_destroy(*packet);
+ IMGP_FREE(output_fmt);
+ return TRUE;
+}
int main(int argc, char *argv[])
{
- unsigned char *src = NULL;
- unsigned char *dst = NULL;
- unsigned int src_width = 0;
- unsigned int src_height = 0;
- unsigned int dst_width = 0;
- unsigned int dst_height = 0;
- char output_file[25];
- unsigned int src_size = 0;
- unsigned int dst_size = 0;
- int src_cs;
- int dst_cs;
int ret = 0;
- int cnt = 0;
- char fmt[IMAGE_FORMAT_LABEL_BUFFER_SIZE];
- FILE *fp = NULL;
-
- if (argc < 6) {
+ mm_util_s *handle = NULL;
+ void *src;
+ void *ptr;
+ media_packet_h src_packet;
+
+ if (argc < 1) {
debug_error("[%s][%05d] Usage: ./mm_image_testsuite filename [yuv420 | yuv420p | yuv422 | uyvy | vyuy | nv12 | nv12t | rgb565 | rgb888 | argb | jpeg] width height\n");
exit (0);
}
- MMTA_INIT();
- #if ONE_ALL
- while(cnt++ < 10000) {
- #endif
-
- if (!strcmp("convert", argv[1])) {
- FILE *fp = fopen(argv[2], "r");
- src_width = atoi(argv[3]);
- src_height = atoi(argv[4]);
- dst_width = atoi(argv[5]);
- dst_height = atoi(argv[6]);
- src_cs =atoi(argv[7]);
- dst_cs = atoi(argv[8]);
- debug_log("convert [FILE (%s)] [src_width (%d)] [src_height (%d)] [dst_width (%d)] [dst_height (%d)] [src_cs (%d)] [dst_cs (%d)]",
- argv[2], src_width, src_height, dst_width, dst_height, src_cs, dst_cs);
-
- ret = mm_util_get_image_size(src_cs, src_width, src_height, &src_size);
- debug_log("convert src buffer size=%d\n", src_size);
- src = malloc(src_size);
- if(fread(src, 1, src_size, fp)) {
- debug_log("#Success# fread");
- } else {
- debug_error("#Error# fread");
+
+ /* Create Transform */
+ ret = mm_util_create (&MMHandle);
+ if(ret == MM_ERROR_NONE) {
+ debug_log("Success - Create Transcode Handle [MMHandle: 0x%2x]", MMHandle);
+ } else {
+ debug_log("ERROR - Create Transcode Handle");
+ return ret;
+ }
+
+ handle = (mm_util_s*) MMHandle;
+
+ media_format_h fmt;
+ if(media_format_create(&fmt) == MEDIA_FORMAT_ERROR_NONE) {
+ if(media_format_set_video_mime(fmt, MEDIA_FORMAT_I420) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(fmt);
+ debug_error("[Error] Set - video mime");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret = mm_util_get_image_size(dst_cs, dst_width, dst_height, &dst_size);
- debug_log("dst_cs: %d dst_width: %d dst_height: %d dst buffer size=%d\n", dst_cs, dst_width, dst_height, dst_size);
- dst = malloc(dst_size);
- debug_log("dst: %p", dst);
-
- __ta__("mm_util_convert_colorspace",
- ret = mm_util_convert_colorspace(src, src_width, src_height, src_cs, dst, dst_cs);
- );
- debug_log("mm_util_convert_colorspace dst:%p ret = %d", dst, ret);
- } else if (!strcmp("resize", argv[1])) {
- fp = fopen(argv[2], "r");
-
- src_width = atoi(argv[3]);
- src_height = atoi(argv[4]);
- dst_width = atoi(argv[5]);
- dst_height = atoi(argv[6]);
- src_cs =atoi(argv[7]);
- dst_cs = src_cs;
- debug_log("resize [FILE (%s)] [src_width (%d)] [src_height (%d)] [dst_width (%d)] [dst_height (%d)] [src_cs (%d)]",
- argv[2], src_width, src_height, dst_width, dst_height, src_cs);
-
- ret = mm_util_get_image_size(src_cs, src_width, src_height, &src_size);
- debug_log("convert src buffer size=%d\n", src_size);
- src = malloc(src_size);
- if(fread(src, 1, src_size, fp)) {
- debug_log("#Success# fread");
- } else {
- debug_error("#Error# fread");
+ if(media_format_set_video_width(fmt, 320) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(fmt);
+ debug_error("[Error] Set - video width");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret = mm_util_get_image_size(dst_cs, dst_width, dst_height, &dst_size);
- debug_log("dst_cs: %d dst_width: %d dst_height: %d dst buffer size=%d\n", dst_cs, dst_width, dst_height, dst_size);
- dst = malloc(dst_size);
- debug_log("dst: %p", dst);
-
- __ta__("mm_util_resize_image",
- ret = mm_util_resize_image(src, src_width, src_height, src_cs, dst, &dst_width, &dst_height);
- );
- debug_log("mm_util_resize_image dst: %p ret = %d", dst, ret);
- } else if (!strcmp("rotate", argv[1])) {
- fp = fopen(argv[2], "r");
- src_width = atoi(argv[3]);
- src_height = atoi(argv[4]);
- dst_width = atoi(argv[5]);
- dst_height = atoi(argv[6]);
- src_cs =atoi(argv[7]);
- mm_util_img_rotate_type angle = atoi(argv[8]);
- dst_cs = src_cs;
- debug_log("rotate [FILE (%s)] [src_width (%d)] [src_height (%d)] [dst_width (%d)] [dst_height (%d)] [src_cs (%d)] [angle (%d)]",
- argv[2], src_width, src_height, dst_width, dst_height, src_cs, angle);
-
- ret = mm_util_get_image_size(src_cs, src_width, src_height, &src_size);
- debug_log("convert src buffer size=%d\n", src_size);
- src = malloc(src_size);
- if(fread(src, 1, src_size, fp)) {
- debug_log("#Success# fread");
- } else {
- debug_error("#Error# fread");
+ if(media_format_set_video_height(fmt, 240) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(fmt);
+ debug_error("[Error] Set - video height");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret = mm_util_get_image_size(dst_cs, dst_width, dst_height, &dst_size);
- debug_log("dst_cs: %d dst_width: %d dst_height: %d dst buffer size=%d\n", dst_cs, dst_width, dst_height, dst_size);
- dst = malloc(dst_size);
- debug_log("dst: %p", dst);
-
- __ta__("mm_util_rotate_image",
- ret = mm_util_rotate_image(src, src_width, src_height, src_cs, dst, &dst_width, &dst_height, angle);
- );
- debug_log("mm_util_rotate_image dst: %p ret = %d\n", dst, ret);
- } else if (!strcmp("crop", argv[1])) {
- fp = fopen(argv[2], "r");
- src_width = atoi(argv[3]);
- src_height = atoi(argv[4]);
- unsigned int crop_start_x = atoi(argv[5]);
- unsigned int crop_start_y = atoi(argv[6]);
- dst_width = atoi(argv[7]);
- dst_height = atoi(argv[8]);
- src_cs =atoi(argv[9]);
- dst_cs = src_cs;
- debug_log("rotate [FILE (%s)] [src_width (%d)] [src_height (%d)] [crop_start_x (%d)] [crop_start_y (%d)] [dst_width (%d)] [dst_height (%d)] [src_cs (%d)]", argv[2], src_width, src_height, crop_start_x, crop_start_y, dst_width, dst_height, src_cs);
-
- ret = mm_util_get_image_size(src_cs, src_width, src_height, &src_size);
- debug_log("convert src buffer size=%d\n", src_size);
- src = malloc(src_size);
- if(fread(src, 1, src_size, fp)) {
- debug_log("#Success# fread");
- } else {
- debug_error("#Error# fread");
+ if(media_format_set_video_avg_bps(fmt, 15000000) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(fmt);
+ debug_error("[Error] Set - video avg bps");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
}
- ret = mm_util_get_image_size(dst_cs, dst_width, dst_height, &dst_size);
- debug_log("dst_cs: %d dst_width: %d dst_height: %d dst buffer size=%d\n", dst_cs, dst_width, dst_height, dst_size);
- dst = malloc(dst_size);
- debug_log("dst: %p", dst);
+ if(media_format_set_video_max_bps(fmt, 20000000) != MEDIA_FORMAT_ERROR_NONE) {
+ media_format_unref(fmt);
+ debug_error("[Error] Set - video max bps");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
+ }
- __ta__("mm_util_crop_image",
- ret = mm_util_crop_image(src, src_width, src_height, src_cs, crop_start_x, crop_start_y, &dst_width, &dst_height, dst);
- );
- debug_log("mm_util_crop_image dst: %p ret = %d\n", dst, ret);
- } else {
- debug_error("convert | resize | rotate | crop fail\n");
+ debug_log("media_format_set_video_info success! w:320, h:240, MEDIA_FORMAT_I420\n");
+ }
+ else {
+ debug_error("media_format_create failed...");
}
- MMTA_ACUM_ITEM_END("colorspace", 0);
- MMTA_ACUM_ITEM_SHOW_RESULT();
- MMTA_RELEASE ();
-
- FILE *fpout;
-
- if(ret==MM_ERROR_NONE) {
- if(cnt == 0) {
- memset(fmt, 0, IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- if(dst_cs ==MM_UTIL_IMG_FMT_YUV420 || dst_cs == MM_UTIL_IMG_FMT_YUV422 ||dst_cs == MM_UTIL_IMG_FMT_I420
- || dst_cs == MM_UTIL_IMG_FMT_NV12 || dst_cs == MM_UTIL_IMG_FMT_UYVY ||dst_cs == MM_UTIL_IMG_FMT_YUYV) {
- strncpy(fmt, "yuv", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
- } else {
- strncpy(fmt,"rgb", IMAGE_FORMAT_LABEL_BUFFER_SIZE);
+ ret = media_packet_create_alloc(fmt, (media_packet_finalize_cb)transform_completed_cb, NULL, &src_packet);
+ if(ret == MM_ERROR_NONE) {
+ debug_log("Success - Create Media Packet(%p)", src_packet);
+ uint64_t size =0;
+ if (media_packet_get_buffer_size(src_packet, &size) == MEDIA_PACKET_ERROR_NONE) {
+ ptr = malloc(size);
+ if (media_packet_get_buffer_data_ptr(src_packet, &ptr) == MEDIA_PACKET_ERROR_NONE) {
+ FILE *fp = fopen(argv[1], "r");
+ src = malloc(size);
+ if(fread(src, 1, (int)size, fp)) {
+ debug_log("#Success# fread");
+ memcpy(ptr, src, (int)size);
+ debug_log("memcpy");
+ } else {
+ debug_error("#Error# fread");
+ }
}
- sprintf(output_file, "result%d_%dx%d.%s", cnt, dst_width, dst_height, fmt);
- fpout = fopen(output_file, "w");
- debug_log("%s = %dx%d dst_size: %d", output_file, dst_width, dst_height, dst_size);
- debug_log("dst:%p ret = %d", dst, ret);
- fwrite(dst, 1, dst_size, fpout);
- fflush(fpout);
}
- if(fp) {
- fclose(fp);
- debug_log("fclose(fp) fp: 0x%2x", fp);
+ } else {
+ debug_log("ERROR - Create Media Packet");
+ return ret;
}
- if(fpout) {
- fclose(fpout);
- debug_log("fclose(fp) fpout: 0x%2x", fpout);
+ /* Set Source */
+ ret = mm_util_set_hardware_acceleration(MMHandle, atoi(argv[2]));
+ if(ret == MM_ERROR_NONE) {
+ debug_log("Success - Set hardware_acceleration");
+ } else {
+ debug_log("ERROR - Set hardware_acceleration");
+ return ret;
}
- debug_log("src: %p", src);
- if(src) {
- free(src); src = NULL;
- }
- debug_log("dst: %p",dst);
- if(dst) {
- free(dst); dst = NULL;
+ ret = mm_util_set_colorspace_convert(MMHandle, MM_UTIL_IMG_FMT_RGB888);
+ if(ret == MM_ERROR_NONE) {
+ debug_log("Success - Set Convert Info");
+ } else {
+ media_format_unref(fmt);
+ debug_log("ERROR - Set Convert Info");
+ return ret;
}
- debug_log("Success - free src & dst");
- #if ONE_ALL
- debug_log("cnt: %d", cnt);
+ ret = mm_util_set_resolution(MMHandle, 320, 240);
+ if(ret == MM_ERROR_NONE) {
+ debug_log("Success - Set Resize Info");
+ } else {
+ media_format_unref(fmt);
+ debug_log("ERROR - Set Resize Info");
+ return ret;
}
- #endif
+
+ /* Transform */
+ ret = mm_util_transform(MMHandle, src_packet, (mm_util_completed_callback) transform_completed_cb, handle);
+ if(ret == MM_ERROR_NONE) {
+ debug_log("Success - Transform");
+ } else {
+ media_format_unref(fmt);
+ debug_error("ERROR - Transform");
+ return ret;
}
+ debug_log("Wait...");
+
+ media_packet_destroy(src_packet);
+ media_format_unref(fmt);
+ debug_log("destroy");
+
return ret;
}
+++ /dev/null
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2006-12-25.00
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-
-nl='
-'
-IFS=" "" $nl"
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit=${DOITPROG-}
-if test -z "$doit"; then
- doit_exec=exec
-else
- doit_exec=$doit
-fi
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_glob='?'
-initialize_posix_glob='
- test "$posix_glob" != "?" || {
- if (set -f) 2>/dev/null; then
- posix_glob=
- else
- posix_glob=:
- fi
- }
-'
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
-rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-no_target_directory=
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
- --help display this help and exit.
- --version display version info and exit.
-
- -c (ignored)
- -C install only if different (preserve the last data modification time)
- -d create directories instead of installing files.
- -g GROUP $chgrpprog installed files to GROUP.
- -m MODE $chmodprog installed files to MODE.
- -o USER $chownprog installed files to USER.
- -s $stripprog installed files.
- -t DIRECTORY install into DIRECTORY.
- -T report an error if DSTFILE is a directory.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
- RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
- case $1 in
- -c) ;;
-
- -C) copy_on_change=true;;
-
- -d) dir_arg=true;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) mode=$2
- case $mode in
- *' '* | *' '* | *'
-'* | *'*'* | *'?'* | *'['*)
- echo "$0: invalid mode: $mode" >&2
- exit 1;;
- esac
- shift;;
-
- -o) chowncmd="$chownprog $2"
- shift;;
-
- -s) stripcmd=$stripprog;;
-
- -t) dst_arg=$2
- shift;;
-
- -T) no_target_directory=true;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- --) shift
- break;;
-
- -*) echo "$0: invalid option: $1" >&2
- exit 1;;
-
- *) break;;
- esac
- shift
-done
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
- # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dst_arg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dst_arg"
- shift # fnord
- fi
- shift # arg
- dst_arg=$arg
- done
-fi
-
-if test $# -eq 0; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call `install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-if test -z "$dir_arg"; then
- trap '(exit $?); exit' 1 2 13 15
-
- # Set umask so as not to create temps with too-generous modes.
- # However, 'strip' requires both read and write access to temps.
- case $mode in
- # Optimize common cases.
- *644) cp_umask=133;;
- *755) cp_umask=22;;
-
- *[0-7])
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw='% 200'
- fi
- cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
- *)
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw=,u+rw
- fi
- cp_umask=$mode$u_plus_rw;;
- esac
-fi
-
-for src
-do
- # Protect names starting with `-'.
- case $src in
- -*) src=./$src;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- dstdir=$dst
- test -d "$dstdir"
- dstdir_status=$?
- else
-
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dst_arg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
-
- dst=$dst_arg
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst;;
- esac
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test -n "$no_target_directory"; then
- echo "$0: $dst_arg: Is a directory" >&2
- exit 1
- fi
- dstdir=$dst
- dst=$dstdir/`basename "$src"`
- dstdir_status=0
- else
- # Prefer dirname, but fall back on a substitute if dirname fails.
- dstdir=`
- (dirname "$dst") 2>/dev/null ||
- expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$dst" : 'X\(//\)[^/]' \| \
- X"$dst" : 'X\(//\)$' \| \
- X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
- echo X"$dst" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'
- `
-
- test -d "$dstdir"
- dstdir_status=$?
- fi
- fi
-
- obsolete_mkdir_used=false
-
- if test $dstdir_status != 0; then
- case $posix_mkdir in
- '')
- # Create intermediate dirs using mode 755 as modified by the umask.
- # This is like FreeBSD 'install' as of 1997-10-28.
- umask=`umask`
- case $stripcmd.$umask in
- # Optimize common cases.
- *[2367][2367]) mkdir_umask=$umask;;
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
- *[0-7])
- mkdir_umask=`expr $umask + 22 \
- - $umask % 100 % 40 + $umask % 20 \
- - $umask % 10 % 4 + $umask % 2
- `;;
- *) mkdir_umask=$umask,go-w;;
- esac
-
- # With -d, create the new directory with the user-specified mode.
- # Otherwise, rely on $mkdir_umask.
- if test -n "$dir_arg"; then
- mkdir_mode=-m$mode
- else
- mkdir_mode=
- fi
-
- posix_mkdir=false
- case $umask in
- *[123567][0-7][0-7])
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
- ;;
- *)
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
- trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
- if (umask $mkdir_umask &&
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
- then
- if test -z "$dir_arg" || {
- # Check for POSIX incompatibilities with -m.
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writeable bit of parent directory when it shouldn't.
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
- ls_ld_tmpdir=`ls -ld "$tmpdir"`
- case $ls_ld_tmpdir in
- d????-?r-*) different_mode=700;;
- d????-?--*) different_mode=755;;
- *) false;;
- esac &&
- $mkdirprog -m$different_mode -p -- "$tmpdir" && {
- ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
- }
- }
- then posix_mkdir=:
- fi
- rmdir "$tmpdir/d" "$tmpdir"
- else
- # Remove any dirs left behind by ancient mkdir implementations.
- rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
- fi
- trap '' 0;;
- esac;;
- esac
-
- if
- $posix_mkdir && (
- umask $mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
- )
- then :
- else
-
- # The umask is ridiculous, or mkdir does not conform to POSIX,
- # or it failed possibly due to a race condition. Create the
- # directory the slow way, step by step, checking for races as we go.
-
- case $dstdir in
- /*) prefix='/';;
- -*) prefix='./';;
- *) prefix='';;
- esac
-
- eval "$initialize_posix_glob"
-
- oIFS=$IFS
- IFS=/
- $posix_glob set -f
- set fnord $dstdir
- shift
- $posix_glob set +f
- IFS=$oIFS
-
- prefixes=
-
- for d
- do
- test -z "$d" && continue
-
- prefix=$prefix$d
- if test -d "$prefix"; then
- prefixes=
- else
- if $posix_mkdir; then
- (umask=$mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
- # Don't fail if two instances are running concurrently.
- test -d "$prefix" || exit 1
- else
- case $prefix in
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
- *) qprefix=$prefix;;
- esac
- prefixes="$prefixes '$qprefix'"
- fi
- fi
- prefix=$prefix/
- done
-
- if test -n "$prefixes"; then
- # Don't fail if two instances are running concurrently.
- (umask $mkdir_umask &&
- eval "\$doit_exec \$mkdirprog $prefixes") ||
- test -d "$dstdir" || exit 1
- obsolete_mkdir_used=true
- fi
- fi
- fi
-
- if test -n "$dir_arg"; then
- { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
- { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
- test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
- else
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
- # Copy the file name to the temp name.
- (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
- { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
- { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
- # If -C, don't bother to copy if it wouldn't change the file.
- if $copy_on_change &&
- old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
- new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
-
- eval "$initialize_posix_glob" &&
- $posix_glob set -f &&
- set X $old && old=:$2:$4:$5:$6 &&
- set X $new && new=:$2:$4:$5:$6 &&
- $posix_glob set +f &&
-
- test "$old" = "$new" &&
- $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
- then
- rm -f "$dsttmp"
- else
- # Rename the file to the real destination.
- $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
- {
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- test ! -f "$dst" ||
- $doit $rmcmd -f "$dst" 2>/dev/null ||
- { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
- { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
- } ||
- { echo "$0: cannot unlink or rename $dst" >&2
- (exit 1); exit 1
- }
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dst"
- }
- fi || exit 1
-
- trap '' 0
- fi
-done
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
installmmutil_jpeg_HEADERS = include/mm_util_jpeg.h
libmmutil_jpeg_la_SOURCES = mm_util_jpeg.c
-
+
libmmutil_jpeg_la_CFLAGS = -I$(srcdir)/include \
- $(MMTA_CFLAGS) \
- $(MMCOMMON_CFLAGS)
-
-libmmutil_jpeg_la_LIBADD = $(MMCOMMON_LIBS) -ljpeg -ldl \
- $(MMTA_LIBS)
+ -I$(srcdir)/../imgp/include \
+ $(GLIB_CFLAGS) \
+ $(MEDIA_CFLAGS) \
+ $(MMCOMMON_CFLAGS) \
+ -I/usr/include \
+ $(SYSTEMINFO_CFLAGS) \
+ $(srcdir)/../imgp/libmmutil_imgp.la
+
+libmmutil_jpeg_la_LIBADD = $(MMCOMMON_LIBS) -ljpeg -ldl -lexif\
+ $(GLIB_LIBS) \
+ $(GMODULE_LIBS) \
+ $(SYSTEMINFO_LIBS)\
+ $(MEDIA_LIBS)
libmmutil_jpeg_la_CFLAGS += $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" -DLIBPREFIX=\"$(libdir)\"
+libmmutil_jpeg_la_DEPENDENCIES = $(srcdir)/../imgp/libmmutil_imgp.la
+
pcfiles = mmutil-jpeg.pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pcfiles)
typedef enum
{
/* YUV planar format */
- MM_UTIL_JPEG_FMT_YUV420 = 0x00, /**< YUV420 format - planer I420*/
+ MM_UTIL_JPEG_FMT_YUV420 = 0x00, /**< YUV420 format - planer I420 */
MM_UTIL_JPEG_FMT_YUV422, /**< YUV422 format - planer */
/* YUV packed format */
MM_UTIL_JPEG_FMT_UYVY, /**< UYVY format - YUV packed format */
/* RGB888 format */
- MM_UTIL_JPEG_FMT_RGB888, /**< RGB888 format */
+ MM_UTIL_JPEG_FMT_RGB888, /**< RGB888 format */
/* GrayScale format */
MM_UTIL_JPEG_FMT_GraySacle, /**< GrayScale format */
/* YUV packed format */
MM_UTIL_JPEG_FMT_YUYV, /**< YUYV format - YUV packed format */
+ /*Following formats are only for qualcomm hardware codecs.*/
+ MM_UTIL_JPEG_FMT_NV12, /**< YUV format - YUV420 semi-planar (NV12) */
+ MM_UTIL_JPEG_FMT_NV21, /**< YUV format - YUV420 semi-planar (NV21) */
+ MM_UTIL_JPEG_FMT_NV16, /**< YUV format - YUV422 semi-planar (NV16) */
+ MM_UTIL_JPEG_FMT_NV61, /**< YUV format - YUV422 semi-planar (NV61) */
+ MM_UTIL_JPEG_FMT_RGBA8888, /**< RGBA8888 format */
+ MM_UTIL_JPEG_FMT_BGRA8888, /**< BGRA8888 format */
+ MM_UTIL_JPEG_FMT_ARGB8888, /**< ARGB8888 format */
} mm_util_jpeg_yuv_format;
/**
* @param src [in] pointer of input stream pointer (raw data)
* @param width [in] width of src data
* @param height [in] height of src data
- * @param fmt [in] color format
+ * @param fmt [in] color format
* @param quality [in] encoding quality, from 1 to 100
* @return This function returns zero on success, or negative value with error code.
* @remark
int
mm_util_decode_from_jpeg_memory (mm_util_jpeg_yuv_data *decoded, void *src, int size, mm_util_jpeg_yuv_format fmt);
-/**
- * This function encodes rawfile to jpeg file.
- *
- * @param filename [in] output file name
- * @param src [in] pointer of input stream pointer (raw data)
- * @param width [in] width of src data
- * @param height [in] height of src data
- * @param fmt [in] color format
- * @param quality [in] encoding quality, from 1 to 100
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_jpeg_yuv_format
- * @since R1, 1.0
- */
-#if 0
-int
-mm_util_jpeg_turbo_encode_to_file (char *filename, void *src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality);
-
-
-/**
- * This function encodes raw file to jpeg into memory.
- *
- * @param mem [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer.
- After using it, please free the allocated memory.
- * @param size [in] output stream size, that is, encoded stream size
- * @param src [in] pointer of input stream pointer (raw data)
- * @param width [in] width of src data
- * @param height [in] height of src data
- * @param fmt [in] color format
- * @param quality [in] encoding quality, from 1 to 100
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_jpeg_yuv_format
- * @since R1, 1.0
- */
-int
-mm_util_jpeg_turbo_encode_to_memory (void **mem, int *size, void *src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality);
-
-
-/**
- * This function extracts yuv data from jpeg file
- *
- * @param decoded [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer.
- After using it, please free the allocated memory.
- * @param filename [in] input file name, encoded stream file
- * @param fmt [in] color format
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_jpeg_yuv_data, mm_util_jpeg_yuv_format
- * @since R1, 1.0
- */
-int
-mm_util_decode_from_jpeg_turbo_file(mm_util_jpeg_yuv_data *decoded, char *filename, mm_util_jpeg_yuv_format fmt);
-
-
-/**
- * This function extracts yuv data from jpeg buffer
- *
- * @param decoded [out] pointer of output stream pointer, that is, pointer of encoded jpeg stream pointer.
- After using it, please free the allocated memory.
- * @param src [in] input stream pointer(pointer of encoded jpeg stream data)
- * @param size [in] size of input stream(size of pointer of encoded jpeg stream data)
- * @param fmt [in] color format
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @see mm_util_jpeg_yuv_data, mm_util_jpeg_yuv_format
- * @since R1, 1.0
- */
-int
-mm_util_decode_from_jpeg_turbo_memory (mm_util_jpeg_yuv_data *decoded, void *src, int size, mm_util_jpeg_yuv_format fmt);
-#endif
-/**
- @}
- */
-
#ifdef __cplusplus
}
#endif
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/times.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h> /* fopen() */
#include <jpeglib.h>
#define LIBJPEG_TURBO 0
+#define ENC_MAX_LEN 8192
#if LIBJPEG_TURBO
#include <turbojpeg.h>
#endif
+#include <libexif/exif-data.h>
+
#include <mm_error.h>
#include <setjmp.h>
#include <glib.h>
#include <mm_attrs.h>
#include <mm_attrs_private.h>
-#include <mm_ta.h>
-
#include "mm_util_jpeg.h"
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#define MAX_SIZE 5000
+#include "mm_util_imgp.h"
#ifndef YUV420_SIZE
#define YUV420_SIZE(width, height) (width*height*3>>1)
#endif
#define YUV422_SIZE(width, height) (width*height<<1)
#endif
-/* H/W JPEG codec */
-#include <dlfcn.h>
-#define ENV_NAME_USE_HW_CODEC "IMAGE_UTIL_USE_HW_CODEC"
-#define LIB_PATH_HW_CODEC_LIBRARY LIBPREFIX "/libmm_jpeg_hw.so"
-#define ENCODE_JPEG_HW_FUNC_NAME "mm_jpeg_encode_hw"
-typedef int (*EncodeJPEGFunc)(unsigned char *src, int width, int height, mm_util_jpeg_yuv_format in_fmt, int quality,
- unsigned char **dst, int *dst_size);
-static int _write_file(char *file_name, void *data, int data_size);
-
-#define PARTIAL_DECODE 0
+#define PARTIAL_DECODE 1
#define LIBJPEG 1
+#define MM_JPEG_ROUND_UP_2(num) (((num)+1)&~1)
+#define MM_JPEG_ROUND_UP_4(num) (((num)+3)&~3)
+#define MM_JPEG_ROUND_UP_8(num) (((num)+7)&~7)
+#define MM_JPEG_ROUND_DOWN_16(num) ((num)&(~15))
#if LIBJPEG_TURBO
-#define MM_LIBJPEG_TURBO_ROUND_UP_2(num) (((num)+1)&~1)
-#define MM_LIBJPEG_TURBO_ROUND_UP_4(num) (((num)+3)&~3)
-#define MM_LIBJPEG_TURBO_ROUND_UP_8(num) (((num)+7)&~7)
#define PAD(v, p) ((v+(p)-1)&(~((p)-1)))
#define _throwtj() {printf("TurboJPEG ERROR:\n%s\n", tjGetErrorStr());}
#define _tj(f) {if((f)==-1) _throwtj();}
else buf[index]=(row<halfway)? 76:226;
}
}
- }else {
+ } else {
for(row=0; row<h; row++) {
for(col=0; col<w; col++) {
if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
buf[index*ps+goffset]=255;
buf[index*ps+boffset]=255;
}
- }else {
+ } else {
buf[index*ps+roffset]=255;
if(row>=halfway) buf[index*ps+goffset]=255;
}
if(jpegBuf == NULL) {
debug_error("jpegBuf is NULL");
- return MM_ERROR_IMAGE_FILEOPEN;
+ return;
}
debug_log("0x%2x, 0x%2x ", jpegBuf[0], jpegBuf[1]);
if(!sf || !n) {
debug_error(" scaledfactor is NULL");
- return MM_ERROR_IMAGE_INVALID_VALUE;
+ return;
}
if((_hdrsubsamp==TJSAMP_444 || _hdrsubsamp==TJSAMP_GRAY) || input_fmt==MM_UTIL_JPEG_FMT_RGB888) {
_sf= sf[i];
- }else {
+ } else {
_sf=sf1;
}
if(input_fmt==MM_UTIL_JPEG_FMT_YUV420 || input_fmt==MM_UTIL_JPEG_FMT_YUV422) {
debug_log("JPEG -> YUV %s ... ", subName[_hdrsubsamp]);
- }else if(input_fmt==MM_UTIL_JPEG_FMT_RGB888) {
+ } else if(input_fmt==MM_UTIL_JPEG_FMT_RGB888) {
debug_log("JPEG -> RGB %d/%d ... ", _sf.num, _sf.denom);
}
_tj(tjDecompress2(handle, jpegBuf, jpegSize, decoded_data->data, scaledWidth, 0, scaledHeight, TJPF_RGB, TD_BU));
debug_log("MM_UTIL_JPEG_FMT_RGB888, dstBuf: %p", decoded_data->data);
decoded_data->format=MM_UTIL_JPEG_FMT_RGB888;
- }else {
- debug_error"[%s][%05d] We can't support the IMAGE format");
- return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ } else {
+ debug_error("[%s][%05d] We can't support the IMAGE format");
+ return;
}
decoded_data->size=dstSize;
{
if(_hdrsubsamp == TJSAMP_422) {
debug_log("_hdrsubsamp == TJSAMP_422", decoded_data->width, _hdrw);
- decoded_data->width=MM_LIBJPEG_TURBO_ROUND_UP_2(_hdrw);
- }else {
+ decoded_data->width=MM_JPEG_ROUND_UP_2(_hdrw);
+ } else {
if(_hdrw% 4 != 0) {
- decoded_data->width=MM_LIBJPEG_TURBO_ROUND_UP_4(_hdrw);
- }else {
+ decoded_data->width=MM_JPEG_ROUND_UP_4(_hdrw);
+ } else {
decoded_data->width=_hdrw;
}
}
if(_hdrsubsamp == TJSAMP_420) {
debug_log("_hdrsubsamp == TJSAMP_420", decoded_data->width, _hdrw);
if(_hdrh% 4 != 0) {
- decoded_data->height=MM_LIBJPEG_TURBO_ROUND_UP_4(_hdrh);
- }else {
+ decoded_data->height=MM_JPEG_ROUND_UP_4(_hdrh);
+ } else {
decoded_data->height=_hdrh;
}
- }else {
+ } else {
decoded_data->height=_hdrh;
}
decoded_data->size = dstSize;
void *src = fopen(pFileName, "rb" );
if(src == NULL) {
- debug_error("Error");
+ debug_error("Error [%s] failed \t %s", pFileName, strerror(errno));
return MM_ERROR_IMAGE_FILEOPEN;
}
fseek (src, 0, SEEK_END);
debug_error("dhandle=tjInitDecompress()) is NULL");
return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
}
- srcBuf=(unsigned char *)malloc(sizeof(char*) * jpegSize);
+ srcBuf=(unsigned char *)malloc(sizeof(char) * jpegSize);
if(srcBuf==NULL) {
fclose(src);
tjDestroy(dhandle);
debug_error("dhandle=tjInitDecompress()) is NULL");
return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
}
- srcBuf=(unsigned char *)malloc(sizeof(char*) * size);
+ srcBuf=(unsigned char *)malloc(sizeof(char) * size);
if(srcBuf==NULL) {
fclose(src);
tjDestroy(dhandle);
if(srcBuf==NULL) {
debug_error("srcBuf is NULL");
- return MM_ERROR_IMAGE_NO_FREE_SPACE;
- }else {
+ return;
+ } else {
debug_log("srcBuf: 0x%2x", srcBuf);
if(fmt==MM_UTIL_JPEG_FMT_RGB888) {
initBuf(srcBuf, w, h, TJPF_RGB, flags);
- }else if(fmt==MM_UTIL_JPEG_FMT_YUV420 || fmt==MM_UTIL_JPEG_FMT_YUV422) {
+ } else if(fmt==MM_UTIL_JPEG_FMT_YUV420 || fmt==MM_UTIL_JPEG_FMT_YUV422) {
initBuf(srcBuf, w, h, TJPF_GRAY, flags);
- }else {
+ } else {
free(srcBuf);
debug_error("[%s][%05d] We can't support the IMAGE format");
- return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ return;
}
memcpy(srcBuf, src, jpegSize);
}
if(fmt==MM_UTIL_JPEG_FMT_RGB888) {
_tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_RGB, dstBuf, dstSize, TJPF_RGB, jpegQual, flags));
debug_log("*dstSize: %d", *dstSize);
- }else if(fmt==MM_UTIL_JPEG_FMT_YUV420) {
+ } else if(fmt==MM_UTIL_JPEG_FMT_YUV420) {
*dstSize=TJBUFSIZEYUV(w, h, TJSAMP_420);
_tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_RGB, *dstBuf, TJSAMP_420, flags));
debug_log("*dstSize: %d \t decode_yuv_subsample: %d TJBUFSIZE(w, h):%d", *dstSize, TJSAMP_420, TJBUFSIZE(w, h));
- }else if(fmt==MM_UTIL_JPEG_FMT_YUV422) {
+ } else if(fmt==MM_UTIL_JPEG_FMT_YUV422) {
*dstSize=TJBUFSIZEYUV(w, h, TJSAMP_422);
_tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_RGB, *dstBuf, TJSAMP_422, flags));
debug_log("*dstSize: %d \t decode_yuv_subsample: %d TJBUFSIZE(w, h):%d", *dstSize, TJSAMP_422, TJBUFSIZE(w, h));
- }else {
+ } else {
debug_error("fmt:%d is wrong", fmt);
}
if(srcBuf) {
int TD_BU=0;
FILE *fout=fopen(filename, "w+");
if(fout == NULL) {
- debug_error("FILE OPEN FAIL");
+ debug_error("FILE OPEN FAIL [%s] failed \t %s", filename, strerror(errno));
return MM_ERROR_IMAGE_FILEOPEN;
}
debug_log("fmt: %d", fmt);
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
-
+ int i, j, flag, _height;
FILE * fpWriter;
JSAMPROW y[16],cb[16],cr[16]; /* y[2][5] = color sample of row 2 and pixel column 5; (one plane) */
return MM_ERROR_IMAGE_FILEOPEN;
}
- int i,j;
data[0] = y;
data[1] = cb;
data[2] = cr;
jpeg_create_compress(&cinfo);
if ((fpWriter = fopen(pFileName, "wb")) == NULL) {
- debug_error("Exit on error");
+ debug_error("[infile] file open [%s] failed \t %s", pFileName, strerror(errno));
return MM_ERROR_IMAGE_FILEOPEN;
}
- if ( fmt == MM_UTIL_JPEG_FMT_RGB888) {
- jpeg_stdio_dest(&cinfo, fpWriter);
- debug_log("jpeg_stdio_dest for MM_UTIL_JPEG_FMT_RGB888");
- }
-
+ jpeg_stdio_dest(&cinfo, fpWriter);
cinfo.image_width = width;
cinfo.image_height = height;
+ if (fmt ==MM_UTIL_JPEG_FMT_YUV420 ||fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+ debug_log("[mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for YUV");
+ debug_log("[Height] %d", height);
+ _height = MM_JPEG_ROUND_DOWN_16(height);
+ flag = height - _height;
- if(fmt ==MM_UTIL_JPEG_FMT_YUV420 ||fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_YCbCr;
- debug_log("JCS_YCbCr");
+ debug_log("JCS_YCbCr [%d] ", flag);
jpeg_set_defaults(&cinfo);
debug_log("jpeg_set_defaults");
cinfo.do_fancy_downsampling = FALSE;
cinfo.comp_info[0].h_samp_factor = 2;
- cinfo.comp_info[0].v_samp_factor = 2;
+ if (fmt ==MM_UTIL_JPEG_FMT_YUV420) {
+ cinfo.comp_info[0].v_samp_factor = 2;
+ } else if (fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+ cinfo.comp_info[0].v_samp_factor = 1;
+ }
cinfo.comp_info[1].h_samp_factor = 1;
cinfo.comp_info[1].v_samp_factor = 1;
cinfo.comp_info[2].h_samp_factor = 1;
debug_log("jpeg_set_quality");
cinfo.dct_method = JDCT_FASTEST;
- jpeg_stdio_dest(&cinfo, fpWriter);
-
jpeg_start_compress(&cinfo, TRUE);
debug_log("jpeg_start_compress");
- for (j = 0; j < height; j += 16) {
- for (i = 0; i < 16; i++) {
+ if(flag) {
+ void *large_rect = malloc (width);
+ void *small_rect = malloc (width);
+ if(large_rect) {
+ memset(large_rect, 0x10, width);
+ } else {
+ debug_error("large rectangle memory");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+ if(small_rect) {
+ memset(small_rect, 0x80, width);
+ } else {
+ free(large_rect);
+ debug_error("small rectangle memory");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+
+ for (j = 0; j < _height; j += 16) {
+ for (i = 0; i < 16; i++) {
+ y[i] = (JSAMPROW)rawdata + width * (i + j);
+ if (i % 2 == 0) {
+ cb[i / 2] = (JSAMPROW)rawdata + width * height + width / 2 * ((i + j) / 2);
+ cr[i / 2] = (JSAMPROW)rawdata + width * height + width * height / 4 + width / 2 * ((i + j) / 2);
+ }
+ }
+ jpeg_write_raw_data(&cinfo, data, 16);
+ }
+ for (i = 0; i < flag; i++) {
y[i] = (JSAMPROW)rawdata + width * (i + j);
if (i % 2 == 0) {
cb[i / 2] = (JSAMPROW)rawdata + width * height + width / 2 * ((i + j) / 2);
cr[i / 2] = (JSAMPROW)rawdata + width * height + width * height / 4 + width / 2 * ((i + j) / 2);
}
}
+ for (; i < 16; i++) {
+ y[i] = (JSAMPROW)large_rect;
+ if (i % 2 == 0) {
+ cb[i / 2] = (JSAMPROW)small_rect;
+ cr[i / 2] = (JSAMPROW)small_rect;
+ }
+ }
jpeg_write_raw_data(&cinfo, data, 16);
+ free(large_rect);
+ free(small_rect);
+ } else {
+ for (j = 0; j < height; j += 16) {
+ for (i = 0; i < 16; i++) {
+ y[i] = (JSAMPROW)rawdata + width * (i + j);
+ if (i % 2 == 0) {
+ cb[i / 2] = (JSAMPROW)rawdata + width * height + width / 2 * ((i + j) / 2);
+ cr[i / 2] = (JSAMPROW)rawdata + width * height + width * height / 4 + width / 2 * ((i + j) / 2);
+ }
+ }
+ jpeg_write_raw_data(&cinfo, data, 16);
+ }
}
debug_log("#for loop#");
jpeg_destroy_compress(&cinfo);
debug_log("jpeg_destroy_compress");
- }else if (fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ }
+
+ else if (fmt == MM_UTIL_JPEG_FMT_RGB888 ||fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
JSAMPROW row_pointer[1];
- int iRowStride;
+ int iRowStride = 0;
if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
debug_log("JCS_RGB");
- }else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
cinfo.input_components = 1; /* one colour component */
cinfo.in_color_space = JCS_GRAYSCALE;
debug_log("JCS_GRAYSCALE");
+ } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ cinfo.input_components = 4; /* one colour component */
+ cinfo.in_color_space = JCS_EXT_RGBA;
+ debug_log("JCS_EXT_RGBA");
+ } else if(fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ cinfo.input_components = 4;
+ cinfo.in_color_space = JCS_EXT_BGRA;
+ debug_log("JCS_EXT_BGRA");
+ } else if(fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ cinfo.input_components = 4;
+ cinfo.in_color_space = JCS_EXT_ARGB;
+ debug_log("JCS_EXT_ARGB");
}
jpeg_set_defaults(&cinfo);
debug_log("jpeg_start_compress");
if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
iRowStride = width * 3;
- }else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
iRowStride = width;
+ } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ iRowStride = width * 4;
}
while (cinfo.next_scanline < cinfo.image_height) {
- row_pointer[0] = &rawdata[cinfo.next_scanline * iRowStride];
+ row_pointer[0] = (JSAMPROW)&rawdata[cinfo.next_scanline * iRowStride];
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
debug_log("while");
jpeg_destroy_compress(&cinfo);
debug_log("jpeg_destroy_compress");
- }else {
+ } else {
debug_error("We can't encode the IMAGE format");
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
-
+ fsync((int)fpWriter);
+ debug_log("[fsync] FILE");
fclose(fpWriter);
return iErrorCode;
}
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
- int i, j;
+ int i, j, flag, _height;
*csize = 0;
data[0] = y;
data[1] = cb;
debug_log("[mm_image_encode_to_jpeg_memory_with_libjpeg] #After jpeg_mem_dest#, mem: %p\t width: %d\t height: %d\t fmt: %d\t quality: %d"
, mem, width, height, fmt, quality);
- if ( fmt == MM_UTIL_JPEG_FMT_RGB888) {
- jpeg_mem_dest(&cinfo, (unsigned char **)mem, (unsigned long *)csize);
- debug_log("[mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for MM_UTIL_JPEG_FMT_RGB888");
- }
-
+ jpeg_mem_dest(&cinfo, (unsigned char **)mem, (unsigned long *)csize);
cinfo.image_width = width;
cinfo.image_height = height;
+ if (fmt ==MM_UTIL_JPEG_FMT_YUV420 ||fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+ debug_log("[mm_image_encode_to_jpeg_file_with_libjpeg] jpeg_stdio_dest for YUV");
+ _height = MM_JPEG_ROUND_DOWN_16(height);
+ flag = height - _height;
- if(fmt ==MM_UTIL_JPEG_FMT_YUV420 ||fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_YCbCr;
jpeg_set_defaults(&cinfo);
cinfo.do_fancy_downsampling = FALSE;
cinfo.comp_info[0].h_samp_factor = 2;
- cinfo.comp_info[0].v_samp_factor = 2;
+ if (fmt ==MM_UTIL_JPEG_FMT_YUV420) {
+ cinfo.comp_info[0].v_samp_factor = 2;
+ } else if (fmt ==MM_UTIL_JPEG_FMT_YUV422 || fmt ==MM_UTIL_JPEG_FMT_UYVY) {
+ cinfo.comp_info[0].v_samp_factor = 1;
+ }
cinfo.comp_info[1].h_samp_factor = 1;
cinfo.comp_info[1].v_samp_factor = 1;
cinfo.comp_info[2].h_samp_factor = 1;
debug_log("jpeg_set_quality");
cinfo.dct_method = JDCT_FASTEST;
- jpeg_mem_dest(&cinfo, (unsigned char **)mem, (unsigned long *)csize);
-
jpeg_start_compress(&cinfo, TRUE);
debug_log("jpeg_start_compress");
- for (j = 0; j < height; j += 16) {
- for (i = 0; i < 16; i++) {
+ if(flag) {
+ void *large_rect = malloc (width);
+ void *small_rect = malloc (width);
+ if(large_rect) {
+ memset(large_rect, 0x10, width);
+ } else {
+ debug_error("large rectangle memory");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+ if(small_rect) {
+ memset(small_rect, 0x80, width);
+ } else {
+ free(large_rect);
+ debug_error("small rectangle memory");
+ return MM_ERROR_IMAGEHANDLE_NOT_INITIALIZED;
+ }
+
+ for (j = 0; j < _height; j += 16) {
+ for (i = 0; i < 16; i++) {
+ y[i] = (JSAMPROW)rawdata + width * (i + j);
+ if (i % 2 == 0) {
+ cb[i / 2] = (JSAMPROW)rawdata + width * height + width / 2 * ((i + j) / 2);
+ cr[i / 2] = (JSAMPROW)rawdata + width * height + width * height / 4 + width / 2 * ((i + j) / 2);
+ }
+ }
+ jpeg_write_raw_data(&cinfo, data, 16);
+ }
+ for (i = 0; i < flag; i++) {
y[i] = (JSAMPROW)rawdata + width * (i + j);
if (i % 2 == 0) {
cb[i / 2] = (JSAMPROW)rawdata + width * height + width / 2 * ((i + j) / 2);
cr[i / 2] = (JSAMPROW)rawdata + width * height + width * height / 4 + width / 2 * ((i + j) / 2);
}
}
+ for (; i < 16; i++) {
+ y[i] = (JSAMPROW)large_rect;
+ if (i % 2 == 0) {
+ cb[i / 2] = (JSAMPROW)small_rect;
+ cr[i / 2] = (JSAMPROW)small_rect;
+ }
+ }
jpeg_write_raw_data(&cinfo, data, 16);
+ free(large_rect);
+ free(small_rect);
+ } else {
+ for (j = 0; j < height; j += 16) {
+ for (i = 0; i < 16; i++) {
+ y[i] = (JSAMPROW)rawdata + width * (i + j);
+ if (i % 2 == 0) {
+ cb[i / 2] = (JSAMPROW)rawdata + width * height + width / 2 * ((i + j) / 2);
+ cr[i / 2] = (JSAMPROW)rawdata + width * height + width * height / 4 + width / 2 * ((i + j) / 2);
+ }
+ }
+ jpeg_write_raw_data(&cinfo, data, 16);
+ }
}
debug_log("#for loop#");
debug_log("Exit jpeg_destroy_compress, mem: %p\t size:%d", *mem, *csize);
}
- else if (fmt == MM_UTIL_JPEG_FMT_RGB888 ||fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ else if (fmt == MM_UTIL_JPEG_FMT_RGB888 ||fmt == MM_UTIL_JPEG_FMT_GraySacle || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
JSAMPROW row_pointer[1];
- int iRowStride;
+ int iRowStride = 0;
debug_log("MM_UTIL_JPEG_FMT_RGB888");
if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
debug_log("JCS_RGB");
- }else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
cinfo.input_components = 1; /* one colour component */
cinfo.in_color_space = JCS_GRAYSCALE;
debug_log("JCS_GRAYSCALE");
+ } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ cinfo.input_components = 4;
+ cinfo.in_color_space = JCS_EXT_RGBA;
+ debug_log("JCS_EXT_RGBA");
+ } else if(fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ cinfo.input_components = 4;
+ cinfo.in_color_space = JCS_EXT_BGRA;
+ debug_log("JCS_EXT_BGRA");
+ } else if(fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ cinfo.input_components = 4;
+ cinfo.in_color_space = JCS_EXT_ARGB;
+ debug_log("JCS_EXT_ARGB");
}
jpeg_set_defaults(&cinfo);
debug_log("jpeg_start_compress");
if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
iRowStride = width * 3;
- }else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(fmt == MM_UTIL_JPEG_FMT_GraySacle) {
iRowStride = width;
+ } else if(fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ iRowStride = width * 4;
}
while (cinfo.next_scanline < cinfo.image_height) {
- row_pointer[0] = &rawdata[cinfo.next_scanline * iRowStride];
+ row_pointer[0] = (JSAMPROW)&rawdata[cinfo.next_scanline * iRowStride];
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
debug_log("while");
jpeg_destroy_compress(&cinfo);
- debug_log(" Exit");
+ debug_log("Exit");
} else {
debug_error("We can't encode the IMAGE format");
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
debug_error("pFileName");
return MM_ERROR_IMAGE_FILEOPEN;
}
+ if(decoded_data) {
+ decoded_data->data = NULL;
+ }
infile = fopen(pFileName, "rb");
if(infile == NULL) {
- debug_error("[infile] Exit on error");
+ debug_error("[infile] file open [%s] \t %s", pFileName, strerror(errno));
return MM_ERROR_IMAGE_FILEOPEN;
}
debug_log("infile");
/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp(jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. We need to clean up the JPEG object, close the input file, and return.*/
+ /* If we get here, the JPEG code has signaled an error. We need to clean up the JPEG object, close the input file, and return.*/
debug_log("setjmp");
jpeg_destroy_decompress(&dinfo);
+ if(decoded_data->data) {
+ free(decoded_data->data);
+ decoded_data->data = NULL;
+ debug_log("free data");
+ }
fclose(infile);
- return MM_ERROR_IMAGE_FILEOPEN;
+ debug_log("fclose");
+ return MM_ERROR_IMAGE_INVALID_VALUE;
}
debug_log("if(setjmp)");
/*read file parameters with jpeg_read_header() */
jpeg_read_header(&dinfo, TRUE);
#if PARTIAL_DECODE
- dinfo.do_fancy_upsampling = FALSE;
- dinfo.do_block_smoothing = FALSE;
- dinfo.dither_mode = JDITHER_ORDERED;
+ debug_log("image width: %d height: %d", dinfo.image_width, dinfo.image_height);
+ if(dinfo.image_width > ENC_MAX_LEN || dinfo.image_height > ENC_MAX_LEN) {
+ dinfo.scale_num = 1;
+ dinfo.scale_denom = 8;
+ dinfo.do_fancy_upsampling = FALSE;
+ dinfo.do_block_smoothing = FALSE;
+ dinfo.dither_mode = JDITHER_ORDERED;
+ }
#endif
dinfo.dct_method = JDCT_FASTEST;
/* set parameters for decompression */
if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
dinfo.out_color_space=JCS_RGB;
- decoded_data->format = MM_UTIL_JPEG_FMT_RGB888;
debug_log("cinfo.out_color_space=JCS_RGB");
- }else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
dinfo.out_color_space=JCS_YCbCr;
- decoded_data->format = input_fmt;
debug_log("cinfo.out_color_space=JCS_YCbCr");
- }else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
dinfo.out_color_space=JCS_GRAYSCALE;
- decoded_data->format = MM_UTIL_JPEG_FMT_GraySacle;
debug_log("cinfo.out_color_space=JCS_GRAYSCALE");
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ dinfo.out_color_space=JCS_EXT_RGBA;
+ debug_log("cinfo.out_color_space=JCS_EXT_RGBA");
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ dinfo.out_color_space=JCS_EXT_BGRA;
+ debug_log("cinfo.out_color_space=JCS_EXT_BGRA");
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ dinfo.out_color_space=JCS_EXT_ARGB;
+ debug_log("cinfo.out_color_space=JCS_EXT_ARGB");
}
+ decoded_data->format = input_fmt;
/* Start decompressor*/
jpeg_start_decompress(&dinfo);
/* JSAMPLEs per row in output buffer */
row_stride = dinfo.output_width * dinfo.output_components;
-
+
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*dinfo.mem->alloc_sarray) ((j_common_ptr) &dinfo, JPOOL_IMAGE, row_stride, 1);
- debug_log("buffer");
+ debug_log("JPOOL_IMAGE BUFFER");
decoded_data->width = dinfo.output_width;
decoded_data->height= dinfo.output_height;
- if(input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
decoded_data->size= dinfo.output_height * row_stride;
- }else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
decoded_data->size= dinfo.output_height * row_stride / 2;
- }else if(input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
decoded_data->size= dinfo.output_height * dinfo.output_width * 2;
- }else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
decoded_data->size= dinfo.output_height * dinfo.output_width;
- }else{
- debug_error("We can't decode the IMAGE format");
+ } else{
+ jpeg_destroy_decompress(&dinfo);
+ debug_error("[%d] We can't decode the IMAGE format", input_fmt);
+ fclose(infile);
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
decoded_data->format = input_fmt;
if(decoded_data->data == NULL) {
+ jpeg_destroy_decompress(&dinfo);
debug_error("decoded_data->data is NULL");
+ fclose(infile);
return MM_ERROR_IMAGE_NO_FREE_SPACE;
}
debug_log("decoded_data->data");
if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
image = decoded_data->data;
u_image = image + (dinfo.output_width * dinfo.output_height);
- v_image = u_image + (dinfo.output_width*dinfo.output_height)/4;
+ v_image = u_image + (dinfo.output_width*dinfo.output_height) / 4;
row= buffer[0];
int i = 0;
int y = 0;
v_image += dinfo.output_width / 2;
}
}
- }else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ }else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
/* while (scan lines remain to be read) jpeg_read_scanlines(...); */
while (dinfo.output_scanline < dinfo.output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
memcpy(decoded_data->data + state, buffer[0], row_stride);
state += row_stride;
}
- debug_log("while");
+ debug_log("jpeg_read_scanlines");
}
/* Finish decompression */
return MM_ERROR_IMAGE_FILEOPEN;
}
debug_log("infile");
+ if(decoded_data) {
+ decoded_data->data = NULL;
+ }
/* allocate and initialize JPEG decompression object We set up the normal JPEG error routines, then override error_exit. */
dinfo.err = jpeg_std_error(&jerr.pub);
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. We need to clean up the JPEG object, close the input file, and return.*/
debug_log("setjmp");
+ if(decoded_data->data) {
+ free(decoded_data->data);
+ decoded_data->data = NULL;
+ }
+
jpeg_destroy_decompress(&dinfo);
return MM_ERROR_IMAGE_FILEOPEN;
}
/*read file parameters with jpeg_read_header() */
jpeg_read_header(&dinfo, TRUE);
debug_log("jpeg_read_header");
+#if PARTIAL_DECODE
+ debug_log("image width: %d height: %d", dinfo.image_width, dinfo.image_height);
+ if(dinfo.image_width > ENC_MAX_LEN || dinfo.image_height > ENC_MAX_LEN) {
+ dinfo.scale_num = 1;
+ dinfo.scale_denom = 8;
+ dinfo.do_fancy_upsampling = FALSE;
+ dinfo.do_block_smoothing = FALSE;
+ dinfo.dither_mode = JDITHER_ORDERED;
+ }
+#endif
dinfo.dct_method = JDCT_FASTEST;
/* set parameters for decompression */
if (input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
dinfo.out_color_space=JCS_RGB;
- decoded_data->format = MM_UTIL_JPEG_FMT_RGB888;
debug_log("cinfo.out_color_space=JCS_RGB");
- }else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420 || input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
dinfo.out_color_space=JCS_YCbCr;
- decoded_data->format = input_fmt;
debug_log("cinfo.out_color_space=JCS_YCbCr");
- }else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
dinfo.out_color_space=JCS_GRAYSCALE;
- decoded_data->format = MM_UTIL_JPEG_FMT_GraySacle;
debug_log("cinfo.out_color_space=JCS_GRAYSCALE");
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_RGBA8888) {
+ dinfo.out_color_space=JCS_EXT_RGBA;
+ debug_log("cinfo.out_color_space=JCS_EXT_RGBA");
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_BGRA8888) {
+ dinfo.out_color_space=JCS_EXT_BGRA;
+ debug_log("cinfo.out_color_space=JCS_EXT_BGRA");
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
+ dinfo.out_color_space=JCS_EXT_ARGB;
+ debug_log("cinfo.out_color_space=JCS_EXT_ARGB");
}
+ decoded_data->format = input_fmt;
/* Start decompressor*/
jpeg_start_decompress(&dinfo);
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*dinfo.mem->alloc_sarray) ((j_common_ptr) &dinfo, JPOOL_IMAGE, row_stride, 1);
- debug_log("buffer");
+ debug_log("JPOOL_IMAGE BUFFER");
decoded_data->width = dinfo.output_width;
decoded_data->height= dinfo.output_height;
- if(input_fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
decoded_data->size= dinfo.output_height * row_stride;
- }else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV420) {
decoded_data->size= dinfo.output_height * row_stride / 2;
- }else if(input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_YUV422 || input_fmt == MM_UTIL_JPEG_FMT_UYVY) {
decoded_data->size= dinfo.output_height * dinfo.output_width * 2;
- }else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
decoded_data->size= dinfo.output_height * dinfo.output_width;
- }else{
- debug_error("We can't decode the IMAGE format");
+ } else{
+ jpeg_destroy_decompress(&dinfo);
+ debug_error("[%d] We can't decode the IMAGE format", input_fmt);
return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
}
decoded_data->format = input_fmt;
if(decoded_data->data == NULL) {
+ jpeg_destroy_decompress(&dinfo);
debug_error("decoded_data->data is NULL");
return MM_ERROR_IMAGE_NO_FREE_SPACE;
}
v_image += dinfo.output_width / 2;
}
}
- }else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
+ } else if(input_fmt == MM_UTIL_JPEG_FMT_RGB888 ||input_fmt == MM_UTIL_JPEG_FMT_GraySacle || input_fmt == MM_UTIL_JPEG_FMT_RGB888 || input_fmt == MM_UTIL_JPEG_FMT_RGBA8888 || input_fmt == MM_UTIL_JPEG_FMT_BGRA8888 || input_fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
while (dinfo.output_scanline < dinfo.output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
jpeg_read_scanlines(&dinfo, buffer, 1);
memcpy(decoded_data->data + state, buffer[0], row_stride);
state += row_stride;
}
- debug_log("while");
+ debug_log("jpeg_read_scanlines");
}
return iErrorCode;
}
+static int _mm_util_set_exif_entry(ExifData *exif, ExifIfd ifd, ExifTag tag,ExifFormat format, unsigned long components, unsigned char* data)
+{
+ ExifData *ed = (ExifData *)exif;
+ ExifEntry *e = NULL;
+
+ if (exif == NULL || format <= 0 || components <= 0 || data == NULL) {
+ debug_error("invalid argument exif = %p format = %d, components = %lu data = %p!",
+ exif, format, components, data);
+ return -1;
+ }
+
+ /*remove same tag in EXIF*/
+ exif_content_remove_entry(ed->ifd[ifd], exif_content_get_entry(ed->ifd[ifd], tag));
+
+ /*create new tag*/
+ e = exif_entry_new();
+ if (e == NULL) {
+ debug_error("entry create error!");
+ return -1;
+ }
+
+ exif_entry_initialize(e, tag);
+
+ e->tag = tag;
+ e->format = format;
+ e->components = components;
+
+ if (e->size == 0) {
+ e->data = NULL;
+ e->data = malloc(exif_format_get_size(format) * e->components);
+ if (!e->data) {
+ exif_entry_unref(e);
+ return -1;
+ }
+
+ if (format == EXIF_FORMAT_ASCII) {
+ memset(e->data, '\0', exif_format_get_size(format) * e->components);
+ }
+ }
+
+ e->size = exif_format_get_size(format) * e->components;
+ memcpy(e->data,data,e->size);
+ exif_content_add_entry(ed->ifd[ifd], e);
+ exif_entry_unref(e);
+
+ return 0;
+}
+
EXPORT_API int
mm_util_jpeg_encode_to_file(char *filename, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
{
int ret = MM_ERROR_NONE;
- int use_hw_codec = 0;
- char *env_value = NULL;
if( !filename || !src) {
debug_error("#ERROR# filename || src buffer is NULL");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_YUYV) ) {
+ if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
debug_error("#ERROR# fmt value");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- /* check environment value */
- env_value = getenv(ENV_NAME_USE_HW_CODEC);
- if (env_value) {
- use_hw_codec = atoi(env_value);
- debug_log("%s - value str:%s -> int:%d",
- ENV_NAME_USE_HW_CODEC, env_value, use_hw_codec);
- }
-
- /* check whether support HW codec */
- if (use_hw_codec) {
- int size = 0;
- void *mem = NULL;
- void *dl_handle = NULL;
- EncodeJPEGFunc encode_jpeg_func = NULL;
-
- /* dlopen library */
- dl_handle = dlopen(LIB_PATH_HW_CODEC_LIBRARY, RTLD_LAZY);
- if (!dl_handle) {
- debug_warning("H/W JPEG not supported");
- goto JPEG_SW_ENCODE;
- }
-
- /* find function symbol */
- encode_jpeg_func = (EncodeJPEGFunc)dlsym(dl_handle, ENCODE_JPEG_HW_FUNC_NAME);
- if (!encode_jpeg_func) {
- debug_warning("find func[%s] failed",
- ENCODE_JPEG_HW_FUNC_NAME);
- /* close dl_handle */
- dlclose(dl_handle);
- dl_handle = NULL;
- goto JPEG_SW_ENCODE;
- }
-
- /* Do H/W jpeg encoding */
- ret = encode_jpeg_func(src, width, height, fmt, quality, (unsigned char **)&mem, &size);
-
- /* close dl_handle */
- dlclose(dl_handle);
- dl_handle = NULL;
-
- if (ret == MM_ERROR_NONE) {
- debug_log("HW ENCODE DONE.. Write file");
- if (mem && size > 0) {
- if (!_write_file(filename, mem, size)) {
- debug_error("failed Write file");
- ret = MM_ERROR_IMAGE_INTERNAL;
- }
-
- free(mem);
- mem = NULL;
- size = 0;
-
- return ret;
- } else {
- debug_warning("invalid data %p, size %d", mem, size);
- }
- } else {
- debug_warning("HW encode failed %x", ret);
- }
- }
-
-JPEG_SW_ENCODE:
- #if LIBJPEG_TURBO
+#if LIBJPEG_TURBO
debug_log("#START# LIBJPEG_TURBO");
ret=mm_image_encode_to_jpeg_file_with_libjpeg_turbo(filename, src, width, height, fmt, quality);
debug_log("#End# libjpeg, Success!! ret: %d", ret);
- #else
+#else
debug_log("#START# LIBJPEG");
- ret=mm_image_encode_to_jpeg_file_with_libjpeg(filename, src, width, height, fmt, quality);
+ if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+ unsigned int dst_size = 0;
+ ret = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
+ unsigned char *dst = NULL;
+ dst = malloc(dst_size);
+ if(dst) {
+ ret = mm_util_convert_colorspace(src, width, height,MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
+ ret =mm_image_encode_to_jpeg_file_with_libjpeg(filename, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
+ free(dst); dst=NULL;
+ } else {
+ return MM_ERROR_IMAGE_NO_FREE_SPACE;
+ }
+ } else if(fmt == MM_UTIL_JPEG_FMT_NV21) {
+ return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ } else {
+ ret = mm_image_encode_to_jpeg_file_with_libjpeg(filename, src, width, height, fmt, quality);
+ }
debug_log("#END# libjpeg, Success!! ret: %d", ret);
- #endif
+#endif
return ret;
}
mm_util_jpeg_encode_to_memory(void **mem, int *size, void* src, int width, int height, mm_util_jpeg_yuv_format fmt, int quality)
{
int ret = MM_ERROR_NONE;
- int use_hw_codec = 0;
- char *env_value = NULL;
if( !mem || !size || !src) {
debug_error("#ERROR# filename ||size || src buffer is NULL");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_YUYV) ) {
+ if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
debug_error("#ERROR# fmt value");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- /* check environment value */
- env_value = getenv(ENV_NAME_USE_HW_CODEC);
- if (env_value) {
- use_hw_codec = atoi(env_value);
- debug_log("%s - value str:%s -> int:%d",
- ENV_NAME_USE_HW_CODEC, env_value, use_hw_codec);
- }
-
- /* check whether support HW codec */
- if (use_hw_codec) {
- void *dl_handle = NULL;
- EncodeJPEGFunc encode_jpeg_func = NULL;
-
- /* dlopen library */
- dl_handle = dlopen(LIB_PATH_HW_CODEC_LIBRARY, RTLD_LAZY);
- if (!dl_handle) {
- debug_warning("H/W JPEG not supported");
- goto JPEG_SW_ENCODE;
- }
-
- /* find function symbol */
- encode_jpeg_func = (EncodeJPEGFunc)dlsym(dl_handle, ENCODE_JPEG_HW_FUNC_NAME);
- if (!encode_jpeg_func) {
- debug_warning("find func[%s] failed",
- ENCODE_JPEG_HW_FUNC_NAME);
- /* close dl_handle */
- dlclose(dl_handle);
- dl_handle = NULL;
- goto JPEG_SW_ENCODE;
- }
-
- /* Do H/W jpeg encoding */
- ret = encode_jpeg_func(src, width, height, fmt, quality, (unsigned char **)mem, size);
-
- /* close dl_handle */
- dlclose(dl_handle);
- dl_handle = NULL;
-
- if (ret == MM_ERROR_NONE) {
- debug_log("HW ENCODE DONE");
- return ret;
- } else {
- debug_warning("HW encode failed %x", ret);
- }
- }
-
-JPEG_SW_ENCODE:
#if LIBJPEG_TURBO
- debug_log("#START# libjpeg");
+ debug_log("#START# libjpeg-turbo");
ret=mm_image_encode_to_jpeg_memory_with_libjpeg_turbo(mem, size, src, width, height, fmt, quality);
- debug_log("#END# libjpeg, Success!! ret: %d", ret);
+ debug_log("#END# libjpeg-turbo, Success!! ret: %d", ret);
#else /* LIBJPEG_TURBO */
debug_log("#START# libjpeg");
- ret = mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, src, width, height, fmt, quality);
- debug_log("#End# libjpeg, Success!! ret: %d", ret);
- #endif /* LIBJPEG_TURBO */
-
+ if(fmt == MM_UTIL_JPEG_FMT_NV12) {
+ unsigned int dst_size = 0;
+ ret = mm_util_get_image_size(MM_UTIL_IMG_FMT_NV12, (unsigned int)width, (unsigned int)height, &dst_size);
+ unsigned char *dst = NULL;
+ dst = malloc(dst_size);
+ if(dst) {
+ ret = mm_util_convert_colorspace(src, width, height,MM_UTIL_IMG_FMT_NV12, dst, MM_UTIL_IMG_FMT_YUV420);
+ ret = mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, dst, width, height, MM_UTIL_JPEG_FMT_YUV420, quality);
+ free(dst); dst=NULL;
+ } else {
+ return MM_ERROR_IMAGE_NO_FREE_SPACE;
+ }
+ } else if(fmt == MM_UTIL_JPEG_FMT_NV21) {
+ return MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ } else {
+ ret = mm_image_encode_to_jpeg_memory_with_libjpeg(mem, size, src, width, height, fmt, quality);
+ }
+#endif /* LIBJPEG_TURBO */
+ debug_log("#END# libjpeg, Success!! ret: %d", ret);
return ret;
}
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_GraySacle) ) {
+ if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
debug_error("#ERROR# fmt value");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- #if LIBJPEG_TURBO
- debug_log("#START# LIBJPEG_TURBO");
- ret = mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
- debug_log("decoded->data: %p\t width: %d\t height: %d\t size: %d\n", decoded->data, decoded->width, decoded->height, decoded->size);
- debug_log("#End# LIBJPEG_TURBO, Success!! ret: %d", ret);
- #else
- debug_log("#START# libjpeg");
- ret = mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, fmt);
- debug_log("decoded->data: %p\t width: %d\t height:%d\t size: %d\n", decoded->data, decoded->width, decoded->height, decoded->size);
- debug_log("#End# libjpeg, Success!! ret: %d", ret);
- #endif
+ FILE *fp = fopen(filename, "rb");
+ unsigned char magic[2] = {0};
+ if(fp) {
+ fread((void *)magic, 1, 2, fp);
+ debug_log("%x %x", magic[0], magic[1]);
+ fclose(fp);
+ }
+ if(magic[0] == 0xff && magic[1] == 0xd8) {
+ #if LIBJPEG_TURBO
+ debug_log("#START# LIBJPEG_TURBO");
+ ret = mm_image_decode_from_jpeg_file_with_libjpeg_turbo(decoded, filename, fmt);
+ debug_log("decoded->data: %p\t width: %d\t height: %d\t size: %d\n", decoded->data, decoded->width, decoded->height, decoded->size);
+ debug_log("#End# LIBJPEG_TURBO, Success!! ret: %d", ret);
+ #else
+ debug_log("#START# libjpeg");
+ ret = mm_image_decode_from_jpeg_file_with_libjpeg(decoded, filename, fmt);
+ debug_log("decoded->data: %p\t width: %d\t height:%d\t size: %d\n", decoded->data, decoded->width, decoded->height, decoded->size);
+ debug_log("#End# libjpeg, Success!! ret: %d", ret);
+ #endif
+ } else if(magic[0] == 0x47 && magic[1] == 0x49) {
+ debug_error("Not JPEG IMAGE - GIF");
+ ret = MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ } else if(magic[0] == 0x89 && magic[1] == 0x50) {
+ debug_error("Not JPEG IMAGE - PNG");
+ ret = MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ } else if(magic[0] == 0x49 && magic[1] == 0x49) {
+ debug_error("Not JPEG IMAGE - TIFF");
+ ret = MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ } else {
+ debug_error("Not JPEG IMAGE");
+ ret = MM_ERROR_IMAGE_NOT_SUPPORT_FORMAT;
+ }
+
return ret;
}
return MM_ERROR_IMAGE_INVALID_VALUE;
}
- if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_GraySacle) ) {
+ if( (fmt < MM_UTIL_JPEG_FMT_YUV420) || (fmt > MM_UTIL_JPEG_FMT_ARGB8888) ) {
debug_error("#ERROR# fmt value");
return MM_ERROR_IMAGE_INVALID_VALUE;
}
#endif
return ret;
}
-
-static int _write_file(char *file_name, void *data, int data_size)
-{
- FILE *fp = NULL;
-
- if (!file_name || !data || data_size <= 0) {
- debug_error("invalid data %s %p size:%d", file_name, data, data_size);
- return FALSE;
- }
-
- debug_log("Try to open %s to write", file_name);
-
- fp = fopen(file_name, "w");
- if (fp) {
- fwrite(data, 1, data_size, fp);
- fclose(fp);
- fp = NULL;
- } else {
- debug_error("file open [%s] failed errno %d", file_name, errno);
- return FALSE;
- }
-
- debug_log("file [%s] write DONE", file_name);
-
- return TRUE;
-}
-
mm_util_jpeg_testsuite_SOURCES = mm_util_jpeg_testsuite.c
mm_util_jpeg_testsuite_CFLAGS = -I$(srcdir)/../include
-mm_util_jpeg_testsuite_CFLAGS += $(MMTA_CFLAGS) -DGST_EXT_TIME_ANALYSIS \
- $(MMCOMMON_CFLAGS) \
+mm_util_jpeg_testsuite_CFLAGS += $(MMCOMMON_CFLAGS) \
$(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x0100 -DMMF_DEBUG_PREFIX=\"MMF-IMAGE\" \
$(TZ_PLATFORM_CONFIG_FLAGS)
############################################
-mm_util_jpeg_testsuite_DEPENDENCIES = $(srcdir)/../libmmutil_jpeg.la
-
-mm_util_jpeg_testsuite_LDADD = $(srcdir)/../libmmutil_jpeg.la
-mm_util_jpeg_testsuite_LDADD += $(MMTA_LIBS) \
- $(MMCOMMON_LIBS) \
+mm_util_jpeg_testsuite_DEPENDENCIES = $(srcdir)/../libmmutil_jpeg.la
+
+mm_util_jpeg_testsuite_LDADD = $(srcdir)/../libmmutil_jpeg.la
+mm_util_jpeg_testsuite_LDADD += $(MMCOMMON_LIBS) \
$(TZ_PLATFORM_CONFIG_LIBS)
#include <fcntl.h>
#include <unistd.h>
#include <mm_util_jpeg.h>
-#include <mm_ta.h>
#include <mm_error.h>
#include <mm_debug.h>
#include <tzplatform_config.h>
return 0;
}
- //g_type_init(); //when you include WINK
+ /*g_type_init(); //when you include WINK */
- MMTA_INIT();
if (!strcmp("encode", argv[1])) {
if (_read_file(argv[2], &src, &src_size)) {
quality = atoi(argv[5]);
fmt = atoi(argv[6]);
- __ta__("mm_util_jpeg_encode_to_memory",
ret = mm_util_jpeg_encode_to_memory(&dst, &dst_size, src, width, height, fmt, quality);
- );
} else {
ret = MM_ERROR_IMAGE_INTERNAL;
}
} else if (!strcmp("decode", argv[1])) {
if (_read_file(argv[2], &src, &src_size)) {
fmt = atoi(argv[3]);
- __ta__("mm_util_decode_from_jpeg_memory",
ret = mm_util_decode_from_jpeg_memory(&decoded_data, src, src_size, fmt);
- );
free(src);
src = NULL;
decoded_data.data, decoded_data.width, decoded_data.height, decoded_data.size);
char filename[BUFFER_SIZE];
memset(filename, 0, BUFFER_SIZE);
- if(fmt == MM_UTIL_JPEG_FMT_RGB888) {
+ if(fmt == MM_UTIL_JPEG_FMT_RGB888 || fmt == MM_UTIL_JPEG_FMT_RGBA8888 || fmt == MM_UTIL_JPEG_FMT_BGRA8888 || fmt == MM_UTIL_JPEG_FMT_ARGB8888) {
sprintf(filename, "%s%s", DECODE_RESULT_PATH, "rgb");
- } else if(fmt == MM_UTIL_JPEG_FMT_YUV420) {
+ } else if((fmt == MM_UTIL_JPEG_FMT_YUV420) ||
+ (fmt == MM_UTIL_JPEG_FMT_NV12) ||
+ (fmt == MM_UTIL_JPEG_FMT_NV21) ||
+ (fmt == MM_UTIL_JPEG_FMT_NV16) ||
+ (fmt == MM_UTIL_JPEG_FMT_NV61)) {
sprintf(filename, "%s%s", DECODE_RESULT_PATH, "yuv");
}
_write_file(filename, decoded_data.data, decoded_data.size);
}
}
- MMTA_ACUM_ITEM_SHOW_RESULT();
- MMTA_RELEASE ();
return 0;
}
+++ /dev/null
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-
-scriptversion=2006-05-10.23
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
-# Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
-fi
-
-run=:
-sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
-sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
- configure_ac=configure.ac
-else
- configure_ac=configure.in
-fi
-
-msg="missing on your system"
-
-case $1 in
---run)
- # Try to run requested program, and just exit if it succeeds.
- run=
- shift
- "$@" && exit 0
- # Exit code 63 means version mismatch. This often happens
- # when the user try to use an ancient version of a tool on
- # a file that requires a minimum version. In this case we
- # we should proceed has if the program had been absent, or
- # if --run hadn't been passed.
- if test $? = 63; then
- run=:
- msg="probably too old"
- fi
- ;;
-
- -h|--h|--he|--hel|--help)
- echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
- -h, --help display this help and exit
- -v, --version output version information and exit
- --run try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
- aclocal touch file \`aclocal.m4'
- autoconf touch file \`configure'
- autoheader touch file \`config.h.in'
- autom4te touch the output file, or create a stub one
- automake touch all \`Makefile.in' files
- bison create \`y.tab.[ch]', if possible, from existing .[ch]
- flex create \`lex.yy.c', if possible, from existing .c
- help2man touch the output file
- lex create \`lex.yy.c', if possible, from existing .c
- makeinfo touch the output file
- tar try tar, gnutar, gtar, then tar without non-portable flags
- yacc create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Send bug reports to <bug-automake@gnu.org>."
- exit $?
- ;;
-
- -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing $scriptversion (GNU Automake)"
- exit $?
- ;;
-
- -*)
- echo 1>&2 "$0: Unknown \`$1' option"
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
- ;;
-
-esac
-
-# Now exit if we have it, but it failed. Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).
-case $1 in
- lex|yacc)
- # Not GNU programs, they don't have --version.
- ;;
-
- tar)
- if test -n "$run"; then
- echo 1>&2 "ERROR: \`tar' requires --run"
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- exit 1
- fi
- ;;
-
- *)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- # Could not run --version or --help. This is probably someone
- # running `$TOOL --version' or `$TOOL --help' to check whether
- # $TOOL exists and not knowing $TOOL uses missing.
- exit 1
- fi
- ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case $1 in
- aclocal*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acinclude.m4' or \`${configure_ac}'. You might want
- to install the \`Automake' and \`Perl' packages. Grab them from
- any GNU archive site."
- touch aclocal.m4
- ;;
-
- autoconf)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`${configure_ac}'. You might want to install the
- \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
- archive site."
- touch configure
- ;;
-
- autoheader)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acconfig.h' or \`${configure_ac}'. You might want
- to install the \`Autoconf' and \`GNU m4' packages. Grab them
- from any GNU archive site."
- files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
- test -z "$files" && files="config.h"
- touch_files=
- for f in $files; do
- case $f in
- *:*) touch_files="$touch_files "`echo "$f" |
- sed -e 's/^[^:]*://' -e 's/:.*//'`;;
- *) touch_files="$touch_files $f.in";;
- esac
- done
- touch $touch_files
- ;;
-
- automake*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
- You might want to install the \`Automake' and \`Perl' packages.
- Grab them from any GNU archive site."
- find . -type f -name Makefile.am -print |
- sed 's/\.am$/.in/' |
- while read f; do touch "$f"; done
- ;;
-
- autom4te)
- echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
- You might have modified some files without having the
- proper tools for further handling them.
- You can get \`$1' as part of \`Autoconf' from any GNU
- archive site."
-
- file=`echo "$*" | sed -n "$sed_output"`
- test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo "#! /bin/sh"
- echo "# Created by GNU Automake missing as a replacement of"
- echo "# $ $@"
- echo "exit 0"
- chmod +x $file
- exit 1
- fi
- ;;
-
- bison|yacc)
- echo 1>&2 "\
-WARNING: \`$1' $msg. You should only need it if
- you modified a \`.y' file. You may need the \`Bison' package
- in order for those modifications to take effect. You can get
- \`Bison' from any GNU archive site."
- rm -f y.tab.c y.tab.h
- if test $# -ne 1; then
- eval LASTARG="\${$#}"
- case $LASTARG in
- *.y)
- SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if test -f "$SRCFILE"; then
- cp "$SRCFILE" y.tab.c
- fi
- SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if test -f "$SRCFILE"; then
- cp "$SRCFILE" y.tab.h
- fi
- ;;
- esac
- fi
- if test ! -f y.tab.h; then
- echo >y.tab.h
- fi
- if test ! -f y.tab.c; then
- echo 'main() { return 0; }' >y.tab.c
- fi
- ;;
-
- lex|flex)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.l' file. You may need the \`Flex' package
- in order for those modifications to take effect. You can get
- \`Flex' from any GNU archive site."
- rm -f lex.yy.c
- if test $# -ne 1; then
- eval LASTARG="\${$#}"
- case $LASTARG in
- *.l)
- SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if test -f "$SRCFILE"; then
- cp "$SRCFILE" lex.yy.c
- fi
- ;;
- esac
- fi
- if test ! -f lex.yy.c; then
- echo 'main() { return 0; }' >lex.yy.c
- fi
- ;;
-
- help2man)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a dependency of a manual page. You may need the
- \`Help2man' package in order for those modifications to take
- effect. You can get \`Help2man' from any GNU archive site."
-
- file=`echo "$*" | sed -n "$sed_output"`
- test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo ".ab help2man is required to generate this page"
- exit 1
- fi
- ;;
-
- makeinfo)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.texi' or \`.texinfo' file, or any other file
- indirectly affecting the aspect of the manual. The spurious
- call might also be the consequence of using a buggy \`make' (AIX,
- DU, IRIX). You might want to install the \`Texinfo' package or
- the \`GNU make' package. Grab either from any GNU archive site."
- # The file to touch is that specified with -o ...
- file=`echo "$*" | sed -n "$sed_output"`
- test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
- if test -z "$file"; then
- # ... or it is the one specified with @setfilename ...
- infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '
- /^@setfilename/{
- s/.* \([^ ]*\) *$/\1/
- p
- q
- }' $infile`
- # ... or it is derived from the source name (dir/f.texi becomes f.info)
- test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
- fi
- # If the file does not exist, the user really needs makeinfo;
- # let's fail without touching anything.
- test -f $file || exit 1
- touch $file
- ;;
-
- tar)
- shift
-
- # We have already tried tar in the generic part.
- # Look for gnutar/gtar before invocation to avoid ugly error
- # messages.
- if (gnutar --version > /dev/null 2>&1); then
- gnutar "$@" && exit 0
- fi
- if (gtar --version > /dev/null 2>&1); then
- gtar "$@" && exit 0
- fi
- firstarg="$1"
- if shift; then
- case $firstarg in
- *o*)
- firstarg=`echo "$firstarg" | sed s/o//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- case $firstarg in
- *h*)
- firstarg=`echo "$firstarg" | sed s/h//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- fi
-
- echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
- You may want to install GNU tar or Free paxutils, or check the
- command line arguments."
- exit 1
- ;;
-
- *)
- echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
- You might have modified some files without having the
- proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequisites for installing
- this package. You may also peek at any GNU archive site, in case
- some other package would contain this missing \`$1' program."
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
-
-
Name: libmm-utility
Summary: Multimedia Framework Utility Library
-Version: 0.7
+Version: 0.8
Release: 0
Group: System/Libraries
License: Apache-2.0
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(mm-common)
BuildRequires: pkgconfig(mm-log)
-BuildRequires: pkgconfig(mm-ta)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gmodule-2.0)
BuildRequires: libjpeg-turbo-devel
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(capi-media-tool)
+BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(libexif)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Multimedia Framework Utility Library - Main package.