Problems with libvpx video quality on ARM platform.

368 views
Skip to first unread message

Rahul Ganure

unread,
Jan 18, 2012, 1:34:38 AM1/18/12
to WebM Discussion
Hello,
I have successful complied the libvpx codec on the android platform by
using the my Amdroid.mk make file for ARM v5, v6 and neon platform by
using the ads2gas.pl script to and invoking the ndk-build command.

I have compiled the required source and got the libvpx.so.

Later i have used this shared object to create an android application,
i have created an android application and ran the application on
android emulator.

I have tested the application by using a raw video sequence of 320x240
video frame resolution and fixing the parameters such as bitrate = 450
Kbps, frame rate = 25 and key frame distance = 8.

Encoding and decoding was successful , but the video quality was poor
for when compared to the video quality obtained by libvpx for x86
platform for same above parameters.

Please provide your valuable inputs.

Eagerly waiting for your en-lighting replies.

Regards,
Rahul Ganure.

Johann Koenig

unread,
Jan 18, 2012, 12:57:24 PM1/18/12
to webm-d...@webmproject.org
On Tue, Jan 17, 2012 at 22:34, Rahul Ganure <rahul...@gmail.com> wrote:
> I have tested the application by using a raw video sequence of 320x240
> video frame resolution and fixing the parameters such as bitrate = 450
> Kbps, frame rate = 25 and key frame distance = 8.
>
> Encoding and decoding was successful , but the video quality was poor
> for when compared to the video quality obtained by libvpx for x86
> platform for same above parameters.

What other settings are you using? With only those the ARM and x86
code produce identical results.
--
- johann koenig
  google

Fritz Koenig

unread,
Jan 18, 2012, 12:58:40 PM1/18/12
to webm-d...@webmproject.org
Ideally given the same parameters, the output will be identical
regardless of platform. There are a few caveats to that.

libvpx has the notion of "speed" settings. A lower speed setting will
take longer to encode, but give better performance. For realtime
encoding on devices we usually aim for a speed setting of 4 or above.
Did you set this?

Did you use --enable-realtime only for the ARM?

Poor is a subjective term and hard to determine what could be going on
with your setup. You could try setting --cpu-used=n where n is a
number between -1 and -16 while encoding on the pc and see if there is
a matching quality to what you are seeing for the ARM encode.
(Setting a negative number holds the encode to that number throughout
the process. If you set it to a positive number it can adapt to the
cpu load and go higher/lower, which will make your encode not
deterministic).

Are you comparing the Android encode with a vpxenc encode? Is there
the possibility that you missed setting up some of the parameters that
vpxenc sets up? Or is your program cross platform and you are running
the same c code on both?

> --
> You received this message because you are subscribed to the Google Groups "WebM Discussion" group.
> To post to this group, send email to webm-d...@webmproject.org.
> To unsubscribe from this group, send email to webm-discuss...@webmproject.org.
> For more options, visit this group at http://groups.google.com/a/webmproject.org/group/webm-discuss/?hl=en.
>

Rahul Ganure

unread,
Jan 19, 2012, 4:23:56 AM1/19/12
to WebM Discussion


On Jan 18, 10:57 pm, Johann Koenig <johannkoe...@google.com> wrote:
> On Tue, Jan 17, 2012 at 22:34, Rahul Ganure <rahul50...@gmail.com> wrote:
> > I have tested the application by using a raw video sequence of 320x240
> > video frame resolution and fixing the parameters such as bitrate = 450
> > Kbps, frame rate = 25 and key frame distance = 8.
>
> > Encoding and decoding was successful , but the video quality was poor
> > for when compared to the video quality obtained by libvpx for x86
> > platform for same above parameters.
>
> What other settings are you using? With only those the ARM and x86
> code produce identical results.

> - johann koenig
> google

other than the above settings, the other parameters i have set were

frame width = 320
frame height = 240
vpx_frame_format = 258 which corresponds to i420 YUV video frame
format.


Rest all parameters are default, set by codec.

I have obtained PSNR Values for decoded video frames on x86 and AMRv7
(neon) platforms

for X86 platform by enabling the mmx and and sse instruction support
the PSNR i got is 37.55 db.

for ARMv7 platform it was 32.17 db. for same parameters as for x86
platform.

Rahul Ganure

unread,
Jan 19, 2012, 4:54:03 AM1/19/12
to WebM Discussion


On Jan 18, 10:58 pm, Fritz Koenig <frkoe...@google.com> wrote:
> Ideally given the same parameters, the output will be identical
> regardless of platform.  There are a few caveats to that.
>
> libvpx has the notion of "speed" settings.  A lower speed setting will
> take longer to encode, but give better performance.  For realtime
> encoding on devices we usually aim for a speed setting of 4 or above.
> Did you set this?
>
> Did you use --enable-realtime only for the ARM?

As i have used the ndk-build command to complie the given source
listed in android.mk, i didn't use --enable-realtime-only.
However, I have deined the macro CONFIG_REALTIME_ONLY as 1 in
vpx_config.h header file.


