Skip to content

Commit

Permalink
Bug 1864008 - Move libvpx to libgkcodecs, part 1 r=media-playback-rev…
Browse files Browse the repository at this point in the history
…iewers,glandium,alwu,padenot

This patch is the first part that moves libvpx from libgkmedias to
libgkcodecs.

When `ac_add_options --with-system-libvpx` (and `--without-sysroot` if
needed) is set in mozconfig (MOZ_SYSTEM_LIBVPX case), the libvpx
installed in the system will be used and the media/libvpx won't be
built, so the libvpx APIs shouldn't be exposed via gkcodecs' symbols in
this case.

With the changes, the "vpx/..." headers `#include`d in the VPX
encoders should be replaced with system headers like `<vpx/...>`
instead. While the VPX headers under dom/media are updated in this
patch, those headers under third_party/libwebrtc are set in a different
way in the following patches.

Since libpixman needs android_getCpuFeatures and _getCpuFamily APIs,
which were built by libvpx previously, cpu-features.c now is required to
be included in its moz.build to get the API it needs.

Differential Revision: https://phabricator.services.mozilla.com/D193599
  • Loading branch information
ChunMinChang committed Dec 5, 2023
1 parent 1e299fc commit 958a88c
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 22 deletions.
25 changes: 25 additions & 0 deletions config/external/gkcodecs/gkcodecs.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,28 @@ vorbis_synthesis_init
vorbis_synthesis_pcmout
vorbis_synthesis_read
vorbis_synthesis_restart
#ifndef MOZ_SYSTEM_LIBVPX
vpx_codec_control_
vpx_codec_dec_init_ver
vpx_codec_decode
vpx_codec_destroy
vpx_codec_enc_config_default
vpx_codec_enc_config_set
vpx_codec_enc_init_multi_ver
vpx_codec_enc_init_ver
vpx_codec_encode
vpx_codec_err_to_string
vpx_codec_error
vpx_codec_error_detail
vpx_codec_get_caps
vpx_codec_get_cx_data
vpx_codec_get_frame
vpx_codec_set_frame_buffer_functions
vpx_codec_vp8_cx
vpx_codec_vp8_dx
vpx_codec_vp9_cx
vpx_codec_vp9_dx
vpx_img_alloc
vpx_img_free
vpx_img_wrap
#endif
6 changes: 4 additions & 2 deletions config/external/gkcodecs/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# The gkcodecs library contains code from third-party libraries implementing
# encoding an decoding for particular audio codecs.
# encoding an decoding for particular audio and video codecs.
#
# They are compiled in a separate shared library to be able to be available
# both from libxul (when decoding using the codec integration layer Gecko
# provides) and from ffmpeg (when decoding trough ffmpeg).
# provides) and from ffmpeg (when decoding and encoding through ffmpeg).

GeckoSharedLibrary("gkcodecs", linkage=None)
SHARED_LIBRARY_NAME = "gkcodecs"
SYMBOLS_FILE = "gkcodecs.symbols"
if CONFIG["MOZ_SYSTEM_LIBVPX"]:
DEFINES["MOZ_SYSTEM_LIBVPX"] = True
23 changes: 11 additions & 12 deletions config/system-headers.mozbuild
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,17 @@ system_headers = [
'opus/opus.h',
'opus/opus_multistream.h',
'ogg/ogg.h',
'theora/theoradec.h'
'theora/theoradec.h',
'vpx/svc_context.h',
'vpx/vp8.h',
'vpx/vp8cx.h',
'vpx/vp8dx.h',
'vpx/vpx_codec.h',
'vpx/vpx_decoder.h',
'vpx/vpx_encoder.h',
'vpx/vpx_frame_buffer.h',
'vpx/vpx_image.h',
'vpx_mem/vpx_mem.h'
]

if CONFIG['MOZ_X11']:
Expand Down Expand Up @@ -1294,17 +1304,6 @@ if CONFIG['MOZ_ENABLE_LIBPROXY']:
'proxy.h',
]

if CONFIG['MOZ_SYSTEM_LIBVPX']:
system_headers += [
'vpx_mem/vpx_mem.h',
'vpx/svc_context.h',
'vpx/vp8cx.h',
'vpx/vp8dx.h',
'vpx/vpx_codec.h',
'vpx/vpx_decoder.h',
'vpx/vpx_encoder.h',
]

if CONFIG['MOZ_SYSTEM_ICU']:
system_headers += [
'unicode/calendar.h',
Expand Down
5 changes: 3 additions & 2 deletions dom/media/encoder/VP8TrackEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

#include "VP8TrackEncoder.h"

#include <vpx/vp8cx.h>
#include <vpx/vpx_encoder.h>

#include "DriftCompensation.h"
#include "ImageToI420.h"
#include "mozilla/gfx/2D.h"
#include "prsystem.h"
#include "VideoSegment.h"
#include "VideoUtils.h"
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
#include "WebMWriter.h"
#include "mozilla/media/MediaUtils.h"
#include "mozilla/dom/ImageUtils.h"
Expand Down
3 changes: 2 additions & 1 deletion dom/media/encoder/VP8TrackEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

#include "TrackEncoder.h"

#include <vpx/vpx_codec.h>

#include "mozilla/RollingMean.h"
#include "TimeUnits.h"
#include "vpx/vpx_codec.h"

namespace mozilla {

Expand Down
2 changes: 1 addition & 1 deletion dom/media/platforms/agnostic/VPXDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "VPXDecoder.h"

#include <algorithm>
#include <vpx/vpx_image.h>

#include "BitReader.h"
#include "BitWriter.h"
Expand All @@ -22,7 +23,6 @@
#include "PerformanceRecorder.h"
#include "prsystem.h"
#include "VideoUtils.h"
#include "vpx/vpx_image.h"

#undef LOG
#define LOG(arg, ...) \
Expand Down
6 changes: 3 additions & 3 deletions dom/media/platforms/agnostic/VPXDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
# define VPXDecoder_h_

# include <stdint.h>
# include <vpx/vp8dx.h>
# include <vpx/vpx_codec.h>
# include <vpx/vpx_decoder.h>

# include "PlatformDecoderModule.h"
# include "mozilla/Span.h"
# include "mozilla/gfx/Types.h"
# include "vpx/vp8dx.h"
# include "vpx/vpx_codec.h"
# include "vpx/vpx_decoder.h"

namespace mozilla {

Expand Down
5 changes: 5 additions & 0 deletions gfx/cairo/libpixman/src/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ if CONFIG['ANDROID_NDK']:
'%%%s/sources/android/cpufeatures' % CONFIG['ANDROID_NDK']
]

if CONFIG['OS_TARGET'] == 'Android':
SOURCES += [
'%%%s/sources/android/cpufeatures/cpu-features.c' % CONFIG['ANDROID_NDK'],
]

if CONFIG['MOZ_USE_PTHREADS']:
DEFINES['HAVE_PTHREADS'] = True

Expand Down
3 changes: 2 additions & 1 deletion media/libvpx/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ else:
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

FINAL_LIBRARY = 'gkmedias'
FINAL_LIBRARY = 'gkcodecs'
NoVisibilityFlags()

DEFINES['HAVE_CONFIG_H'] = 'vpx_config.h'

Expand Down

0 comments on commit 958a88c

Please sign in to comment.