├── .gitignore ├── ChangeLog ├── LICENSE ├── README.md ├── ext ├── audio │ ├── gstimxmp3encoder.c │ ├── gstimxmp3encoder.h │ ├── gstimxuniaudiocodec.c │ ├── gstimxuniaudiocodec.h │ ├── gstimxuniaudiodecoder.c │ ├── gstimxuniaudiodecoder.h │ ├── meson.build │ └── plugin.c ├── imx2d │ ├── gstimx2dcompositor.c │ ├── gstimx2dcompositor.h │ ├── gstimx2dmisc.c │ ├── gstimx2dmisc.h │ ├── gstimx2dvideooverlayhandler.c │ ├── gstimx2dvideooverlayhandler.h │ ├── gstimx2dvideosink.c │ ├── gstimx2dvideosink.h │ ├── gstimx2dvideotransform.c │ ├── gstimx2dvideotransform.h │ ├── gstimxg2dcompositor.c │ ├── gstimxg2dcompositor.h │ ├── gstimxg2dvideosink.c │ ├── gstimxg2dvideosink.h │ ├── gstimxg2dvideotransform.c │ ├── gstimxg2dvideotransform.h │ ├── gstimxipuvideosink.c │ ├── gstimxipuvideosink.h │ ├── gstimxipuvideotransform.c │ ├── gstimxipuvideotransform.h │ ├── gstimxpxpvideosink.c │ ├── gstimxpxpvideosink.h │ ├── gstimxpxpvideotransform.c │ ├── gstimxpxpvideotransform.h │ ├── meson.build │ └── plugin.c └── vpu │ ├── gstimxvpucommon.c │ ├── gstimxvpucommon.h │ ├── gstimxvpudec.c │ ├── gstimxvpudec.h │ ├── gstimxvpudecbufferpool.c │ ├── gstimxvpudecbufferpool.h │ ├── gstimxvpudeccontext.c │ ├── gstimxvpudeccontext.h │ ├── gstimxvpuenc.c │ ├── gstimxvpuenc.h │ ├── gstimxvpuench263.c │ ├── gstimxvpuench263.h │ ├── gstimxvpuench264.c │ ├── gstimxvpuench264.h │ ├── gstimxvpuencjpeg.c │ ├── gstimxvpuencjpeg.h │ ├── gstimxvpuencmpeg4.c │ ├── gstimxvpuencmpeg4.h │ ├── gstimxvpuencvp8.c │ ├── gstimxvpuencvp8.h │ ├── meson.build │ └── plugin.c ├── gst-libs ├── gst │ └── imx │ │ ├── common │ │ ├── gstimxcommon.pc.in │ │ ├── gstimxdefaultallocator.c │ │ ├── gstimxdefaultallocator.h │ │ ├── gstimxdmabufallocator.c │ │ ├── gstimxdmabufallocator.h │ │ ├── gstimxdmabufferallocator.c │ │ ├── gstimxdmabufferallocator.h │ │ ├── gstimxdmabufferuploader.c │ │ ├── gstimxdmabufferuploader.h │ │ ├── gstimxdmaheapallocator.c │ │ ├── gstimxdmaheapallocator.h │ │ ├── gstimxionallocator.c │ │ ├── gstimxionallocator.h │ │ └── meson.build │ │ └── video │ │ ├── gstimxvideobufferpool.c │ │ ├── gstimxvideobufferpool.h │ │ ├── gstimxvideodmabufferpool.c │ │ ├── gstimxvideodmabufferpool.h │ │ ├── gstimxvideouploader.c │ │ ├── gstimxvideouploader.h │ │ ├── gstimxvideoutils.c │ │ ├── gstimxvideoutils.h │ │ └── meson.build └── imx2d │ ├── backend │ ├── g2d │ │ ├── g2d_blitter.c │ │ ├── g2d_blitter.h │ │ └── meson.build │ ├── ipu │ │ ├── ipu_blitter.c │ │ ├── ipu_blitter.h │ │ └── meson.build │ └── pxp │ │ ├── meson.build │ │ ├── pxp_blitter.c │ │ └── pxp_blitter.h │ ├── imx2d.c │ ├── imx2d.h │ ├── imx2d_priv.h │ ├── linux_framebuffer.c │ ├── linux_framebuffer.h │ └── meson.build ├── meson.build ├── meson_options.txt └── sys └── v4l2video ├── gstimxv4l2amphiondec.c ├── gstimxv4l2amphiondec.h ├── gstimxv4l2amphionmisc.c ├── gstimxv4l2amphionmisc.h ├── gstimxv4l2context.c ├── gstimxv4l2context.h ├── gstimxv4l2isivideotransform.c ├── gstimxv4l2isivideotransform.h ├── gstimxv4l2object.c ├── gstimxv4l2object.h ├── gstimxv4l2prelude.h ├── gstimxv4l2videoformat.c ├── gstimxv4l2videoformat.h ├── gstimxv4l2videosink.c ├── gstimxv4l2videosink.h ├── gstimxv4l2videosrc.c ├── gstimxv4l2videosrc.h ├── meson.build └── plugin.c /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /ext/audio/gstimxmp3encoder.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_AUDIO_MP3_ENCODER_H 20 | #define GST_IMX_AUDIO_MP3_ENCODER_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | G_BEGIN_DECLS 29 | 30 | 31 | typedef struct _GstImxAudioMp3Enc GstImxAudioMp3Enc; 32 | typedef struct _GstImxAudioMp3EncClass GstImxAudioMp3EncClass; 33 | 34 | 35 | #define GST_TYPE_IMX_AUDIO_MP3_ENC (gst_imx_audio_mp3_enc_get_type()) 36 | #define GST_IMX_AUDIO_MP3_ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_AUDIO_MP3_ENC,GstImxAudioMp3Enc)) 37 | #define GST_IMX_AUDIO_MP3_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_AUDIO_MP3_ENC,GstImxAudioMp3EncClass)) 38 | #define GST_IS_IMX_AUDIO_MP3_ENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_AUDIO_MP3_ENC)) 39 | #define GST_IS_IMX_AUDIO_MP3_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_AUDIO_MP3_ENC)) 40 | 41 | 42 | struct _GstImxAudioMp3Enc 43 | { 44 | GstAudioEncoder parent; 45 | MP3E_Encoder_Config config; 46 | MP3E_Encoder_Parameter param; 47 | guint bitrate; 48 | gboolean high_quality_mode; 49 | gpointer allocated_blocks[ENC_NUM_MEM_BLOCKS]; 50 | }; 51 | 52 | 53 | struct _GstImxAudioMp3EncClass 54 | { 55 | GstAudioDecoderClass parent_class; 56 | }; 57 | 58 | 59 | GType gst_imx_audio_mp3_enc_get_type(void); 60 | GType gst_imx_audio_mp3_enc_bitrate_get_type(void); 61 | 62 | 63 | G_END_DECLS 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /ext/audio/gstimxuniaudiocodec.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "gstimxuniaudiocodec.h" 22 | 23 | 24 | GST_DEBUG_CATEGORY_STATIC(imx_audio_uniaudio_codec_debug); 25 | #define GST_CAT_DEFAULT imx_audio_uniaudio_codec_debug 26 | 27 | #define UNIA_CODEC_ENTRYPOINT_FUNCTION "UniACodecQueryInterface" 28 | 29 | 30 | static GList *codec_table = NULL; 31 | static GstCaps *codec_table_caps = NULL; 32 | 33 | 34 | static gpointer gst_imx_audio_uniaudio_codec_table_init_internal(G_GNUC_UNUSED gpointer data); 35 | static gboolean gst_imx_audio_uniaudio_codec_add_codec(gchar const *library_filename, GstCaps *caps); 36 | static GstImxAudioUniaudioCodec* gst_imx_audio_uniaudio_codec_load_codec(gchar const *library_filename, GstCaps *caps); 37 | static void gst_imx_audio_uniaudio_codec_unload_codec(GstImxAudioUniaudioCodec *codec); 38 | 39 | 40 | typedef struct 41 | { 42 | gchar const *desc; 43 | gchar const *filename; 44 | gchar const *gstcaps; 45 | } 46 | codec_entry; 47 | 48 | 49 | #define AAC_CAPS "audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string){raw,adts,adif}, profile=(string)lc" 50 | 51 | 52 | static codec_entry const codec_entries[] = 53 | { 54 | { "AAC LC", "lib_aacd_wrap_arm12_elinux.so.3", AAC_CAPS }, 55 | { "MP3", "lib_mp3d_wrap_arm12_elinux.so.3", "audio/mpeg, mpegversion=(int)1, layer=(int)3, parsed=(boolean)true" }, 56 | { "Vorbis", "lib_vorbisd_wrap_arm12_elinux.so.3", "audio/x-vorbis" }, 57 | { "narrowband AMR", "lib_nbamrd_wrap_arm11_elinux.so.1", "audio/AMR" }, 58 | { "wideband AMR", "lib_wbamrd_wrap_arm12_elinux.so.1", "audio/AMR-WB" }, 59 | { "WMA", "lib_wma10d_wrap_arm12_elinux.so", "audio/x-wma, wmaversion = (int)[ 1, 4 ]" }, 60 | { NULL, NULL, NULL } 61 | }; 62 | 63 | 64 | static gpointer gst_imx_audio_uniaudio_codec_table_init_internal(G_GNUC_UNUSED gpointer data) 65 | { 66 | codec_entry const *entry; 67 | 68 | GST_DEBUG_CATEGORY_INIT(imx_audio_uniaudio_codec_debug, "imxuniaudiocodec", 0, "NXP i.MX uniaudio codecs"); 69 | 70 | codec_table = NULL; 71 | codec_table_caps = gst_caps_new_empty(); 72 | 73 | for (entry = codec_entries; entry->filename != NULL; ++entry) 74 | { 75 | GstCaps *caps = gst_caps_from_string(entry->gstcaps); 76 | GST_DEBUG("Adding codec \"%s\" with caps %" GST_PTR_FORMAT, entry->desc, (gpointer)caps); 77 | if (gst_imx_audio_uniaudio_codec_add_codec(entry->filename, caps)) 78 | gst_caps_append(codec_table_caps, caps); 79 | else 80 | gst_caps_unref(caps); 81 | } 82 | 83 | return NULL; 84 | } 85 | 86 | 87 | static gboolean gst_imx_audio_uniaudio_codec_add_codec(gchar const *library_filename, GstCaps *caps) 88 | { 89 | GstImxAudioUniaudioCodec *codec = gst_imx_audio_uniaudio_codec_load_codec(library_filename, caps); 90 | 91 | if (codec != NULL) 92 | { 93 | codec_table = g_list_append(codec_table, codec); 94 | return TRUE; 95 | } 96 | else 97 | return FALSE; 98 | } 99 | 100 | 101 | static GstImxAudioUniaudioCodec* gst_imx_audio_uniaudio_codec_load_codec(gchar const *library_filename, GstCaps *caps) 102 | { 103 | gchar *full_filename = NULL; 104 | GstImxAudioUniaudioCodec *codec = g_malloc0(sizeof(GstImxAudioUniaudioCodec)); 105 | 106 | full_filename = g_strdup_printf("%s/wrap/%s", IMX_AUDIO_CODEC_PATH, library_filename); 107 | 108 | GST_DEBUG("trying to load library %s", full_filename); 109 | 110 | if ((codec->dlhandle = dlopen(full_filename, RTLD_LAZY | RTLD_LOCAL)) == NULL) 111 | { 112 | GST_INFO("failed to load library %s with full filename %s: %s - trying filename only", library_filename, full_filename, dlerror()); 113 | if ((codec->dlhandle = dlopen(library_filename, RTLD_LAZY | RTLD_LOCAL)) == NULL) 114 | { 115 | GST_INFO("loading library %s failed: %s - not adding to codecs", library_filename, dlerror()); 116 | goto error; 117 | } 118 | } 119 | 120 | codec->caps = gst_caps_copy(caps); 121 | GST_MINI_OBJECT_FLAG_SET(codec->caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); 122 | 123 | #pragma GCC diagnostic push 124 | #pragma GCC diagnostic ignored "-Wpedantic" 125 | codec->query_interface = dlsym(codec->dlhandle, UNIA_CODEC_ENTRYPOINT_FUNCTION); 126 | #pragma GCC diagnostic pop 127 | 128 | if (codec->query_interface == NULL) 129 | { 130 | GST_ERROR("getting %s function from library %s failed: %s", UNIA_CODEC_ENTRYPOINT_FUNCTION, library_filename, dlerror()); 131 | goto error; 132 | } 133 | 134 | #define INIT_CODEC_FUNCTION(ID, DESC, FUNC) \ 135 | do \ 136 | { \ 137 | int32 ret = codec->query_interface((ID), (void **)(&(codec->FUNC))); \ 138 | if (ret != ACODEC_SUCCESS) \ 139 | { \ 140 | GST_ERROR("loading %s from library %s failed", DESC, library_filename); \ 141 | goto error; \ 142 | } \ 143 | } \ 144 | while (0) 145 | 146 | INIT_CODEC_FUNCTION(ACODEC_API_GET_VERSION_INFO, "UniAUniaCodecVersionInfo", get_version_info); 147 | INIT_CODEC_FUNCTION(ACODEC_API_CREATE_CODEC, "UniAUniaCodecCreate", create_codec); 148 | INIT_CODEC_FUNCTION(ACODEC_API_DELETE_CODEC, "UniAUniaCodecDelete", delete_codec); 149 | INIT_CODEC_FUNCTION(ACODEC_API_SET_PARAMETER, "UniAUniaCodecSetParameter", set_parameter); 150 | INIT_CODEC_FUNCTION(ACODEC_API_GET_PARAMETER, "UniAUniaCodecGetParameter", get_parameter); 151 | INIT_CODEC_FUNCTION(ACODEC_API_DEC_FRAME, "UniAUniaCodec_decode_frame", decode_frame); 152 | INIT_CODEC_FUNCTION(ACODEC_API_RESET_CODEC, "UniAUniaCodecReset", reset); 153 | INIT_CODEC_FUNCTION(ACODEC_API_GET_LAST_ERROR, "UniAUniaCodec_get_last_error", get_last_error); 154 | 155 | #undef INIT_CODEC_FUNCTION 156 | 157 | done: 158 | g_free(full_filename); 159 | return codec; 160 | 161 | error: 162 | gst_imx_audio_uniaudio_codec_unload_codec(codec); 163 | codec = NULL; 164 | 165 | goto done; 166 | } 167 | 168 | 169 | static void gst_imx_audio_uniaudio_codec_unload_codec(GstImxAudioUniaudioCodec *codec) 170 | { 171 | if (codec->caps != NULL) 172 | gst_caps_unref(codec->caps); 173 | if (codec->dlhandle != NULL) 174 | dlclose(codec->dlhandle); 175 | g_free(codec); 176 | } 177 | 178 | 179 | 180 | 181 | void gst_imx_audio_uniaudio_codec_table_init(void) 182 | { 183 | static GOnce init_once = G_ONCE_INIT; 184 | g_once(&init_once, gst_imx_audio_uniaudio_codec_table_init_internal, NULL); 185 | } 186 | 187 | 188 | GstCaps* gst_imx_audio_uniaudio_codec_table_get_caps(void) 189 | { 190 | return codec_table_caps; 191 | } 192 | 193 | 194 | GstImxAudioUniaudioCodec* gst_imx_audio_uniaudio_codec_table_get_codec(GstCaps *caps) 195 | { 196 | GList *l; 197 | GST_DEBUG("trying to find suitable codec for caps %" GST_PTR_FORMAT, (gpointer)caps); 198 | for (l = codec_table; l != NULL; l = l->next) 199 | { 200 | GstImxAudioUniaudioCodec *codec = (GstImxAudioUniaudioCodec *)(l->data); 201 | gboolean ok = gst_caps_is_always_compatible(caps, codec->caps); 202 | GST_DEBUG("codec caps %" GST_PTR_FORMAT " compatible: %s", (gpointer)(codec->caps), ok ? "yes" : "no"); 203 | if (ok) 204 | return codec; 205 | } 206 | 207 | GST_WARNING("no suitable codec found"); 208 | 209 | return NULL; 210 | } 211 | -------------------------------------------------------------------------------- /ext/audio/gstimxuniaudiocodec.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_AUDIO_UNIAUDIO_CODEC_H 20 | #define GST_IMX_AUDIO_UNIAUDIO_CODEC_H 21 | 22 | #include 23 | 24 | #pragma GCC diagnostic push 25 | #pragma GCC diagnostic ignored "-Wpedantic" 26 | #include 27 | #pragma GCC diagnostic pop 28 | 29 | 30 | G_BEGIN_DECLS 31 | 32 | 33 | typedef struct _GstImxAudioUniaudioCodec GstImxAudioUniaudioCodec; 34 | 35 | 36 | struct _GstImxAudioUniaudioCodec 37 | { 38 | GstCaps *caps; 39 | void* dlhandle; 40 | 41 | tUniACodecQueryInterface query_interface; 42 | 43 | UniACodecVersionInfo get_version_info; 44 | UniACodecCreate create_codec; 45 | UniACodecDelete delete_codec; 46 | UniACodecSetParameter set_parameter; 47 | UniACodecGetParameter get_parameter; 48 | UniACodec_decode_frame decode_frame; 49 | UniACodecReset reset; 50 | UniACodec_get_last_error get_last_error; 51 | }; 52 | 53 | 54 | void gst_imx_audio_uniaudio_codec_table_init(void); 55 | GstCaps* gst_imx_audio_uniaudio_codec_table_get_caps(void); 56 | GstImxAudioUniaudioCodec* gst_imx_audio_uniaudio_codec_table_get_codec(GstCaps *caps); 57 | 58 | 59 | G_END_DECLS 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /ext/audio/gstimxuniaudiodecoder.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_AUDIO_UNIAUDIO_DECODER_H 20 | #define GST_IMX_AUDIO_UNIAUDIO_DECODER_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxAudioUniaudioDec GstImxAudioUniaudioDec; 29 | typedef struct _GstImxAudioUniaudioDecClass GstImxAudioUniaudioDecClass; 30 | 31 | 32 | #define GST_TYPE_IMX_AUDIO_UNIAUDIO_DEC (gst_imx_audio_uniaudio_dec_get_type()) 33 | #define GST_IMX_AUDIO_UNIAUDIO_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_AUDIO_UNIAUDIO_DEC,GstImxAudioUniaudioDec)) 34 | #define GST_IMX_AUDIO_UNIAUDIO_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_AUDIO_UNIAUDIO_DEC,GstImxAudioUniaudioDecClass)) 35 | #define GST_IS_IMX_AUDIO_UNIAUDIO_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_AUDIO_UNIAUDIO_DEC)) 36 | #define GST_IS_IMX_AUDIO_UNIAUDIO_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_AUDIO_UNIAUDIO_DEC)) 37 | 38 | 39 | GType gst_imx_audio_uniaudio_dec_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /ext/audio/meson.build: -------------------------------------------------------------------------------- 1 | if not gstreamer_audio_dep.found() 2 | # TODO: if the audio element options are set to "enabled", and gstaudio was not found, print an error and exit 3 | subdir_done() 4 | endif 5 | 6 | # Check for the libfslaudiocodec library to build the uniaudiodec element 7 | libfslaudiocodec_dep = dependency('libfslaudiocodec', required : get_option('uniaudiodec')) 8 | fslcodec_libdirvar = '' 9 | if libfslaudiocodec_dep.found() 10 | fslcodec_libdirvar = libfslaudiocodec_dep.get_variable(pkgconfig: 'libdir', default_value : '') 11 | if fslcodec_libdirvar != '' 12 | message('Found installed fslaudiocodec library - uniaudio decoder will be built') 13 | message('imx audio codec path: "' + fslcodec_libdirvar + '"') 14 | conf_data.set_quoted('IMX_AUDIO_CODEC_PATH', fslcodec_libdirvar) 15 | conf_data.set('WITH_IMX_UNIAUDIO_DECODER', 1) 16 | else 17 | message('Found installed fslaudiocodec library, but could not find fsl codec path - uniaudio decoder will not be built') 18 | endif 19 | else 20 | message('Installed fslaudiocodec library not found, or user disabled uniaudiodec element compilation - uniaudio decoder will not be built') 21 | endif 22 | 23 | # Check for the mp3 encoder library to build the mp3encoder element 24 | mp3encoder_dep = cc.find_library('_mp3_enc_arm12_elinux', dirs : [fslcodec_libdirvar], required : get_option('mp3encoder')) 25 | if mp3encoder_dep.found() 26 | conf_data.set('WITH_IMX_MP3_ENCODER', 1) 27 | message('Found installed _mp3_enc_arm12_elinux library - mp3 encoder will be built') 28 | else 29 | message('Installed _mp3_enc_arm12_elinux library not found, or user disabled mp3encoder element compilation - mp3 encoder will not be built') 30 | endif 31 | 32 | 33 | source = ['plugin.c'] 34 | if libfslaudiocodec_dep.found() 35 | source += ['gstimxuniaudiocodec.c', 'gstimxuniaudiodecoder.c'] 36 | endif 37 | if mp3encoder_dep.found() 38 | source += ['gstimxmp3encoder.c'] 39 | endif 40 | 41 | if source != [] 42 | library( 43 | 'gstimxaudio', 44 | source, 45 | install : true, 46 | install_dir: plugins_install_dir, 47 | include_directories: [configinc, libsinc], 48 | dependencies : [gstreamer_dep, gstreamer_base_dep, gstreamer_audio_dep, libdl_dep, libfslaudiocodec_dep, mp3encoder_dep], 49 | link_with : [gstimxcommon] 50 | ) 51 | endif 52 | 53 | -------------------------------------------------------------------------------- /ext/audio/plugin.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #ifdef WITH_IMX_UNIAUDIO_DECODER 22 | #include "gstimxuniaudiodecoder.h" 23 | #endif 24 | #ifdef WITH_IMX_MP3_ENCODER 25 | #include "gstimxmp3encoder.h" 26 | #endif 27 | 28 | 29 | 30 | static gboolean plugin_init(GstPlugin *plugin) 31 | { 32 | gboolean ret = TRUE; 33 | #ifdef WITH_IMX_UNIAUDIO_DECODER 34 | ret = ret && gst_element_register(plugin, "imxuniaudiodec", GST_RANK_PRIMARY + 1, gst_imx_audio_uniaudio_dec_get_type()); 35 | #endif 36 | #ifdef WITH_IMX_MP3_ENCODER 37 | ret = ret && gst_element_register(plugin, "imxmp3audioenc", GST_RANK_PRIMARY + 1, gst_imx_audio_mp3_enc_get_type()); 38 | #endif 39 | return ret; 40 | } 41 | 42 | 43 | 44 | GST_PLUGIN_DEFINE( 45 | GST_VERSION_MAJOR, 46 | GST_VERSION_MINOR, 47 | imxaudio, 48 | "audio elements for the NXP i.MX platforms", 49 | plugin_init, 50 | VERSION, 51 | "LGPL", 52 | GST_PACKAGE_NAME, 53 | GST_PACKAGE_ORIGIN 54 | ) 55 | -------------------------------------------------------------------------------- /ext/imx2d/gstimx2dcompositor.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_2D_COMPOSITOR_H 20 | #define GST_IMX_2D_COMPOSITOR_H 21 | 22 | #include 23 | #include 24 | #include "imx2d/imx2d.h" 25 | #include "gst/imx/video/gstimxvideobufferpool.h" 26 | 27 | 28 | G_BEGIN_DECLS 29 | 30 | 31 | #define GST_TYPE_IMX_2D_COMPOSITOR (gst_imx_2d_compositor_get_type()) 32 | #define GST_IMX_2D_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_2D_COMPOSITOR, GstImx2dCompositor)) 33 | #define GST_IMX_2D_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_2D_COMPOSITOR, GstImx2dCompositorClass)) 34 | #define GST_IMX_2D_COMPOSITOR_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_2D_COMPOSITOR, GstImx2dCompositorClass)) 35 | #define GST_IMX_2D_COMPOSITOR_CAST(obj) ((GstImx2dCompositor *)(obj)) 36 | #define GST_IS_IMX_2D_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_2D_COMPOSITOR)) 37 | #define GST_IS_IMX_2D_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_2D_COMPOSITOR)) 38 | 39 | 40 | typedef struct _GstImx2dCompositor GstImx2dCompositor; 41 | typedef struct _GstImx2dCompositorClass GstImx2dCompositorClass; 42 | 43 | 44 | struct _GstImx2dCompositor 45 | { 46 | GstVideoAggregator parent; 47 | 48 | /*< private >*/ 49 | 50 | GstAllocator *imx_dma_buffer_allocator; 51 | 52 | GstImxVideoBufferPool *video_buffer_pool; 53 | 54 | Imx2dBlitter *blitter; 55 | 56 | GstVideoInfo output_video_info; 57 | Imx2dSurface *output_surface; 58 | 59 | guint32 background_color; 60 | }; 61 | 62 | 63 | struct _GstImx2dCompositorClass 64 | { 65 | GstVideoAggregatorClass parent_class; 66 | 67 | Imx2dBlitter* (*create_blitter)(GstImx2dCompositor *imx_2d_compositor); 68 | 69 | Imx2dHardwareCapabilities const *hardware_capabilities; 70 | }; 71 | 72 | 73 | GType gst_imx_2d_compositor_get_type(void); 74 | 75 | 76 | void gst_imx_2d_compositor_common_class_init(GstImx2dCompositorClass *klass, Imx2dHardwareCapabilities const *capabilities); 77 | 78 | 79 | G_END_DECLS 80 | 81 | 82 | #endif /* GST_IMX_2D_COMPOSITOR_H */ 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimx2dmisc.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_2D_VIDEO_MISC_H 20 | #define GST_IMX_2D_VIDEO_MISC_H 21 | 22 | #include 23 | #include 24 | #include "imx2d/imx2d.h" 25 | 26 | 27 | G_BEGIN_DECLS 28 | 29 | 30 | typedef enum 31 | { 32 | GST_IMX_2D_TILE_LAYOUT_NONE, 33 | GST_IMX_2D_TILE_LAYOUT_AMPHION_8x128 34 | } 35 | GstImx2dTileLayout; 36 | 37 | 38 | void gst_imx_2d_setup_logging(void); 39 | 40 | GstCaps* gst_imx_remove_tile_layout_from_caps(GstCaps *caps, GstImx2dTileLayout *tile_layout); 41 | gboolean gst_imx_video_info_from_caps(GstVideoInfo *info, GstCaps const *caps, GstImx2dTileLayout *tile_layout, GstCaps **modified_caps); 42 | 43 | Imx2dPixelFormat gst_imx_2d_convert_from_gst_video_format(GstVideoFormat gst_video_format, GstImx2dTileLayout const *tile_layout); 44 | GstVideoFormat gst_imx_2d_convert_to_gst_video_format(Imx2dPixelFormat imx2d_format); 45 | 46 | GstCaps* gst_imx_2d_get_caps_from_imx2d_capabilities(Imx2dHardwareCapabilities const *capabilities, GstPadDirection direction); 47 | GstCaps* gst_imx_2d_get_caps_from_imx2d_capabilities_full(Imx2dHardwareCapabilities const *capabilities, GstPadDirection direction, gboolean add_composition_meta); 48 | 49 | void gst_imx_2d_canvas_calculate_letterbox_margin( 50 | Imx2dBlitMargin *margin, 51 | Imx2dRegion *inner_region, 52 | Imx2dRegion const *outer_region, 53 | gboolean video_transposed, 54 | guint video_width, guint video_height, 55 | guint video_par_n, guint video_par_d 56 | ); 57 | 58 | gboolean gst_imx_2d_check_input_buffer_structure(GstBuffer *input_buffer, guint num_planes); 59 | 60 | /* Assigns DMA buffers of uploaded_input_buffer to the surface, 61 | * and fills the surface description plane_stride values. 62 | * input_video_info is used as a fallback in case uploaded_input_buffer 63 | * has no video meta. If it is 100% guaranteed that uploaded_input_buffer 64 | * _does_ have that meta, it is OK to set input_video_info to NULL. */ 65 | void gst_imx_2d_assign_input_buffer_to_surface( 66 | GstBuffer *uploaded_input_buffer, 67 | Imx2dSurface *surface, 68 | Imx2dSurfaceDesc *surface_desc, 69 | GstVideoInfo const *input_video_info 70 | ); 71 | void gst_imx_2d_assign_output_buffer_to_surface(Imx2dSurface *surface, GstBuffer *output_buffer, GstVideoInfo const *output_video_info); 72 | 73 | void gst_imx_2d_align_output_video_info(GstVideoInfo *output_video_info, gint *num_padding_rows, Imx2dHardwareCapabilities const *hardware_capabilities); 74 | 75 | gint gst_imx_2d_get_stride_alignment_for(Imx2dPixelFormat imx2d_format, Imx2dHardwareCapabilities const *hardware_capabilities); 76 | 77 | Imx2dRotation gst_imx_2d_convert_from_video_orientation_method(GstVideoOrientationMethod method); 78 | 79 | gboolean gst_imx_2d_orientation_from_image_direction_tag(GstTagList const *taglist, GstVideoOrientationMethod *orientation); 80 | 81 | Imx2dColorimetry gst_imx_2d_convert_colorimetry(GstVideoColorimetry const *colorimetry); 82 | 83 | 84 | G_END_DECLS 85 | 86 | 87 | #endif /* GST_IMX_2D_VIDEO_MISC_H */ 88 | -------------------------------------------------------------------------------- /ext/imx2d/gstimx2dvideooverlayhandler.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_2D_VIDEO_OVERLAY_HANDLER_H 20 | #define GST_IMX_2D_VIDEO_OVERLAY_HANDLER_H 21 | 22 | #include 23 | #include 24 | #include "gst/imx/common/gstimxdmabufferuploader.h" 25 | #include "imx2d/imx2d.h" 26 | 27 | 28 | G_BEGIN_DECLS 29 | 30 | 31 | /* The GstImx2dVideoOverlayHandler is an internal object used in 32 | * imx2d based GStreamer elements. Its purpose is to render overlays 33 | * with an imx2d blitter. Said overlays are specified by an instance 34 | * of GstVideoOverlayComposition, which is contained in GstBuffers 35 | * in a GstVideoOverlayCompositionMeta. 36 | * 37 | * GstVideoOverlayComposition contains a number of "rectangles" - 38 | * GstVideoOverlayRectangle instances that specify the individual 39 | * overlays. Each rectangle defines the overlay with a gstbuffer 40 | * (which contains the pixels), coordinates, and a global alpha 41 | * value. Since overlays often do not render at every frame, it 42 | * is useful to cache all that information. Such caching is one 43 | * of the tasks of GstImx2dVideoOverlayHandler. In particular, the 44 | * contents of these gstbuffers have to be uploaded into a form 45 | * that can be used with imx2d blitters. GstImxDmaBufferUploader 46 | * is used for this purpose. Uploaded versions of overlay gstbuffers 47 | * are kept in the cache. Also, the GstVideoOverlayComposition from 48 | * the meta is ref'd until either a new GstVideoOverlayComposition 49 | * is detected (in an incoming frame that has such a meta), or if 50 | * gst_imx_2d_video_overlay_handler_clear_cached_overlays() is called, 51 | * or until the GstImx2dVideoOverlayHandler instance is destroyed. 52 | * Ref'ing the GstVideoOverlayComposition makes sure that it cannot 53 | * be modified in-place by someone else, and also allows for checking 54 | * if incoming buffers contain the exact same composition. If so, 55 | * the cached data can be reused, otherwise the cache has to be 56 | * repopulated with the new composition's data. 57 | * 58 | * The overlays are drawn with gst_imx_2d_video_overlay_handler_render(). 59 | * Note that imx_2d_blitter_start() must have been called before 60 | * that function can be used, since it does not start an imx2d 61 | * blitter operation sequence on its own. (This is intentional; 62 | * it allows for combining operations from somewhere else with 63 | * blitter operations performed by that function without having 64 | * to start/finish multiple sequences.) 65 | */ 66 | 67 | 68 | #define GST_TYPE_IMX_2D_VIDEO_OVERLAY_HANDLER (gst_imx_2d_video_overlay_handler_get_type()) 69 | #define GST_IMX_2D_VIDEO_OVERLAY_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_2D_VIDEO_OVERLAY_HANDLER, GstImx2dVideoOverlayHandler)) 70 | #define GST_IMX_2D_VIDEO_OVERLAY_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_2D_VIDEO_OVERLAY_HANDLER, GstImx2dVideoOverlayHandlerClass)) 71 | #define GST_IMX_2D_VIDEO_OVERLAY_HANDLER_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_2D_VIDEO_OVERLAY_HANDLER, GstImx2dVideoOverlayHandlerClass)) 72 | #define GST_IMX_2D_VIDEO_OVERLAY_HANDLER_CAST(obj) ((GstImx2dVideoOverlayHandler *)(obj)) 73 | #define GST_IS_IMX_2D_VIDEO_OVERLAY_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_2D_VIDEO_OVERLAY_HANDLER)) 74 | #define GST_IS_IMX_2D_VIDEO_OVERLAY_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_2D_VIDEO_OVERLAY_HANDLER)) 75 | 76 | 77 | typedef struct _GstImx2dVideoOverlayHandler GstImx2dVideoOverlayHandler; 78 | typedef struct _GstImx2dVideoOverlayHandlerClass GstImx2dVideoOverlayHandlerClass; 79 | 80 | 81 | GstImx2dVideoOverlayHandler* gst_imx_2d_video_overlay_handler_new(GstImxDmaBufferUploader *uploader, Imx2dBlitter *blitter); 82 | 83 | void gst_imx_2d_video_overlay_handler_clear_cached_overlays(GstImx2dVideoOverlayHandler *video_overlay_handler); 84 | 85 | gboolean gst_imx_2d_video_overlay_handler_render(GstImx2dVideoOverlayHandler *video_overlay_handler, GstBuffer *buffer); 86 | 87 | 88 | G_END_DECLS 89 | 90 | 91 | #endif /* GST_IMX_2D_VIDEO_OVERLAY_HANDLER_H */ 92 | -------------------------------------------------------------------------------- /ext/imx2d/gstimx2dvideosink.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_2D_VIDEO_SINK_H 20 | #define GST_IMX_2D_VIDEO_SINK_H 21 | 22 | #include 23 | #include 24 | #include "gst/imx/video/gstimxvideouploader.h" 25 | #include "imx2d/imx2d.h" 26 | #include "imx2d/linux_framebuffer.h" 27 | #include "gstimx2dvideooverlayhandler.h" 28 | 29 | 30 | G_BEGIN_DECLS 31 | 32 | 33 | #define GST_TYPE_IMX_2D_VIDEO_SINK (gst_imx_2d_video_sink_get_type()) 34 | #define GST_IMX_2D_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_2D_VIDEO_SINK, GstImx2dVideoSink)) 35 | #define GST_IMX_2D_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_2D_VIDEO_SINK, GstImx2dVideoSinkClass)) 36 | #define GST_IMX_2D_VIDEO_SINK_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_2D_VIDEO_SINK, GstImx2dVideoSinkClass)) 37 | #define GST_IMX_2D_VIDEO_SINK_CAST(obj) ((GstImx2dVideoSink *)(obj)) 38 | #define GST_IS_IMX_2D_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_2D_VIDEO_SINK)) 39 | #define GST_IS_IMX_2D_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_2D_VIDEO_SINK)) 40 | 41 | 42 | typedef struct _GstImx2dVideoSink GstImx2dVideoSink; 43 | typedef struct _GstImx2dVideoSinkClass GstImx2dVideoSinkClass; 44 | 45 | 46 | struct _GstImx2dVideoSink 47 | { 48 | GstVideoSink parent; 49 | 50 | /*< private >*/ 51 | 52 | GstImxVideoUploader *uploader; 53 | GstAllocator *imx_dma_buffer_allocator; 54 | 55 | Imx2dBlitter *blitter; 56 | 57 | GstVideoInfo input_video_info; 58 | Imx2dSurface *input_surface; 59 | Imx2dSurfaceDesc input_surface_desc; 60 | 61 | Imx2dLinuxFramebuffer *framebuffer; 62 | Imx2dSurface *framebuffer_surface; 63 | Imx2dSurfaceDesc const *framebuffer_surface_desc; 64 | 65 | GstImx2dVideoOverlayHandler *overlay_handler; 66 | 67 | gboolean drop_frames; 68 | gchar *framebuffer_name; 69 | gboolean input_crop; 70 | GstVideoOrientationMethod video_direction; 71 | gboolean clear_at_null; 72 | gboolean clear_on_relocate; 73 | gboolean render_overlays; 74 | gboolean use_vsync; 75 | gboolean force_aspect_ratio; 76 | gint window_x_coord, window_y_coord; 77 | guint window_width, window_height; 78 | Imx2dBlitMargin extra_margin; 79 | 80 | GstVideoOrientationMethod tag_video_direction; 81 | 82 | gboolean drop_frames_changed; 83 | 84 | int write_fb_page; 85 | int display_fb_page; 86 | int num_fb_pages; 87 | 88 | /* Terminology: 89 | * 90 | * inner_region = The region covered by the actual 91 | * frame, without any margin. 92 | * 93 | * outer_region = inner_region plus the margin that 94 | * is calculated to draw the letterbox. If the 95 | * aspect ratio is not kept (in other words, 96 | * force_aspect_ratio is FALSE then), then the 97 | * outer_region equals the inner_region. 98 | * 99 | * total_region = outer_region plus extra margin 100 | * specified by the GObject margin properties. 101 | * 102 | * The inner_region is always centered inside 103 | * outer_region, but outer_region may not 104 | * necessarily centered in total_region. 105 | * 106 | * The window-* properties define the total_region. 107 | * extra_margin defines the margin that is added 108 | * around outer_region. 109 | */ 110 | Imx2dRegion total_region; 111 | Imx2dRegion outer_region; 112 | Imx2dRegion inner_region; 113 | 114 | /* letterbox_margin: Margin calculated for producing 115 | * a letterbox around the inner_region. inner_region 116 | * plus letterbox_margin result in the outer_region. 117 | * 118 | * extra_margin: Margin defined by the user via the 119 | * GObject margin properties. outer_region plus 120 | * extra_margin result in total_region. 121 | * 122 | * combined_margin: letterbox_margin plus extra_margin. 123 | * inner_region plus combined_margin result in total_region. 124 | * 125 | * The GObject margin color property value is stored 126 | * in the combined_margin's color field. The color fields 127 | * of letterbox_margin and extra_margin are not used. 128 | */ 129 | Imx2dBlitMargin letterbox_margin; 130 | Imx2dBlitMargin combined_margin; 131 | 132 | gboolean region_coords_need_update; 133 | gboolean total_region_valid; 134 | }; 135 | 136 | 137 | struct _GstImx2dVideoSinkClass 138 | { 139 | GstVideoSinkClass parent_class; 140 | 141 | gboolean (*start)(GstImx2dVideoSink *imx_2d_video_sink); 142 | gboolean (*stop)(GstImx2dVideoSink *imx_2d_video_sink); 143 | 144 | Imx2dBlitter* (*create_blitter)(GstImx2dVideoSink *imx_2d_video_sink); 145 | 146 | Imx2dHardwareCapabilities const *hardware_capabilities; 147 | }; 148 | 149 | 150 | GType gst_imx_2d_video_sink_get_type(void); 151 | 152 | 153 | void gst_imx_2d_video_sink_common_class_init(GstImx2dVideoSinkClass *klass, Imx2dHardwareCapabilities const *capabilities); 154 | 155 | 156 | G_END_DECLS 157 | 158 | 159 | #endif /* GST_IMX_2D_VIDEO_TRASINK*/ 160 | -------------------------------------------------------------------------------- /ext/imx2d/gstimx2dvideotransform.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_2D_VIDEO_TRANSFORM_H 20 | #define GST_IMX_2D_VIDEO_TRANSFORM_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include "gst/imx/video/gstimxvideobufferpool.h" 26 | #include "gst/imx/video/gstimxvideouploader.h" 27 | #include "imx2d/imx2d.h" 28 | #include "gstimx2dmisc.h" 29 | #include "gstimx2dvideooverlayhandler.h" 30 | 31 | 32 | G_BEGIN_DECLS 33 | 34 | 35 | #define GST_TYPE_IMX_2D_VIDEO_TRANSFORM (gst_imx_2d_video_transform_get_type()) 36 | #define GST_IMX_2D_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_2D_VIDEO_TRANSFORM, GstImx2dVideoTransform)) 37 | #define GST_IMX_2D_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_2D_VIDEO_TRANSFORM, GstImx2dVideoTransformClass)) 38 | #define GST_IMX_2D_VIDEO_TRANSFORM_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_2D_VIDEO_TRANSFORM, GstImx2dVideoTransformClass)) 39 | #define GST_IMX_2D_VIDEO_TRANSFORM_CAST(obj) ((GstImx2dVideoTransform *)(obj)) 40 | #define GST_IS_IMX_2D_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_2D_VIDEO_TRANSFORM)) 41 | #define GST_IS_IMX_2D_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_2D_VIDEO_TRANSFORM)) 42 | 43 | 44 | typedef struct _GstImx2dVideoTransform GstImx2dVideoTransform; 45 | typedef struct _GstImx2dVideoTransformClass GstImx2dVideoTransformClass; 46 | 47 | 48 | struct _GstImx2dVideoTransform 49 | { 50 | GstBaseTransform parent; 51 | 52 | /*< private >*/ 53 | 54 | GstImxVideoUploader *uploader; 55 | GstAllocator *imx_dma_buffer_allocator; 56 | 57 | GstImxVideoBufferPool *video_buffer_pool; 58 | 59 | Imx2dBlitter *blitter; 60 | 61 | gboolean inout_info_equal; 62 | gboolean inout_info_set; 63 | 64 | gboolean passing_through_overlay_meta; 65 | 66 | GstVideoInfo input_video_info; 67 | GstVideoInfo output_video_info; 68 | 69 | GstCaps *input_caps; 70 | 71 | Imx2dSurface *input_surface; 72 | Imx2dSurface *output_surface; 73 | 74 | Imx2dSurfaceDesc input_surface_desc; 75 | 76 | GstImx2dVideoOverlayHandler *overlay_handler; 77 | 78 | gboolean input_crop; 79 | GstVideoOrientationMethod video_direction; 80 | gboolean disable_passthrough; 81 | 82 | GstVideoOrientationMethod tag_video_direction; 83 | }; 84 | 85 | 86 | struct _GstImx2dVideoTransformClass 87 | { 88 | GstBaseTransformClass parent_class; 89 | 90 | gboolean (*start)(GstImx2dVideoTransform *imx_2d_video_transform); 91 | gboolean (*stop)(GstImx2dVideoTransform *imx_2d_video_transform); 92 | 93 | Imx2dBlitter* (*create_blitter)(GstImx2dVideoTransform *imx_2d_video_transform); 94 | 95 | Imx2dHardwareCapabilities const *hardware_capabilities; 96 | }; 97 | 98 | 99 | GType gst_imx_2d_video_transform_get_type(void); 100 | 101 | 102 | void gst_imx_2d_video_transform_common_class_init(GstImx2dVideoTransformClass *klass, Imx2dHardwareCapabilities const *capabilities); 103 | 104 | 105 | G_END_DECLS 106 | 107 | 108 | #endif /* GST_IMX_2D_VIDEO_TRANSFORM_H */ 109 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxg2dcompositor.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/g2d/g2d_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dcompositor.h" 24 | #include "gstimxg2dcompositor.h" 25 | 26 | 27 | struct _GstImxG2DCompositor 28 | { 29 | GstImx2dCompositor parent; 30 | }; 31 | 32 | 33 | struct _GstImxG2DCompositorClass 34 | { 35 | GstImx2dCompositorClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxG2DCompositor, gst_imx_g2d_compositor, GST_TYPE_IMX_2D_COMPOSITOR) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_g2d_compositor_create_blitter(GstImx2dCompositor *imx_2d_compositor); 43 | 44 | 45 | 46 | 47 | static void gst_imx_g2d_compositor_class_init(GstImxG2DCompositorClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dCompositorClass *imx_2d_compositor_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_compositor_class = GST_IMX_2D_COMPOSITOR_CLASS(klass); 54 | 55 | imx_2d_compositor_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_g2d_compositor_create_blitter); 56 | 57 | gst_imx_2d_compositor_common_class_init( 58 | imx_2d_compositor_class, 59 | imx_2d_backend_g2d_get_hardware_capabilities() 60 | ); 61 | 62 | gst_element_class_set_static_metadata( 63 | element_class, 64 | "i.MX G2D video transform", 65 | "Filter/Effect/Video/Compositor/Hardware", 66 | "Video transformation using the Vivante G2D API on i.MX platforms", 67 | "Carlos Rafael Giani " 68 | ); 69 | } 70 | 71 | 72 | void gst_imx_g2d_compositor_init(G_GNUC_UNUSED GstImxG2DCompositor *self) 73 | { 74 | } 75 | 76 | 77 | static Imx2dBlitter* gst_imx_g2d_compositor_create_blitter(G_GNUC_UNUSED GstImx2dCompositor *imx_2d_compositor) 78 | { 79 | return imx_2d_backend_g2d_blitter_create(); 80 | } 81 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxg2dcompositor.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_G2D_COMPOSITOR_H 20 | #define GST_IMX_G2D_COMPOSITOR_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxG2DCompositor GstImxG2DCompositor; 29 | typedef struct _GstImxG2DCompositorClass GstImxG2DCompositorClass; 30 | 31 | 32 | #define GST_TYPE_IMX_G2D_COMPOSITOR (gst_imx_g2d_compositor_get_type()) 33 | #define GST_IMX_G2D_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_G2D_COMPOSITOR,GstImxG2DCompositor)) 34 | #define GST_IMX_G2D_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_G2D_COMPOSITOR,GstImxG2DCompositorClass)) 35 | #define GST_IS_IMX_G2D_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_G2D_COMPOSITOR)) 36 | #define GST_IS_IMX_G2D_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_G2D_COMPOSITOR)) 37 | 38 | 39 | GType gst_imx_g2d_compositor_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_2D_G2D_COMPOSITOR_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxg2dvideosink.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/g2d/g2d_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dvideosink.h" 24 | #include "gstimxg2dvideosink.h" 25 | 26 | 27 | struct _GstImxG2DVideoSink 28 | { 29 | GstImx2dVideoSink parent; 30 | }; 31 | 32 | 33 | struct _GstImxG2DVideoSinkClass 34 | { 35 | GstImx2dVideoSinkClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxG2DVideoSink, gst_imx_g2d_video_sink, GST_TYPE_IMX_2D_VIDEO_SINK) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_g2d_video_sink_create_blitter(GstImx2dVideoSink *imx_2d_video_sink); 43 | 44 | 45 | 46 | 47 | static void gst_imx_g2d_video_sink_class_init(GstImxG2DVideoSinkClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dVideoSinkClass *imx_2d_video_sink_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_video_sink_class = GST_IMX_2D_VIDEO_SINK_CLASS(klass); 54 | 55 | imx_2d_video_sink_class->start = NULL; 56 | imx_2d_video_sink_class->stop = NULL; 57 | imx_2d_video_sink_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_g2d_video_sink_create_blitter); 58 | 59 | gst_imx_2d_video_sink_common_class_init( 60 | imx_2d_video_sink_class, 61 | imx_2d_backend_g2d_get_hardware_capabilities() 62 | ); 63 | 64 | gst_element_class_set_static_metadata( 65 | element_class, 66 | "i.MX G2D video sink", 67 | "Sink/Video/Hardware", 68 | "Video output using the Vivante G2D API on i.MX platforms", 69 | "Carlos Rafael Giani " 70 | ); 71 | } 72 | 73 | 74 | void gst_imx_g2d_video_sink_init(G_GNUC_UNUSED GstImxG2DVideoSink *self) 75 | { 76 | } 77 | 78 | 79 | static Imx2dBlitter* gst_imx_g2d_video_sink_create_blitter(G_GNUC_UNUSED GstImx2dVideoSink *imx_2d_video_sink) 80 | { 81 | return imx_2d_backend_g2d_blitter_create(); 82 | } 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxg2dvideosink.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_G2D_VIDEO_SINK_H 20 | #define GST_IMX_G2D_VIDEO_SINK_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxG2DVideoSink GstImxG2DVideoSink; 29 | typedef struct _GstImxG2DVideoSinkClass GstImxG2DVideoSinkClass; 30 | 31 | 32 | #define GST_TYPE_IMX_G2D_VIDEO_SINK (gst_imx_g2d_video_sink_get_type()) 33 | #define GST_IMX_G2D_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_G2D_VIDEO_SINK,GstImxG2DVideoSink)) 34 | #define GST_IMX_G2D_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_G2D_VIDEO_SINK,GstImxG2DVideoSinkClass)) 35 | #define GST_IS_IMX_G2D_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_G2D_VIDEO_SINK)) 36 | #define GST_IS_IMX_G2D_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_G2D_VIDEO_SINK)) 37 | 38 | 39 | GType gst_imx_g2d_video_sink_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_2D_G2D_VIDEO_SINK_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxg2dvideotransform.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/g2d/g2d_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dvideotransform.h" 24 | #include "gstimxg2dvideotransform.h" 25 | 26 | 27 | struct _GstImxG2DVideoTransform 28 | { 29 | GstImx2dVideoTransform parent; 30 | }; 31 | 32 | 33 | struct _GstImxG2DVideoTransformClass 34 | { 35 | GstImx2dVideoTransformClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxG2DVideoTransform, gst_imx_g2d_video_transform, GST_TYPE_IMX_2D_VIDEO_TRANSFORM) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_g2d_video_transform_create_blitter(GstImx2dVideoTransform *imx_2d_video_transform); 43 | 44 | 45 | 46 | 47 | static void gst_imx_g2d_video_transform_class_init(GstImxG2DVideoTransformClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dVideoTransformClass *imx_2d_video_transform_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_video_transform_class = GST_IMX_2D_VIDEO_TRANSFORM_CLASS(klass); 54 | 55 | imx_2d_video_transform_class->start = NULL; 56 | imx_2d_video_transform_class->stop = NULL; 57 | imx_2d_video_transform_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_g2d_video_transform_create_blitter); 58 | 59 | gst_imx_2d_video_transform_common_class_init( 60 | imx_2d_video_transform_class, 61 | imx_2d_backend_g2d_get_hardware_capabilities() 62 | ); 63 | 64 | gst_element_class_set_static_metadata( 65 | element_class, 66 | "i.MX G2D video transform", 67 | "Filter/Converter/Video/Scaler/Transform/Effect/Hardware", 68 | "Video transformation using the Vivante G2D API on i.MX platforms", 69 | "Carlos Rafael Giani " 70 | ); 71 | } 72 | 73 | 74 | void gst_imx_g2d_video_transform_init(G_GNUC_UNUSED GstImxG2DVideoTransform *self) 75 | { 76 | } 77 | 78 | 79 | static Imx2dBlitter* gst_imx_g2d_video_transform_create_blitter(G_GNUC_UNUSED GstImx2dVideoTransform *imx_2d_video_transform) 80 | { 81 | return imx_2d_backend_g2d_blitter_create(); 82 | } 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxg2dvideotransform.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_G2D_VIDEO_TRANSFORM_H 20 | #define GST_IMX_G2D_VIDEO_TRANSFORM_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxG2DVideoTransform GstImxG2DVideoTransform; 29 | typedef struct _GstImxG2DVideoTransformClass GstImxG2DVideoTransformClass; 30 | 31 | 32 | #define GST_TYPE_IMX_G2D_VIDEO_TRANSFORM (gst_imx_g2d_video_transform_get_type()) 33 | #define GST_IMX_G2D_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_G2D_VIDEO_TRANSFORM,GstImxG2DVideoTransform)) 34 | #define GST_IMX_G2D_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_G2D_VIDEO_TRANSFORM,GstImxG2DVideoTransformClass)) 35 | #define GST_IS_IMX_G2D_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_G2D_VIDEO_TRANSFORM)) 36 | #define GST_IS_IMX_G2D_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_G2D_VIDEO_TRANSFORM)) 37 | 38 | 39 | GType gst_imx_g2d_video_transform_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_2D_G2D_VIDEO_TRANSFORM_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxipuvideosink.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2023 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/ipu/ipu_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dvideosink.h" 24 | #include "gstimxipuvideosink.h" 25 | 26 | 27 | struct _GstImxIPUVideoSink 28 | { 29 | GstImx2dVideoSink parent; 30 | }; 31 | 32 | 33 | struct _GstImxIPUVideoSinkClass 34 | { 35 | GstImx2dVideoSinkClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxIPUVideoSink, gst_imx_ipu_video_sink, GST_TYPE_IMX_2D_VIDEO_SINK) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_ipu_video_sink_create_blitter(GstImx2dVideoSink *imx_2d_video_sink); 43 | 44 | 45 | 46 | 47 | static void gst_imx_ipu_video_sink_class_init(GstImxIPUVideoSinkClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dVideoSinkClass *imx_2d_video_sink_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_video_sink_class = GST_IMX_2D_VIDEO_SINK_CLASS(klass); 54 | 55 | imx_2d_video_sink_class->start = NULL; 56 | imx_2d_video_sink_class->stop = NULL; 57 | imx_2d_video_sink_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_ipu_video_sink_create_blitter); 58 | 59 | gst_imx_2d_video_sink_common_class_init( 60 | imx_2d_video_sink_class, 61 | imx_2d_backend_ipu_get_hardware_capabilities() 62 | ); 63 | 64 | gst_element_class_set_static_metadata( 65 | element_class, 66 | "i.MX IPU video sink", 67 | "Sink/Video/Hardware", 68 | "Video output using the i.MX IPU", 69 | "Carlos Rafael Giani " 70 | ); 71 | } 72 | 73 | 74 | void gst_imx_ipu_video_sink_init(G_GNUC_UNUSED GstImxIPUVideoSink *self) 75 | { 76 | } 77 | 78 | 79 | static Imx2dBlitter* gst_imx_ipu_video_sink_create_blitter(G_GNUC_UNUSED GstImx2dVideoSink *imx_2d_video_sink) 80 | { 81 | return imx_2d_backend_ipu_blitter_create(); 82 | } 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxipuvideosink.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2023 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_IPU_VIDEO_SINK_H 20 | #define GST_IMX_IPU_VIDEO_SINK_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxIPUVideoSink GstImxIPUVideoSink; 29 | typedef struct _GstImxIPUVideoSinkClass GstImxIPUVideoSinkClass; 30 | 31 | 32 | #define GST_TYPE_IMX_IPU_VIDEO_SINK (gst_imx_ipu_video_sink_get_type()) 33 | #define GST_IMX_IPU_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_IPU_VIDEO_SINK,GstImxIPUVideoSink)) 34 | #define GST_IMX_IPU_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_IPU_VIDEO_SINK,GstImxIPUVideoSinkClass)) 35 | #define GST_IS_IMX_IPU_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_IPU_VIDEO_SINK)) 36 | #define GST_IS_IMX_IPU_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_IPU_VIDEO_SINK)) 37 | 38 | 39 | GType gst_imx_ipu_video_sink_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_IPU_VIDEO_SINK_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxipuvideotransform.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/ipu/ipu_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dvideotransform.h" 24 | #include "gstimxipuvideotransform.h" 25 | 26 | 27 | struct _GstImxIPUVideoTransform 28 | { 29 | GstImx2dVideoTransform parent; 30 | }; 31 | 32 | 33 | struct _GstImxIPUVideoTransformClass 34 | { 35 | GstImx2dVideoTransformClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxIPUVideoTransform, gst_imx_ipu_video_transform, GST_TYPE_IMX_2D_VIDEO_TRANSFORM) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_ipu_video_transform_create_blitter(GstImx2dVideoTransform *imx_2d_video_transform); 43 | 44 | 45 | 46 | 47 | static void gst_imx_ipu_video_transform_class_init(GstImxIPUVideoTransformClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dVideoTransformClass *imx_2d_video_transform_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_video_transform_class = GST_IMX_2D_VIDEO_TRANSFORM_CLASS(klass); 54 | 55 | imx_2d_video_transform_class->start = NULL; 56 | imx_2d_video_transform_class->stop = NULL; 57 | imx_2d_video_transform_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_ipu_video_transform_create_blitter); 58 | 59 | gst_imx_2d_video_transform_common_class_init( 60 | imx_2d_video_transform_class, 61 | imx_2d_backend_ipu_get_hardware_capabilities() 62 | ); 63 | 64 | gst_element_class_set_static_metadata( 65 | element_class, 66 | "i.MX IPU video transform", 67 | "Filter/Converter/Video/Scaler/Transform/Effect/Hardware", 68 | "Video transformation using the i.MX IPU", 69 | "Carlos Rafael Giani " 70 | ); 71 | } 72 | 73 | 74 | void gst_imx_ipu_video_transform_init(G_GNUC_UNUSED GstImxIPUVideoTransform *self) 75 | { 76 | } 77 | 78 | 79 | static Imx2dBlitter* gst_imx_ipu_video_transform_create_blitter(G_GNUC_UNUSED GstImx2dVideoTransform *imx_2d_video_transform) 80 | { 81 | return imx_2d_backend_ipu_blitter_create(); 82 | } 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxipuvideotransform.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_IPU_VIDEO_TRANSFORM_H 20 | #define GST_IMX_IPU_VIDEO_TRANSFORM_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxIPUVideoTransform GstImxIPUVideoTransform; 29 | typedef struct _GstImxIPUVideoTransformClass GstImxIPUVideoTransformClass; 30 | 31 | 32 | #define GST_TYPE_IMX_IPU_VIDEO_TRANSFORM (gst_imx_ipu_video_transform_get_type()) 33 | #define GST_IMX_IPU_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_IPU_VIDEO_TRANSFORM,GstImxIPUVideoTransform)) 34 | #define GST_IMX_IPU_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_IPU_VIDEO_TRANSFORM,GstImxIPUVideoTransformClass)) 35 | #define GST_IS_IMX_IPU_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_IPU_VIDEO_TRANSFORM)) 36 | #define GST_IS_IMX_IPU_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_IPU_VIDEO_TRANSFORM)) 37 | 38 | 39 | GType gst_imx_ipu_video_transform_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_2D_IPU_VIDEO_TRANSFORM_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxpxpvideosink.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/pxp/pxp_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dvideosink.h" 24 | #include "gstimxpxpvideosink.h" 25 | 26 | 27 | struct _GstImxPxPVideoSink 28 | { 29 | GstImx2dVideoSink parent; 30 | }; 31 | 32 | 33 | struct _GstImxPxPVideoSinkClass 34 | { 35 | GstImx2dVideoSinkClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxPxPVideoSink, gst_imx_pxp_video_sink, GST_TYPE_IMX_2D_VIDEO_SINK) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_pxp_video_sink_create_blitter(GstImx2dVideoSink *imx_2d_video_sink); 43 | 44 | 45 | 46 | 47 | static void gst_imx_pxp_video_sink_class_init(GstImxPxPVideoSinkClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dVideoSinkClass *imx_2d_video_sink_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_video_sink_class = GST_IMX_2D_VIDEO_SINK_CLASS(klass); 54 | 55 | imx_2d_video_sink_class->start = NULL; 56 | imx_2d_video_sink_class->stop = NULL; 57 | imx_2d_video_sink_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_pxp_video_sink_create_blitter); 58 | 59 | gst_imx_2d_video_sink_common_class_init( 60 | imx_2d_video_sink_class, 61 | imx_2d_backend_pxp_get_hardware_capabilities() 62 | ); 63 | 64 | gst_element_class_set_static_metadata( 65 | element_class, 66 | "i.MX PxP video sink", 67 | "Sink/Video/Hardware", 68 | "Video output using the i.MX Pixel Pipeline (PxP)", 69 | "Carlos Rafael Giani " 70 | ); 71 | } 72 | 73 | 74 | void gst_imx_pxp_video_sink_init(G_GNUC_UNUSED GstImxPxPVideoSink *self) 75 | { 76 | } 77 | 78 | 79 | static Imx2dBlitter* gst_imx_pxp_video_sink_create_blitter(G_GNUC_UNUSED GstImx2dVideoSink *imx_2d_video_sink) 80 | { 81 | return imx_2d_backend_pxp_blitter_create(); 82 | } 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxpxpvideosink.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_PXP_VIDEO_SINK_H 20 | #define GST_IMX_PXP_VIDEO_SINK_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxPxPVideoSink GstImxPxPVideoSink; 29 | typedef struct _GstImxPxPVideoSinkClass GstImxPxPVideoSinkClass; 30 | 31 | 32 | #define GST_TYPE_IMX_PXP_VIDEO_SINK (gst_imx_pxp_video_sink_get_type()) 33 | #define GST_IMX_PXP_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_PXP_VIDEO_SINK,GstImxPxPVideoSink)) 34 | #define GST_IMX_PXP_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_PXP_VIDEO_SINK,GstImxPxPVideoSinkClass)) 35 | #define GST_IS_IMX_PXP_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_PXP_VIDEO_SINK)) 36 | #define GST_IS_IMX_PXP_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_PXP_VIDEO_SINK)) 37 | 38 | 39 | GType gst_imx_pxp_video_sink_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_2D_PXP_VIDEO_SINK_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxpxpvideotransform.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "imx2d/backend/pxp/pxp_blitter.h" 22 | #include "gstimx2dmisc.h" 23 | #include "gstimx2dvideotransform.h" 24 | #include "gstimxpxpvideotransform.h" 25 | 26 | 27 | struct _GstImxPxPVideoTransform 28 | { 29 | GstImx2dVideoTransform parent; 30 | }; 31 | 32 | 33 | struct _GstImxPxPVideoTransformClass 34 | { 35 | GstImx2dVideoTransformClass parent_class; 36 | }; 37 | 38 | 39 | G_DEFINE_TYPE(GstImxPxPVideoTransform, gst_imx_pxp_video_transform, GST_TYPE_IMX_2D_VIDEO_TRANSFORM) 40 | 41 | 42 | static Imx2dBlitter* gst_imx_pxp_video_transform_create_blitter(GstImx2dVideoTransform *imx_2d_video_transform); 43 | 44 | 45 | 46 | 47 | static void gst_imx_pxp_video_transform_class_init(GstImxPxPVideoTransformClass *klass) 48 | { 49 | GstElementClass *element_class; 50 | GstImx2dVideoTransformClass *imx_2d_video_transform_class; 51 | 52 | element_class = GST_ELEMENT_CLASS(klass); 53 | imx_2d_video_transform_class = GST_IMX_2D_VIDEO_TRANSFORM_CLASS(klass); 54 | 55 | imx_2d_video_transform_class->start = NULL; 56 | imx_2d_video_transform_class->stop = NULL; 57 | imx_2d_video_transform_class->create_blitter = GST_DEBUG_FUNCPTR(gst_imx_pxp_video_transform_create_blitter); 58 | 59 | gst_imx_2d_video_transform_common_class_init( 60 | imx_2d_video_transform_class, 61 | imx_2d_backend_pxp_get_hardware_capabilities() 62 | ); 63 | 64 | gst_element_class_set_static_metadata( 65 | element_class, 66 | "i.MX PxP video transform", 67 | "Filter/Converter/Video/Scaler/Transform/Effect/Hardware", 68 | "Video transformation using the i.MX Pixel Pipeline (PxP)", 69 | "Carlos Rafael Giani " 70 | ); 71 | } 72 | 73 | 74 | void gst_imx_pxp_video_transform_init(G_GNUC_UNUSED GstImxPxPVideoTransform *self) 75 | { 76 | } 77 | 78 | 79 | static Imx2dBlitter* gst_imx_pxp_video_transform_create_blitter(G_GNUC_UNUSED GstImx2dVideoTransform *imx_2d_video_transform) 80 | { 81 | return imx_2d_backend_pxp_blitter_create(); 82 | } 83 | -------------------------------------------------------------------------------- /ext/imx2d/gstimxpxpvideotransform.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_PXP_VIDEO_TRANSFORM_H 20 | #define GST_IMX_PXP_VIDEO_TRANSFORM_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | typedef struct _GstImxPxPVideoTransform GstImxPxPVideoTransform; 29 | typedef struct _GstImxPxPVideoTransformClass GstImxPxPVideoTransformClass; 30 | 31 | 32 | #define GST_TYPE_IMX_PXP_VIDEO_TRANSFORM (gst_imx_pxp_video_transform_get_type()) 33 | #define GST_IMX_PXP_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_PXP_VIDEO_TRANSFORM,GstImxPxPVideoTransform)) 34 | #define GST_IMX_PXP_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_PXP_VIDEO_TRANSFORM,GstImxPxPVideoTransformClass)) 35 | #define GST_IS_IMX_PXP_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_PXP_VIDEO_TRANSFORM)) 36 | #define GST_IS_IMX_PXP_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_PXP_VIDEO_TRANSFORM)) 37 | 38 | 39 | GType gst_imx_pxp_video_transform_get_type(void); 40 | 41 | 42 | G_END_DECLS 43 | 44 | 45 | #endif /* GST_IMX_2D_PXP_VIDEO_TRANSFORM_H */ 46 | -------------------------------------------------------------------------------- /ext/imx2d/meson.build: -------------------------------------------------------------------------------- 1 | if not gstreamer_video_dep.found() 2 | subdir_done() 3 | endif 4 | 5 | imx2d_compositor_option = get_option('imx2d-compositor') 6 | imx2d_compositor_enabled = false 7 | if imx2d_compositor_option.disabled() 8 | message('imx2d compositor elements disabled explicitely by command line option') 9 | else 10 | is_gst_1_16 = gstreamer_video_dep.version().version_compare('>=1.16.0') 11 | if is_gst_1_16 12 | message('imx2d compositor elements enabled') 13 | imx2d_compositor_enabled = true 14 | else 15 | if imx2d_compositor_option.enabled() 16 | error('imx2d compositor elements enabled, but GStreamer version is too old (must be at least 1.16.0 for GstVideoAggregator in gst-plugins-base)') 17 | else 18 | message('imx2d compositor elements enabled, but GStreamer version is too old (must be at least 1.16.0 for GstVideoAggregator in gst-plugins-base); disabling compositor elements') 19 | imx2d_compositor_enabled = false 20 | endif 21 | endif 22 | endif 23 | 24 | imx2d_videosink_enabled = get_option('imx2d-videosink') 25 | if imx2d_videosink_enabled 26 | message('imx2d videosink elements enabled') 27 | else 28 | message('imx2d videosink elements disabled') 29 | endif 30 | 31 | source = [ 32 | 'gstimx2dmisc.c', 33 | 'gstimx2dvideotransform.c', 34 | 'gstimx2dvideooverlayhandler.c', 35 | 'plugin.c' 36 | ] 37 | 38 | if imx2d_compositor_enabled 39 | source += ['gstimx2dcompositor.c'] 40 | conf_data.set('WITH_GST_IMX2D_COMPOSITOR', 1) 41 | endif 42 | 43 | if imx2d_videosink_enabled 44 | source += ['gstimx2dvideosink.c'] 45 | conf_data.set('WITH_GST_IMX2D_VIDEOSINK', 1) 46 | endif 47 | 48 | 49 | backend_source = [] 50 | backend_deps = [] 51 | 52 | if imx2d_backend_g2d_dep.found() 53 | backend_source += [ 54 | 'gstimxg2dvideotransform.c' 55 | ] 56 | if imx2d_compositor_enabled 57 | source += ['gstimxg2dcompositor.c'] 58 | endif 59 | if imx2d_videosink_enabled 60 | source += ['gstimxg2dvideosink.c'] 61 | endif 62 | backend_deps += [imx2d_backend_g2d_dep] 63 | endif 64 | 65 | if imx2d_backend_ipu_dep.found() 66 | backend_source += [ 67 | 'gstimxipuvideotransform.c' 68 | ] 69 | if imx2d_videosink_enabled 70 | source += ['gstimxipuvideosink.c'] 71 | endif 72 | backend_deps += [imx2d_backend_ipu_dep] 73 | endif 74 | 75 | if imx2d_backend_pxp_dep.found() 76 | backend_source += [ 77 | 'gstimxpxpvideotransform.c' 78 | ] 79 | if imx2d_videosink_enabled 80 | source += ['gstimxpxpvideosink.c'] 81 | endif 82 | backend_deps += [imx2d_backend_pxp_dep] 83 | endif 84 | 85 | if backend_source.length() > 0 86 | library( 87 | 'gstimx2d', 88 | source + backend_source, 89 | install : true, 90 | install_dir: plugins_install_dir, 91 | include_directories: [configinc, libsinc], 92 | dependencies : [gstimxcommon_dep, gstimxvideo_dep, gstreamer_video_dep, imx2d_dep] + backend_deps 93 | ) 94 | endif 95 | -------------------------------------------------------------------------------- /ext/imx2d/plugin.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #ifdef WITH_GST_IMX2D_COMPOSITOR 23 | #include "gstimxg2dcompositor.h" 24 | #endif 25 | 26 | #ifdef WITH_GST_IMX2D_VIDEOSINK 27 | #include "gstimxg2dvideosink.h" 28 | #include "gstimxipuvideosink.h" 29 | #include "gstimxpxpvideosink.h" 30 | #endif 31 | 32 | #include "gstimxg2dvideotransform.h" 33 | #include "gstimxipuvideotransform.h" 34 | #include "gstimxpxpvideotransform.h" 35 | 36 | 37 | static gboolean plugin_init(GstPlugin *plugin) 38 | { 39 | gboolean ret = TRUE; 40 | 41 | #ifdef WITH_IMX2D_G2D_BACKEND 42 | #ifdef WITH_GST_IMX2D_COMPOSITOR 43 | ret = ret && gst_element_register(plugin, "imxg2dcompositor", GST_RANK_NONE, gst_imx_g2d_compositor_get_type()); 44 | #endif 45 | #ifdef WITH_GST_IMX2D_VIDEOSINK 46 | ret = ret && gst_element_register(plugin, "imxg2dvideosink", GST_RANK_NONE, gst_imx_g2d_video_sink_get_type()); 47 | #endif 48 | ret = ret && gst_element_register(plugin, "imxg2dvideotransform", GST_RANK_NONE, gst_imx_g2d_video_transform_get_type()); 49 | #endif 50 | 51 | #ifdef WITH_IMX2D_IPU_BACKEND 52 | #ifdef WITH_GST_IMX2D_VIDEOSINK 53 | ret = ret && gst_element_register(plugin, "imxipuvideosink", GST_RANK_NONE, gst_imx_ipu_video_sink_get_type()); 54 | #endif 55 | ret = ret && gst_element_register(plugin, "imxipuvideotransform", GST_RANK_NONE, gst_imx_ipu_video_transform_get_type()); 56 | #endif 57 | 58 | #ifdef WITH_IMX2D_PXP_BACKEND 59 | #ifdef WITH_GST_IMX2D_VIDEOSINK 60 | ret = ret && gst_element_register(plugin, "imxpxpvideosink", GST_RANK_NONE, gst_imx_pxp_video_sink_get_type()); 61 | #endif 62 | ret = ret && gst_element_register(plugin, "imxpxpvideotransform", GST_RANK_NONE, gst_imx_pxp_video_transform_get_type()); 63 | #endif 64 | 65 | return ret; 66 | } 67 | 68 | 69 | 70 | GST_PLUGIN_DEFINE( 71 | GST_VERSION_MAJOR, 72 | GST_VERSION_MINOR, 73 | imx2d, 74 | "i.MX 2D graphics processing elements", 75 | plugin_init, 76 | VERSION, 77 | "LGPL", 78 | GST_PACKAGE_NAME, 79 | GST_PACKAGE_ORIGIN 80 | ) 81 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpucommon.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_COMMON_H 20 | #define GST_IMX_VPU_COMMON_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | /* These are common internal functions for the GStreamer i.MX VPU elements. */ 28 | 29 | 30 | G_BEGIN_DECLS 31 | 32 | 33 | 34 | #if GST_CHECK_VERSION(1, 16, 0) 35 | #define GST_IMX_VPU_SUPPORTS_SEMI_PLANAR_10BIT_FRAMES 36 | #endif 37 | 38 | 39 | /* Functionality for autogenerating GStreamer element entries in the 40 | * GStreamer registry out of the list of supported codecs. 41 | * 42 | * This is used for both en- and decoder elements, though in different ways. 43 | * 44 | * Decoders: 45 | * 46 | * There is one decoder element for each supported compression format. However, 47 | * there is no source file for each format. Instead, these elements are 48 | * autogenerated, using GstImxVpuDec as the base class. The information stored 49 | * in GstImxVpuCodecDetails is used for that purpose. There is one global 50 | * static table that contains one GstImxVpuCodecDetails entry for each 51 | * compression format. A GType is generated out of these entries, and using 52 | * that (and an autogenerated element name), a new element is registered. 53 | * This is done by gst_imx_vpu_dec_register_decoder_type(). 54 | * 55 | * Encoders: 56 | * 57 | * Unlike with decoders, there _is_ one source file for each format. 58 | * This is because encoders sometimes have additional, format specific 59 | * parameters that can then be adjusted through extra GObject properties. 60 | * Still, GstImxVpuCodecDetails is used by the GstImxVpuEnc base class for 61 | * setting up element metadata etc. 62 | */ 63 | 64 | typedef struct _GstImxVpuCodecDetails GstImxVpuCodecDetails; 65 | 66 | struct _GstImxVpuCodecDetails 67 | { 68 | /* Format specific element name suffix. This is used for generating 69 | * element names that reflect the type the elements can handle. For 70 | * example, decoder element names are "imxvpudec_". */ 71 | gchar const *element_name_suffix; 72 | /* GLib class name suffix. For example, for h.264, this would be 73 | * "H264". This is useful for constructing the GLib class name on the 74 | * fly. Example: GstImxVpuDecH264 */ 75 | gchar const *class_name_suffix; 76 | /* Format specific description. Useful for element class metadata. */ 77 | gchar const *desc_name; 78 | /* The rank the GStreamer element handling this format should have. */ 79 | guint rank; 80 | /* The compression format the element handles. */ 81 | ImxVpuApiCompressionFormat compression_format; 82 | /* Determines whether or not frame reodering is needed depending on 83 | * the format in the GstStructure. If this is NULL, frame reodering 84 | * is enabled by default. */ 85 | gboolean (*is_frame_reordering_required)(GstStructure *format); 86 | /* If TRUE, then out-of-band codec data is required for decoding. 87 | * Unused in encoders. */ 88 | gboolean requires_codec_data; 89 | }; 90 | 91 | 92 | /* Helper macro to access the libimxvpuapi compression format that is stored 93 | * inside a GObject class. */ 94 | #define GST_IMX_VPU_GET_ELEMENT_COMPRESSION_FORMAT(obj) \ 95 | ((ImxVpuApiCompressionFormat)g_type_get_qdata(G_OBJECT_CLASS_TYPE(GST_OBJECT_GET_CLASS(obj)), gst_imx_vpu_compression_format_quark())) 96 | 97 | /* GQuark for accessing the libimxvpuapi compression format in en/decoder classes. */ 98 | GQuark gst_imx_vpu_compression_format_quark(void); 99 | 100 | /* Get this format's GstImxVpuCodecDetails from the static internal global table. */ 101 | GstImxVpuCodecDetails const * gst_imx_vpu_get_codec_details(ImxVpuApiCompressionFormat compression_format); 102 | 103 | 104 | 105 | /* Miscellaneous functions. */ 106 | 107 | gboolean gst_imx_vpu_get_caps_for_format(ImxVpuApiCompressionFormat compression_format, ImxVpuApiCompressionFormatSupportDetails const *details, GstCaps **encoded_caps, GstCaps **raw_caps, gboolean for_encoder); 108 | 109 | guint gst_imx_vpu_get_default_quantization(ImxVpuApiCompressionFormatSupportDetails const *details); 110 | 111 | gboolean gst_imx_vpu_color_format_to_gstvidfmt(GstVideoFormat *gst_video_format, ImxVpuApiColorFormat imxvpuapi_format); 112 | gboolean gst_imx_vpu_color_format_from_gstvidfmt(ImxVpuApiColorFormat *imxvpuapi_format, GstVideoFormat gst_video_format); 113 | 114 | gboolean gst_imx_vpu_color_format_is_semi_planar(GstVideoFormat gst_video_format); 115 | gboolean gst_imx_vpu_color_format_has_10bit(GstVideoFormat gst_video_format); 116 | 117 | gchar const * gst_imx_vpu_get_string_from_structure_field(GstStructure *s, gchar const *field_name); 118 | 119 | void gst_imx_vpu_api_setup_logging(void); 120 | 121 | 122 | 123 | G_END_DECLS 124 | 125 | 126 | #endif /* GST_IMX_VPU_COMMON_H */ 127 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpudec.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_DEC_H 20 | #define GST_IMX_VPU_DEC_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | G_BEGIN_DECLS 27 | 28 | 29 | #define GST_TYPE_IMX_VPU_DEC (gst_imx_vpu_dec_get_type()) 30 | #define GST_IMX_VPU_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_DEC,GstImxVpuDec)) 31 | #define GST_IMX_VPU_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_DEC,GstImxVpuDecClass)) 32 | #define GST_IMX_VPU_DEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_DEC, GstImxVpuDecClass)) 33 | #define GST_IMX_VPU_DEC_CAST(obj) ((GstImxVpuDec *)(obj)) 34 | #define GST_IS_IMX_VPU_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_DEC)) 35 | #define GST_IS_IMX_VPU_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_DEC)) 36 | 37 | 38 | typedef struct _GstImxVpuDec GstImxVpuDec; 39 | typedef struct _GstImxVpuDecClass GstImxVpuDecClass; 40 | 41 | 42 | GTypeInfo gst_imx_vpu_dec_get_derived_type_info(void); 43 | 44 | GType gst_imx_vpu_dec_get_type(void); 45 | 46 | gboolean gst_imx_vpu_dec_register_decoder_type(GstPlugin *plugin, ImxVpuApiCompressionFormat compression_format); 47 | 48 | 49 | G_END_DECLS 50 | 51 | 52 | #endif /* GST_IMX_VPU_DEC_H */ 53 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpudecbufferpool.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_DEC_BUFFER_POOL_H 20 | #define GST_IMX_VPU_DEC_BUFFER_POOL_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "gstimxvpudeccontext.h" 27 | 28 | 29 | G_BEGIN_DECLS 30 | 31 | 32 | /* The GstImxVpuDecBufferPool is a special buffer pool for internal use with 33 | * i.MX decoder elements. 34 | * 35 | * A special buffer pool is necessary because of a peculiarity of at least 36 | * some of the i.MX VPU decoders: They use their own internal buffer pool 37 | * logic. That is, one has to add/register framebuffers to the decoders, and 38 | * the decoder itself picks one of the added framebuffers to decode frames 39 | * into. However, a GstBufferPool does the same thing. Having two buffer pool 40 | * logics does not work out of the box - they'll get in the way of each other. 41 | * 42 | * The solution is this special GstBufferPool subclass. It knows two types of 43 | * buffers: The regular ones, which are handled by the functionaity of the 44 | * GstBufferPool class, and "reserved" ones, which are handled by the subclass. 45 | * "Reserved" means that while they _are_ allocated, they are _not_ actually 46 | * placed into the internal GstBuffer collection that is inside GstBufferPool. 47 | * Instead, these "reserved" GstBuffers are kept in a list in the _subclass_. 48 | * 49 | * Reserved buffers differ from regular ones in two ways: 50 | * 51 | * First, they are "selected". Once a reserved buffer is selected, the next 52 | * gst_buffer_pool_acquire_buffer() call will return this reserved buffer. This 53 | * is accomplished by caling. gst_imx_vpu_dec_buffer_pool_select_reserved_buffer(). 54 | * In other words, the reserved buffer to acquire is not chosen automatically. 55 | * 56 | * Second, when an acquired reserved buffer's refcount reaches zero, it is 57 | * released back to the pool as usual. However, when this happens, it is also 58 | * returned to the VPU by a gst_imx_vpu_dec_context_return_framebuffer_to_decoder() 59 | * call. (The GstImxVpuDecBufferPool can detect whether or not a GstBuffer is 60 | * a reserved one by checking for the ACQUIRE_FLAG_SELECTED flag.) 61 | * 62 | * This makes an integration possible. When the VPU requests framebuffers to be 63 | * added to its pool, one GstBuffer with ImxDmaBuffer backing is allocated for 64 | * each requested framebuffer. gst_imx_vpu_dec_buffer_pool_reserve_buffer() is 65 | * used for this purpose. These GstBuffers are all reserved. If the VPU decodes 66 | * frames into buffers from its own pool (that is, it does not decode into a 67 | * separate output buffer), then gst_imx_vpu_dec_buffer_pool_select_reserved_buffer() 68 | * is called to select this buffer, making sure that the next acquire call picks 69 | * the buffer that holds the newly decoded frame. And, once that buffer is no 70 | * longer needed, it is properly returned to the VPU's pool by the behavior in the 71 | * release() function. 72 | */ 73 | 74 | 75 | #define GST_TYPE_IMX_VPU_DEC_BUFFER_POOL (gst_imx_vpu_dec_buffer_pool_get_type()) 76 | #define GST_IMX_VPU_DEC_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_DEC_BUFFER_POOL,GstImxVpuDecBufferPool)) 77 | #define GST_IMX_VPU_DEC_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_DEC_BUFFER_POOL,GstImxVpuDecBufferPoolClass)) 78 | #define GST_IMX_VPU_DEC_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_DEC_BUFFER_POOL, GstImxVpuDecBufferPoolClass)) 79 | #define GST_IMX_VPU_DEC_BUFFER_POOL_CAST(obj) ((GstImxVpuDecBufferPool *)(obj)) 80 | #define GST_IS_IMX_VPU_DEC_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_DEC_BUFFER_POOL)) 81 | #define GST_IS_IMX_VPU_DEC_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_DEC_BUFFER_POOL)) 82 | 83 | 84 | #define GST_BUFFER_POOL_OPTION_IMX_VPU_DEC_BUFFER_POOL "GstBufferPoolOptionImxVpuDecBufferPool" 85 | 86 | 87 | typedef struct _GstImxVpuDecBufferPool GstImxVpuDecBufferPool; 88 | typedef struct _GstImxVpuDecBufferPoolClass GstImxVpuDecBufferPoolClass; 89 | 90 | 91 | typedef enum 92 | { 93 | GST_IMX_VPU_DEC_BUFFER_POOL_ACQUIRE_FLAG_SELECTED = GST_BUFFER_POOL_ACQUIRE_FLAG_LAST 94 | } 95 | GstImxVpuDecBufferPoolAcquireFlags; 96 | 97 | 98 | GType gst_imx_vpu_dec_buffer_pool_get_type(void); 99 | 100 | GstImxVpuDecBufferPool* gst_imx_vpu_dec_buffer_pool_new(ImxVpuApiDecStreamInfo *stream_info, GstImxVpuDecContext *decoder_context); 101 | 102 | GstVideoInfo const * gst_imx_vpu_dec_buffer_pool_get_video_info(GstImxVpuDecBufferPool *imx_vpu_dec_buffer_pool); 103 | 104 | GstBuffer* gst_imx_vpu_dec_buffer_pool_reserve_buffer(GstImxVpuDecBufferPool *imx_vpu_dec_buffer_pool); 105 | void gst_imx_vpu_dec_buffer_pool_select_reserved_buffer(GstImxVpuDecBufferPool *imx_vpu_dec_buffer_pool, GstBuffer *buffer); 106 | 107 | 108 | G_END_DECLS 109 | 110 | 111 | #endif /* GST_IMX_VPU_DEC_BUFFER_POOL_H */ 112 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpudeccontext.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include "gstimxvpudeccontext.h" 21 | 22 | 23 | GST_DEBUG_CATEGORY_STATIC(imx_vpu_dec_context_debug); 24 | #define GST_CAT_DEFAULT imx_vpu_dec_context_debug 25 | 26 | 27 | G_DEFINE_TYPE(GstImxVpuDecContext, gst_imx_vpu_dec_context, GST_TYPE_OBJECT) 28 | 29 | 30 | static void gst_imx_vpu_dec_context_finalize(GObject *object); 31 | 32 | 33 | void gst_imx_vpu_dec_context_class_init(GstImxVpuDecContextClass *klass) 34 | { 35 | GObjectClass *object_class; 36 | 37 | object_class = G_OBJECT_CLASS(klass); 38 | object_class->finalize = GST_DEBUG_FUNCPTR(gst_imx_vpu_dec_context_finalize); 39 | 40 | GST_DEBUG_CATEGORY_INIT(imx_vpu_dec_context_debug, "imxvpudecodercontext", 0, "NXP i.MX VPU decoder context"); 41 | } 42 | 43 | 44 | void gst_imx_vpu_dec_context_init(GstImxVpuDecContext *imx_vpu_dec_context) 45 | { 46 | imx_vpu_dec_context->decoder = NULL; 47 | 48 | g_mutex_init(&(imx_vpu_dec_context->mutex)); 49 | } 50 | 51 | 52 | static void gst_imx_vpu_dec_context_finalize(GObject *object) 53 | { 54 | GstImxVpuDecContext *imx_vpu_dec_context = GST_IMX_VPU_DEC_CONTEXT(object); 55 | 56 | gst_imx_vpu_dec_context_close_decoder(imx_vpu_dec_context); 57 | 58 | g_mutex_clear(&(imx_vpu_dec_context->mutex)); 59 | 60 | G_OBJECT_CLASS(gst_imx_vpu_dec_context_parent_class)->finalize(object); 61 | } 62 | 63 | 64 | GstImxVpuDecContext* gst_imx_vpu_dec_context_new(ImxVpuApiDecoder *decoder) 65 | { 66 | GstImxVpuDecContext *imx_vpu_dec_context = (GstImxVpuDecContext *)g_object_new(gst_imx_vpu_dec_context_get_type(), NULL); 67 | imx_vpu_dec_context->decoder = decoder; 68 | 69 | GST_DEBUG_OBJECT(imx_vpu_dec_context, "created new context with decoder instance %p", (gpointer)(imx_vpu_dec_context->decoder)); 70 | 71 | return imx_vpu_dec_context; 72 | } 73 | 74 | 75 | void gst_imx_vpu_dec_context_close_decoder(GstImxVpuDecContext *imx_vpu_dec_context) 76 | { 77 | GST_IMX_VPU_DEC_CONTEXT_LOCK(imx_vpu_dec_context); 78 | 79 | if (G_LIKELY(imx_vpu_dec_context->decoder != NULL)) 80 | { 81 | imx_vpu_api_dec_close(imx_vpu_dec_context->decoder); 82 | GST_DEBUG_OBJECT(imx_vpu_dec_context, "closed decoder instance %p", (gpointer)(imx_vpu_dec_context->decoder)); 83 | imx_vpu_dec_context->decoder = NULL; 84 | } 85 | 86 | GST_IMX_VPU_DEC_CONTEXT_UNLOCK(imx_vpu_dec_context); 87 | } 88 | 89 | 90 | void gst_imx_vpu_dec_context_return_framebuffer_to_decoder(GstImxVpuDecContext *imx_vpu_dec_context, ImxDmaBuffer *framebuffer) 91 | { 92 | GST_IMX_VPU_DEC_CONTEXT_LOCK(imx_vpu_dec_context); 93 | 94 | /* If this has been set to NULL, then the decoder is gone. 95 | * Just do nothing in that case. */ 96 | if (imx_vpu_dec_context->decoder != NULL) 97 | { 98 | imx_vpu_api_dec_return_framebuffer_to_decoder(imx_vpu_dec_context->decoder, framebuffer); 99 | GST_LOG_OBJECT(imx_vpu_dec_context, "returned framebuffer DMA buffer %p to decoder instance %p", (gpointer)framebuffer, (gpointer)(imx_vpu_dec_context->decoder)); 100 | } 101 | else 102 | GST_LOG_OBJECT(imx_vpu_dec_context, "not returning framebuffer DMA buffer %p since decoder instance is already gone", (gpointer)framebuffer); 103 | 104 | GST_IMX_VPU_DEC_CONTEXT_UNLOCK(imx_vpu_dec_context); 105 | } 106 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpudeccontext.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_DEC_CONTEXT_H 20 | #define GST_IMX_VPU_DEC_CONTEXT_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | G_BEGIN_DECLS 27 | 28 | 29 | /* The GstImxVpuDecContext is an internal object used by VPU decoder 30 | * elements. Its primary function is to maintain the lifespan of an 31 | * ImxVpuApiDecoder instances until _all_ users of said instance are 32 | * done with it. These users include GstImxVpuDec instances (where 33 | * GstImxVpuDecContext instances are created), but also GstBuffers 34 | * created by a GstImxVpuDecBufferPool. As soon as the refcount of 35 | * one such GstBuffer reaches zero, the release vfunc of that pool 36 | * is called to release the GstBuffer back to that pool. Inside 37 | * that release function, the GstBuffer may be returned to the pool 38 | * just like in a regular pool, or it may be returned to the decoder 39 | * by calling gst_imx_vpu_dec_context_return_framebuffer_to_decoder(). 40 | * 41 | * The latter is done if said decoder places decoded frames into 42 | * framebuffer DMA buffers that are owned by the *decoder's* internal 43 | * pool. Some hardware decoders have their own buffer pool, and 44 | * cannot be used unless said pool is set up. This of course makes 45 | * things more complicated, because that internal pool logic and 46 | * GStreamer's GstBufferPool logic collide with each other. To bring 47 | * these two together, the GstImxVpuDecBufferPool was written, and 48 | * as part of that, that pool' release function calls the function 49 | * gst_imx_vpu_dec_context_return_framebuffer_to_decoder(). 50 | * 51 | * Now, libimxvpuapi's ImxVpuApiDecoder has no reference counting 52 | * mechanism, so if for example imx_vpu_api_close() were called 53 | * while other parts were still using that instance, there would 54 | * be a crash. However, GstImxVpuDecContext is based on GstObject, 55 | * so it *does* have a reference counting mechanism. So, the way 56 | * to avoid such problems is to make GstImxVpuDecBufferPool and 57 | * GstImxVpuDec hold references to an GstImxVpuDecContext instance. 58 | * That way, the context is not discarded until _all_ of its users 59 | * are done with it. 60 | * 61 | * There are additional benefits. The decoder instance can be closed 62 | * through the context, instead of directly. That way, if multiple 63 | * entities try to close the decoder at the same time, the context 64 | * can act as a mediator, and prevent duplicate close attempts 65 | * (which would lead to a segfault). Also, once the decoder instance 66 | * was closed, gst_imx_vpu_dec_context_return_framebuffer_to_decoder() 67 | * calls will respect this and effectively do nothing (since there 68 | * is no decoder to return the framebuffer to anymore). 69 | * 70 | * Also see the GstImxVpuDecBufferPool documentation for additional 71 | * explanations, since that object is used with the context together. 72 | */ 73 | 74 | 75 | #define GST_TYPE_IMX_VPU_DEC_CONTEXT (gst_imx_vpu_dec_context_get_type()) 76 | #define GST_IMX_VPU_DEC_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_DEC_CONTEXT, GstImxVpuDecContext)) 77 | #define GST_IMX_VPU_DEC_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_DEC_CONTEXT, GstImxVpuDecContextClass)) 78 | #define GST_IMX_VPU_DEC_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_DEC_CONTEXT, GstImxVpuDecContextClass)) 79 | #define GST_IS_IMX_VPU_DEC_CONTEXT(obj) (G_TYPE_CHECK_CONTEXT_TYPE((obj), GST_TYPE_IMX_VPU_DEC_CONTEXT)) 80 | #define GST_IS_IMX_VPU_DEC_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_DEC_CONTEXT)) 81 | 82 | 83 | /* Helper macros for using the context' mutex. */ 84 | #define GST_IMX_VPU_DEC_CONTEXT_LOCK(obj) (g_mutex_lock(&(((GstImxVpuDecContext*)(obj))->mutex))) 85 | #define GST_IMX_VPU_DEC_CONTEXT_UNLOCK(obj) (g_mutex_unlock(&(((GstImxVpuDecContext*)(obj))->mutex))) 86 | 87 | 88 | typedef struct _GstImxVpuDecContext GstImxVpuDecContext; 89 | typedef struct _GstImxVpuDecContextClass GstImxVpuDecContextClass; 90 | 91 | 92 | struct _GstImxVpuDecContext 93 | { 94 | GstObject parent; 95 | 96 | /*< private >*/ 97 | 98 | ImxVpuApiDecoder *decoder; 99 | 100 | /* This mutex is used for thread-synchronized access to the decoder instance. */ 101 | GMutex mutex; 102 | }; 103 | 104 | 105 | struct _GstImxVpuDecContextClass 106 | { 107 | GstObjectClass parent_class; 108 | }; 109 | 110 | 111 | GstImxVpuDecContext* gst_imx_vpu_dec_context_new(ImxVpuApiDecoder *decoder); 112 | void gst_imx_vpu_dec_context_close_decoder(GstImxVpuDecContext *imx_vpu_dec_context); 113 | void gst_imx_vpu_dec_context_return_framebuffer_to_decoder(GstImxVpuDecContext *imx_vpu_dec_context, ImxDmaBuffer *framebuffer); 114 | 115 | 116 | G_END_DECLS 117 | 118 | 119 | #endif /* GST_IMX_VPU_DEC_CONTEXT_H */ 120 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuenc.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_ENC_H 20 | #define GST_IMX_VPU_ENC_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "gstimxvpucommon.h" 27 | #include "gst/imx/common/gstimxdmabufferuploader.h" 28 | 29 | 30 | G_BEGIN_DECLS 31 | 32 | 33 | #define GST_TYPE_IMX_VPU_ENC (gst_imx_vpu_enc_get_type()) 34 | #define GST_IMX_VPU_ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_ENC,GstImxVpuEnc)) 35 | #define GST_IMX_VPU_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_ENC,GstImxVpuEncClass)) 36 | #define GST_IMX_VPU_ENC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_ENC, GstImxVpuEncClass)) 37 | #define GST_IMX_VPU_ENC_CAST(obj) ((GstImxVpuEnc *)(obj)) 38 | #define GST_IS_IMX_VPU_ENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_ENC)) 39 | #define GST_IS_IMX_VPU_ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_ENC)) 40 | 41 | #define GST_IMX_VPU_ENC_BASE_PROP_VALUE 100 42 | 43 | 44 | typedef struct _GstImxVpuEnc GstImxVpuEnc; 45 | typedef struct _GstImxVpuEncClass GstImxVpuEncClass; 46 | 47 | 48 | struct _GstImxVpuEnc 49 | { 50 | GstVideoEncoder parent; 51 | 52 | /* The stream buffer that is needed by the decoder for all 53 | * of its decoding operations. Created in gst_imx_vpu_enc_start(). */ 54 | GstMemory *stream_buffer; 55 | /* The actual libimxvpuapi encoder. Created in 56 | * gst_imx_vpu_enc_set_format(). */ 57 | ImxVpuApiEncoder *encoder; 58 | /* Pointer to the constant, static global encoder 59 | * information from libimxvpuapi. */ 60 | ImxVpuApiEncGlobalInfo const *enc_global_info; 61 | /* Copy of the stream info received right after opening the 62 | * libimxvpuapi encoder instance. */ 63 | ImxVpuApiEncStreamInfo current_stream_info; 64 | /* The parameters that are passed on to the imx_vpu_api_enc_open() 65 | * call that opens a libimxvpuapi encoder instance. */ 66 | ImxVpuApiEncOpenParams open_params; 67 | /* libimxdmabuffer-based DMA buffer allocator that is used for 68 | * allocating the stream buffer and the VPU framebuffer pool buffers. 69 | * Depending on the configuration, this may or may not be the 70 | * DMA-BUF backed GstImxIonAllocator. */ 71 | GstAllocator *default_dma_buf_allocator; 72 | 73 | /* Current DMA buffer pool. Created in 74 | * gst_imx_vpu_enc_set_format() by calling 75 | * gst_imx_vpu_enc_create_dma_buffer_pool(). */ 76 | GstBufferPool *dma_buffer_pool; 77 | 78 | /* Used for uploading incoming buffers into ImxDmaBuffer-backed 79 | * GstMemory that we can use with the VPU encoder. */ 80 | GstImxDmaBufferUploader *uploader; 81 | /* The uploader produces new gstbuffers with the uploaded variants 82 | * of input buffers. These are stored here, and get removed once the 83 | * corresponding input frames got fully processed by the encoder. 84 | * This table helps keeping track of these temp buffers at all times. */ 85 | GHashTable *uploaded_buffers_table; 86 | 87 | /* The GstBufferList that was created to act as the backing store 88 | * for the VPU's framebuffer pool. */ 89 | GstBufferList *fb_pool_buffers; 90 | 91 | /* Sometimes, even after one of the GstVideoEncoder vfunctions 92 | * reports an error, processing continues. This flag is intended 93 | * to handle such cases. If set to TRUE, several functions such as 94 | * gst_imx_vpu_enc_handle_frame() will exit early. The flag is 95 | * cleared once the encoder is restarted. */ 96 | gboolean fatal_error_cannot_encode; 97 | 98 | /* Copy of the GstVideoInfo that describes the raw input frames. */ 99 | GstVideoInfo in_video_info; 100 | 101 | /* The frame type that identifies a keyframe. If the codec supports 102 | * IDR frames, then this is set to IMX_VPU_API_FRAME_TYPE_IDR, 103 | * otherwise it is set to IMX_VPU_API_FRAME_TYPE_I. This field is 104 | * used for checking if a GstVideoFrame sync point needs to be set. */ 105 | ImxVpuApiFrameType keyframe_type; 106 | 107 | /* GObject property values. */ 108 | guint gop_size; 109 | guint closed_gop_interval; 110 | guint bitrate; 111 | guint quantization; 112 | guint intra_refresh; 113 | guint fixed_intra_quantization; 114 | gboolean allow_frameskipping; 115 | gboolean use_intra_refresh; 116 | }; 117 | 118 | 119 | struct _GstImxVpuEncClass 120 | { 121 | GstVideoEncoderClass parent_class; 122 | 123 | /* Virtual functions that are implemented by subclasses to allow 124 | * them to installtheir own GObject properties. This is necessary 125 | * because gst_imx_vpu_enc_common_class_init() already sets the 126 | * subclasses' set_property and get_property vfunctions. */ 127 | void (*set_encoder_property)(GObject *object, guint prop_id, GValue const *value, GParamSpec *pspec); 128 | void (*get_encoder_property)(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); 129 | 130 | gboolean (*set_open_params)(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncOpenParams *open_params); 131 | GstCaps* (*get_output_caps)(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncStreamInfo const *stream_info); 132 | 133 | gboolean use_idr_frame_type_for_keyframes; 134 | }; 135 | 136 | 137 | void gst_imx_vpu_enc_common_class_init(GstImxVpuEncClass *klass, ImxVpuApiCompressionFormat compression_format, gboolean with_rate_control, gboolean with_constant_quantization, gboolean with_gop_support, gboolean with_open_closed_gop_support, gboolean with_intra_refresh); 138 | void gst_imx_vpu_enc_common_init(GstImxVpuEnc *imx_vpu_enc); 139 | 140 | GType gst_imx_vpu_enc_get_type(void); 141 | 142 | 143 | G_END_DECLS 144 | 145 | 146 | #endif /* GST_IMX_VPU_ENC_H */ 147 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuench263.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_ENC_H263_H 20 | #define GST_IMX_VPU_ENC_H263_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_VPU_ENC_H263 (gst_imx_vpu_enc_h263_get_type()) 29 | #define GST_IMX_VPU_ENC_H263(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_ENC_H263,GstImxVpuEncH263)) 30 | #define GST_IMX_VPU_ENC_H263_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_ENC_H263,GstImxVpuEncH263Class)) 31 | #define GST_IMX_VPU_ENC_H263_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_ENC_H263, GstImxVpuEncH263Class)) 32 | #define GST_IMX_VPU_ENC_H263_CAST(obj) ((GstImxVpuEncH263 *)(obj)) 33 | #define GST_IS_IMX_VPU_ENC_H263(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_ENC_H263)) 34 | #define GST_IS_IMX_VPU_ENC_H263_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_ENC_H263)) 35 | 36 | 37 | typedef struct _GstImxVpuEncH263 GstImxVpuEncH263; 38 | typedef struct _GstImxVpuEncH263Class GstImxVpuEncH263Class; 39 | 40 | 41 | GType gst_imx_vpu_enc_h263_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_VPU_ENC_H263_H */ 48 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuench264.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_ENC_H264_H 20 | #define GST_IMX_VPU_ENC_H264_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_VPU_ENC_H264 (gst_imx_vpu_enc_h264_get_type()) 29 | #define GST_IMX_VPU_ENC_H264(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_ENC_H264,GstImxVpuEncH264)) 30 | #define GST_IMX_VPU_ENC_H264_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_ENC_H264,GstImxVpuEncH264Class)) 31 | #define GST_IMX_VPU_ENC_H264_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_ENC_H264, GstImxVpuEncH264Class)) 32 | #define GST_IMX_VPU_ENC_H264_CAST(obj) ((GstImxVpuEncH264 *)(obj)) 33 | #define GST_IS_IMX_VPU_ENC_H264(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_ENC_H264)) 34 | #define GST_IS_IMX_VPU_ENC_H264_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_ENC_H264)) 35 | 36 | 37 | typedef struct _GstImxVpuEncH264 GstImxVpuEncH264; 38 | typedef struct _GstImxVpuEncH264Class GstImxVpuEncH264Class; 39 | 40 | 41 | GType gst_imx_vpu_enc_h264_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_VPU_ENC_H264_H */ 48 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuencjpeg.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include "gstimxvpucommon.h" 21 | #include "gstimxvpuenc.h" 22 | #include "gstimxvpuencjpeg.h" 23 | 24 | 25 | GST_DEBUG_CATEGORY_STATIC(imx_vpu_enc_jpeg_debug); 26 | #define GST_CAT_DEFAULT imx_vpu_enc_jpeg_debug 27 | 28 | 29 | struct _GstImxVpuEncJPEG 30 | { 31 | GstImxVpuEnc parent; 32 | }; 33 | 34 | 35 | struct _GstImxVpuEncJPEGClass 36 | { 37 | GstImxVpuEncClass parent; 38 | }; 39 | 40 | 41 | G_DEFINE_TYPE(GstImxVpuEncJPEG, gst_imx_vpu_enc_jpeg, GST_TYPE_IMX_VPU_ENC) 42 | 43 | 44 | GstCaps* gst_imx_vpu_enc_jpeg_get_output_caps(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncStreamInfo const *stream_info); 45 | 46 | 47 | static void gst_imx_vpu_enc_jpeg_class_init(GstImxVpuEncJPEGClass *klass) 48 | { 49 | GstImxVpuEncClass *imx_vpu_enc_class; 50 | 51 | GST_DEBUG_CATEGORY_INIT(imx_vpu_enc_jpeg_debug, "imxvpuenc_jpeg", 0, "NXP i.MX VPU JPEG video encoder"); 52 | 53 | imx_vpu_enc_class = GST_IMX_VPU_ENC_CLASS(klass); 54 | imx_vpu_enc_class->get_output_caps = GST_DEBUG_FUNCPTR(gst_imx_vpu_enc_jpeg_get_output_caps); 55 | 56 | gst_imx_vpu_enc_common_class_init(imx_vpu_enc_class, IMX_VPU_API_COMPRESSION_FORMAT_JPEG, FALSE, TRUE, FALSE, FALSE, FALSE); 57 | } 58 | 59 | 60 | static void gst_imx_vpu_enc_jpeg_init(GstImxVpuEncJPEG *imx_vpu_enc_jpeg) 61 | { 62 | gst_imx_vpu_enc_common_init(GST_IMX_VPU_ENC_CAST(imx_vpu_enc_jpeg)); 63 | } 64 | 65 | 66 | GstCaps* gst_imx_vpu_enc_jpeg_get_output_caps(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncStreamInfo const *stream_info) 67 | { 68 | GstVideoInfo *info = &(imx_vpu_enc->in_video_info); 69 | 70 | return gst_caps_new_simple( 71 | "image/jpeg", 72 | "format", G_TYPE_STRING, gst_video_format_to_string(GST_VIDEO_INFO_FORMAT(info)), 73 | "width", G_TYPE_INT, GST_VIDEO_INFO_WIDTH(info), 74 | "height", G_TYPE_INT, GST_VIDEO_INFO_HEIGHT(info), 75 | "framerate", GST_TYPE_FRACTION, (gint)(stream_info->frame_rate_numerator), (gint)(stream_info->frame_rate_denominator), 76 | "parsed", G_TYPE_BOOLEAN, (gboolean)TRUE, 77 | NULL 78 | ); 79 | } 80 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuencjpeg.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_ENC_JPEG_H 20 | #define GST_IMX_VPU_ENC_JPEG_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_VPU_ENC_JPEG (gst_imx_vpu_enc_jpeg_get_type()) 29 | #define GST_IMX_VPU_ENC_JPEG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_ENC_JPEG,GstImxVpuEncJPEG)) 30 | #define GST_IMX_VPU_ENC_JPEG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_ENC_JPEG,GstImxVpuEncJPEGClass)) 31 | #define GST_IMX_VPU_ENC_JPEG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_ENC_JPEG, GstImxVpuEncJPEGClass)) 32 | #define GST_IMX_VPU_ENC_JPEG_CAST(obj) ((GstImxVpuEncJPEG *)(obj)) 33 | #define GST_IS_IMX_VPU_ENC_JPEG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_ENC_JPEG)) 34 | #define GST_IS_IMX_VPU_ENC_JPEG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_ENC_JPEG)) 35 | 36 | 37 | typedef struct _GstImxVpuEncJPEG GstImxVpuEncJPEG; 38 | typedef struct _GstImxVpuEncJPEGClass GstImxVpuEncJPEGClass; 39 | 40 | 41 | GType gst_imx_vpu_enc_jpeg_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_VPU_ENC_JPEG_H */ 48 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuencmpeg4.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_ENC_MPEG4_H 20 | #define GST_IMX_VPU_ENC_MPEG4_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_VPU_ENC_MPEG4 (gst_imx_vpu_enc_mpeg4_get_type()) 29 | #define GST_IMX_VPU_ENC_MPEG4(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_ENC_MPEG4,GstImxVpuEncMPEG4)) 30 | #define GST_IMX_VPU_ENC_MPEG4_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_ENC_MPEG4,GstImxVpuEncMPEG4Class)) 31 | #define GST_IMX_VPU_ENC_MPEG4_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_ENC_MPEG4, GstImxVpuEncMPEG4Class)) 32 | #define GST_IMX_VPU_ENC_MPEG4_CAST(obj) ((GstImxVpuEncMPEG4 *)(obj)) 33 | #define GST_IS_IMX_VPU_ENC_MPEG4(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_ENC_MPEG4)) 34 | #define GST_IS_IMX_VPU_ENC_MPEG4_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_ENC_MPEG4)) 35 | 36 | 37 | typedef struct _GstImxVpuEncMPEG4 GstImxVpuEncMPEG4; 38 | typedef struct _GstImxVpuEncMPEG4Class GstImxVpuEncMPEG4Class; 39 | 40 | 41 | GType gst_imx_vpu_enc_mpeg4_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_VPU_ENC_MPEG4_H */ 48 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuencvp8.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include "gstimxvpucommon.h" 21 | #include "gstimxvpuenc.h" 22 | #include "gstimxvpuencvp8.h" 23 | 24 | 25 | GST_DEBUG_CATEGORY_STATIC(imx_vpu_enc_vp8_debug); 26 | #define GST_CAT_DEFAULT imx_vpu_enc_vp8_debug 27 | 28 | 29 | struct _GstImxVpuEncVP8 30 | { 31 | GstImxVpuEnc parent; 32 | }; 33 | 34 | 35 | struct _GstImxVpuEncVP8Class 36 | { 37 | GstImxVpuEncClass parent; 38 | }; 39 | 40 | 41 | G_DEFINE_TYPE(GstImxVpuEncVP8, gst_imx_vpu_enc_vp8, GST_TYPE_IMX_VPU_ENC) 42 | 43 | 44 | gboolean gst_imx_vpu_enc_vp8_set_open_params(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncOpenParams *open_params); 45 | GstCaps* gst_imx_vpu_enc_vp8_get_output_caps(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncStreamInfo const *stream_info); 46 | 47 | 48 | static void gst_imx_vpu_enc_vp8_class_init(GstImxVpuEncVP8Class *klass) 49 | { 50 | GstImxVpuEncClass *imx_vpu_enc_class; 51 | 52 | GST_DEBUG_CATEGORY_INIT(imx_vpu_enc_vp8_debug, "imxvpuenc_vp8", 0, "NXP i.MX VPU VP8 video encoder"); 53 | 54 | imx_vpu_enc_class = GST_IMX_VPU_ENC_CLASS(klass); 55 | 56 | imx_vpu_enc_class->set_open_params = GST_DEBUG_FUNCPTR(gst_imx_vpu_enc_vp8_set_open_params); 57 | imx_vpu_enc_class->get_output_caps = GST_DEBUG_FUNCPTR(gst_imx_vpu_enc_vp8_get_output_caps); 58 | 59 | gst_imx_vpu_enc_common_class_init(imx_vpu_enc_class, IMX_VPU_API_COMPRESSION_FORMAT_VP8, TRUE, TRUE, TRUE, FALSE, TRUE); 60 | } 61 | 62 | 63 | static void gst_imx_vpu_enc_vp8_init(GstImxVpuEncVP8 *imx_vpu_enc_vp8) 64 | { 65 | gst_imx_vpu_enc_common_init(GST_IMX_VPU_ENC_CAST(imx_vpu_enc_vp8)); 66 | } 67 | 68 | 69 | gboolean gst_imx_vpu_enc_vp8_set_open_params(GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncOpenParams *open_params) 70 | { 71 | gboolean ret = TRUE; 72 | GstStructure *s; 73 | gchar const *str; 74 | GstCaps *allowed_srccaps; 75 | ImxVpuApiEncVP8OpenParams *vp8_params = &(open_params->format_specific_open_params.vp8_open_params); 76 | 77 | allowed_srccaps = gst_pad_get_allowed_caps(GST_VIDEO_DECODER_SRC_PAD(imx_vpu_enc)); 78 | 79 | if (allowed_srccaps == NULL) 80 | allowed_srccaps = gst_pad_get_pad_template_caps(GST_VIDEO_DECODER_SRC_PAD(imx_vpu_enc)); 81 | if (G_UNLIKELY(allowed_srccaps == NULL)) 82 | { 83 | GST_ERROR_OBJECT(imx_vpu_enc, "could not set VP8 params; unable to get allowed src caps or src template caps"); 84 | ret = FALSE; 85 | goto finish; 86 | } 87 | else if (G_UNLIKELY(gst_caps_is_empty(allowed_srccaps))) 88 | { 89 | GST_ERROR_OBJECT(imx_vpu_enc, "could not set VP8 params; downstream caps are empty"); 90 | ret = FALSE; 91 | goto finish; 92 | } 93 | 94 | s = gst_caps_get_structure(allowed_srccaps, 0); 95 | 96 | str = gst_imx_vpu_get_string_from_structure_field(s, "profile"); 97 | if (str != NULL) 98 | { 99 | if (g_strcmp0(str, "0") == 0) vp8_params->profile = IMX_VPU_API_VP8_PROFILE_0; 100 | else if (g_strcmp0(str, "1") == 0) vp8_params->profile = IMX_VPU_API_VP8_PROFILE_1; 101 | else if (g_strcmp0(str, "2") == 0) vp8_params->profile = IMX_VPU_API_VP8_PROFILE_2; 102 | else if (g_strcmp0(str, "3") == 0) vp8_params->profile = IMX_VPU_API_VP8_PROFILE_3; 103 | else 104 | { 105 | GST_ERROR_OBJECT(imx_vpu_enc, "unsupported VP8 profile \"%s\"", str); 106 | ret = FALSE; 107 | goto finish; 108 | } 109 | } 110 | 111 | 112 | finish: 113 | if (allowed_srccaps != NULL) 114 | gst_caps_unref(allowed_srccaps); 115 | 116 | return ret; 117 | } 118 | 119 | 120 | GstCaps* gst_imx_vpu_enc_vp8_get_output_caps(G_GNUC_UNUSED GstImxVpuEnc *imx_vpu_enc, ImxVpuApiEncStreamInfo const *stream_info) 121 | { 122 | gchar const *profile_str; 123 | 124 | switch (stream_info->format_specific_open_params.vp8_open_params.profile) 125 | { 126 | case IMX_VPU_API_VP8_PROFILE_0: profile_str = "0"; break; 127 | case IMX_VPU_API_VP8_PROFILE_1: profile_str = "1"; break; 128 | case IMX_VPU_API_VP8_PROFILE_2: profile_str = "2"; break; 129 | case IMX_VPU_API_VP8_PROFILE_3: profile_str = "3"; break; 130 | default: g_assert_not_reached(); 131 | } 132 | 133 | return gst_caps_new_simple( 134 | "video/x-vp8", 135 | "profile", G_TYPE_STRING, profile_str, 136 | NULL 137 | ); 138 | } 139 | -------------------------------------------------------------------------------- /ext/vpu/gstimxvpuencvp8.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VPU_ENC_VP8_H 20 | #define GST_IMX_VPU_ENC_VP8_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_VPU_ENC_VP8 (gst_imx_vpu_enc_vp8_get_type()) 29 | #define GST_IMX_VPU_ENC_VP8(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VPU_ENC_VP8,GstImxVpuEncVP8)) 30 | #define GST_IMX_VPU_ENC_VP8_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VPU_ENC_VP8,GstImxVpuEncVP8Class)) 31 | #define GST_IMX_VPU_ENC_VP8_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VPU_ENC_VP8, GstImxVpuEncVP8Class)) 32 | #define GST_IMX_VPU_ENC_VP8_CAST(obj) ((GstImxVpuEncVP8 *)(obj)) 33 | #define GST_IS_IMX_VPU_ENC_VP8(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VPU_ENC_VP8)) 34 | #define GST_IS_IMX_VPU_ENC_VP8_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VPU_ENC_VP8)) 35 | 36 | 37 | typedef struct _GstImxVpuEncVP8 GstImxVpuEncVP8; 38 | typedef struct _GstImxVpuEncVP8Class GstImxVpuEncVP8Class; 39 | 40 | 41 | GType gst_imx_vpu_enc_vp8_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_VPU_ENC_VP8_H */ 48 | -------------------------------------------------------------------------------- /ext/vpu/meson.build: -------------------------------------------------------------------------------- 1 | if not gstreamer_video_dep.found() 2 | # TODO: if VPU is set to "enabled", and gstvideo was not found, print an error and exit 3 | subdir_done() 4 | endif 5 | 6 | libimxvpuapi2_dep = dependency('libimxvpuapi2', version : '>=2.3.0', required : get_option('vpu')) 7 | 8 | if libimxvpuapi2_dep.found() 9 | message('Found installed imxvpuapi library - VPU elements will be built') 10 | else 11 | message('Installed imxvpuapi library not found, or user disabled VPU plugin compilation - VPU elements will not be built') 12 | subdir_done() 13 | endif 14 | 15 | source = [ 16 | 'gstimxvpucommon.c', 17 | 'gstimxvpudecbufferpool.c', 18 | 'gstimxvpudec.c', 19 | 'gstimxvpudeccontext.c', 20 | 'gstimxvpuenc.c', 21 | 'gstimxvpuench263.c', 22 | 'gstimxvpuench264.c', 23 | 'gstimxvpuencjpeg.c', 24 | 'gstimxvpuencmpeg4.c', 25 | 'gstimxvpuencvp8.c', 26 | 'plugin.c' 27 | ] 28 | 29 | 30 | library( 31 | 'gstimxvpu', 32 | source, 33 | install : true, 34 | install_dir: plugins_install_dir, 35 | include_directories: [configinc, libsinc], 36 | dependencies : [gstimxcommon_dep, gstreamer_video_dep, libimxvpuapi2_dep], 37 | link_with : [gstimxcommon] 38 | ) 39 | -------------------------------------------------------------------------------- /ext/vpu/plugin.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "gstimxvpudec.h" 23 | #include "gstimxvpuench263.h" 24 | #include "gstimxvpuench264.h" 25 | #include "gstimxvpuencjpeg.h" 26 | #include "gstimxvpuencmpeg4.h" 27 | #include "gstimxvpuencvp8.h" 28 | #include "gstimxvpucommon.h" 29 | 30 | 31 | GST_DEBUG_CATEGORY(gst_imx_vpu_common_debug); 32 | 33 | 34 | static gboolean plugin_init(GstPlugin *plugin) 35 | { 36 | gboolean ret = TRUE; 37 | ImxVpuApiDecGlobalInfo const *dec_global_info = imx_vpu_api_dec_get_global_info(); 38 | ImxVpuApiEncGlobalInfo const *enc_global_info = imx_vpu_api_enc_get_global_info(); 39 | 40 | GST_DEBUG_CATEGORY_INIT(gst_imx_vpu_common_debug, "imxvpucommon", 0, "common code for the GStreamer i.MX elements"); 41 | 42 | if (dec_global_info->flags & IMX_VPU_API_DEC_GLOBAL_INFO_FLAG_HAS_DECODER) 43 | { 44 | size_t i; 45 | for (i = 0; ret && (i < dec_global_info->num_supported_compression_formats); ++i) 46 | { 47 | ret = gst_imx_vpu_dec_register_decoder_type(plugin, dec_global_info->supported_compression_formats[i]); 48 | } 49 | } 50 | 51 | if (enc_global_info->flags & IMX_VPU_API_ENC_GLOBAL_INFO_FLAG_HAS_ENCODER) 52 | { 53 | size_t i; 54 | for (i = 0; ret && (i < enc_global_info->num_supported_compression_formats); ++i) 55 | { 56 | switch (enc_global_info->supported_compression_formats[i]) 57 | { 58 | case IMX_VPU_API_COMPRESSION_FORMAT_H263: 59 | ret = gst_element_register(plugin, "imxvpuenc_h263", GST_RANK_PRIMARY + 1, gst_imx_vpu_enc_h263_get_type()); 60 | break; 61 | 62 | case IMX_VPU_API_COMPRESSION_FORMAT_H264: 63 | ret = gst_element_register(plugin, "imxvpuenc_h264", GST_RANK_PRIMARY + 1, gst_imx_vpu_enc_h264_get_type()); 64 | break; 65 | 66 | case IMX_VPU_API_COMPRESSION_FORMAT_JPEG: 67 | ret = gst_element_register(plugin, "imxvpuenc_jpeg", GST_RANK_PRIMARY + 1, gst_imx_vpu_enc_jpeg_get_type()); 68 | break; 69 | 70 | case IMX_VPU_API_COMPRESSION_FORMAT_MPEG4: 71 | ret = gst_element_register(plugin, "imxvpuenc_mpeg4", GST_RANK_PRIMARY + 1, gst_imx_vpu_enc_mpeg4_get_type()); 72 | break; 73 | 74 | case IMX_VPU_API_COMPRESSION_FORMAT_VP8: 75 | ret = gst_element_register(plugin, "imxvpuenc_vp8", GST_RANK_PRIMARY + 1, gst_imx_vpu_enc_vp8_get_type()); 76 | break; 77 | 78 | default: 79 | break; 80 | } 81 | } 82 | } 83 | 84 | return ret; 85 | } 86 | 87 | 88 | 89 | GST_PLUGIN_DEFINE( 90 | GST_VERSION_MAJOR, 91 | GST_VERSION_MINOR, 92 | imxvpu, 93 | "video en- and decoder elements using the NXP i.MX VPU", 94 | plugin_init, 95 | VERSION, 96 | "LGPL", 97 | GST_PACKAGE_NAME, 98 | GST_PACKAGE_ORIGIN 99 | ) 100 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxcommon.pc.in: -------------------------------------------------------------------------------- 1 | prefix=/usr 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${exec_prefix}/lib 5 | 6 | Name: gstimxcommon 7 | Description: GStreamer IMX common code 8 | Version: @VERSION@ 9 | Cflags: @CFLAGS@ 10 | Libs: -L${libdir} @LIBS@ 11 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxdefaultallocator.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_DEFAULT_ALLOCATOR_H 20 | #define GST_IMX_DEFAULT_ALLOCATOR_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_DEFAULT_ALLOCATOR (gst_imx_default_allocator_get_type()) 29 | #define GST_IMX_DEFAULT_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_DEFAULT_ALLOCATOR, GstImxDefaultAllocator)) 30 | #define GST_IMX_DEFAULT_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_DEFAULT_ALLOCATOR, GstImxDefaultAllocatorClass)) 31 | #define GST_IMX_DEFAULT_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_DEFAULT_ALLOCATOR, GstImxDefaultAllocatorClass)) 32 | #define GST_IMX_DEFAULT_ALLOCATOR_CAST(obj) ((GstImxDefaultAllocator *)(obj)) 33 | #define GST_IS_IMX_DEFAULT_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_DEFAULT_ALLOCATOR)) 34 | #define GST_IS_IMX_DEFAULT_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_DEFAULT_ALLOCATOR)) 35 | 36 | 37 | typedef struct _GstImxDefaultAllocator GstImxDefaultAllocator; 38 | typedef struct _GstImxDefaultAllocatorClass GstImxDefaultAllocatorClass; 39 | 40 | 41 | GType gst_imx_default_allocator_get_type(void); 42 | 43 | GstAllocator* gst_imx_default_allocator_new(void); 44 | 45 | 46 | G_END_DECLS 47 | 48 | 49 | #endif /* GST_IMX_DEFAULT_ALLOCATOR_H */ 50 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxdmabufallocator.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_DMABUF_ALLOCATOR_H 20 | #define GST_IMX_DMABUF_ALLOCATOR_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | G_BEGIN_DECLS 28 | 29 | 30 | #define GST_TYPE_IMX_DMABUF_ALLOCATOR (gst_imx_dmabuf_allocator_get_type()) 31 | #define GST_IMX_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_DMABUF_ALLOCATOR, GstImxDmaBufAllocator)) 32 | #define GST_IMX_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_DMABUF_ALLOCATOR, GstImxDmaBufAllocatorClass)) 33 | #define GST_IMX_DMABUF_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_DMABUF_ALLOCATOR, GstImxDmaBufAllocatorClass)) 34 | #define GST_IMX_DMABUF_ALLOCATOR_CAST(obj) ((GstImxDmaBufAllocator *)(obj)) 35 | #define GST_IS_IMX_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_DMABUF_ALLOCATOR)) 36 | #define GST_IS_IMX_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_DMABUF_ALLOCATOR)) 37 | 38 | 39 | typedef struct _GstImxDmaBufAllocator GstImxDmaBufAllocator; 40 | typedef struct _GstImxDmaBufAllocatorClass GstImxDmaBufAllocatorClass; 41 | typedef struct _GstImxDmaBufAllocatorPrivate GstImxDmaBufAllocatorPrivate; 42 | 43 | 44 | struct _GstImxDmaBufAllocator 45 | { 46 | GstDmaBufAllocator parent; 47 | 48 | /*< private >*/ 49 | 50 | GstImxDmaBufAllocatorPrivate *priv; 51 | }; 52 | 53 | 54 | struct _GstImxDmaBufAllocatorClass 55 | { 56 | GstDmaBufAllocatorClass parent_class; 57 | 58 | /* NOTE: Acquire the GstObject lock before accessing these vmethods. */ 59 | gboolean (*activate)(GstImxDmaBufAllocator *allocator); 60 | guintptr (*get_physical_address)(GstImxDmaBufAllocator *allocator, int dmabuf_fd); 61 | ImxDmaBufferAllocator* (*get_allocator)(GstImxDmaBufAllocator *allocator); 62 | }; 63 | 64 | 65 | GType gst_imx_dmabuf_allocator_get_type(void); 66 | 67 | /** 68 | * gst_imx_dmabuf_allocator_get_physical_address: 69 | * @allocator: Allocator to use. 70 | * @dmabuf_fd: DMA-BUF FD to get a physical address from. Must be valid. 71 | * 72 | * Retrieves a physical address for the given DMA-BUF file descriptor. 73 | * 74 | * Returns: The physical address to the physically contiguous DMA memory 75 | * block represented by the DMA-BUF FD, or 0 if retrieving the 76 | * physical address fails. 77 | */ 78 | guintptr gst_imx_dmabuf_allocator_get_physical_address(GstImxDmaBufAllocator *allocator, int dmabuf_fd); 79 | 80 | /** 81 | * gst_imx_dmabuf_allocator_wrap_dmabuf: 82 | * @allocator: Allocator to use. 83 | * @dmabuf_fd: DMA-BUF FD to wrap. Must be valid. 84 | * @dmabuf_size: Size of the DMA-BUF buffer, in bytes. Must be greater than zero. 85 | * 86 | * Wraps the specified DMA-BUF FD in an ImxDmaBuffer that is in turn 87 | * contained in a GstMemory. That GstMemory will have @allocator set 88 | * as its allocator. @allocator must be based on #GstImxDmaBufAllocator. 89 | * 90 | * Note that the GstMemory will take ownership over the DMA-BUF FD, 91 | * meaning that the FD will be closed when the memory is disposed of. 92 | * To make sure this does not deallocate the DMA-BUF, use the POSIX 93 | * dup() call to create a duplicate FD. 94 | * 95 | * Returns: GstMemory containing an ImxDmaBuffer which in turn wraps the 96 | * @dmabuf_fd duplicate created internally by this function. 97 | */ 98 | GstMemory* gst_imx_dmabuf_allocator_wrap_dmabuf(GstAllocator *allocator, int dmabuf_fd, gsize dmabuf_size); 99 | 100 | /** 101 | * gst_imx_dmabuf_allocator_is_active: 102 | * @allocator: Allocator to check. 103 | * 104 | * Checks if this i.MX DMA-BUF allocator is active. An active DMA-BUF 105 | * allocator is one whose activate vmethod has been called. This is 106 | * done exactly once during the lifetime of the allocator, and is where 107 | * the allocator opens a device FD etc. 108 | * 109 | * @allocator must be based on #GstImxDmaBufAllocator. 110 | * 111 | * Returns: true if the allocator is active. 112 | */ 113 | gboolean gst_imx_dmabuf_allocator_is_active(GstAllocator *allocator); 114 | 115 | /** 116 | * gst_imx_ion_allocator_new: 117 | * 118 | * Creates a new #GstAllocator that is based on #GstImxDmaBufAllocator. 119 | * 120 | * At least one such allocator must be enabled in the libimxdmabuffer 121 | * build configuration. If none is enabled, an assertion is raised. 122 | * If one such allocator is available, but creating it fails, this 123 | * function returns NULL. 124 | * 125 | * Returns: (transfer full) (nullable): Newly created allocator, or NULL in case of failure. 126 | */ 127 | GstAllocator* gst_imx_dmabuf_allocator_new(void); 128 | 129 | 130 | G_END_DECLS 131 | 132 | 133 | #endif /* GST_IMX_DMABUF_ALLOCATOR_H */ 134 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxdmabufferallocator.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /** 20 | * SECTION:gstimxdmabufferallocator 21 | * @title: GstImxDmaBufferAllocator 22 | * @short_description: Interface for allocators that allocate ImxDmaBuffer instances 23 | * @see_also: #GstMemory, #GstPhysMemoryAllocator 24 | */ 25 | #include "config.h" 26 | 27 | #include 28 | #include "gstimxdmabufferallocator.h" 29 | #include "gstimxdmabufallocator.h" 30 | #include "gstimxdefaultallocator.h" 31 | 32 | 33 | GST_DEBUG_CATEGORY_STATIC(gst_imx_dma_buffer_allocator_debug); 34 | #define GST_CAT_DEFAULT gst_imx_dma_buffer_allocator_debug 35 | 36 | 37 | /** 38 | * gst_imx_is_imx_dma_buffer_memory: 39 | * @memory: a #GstMemory 40 | * 41 | * Returns: Whether the memory at @mem is backed by an ImxDmaBuffer instance 42 | */ 43 | gboolean gst_imx_is_imx_dma_buffer_memory(GstMemory *memory) 44 | { 45 | return (memory != NULL) 46 | && (memory->allocator != NULL) 47 | && g_type_is_a(G_OBJECT_TYPE(memory->allocator), GST_TYPE_IMX_DMA_BUFFER_ALLOCATOR); 48 | } 49 | 50 | 51 | gboolean gst_imx_has_imx_dma_buffer_memory(GstBuffer *buffer) 52 | { 53 | if (G_UNLIKELY((buffer == NULL) || (gst_buffer_n_memory(buffer) == 0))) 54 | return FALSE; 55 | 56 | return gst_imx_is_imx_dma_buffer_memory(gst_buffer_peek_memory(buffer, 0)); 57 | } 58 | 59 | 60 | /** 61 | * gst_imx_get_dma_buffer_from_memory: 62 | * @memory: a #GstMemory 63 | * 64 | * Returns: Pointer to ImxDmaBuffer instance that backs this memory 65 | */ 66 | ImxDmaBuffer* gst_imx_get_dma_buffer_from_memory(GstMemory *memory) 67 | { 68 | GstImxDmaBufferAllocatorInterface *iface; 69 | 70 | if (G_UNLIKELY(memory == NULL)) 71 | return NULL; 72 | 73 | g_return_val_if_fail(GST_IS_IMX_DMA_BUFFER_ALLOCATOR(memory->allocator), NULL); 74 | 75 | iface = GST_IMX_DMA_BUFFER_ALLOCATOR_GET_INTERFACE(memory->allocator); 76 | g_return_val_if_fail(iface != NULL, NULL); 77 | g_return_val_if_fail(iface->get_dma_buffer != NULL, NULL); 78 | 79 | return iface->get_dma_buffer(GST_IMX_DMA_BUFFER_ALLOCATOR_CAST(memory->allocator), memory); 80 | } 81 | 82 | 83 | /** 84 | * gst_imx_get_dma_buffer_from_buffer: 85 | * @buffer: a #GstBuffer 86 | * 87 | * Convenience function that queries the first memory in the buffer 88 | * by calling gst_imx_get_dma_buffer_from_memory(). 89 | * 90 | * Returns: Pointer to ImxDmaBuffer instance that backs this buffer's memory 91 | */ 92 | ImxDmaBuffer* gst_imx_get_dma_buffer_from_buffer(GstBuffer *buffer) 93 | { 94 | if (G_UNLIKELY((buffer == NULL) || (gst_buffer_n_memory(buffer) == 0))) 95 | return NULL; 96 | 97 | return gst_imx_get_dma_buffer_from_memory(gst_buffer_peek_memory(buffer, 0)); 98 | } 99 | 100 | 101 | /** 102 | * gst_imx_allocator_new: 103 | * 104 | * Creates a new allocator that allocates ImxDmaBuffer instances. Internally, 105 | * this chooses a DMA-BUF capable allocator like dma-heap or ION one is 106 | * enabled. Otherwise, it chooses the libimxdmabuffer default allocator. 107 | * 108 | * Returns: (transfer full) (nullable): Newly created allocator, or NULL in case of failure. 109 | */ 110 | GstAllocator* gst_imx_allocator_new(void) 111 | { 112 | #ifdef GST_DMABUF_ALLOCATOR_AVAILABLE 113 | return gst_imx_dmabuf_allocator_new(); 114 | #else 115 | return gst_imx_default_allocator_new(); 116 | #endif 117 | } 118 | 119 | 120 | GType gst_imx_dma_buffer_allocator_get_type(void) 121 | { 122 | static gsize imxdmabufferallocator_type = 0; 123 | 124 | if (g_once_init_enter(&imxdmabufferallocator_type)) 125 | { 126 | GType _type; 127 | static GTypeInfo const imxdmabufferallocator_info = 128 | { 129 | sizeof(GstImxDmaBufferAllocatorInterface), 130 | NULL, 131 | NULL, 132 | NULL, 133 | NULL, 134 | NULL, 135 | 0, 136 | 0, 137 | NULL, 138 | NULL 139 | }; 140 | 141 | _type = g_type_register_static(G_TYPE_INTERFACE, "GstImxDmaBufferAllocator", &imxdmabufferallocator_info, 0); 142 | 143 | GST_DEBUG_CATEGORY_INIT(gst_imx_dma_buffer_allocator_debug, "imxdmabufferallocator", GST_DEBUG_BOLD, "allocates i.MX DMA buffers"); 144 | g_once_init_leave (&imxdmabufferallocator_type, _type); 145 | } 146 | 147 | return imxdmabufferallocator_type; 148 | } 149 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxdmabufferallocator.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2019 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_DMA_BUFFER_ALLOCATOR_H 20 | #define GST_IMX_DMA_BUFFER_ALLOCATOR_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | G_BEGIN_DECLS 27 | 28 | 29 | #define GST_TYPE_IMX_DMA_BUFFER_ALLOCATOR (gst_imx_dma_buffer_allocator_get_type()) 30 | #define GST_IMX_DMA_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_DMA_BUFFER_ALLOCATOR, GstImxDmaBufferAllocator)) 31 | #define GST_IMX_DMA_BUFFER_ALLOCATOR_CAST(obj) ((GstImxDmaBufferAllocator *)(obj)) 32 | #define GST_IS_IMX_DMA_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_DMA_BUFFER_ALLOCATOR)) 33 | #define GST_IMX_DMA_BUFFER_ALLOCATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), GST_TYPE_IMX_DMA_BUFFER_ALLOCATOR, GstImxDmaBufferAllocatorInterface)) 34 | 35 | 36 | /* Extra GstMemory map flag to underlying libimxdmabuffer allocators 37 | * to disable automatic cache sync. Needed if the allocated buffers 38 | * will be manually synced with imx_dma_buffer_start_sync_session() 39 | * and imx_dma_buffer_stop_sync_session(). */ 40 | #define GST_MAP_FLAG_IMX_MANUAL_SYNC (GST_MAP_FLAG_LAST + 0) 41 | 42 | 43 | typedef struct _GstImxDmaBufferAllocator GstImxDmaBufferAllocator; 44 | typedef struct _GstImxDmaBufferAllocatorInterface GstImxDmaBufferAllocatorInterface; 45 | 46 | 47 | /** 48 | * GstImxDmaBufferAllocatorInterface: 49 | * @parent parent interface type. 50 | * @get_dma_buffer: virtual method to get an ImxDmaBuffer out of a GstMemory that was allocated by a DMA buffer allocator 51 | * 52 | * #GstImxDmaBufferAllocator interface. 53 | */ 54 | struct _GstImxDmaBufferAllocatorInterface 55 | { 56 | GTypeInterface parent; 57 | 58 | /* methods */ 59 | ImxDmaBuffer* (*get_dma_buffer)(GstImxDmaBufferAllocator *allocator, GstMemory *memory); 60 | 61 | /*< private >*/ 62 | gpointer _gst_reserved[GST_PADDING]; 63 | }; 64 | 65 | 66 | GType gst_imx_dma_buffer_allocator_get_type(void); 67 | 68 | gboolean gst_imx_is_imx_dma_buffer_memory(GstMemory *memory); 69 | gboolean gst_imx_has_imx_dma_buffer_memory(GstBuffer *buffer); 70 | 71 | ImxDmaBuffer* gst_imx_get_dma_buffer_from_memory(GstMemory *memory); 72 | ImxDmaBuffer* gst_imx_get_dma_buffer_from_buffer(GstBuffer *buffer); 73 | 74 | GstAllocator* gst_imx_allocator_new(void); 75 | 76 | 77 | G_END_DECLS 78 | 79 | 80 | #endif /* GST_IMX_DMA_BUFFER_ALLOCATOR_H */ 81 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxdmabufferuploader.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2020 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_DMA_BUFFER_UPLOADER_H 20 | #define GST_IMX_DMA_BUFFER_UPLOADER_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_DMA_BUFFER_UPLOADER (gst_imx_dma_buffer_uploader_get_type()) 29 | #define GST_IMX_DMA_BUFFER_UPLOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_DMA_BUFFER_UPLOADER,GstImxDmaBufferUploader)) 30 | #define GST_IMX_DMA_BUFFER_UPLOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_DMA_BUFFER_UPLOADER,GstImxDmaBufferUploaderClass)) 31 | #define GST_IMX_DMA_BUFFER_UPLOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_DMA_BUFFER_UPLOADER, GstImxDmaBufferUploaderClass)) 32 | #define GST_IMX_DMA_BUFFER_UPLOADER_CAST(obj) ((GstImxDmaBufferUploader *)(obj)) 33 | #define GST_IS_IMX_DMA_BUFFER_UPLOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_DMA_BUFFER_UPLOADER)) 34 | #define GST_IS_IMX_DMA_BUFFER_UPLOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_DMA_BUFFER_UPLOADER)) 35 | 36 | 37 | /** 38 | * GstImxDmaBufferUploader: 39 | * 40 | * Uploads data into @GstMemory instances that use an ImxDmaBuffer as the underlying memory. 41 | * 42 | * gstreamer-imx elements use libimxdmabuffer's ImxDmaBuffer structure as the basic memory 43 | * unit. ImxDmaBuffer represents a block of physically contiguous memory (also called 44 | * "DMA buffers", not to be confused with Linux DMA-BUF), suitable for DMA transfers. 45 | * 46 | * An allocator that implements the @GstImxDmaBufferAllocatorInterface can allocate 47 | * @GstMemory blocks that contain ImxDmaBuffer instances. In gstreamer-imx, such allocators 48 | * also implement @GstPhysMemoryAllocatorInterface. Additionally, if the allocator is based 49 | * on @GstImxDmaBufAllocator, it is able to allocate DMA-BUF memory. 50 | * 51 | * This means that a @GstMemory that is backed by ImxDmaBuffer is the most "generic" type 52 | * of memory in gstreamer-imx. It can be accessed like system memory, its physical address 53 | * can be obtained via @gst_phys_memory_get_phys_addr, its ImxDmaBuffer can be retrieved 54 | * by using @gst_imx_get_dma_buffer_from_memory or @gst_imx_get_dma_buffer_from_buffer, 55 | * and, if the allocator is DMA-BUF capable, the @gst_dmabuf_memory_get_fd function can be 56 | * used for retrieving the DMA-BUF FD. Therefore, it makes sense to unify these three ways 57 | * of access into one. 58 | * 59 | * For input, this "uploader" takes care of getting incoming data into ImxDmaBuffer-backed 60 | * @GstMemory. Internally, the uploader has "upload methods". The uploader asks each method 61 | * to try to perform the upload. As soon as one succeeds, the uploader considers the upload 62 | * to be done. There are upload methods for DMA-BUF buffers, for raw uploads (meaning that 63 | * the bytes of input buffers are copied into an ImxDmaBuffer-based GstBuffer), etc. 64 | * The upload is done by calling @gst_imx_dma_buffer_uploader_perform. 65 | * 66 | * For output, things are much simpler, since, as described above, ImxDmaBuffer can be used 67 | * in 3 ways without chaging a single thing. The same @GstMemory that was allocated by an 68 | * allocator that implements the aforementioned interfaces and extends @GstDmaBufAllocator 69 | * will be accessible via regular system memory functions (@gst_memory_map etc.), via 70 | * @gst_dmabuf_memory_get_fd, via @gst_imx_get_dma_buffer_from_memory etc. without any 71 | * changes. So, there is no need for an actual "downloader". 72 | * 73 | * In short: Upload = transfer incoming data into ImxDmaBuffer blocks, or wrap DMA-BUF FDs 74 | * into custom ImxDmaBuffer blocks, or simply pass through GstMemory if it already contains 75 | * an ImxDmaBuffer. Download = Just push ImxDmaBuffer-backed GstMemory downstream. 76 | */ 77 | typedef struct _GstImxDmaBufferUploader GstImxDmaBufferUploader; 78 | typedef struct _GstImxDmaBufferUploaderClass GstImxDmaBufferUploaderClass; 79 | 80 | 81 | typedef struct _GstImxDmaBufferUploadMethodContext GstImxDmaBufferUploadMethodContext; 82 | typedef struct _GstImxDmaBufferUploadMethodType GstImxDmaBufferUploadMethodType; 83 | 84 | 85 | 86 | GType gst_imx_dma_buffer_uploader_get_type(void); 87 | 88 | 89 | /** 90 | * gst_imx_dma_buffer_uploader_new: 91 | * @imx_dma_buffer_allocator: ImxDmaBuffer allocator to use in this 92 | * object. If the allocator is based on @GstImxDmaBufAllocator, 93 | * this allows for DMA-BUF based uploads. 94 | * 95 | * Creates a new upload object. 96 | * 97 | * The allocator is ref'd in this function and unref'd when 98 | * the uploader is destroyed. 99 | * 100 | * Returns: (transfer floating) A new upload object. 101 | */ 102 | GstImxDmaBufferUploader* gst_imx_dma_buffer_uploader_new(GstAllocator *imx_dma_buffer_allocator); 103 | 104 | /** 105 | * gst_imx_dma_buffer_uploader_get_allocator: 106 | * @uploader: Uploader instance to get the allocator from. 107 | * 108 | * Returns: (transfer full) The ImxDmaBuffer allocator that this uploader uses. 109 | * Unref with gst_object_unref() after use. 110 | */ 111 | GstAllocator* gst_imx_dma_buffer_uploader_get_allocator(GstImxDmaBufferUploader *uploader); 112 | 113 | /** 114 | * gst_imx_dma_buffer_uploader_perform: 115 | * @uploader: Uploader instance to use for uploading data. 116 | * @input_buffer: (transfer-none) Buffer that shall be uploaded. 117 | * @output_buffer: (out) (transfer-full) Uploaded version of @input_buffer. 118 | * 119 | * The central function of the uploader. This is the function that does the actual uploading. 120 | * A version of @buffer is produced that uses an ImxDmaBuffer backed @GstMemory as its memory. 121 | * 122 | * If @input_buffer has no memory blocks, @output_buffer is set to @input_buffer, and 123 | * @input_buffer is ref'd. 124 | * 125 | * In case of an error, @output_buffer will remain unmodified, and the refcount of @input_buffer 126 | * will not be changed. 127 | * 128 | * Returns: @GST_FLOW_OK if the upload succeeded. 129 | */ 130 | GstFlowReturn gst_imx_dma_buffer_uploader_perform(GstImxDmaBufferUploader *uploader, GstBuffer *input_buffer, GstBuffer **output_buffer); 131 | 132 | 133 | G_END_DECLS 134 | 135 | 136 | #endif /* GST_IMX_DMA_BUFFER_UPLOADER_H */ 137 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxdmaheapallocator.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_DMA_HEAP_ALLOCATOR_H 20 | #define GST_IMX_DMA_HEAP_ALLOCATOR_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_DMA_HEAP_ALLOCATOR (gst_imx_dma_heap_allocator_get_type()) 29 | #define GST_IMX_DMA_HEAP_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_DMA_HEAP_ALLOCATOR, GstImxDmaHeapAllocator)) 30 | #define GST_IMX_DMA_HEAP_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_DMA_HEAP_ALLOCATOR, GstImxDmaHeapAllocatorClass)) 31 | #define GST_IMX_DMA_HEAP_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_DMA_HEAP_ALLOCATOR, GstImxDmaHeapAllocatorClass)) 32 | #define GST_IMX_DMA_HEAP_ALLOCATOR_CAST(obj) ((GstImxDmaHeapAllocator *)(obj)) 33 | #define GST_IS_IMX_DMA_HEAP_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_DMA_HEAP_ALLOCATOR)) 34 | #define GST_IS_IMX_DMA_HEAP_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_DMA_HEAP_ALLOCATOR)) 35 | 36 | 37 | typedef struct _GstImxDmaHeapAllocator GstImxDmaHeapAllocator; 38 | typedef struct _GstImxDmaHeapAllocatorClass GstImxDmaHeapAllocatorClass; 39 | 40 | 41 | GType gst_imx_dma_heap_allocator_get_type(void); 42 | 43 | /** 44 | * gst_imx_dma_heap_allocator_new: 45 | * 46 | * Creates a new #GstAllocator using the dma-heap allocator. 47 | * 48 | * Returns: (transfer full) (nullable): Newly created allocator, or NULL in case of failure. 49 | */ 50 | GstAllocator* gst_imx_dma_heap_allocator_new(void); 51 | 52 | 53 | G_END_DECLS 54 | 55 | 56 | #endif /* GST_IMX_DMA_HEAP_ALLOCATOR_H */ 57 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/gstimxionallocator.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_ION_ALLOCATOR_H 20 | #define GST_IMX_ION_ALLOCATOR_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_ION_ALLOCATOR (gst_imx_ion_allocator_get_type()) 29 | #define GST_IMX_ION_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_ION_ALLOCATOR, GstImxIonAllocator)) 30 | #define GST_IMX_ION_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_ION_ALLOCATOR, GstImxIonAllocatorClass)) 31 | #define GST_IMX_ION_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_ION_ALLOCATOR, GstImxIonAllocatorClass)) 32 | #define GST_IMX_ION_ALLOCATOR_CAST(obj) ((GstImxIonAllocator *)(obj)) 33 | #define GST_IS_IMX_ION_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_ION_ALLOCATOR)) 34 | #define GST_IS_IMX_ION_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_ION_ALLOCATOR)) 35 | 36 | 37 | typedef struct _GstImxIonAllocator GstImxIonAllocator; 38 | typedef struct _GstImxIonAllocatorClass GstImxIonAllocatorClass; 39 | 40 | 41 | GType gst_imx_ion_allocator_get_type(void); 42 | 43 | /** 44 | * gst_imx_ion_allocator_new: 45 | * 46 | * Creates a new #GstAllocator using the ION allocator. 47 | * 48 | * Returns: (transfer full) (nullable): Newly created allocator, or NULL in case of failure. 49 | */ 50 | GstAllocator* gst_imx_ion_allocator_new(void); 51 | 52 | 53 | G_END_DECLS 54 | 55 | 56 | #endif /* GST_IMX_ION_ALLOCATOR_H */ 57 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/common/meson.build: -------------------------------------------------------------------------------- 1 | source = ['gstimxdmabufferallocator.c', 'gstimxdmabufallocator.c', 'gstimxdefaultallocator.c', 'gstimxdmabufferuploader.c'] 2 | public_headers = ['gstimxdmabufferallocator.h', 'gstimxdmabufallocator.h', 'gstimxdefaultallocator.h', 'gstimxdmabufferuploader.h'] 3 | 4 | if dma_heap_support 5 | source += ['gstimxdmaheapallocator.c'] 6 | public_headers += ['gstimxdmaheapallocator.h'] 7 | endif 8 | 9 | if ion_support 10 | source += ['gstimxionallocator.c'] 11 | public_headers += ['gstimxionallocator.h'] 12 | endif 13 | 14 | gstimxcommon = library( 15 | 'gstimxcommon', 16 | source, 17 | version : meson.project_version(), 18 | install : true, 19 | include_directories: [configinc], 20 | dependencies : [gstreamer_dep, gstreamer_base_dep, gstreamer_allocators_dep, libm_dep, libimxdmabuffer_dep] 21 | ) 22 | 23 | gstimxcommon_dep = declare_dependency( 24 | dependencies : [gstreamer_dep, gstreamer_base_dep, gstreamer_allocators_dep, libm_dep, libimxdmabuffer_dep], 25 | include_directories : libsinc, 26 | link_with : [gstimxcommon] 27 | ) 28 | 29 | install_headers(public_headers, subdir : 'gstreamer-1.0/gst/imx/common') 30 | 31 | pkg.generate( 32 | gstimxcommon, 33 | name : 'gstimxcommon', 34 | description : 'GStreamer IMX common code' 35 | ) 36 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/video/gstimxvideobufferpool.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VIDEO_BUFFER_POOL_H 20 | #define GST_IMX_VIDEO_BUFFER_POOL_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | G_BEGIN_DECLS 27 | 28 | 29 | #define GST_TYPE_IMX_VIDEO_BUFFER_POOL (gst_imx_video_buffer_pool_get_type()) 30 | #define GST_IMX_VIDEO_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VIDEO_BUFFER_POOL, GstImxVideoBufferPool)) 31 | #define GST_IMX_VIDEO_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VIDEO_BUFFER_POOL, GstImxVideoBufferPoolClass)) 32 | #define GST_IMX_VIDEO_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VIDEO_BUFFER_POOL, GstImxVideoBufferPoolClass)) 33 | #define GST_IMX_VIDEO_BUFFER_POOL_CAST(obj) ((GstImxVideoBufferPool *)(obj)) 34 | #define GST_IS_IMX_VIDEO_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VIDEO_BUFFER_POOL)) 35 | #define GST_IS_IMX_VIDEO_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VIDEO_BUFFER_POOL)) 36 | 37 | 38 | /** 39 | * GstImxVideoBufferPool: 40 | * 41 | * Creates internal buffer pools depending on the downstream videometa support and the output video info. 42 | * 43 | * If downstream does not support video metas, and if a GStreamer element produces 44 | * buffers with frames that use stride / plane offset values that aren't tightly packed, 45 | * then output frames have to be copied internally into a layout that is tightly packed. 46 | * 47 | * "Tightly packed" means that all of these apply: 48 | * 49 | * 1. The stride size equals width * bytes_per_pixel (that is, there are no padding pixels/bytes to the right) 50 | * 2. In case of planar formats, the plane offsets are such that there are no padding bytes between planes 51 | * 52 | * If this is the case, then stride and plane offset values can be directly derived from 53 | * the video/x-raw caps. If they aren't, then the caps are not enough - the video meta 54 | * data is then necessary. But if downstream can't handle video metas, it therefore can't 55 | * handle these frames directly. Therefore, they need to be transferred into a form that 56 | * _is_ tightly packed before pushing the frames downstream. 57 | * 58 | * To that end, this object exists. It creates two internal buffer pools, one based on a 59 | * GstVideoInfo structure (which can have non-tightly-packed stride and plane offset values), 60 | * the other based on caps from an allocation query. The former allocates DMA buffers, 61 | * and is called the "internal DMA buffer pool". The latter is called the "output video 62 | * buffer pool", and allocates buffers using normal system memory. 63 | * 64 | * If downstream can handle video meta, or if the stride / plane offset values are tightly 65 | * packed, then both buffer pools are the same (that is, there's _one_ pool inside, one 66 | * that allocates DMA buffers). That's because in such a case, frame copies are unnecessary, 67 | * so a separate pool for output buffers is not needed. 68 | * 69 | * The GstImxVideoBufferPool is created in the decide_allocation vmethods of the elements 70 | * (or in the allocation query handler in case the element is not based on a subclass that 71 | * has such a vmethod). The output video buffer pool is added to that query, while the 72 | * internal DMA buffer pool isn't. 73 | * 74 | * When the element's subclass then acquires a buffer from the pool that was added to the 75 | * query (that is - the output video buffer pool in our case), callers need to pass it to 76 | * gst_imx_video_buffer_pool_acquire_intermediate_buffer(). This acquires an "intermediate 77 | * buffer" from the internal DMA buffer pool. The element then needs to use that intermediate 78 | * buffer as the target for its blitting operations. 79 | * 80 | * Once the blitter is done, gst_imx_video_buffer_pool_transfer_to_output_buffer() needs 81 | * to be called to transfer over the rendered pixels into a form that is suitable for 82 | * downstream. The element can then push the final buffer downstream. 83 | * 84 | * Should both pools be the same, then nothing is acquired / transferred, since 85 | * the buffer acquired by the subclass and the intermediate buffer are one and the same; 86 | * gst_imx_video_buffer_pool_acquire_intermediate_buffer() then just refs the output_buffer 87 | * and sets (*intermediate_buffer) to output_buffer, and the intermedia_buffer is unref'd in 88 | * gst_imx_video_buffer_pool_transfer_to_output_buffer(). That way, these two functions 89 | * effectively become no-ops. 90 | */ 91 | typedef struct _GstImxVideoBufferPool GstImxVideoBufferPool; 92 | typedef struct _GstImxVideoBufferPoolClass GstImxVideoBufferPoolClass; 93 | 94 | 95 | GType gst_imx_video_buffer_pool_get_type(void); 96 | 97 | /** 98 | * gst_imx_video_buffer_pool_new: 99 | * @imx_dma_buffer_allocator: ImxDmaBuffer allocator to use for allocating gstbuffers. 100 | * @query: Allocation query to parse and set up. 101 | * @intermediate_video_info: Video info of the intermediate frames. 102 | * 103 | * Returns: (transfer floating) A new video buffer pool. 104 | */ 105 | GstImxVideoBufferPool* gst_imx_video_buffer_pool_new( 106 | GstAllocator *imx_dma_buffer_allocator, 107 | GstQuery *query, 108 | GstVideoInfo const *intermediate_video_info 109 | ); 110 | 111 | GstBufferPool* gst_imx_video_buffer_pool_get_internal_dma_buffer_pool(GstImxVideoBufferPool *imx_video_buffer_pool); 112 | GstBufferPool* gst_imx_video_buffer_pool_get_output_video_buffer_pool(GstImxVideoBufferPool *imx_video_buffer_pool); 113 | 114 | GstFlowReturn gst_imx_video_buffer_pool_acquire_intermediate_buffer(GstImxVideoBufferPool *imx_video_buffer_pool, GstBuffer *output_buffer, GstBuffer **intermediate_buffer); 115 | gboolean gst_imx_video_buffer_pool_transfer_to_output_buffer(GstImxVideoBufferPool *imx_video_buffer_pool, GstBuffer *intermediate_buffer, GstBuffer *output_buffer); 116 | 117 | gboolean gst_imx_video_buffer_pool_are_both_pools_same(GstImxVideoBufferPool *imx_video_buffer_pool); 118 | gboolean gst_imx_video_buffer_pool_video_meta_supported(GstImxVideoBufferPool *imx_video_buffer_pool); 119 | 120 | GstVideoInfo const * gst_imx_video_buffer_pool_get_intermediate_video_info(GstImxVideoBufferPool *imx_video_buffer_pool); 121 | GstVideoInfo const * gst_imx_video_buffer_pool_get_output_video_info(GstImxVideoBufferPool *imx_video_buffer_pool); 122 | 123 | 124 | G_END_DECLS 125 | 126 | 127 | #endif /* GST_IMX_VIDEO_BUFFER_POOL_H */ 128 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/video/gstimxvideodmabufferpool.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VIDEO_DMA_BUFFER_POOL_H 20 | #define GST_IMX_VIDEO_DMA_BUFFER_POOL_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | G_BEGIN_DECLS 27 | 28 | 29 | #define GST_TYPE_IMX_VIDEO_DMA_BUFFER_POOL (gst_imx_video_dma_buffer_pool_get_type()) 30 | #define GST_IMX_VIDEO_DMA_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_VIDEO_DMA_BUFFER_POOL, GstImxVideoDmaBufferPool)) 31 | #define GST_IMX_VIDEO_DMA_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_VIDEO_DMA_BUFFER_POOL, GstImxVideoDmaBufferPoolClass)) 32 | #define GST_IMX_VIDEO_DMA_BUFFER_POOL_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_VIDEO_DMA_BUFFER_POOL, GstImxVideoDmaBufferPoolClass)) 33 | #define GST_IMX_VIDEO_DMA_BUFFER_POOL_CAST(obj) ((GstImxVideoDmaBufferPool *)(obj)) 34 | #define GST_IS_IMX_VIDEO_DMA_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_VIDEO_DMA_BUFFER_POOL)) 35 | #define GST_IS_IMX_VIDEO_DMA_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_VIDEO_DMA_BUFFER_POOL)) 36 | 37 | 38 | /** 39 | * GstImxVideoDmaBufferPool: 40 | * 41 | * Special buffer pool designed for use with elements that produce 42 | * buffers backed with DMA memory and allocated based on the specification 43 | * from a GstVideoInfo instance. The allocated GstBuffer instances 44 | * may be single-memory (= all video frame planes in one GstMemory) 45 | * or multi-memory (= one GstMemory per plane). The plane sizes may 46 | * be specified manually (useful when a driver / API requires certain 47 | * plane sizes) or calculated out of the GstVideoInfo. 48 | * 49 | * Using this pool is not strictly necessary if elements exclusively 50 | * use single-memory gstbuffers; a regular buffer pool combined with 51 | * a DMA buffer allocator also works. But for multi-memory gstbuffers, 52 | * using GstImxVideoDmaBufferPool is recommended. 53 | * 54 | * Importantly, the regular buffer pool configuration that is set 55 | * gst_buffer_pool_set_config is not used, since the GstVideoInfo 56 | * already supplies all the necessary information. 57 | */ 58 | 59 | typedef struct _GstImxVideoDmaBufferPool GstImxVideoDmaBufferPool; 60 | typedef struct _GstImxVideoDmaBufferPoolClass GstImxVideoDmaBufferPoolClass; 61 | 62 | 63 | GType gst_imx_video_dma_buffer_pool_get_type(void); 64 | 65 | 66 | /** 67 | * gst_imx_video_dma_buffer_pool_new: 68 | * @imx_dma_buffer_allocator: ImxDmaBuffer allocator to use for 69 | * allocating GstMemory blocks. 70 | * @video_info: GstVideoInfo to use for allocating buffers. 71 | * @create_multi_memory_buffers: True if the allocated GstBuffer 72 | * shall contain one GstMemory per plane. 73 | * @plane_sizes If non-NULL, this contains the sizes for each 74 | * plane, in bytes. If NULL, the sizes are calculated 75 | * out of the video_info. 76 | * 77 | * Creates a new GstImxVideoDmaBufferPool instance. 78 | * 79 | * The created buffer pool comes already activated and configured. 80 | * Buffers are allocated according to the video info. Their size 81 | * is defined by the video_info's size field, or by the total sum 82 | * of the plane_sizes if that sum exceeds the video_info size. 83 | */ 84 | GstBufferPool* gst_imx_video_dma_buffer_pool_new( 85 | GstAllocator *imx_dma_buffer_allocator, 86 | GstVideoInfo *video_info, 87 | gboolean create_multi_memory_buffers, 88 | gsize *plane_sizes 89 | ); 90 | 91 | GstVideoInfo const * gst_imx_video_dma_buffer_pool_get_video_info(GstBufferPool *imx_video_dma_buffer_pool); 92 | gboolean gst_imx_video_dma_buffer_pool_creates_multi_memory_buffers(GstBufferPool *imx_video_dma_buffer_pool); 93 | 94 | gsize gst_imx_video_dma_buffer_pool_get_plane_offset(GstBufferPool *imx_video_dma_buffer_pool, gint plane_index); 95 | gsize gst_imx_video_dma_buffer_pool_get_plane_size(GstBufferPool *imx_video_dma_buffer_pool, gint plane_index); 96 | 97 | 98 | G_END_DECLS 99 | 100 | 101 | #endif /* GST_IMX_VIDEO_DMA_BUFFER_POOL_H */ 102 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/video/gstimxvideoutils.c: -------------------------------------------------------------------------------- 1 | #include "gstimxvideoutils.h" 2 | 3 | 4 | gint gst_imx_video_utils_calculate_total_num_frame_rows(GstBuffer *video_frame_buffer, GstVideoInfo const *video_info) 5 | { 6 | gint total_num_frame_rows; 7 | GstVideoMeta *video_meta = (video_frame_buffer != NULL) ? gst_buffer_get_video_meta(video_frame_buffer) : NULL; 8 | 9 | /* The number of plane rows are derived from the plane offsets. 10 | * This assumes that the distance between the first and the second plane offsets 11 | * is an integer multiple of the first plane's stride, because the first plane 12 | * _has_ to fit in there, along with any additional padding rows. 13 | * For single-plane formats, we assume that the buffer size is an integer 14 | * multiple of the first plane's stride. */ 15 | 16 | if (video_meta != NULL) 17 | { 18 | if (video_meta->n_planes > 1) 19 | total_num_frame_rows = (video_meta->offset[1] - video_meta->offset[0]) / video_meta->stride[0]; 20 | else 21 | total_num_frame_rows = gst_buffer_get_size(video_frame_buffer) / video_meta->stride[0]; 22 | } 23 | else 24 | { 25 | g_assert(video_info != NULL); 26 | 27 | if (GST_VIDEO_INFO_N_PLANES(video_info) > 1) 28 | total_num_frame_rows = (GST_VIDEO_INFO_PLANE_OFFSET(video_info, 1) - GST_VIDEO_INFO_PLANE_OFFSET(video_info, 0)) / GST_VIDEO_INFO_PLANE_STRIDE(video_info, 0); 29 | else 30 | total_num_frame_rows = GST_VIDEO_INFO_SIZE(video_info) / GST_VIDEO_INFO_PLANE_STRIDE(video_info, 0); 31 | } 32 | 33 | return total_num_frame_rows; 34 | } 35 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/video/gstimxvideoutils.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_VIDEO_UTILS_H 20 | #define GST_IMX_VIDEO_UTILS_H 21 | 22 | #include 23 | #include 24 | 25 | 26 | G_BEGIN_DECLS 27 | 28 | 29 | gint gst_imx_video_utils_calculate_total_num_frame_rows(GstBuffer *video_frame_buffer, GstVideoInfo const *video_info); 30 | 31 | 32 | G_END_DECLS 33 | 34 | 35 | #endif /* GST_IMX_VIDEO_UTILS_H */ 36 | -------------------------------------------------------------------------------- /gst-libs/gst/imx/video/meson.build: -------------------------------------------------------------------------------- 1 | source = [ 2 | 'gstimxvideobufferpool.c', 3 | 'gstimxvideodmabufferpool.c', 4 | 'gstimxvideouploader.c', 5 | 'gstimxvideoutils.c' 6 | ] 7 | public_headers = [ 8 | 'gstimxvideobufferpool.h', 9 | 'gstimxvideodmabufferpool.h', 10 | 'gstimxvideouploader.h', 11 | 'gstimxvideoutils.h' 12 | ] 13 | 14 | gstimxvideo = library( 15 | 'gstimxvideo', 16 | source, 17 | version : meson.project_version(), 18 | install : true, 19 | include_directories: [configinc], 20 | dependencies : [gstimxcommon_dep, gstreamer_video_dep] 21 | ) 22 | 23 | gstimxvideo_dep = declare_dependency( 24 | dependencies : [gstimxcommon_dep, gstreamer_video_dep], 25 | include_directories : libsinc, 26 | link_with : [gstimxvideo] 27 | ) 28 | 29 | install_headers(public_headers, subdir : 'gstreamer-1.0/gst/imx/video') 30 | 31 | pkg.generate( 32 | gstimxvideo, 33 | name : 'gstimxvideo', 34 | description : 'GStreamer IMX common video code' 35 | ) 36 | -------------------------------------------------------------------------------- /gst-libs/imx2d/backend/g2d/g2d_blitter.h: -------------------------------------------------------------------------------- 1 | #ifndef IMX2D_BACKEND_G2D_BLITTER_H 2 | #define IMX2D_BACKEND_G2D_BLITTER_H 3 | 4 | #include 5 | 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | 12 | /** 13 | * imx_2d_backend_g2d_blitter_create: 14 | * 15 | * Creates a new @Imx2dBlitter that uses the Vivante G2D API for blitting. 16 | * 17 | * To destroy the created blitter, use @imx_2d_blitter_destroy. 18 | * 19 | * Returns: Pointer to a newly created G2D blitter, or NULL in case of failure. 20 | */ 21 | Imx2dBlitter* imx_2d_backend_g2d_blitter_create(void); 22 | 23 | /** 24 | * imx_2d_backend_g2d_get_hardware_capabilities: 25 | * 26 | * Returns a const pointer to a static structure that contains 27 | * information about the G2D-based hardware capabilities. 28 | * 29 | * @Returns Const pointer to the @Imx2dHardwareCapabilities structure. 30 | * This structure is static, and does not have to be freed in any way. 31 | */ 32 | Imx2dHardwareCapabilities const * imx_2d_backend_g2d_get_hardware_capabilities(void); 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | 40 | #endif /* IMX2D_BACKEND_G2D_BLITTER_H */ 41 | -------------------------------------------------------------------------------- /gst-libs/imx2d/backend/g2d/meson.build: -------------------------------------------------------------------------------- 1 | g2d_option = get_option('g2d') 2 | 3 | g2d_dep = cc.find_library( 4 | 'g2d', 5 | required : g2d_option, 6 | has_headers : ['g2d.h'] 7 | ) 8 | 9 | if g2d_dep.found() 10 | imx2d_backend_g2d = static_library( 11 | 'imx2d_backend_g2d', 12 | ['g2d_blitter.c'], 13 | install : false, 14 | include_directories: [configinc], 15 | dependencies : [imx2d_dep, g2d_dep] 16 | ) 17 | 18 | imx2d_backend_g2d_dep = declare_dependency( 19 | dependencies : [imx2d_dep, g2d_dep], 20 | link_with : [imx2d_backend_g2d] 21 | ) 22 | 23 | conf_data.set('WITH_IMX2D_G2D_BACKEND', 1) 24 | 25 | g2d_major_version = cc.get_define('G2D_VERSION_MAJOR', prefix : '#include ').to_int() 26 | g2d_minor_version = cc.get_define('G2D_VERSION_MINOR', prefix : '#include ').to_int() 27 | g2d_patch_version = cc.get_define('G2D_VERSION_PATCH', prefix : '#include ').to_int() 28 | message( 29 | 'G2D version: @0@.@1@.@2@'.format( 30 | g2d_major_version, 31 | g2d_minor_version, 32 | g2d_patch_version 33 | ) 34 | ) 35 | 36 | g2d_amphion_support_details = { 37 | 'G2D_AMPHION_TILED' : {'define': 'IMX2D_G2D_AMPHION_TILE_LAYOUT_SUPPORTED', 'name': 'G2D Amphion tile layout'}, 38 | 'G2D_AMPHION_TILED_10BIT' : {'define': 'IMX2D_G2D_AMPHION_10BIT_TILE_LAYOUT_SUPPORTED', 'name': 'G2D Amphion 10-bit tile layout'}, 39 | 'G2D_AMPHION_INTERLACED' : {'define': 'IMX2D_G2D_AMPHION_INTERLACED_TILE_LAYOUT_SUPPORTED', 'name': 'G2D Amphion interlaced tile layout'}, 40 | } 41 | foreach enum, details : g2d_amphion_support_details 42 | g2d_amphion_support = cc.compiles( 43 | ''' 44 | #include 45 | #include 46 | int main(void) 47 | { 48 | int i = @0@; 49 | return 0; 50 | } 51 | '''.format(enum), 52 | dependencies : [g2d_dep], 53 | name : '@0@ support'.format(details['name']) 54 | ) 55 | conf_data.set(details['define'], g2d_amphion_support) 56 | endforeach 57 | 58 | g2d_colorimetry_support = cc.compiles( 59 | ''' 60 | #include 61 | int main(void) 62 | { 63 | int i = G2D_YUV_BT_601; 64 | return 0; 65 | } 66 | ''', 67 | dependencies : [g2d_dep], 68 | name : 'G2D colorimetry support' 69 | ) 70 | conf_data.set('IMX2D_G2D_COLORIMETRY_SUPPORTED', g2d_colorimetry_support) 71 | 72 | g2d_full_range_colorimetry_support = cc.compiles( 73 | ''' 74 | #include 75 | int main(void) 76 | { 77 | int i = G2D_YUV_BT_601FR; 78 | return 0; 79 | } 80 | ''', 81 | dependencies : [g2d_dep], 82 | name : 'G2D full range colorimetry support' 83 | ) 84 | conf_data.set('IMX2D_G2D_FULL_RANGE_COLORIMETRY_SUPPORTED', g2d_full_range_colorimetry_support) 85 | 86 | g2d_based_on_dpu = get_option('g2d-based-on-dpu') 87 | if g2d_based_on_dpu 88 | message('G2D implementation is based on the i.MX8qm / i.MX8qxp DPU') 89 | else 90 | message('G2D implementation is not based on the i.MX8qm / i.MX8qxp DPU') 91 | endif 92 | conf_data.set('IMX2D_G2D_IMPLEMENTATION_BASED_ON_DPU', g2d_based_on_dpu) 93 | 94 | # Starting with G2D 2.0, the previous thread limitation is gone. 95 | # This means that the various G2D function do not stricly have 96 | # to be called from the same thread only. In GStreamer, this is 97 | # important, since then, g2d_open() can be called in a start 98 | # function that may be called in a different thread. Concurrent 99 | # G2D calls are still not supported, though. 100 | # Also, DPU based implementations never had that limitation. 101 | # Thus, if either G2D is new enough, or if this is a DPU based 102 | # G2D implementation, do not restrict G2D calls to one thread. 103 | 104 | if g2d_major_version >= 2 105 | g2d_calls_restricted_to_one_thread = false 106 | message('G2D implementation is sufficiently new; not restricting calls to one thread') 107 | elif g2d_based_on_dpu 108 | g2d_calls_restricted_to_one_thread = false 109 | message('G2D implementation is base on DPU; not restricting calls to one thread') 110 | else 111 | g2d_calls_restricted_to_one_thread = true 112 | message('G2D implementation is too old and not based on DPU; restricting calls to one thread') 113 | endif 114 | 115 | if g2d_calls_restricted_to_one_thread 116 | conf_data.set('IMX2D_G2D_CALLS_RESTRICTED_TO_ONE_THREAD', 1) 117 | endif 118 | 119 | message('imx2d G2D backend enabled') 120 | else 121 | imx2d_backend_g2d_dep = dependency('', required: false) 122 | if g2d_option.disabled() 123 | message('imx2d G2D backend disabled explicitely by command line option') 124 | else 125 | message('imx2d G2D backend disabled due to missing G2D dependency') 126 | endif 127 | endif 128 | -------------------------------------------------------------------------------- /gst-libs/imx2d/backend/ipu/ipu_blitter.h: -------------------------------------------------------------------------------- 1 | #ifndef IMX2D_BACKEND_IPU_BLITTER_H 2 | #define IMX2D_BACKEND_IPU_BLITTER_H 3 | 4 | #include 5 | 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | 12 | /** 13 | * imx_2d_backend_ipu_blitter_create: 14 | * 15 | * Creates a new @Imx2dBlitter that uses the i.MX6 IPU for blitting. 16 | * 17 | * To destroy the created blitter, use @imx_2d_blitter_destroy. 18 | * 19 | * Returns: Pointer to a newly created IPU blitter, or NULL in case of failure. 20 | */ 21 | Imx2dBlitter* imx_2d_backend_ipu_blitter_create(void); 22 | 23 | /** 24 | * imx_2d_backend_ipu_get_hardware_capabilities: 25 | * 26 | * Returns a const pointer to a static structure that contains 27 | * information about the IPU-based hardware capabilities. 28 | * 29 | * @Returns Const pointer to the @Imx2dHardwareCapabilities structure. 30 | * This structure is static, and does not have to be freed in any way. 31 | */ 32 | Imx2dHardwareCapabilities const * imx_2d_backend_ipu_get_hardware_capabilities(void); 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | 40 | #endif /* IMX2D_BACKEND_IPU_BLITTER_H */ 41 | -------------------------------------------------------------------------------- /gst-libs/imx2d/backend/ipu/meson.build: -------------------------------------------------------------------------------- 1 | ipu_option = get_option('ipu') 2 | 3 | ipu_specific_c_args = ['-std=gnu99'] 4 | 5 | if imx_headers_path != '' 6 | ipu_specific_c_args += ['-I' + imx_headers_path] 7 | message('Looking for IPU headers in path "' + imx_headers_path + '"') 8 | endif 9 | 10 | ipu_header_found = cc.check_header( 11 | 'linux/ipu.h', 12 | required : ipu_option, 13 | args : ipu_specific_c_args 14 | ) 15 | 16 | if not ipu_header_found 17 | ipu_header_found = cc.check_header( 18 | 'imx/linux/ipu.h', 19 | required : ipu_option, 20 | args : ipu_specific_c_args 21 | ) 22 | conf_data.set('IPU_HEADER_IS_IN_IMX_SUBDIR', 1) 23 | endif 24 | 25 | if ipu_header_found 26 | imx2d_backend_ipu = static_library( 27 | 'imx2d_backend_ipu', 28 | ['ipu_blitter.c'], 29 | install : false, 30 | include_directories: [configinc], 31 | c_args : ipu_specific_c_args, 32 | dependencies : [imx2d_dep] 33 | ) 34 | 35 | imx2d_backend_ipu_dep = declare_dependency( 36 | dependencies : [imx2d_dep], 37 | link_with : [imx2d_backend_ipu] 38 | ) 39 | 40 | conf_data.set('WITH_IMX2D_IPU_BACKEND', 1) 41 | 42 | message('imx2d IPU backend enabled') 43 | else 44 | imx2d_backend_ipu_dep = dependency('', required: false) 45 | if ipu_option.disabled() 46 | message('imx2d IPU backend disabled explicitely by command line option') 47 | else 48 | message('imx2d IPU backend disabled due to missing IPU dependency') 49 | endif 50 | endif 51 | -------------------------------------------------------------------------------- /gst-libs/imx2d/backend/pxp/meson.build: -------------------------------------------------------------------------------- 1 | pxp_option = get_option('pxp') 2 | 3 | pxp_specific_c_args = [] 4 | 5 | if imx_headers_path != '' 6 | pxp_specific_c_args += ['-I' + imx_headers_path] 7 | message('Looking for PxP headers in path "' + imx_headers_path + '"') 8 | elif sys_root != '' 9 | # Also try this path, since linux/pxp_device.h includes linux/pxp_dma.h, 10 | # and the latter won't be found if the path to the imx headers is not present. 11 | pxp_sys_root_path = join_paths(sys_root , 'usr', 'include', 'imx') 12 | pxp_specific_c_args += ['-I' + pxp_sys_root_path] 13 | message('Looking for PxP headers in path "' + pxp_sys_root_path + '"') 14 | endif 15 | 16 | pxp_header_found = cc.check_header( 17 | 'linux/pxp_device.h', 18 | required : pxp_option, 19 | args : pxp_specific_c_args 20 | ) 21 | 22 | if not pxp_header_found 23 | pxp_header_found = cc.check_header( 24 | 'imx/linux/pxp_device.h', 25 | required : pxp_option, 26 | args : pxp_specific_c_args 27 | ) 28 | conf_data.set('PXP_HEADER_IS_IN_IMX_SUBDIR', 1) 29 | endif 30 | 31 | if pxp_header_found 32 | imx2d_backend_pxp = static_library( 33 | 'imx2d_backend_pxp', 34 | ['pxp_blitter.c'], 35 | install : false, 36 | include_directories: [configinc], 37 | c_args : pxp_specific_c_args, 38 | dependencies : [imx2d_dep] 39 | ) 40 | 41 | imx2d_backend_pxp_dep = declare_dependency( 42 | dependencies : [imx2d_dep], 43 | link_with : [imx2d_backend_pxp] 44 | ) 45 | 46 | conf_data.set('WITH_IMX2D_PXP_BACKEND', 1) 47 | 48 | message('imx2d PxP backend enabled') 49 | else 50 | imx2d_backend_pxp_dep = dependency('', required: false) 51 | if pxp_option.disabled() 52 | message('imx2d PxP backend disabled explicitely by command line option') 53 | else 54 | message('imx2d PxP backend disabled due to missing PxP dependency') 55 | endif 56 | endif 57 | -------------------------------------------------------------------------------- /gst-libs/imx2d/backend/pxp/pxp_blitter.h: -------------------------------------------------------------------------------- 1 | #ifndef IMX2D_BACKEND_PXP_BLITTER_H 2 | #define IMX2D_BACKEND_PXP_BLITTER_H 3 | 4 | #include 5 | 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | 12 | /** 13 | * imx_2d_backend_pxp_blitter_create: 14 | * 15 | * Creates a new @Imx2dBlitter that uses the i.MX6 Pixel Pipeline (PxP). 16 | * 17 | * To destroy the created blitter, use @imx_2d_blitter_destroy. 18 | * 19 | * Returns: Pointer to a newly created PxP blitter, or NULL in case of failure. 20 | */ 21 | Imx2dBlitter* imx_2d_backend_pxp_blitter_create(void); 22 | 23 | /** 24 | * imx_2d_backend_pxp_get_hardware_capabilities: 25 | * 26 | * Returns a const pointer to a static structure that contains 27 | * information about the PxP-based hardware capabilities. 28 | * 29 | * @Returns Const pointer to the @Imx2dHardwareCapabilities structure. 30 | * This structure is static, and does not have to be freed in any way. 31 | */ 32 | Imx2dHardwareCapabilities const * imx_2d_backend_pxp_get_hardware_capabilities(void); 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | 40 | #endif /* IMX2D_BACKEND_PXP_BLITTER_H */ 41 | -------------------------------------------------------------------------------- /gst-libs/imx2d/imx2d_priv.h: -------------------------------------------------------------------------------- 1 | #ifndef IMX2D_PRIV_H 2 | #define IMX2D_PRIV_H 3 | 4 | #include "imx2d.h" 5 | 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | 12 | #ifndef TRUE 13 | #define TRUE (1) 14 | #endif 15 | 16 | 17 | #ifndef FALSE 18 | #define FALSE (0) 19 | #endif 20 | 21 | 22 | #ifndef BOOL 23 | #define BOOL int 24 | #endif 25 | 26 | 27 | #ifndef MIN 28 | #define MIN(a,b) (((a) <= (b)) ? (a) : (b)) 29 | #endif 30 | 31 | 32 | #ifndef MAX 33 | #define MAX(a,b) (((a) >= (b)) ? (a) : (b)) 34 | #endif 35 | 36 | 37 | #define IMX_2D_UNUSED_PARAM(x) ((void)(x)) 38 | 39 | 40 | #define IMX_2D_LOG_FULL(LEVEL, FILE_, LINE_, FUNCTION_, ...) \ 41 | do \ 42 | { \ 43 | if (imx_2d_cur_log_level_threshold >= IMX_2D_LOG_LEVEL_ ## LEVEL) \ 44 | { \ 45 | imx_2d_cur_logging_fn(IMX_2D_LOG_LEVEL_ ## LEVEL, FILE_, LINE_, FUNCTION_, __VA_ARGS__); \ 46 | } \ 47 | } while(0) 48 | 49 | 50 | #define IMX_2D_LOG(LEVEL, ...) \ 51 | IMX_2D_LOG_FULL(LEVEL, __FILE__, __LINE__, __func__, __VA_ARGS__) 52 | 53 | 54 | extern Imx2dLogLevel imx_2d_cur_log_level_threshold; 55 | extern Imx2dLoggingFunc imx_2d_cur_logging_fn; 56 | 57 | 58 | typedef struct _Imx2dSurfaceClass Imx2dSurfaceClass; 59 | typedef struct _Imx2dInternalBlitParams Imx2dInternalBlitParams; 60 | typedef struct _Imx2dInternalFillRegionParams Imx2dInternalFillRegionParams; 61 | 62 | 63 | struct _Imx2dSurface 64 | { 65 | Imx2dSurfaceDesc desc; 66 | Imx2dRegion region; 67 | ImxDmaBuffer *dma_buffers[3]; 68 | int dma_buffer_offsets[3]; 69 | }; 70 | 71 | 72 | struct _Imx2dBlitter 73 | { 74 | Imx2dBlitterClass *blitter_class; 75 | Imx2dSurface *dest; 76 | }; 77 | 78 | 79 | /* source_region and dest_region can be NULL, in which case 80 | * the entire source/dest surface region is used. 81 | * If expanded_dest_region is NULL, then the expanded region 82 | * equals the dest region (either dest_region or dest->region, 83 | * as explained above). 84 | * The alpha value in margin_fill_color is premultiplied. */ 85 | struct _Imx2dInternalBlitParams 86 | { 87 | Imx2dSurface *source; 88 | Imx2dRegion const *source_region; 89 | Imx2dRegion const *dest_region; 90 | Imx2dRotation rotation; 91 | Imx2dRegion const *expanded_dest_region; 92 | int dest_surface_alpha; 93 | uint32_t margin_fill_color; 94 | Imx2dColorimetry colorimetry; 95 | }; 96 | 97 | 98 | struct _Imx2dInternalFillRegionParams 99 | { 100 | Imx2dRegion const *dest_region; 101 | uint32_t fill_color; 102 | }; 103 | 104 | 105 | struct _Imx2dBlitterClass 106 | { 107 | void (*destroy)(Imx2dBlitter *blitter); 108 | 109 | int (*start)(Imx2dBlitter *blitter); 110 | int (*finish)(Imx2dBlitter *blitter); 111 | 112 | int (*do_blit)(Imx2dBlitter *blitter, Imx2dInternalBlitParams *internal_blit_params); 113 | int (*fill_region)(Imx2dBlitter *blitter, Imx2dInternalFillRegionParams *internal_fill_region_params); 114 | 115 | Imx2dHardwareCapabilities const * (*get_hardware_capabilities)(Imx2dBlitter *blitter); 116 | }; 117 | 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | 124 | #endif /* IMX2D_PRIV_H */ 125 | -------------------------------------------------------------------------------- /gst-libs/imx2d/linux_framebuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef IMX_2D_LINUX_FRAMEBUFFER_H 2 | #define IMX_2D_LINUX_FRAMEBUFFER_H 3 | 4 | #include "imx2d.h" 5 | 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | 12 | /** 13 | * Imx2dLinuxFramebuffer: 14 | * 15 | * Wrapper for Linux framebuffer devices. This incorporates 16 | * an Imx2dSurface that can be used as a target for blitting. 17 | * 18 | * This also allows for page flipping, which is useful for 19 | * preventing tearing by enabling vertical blank ("vblank") 20 | * synchronization ("vsync"). Page flipping is tied to vsync. 21 | * A new frame can be written into page A while page B is 22 | * being displayed, and then, the framebuffer can be made 23 | * to switch to page A at the time of the next vblank. 24 | * Note that using page flipping will change the physical 25 | * address of the wrapped DMA buffer of the surface, so 26 | * do not do page flipping while an imx2d sequene is ongoing 27 | * (see @imx_2d_blitter_start). 28 | */ 29 | typedef struct _Imx2dLinuxFramebuffer Imx2dLinuxFramebuffer; 30 | 31 | /** 32 | * imx_2d_linux_framebuffer_create: 33 | * @device_name: Device name of the framebuffer to access. 34 | * @enable_page_flipping: Whether or not to enable page flipping (nonzero = yes, zero = no). 35 | * 36 | * Creates a new framebuffer wrapper. 37 | * 38 | * See @Imx2dLinuxFramebuffer for notes about page flipping. 39 | * If @enable_page_flipping is nonzero, the Linux framebuffer 40 | * specified by @device_name has its virtual height enlarged 41 | * to accomodate for sufficient pages (unless said virtual 42 | * height is large enough already). Page flipping is done by 43 | * setting the write position in the framebuffer and the 44 | * display Y offset the framebuffer reads pixels from. 45 | * Both of these are reset back to zero when this framebuffer 46 | * wrapper is destroyed by @imx_2d_linux_framebuffer_destroy. 47 | * The virtual framebuffer height is also reset to its original 48 | * size (if it was adjusted earlier). 49 | * 50 | * Returns: Pointer to new framebuffer wrapper, or NULL if 51 | * an error occurred (in this case, any changes made 52 | * to the framebuffer configuration are rolled back 53 | * before this function finishes). 54 | */ 55 | Imx2dLinuxFramebuffer* imx_2d_linux_framebuffer_create(char const *device_name, int enable_page_flipping); 56 | 57 | /** 58 | * imx_2d_linux_framebuffer_destroy: 59 | * @linux_framebuffer: Framebuffer wrapper to destroy. 60 | * 61 | * Destroys the given framebuffer wrapper. Any adjustments 62 | * made to the Linux framebuffer are rolled back. 63 | * 64 | * The pointer to the wrapper is invalid after this call 65 | * and must not be used anymore. 66 | */ 67 | void imx_2d_linux_framebuffer_destroy(Imx2dLinuxFramebuffer *linux_framebuffer); 68 | 69 | /** 70 | * imx_2d_linux_framebuffer_get_surface: 71 | * @linux_framebuffer: Framebuffer wrapper to get a surface from. 72 | * 73 | * This returns the surface that represents the region of the 74 | * framebuffer that can be written to. If page flipping is not 75 | * used (see @imx_2d_linux_framebuffer_create), this is the same 76 | * region as the one that is currently being displayed. 77 | * 78 | * Returns: The @Imx2dSurface that wraps the framebuffer. 79 | */ 80 | Imx2dSurface* imx_2d_linux_framebuffer_get_surface(Imx2dLinuxFramebuffer *linux_framebuffer); 81 | 82 | /** 83 | * imx_2d_linux_framebuffer_get_num_fb_pages: 84 | * @linux_framebuffer: Framebuffer wrapper to get the number of available pages from. 85 | * 86 | * This return value never changes after creating the framebuffer wrapper, 87 | * so it can be safely cached. If page flipping is not enabled (see 88 | * @imx_2d_linux_framebuffer_create), the return value is 1. 89 | * 90 | * Returns: Number of pages available for writing / displaying. 91 | */ 92 | int imx_2d_linux_framebuffer_get_num_fb_pages(Imx2dLinuxFramebuffer *linux_framebuffer); 93 | 94 | /** 95 | * @imx_2d_linux_framebuffer_set_write_fb_page: 96 | * @linux_framebuffer: Framebuffer wrapper to set the write target FB page of. 97 | * @page Page number to set as the write taget. 98 | * 99 | * This is only useful if page flipping is enabled (see @imx_2d_linux_framebuffer_create). 100 | * 101 | * This sets the target of write (= blit) operations. @page must be a number in the 102 | * range 0 .. (num-pages - 1), where num-pages is the return value of 103 | * @imx_2d_linux_framebuffer_get_num_fb_pages. 104 | * 105 | * IMPORTANT: This modifies the physical address of the surface associated with 106 | * this framebuffer wrapper (see @imx_2d_linux_framebuffer_get_surface). Do not call 107 | * this while a sequence is ongoing (see @imx_2d_blitter_start). 108 | */ 109 | void imx_2d_linux_framebuffer_set_write_fb_page(Imx2dLinuxFramebuffer *linux_framebuffer, int page); 110 | 111 | /** 112 | * @imx_2d_linux_framebuffer_set_write_fb_page: 113 | * @linux_framebuffer: Framebuffer wrapper to set the display FB page of. 114 | * @page Page number to set as the one to display. 115 | * 116 | * This is only useful if page flipping is enabled (see @imx_2d_linux_framebuffer_create). 117 | * 118 | * This sets the page that the framebuffer shall show on screen. @page must be 119 | * a number in the range 0 .. (num-pages - 1), where num-pages is the return value 120 | * of @imx_2d_linux_framebuffer_get_num_fb_pages. 121 | * 122 | * Returns: Nonzero if the call succeeds, zero on failure. 123 | */ 124 | int imx_2d_linux_framebuffer_set_display_fb_page(Imx2dLinuxFramebuffer *linux_framebuffer, int page); 125 | 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | 132 | #endif /* IMX_2D_LINUX_FRAMEBUFFER_H */ 133 | -------------------------------------------------------------------------------- /gst-libs/imx2d/meson.build: -------------------------------------------------------------------------------- 1 | imx2d = static_library( 2 | 'imx2d', 3 | ['imx2d.c', 'linux_framebuffer.c'], 4 | install : false, 5 | include_directories : libsinc, 6 | dependencies : [libimxdmabuffer_dep] 7 | ) 8 | 9 | imx2d_dep = declare_dependency( 10 | dependencies : [libimxdmabuffer_dep], 11 | include_directories : libsinc, 12 | link_with : [imx2d] 13 | ) 14 | 15 | subdir('backend/g2d') 16 | subdir('backend/ipu') 17 | subdir('backend/pxp') 18 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('gstreamer-imx', 'c', default_options : ['c_std=c99'], version : '2.2.0', license: 'LGPL-2.0-or-later', meson_version: '>= 0.53.2') 2 | 3 | message('Setting up build configuration for gstreamer-imx version ' + meson.project_version()) 4 | 5 | 6 | cc = meson.get_compiler('c') 7 | pkg = import('pkgconfig') 8 | 9 | 10 | # test for miscellaneous system libraries 11 | 12 | libdl_dep = cc.find_library('dl', required : true) 13 | libm_dep = cc.find_library('m', required : true) 14 | 15 | 16 | # test for libimxdmabuffer 17 | 18 | libimxdmabuffer_dep = dependency('libimxdmabuffer', version : '>=1.1.2', required : true, method : 'pkg-config') 19 | 20 | dmabuf_allocator_available = false 21 | 22 | dma_heap_support = cc.compiles( 23 | ''' 24 | #include 25 | #ifndef IMXDMABUFFER_DMA_HEAP_ALLOCATOR_ENABLED 26 | #error dma-heap support is disabled 27 | #endif 28 | ''', 29 | dependencies : [libimxdmabuffer_dep], 30 | name : 'dma-heap allocator support' 31 | ) 32 | if dma_heap_support 33 | message('libimxdmabuffer supports dma-heap allocation - enabling dma-heap GstAllocator') 34 | dmabuf_allocator_available = true 35 | else 36 | message('libimxdmabuffer does not support dma-heap allocation - not enabling dma-heap GstAllocator') 37 | endif 38 | 39 | ion_support = cc.compiles( 40 | ''' 41 | #include 42 | #ifndef IMXDMABUFFER_ION_ALLOCATOR_ENABLED 43 | #error ION support is disabled 44 | #endif 45 | ''', 46 | dependencies : [libimxdmabuffer_dep], 47 | name : 'ION allocator support' 48 | ) 49 | if ion_support 50 | message('libimxdmabuffer supports ION allocation - enabling ION GstAllocator') 51 | dmabuf_allocator_available = true 52 | else 53 | message('libimxdmabuffer does not support ION allocation - not enabling ION GstAllocator') 54 | endif 55 | 56 | 57 | # test for GStreamer libraries 58 | 59 | gstreamer_dep = dependency('gstreamer-1.0', version : '>=1.14.0', required : true) 60 | gstreamer_base_dep = dependency('gstreamer-base-1.0', version : '>=1.14.0', required : true) 61 | gstreamer_allocators_dep = dependency('gstreamer-allocators-1.0', version : '>=1.14.0', required : true) 62 | gstreamer_audio_dep = dependency('gstreamer-audio-1.0', version : '>=1.14.0', required : false) 63 | gstreamer_video_dep = dependency('gstreamer-video-1.0', version : '>=1.14.0', required : false) 64 | 65 | if gstreamer_audio_dep.found() 66 | message('found gstaudio library - building audio plugins') 67 | else 68 | message('could not find gstaudio library - not building audio plugins') 69 | endif 70 | 71 | if gstreamer_video_dep.found() 72 | message('found gstvideo library - building video plugins') 73 | else 74 | message('could not find gstvideo library - not building video plugins') 75 | endif 76 | 77 | 78 | plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0') 79 | 80 | 81 | imx_headers_path = get_option('imx-headers-path') 82 | sys_root = get_option('sysroot') 83 | if sys_root != '' 84 | message('Using sysroot from command line argument: "' + sys_root + '"') 85 | else 86 | if meson.version().version_compare('>= 0.54.0') 87 | sys_root = meson.get_external_property('sys_root', '', native: false) 88 | message('Using sysroot from meson external properties: "' + sys_root + '"') 89 | else 90 | error('sysroot must be specified as a build option when using Meson older than 0.54.0') 91 | endif 92 | endif 93 | 94 | 95 | configinc = include_directories('.') 96 | libsinc = include_directories('gst-libs') 97 | 98 | 99 | conf_data = configuration_data() 100 | conf_data.set_quoted('GST_PACKAGE_NAME', get_option('package-name')) 101 | conf_data.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin')) 102 | conf_data.set_quoted('PACKAGE', 'gstreamer-imx') 103 | conf_data.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/Freescale/gstreamer-imx') 104 | conf_data.set_quoted('VERSION', meson.project_version()) 105 | if dma_heap_support 106 | conf_data.set('WITH_GST_DMA_HEAP_ALLOCATOR', 1) 107 | endif 108 | if ion_support 109 | conf_data.set('WITH_GST_ION_ALLOCATOR', 1) 110 | endif 111 | if dmabuf_allocator_available 112 | conf_data.set('GST_DMABUF_ALLOCATOR_AVAILABLE', 1) 113 | endif 114 | 115 | 116 | subdir('gst-libs/imx2d') 117 | subdir('gst-libs/gst/imx/common') 118 | subdir('gst-libs/gst/imx/video') 119 | subdir('ext/vpu') 120 | subdir('ext/audio') 121 | subdir('ext/imx2d') 122 | subdir('sys/v4l2video') 123 | 124 | 125 | configure_file(output : 'config.h', configuration : conf_data) 126 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('vpu', type : 'feature', value : 'auto', description : 'hardware accelerated video en/decoding elements using the NXP i.MX VPU') 2 | 3 | option('uniaudiodec', type : 'feature', value : 'auto', description : 'Audio decoder element using the NXP uniaudio codecs') 4 | option('mp3encoder', type : 'feature', value : 'auto', description : 'mp3 encoder element using the NXP mp3 encoder library') 5 | 6 | option('g2d', type : 'feature', value : 'auto', description : '2D elements using the Vivante G2D API') 7 | option('g2d-based-on-dpu', type : 'boolean', value : false, description : 'Whether or not the G2D implementation is emulated on top of the i.MX8qm or i.MX8qxp DPU') 8 | 9 | option('ipu', type : 'feature', value : 'auto', description : '2D elements using the i.MX6 Image Processing Unit (IPU)') 10 | 11 | option('pxp', type : 'feature', value : 'auto', description : '2D elements using the i.MX6 Pixel Pipeline (PxP)') 12 | 13 | option('imx-headers-path', type : 'string', value : '', description : 'path to the extra imx kernel headers') 14 | option('sysroot', type : 'string', value : '', description : 'sysroot path (if empty, the sysroot path from the meson external properties is used)') 15 | 16 | option('imx2d-videosink', type : 'boolean', value : true) 17 | option('imx2d-compositor', type : 'feature', value : 'auto') 18 | 19 | option('v4l2', type : 'boolean', value : true, description : 'build mxc_v4l2 specific V4L2 source and sink elements (deprecated; use v4l2-mxc-source-sink instead)') 20 | option('v4l2-mxc-source-sink', type : 'boolean', value : true, description : 'build mxc_v4l2 specific V4L2 source and sink elements') 21 | option('v4l2-isi', type : 'boolean', value : true, description : 'build V4L2 ISI video transform element') 22 | option('v4l2-amphion', type : 'feature', value : 'auto', description : 'build Amphion Windsor/Malone V4L2 mem2mem based en/decoders (requires G2D; "auto" skips this if G2D is not available)') 23 | 24 | option('package-name', type : 'string', value : 'Unknown package name', yield : true, description : 'package name to use in plugins') 25 | option('package-origin', type : 'string', value : 'Unknown package origin', yield : true, description : 'package origin URL to use in plugins') 26 | -------------------------------------------------------------------------------- /sys/v4l2video/gstimxv4l2amphiondec.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_V4L2_AMPHION_DEC_H 20 | #define GST_IMX_V4L2_AMPHION_DEC_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_V4L2_AMPHION_DEC (gst_imx_v4l2_amphion_dec_get_type()) 29 | #define GST_IMX_V4L2_AMPHION_DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_V4L2_AMPHION_DEC, GstImxV4L2AmphionDec)) 30 | #define GST_IMX_V4L2_AMPHION_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_V4L2_AMPHION_DEC, GstImxV4L2AmphionDecClass)) 31 | #define GST_IMX_V4L2_AMPHION_DEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_V4L2_AMPHION_DEC, GstImxV4L2AmphionDecClass)) 32 | #define GST_IMX_V4L2_AMPHION_DEC_CAST(obj) ((GstImxV4L2AmphionDec *)(obj)) 33 | #define GST_IS_IMX_V4L2_AMPHION_DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_V4L2_AMPHION_DEC)) 34 | #define GST_IS_IMX_V4L2_AMPHION_DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_V4L2_AMPHION_DEC)) 35 | 36 | 37 | typedef struct _GstImxV4L2AmphionDec GstImxV4L2AmphionDec; 38 | typedef struct _GstImxV4L2AmphionDecClass GstImxV4L2AmphionDecClass; 39 | 40 | 41 | GType gst_imx_v4l2_amphion_dec_get_type(void); 42 | 43 | gboolean gst_imx_v4l2_amphion_dec_register_decoder_types(GstPlugin *plugin); 44 | 45 | 46 | G_END_DECLS 47 | 48 | 49 | #endif /* GST_IMX_V4L2_AMPHION_DEC_H */ 50 | -------------------------------------------------------------------------------- /sys/v4l2video/gstimxv4l2amphionmisc.h: -------------------------------------------------------------------------------- 1 | #ifndef GST_IMX_V4L2_AMPHION_MISCs_H 2 | #define GST_IMX_V4L2_AMPHION_MISC_H 3 | 4 | #include 5 | 6 | 7 | G_BEGIN_DECLS 8 | 9 | 10 | /* Extra V4L2 FourCC's specific to the Amphion Malone decoder. */ 11 | 12 | #ifndef V4L2_VPU_PIX_FMT_VP6 13 | #define V4L2_VPU_PIX_FMT_VP6 v4l2_fourcc('V', 'P', '6', '0') 14 | #endif 15 | 16 | #ifndef V4L2_VPU_PIX_FMT_AVS 17 | #define V4L2_VPU_PIX_FMT_AVS v4l2_fourcc('A', 'V', 'S', '0') 18 | #endif 19 | 20 | #ifndef V4L2_VPU_PIX_FMT_RV 21 | #define V4L2_VPU_PIX_FMT_RV v4l2_fourcc('R', 'V', '0', '0') 22 | #endif 23 | 24 | #ifndef V4L2_VPU_PIX_FMT_VP6 25 | #define V4L2_VPU_PIX_FMT_VP6 v4l2_fourcc('V', 'P', '6', '0') 26 | #endif 27 | 28 | #ifndef V4L2_VPU_PIX_FMT_SPK 29 | #define V4L2_VPU_PIX_FMT_SPK v4l2_fourcc('S', 'P', 'K', '0') 30 | #endif 31 | 32 | #ifndef V4L2_VPU_PIX_FMT_DIV3 33 | #define V4L2_VPU_PIX_FMT_DIV3 v4l2_fourcc('D', 'I', 'V', '3') 34 | #endif 35 | 36 | #ifndef V4L2_VPU_PIX_FMT_DIVX 37 | #define V4L2_VPU_PIX_FMT_DIVX v4l2_fourcc('D', 'I', 'V', 'X') 38 | #endif 39 | 40 | #ifndef V4L2_PIX_FMT_NV12_10BIT 41 | #define V4L2_PIX_FMT_NV12_10BIT v4l2_fourcc('N', 'T', '1', '2') /* Y/CbCr 4:2:0 for 10bit */ 42 | #endif 43 | 44 | 45 | #define GST_IMX_V4L2_AMPHION_DEVICE_FILENAME_LENGTH 512 46 | 47 | typedef struct 48 | { 49 | gboolean initialized; 50 | char decoder_filename[GST_IMX_V4L2_AMPHION_DEVICE_FILENAME_LENGTH]; 51 | char encoder_filename[GST_IMX_V4L2_AMPHION_DEVICE_FILENAME_LENGTH]; 52 | } 53 | GstImxV4L2AmphionDeviceFilenames; 54 | 55 | extern GstImxV4L2AmphionDeviceFilenames gst_imx_v4l2_amphion_device_filenames; 56 | 57 | void gst_imx_v4l2_amphion_device_filenames_init(void); 58 | 59 | 60 | GstCaps* gst_imx_v4l2_amphion_get_caps_for_format(guint32 v4l2_pixelformat); 61 | 62 | 63 | G_END_DECLS 64 | 65 | 66 | #endif /* GST_IMX_V4L2_AMPHION_MISC_H */ 67 | -------------------------------------------------------------------------------- /sys/v4l2video/gstimxv4l2isivideotransform.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2022 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_V4L2_ISI_VIDEO_TRANSFORM_H 20 | #define GST_IMX_V4L2_ISI_VIDEO_TRANSFORM_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_V4L2_ISI_VIDEO_TRANSFORM (gst_imx_v4l2_isi_video_transform_get_type()) 29 | #define GST_IMX_V4L2_ISI_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_V4L2_ISI_VIDEO_TRANSFORM, GstImxV4L2ISIVideoTransform)) 30 | #define GST_IMX_V4L2_ISI_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_V4L2_ISI_VIDEO_TRANSFORM, GstImxV4L2ISIVideoTransformClass)) 31 | #define GST_IMX_V4L2_ISI_VIDEO_TRANSFORM_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_V4L2_ISI_VIDEO_TRANSFORM, GstImxV4L2ISIVideoTransformClass)) 32 | #define GST_IMX_V4L2_ISI_VIDEO_TRANSFORM_CAST(obj) ((GstImxV4L2ISIVideoTransform *)(obj)) 33 | #define GST_IS_IMX_V4L2_ISI_VIDEO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_V4L2_ISI_VIDEO_TRANSFORM)) 34 | #define GST_IS_IMX_V4L2_ISI_VIDEO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_V4L2_ISI_VIDEO_TRANSFORM)) 35 | 36 | 37 | typedef struct _GstImxV4L2ISIVideoTransform GstImxV4L2ISIVideoTransform; 38 | typedef struct _GstImxV4L2ISIVideoTransformClass GstImxV4L2ISIVideoTransformClass; 39 | 40 | 41 | GType gst_imx_v4l2_isi_video_transform_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_V4L2_ISI_VIDEO_TRANSFORM_H */ 48 | -------------------------------------------------------------------------------- /sys/v4l2video/gstimxv4l2prelude.h: -------------------------------------------------------------------------------- 1 | #ifndef GST_IMX_V4L2_PRELUDE_H 2 | #define GST_IMX_V4L2_PRELUDE_H 3 | 4 | /* This is needed for enabling CLOCK_MONOTONIC and the timespec struct */ 5 | #if __STDC_VERSION__ >= 199901L 6 | #define _XOPEN_SOURCE 600 7 | #else 8 | #define _XOPEN_SOURCE 500 9 | #endif /* __STDC_VERSION__ */ 10 | 11 | #endif /* GST_IMX_V4L2_PRELUDE_H */ 12 | -------------------------------------------------------------------------------- /sys/v4l2video/gstimxv4l2videosink.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_V4L2_VIDEO_SINK_H 20 | #define GST_IMX_V4L2_VIDEO_SINK_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_V4L2_VIDEO_SINK (gst_imx_v4l2_video_sink_get_type()) 29 | #define GST_IMX_V4L2_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_V4L2_VIDEO_SINK, GstImxV4L2VideoSink)) 30 | #define GST_IMX_V4L2_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_V4L2_VIDEO_SINK, GstImxV4L2VideoSinkClass)) 31 | #define GST_IMX_V4L2_VIDEO_SINK_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_V4L2_VIDEO_SINK, GstImxV4L2VideoSinkClass)) 32 | #define GST_IMX_V4L2_VIDEO_SINK_CAST(obj) ((GstImxV4L2VideoSink *)(obj)) 33 | #define GST_IS_IMX_V4L2_VIDEO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_V4L2_VIDEO_SINK)) 34 | #define GST_IS_IMX_V4L2_VIDEO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_V4L2_VIDEO_SINK)) 35 | 36 | 37 | typedef struct _GstImxV4L2VideoSink GstImxV4L2VideoSink; 38 | typedef struct _GstImxV4L2VideoSinkClass GstImxV4L2VideoSinkClass; 39 | 40 | 41 | GType gst_imx_v4l2_video_sink_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_V4L2_VIDEO_SINK_H */ 48 | -------------------------------------------------------------------------------- /sys/v4l2video/gstimxv4l2videosrc.h: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef GST_IMX_V4L2_VIDEO_SRC_H 20 | #define GST_IMX_V4L2_VIDEO_SRC_H 21 | 22 | #include 23 | 24 | 25 | G_BEGIN_DECLS 26 | 27 | 28 | #define GST_TYPE_IMX_V4L2_VIDEO_SRC (gst_imx_v4l2_video_src_get_type()) 29 | #define GST_IMX_V4L2_VIDEO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_IMX_V4L2_VIDEO_SRC, GstImxV4L2VideoSrc)) 30 | #define GST_IMX_V4L2_VIDEO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_IMX_V4L2_VIDEO_SRC, GstImxV4L2VideoSrcClass)) 31 | #define GST_IMX_V4L2_VIDEO_SRC_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_IMX_V4L2_VIDEO_SRC, GstImxV4L2VideoSrcClass)) 32 | #define GST_IMX_V4L2_VIDEO_SRC_CAST(obj) ((GstImxV4L2VideoSrc *)(obj)) 33 | #define GST_IS_IMX_V4L2_VIDEO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_IMX_V4L2_VIDEO_SRC)) 34 | #define GST_IS_IMX_V4L2_VIDEO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_IMX_V4L2_VIDEO_SRC)) 35 | 36 | 37 | typedef struct _GstImxV4L2VideoSrc GstImxV4L2VideoSrc; 38 | typedef struct _GstImxV4L2VideoSrcClass GstImxV4L2VideoSrcClass; 39 | 40 | 41 | GType gst_imx_v4l2_video_src_get_type(void); 42 | 43 | 44 | G_END_DECLS 45 | 46 | 47 | #endif /* GST_IMX_V4L2_VIDEO_SRC_H */ 48 | -------------------------------------------------------------------------------- /sys/v4l2video/meson.build: -------------------------------------------------------------------------------- 1 | source = [] 2 | dependencies = [gstimxcommon_dep, gstreamer_video_dep] 3 | 4 | # mxc_v4l2 elements, available on i.MX6 and i.MX7 SoCs 5 | 6 | v4l2_mxc_source_sink_enabled = get_option('v4l2') and get_option('v4l2-mxc-source-sink') 7 | if v4l2_mxc_source_sink_enabled 8 | message('mxc_v4l2 Video4Linux2 source and sink elements enabled') 9 | 10 | conf_data.set('WITH_IMX_V4L2_VIDEO_SRC', 1) 11 | conf_data.set('WITH_IMX_V4L2_VIDEO_SINK', 1) 12 | 13 | source += [ 14 | 'gstimxv4l2context.c', 15 | 'gstimxv4l2object.c', 16 | 'gstimxv4l2videosrc.c', 17 | 'gstimxv4l2videosink.c', 18 | ] 19 | else 20 | message('mxc_v4l2 Video4Linux2 source and sink elements disabled') 21 | endif 22 | 23 | # V4L2 ISI (Image Sensing Interface) mem2mem transform element, available on i.MX8 QuadMax/QuadXPlus SoCs 24 | 25 | v4l2_isi_enabled = get_option('v4l2-isi') 26 | if v4l2_isi_enabled 27 | message('i.MX8 ISI Video4Linux2 mem2mem transform element enabled') 28 | 29 | conf_data.set('WITH_IMX_V4L2_ISI_VIDEO_TRANSFORM', 1) 30 | 31 | source += [ 32 | 'gstimxv4l2isivideotransform.c', 33 | ] 34 | dependencies += [gstimxvideo_dep] 35 | else 36 | message('i.MX8 ISI Video4Linux2 mem2mem transform element disabled') 37 | endif 38 | 39 | # V4L2 Amphion Malone mem2mem video decoder element, available on i.MX8 QuadMax/QuadXPlus SoCs 40 | 41 | v4l2_amphion_option = get_option('v4l2-amphion') 42 | v4l2_amphion_enabled = false 43 | if v4l2_amphion_option.disabled() 44 | message('Amphion Malone Video4Linux2 mem2mem decoder element disabled') 45 | else 46 | if imx2d_backend_g2d_dep.found() 47 | if not conf_data.get('IMX2D_G2D_AMPHION_TILE_LAYOUT_SUPPORTED') 48 | if v4l2_amphion_option.enabled() 49 | error('Amphion Malone Video4Linux2 mem2mem decoder element enabled, but G2D does not support the Amphion tile layout') 50 | else 51 | message('Amphion Malone Video4Linux2 mem2mem decoder element enabled, but G2D does not support the Amphion tile layout; disabling decoder element') 52 | endif 53 | elif not conf_data.get('IMX2D_G2D_AMPHION_10BIT_TILE_LAYOUT_SUPPORTED') 54 | if v4l2_amphion_option.enabled() 55 | error('Amphion Malone Video4Linux2 mem2mem decoder element enabled, but G2D does not support the 10-bit Amphion tile layout') 56 | else 57 | message('Amphion Malone Video4Linux2 mem2mem decoder element enabled, but G2D does not support the 10-bit Amphion tile layout; disabling decoder element') 58 | endif 59 | else 60 | message('Amphion Malone Video4Linux2 mem2mem decoder element enabled') 61 | v4l2_amphion_enabled = true 62 | endif 63 | else 64 | if v4l2_amphion_option.enabled() 65 | error('Amphion Malone Video4Linux2 mem2mem decoder element enabled, but G2D is not available') 66 | else 67 | message('Amphion Malone Video4Linux2 mem2mem decoder element enabled, but G2D is not available; disabling decoder element') 68 | endif 69 | endif 70 | endif 71 | 72 | if v4l2_amphion_enabled 73 | conf_data.set('WITH_IMX_V4L2_AMPHION_DECODER', 1) 74 | 75 | source += [ 76 | 'gstimxv4l2amphiondec.c', 77 | 'gstimxv4l2amphionmisc.c', 78 | ] 79 | dependencies += [imx2d_dep, imx2d_backend_g2d_dep, gstimxvideo_dep] 80 | endif 81 | 82 | # Common code and the actual GStreamer plugin shared object 83 | 84 | if v4l2_mxc_source_sink_enabled or v4l2_isi_enabled or v4l2_amphion_enabled 85 | source += [ 86 | 'gstimxv4l2videoformat.c', 87 | 'plugin.c' 88 | ] 89 | endif 90 | 91 | if source != [] 92 | library( 93 | 'gstimxv4l2video', 94 | source, 95 | install : true, 96 | install_dir: plugins_install_dir, 97 | include_directories: [configinc, libsinc], 98 | dependencies: dependencies 99 | ) 100 | endif 101 | -------------------------------------------------------------------------------- /sys/v4l2video/plugin.c: -------------------------------------------------------------------------------- 1 | /* gstreamer-imx: GStreamer plugins for the i.MX SoCs 2 | * Copyright (C) 2021 Carlos Rafael Giani 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Library General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Library General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this library; if not, write to the Free 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #ifdef WITH_IMX_V4L2_VIDEO_SRC 22 | #include "gstimxv4l2videosrc.h" 23 | #endif 24 | #ifdef WITH_IMX_V4L2_VIDEO_SINK 25 | #include "gstimxv4l2videosink.h" 26 | #endif 27 | #ifdef WITH_IMX_V4L2_ISI_VIDEO_TRANSFORM 28 | #include "gstimxv4l2isivideotransform.h" 29 | #endif 30 | #ifdef WITH_IMX_V4L2_AMPHION_DECODER 31 | #include "gstimxv4l2amphiondec.h" 32 | #endif 33 | 34 | 35 | GST_DEBUG_CATEGORY(imx_v4l2_utils_debug); 36 | GST_DEBUG_CATEGORY(imx_v4l2_format_debug); 37 | GST_DEBUG_CATEGORY(imx_v4l2_amphion_misc_debug); 38 | 39 | 40 | static gboolean plugin_init(GstPlugin *plugin) 41 | { 42 | GST_DEBUG_CATEGORY_INIT(imx_v4l2_utils_debug, "imxv4l2utils", 0, "NXP i.MX V4L2 utility functions"); 43 | GST_DEBUG_CATEGORY_INIT(imx_v4l2_format_debug, "imxv4l2format", 0, "NXP i.MX V4L2 formats functions"); 44 | GST_DEBUG_CATEGORY_INIT(imx_v4l2_amphion_misc_debug, "imxv4l2amphiondevices", 0, "NXP i.MX Amphion V4L2 miscellaneous functions"); 45 | 46 | gboolean ret = TRUE; 47 | #ifdef WITH_IMX_V4L2_VIDEO_SRC 48 | ret = ret && gst_element_register(plugin, "imxv4l2videosrc", GST_RANK_PRIMARY, gst_imx_v4l2_video_src_get_type()); 49 | #endif 50 | #ifdef WITH_IMX_V4L2_VIDEO_SINK 51 | ret = ret && gst_element_register(plugin, "imxv4l2videosink", GST_RANK_NONE, gst_imx_v4l2_video_sink_get_type()); 52 | #endif 53 | #ifdef WITH_IMX_V4L2_ISI_VIDEO_TRANSFORM 54 | ret = ret && gst_element_register(plugin, "imxv4l2isivideotransform", GST_RANK_NONE, gst_imx_v4l2_isi_video_transform_get_type()); 55 | #endif 56 | #ifdef WITH_IMX_V4L2_AMPHION_DECODER 57 | ret = gst_imx_v4l2_amphion_dec_register_decoder_types(plugin); 58 | #endif 59 | return ret; 60 | } 61 | 62 | 63 | 64 | GST_PLUGIN_DEFINE( 65 | GST_VERSION_MAJOR, 66 | GST_VERSION_MINOR, 67 | imxv4l2video, 68 | "Video capture and output elements using the Video4Linux2 API on the NXP i.MX 6 platforms", 69 | plugin_init, 70 | VERSION, 71 | "LGPL", 72 | GST_PACKAGE_NAME, 73 | GST_PACKAGE_ORIGIN 74 | ) 75 | --------------------------------------------------------------------------------