> Poor is a subjective term and hard to determine what could be going on
> with your setup.  You could try setting --cpu-used=n where n is a
> number between -1 and -16 while encoding on the pc and see if there is
> a matching quality to what you are seeing for the ARM encode.
> (Setting a negative number holds the encode to that number throughout
> the process.  If you set it to a positive number it can adapt to the
> cpu load and go higher/lower, which will make your encode not
> deterministic).

I have obtained PSNR Values for decoded video frames on x86 and AMRv7
(neon) platforms

for X86 platform by enabling the mmx and and sse instruction support
the PSNR i got is 37.55 db.

for ARMv7 platform it was 32.17 db. for same parameters as for x86
platform.

> Are you comparing the Android encode with a vpxenc encode?  Is there
> the possibility that you missed setting up some of the parameters that
> vpxenc sets up?  Or is your program cross platform and you are running
> the same c code on both?

Yes i am using the same C code both on x86 platform and ARM specific
code on ARM Platform which was taken from the same souce code tree.

I have not using the vpxenc, instead i have used a test code which is
written to get the vp8 encoding and decoding operation done. I have
used the same c test code to test the libvpx encoding and decoding
operation on x86 platform.


the vpx_config.h i used is follwoing


/* This file automatically generated by configure. Do not edit! */
#ifndef VPX_CONFIG_H
#define VPX_CONFIG_H
#define RESTRICT
#define ARCH_ARM 1
#define ARCH_MIPS 0
#define ARCH_X86 0
#define ARCH_X86_64 0
#define ARCH_PPC32 0
#define ARCH_PPC64 0
#define HAVE_ARMV5TE 0
#define HAVE_ARMV6 0
#define HAVE_ARMV7 1
#define HAVE_IWMMXT 0
#define HAVE_IWMMXT2 0
#define HAVE_MIPS32 0
#define HAVE_MMX 0
#define HAVE_SSE 0
#define HAVE_SSE2 0
#define HAVE_SSE3 0
#define HAVE_SSSE3 0
#define HAVE_SSE4_1 0
#define HAVE_ALTIVEC 0
#define HAVE_VPX_PORTS 1
#define HAVE_STDINT_H 1
#define HAVE_ALT_TREE_LAYOUT 0
#define HAVE_PTHREAD_H 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_UNISTD_H 1
#define CONFIG_EXTERNAL_BUILD 0
#define CONFIG_INSTALL_DOCS 0
#define CONFIG_INSTALL_BINS 0
#define CONFIG_INSTALL_LIBS 0
#define CONFIG_INSTALL_SRCS 0
#define CONFIG_DEBUG 0
#define CONFIG_GPROF 0
#define CONFIG_GCOV 0
#define CONFIG_RVCT 0
#define CONFIG_GCC 1
#define CONFIG_MSVS 1
#define CONFIG_PIC 1
#define CONFIG_BIG_ENDIAN 0
#define CONFIG_CODEC_SRCS 0
#define CONFIG_DEBUG_LIBS 0
#define CONFIG_FAST_UNALIGNED 1
#define CONFIG_MEM_MANAGER 0
#define CONFIG_MEM_TRACKER 0
#define CONFIG_MEM_CHECKS 0
#define CONFIG_MD5 1
#define CONFIG_DEQUANT_TOKENS 0
#define CONFIG_DC_RECON 0
#define CONFIG_RUNTIME_CPU_DETECT 1
#define CONFIG_POSTPROC 1
#define CONFIG_MULTITHREAD 1
#define CONFIG_INTERNAL_STATS 0
#define CONFIG_VP8_ENCODER 1
#define CONFIG_VP8_DECODER 1
#define CONFIG_VP8 1
#define CONFIG_ENCODERS 1
#define CONFIG_DECODERS 1
#define CONFIG_STATIC_MSVCRT 0
#define CONFIG_SPATIAL_RESAMPLING 1
#define CONFIG_REALTIME_ONLY 1
#define CONFIG_ERROR_CONCEALMENT 1
#define CONFIG_SHARED 0
#define CONFIG_STATIC 0
#define CONFIG_SMALL 0
#define CONFIG_POSTPROC_VISUALIZER 0
#define CONFIG_OS_SUPPORT 1
#endif /* VPX_CONFIG_H */


am i missing setting something here in the vpx_config.h ???

Attila Nagy

unread,
Jan 19, 2012, 5:00:23 AM1/19/12
to webm-d...@webmproject.org
do you have CONFIG_REALTIME_ONLY as 1 in x86 too?

on armv7 you want also
#define HAVE_ARMV5TE 1
#define HAVE_ARMV6 1


Rahul Ganure

unread,
Jan 19, 2012, 6:22:32 AM1/19/12
to WebM Discussion


On Jan 19, 3:00 pm, Attila Nagy <attilan...@google.com> wrote:
> do you have CONFIG_REALTIME_ONLY as 1 in x86 too?

yes. i have enabled it even on x86 platform too.

> on armv7 you want also
> #define HAVE_ARMV5TE 1
> #define HAVE_ARMV6 1
>
previously i have tried that too. i have also checked by enabling the
above macros and didn't get the desired decoded video quality.
> > To post to this group, send email to webm-disc...@webmproject.org.
> > To unsubscribe from this group, send email to
> > webm-discuss+unsubscr...@webmproject.org.

Attila Nagy

unread,
Jan 19, 2012, 7:14:05 AM1/19/12
to webm-d...@webmproject.org
On Thu, Jan 19, 2012 at 1:22 PM, Rahul Ganure <rahul...@gmail.com> wrote:


On Jan 19, 3:00 pm, Attila Nagy <attilan...@google.com> wrote:
> do you have CONFIG_REALTIME_ONLY as 1 in x86 too?

yes. i have enabled it even on x86 platform too.


by default in real-time mode the encoder will try to adapt to the system performance so that it can achieve realtime encoding.
This means that it will lower the encoding quality to achieve faster encoding, when needed
You can force the encoder to stay at a certain speed level by setting the cpu_used parameter  (VP8E_SET_CPUUSED) to a negative value (-4..-16)
Only by forcing this you can have a deterministic output in realtime mode.

vpx_codec_control(&encoder, VP8E_SET_CPUUSED, -6);

 

> on armv7 you want also
> #define HAVE_ARMV5TE 1
> #define HAVE_ARMV6 1
>
previously i have tried that too. i have also checked by enabling the
above macros and didn't get the desired decoded video quality.


you want these always enabled when you target armv7!

 
To post to this group, send email to webm-d...@webmproject.org.
To unsubscribe from this group, send email to webm-discuss...@webmproject.org.

Rahul Ganure

unread,
Jan 19, 2012, 10:00:30 AM1/19/12
to WebM Discussion


On Jan 19, 5:14 pm, Attila Nagy <attilan...@google.com> wrote:
> On Thu, Jan 19, 2012 at 1:22 PM, Rahul Ganure <rahul50...@gmail.com> wrote:
>
> > On Jan 19, 3:00 pm, Attila Nagy <attilan...@google.com> wrote:
> > > do you have CONFIG_REALTIME_ONLY as 1 in x86 too?
>
> > yes. i have enabled it even on x86 platform too.
>
> by default in real-time mode the encoder will try to adapt to the
> system performance so that it can achieve realtime encoding.
> This means that it will lower the encoding quality to achieve faster
> encoding, when needed
> You can force the encoder to stay at a certain speed level by setting the
> cpu_used parameter  (VP8E_SET_CPUUSED) to a negative value (-4..-16)
> Only by forcing this you can have a deterministic output in realtime mode.
>
> vpx_codec_control(&encoder, VP8E_SET_CPUUSED, -6);

Thanks, Attila Nagy for your reply.

I have used, vpx_codec_control_ function to force the encoding speed
by varying the cpu_used parameter between -16 to -6 but, unfortunately
i was not able to get the expected the decoded video quality.

Later i have disabled the realtime-only setting and used
VPX_DL_BEST_QUALITY macro in vpx_codec_encode interface as dealine,
here too i was not able to get the desired decoded video quality.

Please help me and guide to get it solved.

Thanks in advance,
Regards,
Rahul Ganure.

Fritz Koenig

unread,
Jan 19, 2012, 1:37:43 PM1/19/12
to webm-d...@webmproject.org
Please do not hand edit the configure files. Use the configure
script. If you wish to disable the ARM optimizations, pass
--disable-armv7 --disable-armv6 --disable-armv5te to the configure
script

Are you running on a device or in the emulator?

I don't know what your initialization code does. You can configure
and build the examples, copy vpxenc to the phone and run it from there
with the same parameters as on the pc to check for bit exactness.
Link against that lib in your Android project.

But first, please clone a new libvpx tree in a clean directory and
start over from there. Editing source files because of a mismatched
ABI sounds like a problem with the source tree that needs to be solved
first.

Rahul Ganure

unread,
Jan 23, 2012, 9:33:59 AM1/23/12
to WebM Discussion


On Jan 19, 11:37 pm, Fritz Koenig <frkoe...@google.com> wrote:
> Please do not hand edit the configure files.  Use the configure
> script.  If you wish to disable the ARM optimizations, pass
> --disable-armv7 --disable-armv6 --disable-armv5te to the configure
> script
>
> Are you running on a device or in the emulator?
>
> I don't know what your initialization code does.  You can configure
> and build the examples, copy vpxenc to the phone and run it from there
> with the same parameters as on the pc to check for bit exactness.
> Link against that lib in your Android project.
>
> But first, please clone a new libvpx tree in a clean directory and
> start over from there.  Editing source files because of a mismatched
> ABI sounds like a problem with the source tree that needs to be solved
> first.

As per your suggestions, i have downloaded a new set of libvpx and
used the latest patch provided by you. Thank you for that.

I have complied the libvpx and this time i did not get the ABI
mismatch.

I have later disabled real-time only and recompiled the libvpx.

I have checked the decoded video quality on an android emulator.

here i found the decoded video quality was comparative to with the
decoded video quality for x86 platform. during configuring libvpx for
x86 i had enabled realtime only switch

But still the video quality of x86 platform was good when compared to
ARM platform where i disabled realtime time only(as suggested by
you)..
Reply all
Reply to author
Forward
0 new messages